Skip to content
Open
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
55 changes: 55 additions & 0 deletions node/blocktag/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package blocktag

import (
"fmt"
"time"

"github.com/morph-l2/go-ethereum/common"
"github.com/urfave/cli"

node "morph-l2/node/core"
"morph-l2/node/flags"
)

const (
// DefaultSafeConfirmations is the default number of L1 blocks to wait before considering a batch as safe
DefaultSafeConfirmations = 10
// DefaultPollInterval is the default interval to poll L1 for batch status updates
DefaultPollInterval = 10 * time.Second
)

// Config holds the configuration for BlockTagService
type Config struct {
L1Addr string
RollupAddress common.Address
SafeConfirmations uint64
PollInterval time.Duration
}

// DefaultConfig returns the default configuration
func DefaultConfig() *Config {
return &Config{
SafeConfirmations: DefaultSafeConfirmations,
PollInterval: DefaultPollInterval,
}
}

// SetCliContext sets the configuration from CLI context
func (c *Config) SetCliContext(ctx *cli.Context) error {
c.L1Addr = ctx.GlobalString(flags.L1NodeAddr.Name)

// Determine RollupAddress: use explicit flag, or mainnet default, or error
if ctx.GlobalBool(flags.MainnetFlag.Name) {
c.RollupAddress = node.MainnetRollupContractAddress
} else if ctx.GlobalIsSet(flags.RollupContractAddress.Name) {
c.RollupAddress = common.HexToAddress(ctx.GlobalString(flags.RollupContractAddress.Name))
} else {
return fmt.Errorf("rollup contract address is required: either specify --%s or use --%s for mainnet default",
flags.RollupContractAddress.Name, flags.MainnetFlag.Name)
}

if ctx.GlobalIsSet(flags.BlockTagSafeConfirmations.Name) {
c.SafeConfirmations = ctx.GlobalUint64(flags.BlockTagSafeConfirmations.Name)
}
return nil
}
Loading
Loading