-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve pending blocks retrieval mechanism #4227
Improve pending blocks retrieval mechanism #4227
Conversation
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Outdated
Show resolved
Hide resolved
...eum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManager.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/PersistBlockTask.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/hyperledger/besu/ethereum/eth/sync/AbstractBlockPropagationManagerTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
…-Trintinalia/besu into 3955-besu-stop-importing
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
…ancestors of Block Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This goes in the right directions, implementing a basic backward sync to fill gaps in the block propagation, I have reported just a couple of minor things.
During this code review, I have also reviewed the role of maybeProcessNonAnnouncedBlocks
that looks forward, so in the future to try to proactively fetch new blocks, that usually should be notified by peers soon after, so not sure how much it is useful, instead this class was missing something that looks backward, that is probably much needed, not sure if the author relied on the fact that full sync eventally fills the gaps, but when full sync stalls (for yet unknown reasons) we are in throuble, and this PR should fix that!
...eum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManager.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
…ing pending block to the list Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
…block Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaning on @fab-10 's review here a fair bit for the finer details of how this works but looks good to my understanding.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Show resolved
Hide resolved
...eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManagerTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, you might want to think about getting rid of the second parameter of the pendingAncestorBlockOf() method.
Some finals missing :-)
LOG.info( | ||
"Imported {} pending blocks: {}", | ||
r.size(), | ||
r.stream().map(b -> b.getHeader().getNumber()).collect(Collectors.toList())); | ||
} | ||
if (t != null) { | ||
LOG.error("Error importing pending blocks", t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there was an error? Do we need to remove a block from the pending blocks? Depending on what error was thrown?
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Head branch was pushed to by a user without write access
* Add more log to retrieve parent method * Request the lowest pending ancestor when saving a block * Replace recursive implementation with iterative when getting pending ancestors of Block * Decrease scope of synchronized block to reflect only the event of adding pending block to the list * Add fork to the chain so test is more representative Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net> Co-authored-by: Gabriel Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel Trintinalia gabriel.trintinalia@consensys.net
PR description
When a block is saved for future import, requesting the lowest announced block parent does not seem to be always the best option. It can be that we cannot retrieve this block and then we keep selecting the lowest block over and over and eventually it does not fix the gap. A better approach for trying to unstick could be to request the parent of the lowest pending ancestor
Changes:
Fixed Issue(s)
potential aid for #3955
#4197
Documentation
doc-change-required
label to this PR ifupdates are required.
Changelog