Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ import (
"github.com/sei-protocol/sei-chain/sei-cosmos/x/capability"
capabilitykeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/capability/keeper"
capabilitytypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/capability/types"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis"
crisiskeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis/keeper"
crisistypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis/types"
distr "github.com/sei-protocol/sei-chain/sei-cosmos/x/distribution"
distrclient "github.com/sei-protocol/sei-chain/sei-cosmos/x/distribution/client"
distrkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/distribution/keeper"
Expand Down Expand Up @@ -166,7 +163,6 @@ import (
tokenfactorymodule "github.com/sei-protocol/sei-chain/x/tokenfactory"
tokenfactorykeeper "github.com/sei-protocol/sei-chain/x/tokenfactory/keeper"
tokenfactorytypes "github.com/sei-protocol/sei-chain/x/tokenfactory/types"
"github.com/spf13/cast"
dbm "github.com/tendermint/tm-db"
"go.opentelemetry.io/otel/attribute"
otelmetric "go.opentelemetry.io/otel/metric"
Expand Down Expand Up @@ -229,7 +225,6 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()...),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
Expand Down Expand Up @@ -389,8 +384,6 @@ type App struct {
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint

// keys to access the substores
keys map[string]*sdk.KVStoreKey
tkeys map[string]*sdk.TransientStoreKey
Expand All @@ -407,7 +400,6 @@ type App struct {
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
Expand Down Expand Up @@ -504,7 +496,7 @@ func New(
_ bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
_ uint,
enableCustomEVMPrecompiles bool,
tmConfig *tmcfg.Config,
encodingConfig appparams.EncodingConfig,
Expand Down Expand Up @@ -539,7 +531,6 @@ func New(
cdc: cdc,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
Expand Down Expand Up @@ -597,9 +588,6 @@ func New(
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
)
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
Expand Down Expand Up @@ -869,12 +857,6 @@ func New(
app.EvmKeeper.SetCustomPrecompiles(customPrecompiles, LatestUpgrade)
}

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.

Expand All @@ -888,7 +870,6 @@ func New(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -920,7 +901,6 @@ func New(
EvmKeeper: &app.EvmKeeper,
}
app.EndBlockKeepers = legacyabci.EndBlockKeepers{
CrisisKeeper: &app.CrisisKeeper,
Comment thread
cursor[bot] marked this conversation as resolved.
GovKeeper: &app.GovKeeper,
StakingKeeper: &app.StakingKeeper,
OracleKeeper: &app.OracleKeeper,
Expand Down Expand Up @@ -967,7 +947,6 @@ func New(
govtypes.ModuleName,
minttypes.ModuleName,
vestingtypes.ModuleName,
crisistypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
Expand All @@ -982,7 +961,6 @@ func New(
// this line is used by starport scaffolding # stargate/app/initGenesis
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)
Expand Down Expand Up @@ -2865,7 +2843,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
Expand Down
3 changes: 0 additions & 3 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
allowedAddrsMap[addr] = true
}

/* Just to be safe, assert the invariants on current state. */
app.CrisisKeeper.AssertInvariants(ctx)

/* Handle fee distribution state. */

// withdraw all validator commission
Expand Down
4 changes: 0 additions & 4 deletions app/legacyabci/end_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package legacyabci

import (
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis"
crisiskeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis/keeper"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/gov"
govkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/gov/keeper"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/staking"
Expand All @@ -15,15 +13,13 @@ import (
)

type EndBlockKeepers struct {
CrisisKeeper *crisiskeeper.Keeper
GovKeeper *govkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
OracleKeeper *oraclekeeper.Keeper
EvmKeeper *evmkeeper.Keeper
}

func EndBlock(ctx sdk.Context, height int64, blockGasUsed int64, keepers EndBlockKeepers) []abci.ValidatorUpdate {
crisis.EndBlocker(ctx, *keepers.CrisisKeeper)
gov.EndBlocker(ctx, *keepers.GovKeeper)
vals := staking.EndBlocker(ctx, *keepers.StakingKeeper)
oracle.EndBlocker(ctx, *keepers.OracleKeeper)
Expand Down
5 changes: 1 addition & 4 deletions cmd/seid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
authcmd "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/client/cli"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/types"
banktypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/bank/types"
"github.com/sei-protocol/sei-chain/sei-cosmos/x/crisis"
genutilcli "github.com/sei-protocol/sei-chain/sei-cosmos/x/genutil/client/cli"
seidbconfig "github.com/sei-protocol/sei-chain/sei-db/config"
tmcfg "github.com/sei-protocol/sei-chain/sei-tendermint/config"
Expand Down Expand Up @@ -219,9 +218,7 @@ func txCommand() *cobra.Command {
return cmd
}

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
}
func addModuleInitFlags(_ *cobra.Command) {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed CLI flag breaks operators using it

Medium Severity

The --x-crisis-skip-assert-invariants flag is silently removed by making addModuleInitFlags a no-op. Any operator who has this flag in their seid start command (e.g. in a systemd unit file or launch script) will get an "unknown flag" error from cobra, preventing the node from starting after the upgrade. As the PR reviewer noted, a graceful deprecation (accepting the flag as a no-op with a warning) would avoid unexpected startup failures.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 667afb9. Configure here.


// newApp creates a new Cosmos SDK app
func newApp(
Expand Down
1 change: 0 additions & 1 deletion docker/localnode/scripts/step2_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ override_genesis() {
cat ~/.sei/config/genesis.json | jq "$1" > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json;
}

override_genesis '.app_state["crisis"]["constant_fee"]["denom"]="usei"'
override_genesis '.app_state["mint"]["params"]["mint_denom"]="usei"'
override_genesis '.app_state["staking"]["params"]["bond_denom"]="usei"'
override_genesis '.app_state["oracle"]["params"]["vote_period"]="2"'
Expand Down
2 changes: 1 addition & 1 deletion scripts/dump_app_state_for_height.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
cd $HOME
sudo rm -r state_$HEIGHT
mkdir state_$HEIGHT
for key in wasm oracle epoch mint acc bank crisis feegrant staking distribution slashing gov params ibc upgrade evidence transfer tokenfactory
for key in wasm oracle epoch mint acc bank feegrant staking distribution slashing gov params ibc upgrade evidence transfer tokenfactory
do
$HOME/go/bin/iaviewer data $HOME/.sei/data/application.db "s/k:"$key"/" $HEIGHT > $HOME/state_$HEIGHT/$key.data
$HOME/go/bin/iaviewer shape $HOME/.sei/data/application.db "s/k:"$key"/" $HEIGHT > $HOME/state_$HEIGHT/$key.shape
Expand Down
17 changes: 0 additions & 17 deletions sei-cosmos/proto/cosmos/crisis/v1beta1/genesis.proto

This file was deleted.

25 changes: 0 additions & 25 deletions sei-cosmos/proto/cosmos/crisis/v1beta1/tx.proto

This file was deleted.

22 changes: 20 additions & 2 deletions sei-cosmos/types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,27 @@ func (bm BasicManager) ValidateGenesis(cdc codec.JSONCodec, txEncCfg client.TxEn

// ValidateGenesisStream performs genesis state validation on all modules in a streaming fashion.
func (bm BasicManager) ValidateGenesisStream(cdc codec.JSONCodec, txEncCfg client.TxEncodingConfig, moduleName string, genesisCh <-chan json.RawMessage, doneCh <-chan struct{}, errCh chan<- error) {
module, ok := bm[moduleName]
if !ok {
for {
select {
case <-doneCh:
return
case _, ok := <-genesisCh:
if !ok {
return
}
}
}
}

moduleGenesisCh := make(chan json.RawMessage)
moduleDoneCh := make(chan struct{})

var err error

go func() {
err = bm[moduleName].ValidateGenesisStream(cdc, txEncCfg, moduleGenesisCh)
err = module.ValidateGenesisStream(cdc, txEncCfg, moduleGenesisCh)
if err != nil {
errCh <- err
}
Expand Down Expand Up @@ -378,11 +392,15 @@ func (m *Manager) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, genesisData
if moduleName == "genesisDoc" {
continue
}
module, ok := m.Modules[moduleName]
if !ok {
continue
}
if seenModules[moduleName] {
errCh <- fmt.Errorf("module %s seen twice in genesis file", moduleName)
return
}
moduleValUpdates := m.Modules[moduleName].InitGenesis(ctx, cdc, moduleState.AppState.Data)
moduleValUpdates := module.InitGenesis(ctx, cdc, moduleState.AppState.Data)
if len(moduleValUpdates) > 0 {
if len(validatorUpdates) > 0 {
panic("validator InitGenesis updates already set by a previous module")
Expand Down
64 changes: 64 additions & 0 deletions sei-cosmos/types/module/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package module_test
import (
"encoding/json"
"errors"
"os"
"testing"
"time"

tmproto "github.com/sei-protocol/sei-chain/sei-tendermint/proto/tendermint/types"

Expand Down Expand Up @@ -69,6 +71,34 @@ func TestBasicManager(t *testing.T) {
require.Nil(t, module.NewBasicManager().ValidateGenesis(cdc, nil, wantDefaultGenesis))
}

func TestBasicManagerValidateGenesisStreamSkipsUnknownModules(t *testing.T) {
genesisCh := make(chan json.RawMessage)
doneCh := make(chan struct{})
errCh := make(chan error, 1)
completed := make(chan struct{})

go func() {
module.NewBasicManager().ValidateGenesisStream(nil, nil, "crisis", genesisCh, doneCh, errCh)
close(completed)
}()

select {
case genesisCh <- json.RawMessage(`{"constant_fee":{"denom":"usei","amount":"1000"}}`):
case <-time.After(time.Second):
t.Fatal("timed out sending unknown module genesis")
}

close(doneCh)

select {
case <-completed:
case err := <-errCh:
require.NoError(t, err)
case <-time.After(time.Second):
t.Fatal("timed out waiting for unknown module genesis validation to finish")
}
}

func TestGenesisOnlyAppModule(t *testing.T) {
mockCtrl := gomock.NewController(t)
t.Cleanup(mockCtrl.Finish)
Expand Down Expand Up @@ -213,6 +243,40 @@ func TestManager_InitGenesis(t *testing.T) {
require.Panics(t, func() { mm.InitGenesis(ctx, cdc, genesisData, genesis.GenesisImportConfig{}) })
}

func TestManager_InitGenesisStreamSkipsUnknownModules(t *testing.T) {
mockCtrl := gomock.NewController(t)
t.Cleanup(mockCtrl.Finish)

mockAppModule := mocks.NewMockAppModule(mockCtrl)
mockAppModule.EXPECT().Name().Times(2).Return("module1")
mm := module.NewManager(mockAppModule)

ctx := sdk.Context{}
interfaceRegistry := types.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
moduleData := json.RawMessage(`{"key": "value"}`)
genesisFile := t.TempDir() + "/genesis.json"
require.NoError(t, os.WriteFile(
genesisFile,
[]byte(
`{"app_state":{"module":"crisis","data":{"constant_fee":{"denom":"usei","amount":"1000"}}}}`+"\n"+
`{"app_state":{"module":"module1","data":`+string(moduleData)+`}}`+"\n",
),
0o600,
))

mockAppModule.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(moduleData)).Times(1).Return(nil)

require.Equal(
t,
abci.ResponseInitChain{Validators: []abci.ValidatorUpdate(nil)},
mm.InitGenesis(ctx, cdc, nil, genesis.GenesisImportConfig{
StreamGenesisImport: true,
GenesisStreamFile: genesisFile,
}),
)
}

func TestManager_ExportGenesis(t *testing.T) {
mockCtrl := gomock.NewController(t)
t.Cleanup(mockCtrl.Finish)
Expand Down
1 change: 0 additions & 1 deletion sei-cosmos/x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Here are some production-grade modules that can be used in Cosmos SDK applicatio
- [Authz](authz/spec/README.md) - Authorization for accounts to perform actions on behalf of other accounts.
- [Bank](bank/spec/README.md) - Token transfer functionalities.
- [Capability](capability/spec/README.md) - Object capability implementation.
- [Crisis](crisis/spec/README.md) - Halting the blockchain under certain circumstances (e.g. if an invariant is broken).
- [Distribution](distribution/spec/README.md) - Fee distribution, and staking token provision distribution.
- [Evidence](evidence/spec/README.md) - Evidence handling for double signing, misbehaviour, etc.
- [Governance](gov/spec/README.md) - On-chain proposals and voting.
Expand Down
21 changes: 0 additions & 21 deletions sei-cosmos/x/crisis/abci.go

This file was deleted.

Loading