-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-{acceptance-tests|devstack}: sync test: op-node ahead of op-supervisor with DSL #15908
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
Merged
protolambda
merged 13 commits into
develop
from
pcw109550/interop-sync-test-l2cl-ahead-supervisor-dsl
May 16, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0dfb321
DSL for l2 components + supervisor
pcw109550 b1ddb64
type safety
pcw109550 ff73870
support multisupervisor system
pcw109550 db026ca
expose interopRPC towards DSL
pcw109550 968c215
Add TestL2CLAheadOfSupervisor with DSL
pcw109550 fbcdd6d
better naming
pcw109550 f9c6b2c
godoc and better DSL naming and typing
pcw109550 9604016
prefix with decimal for supervisor ordering
pcw109550 364ff4a
Capitalize test log msgs
pcw109550 97739f2
rebase fix
pcw109550 be6ad18
More graceful rewind
pcw109550 415e359
spread out godoc scenario in test
pcw109550 a60d279
Add comment about shim L2CL interop fields
pcw109550 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
op-acceptance-tests/tests/interop/sync/multisupervisor_interop/init_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| presets.DoMain(m, presets.WithMultiSupervisorInterop()) | ||
| } |
119 changes: 119 additions & 0 deletions
119
op-acceptance-tests/tests/interop/sync/multisupervisor_interop/interop_sync_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/dsl" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| "github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types" | ||
| ) | ||
|
|
||
| // TestL2CLAheadOfSupervisor tests the below scenario: | ||
| // L2CL ahead of supervisor, aka supervisor needs to reset the L2CL, to reproduce old data. Currently supervisor has only managed mode implemented, so the supervisor will ask the L2CL to reset back. | ||
| func TestL2CLAheadOfSupervisor(gt *testing.T) { | ||
| t := devtest.SerialT(gt) | ||
|
|
||
| // Two supervisor initialized, each managing two L2CLs per chains. | ||
| // Primary supervisor manages sequencer L2CLs for chain A, B. | ||
| // Secondary supervisor manages verifier L2CLs for chain A, B. | ||
| // Each L2CLs per chain is connected via P2P. | ||
| sys := presets.NewMultiSupervisorInterop(t) | ||
| logger := sys.Log.With("Test", "TestL2CLAheadOfSupervisor") | ||
| require := sys.T.Require() | ||
|
|
||
| // Make sequencers (L2CL), verifiers (L2CL), and supervisors sync for a few blocks. | ||
| // Sequencer and verifier are connected via P2P, which makes their unsafe heads in sync. | ||
| // Both L2CLs are in managed mode, digesting L1 blocks from the supervisor and reporting unsafe and safe blocks back to the supervisor. | ||
| delta := uint64(10) | ||
| logger.Info("Make sure verifiers advances unsafe head", "delta", delta) | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA.Advanced(types.LocalUnsafe, delta, 30), sys.L2CLA2.Advanced(types.LocalUnsafe, delta, 30), | ||
| sys.L2CLB.Advanced(types.LocalUnsafe, delta, 30), sys.L2CLB2.Advanced(types.LocalUnsafe, delta, 30), | ||
| ) | ||
|
|
||
| safeHeadViewA2 := sys.SupervisorSecondary.SafeBlockID(sys.L2CLA.ChainID()) | ||
| safeHeadViewB2 := sys.SupervisorSecondary.SafeBlockID(sys.L2CLB.ChainID()) | ||
|
|
||
| logger.Info("Stop secondary supervisor") | ||
| sys.SupervisorSecondary.Stop() | ||
|
|
||
| safeHeadA2 := sys.L2CLA2.SafeL2BlockRef() | ||
| safeHeadB2 := sys.L2CLB2.SafeL2BlockRef() | ||
| require.Equal(safeHeadViewA2.Hash, safeHeadA2.Hash) | ||
| require.Equal(safeHeadViewB2.Hash, safeHeadB2.Hash) | ||
| logger.Info("Secondary supervisor(stopped) safe head view", "chainA", safeHeadA2, "chainB", safeHeadB2) | ||
|
|
||
| // Wait enough to make sequencers and primary supervisor advance safe head enough. | ||
| logger.Info("Sequencers advances safe heads but not verifiers", "delta", delta) | ||
| dsl.CheckAll(t, | ||
| // verifier CLs cannot advance their safe head because secondary supervisor is down, no supervisor to provide them L1 data. | ||
| sys.L2CLA2.NotAdvanced(types.CrossSafe, 30), sys.L2CLB2.NotAdvanced(types.CrossSafe, 30), | ||
| // sequencer CLs advance their safe heads | ||
| sys.L2CLA.Advanced(types.CrossSafe, delta, 30), sys.L2CLB.Advanced(types.CrossSafe, delta, 30), | ||
| // All the L2CLs advance their unsafe heads | ||
| // Verifiers advances unsafe head because they still have P2P connection with each sequencers | ||
| sys.L2CLA.Advanced(types.LocalUnsafe, delta, 30), sys.L2CLB.Advanced(types.LocalUnsafe, delta, 30), | ||
| sys.L2CLA2.Advanced(types.LocalUnsafe, delta, 30), sys.L2CLB2.Advanced(types.LocalUnsafe, delta, 30), | ||
| ) | ||
|
|
||
| // Primary supervisor has safe heads synced with sequencers. | ||
| // After connection, verifiers will sync with primary supervisor, matching supervisor safe head view. | ||
| logger.Info("Connect verifier CLs to primary supervisor to advance verifier safe heads") | ||
| sys.Supervisor.AddManagedL2CL(sys.L2CLA2) | ||
| sys.Supervisor.AddManagedL2CL(sys.L2CLB2) | ||
|
|
||
| // Secondary supervisor and verifiers becomes out-of-sync with safe heads. | ||
| target := max(sys.L2CLA.SafeL2BlockRef().Number, sys.L2CLB.SafeL2BlockRef().Number) + delta | ||
| logger.Info("Every CLs advance safe heads", "delta", delta, "target", target) | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA.Reached(types.CrossSafe, target, 30), sys.L2CLA2.Reached(types.CrossSafe, target, 30), | ||
| sys.L2CLB.Reached(types.CrossSafe, target, 30), sys.L2CLB2.Reached(types.CrossSafe, target, 30), | ||
| ) | ||
|
|
||
| logger.Info("Stop primary supervisor to disconnect every CL connection") | ||
| sys.Supervisor.Stop() | ||
|
|
||
| logger.Info("Restart primary supervisor") | ||
| sys.Supervisor.Start() | ||
|
|
||
| logger.Info("No CL connected to supervisor so every CL safe head will not advance") | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA.NotAdvanced(types.CrossSafe, 30), sys.L2CLA2.NotAdvanced(types.CrossSafe, 30), | ||
| sys.L2CLB.NotAdvanced(types.CrossSafe, 30), sys.L2CLB2.NotAdvanced(types.CrossSafe, 30), | ||
| ) | ||
|
|
||
| // Sequencers will resume advancing safe heads, but not verifiers. | ||
| logger.Info("Reconnect sequencer CLs to primary supervisor") | ||
| sys.Supervisor.AddManagedL2CL(sys.L2CLA) | ||
| sys.Supervisor.AddManagedL2CL(sys.L2CLB) | ||
|
|
||
| logger.Info("Restart secondary supervisor") | ||
| sys.SupervisorSecondary.Start() | ||
|
|
||
| logger.Info("Reconnect verifier CLs to secondary supervisor") | ||
| sys.SupervisorSecondary.AddManagedL2CL(sys.L2CLA2) | ||
| sys.SupervisorSecondary.AddManagedL2CL(sys.L2CLB2) | ||
|
|
||
| // Secondary supervisor will compare its safe head knowledge with L2CLs, and find out L2CLs are ahead of the Secondary supervisor. | ||
| // Secondary supervisor asks the verifiers (L2CL) to rewind(reset) back to match Secondary supervisor safe head view. | ||
| rewind := uint64(3) | ||
| logger.Info("Check verifier CLs safe head rewinded", "rewind", rewind) | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA2.Rewinded(types.CrossSafe, rewind, 60), | ||
| sys.L2CLB2.Rewinded(types.CrossSafe, rewind, 60), | ||
| ) | ||
|
|
||
| // After rewinding(reset), verifier will advance safe heads again because Secondary supervisor gives L1 data to the verifiers. | ||
| // Wait until verifiers advance safe head enough | ||
| target = max(sys.L2CLA.SafeL2BlockRef().Number, sys.L2CLB.SafeL2BlockRef().Number) + delta | ||
| logger.Info("Every CLs advance safe heads", "delta", delta, "target", target) | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA.Reached(types.CrossSafe, target, 30), sys.L2CLA2.Reached(types.CrossSafe, target, 30), | ||
| sys.L2CLB.Reached(types.CrossSafe, target, 30), sys.L2CLB2.Reached(types.CrossSafe, target, 30), | ||
| ) | ||
|
|
||
| // Make sure each chain did not diverge | ||
| require.Equal(sys.L2ELA.BlockRefByNumber(target).Hash, sys.L2ELA2.BlockRefByNumber(target).Hash) | ||
| require.Equal(sys.L2ELB.BlockRefByNumber(target).Hash, sys.L2ELB2.BlockRefByNumber(target).Hash) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.