Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add hexutil Bytes encoding to batchcall data #14165

Merged
merged 9 commits into from
Aug 21, 2024
5 changes: 5 additions & 0 deletions .changeset/odd-eagles-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Add hexutil Bytes encoding to batchcall data
2 changes: 1 addition & 1 deletion core/services/relay/evm/batch_caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
8 changes: 3 additions & 5 deletions core/services/relay/evm/batch_caller_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)

Expand Down
Loading