-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-devstack: add sync-tester with external EL #17251
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a890663
op-devstack: add sync-tester with ext cl config
nonsense ded07ea
op-devstack: try setting up remote L2 chain
nonsense be847d0
op-devstack: use remote EL and CL for L1 nodes
nonsense 8471343
op-devstack: fix L2CL from sequencer to verifier
nonsense 7079b76
op-devstack: remove redundant configs
nonsense ea91a3a
op-acceptance-tests: use RPC for CI
nonsense c7c5cb1
op-acceptance-tests: skip tests until CI allows tests using external …
nonsense e42deb8
circleci: attempt CI endpoints
nonsense 6293b95
op-devstack: address comments from PR
nonsense 1495405
op-devstack: address comments from PR
nonsense 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
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,39 @@ | ||
| package sync_tester_ext_el | ||
|
|
||
| import ( | ||
| "os" | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/compat" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| ) | ||
|
|
||
| var ( | ||
| InitialL2Block = uint64(32012748) | ||
| ) | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| L2NetworkName := "op-sepolia" | ||
| L1ChainID := eth.ChainIDFromUInt64(11155111) | ||
|
|
||
| L2ELEndpoint := "https://ci-sepolia-l2.optimism.io" | ||
| L1CLBeaconEndpoint := "https://ci-sepolia-beacon.optimism.io" | ||
| L1ELEndpoint := "https://ci-sepolia-l1.optimism.io" | ||
|
|
||
| // Endpoints when running with Tailscale networking | ||
| if os.Getenv("TAILSCALE_NETWORKING") == "true" { | ||
| L2ELEndpoint = "https://proxyd-l2-sepolia.primary.client.dev.oplabs.cloud" | ||
| L1CLBeaconEndpoint = "https://beacon-api-proxy-sepolia.primary.client.dev.oplabs.cloud" | ||
| L1ELEndpoint = "https://proxyd-l1-sepolia.primary.client.dev.oplabs.cloud" | ||
| } | ||
|
|
||
| presets.DoMain(m, presets.WithMinimalExternalELWithSuperchainRegistry(L1CLBeaconEndpoint, L1ELEndpoint, L2ELEndpoint, L1ChainID, L2NetworkName, eth.FCUState{ | ||
| Latest: InitialL2Block, | ||
| Safe: InitialL2Block, | ||
| Finalized: InitialL2Block, | ||
| }), | ||
| presets.WithCompatibleTypes(compat.SysGo), | ||
| ) | ||
|
|
||
| } | ||
52 changes: 52 additions & 0 deletions
52
op-acceptance-tests/tests/sync_tester_ext_el/sync_tester_ext_el_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,52 @@ | ||
| package sync_tester_ext_el | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "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" | ||
| ) | ||
|
|
||
| func TestSyncTesterExtEL(gt *testing.T) { | ||
| t := devtest.SerialT(gt) | ||
|
|
||
| sys := presets.NewMinimalExternalELWithExternalL1(t) | ||
| require := t.Require() | ||
|
|
||
| // Test that we can get chain IDs from L2CL node | ||
| l2CLChainID := sys.L2CL.ID().ChainID() | ||
| require.Equal(eth.ChainIDFromUInt64(11155420), l2CLChainID, "L2CL should be on chain 11155420") | ||
|
|
||
| // Test that the network started successfully | ||
| require.NotNil(sys.L1EL, "L1 EL node should be available") | ||
| require.NotNil(sys.L2CL, "L2 CL node should be available") | ||
| require.NotNil(sys.SyncTester, "SyncTester should be available") | ||
|
|
||
| // Test that we can get sync status from L2CL node | ||
| l2CLSyncStatus := sys.L2CL.SyncStatus() | ||
| require.NotNil(l2CLSyncStatus, "L2CL should have sync status") | ||
|
|
||
| blocksToSync := uint64(20) | ||
| targetBlock := InitialL2Block + blocksToSync | ||
| sys.L2CL.Reached(types.LocalUnsafe, targetBlock, 500) | ||
|
|
||
| l2CLSyncStatus = sys.L2CL.SyncStatus() | ||
| require.NotNil(l2CLSyncStatus, "L2CL should have sync status") | ||
|
|
||
| unsafeL2Ref := l2CLSyncStatus.UnsafeL2 | ||
| blk := sys.L2EL.BlockRefByNumber(unsafeL2Ref.Number) | ||
| require.Equal(unsafeL2Ref.Hash, blk.Hash, "L2EL should be on the same block as L2CL") | ||
|
|
||
| stSessions := sys.SyncTester.ListSessions() | ||
| require.Equal(len(stSessions), 1, "expect exactly one session") | ||
|
|
||
| stSession := sys.SyncTester.GetSession(stSessions[0]) | ||
| require.GreaterOrEqual(stSession.CurrentState.Latest, stSession.InitialState.Latest+blocksToSync, "SyncTester session Latest should be on the same block as L2CL") | ||
| require.GreaterOrEqual(stSession.CurrentState.Safe, stSession.InitialState.Safe+blocksToSync, "SyncTester session Safe should be on the same block as L2CL") | ||
|
|
||
| t.Logger().Info("SyncTester ExtEL test completed successfully", | ||
| "l2cl_chain_id", l2CLChainID, | ||
| "l2cl_sync_status", l2CLSyncStatus) | ||
| } | ||
|
nonsense marked this conversation as resolved.
|
||
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,60 @@ | ||
| package presets | ||
|
|
||
| import ( | ||
| "github.com/ethereum/go-ethereum/log" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/dsl" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/shim" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/stack" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/stack/match" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/sysgo" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| ) | ||
|
|
||
| type MinimalExternalEL struct { | ||
| Log log.Logger | ||
| T devtest.T | ||
| ControlPlane stack.ControlPlane | ||
|
|
||
| L1Network *dsl.L1Network | ||
| L1EL *dsl.L1ELNode | ||
|
|
||
| L2Chain *dsl.L2Network | ||
| L2CL *dsl.L2CLNode | ||
| L2EL *dsl.L2ELNode | ||
|
|
||
| SyncTester *dsl.SyncTester | ||
| } | ||
|
|
||
| func (m *MinimalExternalEL) L2Networks() []*dsl.L2Network { | ||
| return []*dsl.L2Network{ | ||
| m.L2Chain, | ||
| } | ||
| } | ||
|
|
||
| func WithMinimalExternalELWithSuperchainRegistry(l1CLBeaconRPC, l1ELRPC, l2ELRPC string, l1ChainID eth.ChainID, networkName string, fcu eth.FCUState) stack.CommonOption { | ||
| return stack.MakeCommon(sysgo.DefaultMinimalExternalELSystemWithEndpointAndSuperchainRegistry(&sysgo.DefaultMinimalExternalELSystemIDs{}, l1CLBeaconRPC, l1ELRPC, l2ELRPC, l1ChainID, networkName, fcu)) | ||
| } | ||
|
|
||
| func NewMinimalExternalELWithExternalL1(t devtest.T) *MinimalExternalEL { | ||
| system := shim.NewSystem(t) | ||
| orch := Orchestrator() | ||
| orch.Hydrate(system) | ||
|
|
||
| l2 := system.L2Network(match.Assume(t, match.L2ChainA)) | ||
| verifierCL := l2.L2CLNode(match.FirstL2CL) | ||
| syncTester := l2.SyncTester(match.Assume(t, match.FirstSyncTester)) | ||
|
|
||
| return &MinimalExternalEL{ | ||
| Log: t.Logger(), | ||
| T: t, | ||
| ControlPlane: orch.ControlPlane(), | ||
| L1Network: dsl.NewL1Network(system.L1Network(match.FirstL1Network)), | ||
| L1EL: dsl.NewL1ELNode(system.L1Network(match.FirstL1Network).L1ELNode(match.FirstL1EL)), | ||
| L2Chain: dsl.NewL2Network(l2, orch.ControlPlane()), | ||
| L2CL: dsl.NewL2CLNode(verifierCL, orch.ControlPlane()), | ||
| L2EL: dsl.NewL2ELNode(l2.L2ELNode(match.FirstL2EL), orch.ControlPlane()), | ||
| SyncTester: dsl.NewSyncTester(syncTester), | ||
| } | ||
| } |
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,86 @@ | ||
| package sysgo | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/ethereum/go-ethereum/core" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/stack" | ||
| "github.com/ethereum-optimism/optimism/op-node/chaincfg" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| "github.com/ethereum-optimism/optimism/op-service/superutil" | ||
| "github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/depset" | ||
| ) | ||
|
|
||
| // WithL2NetworkFromSuperchainRegistry creates an L2 network using the rollup config from the superchain registry | ||
| func WithL2NetworkFromSuperchainRegistry(l2NetworkID stack.L2NetworkID, networkName string) stack.Option[*Orchestrator] { | ||
| return stack.BeforeDeploy(func(orch *Orchestrator) { | ||
| p := orch.P().WithCtx(stack.ContextWithID(orch.P().Ctx(), l2NetworkID)) | ||
| require := p.Require() | ||
|
|
||
| // Load the rollup config from the superchain registry | ||
| rollupCfg, err := chaincfg.GetRollupConfig(networkName) | ||
| require.NoError(err, "failed to load rollup config for network %s", networkName) | ||
|
|
||
| // Get the chain config from the superchain registry | ||
| chainCfg := chaincfg.ChainByName(networkName) | ||
| require.NotNil(chainCfg, "chain config not found for network %s", networkName) | ||
|
|
||
| // Load the chain config using superutil | ||
| paramsChainConfig, err := superutil.LoadOPStackChainConfigFromChainID(chainCfg.ChainID) | ||
| require.NoError(err, "failed to load chain config for network %s", networkName) | ||
|
|
||
| // Create a genesis config from the chain config | ||
| genesis := &core.Genesis{ | ||
| Config: paramsChainConfig, | ||
| } | ||
|
|
||
| // Create the L2 network | ||
| l2Net := &L2Network{ | ||
| id: l2NetworkID, | ||
| l1ChainID: eth.ChainIDFromBig(rollupCfg.L1ChainID), | ||
| genesis: genesis, | ||
| rollupCfg: rollupCfg, | ||
| keys: orch.keys, | ||
| } | ||
|
|
||
| require.True(orch.l2Nets.SetIfMissing(l2NetworkID.ChainID(), l2Net), | ||
| fmt.Sprintf("must not already exist: %s", l2NetworkID)) | ||
| }) | ||
| } | ||
|
|
||
| // WithL2NetworkFromSuperchainRegistryWithDependencySet creates an L2 network using the rollup config from the superchain registry | ||
| // and also sets up the dependency set for interop support | ||
| func WithL2NetworkFromSuperchainRegistryWithDependencySet(l2NetworkID stack.L2NetworkID, networkName string) stack.Option[*Orchestrator] { | ||
| return stack.Combine( | ||
| WithL2NetworkFromSuperchainRegistry(l2NetworkID, networkName), | ||
| stack.BeforeDeploy(func(orch *Orchestrator) { | ||
| p := orch.P().WithCtx(stack.ContextWithID(orch.P().Ctx(), l2NetworkID)) | ||
| require := p.Require() | ||
|
|
||
| // Load the dependency set from the superchain registry | ||
| chainCfg := chaincfg.ChainByName(networkName) | ||
| require.NotNil(chainCfg, "chain config not found for network %s", networkName) | ||
|
|
||
| _, err := depset.FromRegistry(eth.ChainIDFromUInt64(chainCfg.ChainID)) | ||
| if err != nil { | ||
| // If dependency set is not available, that's okay - it's optional | ||
| p.Logger().Info("No dependency set available for network", "network", networkName, "err", err) | ||
| return | ||
| } | ||
|
|
||
| // Create a cluster to hold the dependency set | ||
| clusterID := stack.ClusterID(networkName) | ||
|
|
||
| // Create a minimal full config set with just the dependency set | ||
| // This is a simplified approach - in a real implementation you might want | ||
| // to create a proper FullConfigSetMerged | ||
| cluster := &Cluster{ | ||
| id: clusterID, | ||
| cfgset: depset.FullConfigSetMerged{}, // Empty for now | ||
| } | ||
|
|
||
| orch.clusters.Set(clusterID, cluster) | ||
| }), | ||
| ) | ||
| } |
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.