Skip to content

Commit 943614b

Browse files
authored
Remove TxHashes from EVM module (#2018)
1 parent e26df24 commit 943614b

File tree

9 files changed

+44
-69
lines changed

9 files changed

+44
-69
lines changed

Diff for: evmrpc/setup_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -909,18 +909,9 @@ func setupLogs() {
909909
})
910910

911911
// block 2
912-
EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight2, []common.Hash{
913-
multiTxBlockTx1.Hash(),
914-
multiTxBlockTx2.Hash(),
915-
multiTxBlockTx3.Hash(),
916-
})
917912
EVMKeeper.SetBlockBloom(MultiTxCtx, []ethtypes.Bloom{bloom1, bloom2, bloom3})
918913

919914
// block 8
920-
EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight8, []common.Hash{
921-
multiTxBlockSynthTx.Hash(),
922-
multiTxBlockTx4.Hash(),
923-
})
924915
bloomTx1 := ethtypes.CreateBloom(ethtypes.Receipts{&ethtypes.Receipt{Logs: []*ethtypes.Log{{
925916
Address: common.HexToAddress("0x1111111111111111111111111111111111111111"),
926917
Topics: []common.Hash{common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111"),

Diff for: x/evm/genesis_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func TestExportImportGenesis(t *testing.T) {
2424
keeper.SetNonce(ctx, evmAddr, 2)
2525
keeper.MockReceipt(ctx, common.BytesToHash([]byte("789")), &types.Receipt{TxType: 2})
2626
keeper.SetBlockBloom(ctx, []ethtypes.Bloom{{1}})
27-
keeper.SetTxHashesOnHeight(ctx, 5, []common.Hash{common.BytesToHash([]byte("123"))})
2827
keeper.SetERC20CW20Pointer(ctx, "cw20addr", codeAddr)
2928
genesis := evm.ExportGenesis(ctx, keeper)
3029
assert.NoError(t, genesis.Validate())
@@ -46,7 +45,6 @@ func TestExportImportGenesis(t *testing.T) {
4645
_, err := keeper.GetReceipt(origctx, common.BytesToHash([]byte("789")))
4746
require.Nil(t, err)
4847
require.Equal(t, keeper.GetBlockBloom(ctx), keeper.GetBlockBloom(origctx))
49-
require.Equal(t, keeper.GetTxHashesOnHeight(ctx, 5), keeper.GetTxHashesOnHeight(origctx, 5))
5048
_, _, exists := keeper.GetERC20CW20Pointer(origctx, "cw20addr")
5149
require.True(t, exists)
5250
}

Diff for: x/evm/keeper/tx.go

-33
This file was deleted.

Diff for: x/evm/keeper/tx_test.go

-21
This file was deleted.

Diff for: x/evm/migrations/migrate_remove_tx_hashes.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package migrations
2+
3+
import (
4+
"github.com/cosmos/cosmos-sdk/store/prefix"
5+
sdk "github.com/cosmos/cosmos-sdk/types"
6+
"github.com/sei-protocol/sei-chain/x/evm/keeper"
7+
"github.com/sei-protocol/sei-chain/x/evm/types"
8+
)
9+
10+
func RemoveTxHashes(ctx sdk.Context, k *keeper.Keeper) error {
11+
store := prefix.NewStore(ctx.KVStore(k.GetStoreKey()), types.TxHashesPrefix)
12+
return store.DeleteAll(nil, nil)
13+
}

Diff for: x/evm/migrations/migrate_remove_tx_hashes_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package migrations_test
2+
3+
import (
4+
"testing"
5+
6+
testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper"
7+
"github.com/sei-protocol/sei-chain/x/evm/migrations"
8+
"github.com/sei-protocol/sei-chain/x/evm/types"
9+
"github.com/stretchr/testify/require"
10+
tmtypes "github.com/tendermint/tendermint/proto/tendermint/types"
11+
)
12+
13+
func TestRemoveTxHashes(t *testing.T) {
14+
k := testkeeper.EVMTestApp.EvmKeeper
15+
ctx := testkeeper.EVMTestApp.NewContext(false, tmtypes.Header{})
16+
store := ctx.KVStore(k.GetStoreKey())
17+
store.Set(types.TxHashesKey(1), []byte{1})
18+
store.Set(types.TxHashesKey(2), []byte{2})
19+
require.Equal(t, []byte{1}, store.Get(types.TxHashesKey(1)))
20+
require.Equal(t, []byte{2}, store.Get(types.TxHashesKey(2)))
21+
require.NoError(t, migrations.RemoveTxHashes(ctx, &k))
22+
require.Nil(t, store.Get(types.TxHashesKey(1)))
23+
require.Nil(t, store.Get(types.TxHashesKey(2)))
24+
}

Diff for: x/evm/module.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
229229
_ = cfg.RegisterMigration(types.ModuleName, 15, func(ctx sdk.Context) error {
230230
return migrations.StoreCWPointerCode(ctx, am.keeper, false, false, true)
231231
})
232+
233+
_ = cfg.RegisterMigration(types.ModuleName, 16, func(ctx sdk.Context) error {
234+
return migrations.RemoveTxHashes(ctx, am.keeper)
235+
})
232236
}
233237

234238
// RegisterInvariants registers the capability module's invariants.
@@ -266,7 +270,7 @@ func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <-
266270
}
267271

268272
// ConsensusVersion implements ConsensusVersion.
269-
func (AppModule) ConsensusVersion() uint64 { return 15 }
273+
func (AppModule) ConsensusVersion() uint64 { return 16 }
270274

271275
// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
272276
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
@@ -350,7 +354,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V
350354
}
351355
}
352356
}
353-
am.keeper.SetTxHashesOnHeight(ctx, ctx.BlockHeight(), utils.Filter(utils.Map(evmTxDeferredInfoList, func(i *types.DeferredInfo) common.Hash { return common.BytesToHash(i.TxHash) }), func(h common.Hash) bool { return h.Cmp(ethtypes.EmptyTxsHash) != 0 }))
354357
am.keeper.SetBlockBloom(ctx, utils.Map(evmTxDeferredInfoList, func(i *types.DeferredInfo) ethtypes.Bloom { return ethtypes.BytesToBloom(i.TxBloom) }))
355358
return []abci.ValidatorUpdate{}
356359
}

Diff for: x/evm/module_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestModuleExportGenesis(t *testing.T) {
6060
func TestConsensusVersion(t *testing.T) {
6161
k, _ := testkeeper.MockEVMKeeper()
6262
module := evm.NewAppModule(nil, k)
63-
assert.Equal(t, uint64(15), module.ConsensusVersion())
63+
assert.Equal(t, uint64(16), module.ConsensusVersion())
6464
}
6565

6666
func TestABCI(t *testing.T) {

Diff for: x/evm/types/keys.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var (
3838
ReceiptKeyPrefix = []byte{0x0b}
3939
WhitelistedCodeHashesForBankSendPrefix = []byte{0x0c}
4040
BlockBloomPrefix = []byte{0x0d}
41-
TxHashesPrefix = []byte{0x0e}
41+
TxHashesPrefix = []byte{0x0e} // deprecated
4242
WhitelistedCodeHashesForDelegateCallPrefix = []byte{0x0f}
4343

4444
// TxHashPrefix = []byte{0x10}

0 commit comments

Comments
 (0)