Skip to content

Commit

Permalink
Revert showing wasm transactions in EVM rpc (#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen authored and blindchaser committed Sep 17, 2024
1 parent f2ff880 commit 685ea93
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 90 deletions.
23 changes: 0 additions & 23 deletions evmrpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, &ethapi.RPCTransaction{
BlockHash: &blockhash,
BlockNumber: (*hexutil.Big)(number),
From: common.HexToAddress(receipt.From),
To: &to,
Input: m.Msg.Bytes(),
Hash: th,
TransactionIndex: (*hexutil.Uint64)(&ti),
})
}
}
}
}
Expand Down
67 changes: 0 additions & 67 deletions evmrpc/block_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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, &ethapi.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))
}

0 comments on commit 685ea93

Please sign in to comment.