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

feat(node): implement engine P2P sync mode #204

Merged
merged 1 commit into from
Oct 24, 2023
Merged

Conversation

seolaoh
Copy link
Contributor

@seolaoh seolaoh commented Sep 25, 2023

Description

Enable to trigger the Execution Engine’s P2P sync for a faster sync and Happy-path sync with newly introduced flag L2_ENGINE_SYNC_ENABLED.
Also there is another related branch in kroma-geth repository to support snap sync.

See Optimism PR#6243.

@seolaoh seolaoh requested a review from a team as a code owner September 25, 2023 12:56
@seolaoh seolaoh force-pushed the feat/enable-engine-p2p-sync branch from cd3a02d to f941fcd Compare October 10, 2023 04:42
@@ -165,6 +172,11 @@ func (eq *EngineQueue) SetUnsafeHead(head eth.L2BlockRef) {
eq.metrics.RecordL2Ref("l2_unsafe", head)
}

func (eq *EngineQueue) SetEngineSyncTarget(head eth.L2BlockRef) {
Copy link
Contributor

@kangsorang kangsorang Oct 11, 2023

Choose a reason for hiding this comment

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

@seolaoh Is there a known use case for this function?

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 is not used, but I think it is added just like SetUnsafeHead.

Copy link
Contributor

@0xHansLee 0xHansLee left a comment

Choose a reason for hiding this comment

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

I'm aware that this PR is from Optimism, but I left some questions. If you have any idea, it'd be appreciate if you leave some comments.

Comment on lines +212 to +224
L2EngineSyncEnabled = &cli.BoolFlag{
Name: "l2.engine-sync",
Usage: "Enables or disables execution engine P2P sync",
EnvVars: prefixEnvVar("L2_ENGINE_SYNC_ENABLED"),
Required: false,
}
SkipSyncStartCheck = &cli.BoolFlag{
Name: "l2.skip-sync-start-check",
Usage: "Skip sanity check of consistency of L1 origins of the unsafe L2 blocks when determining the sync-starting point. " +
"This defers the L1-origin verification, and is recommended to use in when utilizing l2.engine-sync",
EnvVars: prefixEnvVar("L2_SKIP_SYNC_START_CHECK"),
Required: false,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When seeing this, the default value has been set to false. But no default value is set in our PR. Do you have any specific reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because when do not set Value of cli.BoolFlag, the default value is false.

components/node/rollup/derive/engine_queue.go Outdated Show resolved Hide resolved
fc := eth.ForkchoiceState{
HeadBlockHash: eq.unsafeHead.Hash,
HeadBlockHash: eq.engineSyncTarget.Hash,
Copy link
Contributor

Choose a reason for hiding this comment

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

This tryUpdateEngine is called when fork choice is needed.
But can we sure that engineSyncTarget is always same with the unsafeHead when sync is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

During engine is syncing, when a node receives unsafe payload, node continuously requests geth to update unsafe block using tryUpdateEngine. In this case, eq.unsafeHead is not changed but eq.engineSyncTarget is updated with the newly received unsafe payload. So here we use eq.engineSyncTarget. And after engine has finished syncing, a node requests geth to update safe and finalized block using tryUpdateEngine. When eq.engineSyncTarget and eq.unsafeHead is different, it will do not tryUpdateEngine thanks to the line 257-260.

@seolaoh seolaoh force-pushed the feat/enable-engine-p2p-sync branch 2 times, most recently from 81ba988 to c0cc65e Compare October 12, 2023 04:21
- Add new flag `engine-sync` and `sync.Config` struct for engine p2p sync
- Modify `EngineQueue` to support engine p2p sync
- Add e2e test cases
- Modify related components to pass sync config
- Modify execution engine specs
- Fix reorg depth check, Add `skip-sync-start-check` flag

See Optimism PR#6243.
@seolaoh seolaoh force-pushed the feat/enable-engine-p2p-sync branch from c0cc65e to 8535324 Compare October 12, 2023 07:49
Copy link
Contributor

@0xHansLee 0xHansLee left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kangsorang kangsorang left a comment

Choose a reason for hiding this comment

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

lgtm

@seolaoh
Copy link
Contributor Author

seolaoh commented Oct 12, 2023

This PR should be merged after #212 is merged!

@seolaoh seolaoh merged commit 5f40f0e into dev Oct 24, 2023
@seolaoh seolaoh deleted the feat/enable-engine-p2p-sync branch October 24, 2023 05:05
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.

5 participants