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

Post Merge checkpoint sync #4735

Closed

Conversation

gfukushima
Copy link
Contributor

@gfukushima gfukushima commented Nov 25, 2022

PR description

Add post-merge checkpoint sync support

Fixed Issue(s)

Fixes #4573
Linked to #4703

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
…troller

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
# Conflicts:
#	besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
#	ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdated.java
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@gfukushima gfukushima changed the title Nearhead checkpoint sync Near head checkpoint sync Nov 28, 2022
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@gfukushima gfukushima marked this pull request as ready for review November 29, 2022 03:42
@gfukushima gfukushima marked this pull request as draft November 30, 2022 10:13
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
return configOptions.getTerminalTotalDifficulty().isPresent()
&& configOptions.getCheckpointOptions().isValid()
&& (UInt256.fromHexString(configOptions.getCheckpointOptions().getTotalDifficulty().get())
.greaterThan(configOptions.getTerminalTotalDifficulty().get()));
Copy link
Contributor

@siladu siladu Dec 8, 2022

Choose a reason for hiding this comment

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

What happens if we're using a devnet or a new public testnet that starts with TTD = 0? I think every block's TD will be 0 and this condition will never be met?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test and another check for that case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed current besu codebase requires a genesis block difficulty 1 so every block will have TotalDifficulty 1 in this case.

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
return configOptions.getTerminalTotalDifficulty().isPresent()
&& configOptions.getCheckpointOptions().isValid()
&& (UInt256.fromHexString(configOptions.getCheckpointOptions().getTotalDifficulty().get())
.greaterOrEqualThan(configOptions.getTerminalTotalDifficulty().get()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does changing this back to >= mean @jframe's point about the TransitionController being needed on the boundary case become an issue again?
#4735 (comment)

Maybe we need a special case for TTD = 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test and another check for that case

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
# Conflicts:
#	besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
#	consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeContext.java
#	consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PostMergeContext.java
#	ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdated.java
#	ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
@gfukushima gfukushima mentioned this pull request Dec 13, 2022
2 tasks
postMergeContext.setSyncState(null);
assertThat(postMergeContext.isSyncing()).isTrue();

// after setting a syncState things should progress as expected.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would split these up into separate tests, maybe one with null input, one for returning true, one for returning false.

.greaterThan(configOptions.getTerminalTotalDifficulty().get()));
}

private boolean isMergeAtGenesis(final Optional<UInt256> ttd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we avoid mentioning the merge? I think proofOfStakeAtGenesis would be better, if that makes sense here.

Appreciate merge is mentioned a lot elsewhere, but not in this class yet I don't think?

}

@Test
public void preMergeCheckpointSyncUsesTransitionControllerBuilder() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, tests looking good!

Comment on lines +3376 to +3379
.lessOrEqualThan(value)) {
throw new InvalidConfigurationException(
"Near head checkpoint sync requires a block with total difficulty greater than the TTD");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a special case here as well for genesisTD = 0 = TTD?

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you successfully tested a post-merge genesis with this code?

jframe and others added 8 commits December 16, 2022 09:17
Signed-off-by: Jason Frame <jason.frame@consensys.net>

Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
# Conflicts:
#	besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
@gfukushima
Copy link
Contributor Author

Merged as #4844

@gfukushima gfukushima closed this Dec 21, 2022
@gfukushima gfukushima deleted the nearhead-checkpoint-sync branch January 13, 2023 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bonsai light mode to allow checkpoint sync near head block for pivot block
5 participants