Skip to content

Commit

Permalink
op-node: Define message expiry time constant (#14296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Inphi authored and maurelian committed Feb 11, 2025
1 parent 7f108b6 commit 8a740e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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))
}

0 comments on commit 8a740e8

Please sign in to comment.