Skip to content

Commit

Permalink
add PR requests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaubennassar committed Sep 13, 2024
1 parent db74b4c commit 9cf39d0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
5 changes: 3 additions & 2 deletions bridgesync/claimcalldata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/test/contracts/claimmock"
"github.com/0xPolygon/cdk/test/contracts/claimmockcaller"
tree "github.com/0xPolygon/cdk/tree/types"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -52,11 +53,11 @@ func TestClaimCalldata(t *testing.T) {
require.NoError(t, err)

proofLocal := [32][32]byte{}
proofLocalH := [32]common.Hash{}
proofLocalH := tree.Proof{}
proofLocal[5] = common.HexToHash("beef")
proofLocalH[5] = common.HexToHash("beef")
proofRollup := [32][32]byte{}
proofRollupH := [32]common.Hash{}
proofRollupH := tree.Proof{}
proofRollup[4] = common.HexToHash("a1fa")
proofRollupH[4] = common.HexToHash("a1fa")
expectedClaim := Claim{
Expand Down
5 changes: 3 additions & 2 deletions claimsponsor/claimsponsor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/0xPolygon/cdk/db"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/sync"
tree "github.com/0xPolygon/cdk/tree/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/iter"
Expand All @@ -37,8 +38,8 @@ var (
// Claim representation of a claim event
type Claim struct {
LeafType uint8
ProofLocalExitRoot [32]common.Hash
ProofRollupExitRoot [32]common.Hash
ProofLocalExitRoot tree.Proof
ProofRollupExitRoot tree.Proof
GlobalIndex *big.Int
MainnetExitRoot common.Hash
RollupExitRoot common.Hash
Expand Down
6 changes: 0 additions & 6 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,6 @@ GasOffset = 0
L1ChainID = 1337
HTTPHeaders = []
[L1Bridge2InfoIndexSync]
DBPath = "/tmp/l1bridge2infoindexsync"
RetryAfterErrorPeriod = "1s"
MaxRetryAttemptsAfterError = -1
WaitForSyncersPeriod = "3s"
[BridgeL1Sync]
DBPath = "/tmp/bridgel1sync"
BlockFinality = "LatestBlock"
Expand Down
4 changes: 2 additions & 2 deletions l1infotreesync/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type L1InfoTreeLeaf struct {

// Hash as expected by the tree
func (l *L1InfoTreeLeaf) hash() ethCommon.Hash {
var res [32]byte
var res [treeTypes.DefaultHeight]byte
t := make([]byte, 8) //nolint:gomnd
binary.BigEndian.PutUint64(t, l.Timestamp)
copy(res[:], keccak256.Hash(l.globalExitRoot().Bytes(), l.PreviousBlockHash.Bytes(), t))
Expand All @@ -88,7 +88,7 @@ func (l *L1InfoTreeLeaf) hash() ethCommon.Hash {

// GlobalExitRoot returns the GER
func (l *L1InfoTreeLeaf) globalExitRoot() ethCommon.Hash {
var gerBytes [32]byte
var gerBytes [treeTypes.DefaultHeight]byte
hasher := sha3.NewLegacyKeccak256()
hasher.Write(l.MainnetExitRoot[:])
hasher.Write(l.RollupExitRoot[:])
Expand Down
4 changes: 2 additions & 2 deletions rpc/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/0xPolygon/cdk/claimsponsor"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/rpc/types"
"github.com/ethereum/go-ethereum/common"
tree "github.com/0xPolygon/cdk/tree/types"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
)
Expand Down Expand Up @@ -168,7 +168,7 @@ func (b *BridgeEndpoints) ClaimProof(
if err != nil {
return zeroHex, rpc.NewRPCError(rpc.DefaultErrorCode, fmt.Sprintf("failed to get rollup exit proof, error: %s", err))
}
var proofLocalExitRoot [32]common.Hash
var proofLocalExitRoot tree.Proof
if networkID == 0 {
proofLocalExitRoot, err = b.bridgeL1.GetProof(ctx, depositCount, info.MainnetExitRoot)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions rpc/types/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package types

import (
"github.com/0xPolygon/cdk/l1infotreesync"
"github.com/ethereum/go-ethereum/common"
tree "github.com/0xPolygon/cdk/tree/types"
)

type ClaimProof struct {
ProofLocalExitRoot [32]common.Hash
ProofRollupExitRoot [32]common.Hash
ProofLocalExitRoot tree.Proof
ProofRollupExitRoot tree.Proof
L1InfoTreeLeaf l1infotreesync.L1InfoTreeLeaf
}
4 changes: 2 additions & 2 deletions tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newTree(db *sql.DB, tablePrefix string) *Tree {
}

func (t *Tree) getSiblings(tx db.Querier, index uint32, root common.Hash) (
siblings [32]common.Hash,
siblings types.Proof,
hasUsedZeroHashes bool,
err error,
) {
Expand Down Expand Up @@ -209,7 +209,7 @@ func (t *Tree) GetRootByIndex(ctx context.Context, index uint32) (types.Root, er

// GetRootByHash returns the root associated to the hash
func (t *Tree) GetRootByHash(ctx context.Context, hash common.Hash) (*types.Root, error) {
root := &types.Root{}
var root *types.Root
if err := meddler.QueryRow(
t.db, root,
fmt.Sprintf(`SELECT * FROM %s WHERE hash = $1;`, t.rootTable),
Expand Down

0 comments on commit 9cf39d0

Please sign in to comment.