From 88d17134ce3d6a62297da067d789d9f940391d16 Mon Sep 17 00:00:00 2001 From: codchen Date: Tue, 17 Sep 2024 21:26:18 +0800 Subject: [PATCH] Revert showing wasm transactions in EVM rpc (#1861) --- evmrpc/block.go | 23 --------------- evmrpc/block_test.go | 67 -------------------------------------------- 2 files changed, 90 deletions(-) diff --git a/evmrpc/block.go b/evmrpc/block.go index 4753f00e5..1525618dd 100644 --- a/evmrpc/block.go +++ b/evmrpc/block.go @@ -2,14 +2,12 @@ package evmrpc import ( "context" - "crypto/sha256" "errors" "math/big" "strings" "sync" "time" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -195,27 +193,6 @@ func EncodeTmBlock( newTx := ethapi.NewRPCTransaction(ethtx, blockhash, number.Uint64(), uint64(blockTime.Second()), uint64(receipt.TransactionIndex), baseFeePerGas, chainConfig) transactions = append(transactions, newTx) } - case *wasmtypes.MsgExecuteContract: - th := sha256.Sum256(block.Block.Txs[i]) - receipt, err := k.GetReceipt(ctx, th) - if err != nil { - continue - } - if !fullTx { - transactions = append(transactions, th) - } else { - ti := uint64(receipt.TransactionIndex) - to := k.GetEVMAddressOrDefault(ctx, sdk.MustAccAddressFromBech32(m.Contract)) - transactions = append(transactions, ðapi.RPCTransaction{ - BlockHash: &blockhash, - BlockNumber: (*hexutil.Big)(number), - From: common.HexToAddress(receipt.From), - To: &to, - Input: m.Msg.Bytes(), - Hash: th, - TransactionIndex: (*hexutil.Uint64)(&ti), - }) - } } } } diff --git a/evmrpc/block_test.go b/evmrpc/block_test.go index 37b5090df..256312f9b 100644 --- a/evmrpc/block_test.go +++ b/evmrpc/block_test.go @@ -1,23 +1,16 @@ package evmrpc_test import ( - "crypto/sha256" - "math/big" "testing" "time" types2 "github.com/tendermint/tendermint/proto/tendermint/types" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "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/lib/ethapi" "github.com/sei-protocol/sei-chain/evmrpc" testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" - "github.com/sei-protocol/sei-chain/x/evm/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/rpc/coretypes" @@ -225,63 +218,3 @@ func TestEncodeBankMsg(t *testing.T) { txs := res["transactions"].([]interface{}) require.Equal(t, 0, len(txs)) } - -func TestEncodeWasmExecuteMsg(t *testing.T) { - k := &testkeeper.EVMTestApp.EvmKeeper - ctx := testkeeper.EVMTestApp.GetContextForDeliverTx(nil) - fromSeiAddr, fromEvmAddr := testkeeper.MockAddressPair() - toSeiAddr, _ := testkeeper.MockAddressPair() - b := TxConfig.NewTxBuilder() - b.SetMsgs(&wasmtypes.MsgExecuteContract{ - Sender: fromSeiAddr.String(), - Contract: toSeiAddr.String(), - Msg: []byte{1, 2, 3}, - }) - tx := b.GetTx() - bz, _ := Encoder(tx) - k.MockReceipt(ctx, sha256.Sum256(bz), &types.Receipt{ - TransactionIndex: 1, - From: fromEvmAddr.Hex(), - }) - resBlock := coretypes.ResultBlock{ - BlockID: MockBlockID, - Block: &tmtypes.Block{ - Header: mockBlockHeader(MockHeight), - Data: tmtypes.Data{ - Txs: []tmtypes.Tx{bz}, - }, - LastCommit: &tmtypes.Commit{ - Height: MockHeight - 1, - }, - }, - } - resBlockRes := coretypes.ResultBlockResults{ - TxsResults: []*abci.ExecTxResult{ - { - Data: bz, - }, - }, - ConsensusParamUpdates: &types2.ConsensusParams{ - Block: &types2.BlockParams{ - MaxBytes: 100000000, - MaxGas: 200000000, - }, - }, - } - res, err := evmrpc.EncodeTmBlock(ctx, &resBlock, &resBlockRes, k, Decoder, true) - require.Nil(t, err) - txs := res["transactions"].([]interface{}) - require.Equal(t, 1, len(txs)) - ti := uint64(1) - bh := common.HexToHash(MockBlockID.Hash.String()) - to := common.Address(toSeiAddr) - require.Equal(t, ðapi.RPCTransaction{ - BlockHash: &bh, - BlockNumber: (*hexutil.Big)(big.NewInt(MockHeight)), - From: fromEvmAddr, - To: &to, - Input: []byte{1, 2, 3}, - Hash: common.Hash(sha256.Sum256(bz)), - TransactionIndex: (*hexutil.Uint64)(&ti), - }, txs[0].(*ethapi.RPCTransaction)) -}