From 2a5f3115d15bc7454b7f2e6cd0d20438d35fbdec Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Thu, 5 Sep 2024 22:41:43 +0200 Subject: [PATCH 1/2] chore: setup codeowners (#65) --- .github/CODEOWNERS | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) 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 From 10fee9326bf0087f1070edb8ca4c1840dbf82ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:19:11 +0200 Subject: [PATCH 2/2] feat: protect ssender nonce (#67) * feat: protect ssender nonce --- sequencesender/sequencesender.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sequencesender/sequencesender.go b/sequencesender/sequencesender.go index 82e60034..8c96789a 100644 --- a/sequencesender/sequencesender.go +++ b/sequencesender/sequencesender.go @@ -32,6 +32,7 @@ type SequenceSender struct { ethTxManager *ethtxmanager.Client etherman *etherman.Client currentNonce uint64 + nonceMutex sync.Mutex latestVirtualBatch uint64 // Latest virtualized batch obtained from L1 latestVirtualTime time.Time // Latest virtual batch timestamp latestSentToL1Batch uint64 // Latest batch sent to L1 @@ -136,12 +137,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.updateLatestVirtualBatch() @@ -572,8 +575,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 @@ -598,9 +605,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{