From 751a80efcb01ee6cfd3e41afc7da20d924473c35 Mon Sep 17 00:00:00 2001 From: Kevin Jang Date: Thu, 16 Jan 2025 08:10:23 -0800 Subject: [PATCH] feat: add sequencer dangerous flag to disable tx size checks adding the `disable-seq-inbox-max-data-size-check` flag under a new `dangerous` field in the sequencer config. this config disables the check in `nitro.go` that compares the sequencer MaxTxDataSize to ensure that it is at least 15kB below the sequencer inbox's MaxDataSize. discussions with offchain labs on slack helped clarify that this should be a dangerous flag because it breaks batcher manual fallbacks in case the DA layer is down. if the sequencer MaxTxDataSize is too high, there is no way the txs(and further the batches) into the sequencer inbox on the parent chain in a manual fallback scenario. had some difficulties with the naming of this flag to fit all of the needed context. the sequencer inbox MaxTxDataSize is checked two times. once against the sequencer inbox MaxDataSize(in `nitro.go`, we are trying to disable this one) and the other time against arbostypes.MaxL2MessageSize(in `sequencer.go`, not disabling this check). it can be quite verbose to try to spell out the entire interaction(like `DisableMaxTxDataSizeCheckAgainstSeqInboxMaxDataSize`) to avoid confusion on the exact check that is being targeted. on the other hand, i dont see any precedent in any other configs to nest the `dangerous` section(like `sequencer.dangerous.max-tx-data-size.disable-seq-inbox-max-data-size-check`). for now, i shortened it down to `DisableSeqInboxMaxDataSizeCheck`, but i understand this can leave some ambiguity. as this is my first contribution to this repo, please let me know what kind of style you all prefer. with this new dangerous flag, the new limit for sequencer MaxTxDataSize should be ~212kB(`arbostypes.MaxL2MessageSize-50000`). internal context for the offchain labs team: https://alchemyinsights.slack.com/archives/C06SZ7EKS2H/p1736987075713719 --- cmd/nitro/nitro.go | 14 +++++++++----- execution/gethexec/sequencer.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index e4e1b79353..b697902f7e 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -580,12 +580,16 @@ func mainImpl() int { return 1 } } - // If sequencer is enabled, validate MaxTxDataSize to be at least 5kB below the batch poster's MaxSize to allow space for headers and such. - // And since batchposter's MaxSize is to be at least 10kB below the sequencer inbox’s maxDataSize, this leads to another condition of atlest 15kB below the sequencer inbox’s maxDataSize. + if nodeConfig.Execution.Sequencer.Enable { - if nodeConfig.Execution.Sequencer.MaxTxDataSize > nodeConfig.Node.BatchPoster.MaxSize-5000 || - nodeConfig.Execution.Sequencer.MaxTxDataSize > seqInboxMaxDataSize-15000 { - log.Error("sequencer's MaxTxDataSize too large") + // Validate MaxTxDataSize to be at least 5kB below the batch poster's MaxSize to allow space for headers and such. + if nodeConfig.Execution.Sequencer.MaxTxDataSize > nodeConfig.Node.BatchPoster.MaxSize-5000 { + log.Error("sequencer's MaxTxDataSize too large compared to the batchPoster's MaxSize") + return 1 + } + // Since the batchposter's MaxSize must be at least 10kB below the sequencer inbox’s maxDataSize, then MaxTxDataSize must also be 15kB below the sequencer inbox’s maxDataSize. + if nodeConfig.Execution.Sequencer.MaxTxDataSize > seqInboxMaxDataSize-15000 && !nodeConfig.Execution.Sequencer.Dangerous.DisableSeqInboxMaxDataSizeCheck { + log.Error("sequencer's MaxTxDataSize too large compared to the sequencer inbox's MaxDataSize") return 1 } } diff --git a/execution/gethexec/sequencer.go b/execution/gethexec/sequencer.go index faded7375c..ce5394865a 100644 --- a/execution/gethexec/sequencer.go +++ b/execution/gethexec/sequencer.go @@ -68,6 +68,7 @@ type SequencerConfig struct { MaxAcceptableTimestampDelta time.Duration `koanf:"max-acceptable-timestamp-delta" reload:"hot"` SenderWhitelist []string `koanf:"sender-whitelist"` Forwarder ForwarderConfig `koanf:"forwarder"` + Dangerous DangerousConfig `koanf:"dangerous"` QueueSize int `koanf:"queue-size"` QueueTimeout time.Duration `koanf:"queue-timeout" reload:"hot"` NonceCacheSize int `koanf:"nonce-cache-size" reload:"hot"` @@ -119,6 +120,7 @@ var DefaultSequencerConfig = SequencerConfig{ MaxAcceptableTimestampDelta: time.Hour, SenderWhitelist: []string{}, Forwarder: DefaultSequencerForwarderConfig, + Dangerous: DefaultDangerousConfig, QueueSize: 1024, QueueTimeout: time.Second * 12, NonceCacheSize: 1024, @@ -139,6 +141,7 @@ func SequencerConfigAddOptions(prefix string, f *flag.FlagSet) { f.Duration(prefix+".max-acceptable-timestamp-delta", DefaultSequencerConfig.MaxAcceptableTimestampDelta, "maximum acceptable time difference between the local time and the latest L1 block's timestamp") f.StringSlice(prefix+".sender-whitelist", DefaultSequencerConfig.SenderWhitelist, "comma separated whitelist of authorized senders (if empty, everyone is allowed)") AddOptionsForSequencerForwarderConfig(prefix+".forwarder", f) + AddOptionsForDangerousConfig(prefix+".dangerous", f) f.Int(prefix+".queue-size", DefaultSequencerConfig.QueueSize, "size of the pending tx queue") f.Duration(prefix+".queue-timeout", DefaultSequencerConfig.QueueTimeout, "maximum amount of time transaction can wait in queue") f.Int(prefix+".nonce-cache-size", DefaultSequencerConfig.NonceCacheSize, "size of the tx sender nonce cache") @@ -150,6 +153,18 @@ func SequencerConfigAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".enable-profiling", DefaultSequencerConfig.EnableProfiling, "enable CPU profiling and tracing") } +type DangerousConfig struct { + DisableSeqInboxMaxDataSizeCheck bool `koanf:"disable-seq-inbox-max-data-size-check"` +} + +var DefaultDangerousConfig = DangerousConfig{ + DisableSeqInboxMaxDataSizeCheck: false, +} + +func AddOptionsForDangerousConfig(prefix string, f *flag.FlagSet) { + f.Bool(prefix+".disable-seq-inbox-max-data-size-check", DefaultDangerousConfig.DisableSeqInboxMaxDataSizeCheck, "DANGEROUS! disables nitro checks on sequencer MaxTxDataSize against the sequencer inbox MaxDataSize") +} + type txQueueItem struct { tx *types.Transaction txSize int // size in bytes of the marshalled transaction