diff --git a/contracts/test/lib.js b/contracts/test/lib.js index 94a138874..04ca795aa 100644 --- a/contracts/test/lib.js +++ b/contracts/test/lib.js @@ -286,14 +286,14 @@ async function instantiateWasm(codeId, adminAddr, label, args = {}, from=adminKe return getEventAttribute(response, "instantiate", "_contract_address"); } -async function proposeCW20toERC20Upgrade(erc20Address, cw20Address, title="erc20-pointer", version=99, description="erc20 pointer",fees="20000usei", from=adminKeyName) { +async function proposeCW20toERC20Upgrade(erc20Address, cw20Address, title="erc20-pointer", version=99, description="erc20 pointer",fees="200000usei", from=adminKeyName) { const command = `seid tx evm add-cw-erc20-pointer "${title}" "${description}" ${erc20Address} ${version} 200000000usei ${cw20Address} --from ${from} --fees ${fees} -y -o json --broadcast-mode=block` const output = await execute(command); const proposalId = getEventAttribute(JSON.parse(output), "submit_proposal", "proposal_id") return await passProposal(proposalId) } -async function passProposal(proposalId, desposit="200000000usei", fees="20000usei", from=adminKeyName) { +async function passProposal(proposalId, desposit="200000000usei", fees="200000usei", from=adminKeyName) { if(await isDocker()) { await executeOnAllNodes(`seid tx gov vote ${proposalId} yes --from node_admin -b block -y --fees ${fees}`) } else { @@ -330,6 +330,15 @@ async function registerPointerForERC721(erc721Address, fees="20000usei", from=ad return getEventAttribute(response, "pointer_registered", "pointer_address") } +async function registerPointerForERC1155(erc1155Address, fees="200000usei", from=adminKeyName) { + const command = `seid tx evm register-cw-pointer ERC1155 ${erc1155Address} --from ${from} --fees ${fees} --broadcast-mode block -y -o json` + const output = await execute(command); + const response = JSON.parse(output) + if(response.code !== 0) { + throw new Error("contract deployment failed") + } + return getEventAttribute(response, "pointer_registered", "pointer_address") +} async function getSeiAddress(evmAddress) { const command = `seid q evm sei-addr ${evmAddress} -o json` diff --git a/evmrpc/block.go b/evmrpc/block.go index 6ce9290fd..93043f209 100644 --- a/evmrpc/block.go +++ b/evmrpc/block.go @@ -40,7 +40,15 @@ type BlockAPI struct { } func NewBlockAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txConfig client.TxConfig, connectionType ConnectionType, namespace string) *BlockAPI { - return &BlockAPI{tmClient: tmClient, keeper: k, ctxProvider: ctxProvider, txConfig: txConfig, connectionType: connectionType, includeShellReceipts: shouldIncludeSynthetic(namespace)} + return &BlockAPI{ + tmClient: tmClient, + keeper: k, + ctxProvider: ctxProvider, + txConfig: txConfig, + connectionType: connectionType, + namespace: namespace, + includeShellReceipts: shouldIncludeSynthetic(namespace), + } } func (a *BlockAPI) GetBlockTransactionCountByNumber(ctx context.Context, number rpc.BlockNumber) (result *hexutil.Uint, returnErr error) { @@ -150,7 +158,7 @@ func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.Block // Get all tx hashes for the block height := block.Block.Header.Height - txHashes := getEvmTxHashesFromBlock(block, a.txConfig) + txHashes := getTxHashesFromBlock(block, a.txConfig, shouldIncludeSynthetic(a.namespace)) // Get tx receipts for all hashes in parallel wg := sync.WaitGroup{} mtx := sync.Mutex{} diff --git a/evmrpc/block_test.go b/evmrpc/block_test.go index 2082f8b47..398679d58 100644 --- a/evmrpc/block_test.go +++ b/evmrpc/block_test.go @@ -80,16 +80,16 @@ func TestGetBlockReceipts(t *testing.T) { // Query by block height resObj := sendRequestGood(t, "getBlockReceipts", "0x2") result := resObj["result"].([]interface{}) - require.Equal(t, 5, len(result)) + require.Equal(t, 3, len(result)) receipt1 := result[0].(map[string]interface{}) require.Equal(t, "0x2", receipt1["blockNumber"]) - require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt1["transactionHash"]) + require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt1["transactionHash"]) receipt2 := result[1].(map[string]interface{}) require.Equal(t, "0x2", receipt2["blockNumber"]) - require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt2["transactionHash"]) + require.Equal(t, multiTxBlockTx2.Hash().Hex(), receipt2["transactionHash"]) receipt3 := result[2].(map[string]interface{}) require.Equal(t, "0x2", receipt3["blockNumber"]) - require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt3["transactionHash"]) + require.Equal(t, multiTxBlockTx3.Hash().Hex(), receipt3["transactionHash"]) resObjSei := sendSeiRequestGood(t, "getBlockReceipts", "0x2") result = resObjSei["result"].([]interface{}) @@ -98,21 +98,21 @@ func TestGetBlockReceipts(t *testing.T) { // Query by block hash resObj2 := sendRequestGood(t, "getBlockReceipts", "0x0000000000000000000000000000000000000000000000000000000000000002") result = resObj2["result"].([]interface{}) - require.Equal(t, 5, len(result)) + require.Equal(t, 3, len(result)) receipt1 = result[0].(map[string]interface{}) require.Equal(t, "0x2", receipt1["blockNumber"]) - require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt1["transactionHash"]) + require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt1["transactionHash"]) receipt2 = result[1].(map[string]interface{}) require.Equal(t, "0x2", receipt2["blockNumber"]) - require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt2["transactionHash"]) + require.Equal(t, multiTxBlockTx2.Hash().Hex(), receipt2["transactionHash"]) receipt3 = result[2].(map[string]interface{}) require.Equal(t, "0x2", receipt3["blockNumber"]) - require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt3["transactionHash"]) + require.Equal(t, multiTxBlockTx3.Hash().Hex(), receipt3["transactionHash"]) // Query by tag latest => retrieves block 8 resObj3 := sendRequestGood(t, "getBlockReceipts", "latest") result = resObj3["result"].([]interface{}) - require.Equal(t, 2, len(result)) + require.Equal(t, 1, len(result)) receipt1 = result[0].(map[string]interface{}) require.Equal(t, "0x8", receipt1["blockNumber"]) require.Equal(t, tx1.Hash().Hex(), receipt1["transactionHash"]) @@ -192,10 +192,10 @@ func TestEncodeTmBlock_EmptyTransactions(t *testing.T) { block := &coretypes.ResultBlock{ BlockID: MockBlockID, Block: &tmtypes.Block{ - Header: mockBlockHeader(MockHeight), + Header: mockBlockHeader(MockHeight8), Data: tmtypes.Data{}, LastCommit: &tmtypes.Commit{ - Height: MockHeight - 1, + Height: MockHeight8 - 1, }, }, } @@ -228,7 +228,7 @@ func TestEncodeBankMsg(t *testing.T) { resBlock := coretypes.ResultBlock{ BlockID: MockBlockID, Block: &tmtypes.Block{ - Header: mockBlockHeader(MockHeight), + Header: mockBlockHeader(MockHeight8), Data: tmtypes.Data{ Txs: []tmtypes.Tx{func() []byte { bz, _ := Encoder(tx) @@ -236,7 +236,7 @@ func TestEncodeBankMsg(t *testing.T) { }()}, }, LastCommit: &tmtypes.Commit{ - Height: MockHeight - 1, + Height: MockHeight8 - 1, }, }, } @@ -282,12 +282,12 @@ func TestEncodeWasmExecuteMsg(t *testing.T) { resBlock := coretypes.ResultBlock{ BlockID: MockBlockID, Block: &tmtypes.Block{ - Header: mockBlockHeader(MockHeight), + Header: mockBlockHeader(MockHeight8), Data: tmtypes.Data{ Txs: []tmtypes.Tx{bz}, }, LastCommit: &tmtypes.Commit{ - Height: MockHeight - 1, + Height: MockHeight8 - 1, }, }, } @@ -313,7 +313,7 @@ func TestEncodeWasmExecuteMsg(t *testing.T) { to := common.Address(toSeiAddr) require.Equal(t, ðapi.RPCTransaction{ BlockHash: &bh, - BlockNumber: (*hexutil.Big)(big.NewInt(MockHeight)), + BlockNumber: (*hexutil.Big)(big.NewInt(MockHeight8)), From: fromEvmAddr, To: &to, Input: []byte{1, 2, 3}, diff --git a/evmrpc/filter.go b/evmrpc/filter.go index 205be0afc..c972a654b 100644 --- a/evmrpc/filter.go +++ b/evmrpc/filter.go @@ -406,11 +406,13 @@ func (f *LogFetcher) GetLogsForBlock(block *coretypes.ResultBlock, crit filters. func (f *LogFetcher) FindLogsByBloom(block *coretypes.ResultBlock, filters [][]bloomIndexes) (res []*ethtypes.Log) { ctx := f.ctxProvider(LatestCtxHeight) - - for _, hash := range getEvmTxHashesFromBlock(block, f.txConfig) { + for _, hash := range getTxHashesFromBlock(block, f.txConfig, f.includeSyntheticReceipts) { receipt, err := f.k.GetReceipt(ctx, hash) if err != nil { - ctx.Logger().Error(fmt.Sprintf("FindLogsByBloom: unable to find receipt for hash %s", hash.Hex())) + // ignore the error if receipt is not found when includeSyntheticReceipts is true + if !f.includeSyntheticReceipts { + ctx.Logger().Error(fmt.Sprintf("FindLogsByBloom: unable to find receipt for hash %s", hash.Hex())) + } continue } if !f.includeSyntheticReceipts && (receipt.TxType == ShellEVMTxType || receipt.EffectiveGasPrice == 0) { diff --git a/evmrpc/filter_test.go b/evmrpc/filter_test.go index d513f7534..404e54348 100644 --- a/evmrpc/filter_test.go +++ b/evmrpc/filter_test.go @@ -1,7 +1,6 @@ package evmrpc_test import ( - "fmt" "testing" "time" @@ -200,8 +199,8 @@ func TestFilterSeiGetLogs(t *testing.T) { testFilterGetLogs(t, "sei", []GetFilterLogTests{ { name: "filter by single synthetic address", - fromBlock: "0x8", - toBlock: "0x8", + fromBlock: "0x64", + toBlock: "0x64", addrs: []common.Address{common.HexToAddress("0x1111111111111111111111111111111111111116")}, wantErr: false, check: func(t *testing.T, log map[string]interface{}) { @@ -210,21 +209,18 @@ func TestFilterSeiGetLogs(t *testing.T) { wantLen: 1, }, { - name: "filter by single topic with default range, include synethetic logs", - topics: [][]common.Hash{{common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000234")}}, - wantErr: false, + name: "filter by single topic, include synethetic logs", + topics: [][]common.Hash{{common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000234")}}, + wantErr: false, + fromBlock: "0x64", + toBlock: "0x64", check: func(t *testing.T, log map[string]interface{}) { require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000234", log["topics"].([]interface{})[0].(string)) }, wantLen: 1, }, - }) -} - -func TestFilterEthEndpointCanReturnSyntheticLogs(t *testing.T) { - testFilterGetLogs(t, "eth", []GetFilterLogTests{ { - name: "filter by single topic with default range, still include synthetic logs", + name: "filter by single topic with default range, include synethetic logs", topics: [][]common.Hash{{common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000234")}}, wantErr: false, check: func(t *testing.T, log map[string]interface{}) { @@ -255,7 +251,6 @@ func TestFilterEthEndpointReturnsNormalEvmLogEvenIfSyntheticLogIsInSameBlock(t * func testFilterGetLogs(t *testing.T, namespace string, tests []GetFilterLogTests) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - fmt.Println(tt.name) filterCriteria := map[string]interface{}{ "address": tt.addrs, "topics": tt.topics, @@ -300,7 +295,7 @@ func TestFilterGetFilterLogs(t *testing.T) { resObj = sendRequest(t, TestPort, "getFilterLogs", filterId) logs := resObj["result"].([]interface{}) - require.Equal(t, 6, len(logs)) + require.Equal(t, 4, len(logs)) for _, log := range logs { logObj := log.(map[string]interface{}) require.Equal(t, "0x2", logObj["blockNumber"].(string)) diff --git a/evmrpc/setup_test.go b/evmrpc/setup_test.go index 0c8d74e2a..1097d8c98 100644 --- a/evmrpc/setup_test.go +++ b/evmrpc/setup_test.go @@ -47,10 +47,10 @@ const TestPort = 7777 const TestWSPort = 7778 const TestBadPort = 7779 -const MockHeight = 8 -const MultiTxBlockHeight = 2 -const DebugTraceMockHeight = 101 -const SyntheticBlockHeight = 100 +const MockHeight8 = 8 +const MockHeight2 = 2 +const MockHeight101 = 101 +const MockHeight100 = 100 var DebugTraceHashHex = "0x1234567890123456789023456789012345678901234567890123456789000004" var DebugTraceBlockHash = "BE17E0261E539CB7E9A91E123A6D794E0163D656FCF9B8EAC07823F7ED28512B" @@ -129,7 +129,7 @@ func mockBlockHeader(height int64) tmtypes.Header { } func (c *MockClient) mockBlock(height int64) *coretypes.ResultBlock { - if height == MultiTxBlockHeight { + if height == MockHeight2 { return &coretypes.ResultBlock{ BlockID: MockBlockIDMultiTx, Block: &tmtypes.Block{ @@ -168,7 +168,7 @@ func (c *MockClient) mockBlock(height int64) *coretypes.ResultBlock { }, } } - if height == SyntheticBlockHeight { + if height == MockHeight100 { return &coretypes.ResultBlock{ BlockID: MockBlockID, Block: &tmtypes.Block{ @@ -205,11 +205,11 @@ func (c *MockClient) mockBlock(height int64) *coretypes.ResultBlock { }, }, LastCommit: &tmtypes.Commit{ - Height: MockHeight - 1, + Height: MockHeight8 - 1, }, }, } - if height == DebugTraceMockHeight { + if height == MockHeight101 { res.Block.Data.Txs = []tmtypes.Tx{ func() []byte { bz, _ := Encoder(DebugTraceTx) @@ -278,7 +278,7 @@ func (c *MockClient) Genesis(context.Context) (*coretypes.ResultGenesis, error) } func (c *MockClient) Block(_ context.Context, h *int64) (*coretypes.ResultBlock, error) { - height := int64(MockHeight) + height := int64(MockHeight8) if h != nil { height = *h } @@ -287,12 +287,12 @@ func (c *MockClient) Block(_ context.Context, h *int64) (*coretypes.ResultBlock, func (c *MockClient) BlockByHash(_ context.Context, hash bytes.HexBytes) (*coretypes.ResultBlock, error) { if hash.String() == DebugTraceBlockHash { - return c.mockBlock(DebugTraceMockHeight), nil + return c.mockBlock(MockHeight101), nil } if hash.String() == MultiTxBlockHash { - return c.mockBlock(MultiTxBlockHeight), nil + return c.mockBlock(MockHeight2), nil } - return c.mockBlock(MockHeight), nil + return c.mockBlock(MockHeight8), nil } func (c *MockClient) BlockResults(_ context.Context, height *int64) (*coretypes.ResultBlockResults, error) { @@ -351,7 +351,7 @@ func (c *MockClient) Events(_ context.Context, req *coretypes.RequestEvents) (*c panic("invalid cursor") } } else { - cursor = MockHeight + cursor = MockHeight8 } resultBlock := c.mockBlock(int64(cursor)) data := tmtypes.EventDataNewBlock{ @@ -397,7 +397,7 @@ func (c *MockClient) BroadcastTx(context.Context, tmtypes.Tx) (*coretypes.Result } func (c *MockClient) Tx(context.Context, bytes.HexBytes, bool) (*coretypes.ResultTx, error) { - return &coretypes.ResultTx{Hash: bytes.HexBytes(TestCosmosTxHash), Height: MockHeight, TxResult: abci.ExecTxResult{EvmTxInfo: &abci.EvmTxInfo{TxHash: TestEvmTxHash}}}, nil + return &coretypes.ResultTx{Hash: bytes.HexBytes(TestCosmosTxHash), Height: MockHeight8, TxResult: abci.ExecTxResult{EvmTxInfo: &abci.EvmTxInfo{TxHash: TestEvmTxHash}}}, nil } func (c *MockClient) UnconfirmedTxs(ctx context.Context, page, perPage *int) (*coretypes.ResultUnconfirmedTxs, error) { @@ -459,7 +459,7 @@ func init() { } testApp.Commit(context.Background()) ctxProvider := func(height int64) sdk.Context { - if height == MultiTxBlockHeight { + if height == MockHeight2 { return MultiTxCtx } return Ctx @@ -597,12 +597,12 @@ func generateTxData() { From: "0x1234567890123456789012345678901234567890", To: "0x1234567890123456789012345678901234567890", TransactionIndex: 0, - BlockNumber: MockHeight, + BlockNumber: MockHeight8, TxType: 1, ContractAddress: "0x1234567890123456789012345678901234567890", - CumulativeGasUsed: 123, + CumulativeGasUsed: 124, TxHashHex: tx1.Hash().Hex(), - GasUsed: 55, + GasUsed: 56, Status: 0, EffectiveGasPrice: 100000000000, Logs: []*types.Log{{ @@ -700,9 +700,9 @@ func setupLogs() { common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000123"), }, }}}}) - CtxMultiTx := Ctx.WithBlockHeight(MultiTxBlockHeight) + CtxMultiTx := Ctx.WithBlockHeight(MockHeight2) EVMKeeper.MockReceipt(CtxMultiTx, multiTxBlockTx1.Hash(), &types.Receipt{ - BlockNumber: MultiTxBlockHeight, + BlockNumber: MockHeight2, TransactionIndex: 1, // start at 1 bc 0 is the non-evm tx TxHashHex: multiTxBlockTx1.Hash().Hex(), LogsBloom: bloom1[:], @@ -723,7 +723,7 @@ func setupLogs() { }, }}}}) EVMKeeper.MockReceipt(CtxMultiTx, multiTxBlockTx2.Hash(), &types.Receipt{ - BlockNumber: MultiTxBlockHeight, + BlockNumber: MockHeight2, TransactionIndex: 3, TxHashHex: multiTxBlockTx2.Hash().Hex(), LogsBloom: bloom2[:], @@ -741,7 +741,7 @@ func setupLogs() { }, }}}}) EVMKeeper.MockReceipt(CtxMultiTx, multiTxBlockTx3.Hash(), &types.Receipt{ - BlockNumber: MultiTxBlockHeight, + BlockNumber: MockHeight2, TransactionIndex: 4, TxHashHex: multiTxBlockTx3.Hash().Hex(), LogsBloom: bloom3[:], @@ -758,9 +758,9 @@ func setupLogs() { common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000456"), }, }}}}) - CtxMock := Ctx.WithBlockHeight(MockHeight) + CtxMock := Ctx.WithBlockHeight(MockHeight8) EVMKeeper.MockReceipt(CtxMock, multiTxBlockTx4.Hash(), &types.Receipt{ - BlockNumber: MockHeight, + BlockNumber: MockHeight8, TransactionIndex: 1, TxHashHex: multiTxBlockTx4.Hash().Hex(), LogsBloom: bloom4[:], @@ -780,7 +780,7 @@ func setupLogs() { }}}}) EVMKeeper.MockReceipt(CtxMock, multiTxBlockSynthTx.Hash(), &types.Receipt{ TxType: evmrpc.ShellEVMTxType, - BlockNumber: MockHeight, + BlockNumber: MockHeight100, TransactionIndex: 0, TxHashHex: multiTxBlockSynthTx.Hash().Hex(), LogsBloom: bloomSynth[:], @@ -791,16 +791,16 @@ func setupLogs() { }}, EffectiveGasPrice: 0, }) - CtxDebugTrace := Ctx.WithBlockHeight(DebugTraceMockHeight) + CtxDebugTrace := Ctx.WithBlockHeight(MockHeight101) EVMKeeper.MockReceipt(CtxDebugTrace, common.HexToHash(DebugTraceHashHex), &types.Receipt{ - BlockNumber: DebugTraceMockHeight, + BlockNumber: MockHeight101, TransactionIndex: 0, TxHashHex: DebugTraceHashHex, }) txNonEvmBz, _ := Encoder(TxNonEvmWithSyntheticLog) txNonEvmHash := sha256.Sum256(txNonEvmBz) EVMKeeper.MockReceipt(CtxMultiTx, txNonEvmHash, &types.Receipt{ - BlockNumber: MultiTxBlockHeight, + BlockNumber: MockHeight2, TransactionIndex: 1, TxHashHex: common.Hash(txNonEvmHash).Hex(), LogsBloom: bloomSynth[:], @@ -812,16 +812,16 @@ func setupLogs() { EffectiveGasPrice: 100, }) - // block 8 - EVMKeeper.SetTxHashesOnHeight(Ctx, MultiTxBlockHeight, []common.Hash{ + // block 2 + EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight2, []common.Hash{ multiTxBlockTx1.Hash(), multiTxBlockTx2.Hash(), multiTxBlockTx3.Hash(), }) EVMKeeper.SetBlockBloom(MultiTxCtx, []ethtypes.Bloom{bloom1, bloom2, bloom3}) - // block 2 - EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight, []common.Hash{ + // block 8 + EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight8, []common.Hash{ multiTxBlockSynthTx.Hash(), multiTxBlockTx4.Hash(), }) diff --git a/evmrpc/state_test.go b/evmrpc/state_test.go index abcd6c9d8..f68a728bc 100644 --- a/evmrpc/state_test.go +++ b/evmrpc/state_test.go @@ -210,7 +210,7 @@ func TestGetProof(t *testing.T) { _, evmAddr := testkeeper.MockAddressPair() key, val := []byte("test"), []byte("abc") testApp.EvmKeeper.SetState(testApp.GetContextForDeliverTx([]byte{}), evmAddr, common.BytesToHash(key), common.BytesToHash(val)) - for i := 0; i < MockHeight; i++ { + for i := 0; i < MockHeight8; i++ { testApp.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{Height: int64(i + 1)}) testApp.SetDeliverStateToCommit() _, err := testApp.Commit(context.Background()) diff --git a/evmrpc/tx_test.go b/evmrpc/tx_test.go index e2d1896bf..c5352d0fb 100644 --- a/evmrpc/tx_test.go +++ b/evmrpc/tx_test.go @@ -43,10 +43,10 @@ func testGetTxReceipt(t *testing.T, namespace string) { resObj = resObj["result"].(map[string]interface{}) require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000001", resObj["blockHash"].(string)) require.Equal(t, "0x8", resObj["blockNumber"].(string)) - require.Equal(t, "0x7b", resObj["cumulativeGasUsed"].(string)) + require.Equal(t, "0x7c", resObj["cumulativeGasUsed"].(string)) require.Equal(t, "0x174876e800", resObj["effectiveGasPrice"].(string)) require.Equal(t, "0x1234567890123456789012345678901234567890", resObj["from"].(string)) - require.Equal(t, "0x37", resObj["gasUsed"].(string)) + require.Equal(t, "0x38", resObj["gasUsed"].(string)) logs := resObj["logs"].([]interface{}) require.Equal(t, 1, len(logs)) log := logs[0].(map[string]interface{}) diff --git a/evmrpc/utils.go b/evmrpc/utils.go index 0d494c949..953166e11 100644 --- a/evmrpc/utils.go +++ b/evmrpc/utils.go @@ -207,7 +207,7 @@ func shouldIncludeSynthetic(namespace string) bool { return namespace == "sei" } -func getEvmTxHashesFromBlock(block *coretypes.ResultBlock, txConfig client.TxConfig) []common.Hash { +func getTxHashesFromBlock(block *coretypes.ResultBlock, txConfig client.TxConfig, shouldIncludeSynthetic bool) []common.Hash { txHashes := []common.Hash{} for i, tx := range block.Block.Data.Txs { sdkTx, err := txConfig.TxDecoder()(tx) @@ -215,18 +215,18 @@ func getEvmTxHashesFromBlock(block *coretypes.ResultBlock, txConfig client.TxCon fmt.Printf("error decoding tx %d in block %d, skipping\n", i, block.Block.Height) continue } - if len(sdkTx.GetMsgs()) == 0 { - txHashes = append(txHashes, sha256.Sum256(tx)) - continue - } - if evmTx, ok := sdkTx.GetMsgs()[0].(*types.MsgEVMTransaction); ok { - if evmTx.IsAssociateTx() { - continue + if len(sdkTx.GetMsgs()) > 0 { + if evmTx, ok := sdkTx.GetMsgs()[0].(*types.MsgEVMTransaction); ok { + if evmTx.IsAssociateTx() { + continue + } + ethtx, _ := evmTx.AsTransaction() + txHashes = append(txHashes, ethtx.Hash()) } - ethtx, _ := evmTx.AsTransaction() - txHashes = append(txHashes, ethtx.Hash()) } - txHashes = append(txHashes, sha256.Sum256(tx)) + if shouldIncludeSynthetic { + txHashes = append(txHashes, sha256.Sum256(tx)) + } } return txHashes }