eth: skip transaction handling during fast sync #2574
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR's meant to address a transaction handling issue that became a bit more emphasized with the high transaction count of the DAO. During synchronization, nodes do accept, try to process and propagate good transactions to other nodes. This is desirable to prevent DOS attacks.
However, during initial fast sync all the transactions propagated to a node are essentially useless since it cannot do anything with them, and by the time the node finishes syncing, most will be integrated into the chain either way. However, by keeping them in the active pool, it puts a burden on the node to constantly recheck the cached transactions if they should be dumped or still kept around.
This PR disables accepting new transactions while fast sync is in progress, hence taking quite a computational and networking burden off a node's shoulder.
Performance wise with this PR + the concurrent headers a sync from 0 to 1533536 took 24 minutes for me, down from 27 mins a few weeks ago (with less blocks back then). Seems that sync is also a lot more stable, probably due to all that junk transaction traffic not being pushed over network links.
PS: The PR does make one slight change in behavior compared to the old code: if a private network is booted up with every node configured to fast sync, then the network will not forward transactions until the first block is mined and fast sync disabled. Given however that nodes should never assume any timing guarantees about transaction incorporation, this should be a fully negligible scenario.