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

Test that parsing an empty CLI option set results in a default config #1661

Merged
merged 23 commits into from
Oct 11, 2023
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
9 changes: 7 additions & 2 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"

"github.com/offchainlabs/nitro/arbnode/dataposter"
"github.com/offchainlabs/nitro/arbnode/dataposter/storage"
"github.com/offchainlabs/nitro/arbnode/redislock"
Expand All @@ -47,6 +48,7 @@ import (
var (
batchPosterWalletBalance = metrics.NewRegisteredGaugeFloat64("arb/batchposter/wallet/balanceether", nil)
batchPosterGasRefunderBalance = metrics.NewRegisteredGaugeFloat64("arb/batchposter/gasrefunder/balanceether", nil)
batchPosterSimpleRedisLockKey = "node.batch-poster.redis-lock.simple-lock-key"
)

type batchPosterPosition struct {
Expand Down Expand Up @@ -166,7 +168,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
f.String(prefix+".l1-block-bound", DefaultBatchPosterConfig.L1BlockBound, "only post messages to batches when they're within the max future block/timestamp as of this L1 block tag (\"safe\", \"finalized\", \"latest\", or \"ignore\" to ignore this check)")
f.Duration(prefix+".l1-block-bound-bypass", DefaultBatchPosterConfig.L1BlockBoundBypass, "post batches even if not within the layer 1 future bounds if we're within this margin of the max delay")
redislock.AddConfigOptions(prefix+".redis-lock", f)
dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f)
dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfig)
genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultBatchPosterConfig.ParentChainWallet.Pathname)
}

Expand All @@ -187,6 +189,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{
ParentChainWallet: DefaultBatchPosterL1WalletConfig,
L1BlockBound: "",
L1BlockBoundBypass: time.Hour,
RedisLock: redislock.DefaultCfg,
}

var DefaultBatchPosterL1WalletConfig = genericconf.WalletConfig{
Expand Down Expand Up @@ -235,7 +238,9 @@ func NewBatchPoster(ctx context.Context, dataPosterDB ethdb.Database, l1Reader *
return nil, err
}
redisLockConfigFetcher := func() *redislock.SimpleCfg {
return &config().RedisLock
simpleRedisLockConfig := config().RedisLock
simpleRedisLockConfig.Key = batchPosterSimpleRedisLockKey
return &simpleRedisLockConfig
}
redisLock, err := redislock.NewSimple(redisClient, redisLockConfigFetcher, func() bool { return syncMonitor.Synced() })
if err != nil {
Expand Down
30 changes: 15 additions & 15 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,21 +662,21 @@ type DangerousConfig struct {
// that flags can be reloaded dynamically.
type ConfigFetcher func() *DataPosterConfig

func DataPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
f.String(prefix+".replacement-times", DefaultDataPosterConfig.ReplacementTimes, "comma-separated list of durations since first posting to attempt a replace-by-fee")
f.Bool(prefix+".wait-for-l1-finality", DefaultDataPosterConfig.WaitForL1Finality, "only treat a transaction as confirmed after L1 finality has been achieved (recommended)")
f.Uint64(prefix+".max-mempool-transactions", DefaultDataPosterConfig.MaxMempoolTransactions, "the maximum number of transactions to have queued in the mempool at once (0 = unlimited)")
f.Int(prefix+".max-queued-transactions", DefaultDataPosterConfig.MaxQueuedTransactions, "the maximum number of unconfirmed transactions to track at once (0 = unlimited)")
f.Float64(prefix+".target-price-gwei", DefaultDataPosterConfig.TargetPriceGwei, "the target price to use for maximum fee cap calculation")
f.Float64(prefix+".urgency-gwei", DefaultDataPosterConfig.UrgencyGwei, "the urgency to use for maximum fee cap calculation")
f.Float64(prefix+".min-fee-cap-gwei", DefaultDataPosterConfig.MinFeeCapGwei, "the minimum fee cap to post transactions at")
f.Float64(prefix+".min-tip-cap-gwei", DefaultDataPosterConfig.MinTipCapGwei, "the minimum tip cap to post transactions at")
f.Float64(prefix+".max-tip-cap-gwei", DefaultDataPosterConfig.MaxTipCapGwei, "the maximum tip cap to post transactions at")
f.Uint64(prefix+".nonce-rbf-soft-confs", DefaultDataPosterConfig.NonceRbfSoftConfs, "the maximum probable reorg depth, used to determine when a transaction will no longer likely need replaced-by-fee")
f.Bool(prefix+".allocate-mempool-balance", DefaultDataPosterConfig.AllocateMempoolBalance, "if true, don't put transactions in the mempool that spend a total greater than the batch poster's balance")
f.Bool(prefix+".use-db-storage", DefaultDataPosterConfig.UseDBStorage, "uses database storage when enabled")
f.Bool(prefix+".use-noop-storage", DefaultDataPosterConfig.UseNoOpStorage, "uses noop storage, it doesn't store anything")
f.Bool(prefix+".legacy-storage-encoding", DefaultDataPosterConfig.LegacyStorageEncoding, "encodes items in a legacy way (as it was before dropping generics)")
func DataPosterConfigAddOptions(prefix string, f *pflag.FlagSet, defaultDataPosterConfig DataPosterConfig) {
f.String(prefix+".replacement-times", defaultDataPosterConfig.ReplacementTimes, "comma-separated list of durations since first posting to attempt a replace-by-fee")
f.Bool(prefix+".wait-for-l1-finality", defaultDataPosterConfig.WaitForL1Finality, "only treat a transaction as confirmed after L1 finality has been achieved (recommended)")
f.Uint64(prefix+".max-mempool-transactions", defaultDataPosterConfig.MaxMempoolTransactions, "the maximum number of transactions to have queued in the mempool at once (0 = unlimited)")
f.Int(prefix+".max-queued-transactions", defaultDataPosterConfig.MaxQueuedTransactions, "the maximum number of unconfirmed transactions to track at once (0 = unlimited)")
f.Float64(prefix+".target-price-gwei", defaultDataPosterConfig.TargetPriceGwei, "the target price to use for maximum fee cap calculation")
f.Float64(prefix+".urgency-gwei", defaultDataPosterConfig.UrgencyGwei, "the urgency to use for maximum fee cap calculation")
f.Float64(prefix+".min-fee-cap-gwei", defaultDataPosterConfig.MinFeeCapGwei, "the minimum fee cap to post transactions at")
f.Float64(prefix+".min-tip-cap-gwei", defaultDataPosterConfig.MinTipCapGwei, "the minimum tip cap to post transactions at")
f.Float64(prefix+".max-tip-cap-gwei", defaultDataPosterConfig.MaxTipCapGwei, "the maximum tip cap to post transactions at")
f.Uint64(prefix+".nonce-rbf-soft-confs", defaultDataPosterConfig.NonceRbfSoftConfs, "the maximum probable reorg depth, used to determine when a transaction will no longer likely need replaced-by-fee")
f.Bool(prefix+".allocate-mempool-balance", defaultDataPosterConfig.AllocateMempoolBalance, "if true, don't put transactions in the mempool that spend a total greater than the batch poster's balance")
f.Bool(prefix+".use-db-storage", defaultDataPosterConfig.UseDBStorage, "uses database storage when enabled")
f.Bool(prefix+".use-noop-storage", defaultDataPosterConfig.UseNoOpStorage, "uses noop storage, it doesn't store anything")
f.Bool(prefix+".legacy-storage-encoding", defaultDataPosterConfig.LegacyStorageEncoding, "encodes items in a legacy way (as it was before dropping generics)")

signature.SimpleHmacConfigAddOptions(prefix+".redis-signer", f)
addDangerousOptions(prefix+".dangerous", f)
Expand Down
1 change: 1 addition & 0 deletions arbnode/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func MaintenanceConfigAddOptions(prefix string, f *flag.FlagSet) {

var DefaultMaintenanceConfig = MaintenanceConfig{
TimeOfDay: "",
Lock: redislock.DefaultCfg,

minutesAfterMidnight: 0,
}
Expand Down
1 change: 1 addition & 0 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ var ConfigDefault = Config{
Dangerous: DefaultDangerousConfig,
TransactionStreamer: DefaultTransactionStreamerConfig,
ResourceMgmt: resourcemanager.DefaultConfig,
Maintenance: DefaultMaintenanceConfig,
}

func ConfigDefaultL1Test() *Config {
Expand Down
2 changes: 1 addition & 1 deletion arbnode/redislock/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func AddConfigOptions(prefix string, f *flag.FlagSet) {
f.String(prefix+".my-id", "", "this node's id prefix when acquiring the lock (optional)")
f.Duration(prefix+".lockout-duration", DefaultCfg.LockoutDuration, "how long lock is held")
f.Duration(prefix+".refresh-duration", DefaultCfg.RefreshDuration, "how long between consecutive calls to redis")
f.String(prefix+".key", prefix+".simple-lock-key", "key for lock")
f.String(prefix+".key", DefaultCfg.Key, "key for lock")
f.Bool(prefix+".background-lock", DefaultCfg.BackgroundLock, "should node always try grabing lock in background")
}

Expand Down
2 changes: 1 addition & 1 deletion broadcastclient/broadcastclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var DefaultConfig = Config{
RequireChainId: false,
RequireFeedVersion: false,
Verify: signature.DefultFeedVerifierConfig,
URL: []string{""},
URL: []string{},
Timeout: 20 * time.Second,
EnableCompression: true,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/genericconf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ConfConfigAddOptions(prefix string, f *flag.FlagSet) {
var ConfConfigDefault = ConfConfig{
Dump: false,
EnvPrefix: "",
File: nil,
File: []string{},
S3: DefaultS3Config,
String: "",
ReloadInterval: 0,
Expand Down
6 changes: 3 additions & 3 deletions cmd/genericconf/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var HTTPConfigDefault = HTTPConfig{
Port: 8547,
API: append(node.DefaultConfig.HTTPModules, "eth", "arb"),
RPCPrefix: node.DefaultConfig.HTTPPathPrefix,
CORSDomain: node.DefaultConfig.HTTPCors,
CORSDomain: []string{},
VHosts: node.DefaultConfig.HTTPVirtualHosts,
ServerTimeouts: HTTPServerTimeoutConfigDefault,
}
Expand Down Expand Up @@ -91,7 +91,7 @@ var WSConfigDefault = WSConfig{
Port: 8548,
API: append(node.DefaultConfig.WSModules, "eth", "arb"),
RPCPrefix: node.DefaultConfig.WSPathPrefix,
Origins: node.DefaultConfig.WSOrigins,
Origins: []string{},
ExposeAll: node.DefaultConfig.WSExposeAll,
}

Expand Down Expand Up @@ -137,7 +137,7 @@ type GraphQLConfig struct {

var GraphQLConfigDefault = GraphQLConfig{
Enable: false,
CORSDomain: node.DefaultConfig.GraphQLCors,
CORSDomain: []string{},
VHosts: node.DefaultConfig.GraphQLVirtualHosts,
}

Expand Down
19 changes: 19 additions & 0 deletions cmd/nitro/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,29 @@ import (
"time"

"github.com/offchainlabs/nitro/cmd/genericconf"
"github.com/offchainlabs/nitro/cmd/util/confighelpers"
"github.com/offchainlabs/nitro/util/colors"
"github.com/offchainlabs/nitro/util/testhelpers"

"github.com/r3labs/diff/v3"
flag "github.com/spf13/pflag"
)

func TestEmptyCliConfig(t *testing.T) {
f := flag.NewFlagSet("", flag.ContinueOnError)
NodeConfigAddOptions(f)
k, err := confighelpers.BeginCommonParse(f, []string{})
Require(t, err)
var emptyCliNodeConfig NodeConfig
err = confighelpers.EndCommonParse(k, &emptyCliNodeConfig)
Require(t, err)
if !reflect.DeepEqual(emptyCliNodeConfig, NodeConfigDefault) {
changelog, err := diff.Diff(emptyCliNodeConfig, NodeConfigDefault)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use cmp.Diff elsewhere, which could also replace the reflect.DeepEqual call I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah actually initially i was using cmp.Diff only but i am running into this issue with it

cannot handle unexported field at {main.NodeConfig}.Node.BatchPoster.gasRefunder: "github.com/offchainlabs/nitro/arbnode".BatchPosterConfig consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported [recovered] panic: cannot handle unexported field at {main.NodeConfig}.Node.BatchPoster.gasRefunder: "github.com/offchainlabs/nitro/arbnode".BatchPosterConfig consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported

Wasn't sure how solve it in a generic manner so that it does not happen when add a new struct, hence moved to reflect.DeepEqual, let me know you have ideas on how to solve it. Thanks.

Require(t, err)
Fail(t, "empty cli config differs from expected default", changelog)
}
}

func TestSeqConfig(t *testing.T) {
args := strings.Split("--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --parent-chain.wallet.pathname /l1keystore --parent-chain.wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.sequencer --execution.sequencer.enable --node.feed.output.enable --node.feed.output.port 9642", " ")
_, _, _, err := ParseNode(context.Background(), args)
Expand Down
7 changes: 7 additions & 0 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,23 @@ type NodeConfig struct {
var NodeConfigDefault = NodeConfig{
Conf: genericconf.ConfConfigDefault,
Node: arbnode.ConfigDefault,
Execution: gethexec.ConfigDefault,
Validation: valnode.DefaultValidationConfig,
ParentChain: conf.L1ConfigDefault,
Chain: conf.L2ConfigDefault,
LogLevel: int(log.LvlInfo),
LogType: "plaintext",
FileLogging: genericconf.DefaultFileLoggingConfig,
Persistent: conf.PersistentConfigDefault,
HTTP: genericconf.HTTPConfigDefault,
WS: genericconf.WSConfigDefault,
IPC: genericconf.IPCConfigDefault,
Auth: genericconf.AuthRPCConfigDefault,
GraphQL: genericconf.GraphQLConfigDefault,
Metrics: false,
MetricsServer: genericconf.MetricsServerConfigDefault,
Init: InitConfigDefault,
Rpc: genericconf.DefaultRpcConfig,
PProf: false,
PprofCfg: genericconf.PProfDefault,
}
Expand Down
1 change: 1 addition & 0 deletions das/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var DefaultDataAvailabilityConfig = DataAvailabilityConfig{
RestAggregator: DefaultRestfulClientAggregatorConfig,
ParentChainConnectionAttempts: 15,
PanicOnError: false,
IpfsStorage: DefaultIpfsStorageServiceConfig,
}

func OptionalAddressFromString(s string) (*common.Address, error) {
Expand Down
1 change: 1 addition & 0 deletions execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var ConfigDefault = Config{
TxLookupLimit: 126_230_400, // 1 year at 4 blocks per second
Caching: DefaultCachingConfig,
Dangerous: DefaultDangerousConfig,
Forwarder: DefaultNodeForwarderConfig,
}

func ConfigDefaultNonSequencerTest() *Config {
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ require (
github.com/libp2p/go-libp2p v0.27.8
github.com/multiformats/go-multiaddr v0.9.0
github.com/multiformats/go-multihash v0.2.1
github.com/r3labs/diff/v3 v3.0.1
github.com/rivo/tview v0.0.0-20230814110005-ccc2c8119703
github.com/spf13/pflag v1.0.5
github.com/wealdtech/go-merkletree v1.0.0
Expand Down Expand Up @@ -237,6 +238,8 @@ require (
github.com/samber/lo v1.36.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,8 @@ github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y
github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA=
github.com/quic-go/webtransport-go v0.5.2 h1:GA6Bl6oZY+g/flt00Pnu0XtivSD8vukOu3lYhJjnGEk=
github.com/quic-go/webtransport-go v0.5.2/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU=
github.com/r3labs/diff/v3 v3.0.1 h1:CBKqf3XmNRHXKmdU7mZP1w7TV0pDyVCis1AUHtA4Xtg=
github.com/r3labs/diff/v3 v3.0.1/go.mod h1:f1S9bourRbiM66NskseyUdo0fTmEE0qKrikYJX63dgo=
github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM=
github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk=
github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU=
Expand Down Expand Up @@ -1599,6 +1601,10 @@ github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE=
github.com/warpfork/go-testmark v0.3.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0=
github.com/warpfork/go-testmark v0.9.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0=
Expand Down
2 changes: 1 addition & 1 deletion staker/staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func L1ValidatorConfigAddOptions(prefix string, f *flag.FlagSet) {
f.String(prefix+".gas-refunder-address", DefaultL1ValidatorConfig.GasRefunderAddress, "The gas refunder contract address (optional)")
f.String(prefix+".redis-url", DefaultL1ValidatorConfig.RedisUrl, "redis url for L1 validator")
f.Uint64(prefix+".extra-gas", DefaultL1ValidatorConfig.ExtraGas, "use this much more gas than estimation says is necessary to post transactions")
dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f)
dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfigForValidator)
redislock.AddConfigOptions(prefix+".redis-lock", f)
DangerousConfigAddOptions(prefix+".dangerous", f)
genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultL1ValidatorConfig.ParentChainWallet.Pathname)
Expand Down
1 change: 1 addition & 0 deletions util/headerreader/header_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func AddOptions(prefix string, f *flag.FlagSet) {
f.Bool(prefix+".poll-only", DefaultConfig.PollOnly, "do not attempt to subscribe to header events")
f.Bool(prefix+".use-finality-data", DefaultConfig.UseFinalityData, "use l1 data about finalized/safe blocks")
f.Duration(prefix+".poll-interval", DefaultConfig.PollInterval, "interval when polling endpoint")
f.Duration(prefix+".subscribe-err-interval", DefaultConfig.SubscribeErrInterval, "interval for subscribe error")
f.Duration(prefix+".tx-timeout", DefaultConfig.TxTimeout, "timeout when waiting for a transaction")
f.Duration(prefix+".old-header-timeout", DefaultConfig.OldHeaderTimeout, "warns if the latest l1 block is at least this old")
}
Expand Down
6 changes: 6 additions & 0 deletions util/signature/sign_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func SignVerifyConfigAddOptions(prefix string, f *flag.FlagSet) {
}

var DefaultSignVerifyConfig = SignVerifyConfig{
ECDSA: DefultFeedVerifierConfig,
SymmetricFallback: false,
SymmetricSign: false,
Symmetric: EmptySimpleHmacConfig,
}
var TestSignVerifyConfig = SignVerifyConfig{
ECDSA: VerifierConfig{
AcceptSequencer: true,
},
Expand Down
6 changes: 3 additions & 3 deletions util/signature/sign_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ func TestSignVerifyModes(t *testing.T) {
signingAddr := crypto.PubkeyToAddress(privateKey.PublicKey)
dataSigner := DataSignerFromPrivateKey(privateKey)

config := DefaultSignVerifyConfig
config := TestSignVerifyConfig
config.SymmetricFallback = false
config.SymmetricSign = false
config.ECDSA.AcceptSequencer = false
config.ECDSA.AllowedAddresses = []string{signingAddr.Hex()}
signVerifyECDSA, err := NewSignVerify(&config, dataSigner, nil)
Require(t, err)

configSymmetric := DefaultSignVerifyConfig
configSymmetric := TestSignVerifyConfig
configSymmetric.SymmetricFallback = true
configSymmetric.SymmetricSign = true
configSymmetric.ECDSA.AcceptSequencer = false
signVerifySymmetric, err := NewSignVerify(&configSymmetric, nil, nil)
Require(t, err)

configFallback := DefaultSignVerifyConfig
configFallback := TestSignVerifyConfig
configFallback.SymmetricFallback = true
configFallback.SymmetricSign = false
configFallback.ECDSA.AllowedAddresses = []string{signingAddr.Hex()}
Expand Down
2 changes: 1 addition & 1 deletion util/signature/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var ErrMissingSignature = fmt.Errorf("%w: signature not found", ErrSignatureNotV
var ErrSignerNotApproved = fmt.Errorf("%w: signer not approved", ErrSignatureNotVerified)

func FeedVerifierConfigAddOptions(prefix string, f *flag.FlagSet) {
f.StringArray(prefix+".allowed-addresses", DefultFeedVerifierConfig.AllowedAddresses, "a list of allowed addresses")
f.StringSlice(prefix+".allowed-addresses", DefultFeedVerifierConfig.AllowedAddresses, "a list of allowed addresses")
f.Bool(prefix+".accept-sequencer", DefultFeedVerifierConfig.AcceptSequencer, "accept verified message from sequencer")
DangerousFeedVerifierConfigAddOptions(prefix+".dangerous", f)
}
Expand Down
Loading