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
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"editorconfig.generateAuto": false,
"files.trimTrailingWhitespace": true
"files.trimTrailingWhitespace": true,
"openInGitHub.defaultBranch": "develop",
"openInGitHub.alwaysUseDefaultBranch": false,
"openInGitHub.excludeCurrentRevision": true
}
7 changes: 4 additions & 3 deletions op-chain-ops/interopgen/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ func (r *InteropDevRecipe) hydrated() InteropDevRecipe {
const defaultBlockTime = 2

type InteropDevL2Recipe struct {
ChainID uint64
BlockTime uint64
ChainID uint64
BlockTime uint64
InteropOffset uint64
}

func prefundL2Accounts(l1Cfg *L1Config, l2Cfg *L2Config, addrs devkeys.Addresses) error {
Expand Down Expand Up @@ -257,8 +258,8 @@ func (r *InteropDevL2Recipe) build(l1ChainID uint64, addrs devkeys.Addresses) (*
L2GenesisGraniteTimeOffset: new(hexutil.Uint64),
L2GenesisHoloceneTimeOffset: new(hexutil.Uint64),
L2GenesisIsthmusTimeOffset: new(hexutil.Uint64),
L2GenesisInteropTimeOffset: (*hexutil.Uint64)(&r.InteropOffset),
L2GenesisJovianTimeOffset: nil,
L2GenesisInteropTimeOffset: new(hexutil.Uint64),
L1CancunTimeOffset: new(hexutil.Uint64),
L1PragueTimeOffset: new(hexutil.Uint64),
UseInterop: true,
Expand Down
7 changes: 7 additions & 0 deletions op-e2e/actions/helpers/l2_sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,10 @@ func (s *L2Sequencer) ActBuildL2ToIsthmus(t Testing) {
s.ActL2EmptyBlock(t)
}
}

func (s *L2Sequencer) ActBuildL2ToInterop(t Testing) {
require.NotNil(t, s.RollupCfg.InteropTime, "cannot activate InteropTime when it is not scheduled")
for s.L2Unsafe().Time < *s.RollupCfg.InteropTime {
s.ActL2EmptyBlock(t)
}
}
13 changes: 13 additions & 0 deletions op-e2e/actions/interop/dsl/assertions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dsl

import (
"github.com/stretchr/testify/require"
)

func RequireL2UnsafeNumberEquals(t require.TestingT, c *Chain, unsafeNumber uint64) {
require.Equal(t, unsafeNumber, c.Sequencer.L2Unsafe().Number)
}

func RequireL2UnsafeHashNotZero(t require.TestingT, c *Chain) {
require.NotZero(t, c.Sequencer.L2Unsafe().Hash)
}
3 changes: 1 addition & 2 deletions op-e2e/actions/interop/dsl/dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type InteropDSL struct {
func NewInteropDSL(t helpers.Testing, opts ...setupOption) *InteropDSL {
setup := SetupInterop(t, opts...)
actors := setup.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
t.Logf("ChainA: %v, ChainB: %v", actors.ChainA.ChainID, actors.ChainB.ChainID)

allChains := []*Chain{actors.ChainA, actors.ChainB}
Expand Down
31 changes: 31 additions & 0 deletions op-e2e/actions/interop/dsl/interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/syncnode"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
"github.com/ethereum/go-ethereum/common"
gethTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
)

Expand Down Expand Up @@ -91,14 +92,21 @@ func (actors *InteropActors) PrepareChainState(t helpers.Testing) {
actors.ChainA.Sequencer.ActL2PipelineFull(t)
actors.ChainB.Sequencer.ActL2PipelineFull(t)
t.Log("Processed!")
}

func (actors *InteropActors) VerifyInitialState(t helpers.Testing) {
// Verify initial state
statusA := actors.ChainA.Sequencer.SyncStatus()
statusB := actors.ChainB.Sequencer.SyncStatus()
require.Equal(t, uint64(0), statusA.UnsafeL2.Number)
require.Equal(t, uint64(0), statusB.UnsafeL2.Number)
}

func (actors *InteropActors) PrepareAndVerifyInitialState(t helpers.Testing) {
actors.PrepareChainState(t)
actors.VerifyInitialState(t)
}

// messageExpiryTime is the time in seconds that a message will be valid for on the L2 chain.
// At a 2 second block time, this should be small enough to cover all events buffered in the supervisor event queue.
const messageExpiryTime = 120 // 2 minutes
Expand All @@ -123,6 +131,15 @@ func SetMessageExpiryTime(expiryTime uint64) setupOption {
}
}

func SetInteropOffsetForAllL2s(offset uint64) setupOption {
return func(recipe *interopgen.InteropDevRecipe) {
for i, l2 := range recipe.L2s {
l2.InteropOffset = offset
recipe.L2s[i] = l2
}
}
}

// SetupInterop creates an InteropSetup to instantiate actors on, with 2 L2 chains.
func SetupInterop(t helpers.Testing, opts ...setupOption) *InteropSetup {
recipe := interopgen.InteropDevRecipe{
Expand Down Expand Up @@ -307,3 +324,17 @@ func createL2Services(
Batcher: batcher,
}
}

// Creates a new L2 block, submits it to L1, and mines the L1 block.
func (actors *InteropActors) ActBatchAndMine(t helpers.Testing, chains ...*Chain) {
var batches []*gethTypes.Transaction
for _, c := range chains {
c.Batcher.ActSubmitAll(t)
batches = append(batches, c.Batcher.LastSubmitted)
}
actors.L1Miner.ActL1StartBlock(12)(t)
for _, b := range batches {
actors.L1Miner.ActL1IncludeTxByHash(b.Hash())(t)
}
actors.L1Miner.ActL1EndBlock(t)
}
2 changes: 1 addition & 1 deletion op-e2e/actions/interop/emitter_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestEmitterContract(gt *testing.T) {
actors = is.CreateActors()
aliceA = setupUser(t, is, actors.ChainA, 0)
aliceB = setupUser(t, is, actors.ChainB, 0)
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
emitTx = initializeEmitterContractTest(t, aliceA, actors)
}

Expand Down
13 changes: 5 additions & 8 deletions op-e2e/actions/interop/interop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestFullInterop(gt *testing.T) {

is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)

// sync the supervisor, handle initial events emitted by the nodes
actors.ChainA.Sequencer.SyncSupervisor(t)
Expand Down Expand Up @@ -163,8 +163,7 @@ func TestFinality(gt *testing.T) {
testFinality := func(t helpers.StatefulTesting, extraBlocks int) {
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
actors.Supervisor.ProcessFull(t)

// Build L2 block on chain A
Expand Down Expand Up @@ -242,8 +241,7 @@ func TestInteropLocalSafeInvalidation(gt *testing.T) {

is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
genesisB := actors.ChainB.Sequencer.SyncStatus()

// build L2 block on chain B with invalid executing message pointing to A.
Expand Down Expand Up @@ -357,8 +355,7 @@ func TestInteropCrossSafeDependencyDelay(gt *testing.T) {

is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
// We create a batch with some empty blocks before and after the cross-chain message,
// so multiple L2 blocks are all derived from the same L1 block.
actors.ChainA.Sequencer.ActL2EmptyBlock(t)
Expand Down Expand Up @@ -439,7 +436,7 @@ func TestInteropExecutingMessageOutOfRangeLogIndex(gt *testing.T) {
t := helpers.NewDefaultTesting(gt)
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
aliceA := setupUser(t, is, actors.ChainA, 0)

// Execute a fake log on chain A
Expand Down
26 changes: 12 additions & 14 deletions op-e2e/actions/interop/interop_txplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestTxPlanDeployEventLogger(gt *testing.T) {

is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)

aliceA := setupUser(t, is, actors.ChainA, 0)

Expand Down Expand Up @@ -401,7 +401,8 @@ func TestInitAndExecMsgSameTimestamp(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)

alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -476,8 +477,7 @@ func TestBreakTimestampInvariant(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -575,8 +575,7 @@ func TestExecMsgDifferTxIndex(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
// only unsafe head of each chain progresses in this code block
var targetNum uint64
{
Expand Down Expand Up @@ -669,8 +668,7 @@ func TestExpiredMessage(gt *testing.T) {
expiryTime := uint64(6)
is := dsl.SetupInterop(t, dsl.SetMessageExpiryTime(expiryTime))
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -743,7 +741,7 @@ func TestCrossPatternSameTimestamp(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -873,7 +871,7 @@ func TestCrossPatternSameTx(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -964,7 +962,7 @@ func TestCycleInTx(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)

actors.ChainA.Sequencer.ActL2StartBlock(t)
Expand Down Expand Up @@ -1047,7 +1045,7 @@ func TestCycleInBlock(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)

actors.ChainA.Sequencer.ActL2StartBlock(t)
Expand Down Expand Up @@ -1130,7 +1128,7 @@ func TestCycleAcrossChainsSameTimestamp(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down Expand Up @@ -1225,7 +1223,7 @@ func TestCycleAcrossChainsSameTx(gt *testing.T) {
rng := rand.New(rand.NewSource(1234))
is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)
actors.PrepareAndVerifyInitialState(t)
alice := setupUser(t, is, actors.ChainA, 0)
bob := setupUser(t, is, actors.ChainB, 0)

Expand Down
3 changes: 1 addition & 2 deletions op-e2e/actions/interop/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ func TestReset(gt *testing.T) {

is := dsl.SetupInterop(t)
actors := is.CreateActors()
actors.PrepareChainState(t)

actors.PrepareAndVerifyInitialState(t)
// No blocks yet
status := actors.ChainA.Sequencer.SyncStatus()
require.Equal(t, uint64(0), status.UnsafeL2.Number)
Expand Down
Loading