-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-{acceptance-tests|devstack}: sync test: op-supervisor ahead of op-node, unsafe chain known with DSL #15878
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
pcw109550
merged 16 commits into
develop
from
pcw109550/interop-sync-test-supervisor-ahead-l2cl-unsafe-known-dsl
May 15, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7e5c92c
Move simpleinterop sync test to subdir
pcw109550 2eea857
embed chainid to dsl L2CL
pcw109550 9faee2e
dsl can choose second l2cl and l2el
pcw109550 936298e
redundancy interop dsl
pcw109550 8cb3948
More traversal of fetching monorepo contracts
pcw109550 551d802
DSL for l2 components + supervisor
pcw109550 947c531
better L2CL DSL
pcw109550 ee28527
Add TestUnsafeChainKnownToL2CL test with DSL
pcw109550 73e06c1
bad copy paste
pcw109550 6162eaa
DSL consistency
pcw109550 2fabdda
rebase fix
pcw109550 dd001f7
better naming
pcw109550 955e5f4
type safety
pcw109550 60a44ae
refactor
pcw109550 f56c14c
better DSL helper names and godoc
pcw109550 08b6a74
naming error
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
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
11 changes: 11 additions & 0 deletions
11
op-acceptance-tests/tests/interop/sync/redundant_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.WithRedundantInterop()) | ||
| } |
87 changes: 87 additions & 0 deletions
87
op-acceptance-tests/tests/interop/sync/redundant_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,87 @@ | ||
| 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-service/eth" | ||
| "github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types" | ||
| ) | ||
|
|
||
| // TestUnsafeChainKnownToL2CL tests the below scenario: | ||
| // supervisor cross-safe ahead of L2CL cross-safe, aka L2CL can "skip" forward to match safety of supervisor. | ||
| // To create this out-of-sync scenario, we follow the steps below: | ||
| // 1. Make sequencer (L2CL), verifier (L2CL), and supervisor 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. | ||
| // - Wait enough for both L2CLs advance safe heads. | ||
| // 2. Disconnect the P2P connection between the sequencer and verifier. | ||
| // - The verifier will not receive unsafe heads via P2P, and can only update unsafe heads matching with safe heads by reading L1 batches. | ||
| // - The verifier safe head will lag behind or match the sequencer and supervisor because all three components share the same L1 view. | ||
| // 3. Stop verifier L2CL | ||
| // - The verifier will not be able to advance unsafe head and safe head. | ||
| // - The sequencer will advance unsafe head and safe head, as well as synced with supervisor. | ||
| // 4. Wait until sequencer and supervisor diverged enough from the verifier. | ||
| // - To make the verifier held unsafe blocks which are already viewed as safe by sequencer and supervisor, we wait. | ||
| // - Wait until supervisor viewed safe head number is large enough than the stopped verifier's safe head view. | ||
| // 5. Restart the verifier. | ||
| // - The verifier will not sync via P2P but only able to advance unsafe and safe heads by reading L1 batches. | ||
| // - The verifier will quickly catch up with the sequencer safe head as well as the supervisor. | ||
| // - The verifier will "skip" processing already known unsafe blocks, and consolidate them into safe blocks. | ||
| func TestUnsafeChainKnownToL2CL(gt *testing.T) { | ||
| t := devtest.SerialT(gt) | ||
|
|
||
| sys := presets.NewRedundantInterop(t) | ||
| logger := sys.Log.With("Test", "TestUnsafeChainKnownToL2CL") | ||
| require := sys.T.Require() | ||
|
|
||
| logger.Info("make sure verifier safe head advances") | ||
| dsl.CheckAll(t, | ||
| sys.L2CLA.Advanced(types.CrossSafe, 5, 30), | ||
| sys.L2CLA2.Advanced(types.CrossSafe, 5, 30), | ||
| ) | ||
|
|
||
| safeA2 := sys.L2ELA2.BlockRefByLabel(eth.Safe) | ||
| logger.Info("verifier advanced safe head", "number", safeA2.Number) | ||
| unsafeA2 := sys.L2ELA2.BlockRefByLabel(eth.Unsafe) | ||
| logger.Info("verifier advanced unsafe head", "number", unsafeA2.Number) | ||
|
|
||
| // For making verifier stop advancing unsafe head via P2P | ||
| logger.Info("disconnect p2p between L2CLs") | ||
| sys.L2CLA.DisconnectPeer(sys.L2CLA2) | ||
| sys.L2CLA2.DisconnectPeer(sys.L2CLA) | ||
|
|
||
| // For making verifer not sync at all | ||
| logger.Info("stop verifier") | ||
| sys.L2CLA2.Stop() | ||
|
|
||
| delta := uint64(10) | ||
| logger.Info("wait until supervisor reaches safe head", "delta", delta) | ||
| sys.Supervisor.AdvancedSafeHead(sys.L2ChainA.ChainID(), delta, 30) | ||
|
|
||
| // Restarted verifier will advance its unsafe head by reading L1 but not by P2P | ||
| logger.Info("restart verifier") | ||
| sys.L2CLA2.Start() | ||
|
|
||
| safeA2 = sys.L2ELA2.BlockRefByLabel(eth.Safe) | ||
| logger.Info("verifier safe head after restart", "number", safeA2.Number) | ||
| unsafeA2 = sys.L2ELA2.BlockRefByLabel(eth.Unsafe) | ||
| logger.Info("verifier unsafe head after restart", "number", unsafeA2.Number) | ||
|
|
||
| // Make sure there are unsafe blocks to be consolidated: | ||
| // To check verifier does not have to process blocks since unsafe blocks are already processed | ||
| require.Greater(unsafeA2.Number, safeA2.Number) | ||
|
|
||
| logger.Info("make sure verifier unsafe head was consolidated to safe") | ||
| dsl.CheckAll(t, sys.L2CLA2.Reached(types.CrossSafe, unsafeA2.Number, 30)) | ||
|
|
||
| safeA := sys.L2ELA.BlockRefByLabel(eth.Safe) | ||
| target := safeA.Number + delta | ||
| logger.Info("make sure verifier unsafe head advances due to safe head advances", "target", target, "delta", delta) | ||
| dsl.CheckAll(t, sys.L2CLA2.Reached(types.LocalUnsafe, target, 30)) | ||
|
|
||
| block := sys.L2ELA2.BlockRefByNumber(unsafeA2.Number) | ||
| require.Equal(unsafeA2.Hash, block.Hash) | ||
| } | ||
File renamed without changes.
File renamed without changes.
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
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,6 @@ | ||
| package match | ||
|
|
||
| import "github.com/ethereum-optimism/optimism/op-devstack/stack" | ||
|
|
||
| var SecondL2EL = Second[stack.L2ELNodeID, stack.L2ELNode]() | ||
| var SecondL2CL = Second[stack.L2CLNodeID, stack.L2CLNode]() |
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.