diff --git a/app/ante_handler.go b/app/ante_handler.go index f6dce768..0316247c 100644 --- a/app/ante_handler.go +++ b/app/ante_handler.go @@ -15,6 +15,7 @@ import ( type HandlerOptions struct { ante.HandlerOptions IBCKeeper *ibckeeper.Keeper + WasmKeeper *wasmkeeper.Keeper NodeConfig *wasmtypes.NodeConfig TXCounterStoreService corestoretypes.KVStoreService @@ -44,14 +45,12 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { if sigGasConsumer == nil { sigGasConsumer = ante.DefaultSigVerificationGasConsumer } - options.SigVerifyOptions = []ante.SigVerificationDecoratorOption{ - ante.WithUnorderedTxGasCost(ante.DefaultUnorderedTxGasCost), - ante.WithMaxUnorderedTxTimeoutDuration(ante.DefaultMaxTimeoutDuration), - } anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), wasmkeeper.NewLimitSimulationGasDecorator(options.NodeConfig.SimulationGasLimit), // after setup context to enforce limits early wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService), + wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), + wasmkeeper.NewTxContractsDecorator(), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), diff --git a/app/app.go b/app/app.go index 34e41bc5..7635ff49 100644 --- a/app/app.go +++ b/app/app.go @@ -58,7 +58,6 @@ import ( authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/crisis" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/spf13/cast" @@ -172,11 +171,7 @@ func NewApplication( } app.txConfig = txConfig - // 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(applicationOptions.Get(crisis.FlagSkipGenesisInvariants)) - - app.moduleManager = module.NewManager(appModules(app, app.appCodec, app.txConfig, skipGenesisInvariants)...) + app.moduleManager = module.NewManager(appModules(app, app.appCodec, app.txConfig)...) app.ModuleBasicManager = module.NewBasicManagerFromManager(app.moduleManager, map[string]module.AppModuleBasic{ @@ -204,7 +199,7 @@ func NewApplication( app.simulationManager = module.NewSimulationManagerFromAppModules( app.moduleManager.Modules, - overrideSimulationModules(app, app.appCodec, skipGenesisInvariants), + overrideSimulationModules(app, app.appCodec), ) app.simulationManager.RegisterStoreDecoders() @@ -260,10 +255,15 @@ func (app *Application) setupAnteHandler(nodeConfig wasmtypes.NodeConfig) { AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, FeegrantKeeper: app.FeegrantKeeper, - SignModeHandler: app.txConfig.SignModeHandler(), + SignModeHandler: app.TxConfig().SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + SigVerifyOptions: []ante.SigVerificationDecoratorOption{ + ante.WithUnorderedTxGasCost(ante.DefaultUnorderedTxGasCost), + ante.WithMaxUnorderedTxTimeoutDuration(ante.DefaultMaxTimeoutDuration), + }, }, IBCKeeper: app.IBCKeeper, + WasmKeeper: app.WasmKeeper, NodeConfig: &nodeConfig, TXCounterStoreService: runtime.NewKVStoreService(app.GetKVStoreKey()[wasmtypes.StoreKey]), diff --git a/app/modules.go b/app/modules.go index 4a5db765..dde94995 100644 --- a/app/modules.go +++ b/app/modules.go @@ -78,7 +78,6 @@ func appModules( app *Application, appCodec codec.Codec, txCfg client.TxConfig, - skipGenesisInvariants bool, ) []module.AppModule { return []module.AppModule{ @@ -108,7 +107,7 @@ func appModules( epochs.NewAppModule(*app.EpochsKeeper), liquid.NewAppModule(appCodec, app.LiquidKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), liquidstake.NewAppModule(*app.LiquidStakeKeeper), - crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them + crisis.NewAppModule(app.CrisisKeeper, false, app.GetSubspace(crisistypes.ModuleName)), // skipGenesisInvariants: false, always be last to make sure that it checks for all invariants and not only part of them ibctm.NewAppModule(app.TMLightClientModule), } } @@ -116,7 +115,6 @@ func appModules( func overrideSimulationModules( app *Application, appCodec codec.Codec, - _ bool, ) map[string]module.AppModuleSimulation { return map[string]module.AppModuleSimulation{ authtypes.ModuleName: auth.NewAppModule(appCodec, *app.AccountKeeper, authsimulation.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), diff --git a/cmd/persistenceCore/cmd/root.go b/cmd/persistenceCore/cmd/root.go index 554b2222..0bd8759c 100644 --- a/cmd/persistenceCore/cmd/root.go +++ b/cmd/persistenceCore/cmd/root.go @@ -5,12 +5,6 @@ import ( "io" "os" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" - nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/snapshot" - "github.com/persistenceOne/persistenceCore/v16/app/constants" - "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/CosmWasm/wasmd/x/wasm" @@ -18,19 +12,26 @@ import ( cmtcfg "github.com/cometbft/cometbft/config" cmtcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/client/snapshot" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/version" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" @@ -40,6 +41,7 @@ import ( "github.com/spf13/cobra" "github.com/persistenceOne/persistenceCore/v16/app" + "github.com/persistenceOne/persistenceCore/v16/app/constants" "github.com/persistenceOne/persistenceCore/v16/app/params" ) @@ -67,7 +69,6 @@ func NewRootCmd() *cobra.Command { WithLegacyAmino(tempApp.LegacyAmino()). WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). - WithBroadcastMode(flags.BroadcastSync). WithHomeDir(app.DefaultNodeHome). WithViper("") @@ -80,6 +81,7 @@ func NewRootCmd() *cobra.Command { cmd.SetOut(cmd.OutOrStdout()) cmd.SetErr(cmd.ErrOrStderr()) + initClientCtx = initClientCtx.WithCmdContext(cmd.Context()) initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) if err != nil { return err @@ -89,6 +91,22 @@ func NewRootCmd() *cobra.Command { if err != nil { return err } + if !initClientCtx.Offline { + enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfig, err := tx.NewTxConfigWithOptions( + initClientCtx.Codec, + txConfigOpts, + ) + if err != nil { + return err + } + + initClientCtx = initClientCtx.WithTxConfig(txConfig) + } if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err