Skip to content

Commit

Permalink
Fix: Add hexutil Bytes encoding to batchcall data (#14165)
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan authored Aug 21, 2024
1 parent 831d006 commit e76463c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
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

0 comments on commit e76463c

Please sign in to comment.