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

Revert showing wasm transactions in EVM rpc #1861

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -198,27 +196,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 @@ -221,63 +214,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, ethtypes.Bloom{}, 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))
}
Loading