Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rollup.Config implements types.BlockType interface
Browse files Browse the repository at this point in the history
vdamle committed Dec 17, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 71eb8d6 commit 6054bed
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
@@ -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 {
34 changes: 34 additions & 0 deletions op-node/rollup/types_test.go
Original file line number Diff line number Diff line change
@@ -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 6054bed

Please sign in to comment.