From cb2511924c85702645f5e0fcbb319fee5214a0b2 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:51:00 +0900 Subject: [PATCH] fix to use hexutils --- app/ibc-hooks/ack.go | 5 +- app/ibc-hooks/ack_test.go | 5 +- app/ibc-hooks/receive_test.go | 7 +- app/ibc-hooks/timeout.go | 7 +- app/ibc-hooks/timeout_test.go | 5 +- proto/minievm/evm/v1/query.proto | 6 +- x/evm/keeper/context.go | 5 +- x/evm/keeper/context_test.go | 7 +- x/evm/keeper/erc20.go | 6 +- x/evm/keeper/erc20_test.go | 5 +- x/evm/keeper/msg_server.go | 14 ++-- x/evm/keeper/msg_server_test.go | 17 ++-- x/evm/keeper/query_server.go | 14 ++-- x/evm/keeper/query_server_test.go | 5 +- x/evm/precompiles/cosmos/contract.go | 8 +- x/evm/types/log.go | 4 +- x/evm/types/query.pb.go | 121 +++++++++++++-------------- 17 files changed, 113 insertions(+), 128 deletions(-) diff --git a/app/ibc-hooks/ack.go b/app/ibc-hooks/ack.go index 21f0b0c5..19bb4351 100644 --- a/app/ibc-hooks/ack.go +++ b/app/ibc-hooks/ack.go @@ -1,11 +1,10 @@ package evm_hooks import ( - "encoding/hex" - sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + "github.com/ethereum/go-ethereum/common/hexutil" ibchooks "github.com/initia-labs/initia/x/ibc-hooks" evmtypes "github.com/initia-labs/minievm/x/evm/types" @@ -46,7 +45,7 @@ func (h EVMHooks) onAckIcs20Packet( _, err = h.execMsg(ctx, &evmtypes.MsgCall{ Sender: data.Sender, ContractAddr: callback.ContractAddress, - Input: hex.EncodeToString(inputBz), + Input: hexutil.Encode(inputBz), }) if err != nil { return err diff --git a/app/ibc-hooks/ack_test.go b/app/ibc-hooks/ack_test.go index 769ec744..6770b52c 100644 --- a/app/ibc-hooks/ack_test.go +++ b/app/ibc-hooks/ack_test.go @@ -1,16 +1,15 @@ package evm_hooks_test import ( - "encoding/hex" "encoding/json" "errors" "fmt" - "strings" "testing" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/holiman/uint256" "github.com/initia-labs/minievm/x/evm/contracts/counter" "github.com/stretchr/testify/require" @@ -46,7 +45,7 @@ func Test_onAckIcs20Packet_memo(t *testing.T) { _, _, addr := keyPubAddr() evmAddr := common.BytesToAddress(addr.Bytes()) - codeBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) _, contractAddr, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz) diff --git a/app/ibc-hooks/receive_test.go b/app/ibc-hooks/receive_test.go index a6b5cb8e..617f7cd2 100644 --- a/app/ibc-hooks/receive_test.go +++ b/app/ibc-hooks/receive_test.go @@ -1,13 +1,12 @@ package evm_hooks_test import ( - "encoding/hex" "encoding/json" "fmt" - "strings" "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/holiman/uint256" "github.com/stretchr/testify/require" @@ -45,7 +44,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) { _, _, addr := keyPubAddr() evmAddr := common.BytesToAddress(addr.Bytes()) - codeBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) _, contractAddr, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz) @@ -69,7 +68,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) { "input": "%s" } } - }`, contractAddr.Hex(), hex.EncodeToString(inputBz)), + }`, contractAddr.Hex(), hexutil.Encode(inputBz)), } dataBz, err := json.Marshal(&data) diff --git a/app/ibc-hooks/timeout.go b/app/ibc-hooks/timeout.go index 889f604f..b7d1bc4e 100644 --- a/app/ibc-hooks/timeout.go +++ b/app/ibc-hooks/timeout.go @@ -1,11 +1,10 @@ package evm_hooks import ( - "encoding/hex" - sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + "github.com/ethereum/go-ethereum/common/hexutil" ibchooks "github.com/initia-labs/initia/x/ibc-hooks" @@ -46,7 +45,7 @@ func (h EVMHooks) onTimeoutIcs20Packet( _, err = h.execMsg(ctx, &evmtypes.MsgCall{ Sender: data.Sender, ContractAddr: callback.ContractAddress, - Input: hex.EncodeToString(inputBz), + Input: hexutil.Encode(inputBz), }) if err != nil { return err @@ -88,7 +87,7 @@ func (h EVMHooks) onTimeoutIcs20Packet( // _, err = h.execMsg(ctx, &evmtypes.MsgCall{ // Sender: data.Sender, // ContractAddr: callback.ContractAddress, -// Input: hex.EncodeToString(inputBz), +// Input: hexutil.Encode(inputBz), // }) // if err != nil { // return err diff --git a/app/ibc-hooks/timeout_test.go b/app/ibc-hooks/timeout_test.go index dc3ae3d9..f8b5fbfa 100644 --- a/app/ibc-hooks/timeout_test.go +++ b/app/ibc-hooks/timeout_test.go @@ -1,15 +1,14 @@ package evm_hooks_test import ( - "encoding/hex" "encoding/json" "fmt" - "strings" "testing" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/holiman/uint256" "github.com/initia-labs/minievm/x/evm/contracts/counter" "github.com/stretchr/testify/require" @@ -42,7 +41,7 @@ func Test_onTimeoutIcs20Packet_memo(t *testing.T) { _, _, addr := keyPubAddr() evmAddr := common.BytesToAddress(addr.Bytes()) - codeBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) _, contractAddr, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz) diff --git a/proto/minievm/evm/v1/query.proto b/proto/minievm/evm/v1/query.proto index ba091c2b..8ed29d6c 100644 --- a/proto/minievm/evm/v1/query.proto +++ b/proto/minievm/evm/v1/query.proto @@ -55,13 +55,13 @@ message QueryCodeRequest { // method message QueryCodeResponse { option (gogoproto.equal) = true; - bytes code = 1; + string code = 1; } // QueryStateRequest is the request type for the Query/State RPC // method message QueryStateRequest { - // It can be cosmos address or hex encoded address (0x prefixed). + // It can be cosmos address or hex encoded address. string contract_addr = 1; // hex encoded hash string string key = 2; @@ -80,7 +80,7 @@ message QueryStateResponse { message QueryCallRequest { // sender address string sender = 1; - // It can be cosmos address or hex encoded address (0x prefixed). + // It can be cosmos address or hex encoded address. string contract_addr = 2; // hex encoded call input string input = 3; diff --git a/x/evm/keeper/context.go b/x/evm/keeper/context.go index f3fcf9a8..02293a3f 100644 --- a/x/evm/keeper/context.go +++ b/x/evm/keeper/context.go @@ -10,6 +10,7 @@ import ( "github.com/holiman/uint256" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" coretypes "github.com/ethereum/go-ethereum/core/types" @@ -222,7 +223,7 @@ func (k Keeper) EVMCallWithTracer(ctx context.Context, caller common.Address, co return nil, nil, err } - retHex := common.Bytes2Hex(retBz) + retHex := hexutil.Encode(retBz) logs := types.NewLogs(stateDB.Logs()) // emit action events @@ -304,7 +305,7 @@ func (k Keeper) EVMCreateWithTracer(ctx context.Context, caller common.Address, return nil, common.Address{}, err } - retHex := common.Bytes2Hex(retBz) + retHex := hexutil.Encode(retBz) logs := types.NewLogs(stateDB.Logs()) // emit action events diff --git a/x/evm/keeper/context_test.go b/x/evm/keeper/context_test.go index 1d5556ce..d165aa22 100644 --- a/x/evm/keeper/context_test.go +++ b/x/evm/keeper/context_test.go @@ -1,14 +1,13 @@ package keeper_test import ( - "encoding/hex" "fmt" - "strings" "testing" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/vm" "github.com/holiman/uint256" @@ -25,7 +24,7 @@ func Test_Create(t *testing.T) { ctx, input := createDefaultTestInput(t) _, _, addr := keyPubAddr() - counterBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + counterBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) @@ -39,7 +38,7 @@ func Test_Call(t *testing.T) { ctx, input := createDefaultTestInput(t) _, _, addr := keyPubAddr() - counterBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + counterBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) diff --git a/x/evm/keeper/erc20.go b/x/evm/keeper/erc20.go index 53d967fc..c7d44e95 100644 --- a/x/evm/keeper/erc20.go +++ b/x/evm/keeper/erc20.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "encoding/hex" "math/big" "strings" @@ -15,6 +14,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/initia-labs/minievm/x/evm/contracts/erc20" "github.com/initia-labs/minievm/x/evm/types" @@ -32,7 +32,7 @@ func NewERC20Keeper(k *Keeper) (types.IERC20Keeper, error) { return ERC20Keeper{}, err } - erc20Bin, err := hex.DecodeString(strings.TrimPrefix(erc20.Erc20Bin, "0x")) + erc20Bin, err := hexutil.Decode(erc20.Erc20Bin) if err != nil { return ERC20Keeper{}, err } @@ -310,7 +310,7 @@ func (k ERC20Keeper) MintCoins(ctx context.Context, addr sdk.AccAddress, amount sdk.NewEvent( types.EventTypeERC20Created, sdk.NewAttribute(types.AttributeKeyDenom, denom), - sdk.NewAttribute(types.AttributeKeyContract, common.Bytes2Hex(ret)), + sdk.NewAttribute(types.AttributeKeyContract, hexutil.Encode(ret)), ), ) } diff --git a/x/evm/keeper/erc20_test.go b/x/evm/keeper/erc20_test.go index 33a508d5..e1f5f22b 100644 --- a/x/evm/keeper/erc20_test.go +++ b/x/evm/keeper/erc20_test.go @@ -1,12 +1,11 @@ package keeper_test import ( - "encoding/hex" - "strings" "testing" "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +23,7 @@ func deployERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller common inputBz, err := abi.Pack("", denom, denom, uint8(6)) require.NoError(t, err) - erc20Bin, err := hex.DecodeString(strings.TrimPrefix(erc20.Erc20Bin, "0x")) + erc20Bin, err := hexutil.Decode(erc20.Erc20Bin) require.NoError(t, err) _, contractAddr, err := input.EVMKeeper.EVMCreate(ctx, caller, append(erc20Bin, inputBz...)) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index b6da179d..581f00f5 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -2,10 +2,8 @@ package keeper import ( "context" - "encoding/hex" - "strings" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -36,7 +34,7 @@ func (ms *msgServerImpl) Create(ctx context.Context, msg *types.MsgCreate) (*typ if len(msg.Code) == 0 { return nil, sdkerrors.ErrInvalidRequest.Wrap("empty code bytes") } - codeBz, err := hex.DecodeString(strings.TrimPrefix(msg.Code, "0x")) + codeBz, err := hexutil.Decode(msg.Code) if err != nil { return nil, types.ErrInvalidHexString.Wrap(err.Error()) } @@ -69,9 +67,8 @@ func (ms *msgServerImpl) Create(ctx context.Context, msg *types.MsgCreate) (*typ return nil, types.ErrEVMCallFailed.Wrap(err.Error()) } - retHex := common.Bytes2Hex(retBz) return &types.MsgCreateResponse{ - Result: retHex, + Result: hexutil.Encode(retBz), ContractAddr: contractAddr.Hex(), }, nil } @@ -93,7 +90,7 @@ func (ms *msgServerImpl) Call(ctx context.Context, msg *types.MsgCall) (*types.M if err != nil { return nil, err } - inputBz, err := hex.DecodeString(strings.TrimPrefix(msg.Input, "0x")) + inputBz, err := hexutil.Decode(msg.Input) if err != nil { return nil, types.ErrInvalidHexString.Wrap(err.Error()) } @@ -103,8 +100,7 @@ func (ms *msgServerImpl) Call(ctx context.Context, msg *types.MsgCall) (*types.M return nil, types.ErrEVMCreateFailed.Wrap(err.Error()) } - retHex := common.Bytes2Hex(retBz) - return &types.MsgCallResponse{Result: retHex, Logs: logs}, nil + return &types.MsgCallResponse{Result: hexutil.Encode(retBz), Logs: logs}, nil } // UpdateParams implements types.MsgServer. diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index c0a2dea8..b3f1875a 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -1,11 +1,10 @@ package keeper_test import ( - "encoding/hex" - "strings" "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/holiman/uint256" "github.com/initia-labs/minievm/x/evm/contracts/counter" "github.com/initia-labs/minievm/x/evm/keeper" @@ -17,12 +16,10 @@ func Test_MsgServer_Create(t *testing.T) { ctx, input := createDefaultTestInput(t) _, _, addr := keyPubAddr() - counterBin := strings.TrimPrefix(counter.CounterBin, "0x") - msgServer := keeper.NewMsgServerImpl(&input.EVMKeeper) res, err := msgServer.Create(ctx, &types.MsgCreate{ Sender: addr.String(), - Code: counterBin, + Code: counter.CounterBin, }) require.NoError(t, err) require.NotEmpty(t, res.Result) @@ -37,7 +34,7 @@ func Test_MsgServer_Create(t *testing.T) { // allowed res, err = msgServer.Create(ctx, &types.MsgCreate{ Sender: addr.String(), - Code: counterBin, + Code: counter.CounterBin, }) require.NoError(t, err) require.NotEmpty(t, res.Result) @@ -47,7 +44,7 @@ func Test_MsgServer_Create(t *testing.T) { _, _, addr = keyPubAddr() _, err = msgServer.Create(ctx, &types.MsgCreate{ Sender: addr.String(), - Code: counterBin, + Code: counter.CounterBin, }) require.Error(t, err) } @@ -57,7 +54,7 @@ func Test_MsgServer_Call(t *testing.T) { _, _, addr := keyPubAddr() caller := common.BytesToAddress(addr.Bytes()) - counterBz, err := hex.DecodeString(strings.TrimPrefix(counter.CounterBin, "0x")) + counterBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) retBz, contractAddr, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz) @@ -83,10 +80,10 @@ func Test_MsgServer_Call(t *testing.T) { res, err := msgServer.Call(ctx, &types.MsgCall{ Sender: addr.String(), ContractAddr: contractAddr.Hex(), - Input: common.Bytes2Hex(inputBz), + Input: hexutil.Encode(inputBz), }) require.NoError(t, err) - require.Empty(t, res.Result) + require.Equal(t, "0x", res.Result) require.NotEmpty(t, res.Logs) queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz) diff --git a/x/evm/keeper/query_server.go b/x/evm/keeper/query_server.go index 2f04c92d..fdeede9d 100644 --- a/x/evm/keeper/query_server.go +++ b/x/evm/keeper/query_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "encoding/hex" "fmt" "strings" @@ -11,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/eth/tracers/logger" @@ -46,7 +46,7 @@ func (qs *queryServerImpl) Call(ctx context.Context, req *types.QueryCallRequest return nil, err } - inputBz, err := hex.DecodeString(strings.TrimPrefix(req.Input, "0x")) + inputBz, err := hexutil.Decode(req.Input) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func (qs *queryServerImpl) Call(ctx context.Context, req *types.QueryCallRequest } return &types.QueryCallResponse{ - Response: common.Bytes2Hex(retBz), + Response: hexutil.Encode(retBz), UsedGas: sdkCtx.GasMeter().GasConsumedToLimit(), Logs: logs, TraceOutput: tracerOutput.String(), @@ -94,9 +94,9 @@ func (qs *queryServerImpl) Code(ctx context.Context, req *types.QueryCodeRequest return nil, err } - codeBz := stateDB.GetCode(common.Address(contractAddr.Bytes())) + codeBz := stateDB.GetCode(contractAddr) return &types.QueryCodeResponse{ - Code: codeBz, + Code: hexutil.Encode(codeBz), }, nil } @@ -112,12 +112,12 @@ func (qs *queryServerImpl) State(ctx context.Context, req *types.QueryStateReque return nil, err } - keyBz, err := hex.DecodeString(strings.TrimPrefix(req.Key, "0x")) + keyBz, err := hexutil.Decode(req.Key) if err != nil { return nil, err } - state := stateDB.GetState(common.Address(contractAddr.Bytes()), common.BytesToHash(keyBz)) + state := stateDB.GetState(contractAddr, common.BytesToHash(keyBz)) return &types.QueryStateResponse{ Value: state.Hex(), }, nil diff --git a/x/evm/keeper/query_server_test.go b/x/evm/keeper/query_server_test.go index a5bda76f..60afa018 100644 --- a/x/evm/keeper/query_server_test.go +++ b/x/evm/keeper/query_server_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/initia-labs/minievm/x/evm/contracts/erc20" "github.com/initia-labs/minievm/x/evm/keeper" @@ -39,12 +40,12 @@ func Test_Query_Call(t *testing.T) { res, err := qs.Call(ctx, &types.QueryCallRequest{ Sender: addr.String(), ContractAddr: fooContractAddr.String(), - Input: common.Bytes2Hex(inputBz), + Input: hexutil.Encode(inputBz), WithTrace: true, }) require.NoError(t, err) - outputBz := common.Hex2Bytes(res.Response) + outputBz := hexutil.MustDecode(res.Response) ret, err := abi.Unpack("balanceOf", outputBz) require.NoError(t, err) diff --git a/x/evm/precompiles/cosmos/contract.go b/x/evm/precompiles/cosmos/contract.go index bf61802b..a2255f29 100644 --- a/x/evm/precompiles/cosmos/contract.go +++ b/x/evm/precompiles/cosmos/contract.go @@ -3,11 +3,11 @@ package cosmosprecompile import ( "bytes" "context" - "encoding/hex" "errors" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/vm" "cosmossdk.io/core/address" @@ -104,7 +104,7 @@ func (e CosmosPrecompile) ExtendedRun(caller vm.ContractRef, input []byte, suppl // check address length if len(addr) != common.AddressLength { - return nil, ctx.GasMeter().GasConsumedToLimit(), types.ErrInvalidAddressLength.Wrap(common.Bytes2Hex(addr)) + return nil, ctx.GasMeter().GasConsumedToLimit(), types.ErrInvalidAddressLength.Wrap(hexutil.Encode(addr)) } resBz, err = method.Outputs.Pack(common.BytesToAddress(addr)) @@ -156,8 +156,8 @@ func (e CosmosPrecompile) ExtendedRun(caller vm.ContractRef, input []byte, suppl } return nil, ctx.GasMeter().GasConsumedToLimit(), sdkerrors.ErrUnauthorized.Wrapf( - "required signer: `0x%s`, given signer: `%s`", - hex.EncodeToString(signer), caller.Address(), + "required signer: `%s`, given signer: `%s`", + hexutil.Encode(signer), caller.Address(), ) } diff --git a/x/evm/types/log.go b/x/evm/types/log.go index 54a59ab1..5a9eb86e 100644 --- a/x/evm/types/log.go +++ b/x/evm/types/log.go @@ -1,7 +1,7 @@ package types import ( - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" coretypes "github.com/ethereum/go-ethereum/core/types" ) @@ -25,6 +25,6 @@ func NewLog(ethLog *coretypes.Log) Log { return Log{ Address: ethLog.Address.String(), Topics: topics, - Data: common.Bytes2Hex(ethLog.Data), + Data: hexutil.Encode(ethLog.Data), } } diff --git a/x/evm/types/query.pb.go b/x/evm/types/query.pb.go index eb75f7e7..ac502341 100644 --- a/x/evm/types/query.pb.go +++ b/x/evm/types/query.pb.go @@ -4,7 +4,6 @@ package types import ( - bytes "bytes" context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -74,7 +73,7 @@ var xxx_messageInfo_QueryCodeRequest proto.InternalMessageInfo // QueryCodeResponse is the response type for the Query/Code RPC // method type QueryCodeResponse struct { - Code []byte `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` } func (m *QueryCodeResponse) Reset() { *m = QueryCodeResponse{} } @@ -113,7 +112,7 @@ var xxx_messageInfo_QueryCodeResponse proto.InternalMessageInfo // QueryStateRequest is the request type for the Query/State RPC // method type QueryStateRequest struct { - // It can be cosmos address or hex encoded address (0x prefixed). + // It can be cosmos address or hex encoded address. ContractAddr string `protobuf:"bytes,1,opt,name=contract_addr,json=contractAddr,proto3" json:"contract_addr,omitempty"` // hex encoded hash string Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` @@ -197,7 +196,7 @@ var xxx_messageInfo_QueryStateResponse proto.InternalMessageInfo type QueryCallRequest struct { // sender address Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // It can be cosmos address or hex encoded address (0x prefixed). + // It can be cosmos address or hex encoded address. ContractAddr string `protobuf:"bytes,2,opt,name=contract_addr,json=contractAddr,proto3" json:"contract_addr,omitempty"` // hex encoded call input Input string `protobuf:"bytes,3,opt,name=input,proto3" json:"input,omitempty"` @@ -534,56 +533,56 @@ func init() { func init() { proto.RegisterFile("minievm/evm/v1/query.proto", fileDescriptor_2bf9e0bee7cfd1a4) } var fileDescriptor_2bf9e0bee7cfd1a4 = []byte{ - // 781 bytes of a gzipped FileDescriptorProto + // 778 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00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e5, 0x01, 0x5e, 0x43, 0x7f, 0xd5, - 0x99, 0x17, 0xf8, 0xa4, 0x1e, 0x54, 0x89, 0x6d, 0xfb, 0x9a, 0x92, 0x53, 0xf2, 0xb3, 0x95, 0xf9, - 0x48, 0x79, 0xdb, 0xb6, 0x7d, 0x73, 0x1d, 0x2d, 0xf6, 0x39, 0xf2, 0x16, 0xf3, 0x38, 0xc5, 0x18, - 0xa9, 0x75, 0x66, 0x53, 0x70, 0x98, 0xaf, 0xc0, 0x79, 0x47, 0xfd, 0xf5, 0x3e, 0xab, 0x98, 0xf7, - 0xa5, 0xf9, 0x93, 0x80, 0x04, 0x7f, 0x04, 0x84, 0x17, 0x50, 0x72, 0x9f, 0x76, 0xb5, 0x29, 0xb8, - 0x12, 0x47, 0x73, 0x03, 0xe1, 0xfe, 0x58, 0x12, 0x3b, 0x83, 0x52, 0x1d, 0xd2, 0x68, 0x53, 0x19, - 0x24, 0x14, 0x24, 0xfa, 0xb1, 0x12, 0xa5, 0x49, 0x1a, 0x8d, 0x08, 0x7d, 0x19, 0xa5, 0x39, 0xf5, - 0x6c, 0x1a, 0xc1, 0x4a, 0x69, 0x98, 0xd5, 0xd4, 0x08, 0x56, 0x19, 0x94, 0x72, 0xbd, 0x56, 0x3b, - 0xd0, 0x92, 0x21, 0x1a, 0x08, 0xf8, 0x5f, 0x84, 0x9e, 0xbb, 0xc1, 0x5e, 0x55, 0xd8, 0x51, 0x4d, - 0xcd, 0x29, 0xf9, 0x99, 0xca, 0xac, 0xd0, 0x3c, 0x15, 0x0a, 0xf3, 0x93, 0x12, 0x15, 0x0d, 0x68, - 0x48, 0xe2, 0x3a, 0x9a, 0xf1, 0xe5, 0x59, 0x32, 0xb9, 0x90, 0xf1, 0x0a, 0x9a, 0x69, 0x73, 0x6a, - 0x57, 0x1d, 0xc2, 0x81, 0x86, 0x5a, 0x99, 0x16, 0xf2, 0x3d, 0xc2, 0x71, 0x09, 0xa9, 0x0d, 0xe6, - 0x70, 0x2d, 0x99, 0x4b, 0xe6, 0xe7, 0x4a, 0x4b, 0xc5, 0xc1, 0xd9, 0x29, 0xee, 0x32, 0xa7, 0x3c, - 0x7b, 0xfa, 0x35, 0x9b, 0x38, 0xf9, 0xf9, 0xb1, 0xa0, 0x54, 0xc0, 0x16, 0xaf, 0xa2, 0x79, 0xa0, - 0x56, 0x65, 0xed, 0x40, 0x90, 0x57, 0x01, 0x6e, 0x0e, 0x74, 0x0f, 0x41, 0x25, 0x12, 0xa3, 0xbe, - 0xcf, 0x7c, 0x2d, 0x15, 0x26, 0x06, 0x82, 0xb9, 0x8d, 0xb2, 0xb2, 0xdb, 0x97, 0x35, 0x28, 0x77, - 0xef, 0x52, 0x8f, 0x35, 0xa3, 0x72, 0x66, 0x50, 0xca, 0x16, 0x72, 0x54, 0x7f, 0x10, 0xcc, 0x32, - 0xca, 0x8d, 0x77, 0x94, 0x49, 0x6a, 0x68, 0x5a, 0xd4, 0x99, 0x72, 0x2e, 0x7d, 0x23, 0x51, 0x76, - 0xef, 0x96, 0xac, 0xda, 0x00, 0xdc, 0x95, 0x86, 0x34, 0x9a, 0x94, 0x41, 0xbc, 0x91, 0x4c, 0x25, - 0x56, 0x46, 0x7a, 0x3c, 0x22, 0x3e, 0x69, 0x72, 0x09, 0x66, 0x3e, 0x40, 0x4b, 0x03, 0x5a, 0x19, - 0x68, 0x0b, 0xa5, 0x5b, 0xa0, 0x81, 0x48, 0x73, 0xa5, 0xe5, 0x78, 0x13, 0x42, 0xfb, 0xb2, 0x2a, - 0xfa, 0x50, 0x91, 0xb6, 0xa5, 0xb7, 0x69, 0x94, 0x82, 0x68, 0xf8, 0x25, 0x52, 0xc5, 0xfa, 0xe0, - 0x5c, 0xdc, 0x2f, 0xbe, 0x92, 0xfa, 0xea, 0x04, 0x8b, 0x90, 0x8c, 0xb9, 0xfe, 0xfa, 0xf3, 0x8f, - 0x77, 0x53, 0xd7, 0xf1, 0xff, 0x56, 0x6c, 0xdd, 0xc5, 0x16, 0x72, 0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0x61, 0xcf, 0xa3, + 0x01, 0x0e, 0x5c, 0xea, 0x31, 0x79, 0x1b, 0x87, 0x0c, 0xba, 0x2d, 0x22, 0xef, 0xcc, 0x6d, 0x58, + 0x78, 0xcc, 0x19, 0xdc, 0xa1, 0x36, 0xa9, 0x90, 0x83, 0x36, 0x61, 0x01, 0x5a, 0x83, 0xbf, 0xea, + 0xd4, 0x0b, 0x7c, 0x5c, 0x0f, 0xaa, 0xd8, 0xb6, 0x7d, 0x4d, 0xc9, 0x29, 0xf9, 0xd9, 0xca, 0x7c, + 0xa4, 0xbc, 0x6d, 0xdb, 0xbe, 0xb9, 0x0e, 0x8b, 0x7d, 0x8e, 0xac, 0x45, 0x3d, 0x46, 0x10, 0x02, + 0xb5, 0x4e, 0x6d, 0x22, 0x1d, 0xc4, 0x79, 0x47, 0xfd, 0xf5, 0x3e, 0xab, 0x98, 0xf7, 0xa5, 0xf9, + 0x93, 0x00, 0x07, 0x7f, 0x04, 0x84, 0x16, 0x20, 0xb9, 0x4f, 0xba, 0xda, 0x94, 0xb8, 0xe2, 0x47, + 0x73, 0x03, 0x50, 0x7f, 0x2c, 0x89, 0x9d, 0x81, 0x54, 0x07, 0x37, 0xda, 0x11, 0x78, 0x28, 0x48, + 0xf4, 0x63, 0x25, 0x4a, 0x13, 0x37, 0x1a, 0x11, 0xfa, 0x32, 0xa4, 0x19, 0xf1, 0x6c, 0x12, 0xc1, + 0x4a, 0x69, 0x98, 0xd5, 0xd4, 0x08, 0x56, 0x19, 0x48, 0xb9, 0x5e, 0xab, 0x1d, 0x68, 0xc9, 0x10, + 0x4d, 0x08, 0xe8, 0x5f, 0x80, 0xe7, 0x6e, 0xb0, 0x57, 0xe5, 0x76, 0x44, 0x53, 0x73, 0x4a, 0x7e, + 0xa6, 0x32, 0xcb, 0x35, 0x4f, 0xb9, 0xc2, 0xfc, 0xa4, 0x44, 0x45, 0x13, 0x34, 0x24, 0x71, 0x1d, + 0x66, 0x7c, 0x79, 0x96, 0x4c, 0x2e, 0x64, 0xb4, 0x02, 0x33, 0x6d, 0x46, 0xec, 0xaa, 0x83, 0x99, + 0xa0, 0xa1, 0x56, 0xa6, 0xb9, 0x7c, 0x0f, 0x33, 0x54, 0x02, 0xb5, 0x41, 0x1d, 0xa6, 0x25, 0x73, + 0xc9, 0xfc, 0x5c, 0x69, 0xa9, 0x38, 0x38, 0x3b, 0xc5, 0x5d, 0xea, 0x94, 0x67, 0x4f, 0xbf, 0x66, + 0x13, 0x27, 0x3f, 0x3f, 0x16, 0x94, 0x8a, 0xb0, 0x45, 0xab, 0x30, 0x2f, 0xa8, 0x55, 0x69, 0x3b, + 0xe0, 0xe4, 0x55, 0x01, 0x37, 0x27, 0x74, 0x0f, 0x85, 0x8a, 0x27, 0x46, 0x7c, 0x9f, 0xfa, 0x5a, + 0x2a, 0x4c, 0x4c, 0x08, 0xe6, 0x36, 0x64, 0x65, 0xb7, 0x2f, 0x6b, 0x50, 0xee, 0xde, 0x25, 0x1e, + 0x6d, 0x46, 0xe5, 0xcc, 0x40, 0xca, 0xe6, 0x72, 0x54, 0x7f, 0x21, 0x98, 0x65, 0xc8, 0x8d, 0x77, + 0x94, 0x49, 0x6a, 0x30, 0xcd, 0xeb, 0x4c, 0x18, 0x93, 0xbe, 0x91, 0x28, 0xbb, 0x77, 0x4b, 0x56, + 0x6d, 0x00, 0xee, 0x4a, 0x43, 0x1a, 0x4d, 0xca, 0x20, 0xde, 0x48, 0xa6, 0x12, 0x2b, 0x23, 0x3d, + 0x1e, 0x61, 0x1f, 0x37, 0x99, 0x04, 0x33, 0x1f, 0xc0, 0xd2, 0x80, 0x56, 0x06, 0xda, 0x82, 0x74, + 0x4b, 0x68, 0x44, 0xa4, 0xb9, 0xd2, 0x72, 0xbc, 0x09, 0xa1, 0x7d, 0x59, 0xe5, 0x7d, 0xa8, 0x48, + 0xdb, 0xd2, 0xdb, 0x34, 0xa4, 0x44, 0x34, 0xf4, 0x12, 0x54, 0xbe, 0x3e, 0x28, 0x17,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, 0xf4, 0x8c, 0xc4, 0x69, 0xcf, 0x50, 0xce, 0x7a, 0x86, 0xf2, 0xad, 0x67, + 0x28, 0x6f, 0xce, 0x8d, 0xc4, 0xd9, 0xb9, 0x91, 0xf8, 0x72, 0x6e, 0x24, 0x9e, 0x15, 0x1c, 0x37, + 0xd8, 0x6b, 0xd7, 0x8a, 0x75, 0xda, 0xb4, 0x5c, 0xcf, 0x0d, 0x5c, 0xbc, 0xde, 0xc0, 0x35, 0x76, + 0x11, 0xef, 0x85, 0x88, 0x28, 0xbe, 0x6d, 0xb5, 0xb4, 0xf8, 0xb8, 0xdd, 0xfc, 0x1d, 0x00, 0x00, + 0xff, 0xff, 0x69, 0x0d, 0x3c, 0x88, 0x6d, 0x07, 0x00, 0x00, } func (this *QueryCodeResponse) Equal(that interface{}) bool { @@ -605,7 +604,7 @@ func (this *QueryCodeResponse) Equal(that interface{}) bool { } else if this == nil { return false } - if !bytes.Equal(this.Code, that1.Code) { + if this.Code != that1.Code { return false } return true @@ -1685,7 +1684,7 @@ func (m *QueryCodeResponse) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -1695,25 +1694,23 @@ func (m *QueryCodeResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) - if m.Code == nil { - m.Code = []byte{} - } + m.Code = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex