-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Only perform DAO hard fork challenge if Aleth's top block is >= DAO hard fork block #5579
Description
Aleth contains a DAO hard fork challenge which it issues to potential peers in order to avoid wasting time syncing to ETC nodes. Additional details on the motivation for this challenge are described here: #5540 (comment)
The way the challenge works is that Aleth requests the DAO hard fork block from a potential peer and validates the extradata section of the block. If the peer is an ETC node, the hard fork block won't contain the expected extradata data and Aleth will avoid peering with the node.
The block is requested here:
aleth/libethereum/BlockChainSync.cpp
Lines 204 to 209 in 6de1e88
| // Before starting to exchange the data with the node, let's verify that it's on our chain | |
| if (!requestDaoForkBlockHeader(_peer.id())) | |
| { | |
| // DAO challenge not needed | |
| syncPeer(_peer.id(), false); | |
| } |
The challenge is verified in BlockChainSync::onPeerBlockHeaders:
aleth/libethereum/BlockChainSync.cpp
Lines 444 to 453 in 6de1e88
| if (m_daoChallengedPeers.find(_peerID) != m_daoChallengedPeers.end()) | |
| { | |
| if (verifyDaoChallengeResponse(_r)) | |
| syncPeer(_peerID, false); | |
| else | |
| m_host.disablePeer(_peerID, "Peer from another fork."); | |
| m_daoChallengedPeers.erase(_peerID); | |
| return; | |
| } |
However, this challenge prevents us from syncing blocks with ETC nodes from before the DAO hard fork block. An optimization would be to only perform the DAO hard fork challenge if our top block is >= the DAO hard fork block (1920000).