Skip to content

Commit

Permalink
feat: integrate zkevm-ethtx-manager (sql lite integration) (#131)
Browse files Browse the repository at this point in the history
* feat: bump zkevm-ethtx-manager (sql lite integration)

* chore: remove unused prover parameter

* bump golang version to 1.22 in the CI

* fix: update the configuration param
  • Loading branch information
Stefan-Ethernal authored Oct 4, 2024
1 parent 6406c87 commit 4648147
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
test:
strategy:
matrix:
go-version: [ 1.21.x ]
go-version: [ 1.22.x ]
goarch: [ "amd64" ]
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CONTAINER FOR BUILDING BINARY
FROM golang:1.21 AS build
FROM golang:1.22 AS build

# INSTALL DEPENDENCIES
RUN go install github.com/gobuffalo/packr/v2/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
endif
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/dist
GOENVVARS := GOBIN=$(GOBIN) CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH)
GOENVVARS := GOBIN=$(GOBIN) CGO_ENABLED=1 GOARCH=$(ARCH)
GOBINARY := zkevm-aggregator
GOCMD := $(GOBASE)/cmd

Expand Down
17 changes: 9 additions & 8 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (

"github.com/0xPolygon/cdk-rpc/rpc"
cdkTypes "github.com/0xPolygon/cdk-rpc/types"
"github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager"
ethtxlog "github.com/0xPolygon/zkevm-ethtx-manager/log"
ethtxtypes "github.com/0xPolygon/zkevm-ethtx-manager/types"
"github.com/0xPolygonHermez/zkevm-aggregator/aggregator/accinputhash"
"github.com/0xPolygonHermez/zkevm-aggregator/aggregator/metrics"
"github.com/0xPolygonHermez/zkevm-aggregator/aggregator/prover"
Expand All @@ -27,8 +30,6 @@ import (
"github.com/0xPolygonHermez/zkevm-aggregator/state/datastream"
"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
streamlog "github.com/0xPolygonHermez/zkevm-data-streamer/log"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/ethtxmanager"
ethtxlog "github.com/0xPolygonHermez/zkevm-ethtx-manager/log"
synclog "github.com/0xPolygonHermez/zkevm-synchronizer-l1/log"
"github.com/0xPolygonHermez/zkevm-synchronizer-l1/state/entities"
"github.com/0xPolygonHermez/zkevm-synchronizer-l1/synchronizer"
Expand Down Expand Up @@ -788,7 +789,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 {
log.Errorf("Error Adding TX to ethTxManager: %v", err)
mTxLogger := ethtxmanager.CreateLogger(monitoredTxID, sender, to)
Expand All @@ -798,7 +799,7 @@ func (a *Aggregator) settleDirect(
}

// process monitored batch verifications before starting a next cycle
a.ethTxManager.ProcessPendingMonitoredTxs(ctx, func(result ethtxmanager.MonitoredTxResult) {
a.ethTxManager.ProcessPendingMonitoredTxs(ctx, func(result ethtxtypes.MonitoredTxResult) {
a.handleMonitoredTxResult(result)
})

Expand Down Expand Up @@ -887,7 +888,7 @@ func (a *Aggregator) tryBuildFinalProof(ctx context.Context, prover proverInterf
// we don't have a proof generating at the moment, check if we
// have a proof ready to verify

proof, err = a.getAndLockProofReadyToVerify(ctx, prover, lastVerifiedBatchNumber)
proof, err = a.getAndLockProofReadyToVerify(ctx, lastVerifiedBatchNumber)
if errors.Is(err, state.ErrNotFound) {
// nothing to verify, swallow the error
log.Debug("No proof ready to verify")
Expand Down Expand Up @@ -981,7 +982,7 @@ func (a *Aggregator) validateEligibleFinalProof(ctx context.Context, proof *stat
return true, nil
}

func (a *Aggregator) getAndLockProofReadyToVerify(ctx context.Context, prover proverInterface, lastVerifiedBatchNum uint64) (*state.Proof, error) {
func (a *Aggregator) getAndLockProofReadyToVerify(ctx context.Context, lastVerifiedBatchNum uint64) (*state.Proof, error) {
a.stateDBMutex.Lock()
defer a.stateDBMutex.Unlock()

Expand Down Expand Up @@ -1690,9 +1691,9 @@ func (hc *healthChecker) Watch(req *grpchealth.HealthCheckRequest, server grpche
})
}

func (a *Aggregator) handleMonitoredTxResult(result ethtxmanager.MonitoredTxResult) {
func (a *Aggregator) handleMonitoredTxResult(result ethtxtypes.MonitoredTxResult) {
mTxResultLogger := ethtxmanager.CreateMonitoredTxResultLogger(result)
if result.Status == ethtxmanager.MonitoredTxStatusFailed {
if result.Status == ethtxtypes.MonitoredTxStatusFailed {
mTxResultLogger.Fatal("failed to send batch verification, TODO: review this fatal and define what to do in this case")
}

Expand Down
2 changes: 1 addition & 1 deletion aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"os"
"path/filepath"

"github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-aggregator/config/types"
"github.com/0xPolygonHermez/zkevm-aggregator/db"
"github.com/0xPolygonHermez/zkevm-aggregator/encoding"
"github.com/0xPolygonHermez/zkevm-aggregator/log"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/ethtxmanager"
syncronizerConfig "github.com/0xPolygonHermez/zkevm-synchronizer-l1/config"
"github.com/ethereum/go-ethereum/accounts/keystore"
)
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"path/filepath"
"strings"

"github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-aggregator/aggregator"
"github.com/0xPolygonHermez/zkevm-aggregator/etherman"
"github.com/0xPolygonHermez/zkevm-aggregator/event"
"github.com/0xPolygonHermez/zkevm-aggregator/log"
"github.com/0xPolygonHermez/zkevm-aggregator/metrics"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/ethtxmanager"
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
"github.com/urfave/cli/v2"
Expand Down
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SequencerPrivateKey = {}
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = ""
StoragePath = ""
ReadPendingL1Txs = false
SafeStatusL1NumberOfBlocks = 0
FinalizedStatusL1NumberOfBlocks = 0
Expand Down
44 changes: 23 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/0xPolygonHermez/zkevm-aggregator

go 1.21.3
go 1.22

require (
github.com/0xPolygon/cdk-rpc v0.0.0-20240419104226-c0a62ba0f49d
github.com/0xPolygon/zkevm-ethtx-manager v0.2.0
github.com/0xPolygonHermez/zkevm-data-streamer v0.2.2
github.com/0xPolygonHermez/zkevm-ethtx-manager v0.1.9
github.com/0xPolygonHermez/zkevm-synchronizer-l1 v0.6.6
github.com/ethereum/go-ethereum v1.14.7
github.com/0xPolygonHermez/zkevm-synchronizer-l1 v0.7.0
github.com/ethereum/go-ethereum v1.14.8
github.com/gobuffalo/packr/v2 v2.8.3
github.com/hermeznetwork/tracerr v0.3.2
github.com/iden3/go-iden3-crypto v0.0.16
Expand All @@ -30,48 +30,48 @@ require (
require (
github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240819092536-5a65d4761b2f // indirect
github.com/0xPolygon/cdk-data-availability v0.0.8-0.20240712072318-72ae67613cbf // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/DataDog/zstd v1.5.6 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/bits-and-blooms/bitset v1.14.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/consensys/gnark-crypto v0.13.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/didip/tollbooth/v6 v6.1.2 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/getsentry/sentry-go v0.28.1 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-pkgz/expirable-cache v0.0.3 // indirect
github.com/gobuffalo/logger v1.0.7 // indirect
github.com/gobuffalo/packd v1.0.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.1-0.20180906183839-65a6292f0157 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.3.0 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand All @@ -81,7 +81,7 @@ require (
github.com/jackc/puddle v1.3.0 // indirect
github.com/jmoiron/sqlx v1.2.0 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
Expand All @@ -90,7 +90,8 @@ require (
github.com/markbates/errx v1.1.0 // indirect
github.com/markbates/oncer v1.0.0 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-sqlite3 v1.14.23 // indirect
github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand All @@ -100,8 +101,9 @@ require (
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/russross/meddler v1.0.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
Expand Down
Loading

0 comments on commit 4648147

Please sign in to comment.