diff --git a/bridgesync/claimcalldata_test.go b/bridgesync/claimcalldata_test.go index 1319835b..2e574a4e 100644 --- a/bridgesync/claimcalldata_test.go +++ b/bridgesync/claimcalldata_test.go @@ -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" @@ -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{ diff --git a/claimsponsor/claimsponsor.go b/claimsponsor/claimsponsor.go index dcb1c024..6a7b578d 100644 --- a/claimsponsor/claimsponsor.go +++ b/claimsponsor/claimsponsor.go @@ -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" @@ -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 diff --git a/config/default.go b/config/default.go index ce76abc4..03bcccd4 100644 --- a/config/default.go +++ b/config/default.go @@ -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" diff --git a/l1infotreesync/processor.go b/l1infotreesync/processor.go index 70385d9f..e337b9c8 100644 --- a/l1infotreesync/processor.go +++ b/l1infotreesync/processor.go @@ -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)) @@ -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[:]) diff --git a/rpc/bridge.go b/rpc/bridge.go index 70c3fba4..7f58cf1c 100644 --- a/rpc/bridge.go +++ b/rpc/bridge.go @@ -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" ) @@ -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 { diff --git a/rpc/types/bridge.go b/rpc/types/bridge.go index 389a22f1..eb8c6464 100644 --- a/rpc/types/bridge.go +++ b/rpc/types/bridge.go @@ -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 } diff --git a/tree/tree.go b/tree/tree.go index b99ef451..5d307e8a 100644 --- a/tree/tree.go +++ b/tree/tree.go @@ -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, ) { @@ -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),