From 50705871d2915ee457e72424dbbf18cec2f5ced5 Mon Sep 17 00:00:00 2001 From: codchen Date: Mon, 9 Sep 2024 14:57:22 +0800 Subject: [PATCH 1/8] Avoid n^2 storage for block bloom (#1849) --- evmrpc/block.go | 9 +++-- evmrpc/block_test.go | 12 ++---- evmrpc/filter.go | 8 +++- evmrpc/filter_test.go | 2 +- evmrpc/setup_test.go | 18 ++++++--- x/evm/genesis.go | 4 ++ x/evm/genesis_test.go | 4 +- x/evm/keeper/log.go | 42 ++++++++++++++++---- x/evm/keeper/log_test.go | 16 ++++++-- x/evm/migrations/migrate_block_bloom.go | 25 ++++++++++++ x/evm/migrations/migrate_block_bloom_test.go | 22 ++++++++++ x/evm/module.go | 8 +++- x/evm/module_test.go | 2 +- x/evm/types/keys.go | 2 + 14 files changed, 139 insertions(+), 35 deletions(-) create mode 100644 x/evm/migrations/migrate_block_bloom.go create mode 100644 x/evm/migrations/migrate_block_bloom_test.go diff --git a/evmrpc/block.go b/evmrpc/block.go index 4753f00e5..cefd19011 100644 --- a/evmrpc/block.go +++ b/evmrpc/block.go @@ -71,7 +71,8 @@ func (a *BlockAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fu if err != nil { return nil, err } - return EncodeTmBlock(a.ctxProvider(LatestCtxHeight), block, blockRes, a.keeper, a.txConfig.TxDecoder(), fullTx) + blockBloom := a.keeper.GetBlockBloom(a.ctxProvider(block.Block.Height)) + return EncodeTmBlock(a.ctxProvider(LatestCtxHeight), block, blockRes, blockBloom, a.keeper, a.txConfig.TxDecoder(), fullTx) } func (a *BlockAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (result map[string]interface{}, returnErr error) { @@ -89,7 +90,8 @@ func (a *BlockAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, if err != nil { return nil, err } - return EncodeTmBlock(a.ctxProvider(LatestCtxHeight), block, blockRes, a.keeper, a.txConfig.TxDecoder(), fullTx) + blockBloom := a.keeper.GetBlockBloom(a.ctxProvider(block.Block.Height)) + return EncodeTmBlock(a.ctxProvider(LatestCtxHeight), block, blockRes, blockBloom, a.keeper, a.txConfig.TxDecoder(), fullTx) } func (a *BlockAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (result []map[string]interface{}, returnErr error) { @@ -154,6 +156,7 @@ func EncodeTmBlock( ctx sdk.Context, block *coretypes.ResultBlock, blockRes *coretypes.ResultBlockResults, + blockBloom ethtypes.Bloom, k *keeper.Keeper, txDecoder sdk.TxDecoder, fullTx bool, @@ -231,7 +234,7 @@ func EncodeTmBlock( "nonce": ethtypes.BlockNonce{}, // inapplicable to Sei "mixHash": common.Hash{}, // inapplicable to Sei "sha3Uncles": ethtypes.EmptyUncleHash, // inapplicable to Sei - "logsBloom": k.GetBlockBloom(ctx, block.Block.Height), + "logsBloom": blockBloom, "stateRoot": appHash, "miner": miner, "difficulty": (*hexutil.Big)(big.NewInt(0)), // inapplicable to Sei diff --git a/evmrpc/block_test.go b/evmrpc/block_test.go index 37b5090df..58d796ec8 100644 --- a/evmrpc/block_test.go +++ b/evmrpc/block_test.go @@ -110,11 +110,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) - if resObj["number"] == "0x8" { - require.Equal(t, "0x00002000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000200000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000", resObj["logsBloom"]) - } else { - require.Equal(t, "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", resObj["logsBloom"]) - } + require.Equal(t, "0x00002000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000200000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000", resObj["logsBloom"]) require.Equal(t, "0x0000000000000000000000000000000000000005", resObj["miner"]) require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000000", resObj["mixHash"]) require.Equal(t, "0x0000000000000000", resObj["nonce"]) @@ -174,7 +170,7 @@ func TestEncodeTmBlock_EmptyTransactions(t *testing.T) { } // Call EncodeTmBlock with empty transactions - result, err := evmrpc.EncodeTmBlock(ctx, block, blockRes, k, Decoder, true) + result, err := evmrpc.EncodeTmBlock(ctx, block, blockRes, ethtypes.Bloom{}, k, Decoder, true) require.Nil(t, err) // Assert txHash is equal to ethtypes.EmptyTxsHash @@ -220,7 +216,7 @@ func TestEncodeBankMsg(t *testing.T) { }, }, } - res, err := evmrpc.EncodeTmBlock(ctx, &resBlock, &resBlockRes, k, Decoder, true) + res, err := evmrpc.EncodeTmBlock(ctx, &resBlock, &resBlockRes, ethtypes.Bloom{}, k, Decoder, true) require.Nil(t, err) txs := res["transactions"].([]interface{}) require.Equal(t, 0, len(txs)) @@ -268,7 +264,7 @@ func TestEncodeWasmExecuteMsg(t *testing.T) { }, }, } - res, err := evmrpc.EncodeTmBlock(ctx, &resBlock, &resBlockRes, k, Decoder, true) + 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)) diff --git a/evmrpc/filter.go b/evmrpc/filter.go index a8abee155..04f5f561c 100644 --- a/evmrpc/filter.go +++ b/evmrpc/filter.go @@ -339,9 +339,13 @@ func (f *LogFetcher) GetLogsForBlock(ctx context.Context, block *coretypes.Resul func (f *LogFetcher) FindBlockesByBloom(begin, end int64, filters [][]bloomIndexes) (res []int64) { //TODO: parallelize - ctx := f.ctxProvider(LatestCtxHeight) for height := begin; height <= end; height++ { - blockBloom := f.k.GetBlockBloom(ctx, height) + if height == 0 { + // no block bloom on genesis height + continue + } + ctx := f.ctxProvider(height) + blockBloom := f.k.GetBlockBloom(ctx) if MatchFilters(blockBloom, filters) { res = append(res, height) } diff --git a/evmrpc/filter_test.go b/evmrpc/filter_test.go index 77e211b74..94581979d 100644 --- a/evmrpc/filter_test.go +++ b/evmrpc/filter_test.go @@ -266,7 +266,7 @@ func TestFilterGetFilterChanges(t *testing.T) { EVMKeeper.SetTxHashesOnHeight(Ctx, 9, []common.Hash{ common.HexToHash("0x123456789012345678902345678901234567890123456789012345678900005"), }) - EVMKeeper.SetBlockBloom(Ctx, 9, []ethtypes.Bloom{bloom}) + EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom}) Ctx = Ctx.WithBlockHeight(9) resObj = sendRequest(t, TestPort, "getFilterChanges", filterId) Ctx = Ctx.WithBlockHeight(8) diff --git a/evmrpc/setup_test.go b/evmrpc/setup_test.go index 3d6ff7ddb..898e566ee 100644 --- a/evmrpc/setup_test.go +++ b/evmrpc/setup_test.go @@ -407,11 +407,13 @@ func (m *MockBadClient) BroadcastTx(context.Context, tmtypes.Tx) (*coretypes.Res var EVMKeeper *keeper.Keeper var Ctx sdk.Context +var MultiTxCtx sdk.Context func init() { types.RegisterInterfaces(EncodingConfig.InterfaceRegistry) testApp := app.Setup(false, false) Ctx = testApp.GetContextForDeliverTx([]byte{}).WithBlockHeight(8) + MultiTxCtx, _ = Ctx.CacheContext() EVMKeeper = &testApp.EvmKeeper EVMKeeper.InitGenesis(Ctx, *evmtypes.DefaultGenesis()) seiAddr, err := sdk.AccAddressFromHex(common.Bytes2Hex([]byte("seiAddr"))) @@ -427,6 +429,12 @@ func init() { panic(err) } testApp.Commit(context.Background()) + ctxProvider := func(height int64) sdk.Context { + if height == MultiTxBlockHeight { + return MultiTxCtx + } + return Ctx + } // Start good http server goodConfig := evmrpc.DefaultConfig goodConfig.HTTPPort = TestPort @@ -437,7 +445,7 @@ func init() { if err != nil { panic(err) } - HttpServer, err := evmrpc.NewEVMHTTPServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "") + HttpServer, err := evmrpc.NewEVMHTTPServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, ctxProvider, TxConfig, "") if err != nil { panic(err) } @@ -449,7 +457,7 @@ func init() { badConfig := evmrpc.DefaultConfig badConfig.HTTPPort = TestBadPort badConfig.FilterTimeout = 500 * time.Millisecond - badHTTPServer, err := evmrpc.NewEVMHTTPServer(infoLog, badConfig, &MockBadClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "") + badHTTPServer, err := evmrpc.NewEVMHTTPServer(infoLog, badConfig, &MockBadClient{}, EVMKeeper, ctxProvider, TxConfig, "") if err != nil { panic(err) } @@ -458,7 +466,7 @@ func init() { } // Start ws server - wsServer, err := evmrpc.NewEVMWebSocketServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "") + wsServer, err := evmrpc.NewEVMWebSocketServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, ctxProvider, TxConfig, "") if err != nil { panic(err) } @@ -723,8 +731,8 @@ func setupLogs() { EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight, []common.Hash{ multiTxBlockTx4.Hash(), }) - EVMKeeper.SetBlockBloom(Ctx, MultiTxBlockHeight, []ethtypes.Bloom{bloom1, bloom2, bloom3}) - EVMKeeper.SetBlockBloom(Ctx, MockHeight, []ethtypes.Bloom{bloom4}) + EVMKeeper.SetBlockBloom(MultiTxCtx, []ethtypes.Bloom{bloom1, bloom2, bloom3}) + EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom4}) } //nolint:deadcode diff --git a/x/evm/genesis.go b/x/evm/genesis.go index c90d3bf70..84bd848fd 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -26,6 +26,10 @@ func InitGenesis(ctx sdk.Context, k *keeper.Keeper, genState types.GenesisState) k.SetNonce(ctx, common.HexToAddress(nonce.Address), nonce.Nonce) } for _, serialized := range genState.Serialized { + if len(serialized.Key) == 0 { + ctx.KVStore(k.GetStoreKey()).Set(serialized.Prefix, serialized.Value) + continue + } k.PrefixStore(ctx, serialized.Prefix).Set(serialized.Key, serialized.Value) } } diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index 2ad13e0f4..f43dc2d60 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -23,7 +23,7 @@ func TestExportImportGenesis(t *testing.T) { keeper.SetState(ctx, codeAddr, common.BytesToHash([]byte("123")), common.BytesToHash([]byte("456"))) keeper.SetNonce(ctx, evmAddr, 2) keeper.MockReceipt(ctx, common.BytesToHash([]byte("789")), &types.Receipt{TxType: 2}) - keeper.SetBlockBloom(ctx, 5, []ethtypes.Bloom{{1}}) + keeper.SetBlockBloom(ctx, []ethtypes.Bloom{{1}}) keeper.SetTxHashesOnHeight(ctx, 5, []common.Hash{common.BytesToHash([]byte("123"))}) keeper.SetERC20CW20Pointer(ctx, "cw20addr", codeAddr) genesis := evm.ExportGenesis(ctx, keeper) @@ -42,7 +42,7 @@ func TestExportImportGenesis(t *testing.T) { require.Equal(t, keeper.GetNonce(ctx, evmAddr), keeper.GetNonce(origctx, evmAddr)) _, err := keeper.GetReceipt(origctx, common.BytesToHash([]byte("789"))) require.Nil(t, err) - require.Equal(t, keeper.GetBlockBloom(ctx, 5), keeper.GetBlockBloom(origctx, 5)) + require.Equal(t, keeper.GetBlockBloom(ctx), keeper.GetBlockBloom(origctx)) require.Equal(t, keeper.GetTxHashesOnHeight(ctx, 5), keeper.GetTxHashesOnHeight(origctx, 5)) _, _, exists := keeper.GetERC20CW20Pointer(origctx, "cw20addr") require.True(t, exists) diff --git a/x/evm/keeper/log.go b/x/evm/keeper/log.go index b7078759f..25a8515cc 100644 --- a/x/evm/keeper/log.go +++ b/x/evm/keeper/log.go @@ -1,7 +1,7 @@ package keeper import ( - "bytes" + "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" @@ -11,7 +11,21 @@ import ( "github.com/sei-protocol/sei-chain/x/evm/types" ) -func (k *Keeper) GetBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloom) { +func (k *Keeper) GetBlockBloom(ctx sdk.Context) (res ethtypes.Bloom) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.BlockBloomPrefix) + if bz != nil { + res.SetBytes(bz) + return + } + cutoff := k.GetLegacyBlockBloomCutoffHeight(ctx) + if cutoff == 0 || ctx.BlockHeight() < cutoff { + res = k.GetLegacyBlockBloom(ctx, ctx.BlockHeight()) + } + return +} + +func (k *Keeper) GetLegacyBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloom) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.BlockBloomKey(height)) if bz != nil { @@ -20,19 +34,31 @@ func (k *Keeper) GetBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloo return } -func (k *Keeper) SetBlockBloom(ctx sdk.Context, height int64, blooms []ethtypes.Bloom) { +func (k *Keeper) SetBlockBloom(ctx sdk.Context, blooms []ethtypes.Bloom) { blockBloom := make([]byte, ethtypes.BloomByteLength) for _, bloom := range blooms { or := make([]byte, ethtypes.BloomByteLength) bitutil.ORBytes(or, blockBloom, bloom[:]) blockBloom = or } - if bytes.Equal(blockBloom, make([]byte, ethtypes.BloomByteLength)) { - // early return if bloom is empty - return - } store := ctx.KVStore(k.storeKey) - store.Set(types.BlockBloomKey(height), blockBloom) + store.Set(types.BlockBloomPrefix, blockBloom) +} + +func (k *Keeper) SetLegacyBlockBloomCutoffHeight(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(ctx.BlockHeight())) + store.Set(types.LegacyBlockBloomCutoffHeightKey, bz) +} + +func (k *Keeper) GetLegacyBlockBloomCutoffHeight(ctx sdk.Context) int64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.LegacyBlockBloomCutoffHeightKey) + if len(bz) == 0 { + return 0 + } + return int64(binary.BigEndian.Uint64(bz)) } func GetLogsForTx(receipt *types.Receipt) []*ethtypes.Log { diff --git a/x/evm/keeper/log_test.go b/x/evm/keeper/log_test.go index 8f3644d00..9f698d831 100644 --- a/x/evm/keeper/log_test.go +++ b/x/evm/keeper/log_test.go @@ -1,4 +1,4 @@ -package keeper +package keeper_test import ( "testing" @@ -7,6 +7,8 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" + testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/sei-protocol/sei-chain/x/evm/keeper" evmtypes "github.com/sei-protocol/sei-chain/x/evm/types" ) @@ -26,7 +28,7 @@ func TestConvertEthLog(t *testing.T) { } // Convert the ethtypes.Log to a types.Log - log := ConvertEthLog(ethLog) + log := keeper.ConvertEthLog(ethLog) // Check that the fields match require.Equal(t, ethLog.Address.Hex(), log.Address) @@ -67,7 +69,7 @@ func TestGetLogsForTx(t *testing.T) { } // Convert the types.Receipt to a list of ethtypes.Log objects - logs := GetLogsForTx(receipt) + logs := keeper.GetLogsForTx(receipt) // Check that the fields match require.Equal(t, len(receipt.Logs), len(logs)) @@ -81,3 +83,11 @@ func TestGetLogsForTx(t *testing.T) { require.Equal(t, uint(receipt.Logs[i].Index), log.Index) } } + +func TestLegacyBlockBloomCutoffHeight(t *testing.T) { + k := &testkeeper.EVMTestApp.EvmKeeper + ctx := testkeeper.EVMTestApp.GetContextForDeliverTx([]byte{}).WithBlockHeight(123) + require.Equal(t, int64(0), k.GetLegacyBlockBloomCutoffHeight(ctx)) + k.SetLegacyBlockBloomCutoffHeight(ctx) + require.Equal(t, int64(123), k.GetLegacyBlockBloomCutoffHeight(ctx)) +} diff --git a/x/evm/migrations/migrate_block_bloom.go b/x/evm/migrations/migrate_block_bloom.go new file mode 100644 index 000000000..e98e5244e --- /dev/null +++ b/x/evm/migrations/migrate_block_bloom.go @@ -0,0 +1,25 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sei-protocol/sei-chain/x/evm/keeper" + "github.com/sei-protocol/sei-chain/x/evm/types" +) + +func MigrateBlockBloom(ctx sdk.Context, k *keeper.Keeper) error { + k.SetLegacyBlockBloomCutoffHeight(ctx) + + prefsToDelete := [][]byte{} + k.IterateAll(ctx, types.BlockBloomPrefix, func(key, _ []byte) bool { + if len(key) > 0 { + prefsToDelete = append(prefsToDelete, key) + } + return false + }) + store := k.PrefixStore(ctx, types.BlockBloomPrefix) + for _, pref := range prefsToDelete { + store.Delete(pref) + } + + return nil +} diff --git a/x/evm/migrations/migrate_block_bloom_test.go b/x/evm/migrations/migrate_block_bloom_test.go new file mode 100644 index 000000000..688b66571 --- /dev/null +++ b/x/evm/migrations/migrate_block_bloom_test.go @@ -0,0 +1,22 @@ +package migrations_test + +import ( + "testing" + + ethtypes "github.com/ethereum/go-ethereum/core/types" + testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/sei-protocol/sei-chain/x/evm/migrations" + "github.com/sei-protocol/sei-chain/x/evm/types" + "github.com/stretchr/testify/require" +) + +func TestMigrateBlockBloom(t *testing.T) { + k := testkeeper.EVMTestApp.EvmKeeper + ctx := testkeeper.EVMTestApp.GetContextForDeliverTx([]byte{}).WithBlockHeight(8) + k.PrefixStore(ctx, types.BlockBloomPrefix).Set([]byte{1, 2, 3}, []byte{4, 5, 6}) + k.SetBlockBloom(ctx, []ethtypes.Bloom{}) + require.Nil(t, migrations.MigrateBlockBloom(ctx, &k)) + require.Nil(t, k.PrefixStore(ctx, types.BlockBloomPrefix).Get([]byte{1, 2, 3})) + require.NotNil(t, k.GetBlockBloom(ctx)) + require.Equal(t, int64(8), k.GetLegacyBlockBloomCutoffHeight(ctx)) +} diff --git a/x/evm/module.go b/x/evm/module.go index fbbd882a3..16d44ecb5 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -212,6 +212,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { _ = cfg.RegisterMigration(types.ModuleName, 11, func(ctx sdk.Context) error { return migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, am.keeper) }) + + _ = cfg.RegisterMigration(types.ModuleName, 12, func(ctx sdk.Context) error { + return migrations.MigrateBlockBloom(ctx, am.keeper) + }) } // RegisterInvariants registers the capability module's invariants. @@ -249,7 +253,7 @@ func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <- } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 12 } +func (AppModule) ConsensusVersion() uint64 { return 13 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { @@ -330,6 +334,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val } } 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 })) - am.keeper.SetBlockBloom(ctx, ctx.BlockHeight(), utils.Map(evmTxDeferredInfoList, func(i *types.DeferredInfo) ethtypes.Bloom { return ethtypes.BytesToBloom(i.TxBloom) })) + am.keeper.SetBlockBloom(ctx, utils.Map(evmTxDeferredInfoList, func(i *types.DeferredInfo) ethtypes.Bloom { return ethtypes.BytesToBloom(i.TxBloom) })) return []abci.ValidatorUpdate{} } diff --git a/x/evm/module_test.go b/x/evm/module_test.go index d9ad4a0dd..c8bd73ebe 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -59,7 +59,7 @@ func TestModuleExportGenesis(t *testing.T) { func TestConsensusVersion(t *testing.T) { k, _ := testkeeper.MockEVMKeeper() module := evm.NewAppModule(nil, k) - assert.Equal(t, uint64(12), module.ConsensusVersion()) + assert.Equal(t, uint64(13), module.ConsensusVersion()) } func TestABCI(t *testing.T) { diff --git a/x/evm/types/keys.go b/x/evm/types/keys.go index 3234b73c8..d6e269b3f 100644 --- a/x/evm/types/keys.go +++ b/x/evm/types/keys.go @@ -54,6 +54,8 @@ var ( AnteSurplusPrefix = []byte{0x18} // transient DeferredInfoPrefix = []byte{0x19} // transient + + LegacyBlockBloomCutoffHeightKey = []byte{0x1a} ) var ( From 8defdf4df0c7e4914d5c46af97dee0a9e0277258 Mon Sep 17 00:00:00 2001 From: Uday Patil Date: Wed, 11 Sep 2024 11:38:18 -0500 Subject: [PATCH 2/8] Update changelog (#1852) * update v5.7.5 changelog * update v5.8.0 changelog --- CHANGELOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 578d175c3..4c5ab66af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,56 @@ Ref: https://keepachangelog.com/en/1.0.0/ --> # Changelog +## v5.8.0 +sei-chain +* [#1840](https://github.com/sei-protocol/sei-chain/pull/1840) Add migration for new params +* [#1837](https://github.com/sei-protocol/sei-chain/pull/1837) Move token id from Data to Topic in ERC721 Event +* [#1836](https://github.com/sei-protocol/sei-chain/pull/1836) Properly handle gas in pointer precompile +* [#1835](https://github.com/sei-protocol/sei-chain/pull/1835) Check TX nonce before registering hook to bump nonce for failed tx +* [#1832](https://github.com/sei-protocol/sei-chain/pull/1832) Show CW transactions that have synthetic EVM events in eth_getBlock response +* [#1831](https://github.com/sei-protocol/sei-chain/pull/1831) Fork event manager when creating EVM snapshots +* [#1830](https://github.com/sei-protocol/sei-chain/pull/1830) Add wasm contract query gas limit +* [#1826](https://github.com/sei-protocol/sei-chain/pull/1826) limit MsgExec max nested level +* [#1821](https://github.com/sei-protocol/sei-chain/pull/1821) Add antehandler for EVM to check gas exceed limit or not +* [#1818](https://github.com/sei-protocol/sei-chain/pull/1818) Prevent ddos against associate msgs +* [#1816](https://github.com/sei-protocol/sei-chain/pull/1816) Actually remove dex module +* [#1813](https://github.com/sei-protocol/sei-chain/pull/1813) Tune Configs +* [#1812](https://github.com/sei-protocol/sei-chain/pull/1812) Evidence Max Bytes Update +* [#1785](https://github.com/sei-protocol/sei-chain/pull/1785) Allow CW->ERC pointers to be called through wasmd precompile +* [#1778](https://github.com/sei-protocol/sei-chain/pull/1778) Bump nonce even if tx fails + +sei-cosmos +* [#535](https://github.com/sei-protocol/sei-cosmos/pull/535) init app earliest version correctly after state sync +* [#534](https://github.com/sei-protocol/sei-cosmos/pull/534) Stop executing the handler when proposal is submitted +* [#533](https://github.com/sei-protocol/sei-cosmos/pull/533) Delete kvstore specified in store upgrades +* [#532](https://github.com/sei-protocol/sei-cosmos/pull/532) Add max gas limit check in ante handler +* [#528](https://github.com/sei-protocol/sei-cosmos/pull/528) Add logs for snapshot export and impor + +sei-wasmd +* [63](https://github.com/sei-protocol/sei-wasmd/pull/63) Add CW dispatch call depth +* [62](https://github.com/sei-protocol/sei-wasmd/pull/62) Patch Gas mispricing in CW VM + +sei-tendermint +* [#242](https://github.com/sei-protocol/sei-tendermint/pull/242) Allow hyphen in event query + +## v5.7.5 +sei-chain +* [#1795](https://github.com/sei-protocol/sei-chain/pull/1795) Do not charge gas for feecollector address query +* [#1782](https://github.com/sei-protocol/sei-chain/pull/1782) Update excessBlobGas and BlobBaseFee to fix simulate evmcontext +* [#1741](https://github.com/sei-protocol/sei-chain/pull/1782) Update excessBlobGas and BlobBaseFee to fix simulate evmcontext + +sei-cosmos +* [#530](https://github.com/sei-protocol/sei-cosmos/pull/530) Add EVMEntryViaWasmdPrecompile flag +* [#519](https://github.com/sei-protocol/sei-cosmos/pull/519) Genesis export stream +* [#529](https://github.com/sei-protocol/sei-cosmos/pull/529) Add DeliverTx callback +* [#528](https://github.com/sei-protocol/sei-cosmos/pull/528) Add logs for snapshot export and import + +sei-wasmd +* [58](https://github.com/sei-protocol/sei-wasmd/pull/58) Genesis Export OOM + +sei-tendermint +* [#239](https://github.com/sei-protocol/sei-tendermint/pull/239) Use Marshal and UnmarshalJSON For HexBytes + ## v5.7.1 & v5.7.2 sei-chain * [#1779](https://github.com/sei-protocol/sei-chain/pull/1779) Fix subscribe logs empty params crash From aeecb5f3d2344e9547d64ceda34ccafb6c41545f Mon Sep 17 00:00:00 2001 From: codchen Date: Fri, 13 Sep 2024 10:58:34 +0800 Subject: [PATCH 3/8] Fix websocket from_height (#1853) --- evmrpc/subscribe.go | 1 + 1 file changed, 1 insertion(+) diff --git a/evmrpc/subscribe.go b/evmrpc/subscribe.go index 35c8e2c3c..43b04d50b 100644 --- a/evmrpc/subscribe.go +++ b/evmrpc/subscribe.go @@ -183,6 +183,7 @@ func (a *SubscriptionAPI) Logs(ctx context.Context, filter *filters.FilterCriter return } begin = lastToHeight + filter.FromBlock = big.NewInt(lastToHeight + 1) time.Sleep(SleepInterval) } From a5c89c06fba23cd97b9ba60847febb8492edf53c Mon Sep 17 00:00:00 2001 From: Philip Su Date: Fri, 13 Sep 2024 08:08:23 -0700 Subject: [PATCH 4/8] Security md (#1854) * Add security.md * rm * rm bounty --- SECURITY.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..0962dc46e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,68 @@ +# Security Policy + +## Introduction + +Security researchers are essential in identifying vulnerabilities that may impact the Sei ecosystem. If you have discovered a security vulnerability in the Sei chain or any repository managed by Sei, we encourage you to notify us using one of the methods outlined below. + +### Guidelines for Responsible Vulnerability Testing and Reporting + +1. **Refrain from testing vulnerabilities on our publicly accessible environments**, including but not limited to: + +- Sei mainnet `pacific-1` +- Sei frontend +- Sei public testnets +- Sei testnet frontend + +2. **Avoid reporting security vulnerabilities through public channels, including GitHub issues** + +To privately report a security vulnerability, please choose one of the following options: + +### 1. Email + +Send your detailed vulnerability report to `protocol-eng@seinetwork.io`. + +### 2. GitHub Private Vulnerability Reporting + +Utilize [GitHub's Private Vulnerability Reporting](https://github.com/sei-protocol/sei-chain/security/advisories/new) for confidential disclosure. + +## Submit Vulnerability Report + +When reporting a vulnerability through either method, please include the following details to aid in our assessment: + +- Type of vulnerability +- Description of the vulnerability +- Steps to reproduce the issue +- Impact of the issue +- Explanation on how an attacker could exploit it + +## Vulnerability Disclosure Process + +1. **Initial Report**: Submit the vulnerability via one of the above channels. +2. **Confirmation**: We will confirm receipt of your report within 48 hours. +3. **Assessment**: Our security team will evaluate the vulnerability and inform you of its severity and the estimated time frame for resolution. +4. **Resolution**: Once fixed, you will be contacted to verify the solution. +5. **Public Disclosure**: Details of the vulnerability may be publicly disclosed after ensuring it poses no further risk. + +During the vulnerability disclosure process, we ask security researchers to keep vulnerabilities and communications around vulnerability submissions private and confidential until a patch is developed. Should a security issue require a network upgrade, additional time may be needed to raise a governance proposal and complete the upgrade. + +During this time: + +- Avoid exploiting any vulnerabilities you discover. +- Demonstrate good faith by not disrupting or degrading Sei's services. + +## Feature request + +For a feature request, e.g. module inclusion, please make a GitHub issue. Clearly state your use case and what value it will bring to other users or developers on Sei. + +## Severity Characterization + +| Severity | Description | +| ------------ | ----------------------------------------------------------------------- | +| **CRITICAL** | Immediate threat to critical systems (e.g., chain halts, funds at risk) | +| **HIGH** | Significant impact on major functionality | +| **MEDIUM** | Impacts minor features or exposes non-sensitive data | +| **LOW** | Minimal impact | + +## Feedback on this Policy + +For recommendations on how to improve this policy, either submit a pull request or email `protocol-eng@seinetwork.io`. From dcb6b1453e8a7b608fa06e5419143951a1ad7329 Mon Sep 17 00:00:00 2001 From: codchen Date: Tue, 17 Sep 2024 21:26:18 +0800 Subject: [PATCH 5/8] Revert showing wasm transactions in EVM rpc (#1861) --- evmrpc/block.go | 23 --------------- evmrpc/block_test.go | 67 -------------------------------------------- 2 files changed, 90 deletions(-) diff --git a/evmrpc/block.go b/evmrpc/block.go index cefd19011..186b8d955 100644 --- a/evmrpc/block.go +++ b/evmrpc/block.go @@ -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" @@ -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, ðapi.RPCTransaction{ - BlockHash: &blockhash, - BlockNumber: (*hexutil.Big)(number), - From: common.HexToAddress(receipt.From), - To: &to, - Input: m.Msg.Bytes(), - Hash: th, - TransactionIndex: (*hexutil.Uint64)(&ti), - }) - } } } } diff --git a/evmrpc/block_test.go b/evmrpc/block_test.go index 58d796ec8..c91798026 100644 --- a/evmrpc/block_test.go +++ b/evmrpc/block_test.go @@ -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" @@ -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, ðapi.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)) -} From 76931f279cff0c2bd1572dec018ba0a450361c57 Mon Sep 17 00:00:00 2001 From: Yiming Zang <50607998+yzang2019@users.noreply.github.com> Date: Tue, 17 Sep 2024 07:58:13 -0700 Subject: [PATCH 6/8] Bump IAVL version (#1858) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f8063c924..b825b4986 100644 --- a/go.mod +++ b/go.mod @@ -347,7 +347,7 @@ 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.35 - github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9 + 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-22 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/go.sum b/go.sum index 256d52167..7e9049803 100644 --- a/go.sum +++ b/go.sum @@ -1351,8 +1351,8 @@ github.com/sei-protocol/sei-cosmos v0.3.35 h1:mPj5AE21DE5Zpe4UzMv2YwsaPm8mCFLbb0 github.com/sei-protocol/sei-cosmos v0.3.35/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= github.com/sei-protocol/sei-db v0.0.44 h1:HMgcyDTQlmXdJysHJxmIo66EKeXn1CSQT9qXDnxjJgI= github.com/sei-protocol/sei-db v0.0.44/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= -github.com/sei-protocol/sei-iavl v0.1.9 h1:y4mVYftxLNRs6533zl7N0/Ch+CzRQc04JDfHolIxgBE= -github.com/sei-protocol/sei-iavl v0.1.9/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk= +github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= +github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 h1:BaMZ6gjwqe3R/5dLmcJ1TkSZ3omcWy2TjaAZAeOJH44= github.com/sei-protocol/sei-ibc-go/v3 v3.3.2/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= github.com/sei-protocol/sei-tendermint v0.3.8 h1:9o+A3tL6q1ki++dLng/J8MHHiT6y3l7D4Ir2UIQSkAQ= From fa620f1f5fe5c7eaeda6223ed8afc1b12b0711ef Mon Sep 17 00:00:00 2001 From: codchen Date: Thu, 19 Sep 2024 12:48:11 +0800 Subject: [PATCH 7/8] Fix events in 2-hop scenarios (#1857) * Fix events in 2-hop scenarios * integration test --- contracts/test/CW20toERC20PointerTest.js | 8 +++++++ x/evm/keeper/msg_server.go | 28 ++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/contracts/test/CW20toERC20PointerTest.js b/contracts/test/CW20toERC20PointerTest.js index 0638aa38f..f1444fa5b 100644 --- a/contracts/test/CW20toERC20PointerTest.js +++ b/contracts/test/CW20toERC20PointerTest.js @@ -184,6 +184,14 @@ describe("CW20 to ERC20 Pointer", function () { const response = await wasmd.execute(pointer, transferBz, coinsBz); const receipt = await response.wait(); expect(receipt.status).to.equal(1); + + const filter = { + fromBlock: receipt["blockNumber"], + toBlock: 'latest', + topics: [ethers.id("Transfer(address,address,uint256)")] + }; + const logs = await ethers.provider.getLogs(filter); + expect(logs.length).to.equal(1); }); }); }); diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 0402ff48a..76e9d329a 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -90,6 +90,20 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT return } extraSurplus := sdk.ZeroInt() + surplus, ferr := stateDB.Finalize() + if ferr != nil { + err = ferr + ctx.Logger().Error(fmt.Sprintf("failed to finalize EVM stateDB: %s", err)) + + telemetry.IncrCounterWithLabels( + []string{types.ModuleName, "errors", "stateDB_finalize"}, + 1, + []metrics.Label{ + telemetry.NewLabel("type", err.Error()), + }, + ) + return + } if isWasmdPrecompileCall { syntheticReceipt, err := server.GetTransientReceipt(ctx, ctx.TxSum()) if err == nil { @@ -132,20 +146,6 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT telemetry.IncrCounter(1, "receipt", "status", "success") } - surplus, ferr := stateDB.Finalize() - if ferr != nil { - err = ferr - ctx.Logger().Error(fmt.Sprintf("failed to finalize EVM stateDB: %s", err)) - - telemetry.IncrCounterWithLabels( - []string{types.ModuleName, "errors", "stateDB_finalize"}, - 1, - []metrics.Label{ - telemetry.NewLabel("type", err.Error()), - }, - ) - return - } surplus = surplus.Add(extraSurplus) bloom := ethtypes.Bloom{} bloom.SetBytes(receipt.LogsBloom) From fa43819a177948b57bc5ebe24c73608f15a815fc Mon Sep 17 00:00:00 2001 From: yirenz Date: Thu, 19 Sep 2024 14:23:12 -0400 Subject: [PATCH 8/8] V5.8.0 hotfix 3 (#1862) * Release oom hotfix * Revert showing wasm transactions in EVM rpc (#1861) * fix: add V580Params specific functions * chore: update variable name ParamsPreV580 --------- Co-authored-by: yzang2019 Co-authored-by: codchen --- go.mod | 2 + go.sum | 3 + proto/evm/params.proto | 45 ++++- x/evm/keeper/params.go | 23 ++- x/evm/module_test.go | 2 +- x/evm/types/params.go | 16 +- x/evm/types/params.pb.go | 419 +++++++++++++++++++++++++++++++++++---- 7 files changed, 464 insertions(+), 46 deletions(-) diff --git a/go.mod b/go.mod index b825b4986..eb6425424 100644 --- a/go.mod +++ b/go.mod @@ -125,6 +125,7 @@ require ( github.com/fzipp/gocyclo v0.5.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -172,6 +173,7 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect diff --git a/go.sum b/go.sum index 7e9049803..cd8366573 100644 --- a/go.sum +++ b/go.sum @@ -457,6 +457,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -765,6 +766,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/guptarohit/asciigraph v0.5.5/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= diff --git a/proto/evm/params.proto b/proto/evm/params.proto index d2497e4b3..23a1454f0 100644 --- a/proto/evm/params.proto +++ b/proto/evm/params.proto @@ -32,7 +32,50 @@ string minimum_fee_per_gas = 4 [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "minimum_fee_per_gas" ]; -uint64 deliver_tx_hook_wasm_gas_limit = 5; + // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; +// string chain_id = 6 [ +// (gogoproto.moretags) = "yaml:\"chain_id\"", +// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", +// (gogoproto.nullable) = false, +// (gogoproto.jsontag) = "chain_id" +// ]; + // repeated string whitelisted_codehashes_bank_send = 7 [ + // (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"", + // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" + // ]; + repeated bytes whitelisted_cw_code_hashes_for_delegate_call = 8 [ + (gogoproto.moretags) = "yaml:\"whitelisted_cw_code_hashes_for_delegate_call\"", + (gogoproto.jsontag) = "whitelisted_cw_code_hashes_for_delegate_call" + ]; + + uint64 deliver_tx_hook_wasm_gas_limit = 9; +} + +message ParamsPreV580 { + option (gogoproto.goproto_stringer) = false; + + // string base_denom = 1 [ + // (gogoproto.moretags) = "yaml:\"base_denom\"", + // (gogoproto.jsontag) = "base_denom" + // ]; + string priority_normalizer = 2 [ + (gogoproto.moretags) = "yaml:\"priority_normalizer\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "priority_normalizer" + ]; + string base_fee_per_gas = 3 [ + (gogoproto.moretags) = "yaml:\"base_fee_per_gas\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "base_fee_per_gas" +]; +string minimum_fee_per_gas = 4 [ + (gogoproto.moretags) = "yaml:\"minimum_fee_per_gas\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "minimum_fee_per_gas" +]; // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; // string chain_id = 6 [ // (gogoproto.moretags) = "yaml:\"chain_id\"", diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index fbd885e11..cc988adfd 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -15,12 +15,31 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.Paramstore.SetParamSet(ctx, ¶ms) } -func (k *Keeper) GetParams(ctx sdk.Context) types.Params { - params := types.Params{} +func (k *Keeper) GetParams(ctx sdk.Context) (params types.Params) { + params = types.Params{} + defer func() { + if r := recover(); r != nil { + // If panic occurs, try to get paramsPreV580 + params = k.GetParamsPreV580(ctx) + } + }() k.Paramstore.GetParamSet(ctx, ¶ms) return params } +func (k *Keeper) GetParamsPreV580(ctx sdk.Context) types.Params { + paramsPreV580 := types.ParamsPreV580{} + k.Paramstore.GetParamSet(ctx, ¶msPreV580) + // Convert paramsPreV580 to params + return types.Params{ + PriorityNormalizer: paramsPreV580.PriorityNormalizer, + BaseFeePerGas: paramsPreV580.BaseFeePerGas, + MinimumFeePerGas: paramsPreV580.MinimumFeePerGas, + WhitelistedCwCodeHashesForDelegateCall: paramsPreV580.WhitelistedCwCodeHashesForDelegateCall, + DeliverTxHookWasmGasLimit: uint64(300000), + } +} + func (k *Keeper) GetParamsIfExists(ctx sdk.Context) types.Params { params := types.Params{} k.Paramstore.GetParamSetIfExists(ctx, ¶ms) diff --git a/x/evm/module_test.go b/x/evm/module_test.go index c8bd73ebe..624810dea 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -53,7 +53,7 @@ func TestModuleExportGenesis(t *testing.T) { module := evm.NewAppModule(nil, k) jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc) jsonStr := string(jsonMsg) - assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"deliver_tx_hook_wasm_gas_limit\":\"300000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) + assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[],\"deliver_tx_hook_wasm_gas_limit\":\"300000\"},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) } func TestConsensusVersion(t *testing.T) { diff --git a/x/evm/types/params.go b/x/evm/types/params.go index ffb78606d..b05983296 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -50,8 +50,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyPriorityNormalizer, &p.PriorityNormalizer, validatePriorityNormalizer), paramtypes.NewParamSetPair(KeyBaseFeePerGas, &p.BaseFeePerGas, validateBaseFeePerGas), paramtypes.NewParamSetPair(KeyMinFeePerGas, &p.MinimumFeePerGas, validateMinFeePerGas), - paramtypes.NewParamSetPair(KeyDeliverTxHookWasmGasLimit, &p.DeliverTxHookWasmGasLimit, validateDeliverTxHookWasmGasLimit), paramtypes.NewParamSetPair(KeyWhitelistedCwCodeHashesForDelegateCall, &p.WhitelistedCwCodeHashesForDelegateCall, validateWhitelistedCwHashesForDelegateCall), + paramtypes.NewParamSetPair(KeyDeliverTxHookWasmGasLimit, &p.DeliverTxHookWasmGasLimit, validateDeliverTxHookWasmGasLimit), } } @@ -79,6 +79,20 @@ func (p Params) String() string { return string(out) } +func (p *ParamsPreV580) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyPriorityNormalizer, &p.PriorityNormalizer, validatePriorityNormalizer), + paramtypes.NewParamSetPair(KeyBaseFeePerGas, &p.BaseFeePerGas, validateBaseFeePerGas), + paramtypes.NewParamSetPair(KeyMinFeePerGas, &p.MinimumFeePerGas, validateMinFeePerGas), + paramtypes.NewParamSetPair(KeyWhitelistedCwCodeHashesForDelegateCall, &p.WhitelistedCwCodeHashesForDelegateCall, validateWhitelistedCwHashesForDelegateCall), + } +} + +func (p ParamsPreV580) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + func validatePriorityNormalizer(i interface{}) error { v, ok := i.(sdk.Dec) if !ok { diff --git a/x/evm/types/params.pb.go b/x/evm/types/params.pb.go index 8303ff5af..5b0211d8c 100644 --- a/x/evm/types/params.pb.go +++ b/x/evm/types/params.pb.go @@ -30,10 +30,9 @@ type Params struct { // (gogoproto.moretags) = "yaml:\"base_denom\"", // (gogoproto.jsontag) = "base_denom" // ]; - PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` - BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` - MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` - DeliverTxHookWasmGasLimit uint64 `protobuf:"varint,5,opt,name=deliver_tx_hook_wasm_gas_limit,json=deliverTxHookWasmGasLimit,proto3" json:"deliver_tx_hook_wasm_gas_limit,omitempty"` + PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` + BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` + MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; // string chain_id = 6 [ // (gogoproto.moretags) = "yaml:\"chain_id\"", @@ -46,6 +45,7 @@ type Params struct { // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" // ]; WhitelistedCwCodeHashesForDelegateCall [][]byte `protobuf:"bytes,8,rep,name=whitelisted_cw_code_hashes_for_delegate_call,json=whitelistedCwCodeHashesForDelegateCall,proto3" json:"whitelisted_cw_code_hashes_for_delegate_call" yaml:"whitelisted_cw_code_hashes_for_delegate_call"` + DeliverTxHookWasmGasLimit uint64 `protobuf:"varint,9,opt,name=deliver_tx_hook_wasm_gas_limit,json=deliverTxHookWasmGasLimit,proto3" json:"deliver_tx_hook_wasm_gas_limit,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -80,6 +80,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { + if m != nil { + return m.WhitelistedCwCodeHashesForDelegateCall + } + return nil +} + func (m *Params) GetDeliverTxHookWasmGasLimit() uint64 { if m != nil { return m.DeliverTxHookWasmGasLimit @@ -87,7 +94,67 @@ func (m *Params) GetDeliverTxHookWasmGasLimit() uint64 { return 0 } -func (m *Params) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { +type ParamsPreV580 struct { + // string base_denom = 1 [ + // + // (gogoproto.moretags) = "yaml:\"base_denom\"", + // (gogoproto.jsontag) = "base_denom" + // + // ]; + PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` + BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` + MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` + // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; + // + // string chain_id = 6 [ + // (gogoproto.moretags) = "yaml:\"chain_id\"", + // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + // (gogoproto.nullable) = false, + // (gogoproto.jsontag) = "chain_id" + // + // ]; + // repeated string whitelisted_codehashes_bank_send = 7 [ + // + // (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"", + // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" + // + // ]; + WhitelistedCwCodeHashesForDelegateCall [][]byte `protobuf:"bytes,8,rep,name=whitelisted_cw_code_hashes_for_delegate_call,json=whitelistedCwCodeHashesForDelegateCall,proto3" json:"whitelisted_cw_code_hashes_for_delegate_call" yaml:"whitelisted_cw_code_hashes_for_delegate_call"` +} + +func (m *ParamsPreV580) Reset() { *m = ParamsPreV580{} } +func (*ParamsPreV580) ProtoMessage() {} +func (*ParamsPreV580) Descriptor() ([]byte, []int) { + return fileDescriptor_9272f3679901ea94, []int{1} +} +func (m *ParamsPreV580) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsPreV580) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsPreV580.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamsPreV580) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsPreV580.Merge(m, src) +} +func (m *ParamsPreV580) XXX_Size() int { + return m.Size() +} +func (m *ParamsPreV580) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsPreV580.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsPreV580 proto.InternalMessageInfo + +func (m *ParamsPreV580) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { if m != nil { return m.WhitelistedCwCodeHashesForDelegateCall } @@ -96,42 +163,45 @@ func (m *Params) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.evm.Params") + proto.RegisterType((*ParamsPreV580)(nil), "seiprotocol.seichain.evm.ParamsPreV580") } func init() { proto.RegisterFile("evm/params.proto", fileDescriptor_9272f3679901ea94) } var fileDescriptor_9272f3679901ea94 = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0x4e, 0xdc, 0xee, 0xa2, 0x41, 0xa1, 0x64, 0x05, 0x63, 0x0f, 0x49, 0xc9, 0x61, 0xe9, 0xc1, - 0x26, 0x87, 0xbd, 0xed, 0xcd, 0x76, 0xd9, 0xee, 0x41, 0x64, 0x09, 0x82, 0x20, 0xc8, 0x30, 0x4d, - 0x5e, 0x93, 0xa1, 0x33, 0x7d, 0x61, 0x26, 0xdb, 0x1f, 0xfe, 0x01, 0x9e, 0x45, 0x3c, 0x78, 0xf4, - 0x9f, 0x11, 0xf6, 0x24, 0x7b, 0x14, 0x0f, 0x41, 0xda, 0xdb, 0x1e, 0xfb, 0x17, 0x48, 0xa6, 0x5d, - 0xb7, 0x6a, 0x2f, 0xf5, 0x94, 0x97, 0xef, 0xfb, 0xde, 0xc7, 0x37, 0xef, 0xf1, 0xac, 0x3a, 0x8c, - 0x45, 0x98, 0x53, 0x49, 0x85, 0x0a, 0x72, 0x89, 0x05, 0xda, 0x8e, 0x02, 0xa6, 0xab, 0x18, 0x79, - 0xa0, 0x80, 0xc5, 0x19, 0x65, 0xa3, 0x00, 0xc6, 0xa2, 0xf1, 0x38, 0xc5, 0x14, 0x35, 0x15, 0x56, - 0xd5, 0x4a, 0xdf, 0xd0, 0x0e, 0x31, 0x8e, 0x06, 0x2c, 0x5d, 0x21, 0xfe, 0xb7, 0x7d, 0xeb, 0xe0, - 0x42, 0x5b, 0xda, 0x9f, 0x4c, 0xeb, 0x30, 0x97, 0x0c, 0x25, 0x2b, 0x66, 0x64, 0x84, 0x52, 0x50, - 0xce, 0xde, 0x81, 0x74, 0xee, 0x35, 0xcd, 0xd6, 0x83, 0x4e, 0x7c, 0x55, 0x7a, 0xc6, 0x8f, 0xd2, - 0x3b, 0x4a, 0x59, 0x91, 0x5d, 0xf6, 0x83, 0x18, 0x2b, 0x27, 0x25, 0x50, 0xad, 0x3f, 0x6d, 0x95, - 0x0c, 0xc3, 0x62, 0x96, 0x83, 0x0a, 0x4e, 0x21, 0xbe, 0x29, 0xbd, 0x6d, 0x66, 0xcb, 0xd2, 0x6b, - 0xcc, 0xa8, 0xe0, 0x27, 0xfe, 0x16, 0xd2, 0x8f, 0xec, 0x5b, 0xf4, 0xe5, 0x6f, 0xd0, 0x7e, 0x6f, - 0x5a, 0xf5, 0x3e, 0x55, 0x40, 0x06, 0x00, 0x24, 0x07, 0x49, 0x52, 0xaa, 0x9c, 0x3d, 0x9d, 0xe9, - 0xed, 0xce, 0x99, 0xfe, 0x71, 0x5a, 0x96, 0xde, 0x93, 0x55, 0xa0, 0xbf, 0x19, 0x3f, 0x7a, 0x54, - 0x41, 0x67, 0x00, 0x17, 0x20, 0x7b, 0x54, 0xd9, 0x1f, 0x4d, 0xeb, 0x50, 0xb0, 0x11, 0x13, 0x97, - 0xe2, 0x8f, 0x2c, 0xb5, 0xff, 0x9d, 0xcf, 0x16, 0xb3, 0xbb, 0xf9, 0x6c, 0x21, 0xfd, 0xa8, 0xbe, - 0x46, 0xef, 0x42, 0x3d, 0xb7, 0xdc, 0x04, 0x38, 0x1b, 0x83, 0x24, 0xc5, 0x94, 0x64, 0x88, 0x43, - 0x32, 0xa1, 0x4a, 0x54, 0x72, 0xc2, 0x99, 0x60, 0x85, 0xb3, 0xdf, 0x34, 0x5b, 0xb5, 0xe8, 0xe9, - 0x5a, 0xf5, 0x6a, 0x7a, 0x8e, 0x38, 0x7c, 0x4d, 0x95, 0xe8, 0x51, 0xf5, 0xa2, 0x12, 0xd8, 0x5f, - 0x4d, 0xeb, 0xd9, 0x24, 0x63, 0x05, 0x70, 0xa6, 0x0a, 0x48, 0x48, 0x3c, 0x21, 0x31, 0x26, 0x40, - 0x32, 0xaa, 0x32, 0x50, 0x64, 0x80, 0x92, 0x24, 0xc0, 0x21, 0xa5, 0x05, 0x90, 0x98, 0x72, 0xee, - 0xdc, 0x6f, 0xee, 0xb5, 0x1e, 0x76, 0xd2, 0x9b, 0xd2, 0xdb, 0xa9, 0x6f, 0x59, 0x7a, 0xc7, 0xab, - 0xb7, 0xed, 0xd2, 0xe5, 0x47, 0x47, 0x1b, 0xf2, 0xee, 0xa4, 0x8b, 0x09, 0x9c, 0x6b, 0xed, 0x19, - 0xca, 0xd3, 0xb5, 0xb2, 0x4b, 0x39, 0x3f, 0xa9, 0x7d, 0xfe, 0xe2, 0x19, 0x9d, 0xde, 0xd5, 0xdc, - 0x35, 0xaf, 0xe7, 0xae, 0xf9, 0x73, 0xee, 0x9a, 0x1f, 0x16, 0xae, 0x71, 0xbd, 0x70, 0x8d, 0xef, - 0x0b, 0xd7, 0x78, 0xd3, 0xde, 0xd8, 0x8c, 0x02, 0xd6, 0xbe, 0x3d, 0x1c, 0xfd, 0xa3, 0x2f, 0x27, - 0x9c, 0x86, 0xd5, 0x81, 0xe8, 0x25, 0xf5, 0x0f, 0x34, 0x7f, 0xfc, 0x2b, 0x00, 0x00, 0xff, 0xff, - 0x70, 0xe7, 0xb6, 0xa2, 0x76, 0x03, 0x00, 0x00, + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x54, 0x3f, 0x6b, 0xdb, 0x40, + 0x1c, 0x95, 0x1a, 0x27, 0x34, 0xa2, 0x01, 0xa3, 0x14, 0xaa, 0x7a, 0x90, 0x8c, 0x86, 0xe0, 0xa1, + 0x96, 0x0a, 0xa1, 0x50, 0xb2, 0xd5, 0x0e, 0x71, 0x86, 0x52, 0x8c, 0x28, 0x2d, 0x14, 0xca, 0x71, + 0x96, 0x7e, 0x96, 0x0e, 0xdf, 0xf9, 0xc4, 0x9d, 0xe2, 0x3f, 0xfd, 0x00, 0x9d, 0x4b, 0xe8, 0xd0, + 0xb1, 0x5f, 0xa6, 0x90, 0xa9, 0x64, 0x2c, 0x1d, 0x44, 0xb1, 0xb7, 0x8c, 0xfe, 0x04, 0x45, 0x27, + 0xa7, 0x49, 0x5b, 0x2f, 0xee, 0xd2, 0xc5, 0x93, 0x4e, 0xef, 0xbd, 0x7b, 0xbc, 0xfb, 0xf1, 0xf8, + 0x19, 0x55, 0x18, 0x31, 0x3f, 0xc5, 0x02, 0x33, 0xe9, 0xa5, 0x82, 0x67, 0xdc, 0xb4, 0x24, 0x10, + 0x75, 0x0a, 0x39, 0xf5, 0x24, 0x90, 0x30, 0xc1, 0x64, 0xe8, 0xc1, 0x88, 0xd5, 0xee, 0xc7, 0x3c, + 0xe6, 0x8a, 0xf2, 0x8b, 0x53, 0xa9, 0xaf, 0x29, 0x87, 0x90, 0x0f, 0xfb, 0x24, 0x2e, 0x11, 0xf7, + 0xeb, 0xb6, 0xb1, 0xd3, 0x55, 0x96, 0xe6, 0x47, 0xdd, 0xd8, 0x4f, 0x05, 0xe1, 0x82, 0x64, 0x53, + 0x34, 0xe4, 0x82, 0x61, 0x4a, 0xde, 0x81, 0xb0, 0xee, 0xd4, 0xf5, 0xc6, 0x6e, 0x2b, 0xbc, 0xc8, + 0x1d, 0xed, 0x7b, 0xee, 0x1c, 0xc4, 0x24, 0x4b, 0xce, 0x7a, 0x5e, 0xc8, 0x0b, 0x27, 0xc9, 0xb8, + 0x5c, 0x7e, 0x9a, 0x32, 0x1a, 0xf8, 0xd9, 0x34, 0x05, 0xe9, 0x1d, 0x43, 0x78, 0x95, 0x3b, 0xab, + 0xcc, 0x16, 0xb9, 0x53, 0x9b, 0x62, 0x46, 0x8f, 0xdc, 0x15, 0xa4, 0x1b, 0x98, 0xd7, 0xe8, 0x8b, + 0x5f, 0xa0, 0xf9, 0x5e, 0x37, 0xaa, 0x3d, 0x2c, 0x01, 0xf5, 0x01, 0x50, 0x0a, 0x02, 0xc5, 0x58, + 0x5a, 0x5b, 0x2a, 0xd3, 0xdb, 0xb5, 0x33, 0xfd, 0xe5, 0xb4, 0xc8, 0x9d, 0x07, 0x65, 0xa0, 0x3f, + 0x19, 0x37, 0xd8, 0x2b, 0xa0, 0x13, 0x80, 0x2e, 0x88, 0x0e, 0x96, 0xe6, 0xb9, 0x6e, 0xec, 0x33, + 0x32, 0x24, 0xec, 0x8c, 0xfd, 0x96, 0xa5, 0xf2, 0xaf, 0xf3, 0x59, 0x61, 0x76, 0x33, 0x9f, 0x15, + 0xa4, 0x1b, 0x54, 0x97, 0xe8, 0x4d, 0xa8, 0x2f, 0xba, 0xf1, 0x68, 0x9c, 0x90, 0x0c, 0x28, 0x91, + 0x19, 0x44, 0x28, 0x1c, 0xa3, 0x90, 0x47, 0x80, 0x12, 0x2c, 0x13, 0x90, 0xa8, 0xcf, 0x05, 0x8a, + 0x80, 0x42, 0x8c, 0x33, 0x40, 0x21, 0xa6, 0xd4, 0xba, 0x5b, 0xdf, 0x6a, 0xdc, 0x6b, 0xc5, 0x57, + 0xb9, 0xb3, 0xd6, 0xbd, 0x45, 0xee, 0x1c, 0x96, 0xc1, 0xd6, 0xb9, 0xe5, 0x06, 0x07, 0xb7, 0xe4, + 0xed, 0x71, 0x9b, 0x47, 0x70, 0xaa, 0xb4, 0x27, 0x5c, 0x1c, 0x2f, 0x95, 0x6d, 0x4c, 0xa9, 0xf9, + 0xcc, 0xb0, 0x23, 0xa0, 0x64, 0x04, 0x02, 0x65, 0x13, 0x94, 0x70, 0x3e, 0x40, 0x63, 0x2c, 0x59, + 0xf1, 0x6c, 0x44, 0x09, 0x23, 0x99, 0xb5, 0x5b, 0xd7, 0x1b, 0x95, 0xe0, 0xe1, 0x52, 0xf5, 0x72, + 0x72, 0xca, 0xf9, 0xe0, 0x35, 0x96, 0xac, 0x83, 0xe5, 0xf3, 0x42, 0x70, 0x54, 0xf9, 0xf4, 0xd9, + 0xd1, 0xdc, 0xf3, 0x6d, 0x63, 0xaf, 0x2c, 0x74, 0x57, 0xc0, 0xab, 0x27, 0x4f, 0x1f, 0x6f, 0x7a, + 0xbd, 0xe9, 0xf5, 0x7f, 0xeb, 0x75, 0x59, 0xca, 0x56, 0xe7, 0x62, 0x66, 0xeb, 0x97, 0x33, 0x5b, + 0xff, 0x31, 0xb3, 0xf5, 0x0f, 0x73, 0x5b, 0xbb, 0x9c, 0xdb, 0xda, 0xb7, 0xb9, 0xad, 0xbd, 0x69, + 0xde, 0x1a, 0xab, 0x04, 0xd2, 0xbc, 0xde, 0xe6, 0xea, 0x47, 0xad, 0x73, 0x7f, 0xe2, 0x17, 0x5b, + 0x5b, 0x4d, 0xb8, 0xb7, 0xa3, 0xf8, 0xc3, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x06, 0x70, 0x97, + 0xaa, 0x0b, 0x06, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -154,6 +224,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.DeliverTxHookWasmGasLimit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DeliverTxHookWasmGasLimit)) + i-- + dAtA[i] = 0x48 + } if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { for iNdEx := len(m.WhitelistedCwCodeHashesForDelegateCall) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) @@ -163,10 +238,67 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x42 } } - if m.DeliverTxHookWasmGasLimit != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.DeliverTxHookWasmGasLimit)) - i-- - dAtA[i] = 0x28 + { + size := m.MinimumFeePerGas.Size() + i -= size + if _, err := m.MinimumFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.BaseFeePerGas.Size() + i -= size + if _, err := m.BaseFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.PriorityNormalizer.Size() + i -= size + if _, err := m.PriorityNormalizer.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} + +func (m *ParamsPreV580) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamsPreV580) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsPreV580) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for iNdEx := len(m.WhitelistedCwCodeHashesForDelegateCall) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + copy(dAtA[i:], m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]))) + i-- + dAtA[i] = 0x42 + } } { size := m.MinimumFeePerGas.Size() @@ -224,9 +356,30 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = m.MinimumFeePerGas.Size() n += 1 + l + sovParams(uint64(l)) + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { + l = len(b) + n += 1 + l + sovParams(uint64(l)) + } + } if m.DeliverTxHookWasmGasLimit != 0 { n += 1 + sovParams(uint64(m.DeliverTxHookWasmGasLimit)) } + return n +} + +func (m *ParamsPreV580) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PriorityNormalizer.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.BaseFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinimumFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { l = len(b) @@ -373,7 +526,39 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedCwCodeHashesForDelegateCall = append(m.WhitelistedCwCodeHashesForDelegateCall, make([]byte, postIndex-iNdEx)) + copy(m.WhitelistedCwCodeHashesForDelegateCall[len(m.WhitelistedCwCodeHashesForDelegateCall)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DeliverTxHookWasmGasLimit", wireType) } @@ -392,6 +577,158 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ParamsPreV580) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamsPreV580: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsPreV580: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriorityNormalizer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriorityNormalizer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BaseFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinimumFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinimumFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType)