Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Fix segmentation fault during syncing #5834

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed: [#5821](https://github.com/ethereum/aleth/pull/5821) `test_setChainParams` correctly initializes custom configuration of precompiled contracts.
- Fixed: [#5826](https://github.com/ethereum/aleth/pull/5826) Fix blocking bug in database rebuild functionality - users can now rebuild their databases via Aleth's '-R' switch.
- Fixed: [#5827](https://github.com/ethereum/aleth/pull/5827) Detect database upgrades and automatically rebuild the database when they occur.
- Fixed: [#5834](https://github.com/ethereum/aleth/pull/5834) Fix segmentation fault during sync.

## [1.7.1] - 2019-11-18

Expand Down
16 changes: 8 additions & 8 deletions libethereum/EthereumCapability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ void EthereumCapability::onDisconnect(NodeID const& _peerID)
bool EthereumCapability::interpretCapabilityPacket(
NodeID const& _peerID, unsigned _id, RLP const& _r)
{
auto& peer = m_peers[_peerID];
peer.setLastAsk(std::chrono::system_clock::to_time_t(chrono::system_clock::now()));
auto& remotePeer = peer(_peerID);
remotePeer.setLastAsk(std::chrono::system_clock::to_time_t(chrono::system_clock::now()));

try
{
Expand All @@ -648,10 +648,10 @@ bool EthereumCapability::interpretCapabilityPacket(
<< networkId << " / " << genesisHash << ", TD: " << totalDifficulty
<< " = " << latestHash;

peer.setStatus(
remotePeer.setStatus(
peerProtocolVersion, networkId, totalDifficulty, latestHash, genesisHash);
setIdle(_peerID);
m_peerObserver->onPeerStatus(peer);
m_peerObserver->onPeerStatus(remotePeer);
break;
}
case TransactionsPacket:
Expand Down Expand Up @@ -691,7 +691,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case BlockHeadersPacket:
{
if (peer.asking() != Asking::BlockHeaders)
if (remotePeer.asking() != Asking::BlockHeaders)
LOG(m_loggerImpolite) << "Peer " << _peerID
<< " giving us block headers when we didn't ask for them.";
else
Expand Down Expand Up @@ -724,7 +724,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case BlockBodiesPacket:
{
if (peer.asking() != Asking::BlockBodies)
if (remotePeer.asking() != Asking::BlockBodies)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us block bodies when we didn't ask for them.";
else
Expand Down Expand Up @@ -803,7 +803,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case NodeDataPacket:
{
if (peer.asking() != Asking::NodeData)
if (remotePeer.asking() != Asking::NodeData)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us node data when we didn't ask for them.";
else
Expand All @@ -815,7 +815,7 @@ bool EthereumCapability::interpretCapabilityPacket(
}
case ReceiptsPacket:
{
if (peer.asking() != Asking::Receipts)
if (remotePeer.asking() != Asking::Receipts)
LOG(m_loggerImpolite)
<< "Peer " << _peerID << " giving us receipts when we didn't ask for them.";
else
Expand Down
2 changes: 1 addition & 1 deletion libethereum/EthereumPeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace eth
class EthereumPeer
{
public:
EthereumPeer() = default;
EthereumPeer() = delete;
EthereumPeer(std::shared_ptr<p2p::CapabilityHostFace> _host, NodeID const& _peerID,
u256 const& /*_capabilityVersion*/)
: m_host(std::move(_host)), m_id(_peerID)
Expand Down