-
Notifications
You must be signed in to change notification settings - Fork 12
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: protect ssender nonce #67
Conversation
sequencesender/sequencesender.go
Outdated
@@ -131,6 +132,9 @@ func New(cfg Config, etherman *etherman.Client, txBuilder txbuilder.TxBuilder) ( | |||
|
|||
// Start starts the sequence sender | |||
func (s *SequenceSender) Start(ctx context.Context) { | |||
s.nonceMutex.Lock() |
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.
WDYT if we lock only this critical section?
s.currentNonce, err = s.etherman.CurrentNonce(ctx, s.cfg.L2Coinbase)
if err != nil {
log.Fatalf("failed to get current nonce from %v, error: %v", s.cfg.L2Coinbase, err)
} else {
log.Infof("current nonce for %v is %d", s.cfg.L2Coinbase, s.currentNonce)
}
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.
Yes, but honestly this is the Start function. It will never be executed in parallel and it is not even needed to protect that variable in this function. But it is ok for me to just protect in that section. I will do the change.
|
* feat: protect ssender nonce
Description
Protects sequence sender nonce using a mutex, to avoid issues detected in parallel mode.