From 016f79a7a18fa6d01c9f745df5b4f2dbc6178c26 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 11:33:19 +0100 Subject: [PATCH 01/15] chg: handle edge cases with string blockNumber --- bor/client/grpc/query.go | 26 ++++++++++++++++++++++++-- go.mod | 2 +- go.sum | 4 ++-- helper/call.go | 7 ++----- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index 36e07663c..f363adbb9 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -2,6 +2,9 @@ package grpc import ( "context" + "fmt" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/rpc" "math/big" "github.com/ethereum/go-ethereum/common" @@ -54,8 +57,10 @@ func (h *BorGRPCClient) GetVoteOnHash(ctx context.Context, startBlock uint64, en func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*ethTypes.Header, error) { + blockNumberAsString := toBlockNumArg(big.NewInt(int64(blockID))) + req := &proto.GetHeaderByNumberRequest{ - Number: blockID, + Number: blockNumberAsString, } log.Info("Fetching header by number") @@ -78,8 +83,10 @@ func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*et func (h *BorGRPCClient) BlockByNumber(ctx context.Context, blockID uint64) (*ethTypes.Block, error) { + blockNumberAsString := toBlockNumArg(big.NewInt(int64(blockID))) + req := &proto.GetBlockByNumberRequest{ - Number: blockID, + Number: blockNumberAsString, } log.Info("Fetching block by number") @@ -153,3 +160,18 @@ func receiptResponseToTypesReceipt(receipt *proto.Receipt) *ethTypes.Receipt { TransactionIndex: uint(receipt.TransactionIndex), } } + +func toBlockNumArg(number *big.Int) string { + if number == nil { + return "latest" + } + if number.Sign() >= 0 { + return hexutil.EncodeBig(number) + } + // It's negative. + if number.IsInt64() { + return rpc.BlockNumber(number.Int64()).String() + } + // It's negative and large, which is invalid. + return fmt.Sprintf("", number) +} diff --git a/go.mod b/go.mod index c976c52f6..c8b1ce5d3 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/hashicorp/golang-lru v1.0.2 github.com/json-iterator/go v1.1.12 - github.com/maticnetwork/polyproto v0.0.3 + github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59 github.com/pborman/uuid v1.2.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.19.0 diff --git a/go.sum b/go.sum index 5d48562bb..dae90f54c 100644 --- a/go.sum +++ b/go.sum @@ -2225,8 +2225,8 @@ github.com/maticnetwork/crand v1.0.2 h1:Af0tAivC8zrxXDpGWNWVT/0s1fOz8w0eRbahZgUR github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxpj5ZKxfHjyg= github.com/maticnetwork/heimdall v1.0.7/go.mod h1:+ANI5+VV28ahwfdl7oMzrcNwaTEs1Fn6z39BqBGcvaA= github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= -github.com/maticnetwork/polyproto v0.0.3 h1:a69rIp97fcl3ABY4LlVX9B2t1qhLa0Jhny3HNOzReBU= -github.com/maticnetwork/polyproto v0.0.3/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= +github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59 h1:FAezvZ+jt3b1all6taYql6+mafszYBpwfD5KYQqQdNg= +github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= github.com/maticnetwork/tendermint v0.33.2 h1:R9M7jgAmON8K/LbzMvtWPDhtPkNcqzkUUHp1ict/h3s= github.com/maticnetwork/tendermint v0.33.2/go.mod h1:D2fcnxGk6bje+LoPwImuKSSYLiK7/G06IynGNDSEcJk= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= diff --git a/helper/call.go b/helper/call.go index 556291d41..4f1a84a66 100644 --- a/helper/call.go +++ b/helper/call.go @@ -464,10 +464,7 @@ func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes var latestBlock *ethTypes.Header - if c.MaticGrpcFlag && blockNum != nil { - if blockNum.Sign() < 0 { - blockNum = new(big.Int).Abs(blockNum) - } + if c.MaticGrpcFlag { latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64()) } else { latestBlock, err = c.MaticChainClient.HeaderByNumber(ctx, blockNum) @@ -885,7 +882,7 @@ func (c *ContractCaller) GetBlockByNumber(ctx context.Context, blockNumber uint6 var block *ethTypes.Block var err error - if c.MaticGrpcFlag && big.NewInt(int64(blockNumber)) != nil { + if c.MaticGrpcFlag { block, err = c.MaticGrpcClient.BlockByNumber(ctx, blockNumber) } else { block, err = c.MaticChainClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber))) From c84b35ba61c51f14d2058ad968d61c34ca5a7931 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 14:04:33 +0100 Subject: [PATCH 02/15] chg: sort imports --- bor/client/grpc/query.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index f363adbb9..acfb5a065 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -3,13 +3,13 @@ package grpc import ( "context" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/rpc" "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/rpc" proto "github.com/maticnetwork/polyproto/bor" protoutil "github.com/maticnetwork/polyproto/utils" From 8c95b0ec9c638292f8611ecb1714a5570b46138f Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 14:54:52 +0100 Subject: [PATCH 03/15] cgh: fix rpc blockNumber and bash warnings --- helper/call.go | 22 +++++++++++++++++++++- integration-tests/bor_health.sh | 4 ++-- integration-tests/smoke_test.sh | 14 +++++++------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/helper/call.go b/helper/call.go index 4f1a84a66..2acbf72c1 100644 --- a/helper/call.go +++ b/helper/call.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "strings" "time" @@ -465,7 +466,11 @@ func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes var latestBlock *ethTypes.Header if c.MaticGrpcFlag { - latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64()) + if blockNum == nil { + latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, uint64(rpc.LatestBlockNumber.Int64())) + } else { + latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64()) + } } else { latestBlock, err = c.MaticChainClient.HeaderByNumber(ctx, blockNum) } @@ -1016,3 +1021,18 @@ func chooseContractCallerABI(contractCallerObj *ContractCaller, abi string) (*ab func getABI(data string) (abi.ABI, error) { return abi.JSON(strings.NewReader(data)) } + +func toBlockNumArg(number *big.Int) string { + if number == nil { + return "latest" + } + if number.Sign() >= 0 { + return hexutil.EncodeBig(number) + } + // It's negative. + if number.IsInt64() { + return rpc.BlockNumber(number.Int64()).String() + } + // It's negative and large, which is invalid. + return fmt.Sprintf("", number) +} diff --git a/integration-tests/bor_health.sh b/integration-tests/bor_health.sh index 0791d415f..469992098 100644 --- a/integration-tests/bor_health.sh +++ b/integration-tests/bor_health.sh @@ -11,5 +11,5 @@ do fi done -echo $peers -echo $block +echo "$peers" +echo "$block" diff --git a/integration-tests/smoke_test.sh b/integration-tests/smoke_test.sh index 4541ec5d4..f5354ffde 100644 --- a/integration-tests/smoke_test.sh +++ b/integration-tests/smoke_test.sh @@ -18,8 +18,8 @@ do exit 1 fi - if (( $balance > $balanceInit )); then - if [ $stateSyncFound != "true" ]; then + if (( balance > balanceInit )); then + if [ "$stateSyncFound" != "true" ]; then stateSyncTime=$(( SECONDS - start_time )) stateSyncFound="true" fi @@ -27,18 +27,18 @@ do checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id) - if [ $checkpointID != "null" ]; then - if [ $checkpointFound != "true" ]; then + if [ "$checkpointID" != "null" ]; then + if [ "$checkpointFound" != "true" ]; then checkpointTime=$(( SECONDS - start_time )) checkpointFound="true" fi fi - if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then + if [ "$stateSyncFound" == "true" ] && [ "$checkpointFound" == "true" ]; then break fi done echo "Both state sync and checkpoint went through. All tests have passed!" -echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))" -echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))" +echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $((stateSyncTime%3600/60)) $((stateSyncTime%60)))" +echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $((checkpointTime%3600/60)) $((checkpointTime%60)))" From b404196ee27ffbe86a0423cf98dc71e57de110c8 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 15:03:07 +0100 Subject: [PATCH 04/15] cgh: sort imports --- helper/call.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/call.go b/helper/call.go index 2acbf72c1..853798db2 100644 --- a/helper/call.go +++ b/helper/call.go @@ -5,13 +5,13 @@ import ( "context" "errors" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "strings" "time" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" From 6b147ec8e808b1e872e8ae8c56e9253ac1930f6a Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 15:03:34 +0100 Subject: [PATCH 05/15] cgh: remove unused fn --- helper/call.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/helper/call.go b/helper/call.go index 853798db2..703670e41 100644 --- a/helper/call.go +++ b/helper/call.go @@ -11,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" @@ -1021,18 +1020,3 @@ func chooseContractCallerABI(contractCallerObj *ContractCaller, abi string) (*ab func getABI(data string) (abi.ABI, error) { return abi.JSON(strings.NewReader(data)) } - -func toBlockNumArg(number *big.Int) string { - if number == nil { - return "latest" - } - if number.Sign() >= 0 { - return hexutil.EncodeBig(number) - } - // It's negative. - if number.IsInt64() { - return rpc.BlockNumber(number.Int64()).String() - } - // It's negative and large, which is invalid. - return fmt.Sprintf("", number) -} From dcc009745d5985770b03d8b6b0aa5ab48fe46057 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 15:50:42 +0100 Subject: [PATCH 06/15] chg: use decimals over hex and fix overflow --- bor/client/grpc/grpc_util_test.go | 54 +++++++++++++++++++++++++++++++ bor/client/grpc/query.go | 18 ++++++++--- 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 bor/client/grpc/grpc_util_test.go diff --git a/bor/client/grpc/grpc_util_test.go b/bor/client/grpc/grpc_util_test.go new file mode 100644 index 000000000..c480b0e91 --- /dev/null +++ b/bor/client/grpc/grpc_util_test.go @@ -0,0 +1,54 @@ +package grpc + +import ( + "math/big" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestToBlockNumArg(t *testing.T) { + tests := []struct { + name string + input *big.Int + expected string + }{ + { + name: "Nil input", + input: nil, + expected: "latest", + }, + { + name: "Positive number", + input: big.NewInt(12345), + expected: "12345", + }, + { + name: "Zero", + input: big.NewInt(0), + expected: "0", + }, + { + name: "Negative number", + input: big.NewInt(-1), + expected: "pending", + }, + { + name: "Large negative number", + input: big.NewInt(-1234567890), + expected: "", + }, + { + name: "Large number", + input: big.NewInt(99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999), + expected: "", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := ToBlockNumArg(tt.input) + assert.Equal(t, tt.expected, result) + }) + } +} diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index acfb5a065..19ef22637 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -6,7 +6,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" @@ -57,7 +57,11 @@ func (h *BorGRPCClient) GetVoteOnHash(ctx context.Context, startBlock uint64, en func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*ethTypes.Header, error) { - blockNumberAsString := toBlockNumArg(big.NewInt(int64(blockID))) + if blockID > math.MaxInt64 { + return nil, fmt.Errorf("blockID too large: %d", blockID) + } + + blockNumberAsString := ToBlockNumArg(big.NewInt(int64(blockID))) req := &proto.GetHeaderByNumberRequest{ Number: blockNumberAsString, @@ -83,7 +87,11 @@ func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*et func (h *BorGRPCClient) BlockByNumber(ctx context.Context, blockID uint64) (*ethTypes.Block, error) { - blockNumberAsString := toBlockNumArg(big.NewInt(int64(blockID))) + if blockID > math.MaxInt64 { + return nil, fmt.Errorf("blockID too large: %d", blockID) + } + + blockNumberAsString := ToBlockNumArg(big.NewInt(int64(blockID))) req := &proto.GetBlockByNumberRequest{ Number: blockNumberAsString, @@ -161,12 +169,12 @@ func receiptResponseToTypesReceipt(receipt *proto.Receipt) *ethTypes.Receipt { } } -func toBlockNumArg(number *big.Int) string { +func ToBlockNumArg(number *big.Int) string { if number == nil { return "latest" } if number.Sign() >= 0 { - return hexutil.EncodeBig(number) + return number.String() } // It's negative. if number.IsInt64() { From 474c4ad09983bfea34b078ba1cab5a5551a6fd3f Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 15:59:28 +0100 Subject: [PATCH 07/15] chg: remove test --- bor/client/grpc/grpc_util_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bor/client/grpc/grpc_util_test.go b/bor/client/grpc/grpc_util_test.go index c480b0e91..803c6efb9 100644 --- a/bor/client/grpc/grpc_util_test.go +++ b/bor/client/grpc/grpc_util_test.go @@ -38,11 +38,6 @@ func TestToBlockNumArg(t *testing.T) { input: big.NewInt(-1234567890), expected: "", }, - { - name: "Large number", - input: big.NewInt(99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999), - expected: "", - }, } for _, tt := range tests { From e5c1066002d12a114866736fa0df8d7ed7648c54 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 16:05:44 +0100 Subject: [PATCH 08/15] chg: parallel tests --- bor/client/grpc/grpc_util_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bor/client/grpc/grpc_util_test.go b/bor/client/grpc/grpc_util_test.go index 803c6efb9..b00f31f1b 100644 --- a/bor/client/grpc/grpc_util_test.go +++ b/bor/client/grpc/grpc_util_test.go @@ -8,6 +8,8 @@ import ( ) func TestToBlockNumArg(t *testing.T) { + t.Parallel() + tests := []struct { name string input *big.Int From 0a52b7dd9374f1a845a553bc4a2693be00e5083e Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 16:08:42 +0100 Subject: [PATCH 09/15] chg: parallel subtests --- bor/client/grpc/grpc_util_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bor/client/grpc/grpc_util_test.go b/bor/client/grpc/grpc_util_test.go index b00f31f1b..eba9ba092 100644 --- a/bor/client/grpc/grpc_util_test.go +++ b/bor/client/grpc/grpc_util_test.go @@ -44,6 +44,7 @@ func TestToBlockNumArg(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() result := ToBlockNumArg(tt.input) assert.Equal(t, tt.expected, result) }) From 57e65604e9355d9e1c58b97761c2bfba587e8905 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 16:11:53 +0100 Subject: [PATCH 10/15] chg: fix lint --- bor/client/grpc/grpc_util_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bor/client/grpc/grpc_util_test.go b/bor/client/grpc/grpc_util_test.go index eba9ba092..7dec34aa8 100644 --- a/bor/client/grpc/grpc_util_test.go +++ b/bor/client/grpc/grpc_util_test.go @@ -43,6 +43,7 @@ func TestToBlockNumArg(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() result := ToBlockNumArg(tt.input) From 8b529034339a9ccdf2b83815822a93f26afda8b3 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 16:31:06 +0100 Subject: [PATCH 11/15] chg: fix LatestBlockNumber case --- helper/call.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/call.go b/helper/call.go index 703670e41..b23dc28f3 100644 --- a/helper/call.go +++ b/helper/call.go @@ -466,7 +466,8 @@ func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes if c.MaticGrpcFlag { if blockNum == nil { - latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, uint64(rpc.LatestBlockNumber.Int64())) + // LatestBlockNumber is BlockNumber(-2) in go-ethereum rpc + latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, -2) } else { latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64()) } From cab287eabeb7090a051fb4defadad06c04656c0b Mon Sep 17 00:00:00 2001 From: marcello33 Date: Wed, 13 Nov 2024 16:58:12 +0100 Subject: [PATCH 12/15] chg: fix negative blockNums --- bor/client/grpc/query.go | 8 ++++---- helper/call.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index 19ef22637..e9b01dccc 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -55,13 +55,13 @@ func (h *BorGRPCClient) GetVoteOnHash(ctx context.Context, startBlock uint64, en return res.Response, nil } -func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*ethTypes.Header, error) { +func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID int64) (*ethTypes.Header, error) { if blockID > math.MaxInt64 { return nil, fmt.Errorf("blockID too large: %d", blockID) } - blockNumberAsString := ToBlockNumArg(big.NewInt(int64(blockID))) + blockNumberAsString := ToBlockNumArg(big.NewInt(blockID)) req := &proto.GetHeaderByNumberRequest{ Number: blockNumberAsString, @@ -85,13 +85,13 @@ func (h *BorGRPCClient) HeaderByNumber(ctx context.Context, blockID uint64) (*et return resp, nil } -func (h *BorGRPCClient) BlockByNumber(ctx context.Context, blockID uint64) (*ethTypes.Block, error) { +func (h *BorGRPCClient) BlockByNumber(ctx context.Context, blockID int64) (*ethTypes.Block, error) { if blockID > math.MaxInt64 { return nil, fmt.Errorf("blockID too large: %d", blockID) } - blockNumberAsString := ToBlockNumArg(big.NewInt(int64(blockID))) + blockNumberAsString := ToBlockNumArg(big.NewInt(blockID)) req := &proto.GetBlockByNumberRequest{ Number: blockNumberAsString, diff --git a/helper/call.go b/helper/call.go index b23dc28f3..bac756edb 100644 --- a/helper/call.go +++ b/helper/call.go @@ -469,7 +469,7 @@ func (c *ContractCaller) GetMaticChainBlock(blockNum *big.Int) (header *ethTypes // LatestBlockNumber is BlockNumber(-2) in go-ethereum rpc latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, -2) } else { - latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Uint64()) + latestBlock, err = c.MaticGrpcClient.HeaderByNumber(ctx, blockNum.Int64()) } } else { latestBlock, err = c.MaticChainClient.HeaderByNumber(ctx, blockNum) @@ -888,7 +888,7 @@ func (c *ContractCaller) GetBlockByNumber(ctx context.Context, blockNumber uint6 var err error if c.MaticGrpcFlag { - block, err = c.MaticGrpcClient.BlockByNumber(ctx, blockNumber) + block, err = c.MaticGrpcClient.BlockByNumber(ctx, int64(blockNumber)) } else { block, err = c.MaticChainClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber))) } From 1f535e5c8b71793fafaad816815fa02fcb2e9286 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Thu, 14 Nov 2024 07:16:14 +0100 Subject: [PATCH 13/15] chg: try blocks hex ecnoding --- bor/client/grpc/query.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index e9b01dccc..9d2999b9c 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -3,6 +3,7 @@ package grpc import ( "context" "fmt" + "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "github.com/ethereum/go-ethereum/common" @@ -174,7 +175,7 @@ func ToBlockNumArg(number *big.Int) string { return "latest" } if number.Sign() >= 0 { - return number.String() + return hexutil.EncodeBig(number) } // It's negative. if number.IsInt64() { From 94f9809de3f8b6c8297e2d342a1766ee6ec84efe Mon Sep 17 00:00:00 2001 From: marcello33 Date: Thu, 14 Nov 2024 11:35:08 +0100 Subject: [PATCH 14/15] chg: fix lint --- bor/client/grpc/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bor/client/grpc/query.go b/bor/client/grpc/query.go index 9d2999b9c..6df82c997 100644 --- a/bor/client/grpc/query.go +++ b/bor/client/grpc/query.go @@ -3,10 +3,10 @@ package grpc import ( "context" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" ethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" From 4cdde382e4d2c489874db471c57e557646ead8ed Mon Sep 17 00:00:00 2001 From: marcello33 Date: Thu, 14 Nov 2024 11:42:23 +0100 Subject: [PATCH 15/15] chg: bump polyproto --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c8b1ce5d3..99ca5af78 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/hashicorp/golang-lru v1.0.2 github.com/json-iterator/go v1.1.12 - github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59 + github.com/maticnetwork/polyproto v0.0.4 github.com/pborman/uuid v1.2.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.19.0 diff --git a/go.sum b/go.sum index dae90f54c..17c18efa3 100644 --- a/go.sum +++ b/go.sum @@ -2225,8 +2225,8 @@ github.com/maticnetwork/crand v1.0.2 h1:Af0tAivC8zrxXDpGWNWVT/0s1fOz8w0eRbahZgUR github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxpj5ZKxfHjyg= github.com/maticnetwork/heimdall v1.0.7/go.mod h1:+ANI5+VV28ahwfdl7oMzrcNwaTEs1Fn6z39BqBGcvaA= github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= -github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59 h1:FAezvZ+jt3b1all6taYql6+mafszYBpwfD5KYQqQdNg= -github.com/maticnetwork/polyproto v0.0.4-0.20241113101917-6744479e4d59/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= +github.com/maticnetwork/polyproto v0.0.4 h1:qQ/qwcO6UNGS4mJlzlLJn1AUMfJK9Rqmf1v+KJgnPsk= +github.com/maticnetwork/polyproto v0.0.4/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o= github.com/maticnetwork/tendermint v0.33.2 h1:R9M7jgAmON8K/LbzMvtWPDhtPkNcqzkUUHp1ict/h3s= github.com/maticnetwork/tendermint v0.33.2/go.mod h1:D2fcnxGk6bje+LoPwImuKSSYLiK7/G06IynGNDSEcJk= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=