diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index ee02771e..4ad053c4 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -31,7 +31,6 @@ type EthTxManager interface { Result(ctx context.Context, id common.Hash) (ethtxmanager.MonitoredTxResult, error) Add(ctx context.Context, to *common.Address, - forcedNonce *uint64, value *big.Int, data []byte, gasOffset uint64, @@ -103,7 +102,7 @@ func (c *EVMChainGERSender) UpdateGERWaitUntilMined(ctx context.Context, ger com if err != nil { return err } - id, err := c.ethTxMan.Add(ctx, &c.gerAddr, nil, big.NewInt(0), data, c.gasOffset, nil) + id, err := c.ethTxMan.Add(ctx, &c.gerAddr, big.NewInt(0), data, c.gasOffset, nil) if err != nil { return err } diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index a97d72f9..249f260a 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -978,7 +978,7 @@ func (a *Aggregator) settleDirect( return false } - monitoredTxID, err := a.ethTxManager.Add(ctx, to, nil, big.NewInt(0), data, a.cfg.GasOffset, nil) + monitoredTxID, err := a.ethTxManager.Add(ctx, to, big.NewInt(0), data, a.cfg.GasOffset, nil) if err != nil { a.logger.Errorf("Error Adding TX to ethTxManager: %v", err) mTxLogger := ethtxmanager.CreateLogger(monitoredTxID, sender, to) diff --git a/bridgesync/mock_l2_test.go b/bridgesync/mock_l2_test.go index adbff51f..ef842d18 100644 --- a/bridgesync/mock_l2_test.go +++ b/bridgesync/mock_l2_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package bridgesync diff --git a/claimsponsor/evmclaimsponsor.go b/claimsponsor/evmclaimsponsor.go index 540f3203..5f394b14 100644 --- a/claimsponsor/evmclaimsponsor.go +++ b/claimsponsor/evmclaimsponsor.go @@ -36,7 +36,7 @@ type EthTxManager interface { ResultsByStatus(ctx context.Context, statuses []ethtxmanager.MonitoredTxStatus, ) ([]ethtxmanager.MonitoredTxResult, error) Result(ctx context.Context, id common.Hash) (ethtxmanager.MonitoredTxResult, error) - Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte, + Add(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) } @@ -152,7 +152,7 @@ func (c *EVMClaimSponsor) sendClaim(ctx context.Context, claim *Claim) (string, if err != nil { return "", err } - id, err := c.ethTxManager.Add(ctx, &c.bridgeAddr, nil, big.NewInt(0), data, c.gasOffest, nil) + id, err := c.ethTxManager.Add(ctx, &c.bridgeAddr, big.NewInt(0), data, c.gasOffest, nil) if err != nil { return "", err } diff --git a/go.mod b/go.mod index aeaae312..6396bd68 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/0xPolygon/cdk-data-availability v0.0.9 github.com/0xPolygon/cdk-rpc v0.0.0-20240905074455-431d3c271fe8 github.com/0xPolygonHermez/zkevm-data-streamer v0.2.6 - github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240716105056-c051c96d0234 + github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240930120324-65816dead447 github.com/0xPolygonHermez/zkevm-synchronizer-l1 v1.0.1 github.com/ethereum/go-ethereum v1.14.8 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 diff --git a/go.sum b/go.sum index e3544380..d20624ff 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/0xPolygonHermez/zkevm-data-streamer v0.2.6 h1:BSO1uu6dmLQ5kKb3uyDvsUx github.com/0xPolygonHermez/zkevm-data-streamer v0.2.6/go.mod h1:RC6ouyNsUtJrv5aGPcM6Dm5xhXN209tRSzcsJsaOtZI= github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240716105056-c051c96d0234 h1:QElCysO7f2xaknY/RDjxcs7IVmcgORfsCX2g+YD0Ko4= github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240716105056-c051c96d0234/go.mod h1:zBZWxwOHKlw+ghd9roQLgIkDZWA7e7qO3EsfQQT/+oQ= +github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240930120324-65816dead447 h1:8nZjZrHZo+P9hTkhwtQ4J6eh9v4MTMtVb9jRDra8h0s= +github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.10-0.20240930120324-65816dead447/go.mod h1:4iWpcwMOZJPapUzFB/HjTAM0X/gltHSEzQHE0lOt+eY= github.com/0xPolygonHermez/zkevm-synchronizer-l1 v1.0.1 h1:8GbJBNsYO4zrqiBX++et8eQrJDEWEZuo3Ch3M416YnI= github.com/0xPolygonHermez/zkevm-synchronizer-l1 v1.0.1/go.mod h1:96i+QSANfbikwlUY3U9MLNtg3656W3dWfbGqH+Od1/k= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= diff --git a/sequencesender/sequencesender.go b/sequencesender/sequencesender.go index 1d76d3c0..363b5a10 100644 --- a/sequencesender/sequencesender.go +++ b/sequencesender/sequencesender.go @@ -32,8 +32,6 @@ type SequenceSender struct { logger *log.Logger 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 @@ -141,14 +139,6 @@ 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 { - s.logger.Fatalf("failed to get current nonce from %v, error: %v", s.cfg.L2Coinbase, err) - } else { - s.logger.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() @@ -601,18 +591,12 @@ func (s *SequenceSender) sendTx( ) error { // Params if new tx to send or resend a previous tx var paramTo *common.Address - var paramNonce *uint64 var paramData []byte var valueFromBatch uint64 var valueToBatch uint64 var valueToAddress common.Address if !resend { - s.nonceMutex.Lock() - nonce := s.currentNonce - s.currentNonce++ - s.nonceMutex.Unlock() - paramNonce = &nonce paramTo = to paramData = data valueFromBatch = fromBatch @@ -623,7 +607,6 @@ func (s *SequenceSender) sendTx( return errors.New("resend tx with nil hash monitor id") } paramTo = &s.ethTransactions[*txOldHash].To - paramNonce = &s.ethTransactions[*txOldHash].Nonce paramData = s.ethTxData[*txOldHash] valueFromBatch = s.ethTransactions[*txOldHash].FromBatch valueToBatch = s.ethTransactions[*txOldHash].ToBatch @@ -633,7 +616,7 @@ func (s *SequenceSender) sendTx( } // Add sequence tx - txHash, err := s.ethTxManager.AddWithGas(ctx, paramTo, paramNonce, big.NewInt(0), paramData, s.cfg.GasOffset, nil, gas) + txHash, err := s.ethTxManager.AddWithGas(ctx, paramTo, big.NewInt(0), paramData, s.cfg.GasOffset, nil, gas) if err != nil { s.logger.Errorf("error adding sequence to ethtxmanager: %v", err) return err diff --git a/test/helpers/mock_ethtxmanager.go b/test/helpers/mock_ethtxmanager.go index 4dd103af..a75f57e9 100644 --- a/test/helpers/mock_ethtxmanager.go +++ b/test/helpers/mock_ethtxmanager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package helpers @@ -21,9 +21,9 @@ type EthTxManagerMock struct { mock.Mock } -// Add provides a mock function with given fields: ctx, to, forcedNonce, value, data, gasOffset, sidecar -func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, forcedNonce *uint64, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) { - ret := _m.Called(ctx, to, forcedNonce, value, data, gasOffset, sidecar) +// Add provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar +func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) { + ret := _m.Called(ctx, to, value, data, gasOffset, sidecar) if len(ret) == 0 { panic("no return value specified for Add") @@ -31,19 +31,19 @@ func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, forcedN var r0 common.Hash var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *uint64, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)); ok { - return rf(ctx, to, forcedNonce, value, data, gasOffset, sidecar) + if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)); ok { + return rf(ctx, to, value, data, gasOffset, sidecar) } - if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *uint64, *big.Int, []byte, uint64, *types.BlobTxSidecar) common.Hash); ok { - r0 = rf(ctx, to, forcedNonce, value, data, gasOffset, sidecar) + if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) common.Hash); ok { + r0 = rf(ctx, to, value, data, gasOffset, sidecar) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(common.Hash) } } - if rf, ok := ret.Get(1).(func(context.Context, *common.Address, *uint64, *big.Int, []byte, uint64, *types.BlobTxSidecar) error); ok { - r1 = rf(ctx, to, forcedNonce, value, data, gasOffset, sidecar) + if rf, ok := ret.Get(1).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) error); ok { + r1 = rf(ctx, to, value, data, gasOffset, sidecar) } else { r1 = ret.Error(1) }