diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 847bd845..2ac98e7c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,30 +1 @@ -# This is a comment. - -# Each line is a file pattern followed by one or more owners. - -# These owners will be the default owners for everything in the repo. -* @default-owner - -# Order is important. The last matching pattern has the most precedence. - -# To set ownership of a particular folder, add a line like this: -/docs/ @documentation-team - -# To set ownership of all .js files in the src/js/ directory, add a line like this: -/src/js/*.js @js-developers - -# You can also specify individual users. This will make @octocat the owner of any .md files at the root of the repository: -/*.md @octocat - -# In this example, @doctocat owns any files in the /apps/ directory and any of its subdirectories. -/apps/ @doctocat - -# The `@backend-team` team owns any files in the `/api/` directory in the root of your repository and any of its subdirectories. -/api/ @backend-team - -# The `@frontend-team` team owns any files in the `/web/` directory in the root of your repository and any of its subdirectories. -/web/ @frontend-team - -# Add this line at the end of the file to always require pull request reviews -# when someone on the team is not an owner and the pull request modifies code owned by the team. -* @global-owner +@0xPolygon/core-cdk diff --git a/sequencesender/ethtx.go b/sequencesender/ethtx.go index 77ca016a..6d3f4053 100644 --- a/sequencesender/ethtx.go +++ b/sequencesender/ethtx.go @@ -46,8 +46,12 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com var valueToAddress common.Address if !resend { + s.nonceMutex.Lock() + nonce := s.currentNonce + s.currentNonce++ + s.nonceMutex.Unlock() + paramNonce = &nonce paramTo = to - paramNonce = &s.currentNonce paramData = data valueFromBatch = fromBatch valueToBatch = toBatch @@ -73,9 +77,6 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com log.Errorf("error adding sequence to ethtxmanager: %v", err) return err } - if !resend { - s.currentNonce++ - } // Add new eth tx txData := ethTxData{ diff --git a/sequencesender/sequencesender.go b/sequencesender/sequencesender.go index 144cb28a..b29d8ad3 100644 --- a/sequencesender/sequencesender.go +++ b/sequencesender/sequencesender.go @@ -25,6 +25,7 @@ type SequenceSender struct { ethTxManager *ethtxmanager.Client etherman *etherman.Client currentNonce uint64 + nonceMutex sync.Mutex latestVirtualBatchNumber uint64 // Latest virtualized batch obtained from L1 latestVirtualTime time.Time // Latest virtual batch timestamp latestSentToL1Batch uint64 // Latest batch sent to L1 @@ -92,12 +93,14 @@ func (s *SequenceSender) Start(ctx context.Context) { // Get current nonce var err error + s.nonceMutex.Lock() 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) } + s.nonceMutex.Unlock() // Get latest virtual state batch from L1 err = s.getLatestVirtualBatch()