Skip to content
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

client: Patch fcu skeleton blockfill process to avoid chain reset #3137

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Nov 2, 2023

to avoid the chain being reset by getting interfered with sksleton's fill Canonicaland fcU's sethead's putblocks of executed blocks

now skeleton attempts blocking fill for the max number of executed blocks which fcu wants to put via execution's setHead

This PR should fix the hive pytests failing because of this issue

ps:
this is a patch but a proper solution needs to happen at blockchain layer where blocks shouldn't reset the chain unless explicitly asked to or via a proper rule that they should extend the max height of the chain.
Also skeleton 's canonical block handling/tracking needs to be up streamed to the chain , but that could be a little more involved work to address separately

@g11tech g11tech force-pushed the fix-hive-fcuspatch branch from 414014e to 1ef50dd Compare November 2, 2023 18:19
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #3137 (2425caf) into master (3a00a32) will decrease coverage by 1.50%.
The diff coverage is 47.43%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.80% <ø> (?)
blockchain 92.27% <ø> (?)
client 86.19% <47.43%> (-0.02%) ⬇️
common 98.19% <ø> (?)
devp2p 86.32% <ø> (?)
evm 71.93% <ø> (?)
statemanager 90.13% <ø> (?)
trie 89.72% <ø> (?)
tx 96.36% <ø> (ø)
util 87.53% <ø> (?)
vm 76.22% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

// cause chain reset. This can happen if any other async process added a batch of blocks like
// execution's setHead. If that caused this chain to be not canonical anymore than the next
// putblocks should fail causing the fill to exit with skeleton stepback
if (this.chain.blocks.height <= block.header.number) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only real change here, i.e. skip putting if chain has been advanced by some other putBlock process. But in the hive tests i ran locally, there would still be a random race where this check would pass but still when actual writing the block, a concurrent putblock wins the race causing an issue

(so we eventually needs to fix it since the only actual locking happens in the blockchain class)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a silly question but do we need to check block.header.number and ensure its only one block ahead of height?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its not, the putBlock will fail anyway

this.config.updateSynchronizedState(headBlock.header)
if (!isPrevSynced && this.chain.config.synchronized) {
this.service.txPool.checkRunState()
}
} else if (!headBlock.isGenesis()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does removing this section do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to be a redundant txpool start snippet, just below this if/else there is a similar snippet

Co-authored-by: acolytec3 <17355484+acolytec3@users.noreply.github.com>
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acolytec3 acolytec3 merged commit 6d64162 into master Nov 3, 2023
@acolytec3 acolytec3 deleted the fix-hive-fcuspatch branch November 3, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants