Skip to content

Commit 12cb0c5

Browse files
authored
op-node interop upgrade txs (#15517)
Remove rescheduled upgrade transactions
1 parent a841969 commit 12cb0c5

16 files changed

+446
-31
lines changed

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"editorconfig.generateAuto": false,
3-
"files.trimTrailingWhitespace": true
3+
"files.trimTrailingWhitespace": true,
4+
"openInGitHub.defaultBranch": "develop",
5+
"openInGitHub.alwaysUseDefaultBranch": false,
6+
"openInGitHub.excludeCurrentRevision": true
47
}

op-chain-ops/interopgen/recipe.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ func (r *InteropDevRecipe) hydrated() InteropDevRecipe {
123123
const defaultBlockTime = 2
124124

125125
type InteropDevL2Recipe struct {
126-
ChainID uint64
127-
BlockTime uint64
126+
ChainID uint64
127+
BlockTime uint64
128+
InteropOffset uint64
128129
}
129130

130131
func prefundL2Accounts(l1Cfg *L1Config, l2Cfg *L2Config, addrs devkeys.Addresses) error {
@@ -257,8 +258,8 @@ func (r *InteropDevL2Recipe) build(l1ChainID uint64, addrs devkeys.Addresses) (*
257258
L2GenesisGraniteTimeOffset: new(hexutil.Uint64),
258259
L2GenesisHoloceneTimeOffset: new(hexutil.Uint64),
259260
L2GenesisIsthmusTimeOffset: new(hexutil.Uint64),
261+
L2GenesisInteropTimeOffset: (*hexutil.Uint64)(&r.InteropOffset),
260262
L2GenesisJovianTimeOffset: nil,
261-
L2GenesisInteropTimeOffset: new(hexutil.Uint64),
262263
L1CancunTimeOffset: new(hexutil.Uint64),
263264
L1PragueTimeOffset: new(hexutil.Uint64),
264265
UseInterop: true,

op-e2e/actions/helpers/l2_sequencer.go

+7
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,10 @@ func (s *L2Sequencer) ActBuildL2ToIsthmus(t Testing) {
249249
s.ActL2EmptyBlock(t)
250250
}
251251
}
252+
253+
func (s *L2Sequencer) ActBuildL2ToInterop(t Testing) {
254+
require.NotNil(t, s.RollupCfg.InteropTime, "cannot activate InteropTime when it is not scheduled")
255+
for s.L2Unsafe().Time < *s.RollupCfg.InteropTime {
256+
s.ActL2EmptyBlock(t)
257+
}
258+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dsl
2+
3+
import (
4+
"github.com/stretchr/testify/require"
5+
)
6+
7+
func RequireL2UnsafeNumberEquals(t require.TestingT, c *Chain, unsafeNumber uint64) {
8+
require.Equal(t, unsafeNumber, c.Sequencer.L2Unsafe().Number)
9+
}
10+
11+
func RequireL2UnsafeHashNotZero(t require.TestingT, c *Chain) {
12+
require.NotZero(t, c.Sequencer.L2Unsafe().Hash)
13+
}

op-e2e/actions/interop/dsl/dsl.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ type InteropDSL struct {
6565
func NewInteropDSL(t helpers.Testing, opts ...setupOption) *InteropDSL {
6666
setup := SetupInterop(t, opts...)
6767
actors := setup.CreateActors()
68-
actors.PrepareChainState(t)
69-
68+
actors.PrepareAndVerifyInitialState(t)
7069
t.Logf("ChainA: %v, ChainB: %v", actors.ChainA.ChainID, actors.ChainB.ChainID)
7170

7271
allChains := []*Chain{actors.ChainA, actors.ChainB}

op-e2e/actions/interop/dsl/interop.go

+31
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/syncnode"
3030
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
3131
"github.com/ethereum/go-ethereum/common"
32+
gethTypes "github.com/ethereum/go-ethereum/core/types"
3233
"github.com/ethereum/go-ethereum/crypto"
3334
)
3435

@@ -91,14 +92,21 @@ func (actors *InteropActors) PrepareChainState(t helpers.Testing) {
9192
actors.ChainA.Sequencer.ActL2PipelineFull(t)
9293
actors.ChainB.Sequencer.ActL2PipelineFull(t)
9394
t.Log("Processed!")
95+
}
9496

97+
func (actors *InteropActors) VerifyInitialState(t helpers.Testing) {
9598
// Verify initial state
9699
statusA := actors.ChainA.Sequencer.SyncStatus()
97100
statusB := actors.ChainB.Sequencer.SyncStatus()
98101
require.Equal(t, uint64(0), statusA.UnsafeL2.Number)
99102
require.Equal(t, uint64(0), statusB.UnsafeL2.Number)
100103
}
101104

105+
func (actors *InteropActors) PrepareAndVerifyInitialState(t helpers.Testing) {
106+
actors.PrepareChainState(t)
107+
actors.VerifyInitialState(t)
108+
}
109+
102110
// messageExpiryTime is the time in seconds that a message will be valid for on the L2 chain.
103111
// At a 2 second block time, this should be small enough to cover all events buffered in the supervisor event queue.
104112
const messageExpiryTime = 120 // 2 minutes
@@ -123,6 +131,15 @@ func SetMessageExpiryTime(expiryTime uint64) setupOption {
123131
}
124132
}
125133

134+
func SetInteropOffsetForAllL2s(offset uint64) setupOption {
135+
return func(recipe *interopgen.InteropDevRecipe) {
136+
for i, l2 := range recipe.L2s {
137+
l2.InteropOffset = offset
138+
recipe.L2s[i] = l2
139+
}
140+
}
141+
}
142+
126143
// SetupInterop creates an InteropSetup to instantiate actors on, with 2 L2 chains.
127144
func SetupInterop(t helpers.Testing, opts ...setupOption) *InteropSetup {
128145
recipe := interopgen.InteropDevRecipe{
@@ -307,3 +324,17 @@ func createL2Services(
307324
Batcher: batcher,
308325
}
309326
}
327+
328+
// Creates a new L2 block, submits it to L1, and mines the L1 block.
329+
func (actors *InteropActors) ActBatchAndMine(t helpers.Testing, chains ...*Chain) {
330+
var batches []*gethTypes.Transaction
331+
for _, c := range chains {
332+
c.Batcher.ActSubmitAll(t)
333+
batches = append(batches, c.Batcher.LastSubmitted)
334+
}
335+
actors.L1Miner.ActL1StartBlock(12)(t)
336+
for _, b := range batches {
337+
actors.L1Miner.ActL1IncludeTxByHash(b.Hash())(t)
338+
}
339+
actors.L1Miner.ActL1EndBlock(t)
340+
}

op-e2e/actions/interop/emitter_contract_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestEmitterContract(gt *testing.T) {
4545
actors = is.CreateActors()
4646
aliceA = setupUser(t, is, actors.ChainA, 0)
4747
aliceB = setupUser(t, is, actors.ChainB, 0)
48-
actors.PrepareChainState(t)
48+
actors.PrepareAndVerifyInitialState(t)
4949
emitTx = initializeEmitterContractTest(t, aliceA, actors)
5050
}
5151

op-e2e/actions/interop/interop_test.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestFullInterop(gt *testing.T) {
2323

2424
is := dsl.SetupInterop(t)
2525
actors := is.CreateActors()
26-
actors.PrepareChainState(t)
26+
actors.PrepareAndVerifyInitialState(t)
2727

2828
// sync the supervisor, handle initial events emitted by the nodes
2929
actors.ChainA.Sequencer.SyncSupervisor(t)
@@ -163,8 +163,7 @@ func TestFinality(gt *testing.T) {
163163
testFinality := func(t helpers.StatefulTesting, extraBlocks int) {
164164
is := dsl.SetupInterop(t)
165165
actors := is.CreateActors()
166-
actors.PrepareChainState(t)
167-
166+
actors.PrepareAndVerifyInitialState(t)
168167
actors.Supervisor.ProcessFull(t)
169168

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

243242
is := dsl.SetupInterop(t)
244243
actors := is.CreateActors()
245-
actors.PrepareChainState(t)
246-
244+
actors.PrepareAndVerifyInitialState(t)
247245
genesisB := actors.ChainB.Sequencer.SyncStatus()
248246

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

358356
is := dsl.SetupInterop(t)
359357
actors := is.CreateActors()
360-
actors.PrepareChainState(t)
361-
358+
actors.PrepareAndVerifyInitialState(t)
362359
// We create a batch with some empty blocks before and after the cross-chain message,
363360
// so multiple L2 blocks are all derived from the same L1 block.
364361
actors.ChainA.Sequencer.ActL2EmptyBlock(t)
@@ -439,7 +436,7 @@ func TestInteropExecutingMessageOutOfRangeLogIndex(gt *testing.T) {
439436
t := helpers.NewDefaultTesting(gt)
440437
is := dsl.SetupInterop(t)
441438
actors := is.CreateActors()
442-
actors.PrepareChainState(t)
439+
actors.PrepareAndVerifyInitialState(t)
443440
aliceA := setupUser(t, is, actors.ChainA, 0)
444441

445442
// Execute a fake log on chain A

op-e2e/actions/interop/interop_txplan_test.go

+12-14
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestTxPlanDeployEventLogger(gt *testing.T) {
7474

7575
is := dsl.SetupInterop(t)
7676
actors := is.CreateActors()
77-
actors.PrepareChainState(t)
77+
actors.PrepareAndVerifyInitialState(t)
7878

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

@@ -402,7 +402,8 @@ func TestInitAndExecMsgSameTimestamp(gt *testing.T) {
402402
rng := rand.New(rand.NewSource(1234))
403403
is := dsl.SetupInterop(t)
404404
actors := is.CreateActors()
405-
actors.PrepareChainState(t)
405+
actors.PrepareAndVerifyInitialState(t)
406+
406407
alice := setupUser(t, is, actors.ChainA, 0)
407408
bob := setupUser(t, is, actors.ChainB, 0)
408409

@@ -477,8 +478,7 @@ func TestBreakTimestampInvariant(gt *testing.T) {
477478
rng := rand.New(rand.NewSource(1234))
478479
is := dsl.SetupInterop(t)
479480
actors := is.CreateActors()
480-
actors.PrepareChainState(t)
481-
481+
actors.PrepareAndVerifyInitialState(t)
482482
alice := setupUser(t, is, actors.ChainA, 0)
483483
bob := setupUser(t, is, actors.ChainB, 0)
484484

@@ -576,8 +576,7 @@ func TestExecMsgDifferTxIndex(gt *testing.T) {
576576
rng := rand.New(rand.NewSource(1234))
577577
is := dsl.SetupInterop(t)
578578
actors := is.CreateActors()
579-
actors.PrepareChainState(t)
580-
579+
actors.PrepareAndVerifyInitialState(t)
581580
// only unsafe head of each chain progresses in this code block
582581
var targetNum uint64
583582
{
@@ -670,8 +669,7 @@ func TestExpiredMessage(gt *testing.T) {
670669
expiryTime := uint64(6)
671670
is := dsl.SetupInterop(t, dsl.SetMessageExpiryTime(expiryTime))
672671
actors := is.CreateActors()
673-
actors.PrepareChainState(t)
674-
672+
actors.PrepareAndVerifyInitialState(t)
675673
alice := setupUser(t, is, actors.ChainA, 0)
676674
bob := setupUser(t, is, actors.ChainB, 0)
677675

@@ -744,7 +742,7 @@ func TestCrossPatternSameTimestamp(gt *testing.T) {
744742
rng := rand.New(rand.NewSource(1234))
745743
is := dsl.SetupInterop(t)
746744
actors := is.CreateActors()
747-
actors.PrepareChainState(t)
745+
actors.PrepareAndVerifyInitialState(t)
748746
alice := setupUser(t, is, actors.ChainA, 0)
749747
bob := setupUser(t, is, actors.ChainB, 0)
750748

@@ -874,7 +872,7 @@ func TestCrossPatternSameTx(gt *testing.T) {
874872
rng := rand.New(rand.NewSource(1234))
875873
is := dsl.SetupInterop(t)
876874
actors := is.CreateActors()
877-
actors.PrepareChainState(t)
875+
actors.PrepareAndVerifyInitialState(t)
878876
alice := setupUser(t, is, actors.ChainA, 0)
879877
bob := setupUser(t, is, actors.ChainB, 0)
880878

@@ -965,7 +963,7 @@ func TestCycleInTx(gt *testing.T) {
965963
rng := rand.New(rand.NewSource(1234))
966964
is := dsl.SetupInterop(t)
967965
actors := is.CreateActors()
968-
actors.PrepareChainState(t)
966+
actors.PrepareAndVerifyInitialState(t)
969967
alice := setupUser(t, is, actors.ChainA, 0)
970968

971969
actors.ChainA.Sequencer.ActL2StartBlock(t)
@@ -1048,7 +1046,7 @@ func TestCycleInBlock(gt *testing.T) {
10481046
rng := rand.New(rand.NewSource(1234))
10491047
is := dsl.SetupInterop(t)
10501048
actors := is.CreateActors()
1051-
actors.PrepareChainState(t)
1049+
actors.PrepareAndVerifyInitialState(t)
10521050
alice := setupUser(t, is, actors.ChainA, 0)
10531051

10541052
actors.ChainA.Sequencer.ActL2StartBlock(t)
@@ -1131,7 +1129,7 @@ func TestCycleAcrossChainsSameTimestamp(gt *testing.T) {
11311129
rng := rand.New(rand.NewSource(1234))
11321130
is := dsl.SetupInterop(t)
11331131
actors := is.CreateActors()
1134-
actors.PrepareChainState(t)
1132+
actors.PrepareAndVerifyInitialState(t)
11351133
alice := setupUser(t, is, actors.ChainA, 0)
11361134
bob := setupUser(t, is, actors.ChainB, 0)
11371135

@@ -1226,7 +1224,7 @@ func TestCycleAcrossChainsSameTx(gt *testing.T) {
12261224
rng := rand.New(rand.NewSource(1234))
12271225
is := dsl.SetupInterop(t)
12281226
actors := is.CreateActors()
1229-
actors.PrepareChainState(t)
1227+
actors.PrepareAndVerifyInitialState(t)
12301228
alice := setupUser(t, is, actors.ChainA, 0)
12311229
bob := setupUser(t, is, actors.ChainB, 0)
12321230

op-e2e/actions/interop/reset_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func TestReset(gt *testing.T) {
1616

1717
is := dsl.SetupInterop(t)
1818
actors := is.CreateActors()
19-
actors.PrepareChainState(t)
20-
19+
actors.PrepareAndVerifyInitialState(t)
2120
// No blocks yet
2221
status := actors.ChainA.Sequencer.SyncStatus()
2322
require.Equal(t, uint64(0), status.UnsafeL2.Number)

0 commit comments

Comments
 (0)