Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-node: Define message expiry time constant #14296

Merged
merged 1 commit into from
Feb 10, 2025
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
4 changes: 3 additions & 1 deletion op-node/params/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package params

const (
// Post-Granite constant: Number of L1 blocks between when a channel can be opened and when it must be closed by.
// ChannelTimeoutGranite is a post-Granite constant: Number of L1 blocks between when a channel can be opened and when it must be closed by.
ChannelTimeoutGranite uint64 = 50
// MessageExpiryTimeSecondsInterop is a post-Interop constant for the minimum age of a message before it can be considered executable
MessageExpiryTimeSecondsInterop = 15552000
)
16 changes: 16 additions & 0 deletions op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/params"

altda "github.com/ethereum-optimism/optimism/op-alt-da"
opparams "github.com/ethereum-optimism/optimism/op-node/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
)

Expand Down Expand Up @@ -149,6 +150,11 @@ type Config struct {
// parameters to the protocol values, like the execution layer does.
// If missing, it is loaded by the op-node from the embedded superchain config at startup.
ChainOpConfig *params.OptimismConfig `json:"chain_op_config,omitempty"`

// OverrideMessageExpiryTimeInterop is only used for testing purposes.
// It is used to override the protocol-defined interop message time expiry.
// DO NOT this read value directly. Use GetMessageExpiryTimeInterop instead.
OverrideMessageExpiryTimeInterop uint64 `json:"override_message_expiry_time_interop,omitempty"`
}

// ValidateL1Config checks L1 config variables for errors.
Expand Down Expand Up @@ -610,6 +616,16 @@ func (c *Config) GetOPAltDAConfig() (altda.Config, error) {
}, nil
}

// GetMessageExpiryTimeInterop returns the expiry time of interop messages in seconds.
// If a message expiry override is set in the rollup config, it returns the override value.
// Otherwise, it returns the protocol-defined interop message time expiry.
func (c *Config) GetMessageExpiryTimeInterop() uint64 {
if c.OverrideMessageExpiryTimeInterop != 0 {
return c.OverrideMessageExpiryTimeInterop
}
return opparams.MessageExpiryTimeSecondsInterop
}

func (c *Config) AltDAEnabled() bool {
return c.AltDAConfig != nil
}
Expand Down
8 changes: 8 additions & 0 deletions op-node/rollup/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/ethereum/go-ethereum/common"

"github.com/ethereum-optimism/optimism/op-node/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
)

Expand Down Expand Up @@ -823,3 +824,10 @@ func TestConfigImplementsBlockType(t *testing.T) {
})
}
}

func TestConfig_GetMessageExpiryTimeInterop(t *testing.T) {
config := randConfig()
assert.Equal(t, config.GetMessageExpiryTimeInterop(), uint64(params.MessageExpiryTimeSecondsInterop))
config.OverrideMessageExpiryTimeInterop = 100
assert.Equal(t, config.GetMessageExpiryTimeInterop(), uint64(100))
}