Skip to content

Commit

Permalink
rollup.Config implements types.BlockType interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vdamle committed Dec 16, 2024
1 parent 9d9ce01 commit 349081f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ func (cfg *Config) Check() error {
return nil
}

func (cfg *Config) HasOptimismWithdrawalsRoot(timestamp uint64) bool {
return cfg.IsIsthmus(timestamp)
}

// validateAltDAConfig checks the two approaches to configuring alt-da mode.
// If the legacy values are set, they are copied to the new location. If both are set, they are check for consistency.
func validateAltDAConfig(cfg *Config) error {
Expand Down
34 changes: 34 additions & 0 deletions op-node/rollup/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,37 @@ func TestConfig_IsActivationBlock(t *testing.T) {
require.Zero(t, cfg.IsActivationBlock(ts, ts+1))
}
}

func TestConfigImplementsBlockType(t *testing.T) {
config := randConfig()
isthmusTime := uint64(100)
config.IsthmusTime = &isthmusTime
tests := []struct {
name string
blockTime uint64
hasOptimismWithdrawalsRoot bool
}{
{
name: "BeforeIsthmus",
blockTime: uint64(99),
hasOptimismWithdrawalsRoot: false,
},
{
name: "AtIsthmus",
blockTime: uint64(100),
hasOptimismWithdrawalsRoot: true,
},
{
name: "AfterIsthmus",
blockTime: uint64(200),
hasOptimismWithdrawalsRoot: true,
},
}

for _, test := range tests {
test := test
t.Run(fmt.Sprintf("TestHasOptimismWithdrawalsRoot_%s", test.name), func(t *testing.T) {
assert.Equal(t, config.HasOptimismWithdrawalsRoot(test.blockTime), test.hasOptimismWithdrawalsRoot)
})
}
}

0 comments on commit 349081f

Please sign in to comment.