Skip to content
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: Sequence sender unit tests #103

Merged
merged 12 commits into from
Oct 4, 2024
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
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.20240930120324-65816dead447
github.com/0xPolygonHermez/zkevm-synchronizer-l1 v1.0.2
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
github.com/hermeznetwork/tracerr v0.3.2
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ github.com/0xPolygon/cdk-rpc v0.0.0-20240905074455-431d3c271fe8 h1:Jri+ydl8Puddd
github.com/0xPolygon/cdk-rpc v0.0.0-20240905074455-431d3c271fe8/go.mod h1:2scWqMMufrQXu7TikDgQ3BsyaKoX8qP26D6E262vSOg=
github.com/0xPolygonHermez/zkevm-data-streamer v0.2.6 h1:BSO1uu6dmLQ5kKb3uyDvsUxbnIoyumKvlwr0OtpTYMo=
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.2 h1:DYioOpHDcn7rtojInDTEv7vmnhs8HP6zOSSXSGENM7s=
github.com/0xPolygonHermez/zkevm-synchronizer-l1 v1.0.2/go.mod h1:96i+QSANfbikwlUY3U9MLNtg3656W3dWfbGqH+Od1/k=
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=
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
Expand Down
7 changes: 4 additions & 3 deletions sequencesender/ethtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/big"
"os"
"strings"
"sync/atomic"
"time"

"github.com/0xPolygon/cdk/log"
Expand Down Expand Up @@ -96,7 +97,7 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com
log.Errorf("error getting result for tx %v: %v", txHash, err)
}
if !resend {
s.latestSentToL1Batch = valueToBatch
atomic.StoreUint64(&s.latestSentToL1Batch, valueToBatch)
} else {
s.ethTransactions[*txOldHash].Status = "*resent"
}
Expand All @@ -113,7 +114,7 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com
// purgeEthTx purges transactions from memory structures
func (s *SequenceSender) purgeEthTx(ctx context.Context) {
// If sequence sending is stopped, do not purge
if s.seqSendingStopped {
if atomic.LoadUint32(&s.seqSendingStopped) == 1 {
return
}

Expand Down Expand Up @@ -274,7 +275,7 @@ func (s *SequenceSender) updateEthTxResult(txData *ethTxData, txResult ethtxmana
txData.Status == ethtxmanager.MonitoredTxStatusFinalized.String()
if txData.Status == ethtxmanager.MonitoredTxStatusFailed.String() {
s.logFatalf("transaction %v result failed!")
} else if statusConsolidated && txData.ToBatch >= s.latestVirtualBatchNumber {
} else if statusConsolidated && txData.ToBatch >= atomic.LoadUint64(&s.latestVirtualBatchNumber) {
s.latestVirtualTime = txData.StatusTimestamp
}
}
Expand Down
Loading
Loading