-
Notifications
You must be signed in to change notification settings - Fork 472
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
Don't post a batch that would cause a reorg due to being outside (or near) the time bounds #2340
Conversation
…near) the time bounds
if (config.ReorgResistanceMargin > 0 && config.ReorgResistanceMargin < config.MaxDelay) && | ||
(batchDuration >= config.MaxDelay-config.ReorgResistanceMargin) && | ||
(batchDuration <= config.MaxDelay || (batchDuration <= config.MaxDelay+config.ReorgResistanceMargin && !config.IgnoreReorgResistanceMargin)) { | ||
disablePosting = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should log an error here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added it
arbnode/batch_poster.go
Outdated
@@ -156,6 +156,8 @@ type BatchPosterConfig struct { | |||
L1BlockBoundBypass time.Duration `koanf:"l1-block-bound-bypass" reload:"hot"` | |||
UseAccessLists bool `koanf:"use-access-lists" reload:"hot"` | |||
GasEstimateBaseFeeMultipleBips arbmath.Bips `koanf:"gas-estimate-base-fee-multiple-bips"` | |||
ReorgResistanceMargin time.Duration `koanf:"reorg-resistance-margin" reload:"hot"` | |||
IgnoreReorgResistanceMargin bool `koanf:"ignore-reorg-resistance-margin" reload:"hot"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional(Nit): Prefer using boolean flags with a positive phrasing. Maybe "EnableReorgResistanceMargin" or "EnforceReorgResistanceMargin". When you have a negative like "Ignore" or "Disable" it means that you have to mentally negate the meaning of the boolean which slightly deteriorates the readability of the code.
arbnode/batch_poster.go
Outdated
batchDuration := time.Since(firstMsgTime) | ||
if (config.ReorgResistanceMargin > 0 && config.ReorgResistanceMargin < config.MaxDelay) && | ||
(batchDuration >= config.MaxDelay-config.ReorgResistanceMargin) && | ||
(batchDuration <= config.MaxDelay || (batchDuration <= config.MaxDelay+config.ReorgResistanceMargin && !config.IgnoreReorgResistanceMargin)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally having trouble reasoning through this compound condition. For example, I wonder why we are only checking config.IgnoreReorgResistanceMargin
in the last parenthetical ||
instead of in the other places where the value of the config.ReorgResistanceMargin
is being checked. Like, why don't we only ignore the config.ReorgResistanceMargin
when checking <=
instead of for both <=
and >=
?
Maybe some test-cases would make it easier to see the truth table of when this clause should disable posting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @eljobe on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the if condition is quite complex, I'll try to split it into multiple stages for clarity.
When the batch's duration is between config.MaxDelay-config.ReorgResistanceMargin
and config.MaxDelay
we will definitely pause posting of batches.
And when its between config.MaxDelay
and config.MaxDelay+config.ReorgResistanceMargin
we provide an option to prioritize MaxDelay
's purpose over ReorgResistanceMargin
's.
IgnoreReorgResistanceMargin
flag is used to achieve this.
Line 1123 in 7373a4e
forcePostBatch := config.MaxDelay <= 0 || time.Since(firstMsgTime) >= config.MaxDelay |
I'll rename IgnoreReorgResistanceMargin
flag to something like PrioritizeMaxDelayOverReorgResistance
which captures its purpose clearly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Resolves NIT-2524