Skip to content

Commit

Permalink
Merge v0.1.1 0.3.0 (#57)
Browse files Browse the repository at this point in the history
* Bump github.com/0xPolygonHermez/zkevm-node from 0.1.3 to 0.1.4 (0xPolygonHermez#459)

Bumps [github.com/0xPolygonHermez/zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/0xPolygonHermez/zkevm-node/releases)
- [Changelog](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/.goreleaser.yaml)
- [Commits](0xPolygonHermez/zkevm-node@v0.1.3...v0.1.4)

---
updated-dependencies:
- dependency-name: github.com/0xPolygonHermez/zkevm-node
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump golang.org/x/crypto from 0.10.0 to 0.11.0 (0xPolygonHermez#460)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.10.0 to 0.11.0.
- [Commits](golang/crypto@v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump google.golang.org/grpc from 1.56.1 to 1.56.2 (0xPolygonHermez#461)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.1 to 1.56.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.56.1...v1.56.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/rubenv/sql-migrate from 1.5.1 to 1.5.2 (0xPolygonHermez#474)

Bumps [github.com/rubenv/sql-migrate](https://github.com/rubenv/sql-migrate) from 1.5.1 to 1.5.2.
- [Commits](rubenv/sql-migrate@v1.5.1...v1.5.2)

---
updated-dependencies:
- dependency-name: github.com/rubenv/sql-migrate
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/jackc/pgconn from 1.14.0 to 1.14.1 (0xPolygonHermez#475)

Bumps [github.com/jackc/pgconn](https://github.com/jackc/pgconn) from 1.14.0 to 1.14.1.
- [Changelog](https://github.com/jackc/pgconn/blob/master/CHANGELOG.md)
- [Commits](jackc/pgconn@v1.14.0...v1.14.1)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgconn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump google.golang.org/grpc from 1.56.2 to 1.57.0 (0xPolygonHermez#480)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.2 to 1.57.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.56.2...v1.57.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/grpc-ecosystem/grpc-gateway/v2 from 2.16.0 to 2.16.2 (0xPolygonHermez#482)

Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.16.0 to 2.16.2.
- [Release notes](https://github.com/grpc-ecosystem/grpc-gateway/releases)
- [Changelog](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/.goreleaser.yml)
- [Commits](grpc-ecosystem/grpc-gateway@v2.16.0...v2.16.2)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/grpc-gateway/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/0xPolygonHermez/zkevm-node from 0.1.4 to 0.2.2 (0xPolygonHermez#483)

* Bump github.com/0xPolygonHermez/zkevm-node from 0.1.4 to 0.2.2

Bumps [github.com/0xPolygonHermez/zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) from 0.1.4 to 0.2.2.
- [Release notes](https://github.com/0xPolygonHermez/zkevm-node/releases)
- [Changelog](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/.goreleaser.yaml)
- [Commits](0xPolygonHermez/zkevm-node@v0.1.4...v0.2.2)

---
updated-dependencies:
- dependency-name: github.com/0xPolygonHermez/zkevm-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix script

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* Bump github.com/0xPolygonHermez/zkevm-node from 0.2.2 to 0.2.3 (0xPolygonHermez#485)

Bumps [github.com/0xPolygonHermez/zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/0xPolygonHermez/zkevm-node/releases)
- [Changelog](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/.goreleaser.yaml)
- [Commits](0xPolygonHermez/zkevm-node@v0.2.2...v0.2.3)

---
updated-dependencies:
- dependency-name: github.com/0xPolygonHermez/zkevm-node
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump golang.org/x/crypto from 0.11.0 to 0.12.0 (0xPolygonHermez#489)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.11.0 to 0.12.0.
- [Commits](golang/crypto@v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/0xPolygonHermez/zkevm-node from 0.2.3 to 0.2.4 (0xPolygonHermez#490)

Bumps [github.com/0xPolygonHermez/zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) from 0.2.3 to 0.2.4.
- [Release notes](https://github.com/0xPolygonHermez/zkevm-node/releases)
- [Changelog](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/.goreleaser.yaml)
- [Commits](0xPolygonHermez/zkevm-node@v0.2.3...v0.2.4)

---
updated-dependencies:
- dependency-name: github.com/0xPolygonHermez/zkevm-node
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/hashicorp/golang-lru/v2 from 2.0.4 to 2.0.5 (0xPolygonHermez#491)

Bumps [github.com/hashicorp/golang-lru/v2](https://github.com/hashicorp/golang-lru) from 2.0.4 to 2.0.5.
- [Release notes](https://github.com/hashicorp/golang-lru/releases)
- [Commits](hashicorp/golang-lru@v2.0.4...v2.0.5)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/golang-lru/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Feature/0xPolygonHermez#486 update versions (0xPolygonHermez#487)

* Update versions

* Remove log that shows the configuration

* docker compose command

* fix

* remove log db config

* Release/v0.2.0 (0xPolygonHermez#495)

* Remove MaticAddr (0xPolygonHermez#464)

* Increase gasPrice (0xPolygonHermez#466)

* Fix channel listener when claimTxManager is disabled (0xPolygonHermez#468)

* remove unused config param (0xPolygonHermez#470)

* Fix revert check and max rety mechanism (0xPolygonHermez#472)

* Fix revert check and max rety mechanism

* Add maxRetries and retry interval as config params

* force gha

* fix config (0xPolygonHermez#473)

* Check in claimtxmanager to block until l2network is synced (0xPolygonHermez#498)

* Check in claimtxmanager to block until l2network is synced

* Fix monitoring

* fix unit test

* synced log

* remove alice and bob from pr template

* Bump github.com/hashicorp/golang-lru/v2 from 2.0.5 to 2.0.6 (0xPolygonHermez#500)

Bumps [github.com/hashicorp/golang-lru/v2](https://github.com/hashicorp/golang-lru) from 2.0.5 to 2.0.6.
- [Release notes](https://github.com/hashicorp/golang-lru/releases)
- [Commits](hashicorp/golang-lru@v2.0.5...v2.0.6)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/golang-lru/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump golang.org/x/crypto from 0.12.0 to 0.13.0 (0xPolygonHermez#506)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.12.0 to 0.13.0.
- [Commits](golang/crypto@v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/0xPolygonHermez/zkevm-node from 0.2.4 to 0.3.1 (0xPolygonHermez#508)

Bumps [github.com/0xPolygonHermez/zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) from 0.2.4 to 0.3.1.
- [Release notes](https://github.com/0xPolygonHermez/zkevm-node/releases)
- [Changelog](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/.goreleaser.yaml)
- [Commits](0xPolygonHermez/zkevm-node@v0.2.4...v0.3.1)

---
updated-dependencies:
- dependency-name: github.com/0xPolygonHermez/zkevm-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/grpc-ecosystem/grpc-gateway/v2 from 2.16.2 to 2.18.0 (0xPolygonHermez#507)

Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.16.2 to 2.18.0.
- [Release notes](https://github.com/grpc-ecosystem/grpc-gateway/releases)
- [Changelog](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/.goreleaser.yml)
- [Commits](grpc-ecosystem/grpc-gateway@v2.16.2...v2.18.0)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/grpc-gateway/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/ethereum/go-ethereum from 1.12.0 to 1.13.0 (0xPolygonHermez#509)

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](ethereum/go-ethereum@v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso Rodriguez <[email protected]>
Co-authored-by: Alonso <[email protected]>

* Primary keys in db tables (0xPolygonHermez#511)

* Primary keys in db tables

* linter

* TestMTAddLeaf

* linter

* fix benchmarks

* Bump google.golang.org/grpc from 1.58.0 to 1.58.1 (0xPolygonHermez#512)

* Bump google.golang.org/grpc from 1.58.0 to 1.58.1

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.0 to 1.58.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.58.0...v1.58.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* New indexes + tests (0xPolygonHermez#515)

* Bump github.com/ethereum/go-ethereum from 1.13.0 to 1.13.1 (0xPolygonHermez#513)

* Bump github.com/ethereum/go-ethereum from 1.13.0 to 1.13.1

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.13.0 to 1.13.1.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](ethereum/go-ethereum@v1.13.0...v1.13.1)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* Fix/0xPolygonHermez#478 tx history (0xPolygonHermez#517)

* Fix duplicated tx hash in the tx history

* Retry if error getting txByHash

* linter

* fix test

* linter

* log

* Bump google.golang.org/grpc from 1.58.1 to 1.58.2 (0xPolygonHermez#518)

* Bump google.golang.org/grpc from 1.58.1 to 1.58.2

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.1 to 1.58.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.58.1...v1.58.2)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* autoclaim bridge msg for authorized addrs (0xPolygonHermez#519)

* autoclaim bridge msg for authorized addrs

* variable name

* Bump github.com/hashicorp/golang-lru/v2 from 2.0.6 to 2.0.7 (0xPolygonHermez#521)

* Bump github.com/hashicorp/golang-lru/v2 from 2.0.6 to 2.0.7

Bumps [github.com/hashicorp/golang-lru/v2](https://github.com/hashicorp/golang-lru) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/hashicorp/golang-lru/releases)
- [Commits](hashicorp/golang-lru@v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/golang-lru/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* Bump github.com/ethereum/go-ethereum from 1.13.1 to 1.13.2 (0xPolygonHermez#520)

* Bump github.com/ethereum/go-ethereum from 1.13.1 to 1.13.2

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.13.1 to 1.13.2.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](ethereum/go-ethereum@v1.13.1...v1.13.2)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>

* Remove blockid (0xPolygonHermez#524)

* Remove blockid

* Set blockID by default to 0 in migration down

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alonso <[email protected]>
Co-authored-by: Alonso Rodriguez <[email protected]>
Co-authored-by: Thiago Coimbra Lemos <[email protected]>
Co-authored-by: Toni Ramírez <[email protected]>
  • Loading branch information
6 people authored Dec 18, 2023
1 parent 161427b commit 271203a
Show file tree
Hide file tree
Showing 23 changed files with 467 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Codeowner reviewers:

<!-- Codeowners should review only the part of code that they own, they're added automatically as reviewers and it's good to let them know that they shouldn't do a full review -->

- @Alice
- @Bob
- @-Alice
- @-Bob
33 changes: 20 additions & 13 deletions bridgectrl/merkletree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,39 @@ func TestMTAddLeaf(t *testing.T) {

amount, result := new(big.Int).SetString(testVector.NewLeaf.Amount, 0)
require.True(t, result)
deposit := &etherman.Deposit{
OriginalNetwork: testVector.NewLeaf.OriginalNetwork,
OriginalAddress: common.HexToAddress(testVector.NewLeaf.TokenAddress),
Amount: amount,
DestinationNetwork: testVector.NewLeaf.DestinationNetwork,
DestinationAddress: common.HexToAddress(testVector.NewLeaf.DestinationAddress),
BlockNumber: 0,
DepositCount: uint(ti + 1),
Metadata: common.FromHex(testVector.NewLeaf.Metadata),
var (
depositIDs []uint64
deposit *etherman.Deposit
)
for i := 0; i <= ti; i++ {
deposit = &etherman.Deposit{
OriginalNetwork: testVector.NewLeaf.OriginalNetwork,
OriginalAddress: common.HexToAddress(testVector.NewLeaf.TokenAddress),
Amount: amount,
DestinationNetwork: testVector.NewLeaf.DestinationNetwork,
DestinationAddress: common.HexToAddress(testVector.NewLeaf.DestinationAddress),
BlockNumber: 0,
DepositCount: uint(i + 1),
Metadata: common.FromHex(testVector.NewLeaf.Metadata),
}
depositID, err := store.AddDeposit(ctx, deposit, nil)
require.NoError(t, err)
depositIDs = append(depositIDs, depositID)
}
depositID, err := store.AddDeposit(ctx, deposit, nil)
require.NoError(t, err)

for i, leaf := range testVector.ExistingLeaves {
leafValue, err := formatBytes32String(leaf[2:])
require.NoError(t, err)

err = mt.addLeaf(ctx, depositID, leafValue, uint(i), nil)
err = mt.addLeaf(ctx, depositIDs[i], leafValue, uint(i), nil)
require.NoError(t, err)
}
curRoot, err := mt.getRoot(ctx, nil)
require.NoError(t, err)
assert.Equal(t, hex.EncodeToString(curRoot), testVector.CurrentRoot[2:])

leafHash := hashDeposit(deposit)
err = mt.addLeaf(ctx, depositID, leafHash, uint(len(testVector.ExistingLeaves)), nil)
err = mt.addLeaf(ctx, depositIDs[len(depositIDs)-1], leafHash, uint(len(testVector.ExistingLeaves)), nil)
require.NoError(t, err)
newRoot, err := mt.getRoot(ctx, nil)
require.NoError(t, err)
Expand Down
76 changes: 41 additions & 35 deletions claimtxman/claimtxman.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (tm *ClaimTxManager) processDepositStatusL1(ger *etherman.GlobalExitRoot) e
tm.rollbackStore(dbTx)
return err
}
if err = tm.addClaimTx(deposit.DepositCount, deposit.BlockID, tm.auth.From, tx.To(), nil, tx.Data(), dbTx); err != nil {
if err = tm.addClaimTx(deposit.DepositCount, tm.auth.From, tx.To(), nil, tx.Data(), dbTx); err != nil {
log.Errorf("error adding claim tx for deposit %d. Error: %v", deposit.DepositCount, err)
tm.rollbackStore(dbTx)
return err
Expand Down Expand Up @@ -309,8 +309,8 @@ func (tm *ClaimTxManager) processDepositStatus(ger *etherman.GlobalExitRoot, dbT
log.Errorf("error getting deposit status for deposit %d. Error: %v", deposit.DepositCount, err)
return err
}
if len(claimHash) > 0 || deposit.LeafType == LeafTypeMessage {
log.Infof("Ignoring deposit: %d, leafType: %d, claimHash: %s", deposit.DepositCount, deposit.LeafType, claimHash)
if len(claimHash) > 0 || deposit.LeafType == LeafTypeMessage && !tm.isDepositMessageAllowed(deposit) {
log.Infof("Ignoring deposit: %d, leafType: %d, claimHash: %s, deposit.OriginalAddress: %s", deposit.DepositCount, deposit.LeafType, claimHash, deposit.OriginalAddress.String())
continue
}
log.Infof("create the claim tx for the deposit %d", deposit.DepositCount)
Expand All @@ -336,7 +336,7 @@ func (tm *ClaimTxManager) processDepositStatus(ger *etherman.GlobalExitRoot, dbT
return err
}
log.Debugf("claimTx for deposit %d build successfully %d", deposit.DepositCount)
if err = tm.addClaimTx(deposit.DepositCount, deposit.BlockID, tm.auth.From, tx.To(), nil, tx.Data(), dbTx); err != nil {
if err = tm.addClaimTx(deposit.DepositCount, tm.auth.From, tx.To(), nil, tx.Data(), dbTx); err != nil {
log.Errorf("error adding claim tx for deposit %d. Error: %v", deposit.DepositCount, err)
return err
}
Expand All @@ -346,6 +346,17 @@ func (tm *ClaimTxManager) processDepositStatus(ger *etherman.GlobalExitRoot, dbT
return nil
}

func (tm *ClaimTxManager) isDepositMessageAllowed(deposit *etherman.Deposit) bool {
for _, addr := range tm.cfg.AuthorizedClaimMessageAddresses {
if deposit.OriginalAddress == addr {
log.Infof("MessageBridge from authorized account detected: %+v, account: %s", deposit, addr.String())
return true
}
}
log.Infof("MessageBridge Not authorized. DepositCount: %d", deposit.DepositCount)
return false
}

func (tm *ClaimTxManager) getNextNonce(from common.Address) (uint64, error) {
nonce, err := tm.l2Node.NonceAt(tm.ctx, from, nil)
if err != nil {
Expand All @@ -360,15 +371,15 @@ func (tm *ClaimTxManager) getNextNonce(from common.Address) (uint64, error) {
return nonce, nil
}

func (tm *ClaimTxManager) addClaimTx(depositCount uint, blockID uint64, from common.Address, to *common.Address, value *big.Int, data []byte, dbTx pgx.Tx) error {
func (tm *ClaimTxManager) addClaimTx(depositCount uint, from common.Address, to *common.Address, value *big.Int, data []byte, dbTx pgx.Tx) error {
// get gas
tx := ethereum.CallMsg{
From: from,
To: to,
Value: value,
Data: data,
}
log.Debugf("addClaimTx deposit: %d, blockID %d", depositCount, blockID)
log.Debugf("addClaimTx deposit: %d", depositCount)
gas, err := tm.l2Node.EstimateGas(tm.ctx, tx)
for i := 1; err != nil && err.Error() != runtime.ErrExecutionReverted.Error() && i < tm.cfg.RetryNumber; i++ {
log.Warnf("error while doing gas estimation. Retrying... Error: %v, Data: %s", err, common.Bytes2Hex(data))
Expand All @@ -389,7 +400,7 @@ func (tm *ClaimTxManager) addClaimTx(depositCount uint, blockID uint64, from com

// create monitored tx
mTx := ctmtypes.MonitoredTx{
ID: depositCount, BlockID: blockID, From: from, To: to,
DepositID: depositCount, From: from, To: to,
Nonce: nonce, Value: value, Data: data,
Gas: gas, Status: ctmtypes.MonitoredTxStatusCreated,
}
Expand All @@ -401,7 +412,7 @@ func (tm *ClaimTxManager) addClaimTx(depositCount uint, blockID uint64, from com
log.Errorf("error adding claim tx to db. Error: %s", err.Error())
return err
}
log.Debugf("addClaimTx successfully depositCount: %d, blockID: %d", depositCount, blockID)
log.Debugf("addClaimTx successfully depositCount: %d", depositCount)

return nil
}
Expand Down Expand Up @@ -432,7 +443,7 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
isResetNonce := false // it will reset the nonce in one cycle
for _, mTx := range mTxs {
mTx := mTx // force variable shadowing to avoid pointer conflicts
mTxLog := mLog.WithFields("monitoredTx", mTx.ID)
mTxLog := log.WithFields("monitoredTx", mTx.DepositID)
mTxLog.Infof("processing tx with nonce %d", mTx.Nonce)

// check if any of the txs in the history was mined
Expand All @@ -443,7 +454,7 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
receiptSuccessful := false

for txHash := range mTx.History {
mTxLog.Debugf("Checking if tx %s is mined", txHash)
mTxLog.Infof("Checking if tx %s is mined", txHash.String())
mined, receipt, err = tm.l2Node.CheckTxWasMined(ctx, txHash)
if err != nil {
mTxLog.Errorf("failed to check if tx %s was mined: %v", txHash.String(), err)
Expand All @@ -454,13 +465,22 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
if !mined {
// check if the tx is in the pending pool
_, _, err = tm.l2Node.TransactionByHash(ctx, txHash)
if errors.Is(err, ethereum.NotFound) {
mTxLog.Errorf("tx %s was not found in the pending pool", txHash.String())
hasFailedReceipts = true
continue
} else if err != nil {
mTxLog.Errorf("failed to get tx %s: %v", txHash.String(), err)
continue
if err != nil {
mTxLog.Errorf("error getting txByHash %s. Error: %v", txHash.String(), err)
// Retry if the tx has not appeared in the pool yet.
for i := 0; i < tm.cfg.RetryNumber && err != nil; i++ {
mTxLog.Warn("waiting and retrying to find the tx in the pool. TxHash: %s. Error: %v", txHash.String(), err)
time.Sleep(tm.cfg.RetryInterval.Duration)
_, _, err = tm.l2Node.TransactionByHash(ctx, txHash)
}
if errors.Is(err, ethereum.NotFound) {
mTxLog.Error("maximum retries and the tx is still missing in the pool. TxHash: ", txHash.String())
hasFailedReceipts = true
continue
} else if err != nil {
mTxLog.Errorf("failed to retry to get tx %s: %v", txHash.String(), err)
continue
}
}
log.Infof("tx: %s not mined yet", txHash.String())

Expand All @@ -472,22 +492,6 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
if receipt.Status == types.ReceiptStatusSuccessful {
mTxLog.Infof("tx %s was mined successfully", txHash.String())
receiptSuccessful = true
block, err := tm.l2Node.BlockByNumber(ctx, receipt.BlockNumber)
if err != nil {
mTxLog.Errorf("failed to get receipt block: %v", err)
continue
}
mTx.BlockID, err = tm.storage.AddBlock(ctx, &etherman.Block{
NetworkID: tm.l2NetworkID,
BlockNumber: block.Number().Uint64(),
BlockHash: block.Hash(),
ParentHash: block.ParentHash(),
ReceivedAt: block.ReceivedAt,
}, dbTx)
if err != nil {
mTxLog.Errorf("failed to add receipt block: %v", err)
continue
}
mTx.Status = ctmtypes.MonitoredTxStatusConfirmed
// update monitored tx changes into storage
err = tm.storage.UpdateClaimTx(ctx, mTx, dbTx)
Expand Down Expand Up @@ -597,8 +601,10 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
mTxLog.Errorf("failed to review monitored tx: %v", err)
}
}
} else if err != nil && !errors.Is(err, ethereum.NotFound) {
mTxLog.Error("unexpected error getting TransactionByHash. Error: ", err)
} else {
mTxLog.Infof("signed tx %v already found in the network for the monitored tx: %v", signedTx.Hash().String(), err)
mTxLog.Infof("signed tx %v already found in the network for the monitored tx.", signedTx.Hash().String())
}

// update monitored tx changes into storage
Expand Down Expand Up @@ -631,7 +637,7 @@ func (tm *ClaimTxManager) monitorTxs(ctx context.Context) error {
// accordingly to the current information stored and the current
// state of the blockchain
func (tm *ClaimTxManager) ReviewMonitoredTx(ctx context.Context, mTx *ctmtypes.MonitoredTx, reviewNonce bool) error {
mTxLog := log.WithFields("monitoredTx", mTx.ID)
mTxLog := log.WithFields("monitoredTx", mTx.DepositID)
mTxLog.Debug("reviewing")
// get gas
tx := ethereum.CallMsg{
Expand Down
49 changes: 18 additions & 31 deletions claimtxman/claimtxman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ func TestMonitoredTxStorage(t *testing.T) {
tx, err := pg.BeginDBTransaction(ctx)
require.NoError(t, err)

block := &etherman.Block{
BlockNumber: 1,
BlockHash: common.HexToHash("0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1"),
ParentHash: common.HexToHash("0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f2"),
NetworkID: 0,
ReceivedAt: time.Now(),
}
blockID, err := pg.AddBlock(ctx, block, tx)
require.NoError(t, err)

deposit := &etherman.Deposit{
NetworkID: 0,
OriginalNetwork: 0,
Expand All @@ -45,7 +35,6 @@ func TestMonitoredTxStorage(t *testing.T) {
DestinationNetwork: 1,
DestinationAddress: common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),
BlockNumber: 1,
BlockID: blockID,
DepositCount: 1,
Metadata: common.FromHex("0x0"),
}
Expand All @@ -54,16 +43,15 @@ func TestMonitoredTxStorage(t *testing.T) {

toAdr := common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")
mTx := ctmtypes.MonitoredTx{
ID: 1,
BlockID: blockID,
From: common.HexToAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
To: &toAdr,
Nonce: 1,
Value: big.NewInt(1000000),
Data: common.FromHex("0x0"),
Gas: 1000000,
Status: ctmtypes.MonitoredTxStatusCreated,
History: make(map[common.Hash]bool),
DepositID: 1,
From: common.HexToAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
To: &toAdr,
Nonce: 1,
Value: big.NewInt(1000000),
Data: common.FromHex("0x0"),
Gas: 1000000,
Status: ctmtypes.MonitoredTxStatusCreated,
History: make(map[common.Hash]bool),
}
err = pg.AddClaimTx(ctx, mTx, tx)
require.NoError(t, err)
Expand All @@ -79,16 +67,15 @@ func TestMonitoredTxStorage(t *testing.T) {
require.NoError(t, err)

mTx = ctmtypes.MonitoredTx{
ID: 2,
BlockID: blockID,
From: common.HexToAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
To: &toAdr,
Nonce: 1,
Value: big.NewInt(1000000),
Data: common.FromHex("0x0"),
Gas: 1000000,
Status: ctmtypes.MonitoredTxStatusConfirmed,
History: make(map[common.Hash]bool),
DepositID: 2,
From: common.HexToAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
To: &toAdr,
Nonce: 1,
Value: big.NewInt(1000000),
Data: common.FromHex("0x0"),
Gas: 1000000,
Status: ctmtypes.MonitoredTxStatusConfirmed,
History: make(map[common.Hash]bool),
}
err = pg.AddClaimTx(ctx, mTx, tx)
require.NoError(t, err)
Expand Down
7 changes: 6 additions & 1 deletion claimtxman/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package claimtxman

import "github.com/0xPolygonHermez/zkevm-node/config/types"
import (
"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/ethereum/go-ethereum/common"
)

// Config is configuration for L2 claim transaction manager
type Config struct {
Expand All @@ -19,4 +22,6 @@ type Config struct {
FreeGas bool `mapstructure:"FreeGas"`
//OptClaim enabled store claimTx into storage every deposit
OptClaim bool `mapstructure:"OptClaim"`
// AuthorizedClaimMessageAddresses are the allowed address to bridge message with autoClaim
AuthorizedClaimMessageAddresses []common.Address `mapstructure:"AuthorizedClaimMessageAddresses"`
}
9 changes: 2 additions & 7 deletions claimtxman/types/monitoredtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (s MonitoredTxStatus) String() string {
// MonitoredTx represents a set of information used to build tx
// plus information to monitor if the transactions was sent successfully
type MonitoredTx struct {
// Id is the tx identifier controller by the caller
ID uint
// DepositID is the tx identifier controller by the caller
DepositID uint

// From is a sender of the tx, used to identify which private key should be used to sing the tx
From common.Address
Expand All @@ -66,11 +66,6 @@ type MonitoredTx struct {
// Status of this monitoring
Status MonitoredTxStatus

// BlockID represents the block where the tx was identified
// to be mined, it's the same as the block id found in the
// tx receipt, this is used to control reorged monitored txs
BlockID uint64

// History represent all transaction hashes from
// transactions created using this struct data and
// sent to the network
Expand Down
Loading

0 comments on commit 271203a

Please sign in to comment.