Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions op-acceptance-tests/tests/sync/elsync/reorg/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package reorg

import (
"testing"

"github.com/ethereum-optimism/optimism/op-devstack/compat"
"github.com/ethereum-optimism/optimism/op-devstack/presets"
)

func TestMain(m *testing.M) {
presets.DoMain(m,
presets.WithNewSingleChainMultiNodeWithTestSeq(),
presets.WithCompatibleTypes(compat.SysGo),
presets.WithNoDiscovery(),
)
}
392 changes: 392 additions & 0 deletions op-acceptance-tests/tests/sync/elsync/reorg/sync_test.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions op-devstack/dsl/l2_cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,15 @@ func (cl *L2CLNode) SignalTarget(el *L2ELNode, targetNum uint64) {
})
cl.require.NoErrorf(err, "failed to post unsafe payload via admin API: target %d", targetNum)
}

func (cl *L2CLNode) Reset(lvl types.SafetyLevel, target eth.L2BlockRef) {
cl.require.NoError(retry.Do0(cl.ctx, 5, &retry.FixedStrategy{Dur: 2 * time.Second},
func() error {
res := cl.HeadBlockRef(lvl)
cl.log.Info("Chain sync Status", lvl, res)
if res.Hash == target.Hash {
return nil
}
return errors.New("waiting to reset")
}))
}
25 changes: 25 additions & 0 deletions op-devstack/dsl/l2_el.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/predeploys"
"github.com/ethereum-optimism/optimism/op-service/retry"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
"github.com/ethereum/go-ethereum/common"
)

Expand Down Expand Up @@ -273,3 +274,27 @@ func (el *L2ELNode) FinishedELSync(refNode *L2ELNode, unsafe, safe, finalized ui
return errors.New("EL Sync not yet triggered")
}))
}

func (el *L2ELNode) ChainSyncStatus(chainID eth.ChainID, lvl types.SafetyLevel) eth.BlockID {
el.require.Equal(chainID, el.inner.ID().ChainID(), "chain ID mismatch")
var blockRef eth.L2BlockRef
switch lvl {
case types.Finalized:
blockRef = el.BlockRefByLabel(eth.Finalized)
case types.CrossSafe, types.LocalSafe:
blockRef = el.BlockRefByLabel(eth.Safe)
case types.CrossUnsafe, types.LocalUnsafe:
blockRef = el.BlockRefByLabel(eth.Unsafe)
default:
el.require.NoError(errors.New("invalid safety level"))
}
return blockRef.ID()
}

func (el *L2ELNode) MatchedFn(refNode SyncStatusProvider, lvl types.SafetyLevel, attempts int) CheckFunc {
return MatchedFn(el, refNode, el.log, el.ctx, lvl, el.ChainID(), attempts)
}

func (el *L2ELNode) Matched(refNode SyncStatusProvider, lvl types.SafetyLevel, attempts int) {
el.require.NoError(el.MatchedFn(refNode, lvl, attempts)())
}
8 changes: 8 additions & 0 deletions op-devstack/presets/cl_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ func WithReqRespSyncDisabled() stack.CommonOption {
cfg.EnableReqRespSync = false
})))
}

func WithNoDiscovery() stack.CommonOption {
return stack.MakeCommon(
sysgo.WithGlobalL2CLOption(sysgo.L2CLOptionFn(
func(_ devtest.P, id stack.L2CLNodeID, cfg *sysgo.L2CLConfig) {
cfg.NoDiscovery = true
})))
}
37 changes: 37 additions & 0 deletions op-devstack/presets/singlechain_multinode.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,40 @@ func NewSingleChainMultiNodeWithoutCheck(t devtest.T) *SingleChainMultiNode {
func WithSingleChainMultiNodeWithoutP2P() stack.CommonOption {
return stack.MakeCommon(sysgo.DefaultSingleChainMultiNodeSystemWithoutP2P(&sysgo.DefaultSingleChainMultiNodeSystemIDs{}))
}

type SingleChainMultiNodeWithTestSeq struct {
SingleChainMultiNode

TestSequencer *dsl.TestSequencer
}

func NewSingleChainMultiNodeWithTestSeq(t devtest.T) *SingleChainMultiNodeWithTestSeq {
system := shim.NewSystem(t)
orch := Orchestrator()
orch.Hydrate(system)
minimal := minimalFromSystem(t, system, orch)
l2 := system.L2Network(match.Assume(t, match.L2ChainA))
verifierCL := l2.L2CLNode(match.Assume(t,
match.And(
match.Not(match.WithSequencerActive(t.Ctx())),
match.Not[stack.L2CLNodeID, stack.L2CLNode](minimal.L2CL.ID()),
)))
verifierEL := l2.L2ELNode(match.Assume(t,
match.And(
match.EngineFor(verifierCL),
match.Not[stack.L2ELNodeID, stack.L2ELNode](minimal.L2EL.ID()))))
preset := &SingleChainMultiNode{
Minimal: *minimal,
L2ELB: dsl.NewL2ELNode(verifierEL, orch.ControlPlane()),
L2CLB: dsl.NewL2CLNode(verifierCL, orch.ControlPlane()),
}
out := &SingleChainMultiNodeWithTestSeq{
SingleChainMultiNode: *preset,
TestSequencer: dsl.NewTestSequencer(system.TestSequencer(match.Assume(t, match.FirstTestSequencer))),
}
return out
}

func WithNewSingleChainMultiNodeWithTestSeq() stack.CommonOption {
return stack.MakeCommon(sysgo.DefaultSingleChainMultiNodeWithTestSeqSystem(&sysgo.DefaultSingleChainMultiNodeWithTestSeqSystemIDs{}))
}
4 changes: 4 additions & 0 deletions op-devstack/sysgo/l2_cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type L2CLConfig struct {

// EnableReqRespSync is the flag to enable/disable req-resp sync.
EnableReqRespSync bool

// NoDiscovery is the flag to enable/disable discovery
NoDiscovery bool
}

func L2CLSequencer() L2CLOption {
Expand All @@ -52,6 +55,7 @@ func DefaultL2CLConfig() *L2CLConfig {
IsSequencer: false,
IndexingMode: false,
EnableReqRespSync: true,
NoDiscovery: false,
}
}

Expand Down
1 change: 1 addition & 0 deletions op-devstack/sysgo/l2_cl_opnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func WithOpNode(l2CLID stack.L2CLNodeID, l1CLID stack.L1CLNodeID, l1ELID stack.L
}
p2pConfig, err = p2pcli.NewConfig(cliCtx, l2Net.rollupCfg.BlockTime)
require.NoError(err, "failed to load p2p config")
p2pConfig.NoDiscovery = cfg.NoDiscovery
}

// specify interop config, but do not configure anything, to disable indexing mode
Expand Down
26 changes: 26 additions & 0 deletions op-devstack/sysgo/system_singlechain_multinode.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ type DefaultSingleChainMultiNodeSystemIDs struct {
L2ELB stack.L2ELNodeID
}

type DefaultSingleChainMultiNodeWithTestSeqSystemIDs struct {
DefaultSingleChainMultiNodeSystemIDs

TestSequencer stack.TestSequencerID
}

func NewDefaultSingleChainMultiNodeSystemIDs(l1ID, l2ID eth.ChainID) DefaultSingleChainMultiNodeSystemIDs {
minimal := NewDefaultMinimalSystemIDs(l1ID, l2ID)
return DefaultSingleChainMultiNodeSystemIDs{
Expand All @@ -21,6 +27,13 @@ func NewDefaultSingleChainMultiNodeSystemIDs(l1ID, l2ID eth.ChainID) DefaultSing
}
}

func NewDefaultSingleChainMultiNodeWithTestSeqSystemIDs(l1ID, l2ID eth.ChainID) DefaultSingleChainMultiNodeWithTestSeqSystemIDs {
return DefaultSingleChainMultiNodeWithTestSeqSystemIDs{
DefaultSingleChainMultiNodeSystemIDs: NewDefaultSingleChainMultiNodeSystemIDs(l1ID, l2ID),
TestSequencer: "dev",
}
}

func DefaultSingleChainMultiNodeSystem(dest *DefaultSingleChainMultiNodeSystemIDs) stack.Option[*Orchestrator] {
ids := NewDefaultSingleChainMultiNodeSystemIDs(DefaultL1ID, DefaultL2AID)

Expand All @@ -40,6 +53,19 @@ func DefaultSingleChainMultiNodeSystem(dest *DefaultSingleChainMultiNodeSystemID
return opt
}

func DefaultSingleChainMultiNodeWithTestSeqSystem(dest *DefaultSingleChainMultiNodeWithTestSeqSystemIDs) stack.Option[*Orchestrator] {
ids := NewDefaultSingleChainMultiNodeWithTestSeqSystemIDs(DefaultL1ID, DefaultL2AID)
opt := stack.Combine[*Orchestrator]()
opt.Add(DefaultSingleChainMultiNodeSystem(&dest.DefaultSingleChainMultiNodeSystemIDs))

opt.Add(WithTestSequencer(ids.TestSequencer, ids.L1CL, ids.L2CL, ids.L1EL, ids.L2EL))

opt.Add(stack.Finally(func(orch *Orchestrator) {
*dest = ids
}))
return opt
}

func DefaultSingleChainMultiNodeSystemWithoutP2P(dest *DefaultSingleChainMultiNodeSystemIDs) stack.Option[*Orchestrator] {
ids := NewDefaultSingleChainMultiNodeSystemIDs(DefaultL1ID, DefaultL2AID)

Expand Down