-
Notifications
You must be signed in to change notification settings - Fork 467
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
Fix off-by-one in data poster nonce check #2326
Conversation
return nil | ||
} | ||
} else { | ||
log.Info("DataPoster will send previously unsent batch tx", "nonce", newTx.FullTx.Nonce(), "prevType", precedingTx.FullTx.Type(), "type", newTx.FullTx.Type(), "prevSent", precedingTx.Sent, "latestBlockNumber", latestBlockNumber, "prevBlockNumber", prevBlockNumber, "reorgResistantNonce", reorgResistantNonce) | ||
} |
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 think it needs to be at the inner level here since precedingTx
can be nil, and also I put it at that level because didn't want to spam too many of these logs when the tx was previously sent.
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.
Did you mean to put it in the else? Most of the fields are only populated in the if case which is why I was confused
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.
In the current level of nesting I believe precedingTx is always non-nil, and I changed it to a debug log (instead of info) to make it a bit quieter
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
The "reorg resistant nonce" is really a reorg resistant tx count, which is one higher than the tx nonce that won't be reorged. In other words, if the previous tx is equal to the reorg resistant tx count, then the previous tx can still be reorged (only the one before it is safe). This PR fixes that by comparing it to the new tx nonce. If the new tx nonce is greater than the reorg resistant tx count, then that means that there's a gap between the last safe tx and the new tx we're posting. This would be equivalent to changing the
>
to a>=
, but I thought this way was clearer. I also cleaned up some logging which was logging the variables in the wrong place (they aren't populated in the second log statement).