From 38418afec33d898588133cf5697090d7e2a87b37 Mon Sep 17 00:00:00 2001 From: Philip Su Date: Tue, 5 Nov 2024 03:36:55 +0100 Subject: [PATCH 1/2] v6.0.0 release (#1914) * v6.0.0 release * Disable Pruning during SC migration + Bump Sei-cosmos (#1917) * Disable Pruning during SC migration * Bump sei-cosmos * v6.0.0 release * Disable Pruning during SC migration + Bump Sei-cosmos (#1917) * Disable Pruning during SC migration * Bump sei-cosmos * Bump cosmos --------- Co-authored-by: Kartik Bhat --- CHANGELOG.md | 21 +++++++++++++++++++++ app/upgrades.go | 1 + go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d93eae4d7..feaf9502c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,27 @@ Ref: https://keepachangelog.com/en/1.0.0/ --> # Changelog +## v6.0.0 +sei-chain +* [#1905](https://github.com/sei-protocol/sei-chain/pull/1905) Use limited wasm gas meter +* [#1889](https://github.com/sei-protocol/sei-chain/pull/1889) Fix amino registry for custom modules +* [#1888](https://github.com/sei-protocol/sei-chain/pull/1888) Set EIP-1559 default values +* [#1884](https://github.com/sei-protocol/sei-chain/pull/1884) Update gas tip cap param range +* [#1878](https://github.com/sei-protocol/sei-chain/pull/1878) Add endpoint to estimate gas after simulating calls + +sei-cosmos +* [#547](https://github.com/sei-protocol/sei-cosmos/pull/547) Do not early return for validated tasks in synchronous mode +* [#544](https://github.com/sei-protocol/sei-cosmos/pull/544) Only apply DeliverTx hooks if there is no error +* [#538](https://github.com/sei-protocol/sei-cosmos/pull/538) Token allowlist feature + +sei-tendermint +* [#248](https://github.com/sei-protocol/sei-tendermint/pull/248) Improve Peer Score algorithm +* [#245](https://github.com/sei-protocol/sei-tendermint/pull/245) Exclude unconditional peers when connection limit checking +* [#244](https://github.com/sei-protocol/sei-tendermint/pull/244) Add new config to speed up block sync + +sei-db +* [#75](https://github.com/sei-protocol/sei-db/pull/75) Online archive node migration + ## v5.9.0 sei-chain * [#1867](https://github.com/sei-protocol/sei-chain/pull/1867) Add synthetic events in separate sei endpoints diff --git a/app/upgrades.go b/app/upgrades.go index 4ec052825..1c1715f8c 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -111,6 +111,7 @@ var upgradesList = []string{ "v5.7.5", "v5.8.0", "v5.9.0", + "v6.0.0", } // if there is an override list, use that instead, for integration tests diff --git a/go.mod b/go.mod index 40a24f4b0..42a604753 100644 --- a/go.mod +++ b/go.mod @@ -346,7 +346,7 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.43 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.44 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-23 diff --git a/go.sum b/go.sum index d75f86825..05415a6ba 100644 --- a/go.sum +++ b/go.sum @@ -1347,8 +1347,8 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-23 h1:rkgeOHC56QTco4mIyGd6cZHtlo github.com/sei-protocol/go-ethereum v1.13.5-sei-23/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= -github.com/sei-protocol/sei-cosmos v0.3.43 h1:H3F6wHze6Td0bdrOgV6uGzbMV9H699AA5w2sVgscKEA= -github.com/sei-protocol/sei-cosmos v0.3.43/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= +github.com/sei-protocol/sei-cosmos v0.3.44 h1:7wLuJguQBhQ1ljU92lEDrZDLcNt+JbUcX7r1Y7V1qws= +github.com/sei-protocol/sei-cosmos v0.3.44/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= github.com/sei-protocol/sei-db v0.0.45 h1:95ygzGFMyvaGwEUmzlKi8MxwXfbluoNzbaIjy9zOG6o= github.com/sei-protocol/sei-db v0.0.45/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= From ddcb1e6eff4df4a81008666d4c50e400f46309a7 Mon Sep 17 00:00:00 2001 From: codchen Date: Tue, 5 Nov 2024 13:58:49 +0800 Subject: [PATCH 2/2] Use tendermint store to get Tx hashes instead of storing explicitly (#1913) * Use tendermint store to get Tx hashes instead of storing explicitly * refactor * fix tests --- evmrpc/block.go | 6 +----- evmrpc/block_test.go | 34 ++++++++++------------------------ evmrpc/filter.go | 15 +++++++++++---- evmrpc/filter_test.go | 6 +++--- evmrpc/server.go | 6 +++--- evmrpc/setup_test.go | 36 ++++++++++++++++++++++++++++++++---- evmrpc/utils.go | 27 +++++++++++++++++++++++++++ x/evm/keeper/tx.go | 2 ++ 8 files changed, 89 insertions(+), 43 deletions(-) diff --git a/evmrpc/block.go b/evmrpc/block.go index 6a51d6414..6ce9290fd 100644 --- a/evmrpc/block.go +++ b/evmrpc/block.go @@ -148,13 +148,9 @@ func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.Block return nil, err } - if block == nil { - return nil, errors.New("could not retrieve block requested") - } - // Get all tx hashes for the block height := block.Block.Header.Height - txHashes := a.keeper.GetTxHashesOnHeight(a.ctxProvider(height), height) + txHashes := getEvmTxHashesFromBlock(block, a.txConfig) // 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 4c394ead3..5a9678126 100644 --- a/evmrpc/block_test.go +++ b/evmrpc/block_test.go @@ -80,36 +80,30 @@ func TestGetBlockReceipts(t *testing.T) { // Query by block height resObj := sendRequestGood(t, "getBlockReceipts", "0x2") result := resObj["result"].([]interface{}) - require.Equal(t, 3, len(result)) + require.Equal(t, 6, len(result)) receipt1 := result[0].(map[string]interface{}) require.Equal(t, "0x2", receipt1["blockNumber"]) - require.Equal(t, "0x0", receipt1["transactionIndex"]) - require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt1["transactionHash"]) + require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt1["transactionHash"]) receipt2 := result[1].(map[string]interface{}) require.Equal(t, "0x2", receipt2["blockNumber"]) - require.Equal(t, "0x1", receipt2["transactionIndex"]) - require.Equal(t, multiTxBlockTx2.Hash().Hex(), receipt2["transactionHash"]) + require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt2["transactionHash"]) receipt3 := result[2].(map[string]interface{}) require.Equal(t, "0x2", receipt3["blockNumber"]) - require.Equal(t, "0x2", receipt3["transactionIndex"]) - require.Equal(t, multiTxBlockTx3.Hash().Hex(), receipt3["transactionHash"]) + require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt3["transactionHash"]) // Query by block hash resObj2 := sendRequestGood(t, "getBlockReceipts", "0x0000000000000000000000000000000000000000000000000000000000000002") result = resObj2["result"].([]interface{}) - require.Equal(t, 3, len(result)) + require.Equal(t, 6, len(result)) receipt1 = result[0].(map[string]interface{}) require.Equal(t, "0x2", receipt1["blockNumber"]) - require.Equal(t, "0x0", receipt1["transactionIndex"]) - require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt1["transactionHash"]) + require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt1["transactionHash"]) receipt2 = result[1].(map[string]interface{}) require.Equal(t, "0x2", receipt2["blockNumber"]) - require.Equal(t, "0x1", receipt2["transactionIndex"]) - require.Equal(t, multiTxBlockTx2.Hash().Hex(), receipt2["transactionHash"]) + require.Equal(t, multiTxBlockTx1.Hash().Hex(), receipt2["transactionHash"]) receipt3 = result[2].(map[string]interface{}) require.Equal(t, "0x2", receipt3["blockNumber"]) - require.Equal(t, "0x2", receipt3["transactionIndex"]) - require.Equal(t, multiTxBlockTx3.Hash().Hex(), receipt3["transactionHash"]) + require.Equal(t, "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", receipt3["transactionHash"]) // Query by tag latest => retrieves block 8 resObj3 := sendRequestGood(t, "getBlockReceipts", "latest") @@ -117,15 +111,7 @@ func TestGetBlockReceipts(t *testing.T) { require.Equal(t, 2, len(result)) receipt1 = result[0].(map[string]interface{}) require.Equal(t, "0x8", receipt1["blockNumber"]) - require.Equal(t, "0x0", receipt1["transactionIndex"]) - require.Equal(t, multiTxBlockTx4.Hash().Hex(), receipt1["transactionHash"]) - receiptWithSyntheticLog := result[1].(map[string]interface{}) - require.Equal(t, "0x8", receiptWithSyntheticLog["blockNumber"]) - logs := receiptWithSyntheticLog["logs"].([]interface{}) - firstLog := logs[0].(map[string]interface{}) - topics := firstLog["topics"].([]interface{}) - syntheticLogFirstTopic := "0x0000000000000000000000000000000000000000000000000000000000000234" - require.Equal(t, syntheticLogFirstTopic, topics[0].(string)) + require.Equal(t, tx1.Hash().Hex(), receipt1["transactionHash"]) } func verifyGenesisBlockResult(t *testing.T, resObj map[string]interface{}) { @@ -160,7 +146,7 @@ func verifyBlockResult(t *testing.T, resObj map[string]interface{}) { require.Equal(t, "0x5", resObj["gasUsed"]) require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000001", resObj["hash"]) // see setup_tests.go, which have one transaction for block 0x8 (latest) - require.Equal(t, "0x00002000040000000000000000000080000000200000000000000000000000080000000000000000000000000000000000000000000000000800000000000000001000000000000000000000000000000000000000000000000000000000000100000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000200000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000010200000000000000", resObj["logsBloom"]) + require.Equal(t, "0x00002000040000000000000000000080000000200000000000002000000000080000000000000000000000000000000000000000000000000800000000000000001000000000000000000000000000000000020000000000000000000000000100000000000000002000000000200000000000000000000000000000000000100000000000000000000000000400000000000000200000000000000000000000000000000000000100000000000000020000200000000000000000002000000000000000000000000000000000000000000000000000000000000000000200000000010000000002000000000000000000000000000000010200000000000000", resObj["logsBloom"]) require.Equal(t, "0x0000000000000000000000000000000000000005", resObj["miner"]) require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000000", resObj["mixHash"]) require.Equal(t, "0x0000000000000000", resObj["nonce"]) diff --git a/evmrpc/filter.go b/evmrpc/filter.go index 167118ede..bf5cdab9a 100644 --- a/evmrpc/filter.go +++ b/evmrpc/filter.go @@ -8,6 +8,7 @@ import ( "sync" "time" + "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -63,8 +64,8 @@ type EventItemDataWrapper struct { Value json.RawMessage `json:"value"` } -func NewFilterAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, filterConfig *FilterConfig, connectionType ConnectionType, namespace string) *FilterAPI { - logFetcher := &LogFetcher{tmClient: tmClient, k: k, ctxProvider: ctxProvider, filterConfig: filterConfig, includeSyntheticReceipts: shouldIncludeSynthetic(namespace)} +func NewFilterAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txConfig client.TxConfig, filterConfig *FilterConfig, connectionType ConnectionType, namespace string) *FilterAPI { + logFetcher := &LogFetcher{tmClient: tmClient, k: k, ctxProvider: ctxProvider, txConfig: txConfig, filterConfig: filterConfig, includeSyntheticReceipts: shouldIncludeSynthetic(namespace)} filters := make(map[ethrpc.ID]filter) api := &FilterAPI{ namespace: namespace, @@ -276,6 +277,7 @@ func (a *FilterAPI) UninstallFilter( type LogFetcher struct { tmClient rpcclient.Client k *keeper.Keeper + txConfig client.TxConfig ctxProvider func(int64) sdk.Context filterConfig *FilterConfig includeSyntheticReceipts bool @@ -358,8 +360,13 @@ func (f *LogFetcher) FindBlockesByBloom(begin, end int64, filters [][]bloomIndex func (f *LogFetcher) FindLogsByBloom(height int64, filters [][]bloomIndexes) (res []*ethtypes.Log) { ctx := f.ctxProvider(LatestCtxHeight) - txHashes := f.k.GetTxHashesOnHeight(ctx, height) - for _, hash := range txHashes { + block, err := blockByNumberWithRetry(context.Background(), f.tmClient, &height, 1) + if err != nil { + fmt.Printf("error getting block when querying logs: %s\n", err) + return + } + + for _, hash := range getEvmTxHashesFromBlock(block, f.txConfig) { 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())) diff --git a/evmrpc/filter_test.go b/evmrpc/filter_test.go index fa0a4f145..8fa73c77b 100644 --- a/evmrpc/filter_test.go +++ b/evmrpc/filter_test.go @@ -131,10 +131,10 @@ func getCommonFilterLogTests() []GetFilterLogTests { }, { name: "filter by single topic with default range", - topics: [][]common.Hash{{common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000123")}}, + topics: [][]common.Hash{{common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111")}}, wantErr: false, check: func(t *testing.T, log map[string]interface{}) { - require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000123", log["topics"].([]interface{})[0].(string)) + require.Equal(t, "0x1111111111111111111111111111111111111111111111111111111111111111", log["topics"].([]interface{})[0].(string)) }, wantLen: 1, }, @@ -283,7 +283,7 @@ func TestFilterGetFilterLogs(t *testing.T) { resObj = sendRequest(t, TestPort, "getFilterLogs", filterId) logs := resObj["result"].([]interface{}) - require.Equal(t, 4, len(logs)) + require.Equal(t, 7, len(logs)) for _, log := range logs { logObj := log.(map[string]interface{}) require.Equal(t, "0x2", logObj["blockNumber"].(string)) diff --git a/evmrpc/server.go b/evmrpc/server.go index a76045e29..9691d5b07 100644 --- a/evmrpc/server.go +++ b/evmrpc/server.go @@ -87,11 +87,11 @@ func NewEVMHTTPServer( }, { Namespace: "eth", - Service: NewFilterAPI(tmClient, k, ctxProvider, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeHTTP, "eth"), + Service: NewFilterAPI(tmClient, k, ctxProvider, txConfig, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeHTTP, "eth"), }, { Namespace: "sei", - Service: NewFilterAPI(tmClient, k, ctxProvider, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeHTTP, "sei"), + Service: NewFilterAPI(tmClient, k, ctxProvider, txConfig, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeHTTP, "sei"), }, { Namespace: "sei", @@ -184,7 +184,7 @@ func NewEVMWebSocketServer( }, { Namespace: "eth", - Service: NewSubscriptionAPI(tmClient, &LogFetcher{tmClient: tmClient, k: k, ctxProvider: ctxProvider}, &SubscriptionConfig{subscriptionCapacity: 100, newHeadLimit: config.MaxSubscriptionsNewHead}, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeWS), + Service: NewSubscriptionAPI(tmClient, &LogFetcher{tmClient: tmClient, k: k, ctxProvider: ctxProvider, txConfig: txConfig}, &SubscriptionConfig{subscriptionCapacity: 100, newHeadLimit: config.MaxSubscriptionsNewHead}, &FilterConfig{timeout: config.FilterTimeout, maxLog: config.MaxLogNoBlock, maxBlock: config.MaxBlocksForLog}, ConnectionTypeWS), }, { Namespace: "web3", diff --git a/evmrpc/setup_test.go b/evmrpc/setup_test.go index d252f3167..635b2f91d 100644 --- a/evmrpc/setup_test.go +++ b/evmrpc/setup_test.go @@ -2,6 +2,7 @@ package evmrpc_test import ( "context" + "crypto/sha256" "encoding/hex" "encoding/json" "errors" @@ -76,6 +77,7 @@ var multiTxBlockSynthTx *ethtypes.Transaction var DebugTraceTx sdk.Tx var TxNonEvm sdk.Tx +var TxNonEvmWithSyntheticLog sdk.Tx var UnconfirmedTx sdk.Tx var SConfig = evmrpc.SimulateConfig{GasCap: 10000000} @@ -176,7 +178,7 @@ func (c *MockClient) mockBlock(height int64) *coretypes.ResultBlock { return bz }(), func() []byte { - bz, _ := Encoder(TxNonEvm) + bz, _ := Encoder(TxNonEvmWithSyntheticLog) return bz }(), }, @@ -564,6 +566,12 @@ func generateTxData() { MultiTxBlockSynthTx = synthTxBuilder.GetTx() DebugTraceTx = debugTraceTxBuilder.GetTx() TxNonEvm = app.TestTx{} + TxNonEvmWithSyntheticLog = app.TestTx{} + bloomTx1 := ethtypes.CreateBloom(ethtypes.Receipts{ðtypes.Receipt{Logs: []*ethtypes.Log{{ + Address: common.HexToAddress("0x1111111111111111111111111111111111111111"), + Topics: []common.Hash{common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111"), + common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111112")}, + }}}}) if err := EVMKeeper.MockReceipt(Ctx, tx1.Hash(), &types.Receipt{ From: "0x1234567890123456789012345678901234567890", To: "0x1234567890123456789012345678901234567890", @@ -580,6 +588,7 @@ func generateTxData() { Address: "0x1111111111111111111111111111111111111111", Topics: []string{"0x1111111111111111111111111111111111111111111111111111111111111111", "0x1111111111111111111111111111111111111111111111111111111111111112"}, }}, + LogsBloom: bloomTx1[:], }); err != nil { panic(err) } @@ -747,8 +756,8 @@ func setupLogs() { }, }}}}) EVMKeeper.MockReceipt(Ctx, multiTxBlockSynthTx.Hash(), &types.Receipt{ - BlockNumber: MockHeight, - TransactionIndex: 0, + BlockNumber: MultiTxBlockHeight, + TransactionIndex: 5, TxHashHex: multiTxBlockSynthTx.Hash().Hex(), LogsBloom: bloomSynth[:], Logs: []*types.Log{{ @@ -763,6 +772,20 @@ func setupLogs() { TransactionIndex: 0, TxHashHex: DebugTraceHashHex, }) + txNonEvmBz, _ := Encoder(TxNonEvmWithSyntheticLog) + txNonEvmHash := sha256.Sum256(txNonEvmBz) + EVMKeeper.MockReceipt(Ctx, txNonEvmHash, &types.Receipt{ + BlockNumber: MultiTxBlockHeight, + TransactionIndex: 1, + TxHashHex: common.Hash(txNonEvmHash).Hex(), + LogsBloom: bloomSynth[:], + Logs: []*types.Log{{ + Address: "0x1111111111111111111111111111111111111116", + Topics: []string{"0x0000000000000000000000000000000000000000000000000000000000000234", "0x0000000000000000000000000000000000000000000000000000000000000789"}, + Synthetic: true, + }}, + EffectiveGasPrice: 100, + }) EVMKeeper.SetTxHashesOnHeight(Ctx, MultiTxBlockHeight, []common.Hash{ multiTxBlockTx1.Hash(), multiTxBlockTx2.Hash(), @@ -772,8 +795,13 @@ func setupLogs() { multiTxBlockTx4.Hash(), multiTxBlockSynthTx.Hash(), }) + bloomTx1 := ethtypes.CreateBloom(ethtypes.Receipts{ðtypes.Receipt{Logs: []*ethtypes.Log{{ + Address: common.HexToAddress("0x1111111111111111111111111111111111111111"), + Topics: []common.Hash{common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111"), + common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111112")}, + }}}}) EVMKeeper.SetBlockBloom(MultiTxCtx, []ethtypes.Bloom{bloom1, bloom2, bloom3}) - EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom4, bloomSynth}) + EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom4, bloomSynth, bloomTx1}) } //nolint:deadcode diff --git a/evmrpc/utils.go b/evmrpc/utils.go index 6fc9eb30d..0d494c949 100644 --- a/evmrpc/utils.go +++ b/evmrpc/utils.go @@ -3,6 +3,7 @@ package evmrpc import ( "context" "crypto/ecdsa" + "crypto/sha256" "encoding/hex" "fmt" "math/big" @@ -15,10 +16,12 @@ import ( "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/sei-protocol/sei-chain/utils/metrics" "github.com/sei-protocol/sei-chain/x/evm/keeper" + "github.com/sei-protocol/sei-chain/x/evm/types" "github.com/tendermint/tendermint/libs/bytes" rpcclient "github.com/tendermint/tendermint/rpc/client" "github.com/tendermint/tendermint/rpc/coretypes" @@ -203,3 +206,27 @@ func shouldIncludeSynthetic(namespace string) bool { } return namespace == "sei" } + +func getEvmTxHashesFromBlock(block *coretypes.ResultBlock, txConfig client.TxConfig) []common.Hash { + txHashes := []common.Hash{} + for i, tx := range block.Block.Data.Txs { + sdkTx, err := txConfig.TxDecoder()(tx) + if err != nil { + 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 + } + ethtx, _ := evmTx.AsTransaction() + txHashes = append(txHashes, ethtx.Hash()) + } + txHashes = append(txHashes, sha256.Sum256(tx)) + } + return txHashes +} diff --git a/x/evm/keeper/tx.go b/x/evm/keeper/tx.go index 1c086d565..2a5c90093 100644 --- a/x/evm/keeper/tx.go +++ b/x/evm/keeper/tx.go @@ -6,6 +6,7 @@ import ( "github.com/sei-protocol/sei-chain/x/evm/types" ) +// deprecated func (k *Keeper) GetTxHashesOnHeight(ctx sdk.Context, height int64) (res []common.Hash) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.TxHashesKey(height)) @@ -18,6 +19,7 @@ func (k *Keeper) GetTxHashesOnHeight(ctx sdk.Context, height int64) (res []commo return } +// deprecated func (k *Keeper) SetTxHashesOnHeight(ctx sdk.Context, height int64, hashes []common.Hash) { if len(hashes) == 0 { return