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

feat: add sequencer dangerous flag to disable tx size checks #2885

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 9 additions & 5 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
15 changes: 15 additions & 0 deletions execution/gethexec/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -119,6 +120,7 @@ var DefaultSequencerConfig = SequencerConfig{
MaxAcceptableTimestampDelta: time.Hour,
SenderWhitelist: []string{},
Forwarder: DefaultSequencerForwarderConfig,
Dangerous: DefaultDangerousConfig,
QueueSize: 1024,
QueueTimeout: time.Second * 12,
NonceCacheSize: 1024,
Expand All @@ -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")
Expand All @@ -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
Expand Down
Loading