From e76463cfa9a0fbe6e35a74cbb3f7d63c85efcd88 Mon Sep 17 00:00:00 2001 From: Silas Lenihan <32529249+silaslenihan@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:14:18 -0400 Subject: [PATCH] Fix: Add hexutil Bytes encoding to batchcall data (#14165) --- .changeset/odd-eagles-shave.md | 5 +++++ core/services/relay/evm/batch_caller.go | 2 +- core/services/relay/evm/batch_caller_test.go | 8 +++----- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .changeset/odd-eagles-shave.md diff --git a/.changeset/odd-eagles-shave.md b/.changeset/odd-eagles-shave.md new file mode 100644 index 00000000000..0c68bc1573c --- /dev/null +++ b/.changeset/odd-eagles-shave.md @@ -0,0 +1,5 @@ +--- +"chainlink": minor +--- + +#internal Add hexutil Bytes encoding to batchcall data diff --git a/core/services/relay/evm/batch_caller.go b/core/services/relay/evm/batch_caller.go index 53edc49eaa2..ce5a2bd722a 100644 --- a/core/services/relay/evm/batch_caller.go +++ b/core/services/relay/evm/batch_caller.go @@ -149,7 +149,7 @@ func (c *defaultEvmBatchCaller) batchCall(ctx context.Context, blockNumber uint6 map[string]interface{}{ "from": common.Address{}, "to": call.ContractAddress, - "data": data, + "data": hexutil.Bytes(data), }, blockNumStr, }, diff --git a/core/services/relay/evm/batch_caller_test.go b/core/services/relay/evm/batch_caller_test.go index 995e47618cc..048df90daba 100644 --- a/core/services/relay/evm/batch_caller_test.go +++ b/core/services/relay/evm/batch_caller_test.go @@ -1,12 +1,12 @@ package evm_test import ( - "encoding/hex" "fmt" "math/big" "testing" "github.com/cometbft/cometbft/libs/rand" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/rpc" "github.com/pkg/errors" "github.com/stretchr/testify/assert" @@ -152,12 +152,10 @@ func TestDefaultEvmBatchCaller_batchCallLimit(t *testing.T) { Run(func(args mock.Arguments) { evmCalls := args.Get(1).([]rpc.BatchElem) for i := range evmCalls { - arg := evmCalls[i].Args[0].(map[string]interface{})["data"].([]uint8) - bytes, err := hex.DecodeString(fmt.Sprintf("%x", arg)) - require.NoError(t, err) + arg := evmCalls[i].Args[0].(map[string]interface{})["data"].(hexutil.Bytes) str, isOk := evmCalls[i].Result.(*string) require.True(t, isOk) - *str = fmt.Sprintf("0x%064x", new(big.Int).SetBytes(bytes[24:]).Uint64()) + *str = fmt.Sprintf("0x%064x", new(big.Int).SetBytes(arg[24:]).Uint64()) } }).Return(nil)