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

Consensus pushes finality data to Execution. Execution sets finalized block in blockchain #2936

Merged
merged 27 commits into from
Feb 19, 2025

Conversation

diegoximenes
Copy link
Contributor

@diegoximenes diegoximenes commented Feb 7, 2025

Resolves NIT-2627 and NIT-2585.

Today execution polls finality data from consensus.
With this PR consensus pushes finality data to execution, which avoids a circular dependency between consensus and simple execution (execution without sequencer behavior, for example).

Also, with this PR Execution starts setting the finalized block into the blockchain.
This enables go-ethereum to move blocks from the fast database to the ancients only if they are finalized, or if they are older than HEAD-params.FullImmutabilityThreshold.
params.FullImmutabilityThreshold is set to 90000 by go-ethereum today.

Pulls OffchainLabs/go-ethereum#411

@diegoximenes diegoximenes changed the title Push safe finalized Consensus pushes finality data to Execution Feb 7, 2025
@diegoximenes diegoximenes force-pushed the push_safe_finalized branch 2 times, most recently from f57d7be to cbc3407 Compare February 10, 2025 13:20
@diegoximenes diegoximenes marked this pull request as ready for review February 10, 2025 15:55
@diegoximenes diegoximenes marked this pull request as draft February 10, 2025 20:55
@diegoximenes
Copy link
Contributor Author

As a suggestion from Tsahi, I will include the behavior implemented in #2927 in this PR

@diegoximenes diegoximenes changed the title Consensus pushes finality data to Execution Consensus pushes finality data to Execution and sets finalized block in blockchain Feb 11, 2025
@diegoximenes diegoximenes changed the title Consensus pushes finality data to Execution and sets finalized block in blockchain Consensus pushes finality data to Execution. Execution sets finalized block in blockchain Feb 11, 2025
@diegoximenes diegoximenes marked this pull request as ready for review February 12, 2025 15:49
Copy link
Collaborator

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

generally seems good. A few small comments

arbnode/consensus_execution_syncer.go Outdated Show resolved Hide resolved
execution/gethexec/sync_monitor.go Outdated Show resolved Hide resolved
execution/gethexec/sync_monitor.go Outdated Show resolved Hide resolved
system_tests/common_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ganeshvanahalli ganeshvanahalli left a comment

Choose a reason for hiding this comment

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

LGTM

tsahee
tsahee previously approved these changes Feb 18, 2025
Copy link
Collaborator

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

A few comments for separate PR

type ConsensusExecutionSyncer struct {
stopwaiter.StopWaiter

config func() *ConsensusExecutionSyncerConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

config functions are generally only needed for hot-configurable configs.
Here we don't have any, so it's fine to just hold a pointer to a config instead of config-func

log.Warn("Finality not supported so not setting finalized block number")
} else if err == nil {
err = s.exec.SetFinalized(finalizedBlockNumber)
func (s *SyncMonitor) SetFinalityData(ctx context.Context, finalityData *arbutil.FinalityData) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

separate PR:
I'm thinking about two contradicting options:

  1. don't pass valid as part of finality data, only pass finalized & safe, let consensus side implement logic to limit finalized & safe by valid
  2. do pass final, safe & valid, use valid to also replace "MarkValid" from the blockRecorder.
    Not sure yet which makes more sense, specifically for scenario with multiple execution engines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to pass valid from consensus to execution because FinalizedBlockWaitForBlockValidator and SafeBlockWaitForBlockValidator configs are defined in the execution side.
So to implement option 1 we will need to do a breaking change in that regard, i.e., move these configs to the consensus side.

Copy link
Collaborator

Choose a reason for hiding this comment

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

makes sense. We may change it in the future, but it's a good deciding factor for now.

type FinalityData struct {
FinalizedMsgCount MessageIndex
SafeMsgCount MessageIndex
ValidatedMsgCount *MessageIndex
Copy link
Collaborator

Choose a reason for hiding this comment

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

separate PR: we should also have block-hashes for all of these, to make sure weird race conditions don't make us finalize a reorged-out block

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 possible inconsistency is more likely to happen with safe blocks than finalized.
It seems that geth doesn't update safe and finalized blocks in case of reorgs BTW.
ConsensusExecutionSyncer will periodically push finality data to execution, so this inconsistency will eventually disappear.

But it makes sense to add those hashes that you mentioned, considering that SetSafe and SetFinalizes will be called holding ExecutionEngine.createBlocksMutex.

I will create a linear task to handle those issues.

@diegoximenes diegoximenes dismissed stale reviews from tsahee and ganeshvanahalli via 16a53fc February 19, 2025 13:05
@@ -263,6 +263,7 @@ type NodeBuilder struct {
withProdConfirmPeriodBlocks bool
wasmCacheTag uint32
delayBufferThreshold uint64
useFreezer bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

separate PR: is there actually a good reason to ever set that to false? If not, can remove the config.

@tsahee tsahee merged commit 60a48d3 into master Feb 19, 2025
15 checks passed
@tsahee tsahee deleted the push_safe_finalized branch February 19, 2025 16:59
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.

3 participants