Skip to content

Commit 806afc8

Browse files
authored
Merge pull request #442 from persistenceOne/puneet/signmodetextual
fix: sign mode textual
2 parents 37da440 + 1d8ec16 commit 806afc8

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

app/ante_handler.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
type HandlerOptions struct {
1616
ante.HandlerOptions
1717
IBCKeeper *ibckeeper.Keeper
18+
WasmKeeper *wasmkeeper.Keeper
1819
NodeConfig *wasmtypes.NodeConfig
1920
TXCounterStoreService corestoretypes.KVStoreService
2021

@@ -44,14 +45,12 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
4445
if sigGasConsumer == nil {
4546
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
4647
}
47-
options.SigVerifyOptions = []ante.SigVerificationDecoratorOption{
48-
ante.WithUnorderedTxGasCost(ante.DefaultUnorderedTxGasCost),
49-
ante.WithMaxUnorderedTxTimeoutDuration(ante.DefaultMaxTimeoutDuration),
50-
}
5148
anteDecorators := []sdk.AnteDecorator{
5249
ante.NewSetUpContextDecorator(),
5350
wasmkeeper.NewLimitSimulationGasDecorator(options.NodeConfig.SimulationGasLimit), // after setup context to enforce limits early
5451
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
52+
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
53+
wasmkeeper.NewTxContractsDecorator(),
5554
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
5655
ante.NewValidateBasicDecorator(),
5756
ante.NewTxTimeoutHeightDecorator(),

app/app.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import (
5858
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
5959
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
6060
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
61-
"github.com/cosmos/cosmos-sdk/x/crisis"
6261
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
6362
"github.com/spf13/cast"
6463

@@ -172,11 +171,7 @@ func NewApplication(
172171
}
173172
app.txConfig = txConfig
174173

175-
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
176-
// we prefer to be more strict in what arguments the modules expect.
177-
skipGenesisInvariants := cast.ToBool(applicationOptions.Get(crisis.FlagSkipGenesisInvariants))
178-
179-
app.moduleManager = module.NewManager(appModules(app, app.appCodec, app.txConfig, skipGenesisInvariants)...)
174+
app.moduleManager = module.NewManager(appModules(app, app.appCodec, app.txConfig)...)
180175

181176
app.ModuleBasicManager = module.NewBasicManagerFromManager(app.moduleManager,
182177
map[string]module.AppModuleBasic{
@@ -204,7 +199,7 @@ func NewApplication(
204199

205200
app.simulationManager = module.NewSimulationManagerFromAppModules(
206201
app.moduleManager.Modules,
207-
overrideSimulationModules(app, app.appCodec, skipGenesisInvariants),
202+
overrideSimulationModules(app, app.appCodec),
208203
)
209204
app.simulationManager.RegisterStoreDecoders()
210205

@@ -260,10 +255,15 @@ func (app *Application) setupAnteHandler(nodeConfig wasmtypes.NodeConfig) {
260255
AccountKeeper: app.AccountKeeper,
261256
BankKeeper: app.BankKeeper,
262257
FeegrantKeeper: app.FeegrantKeeper,
263-
SignModeHandler: app.txConfig.SignModeHandler(),
258+
SignModeHandler: app.TxConfig().SignModeHandler(),
264259
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
260+
SigVerifyOptions: []ante.SigVerificationDecoratorOption{
261+
ante.WithUnorderedTxGasCost(ante.DefaultUnorderedTxGasCost),
262+
ante.WithMaxUnorderedTxTimeoutDuration(ante.DefaultMaxTimeoutDuration),
263+
},
265264
},
266265
IBCKeeper: app.IBCKeeper,
266+
WasmKeeper: app.WasmKeeper,
267267
NodeConfig: &nodeConfig,
268268
TXCounterStoreService: runtime.NewKVStoreService(app.GetKVStoreKey()[wasmtypes.StoreKey]),
269269

app/modules.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func appModules(
7878
app *Application,
7979
appCodec codec.Codec,
8080
txCfg client.TxConfig,
81-
skipGenesisInvariants bool,
8281
) []module.AppModule {
8382

8483
return []module.AppModule{
@@ -108,15 +107,14 @@ func appModules(
108107
epochs.NewAppModule(*app.EpochsKeeper),
109108
liquid.NewAppModule(appCodec, app.LiquidKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
110109
liquidstake.NewAppModule(*app.LiquidStakeKeeper),
111-
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
110+
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
112111
ibctm.NewAppModule(app.TMLightClientModule),
113112
}
114113
}
115114

116115
func overrideSimulationModules(
117116
app *Application,
118117
appCodec codec.Codec,
119-
_ bool,
120118
) map[string]module.AppModuleSimulation {
121119
return map[string]module.AppModuleSimulation{
122120
authtypes.ModuleName: auth.NewAppModule(appCodec, *app.AccountKeeper, authsimulation.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),

cmd/persistenceCore/cmd/root.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,33 @@ import (
55
"io"
66
"os"
77

8-
"github.com/cosmos/cosmos-sdk/client"
9-
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
10-
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
11-
"github.com/cosmos/cosmos-sdk/client/snapshot"
12-
"github.com/persistenceOne/persistenceCore/v16/app/constants"
13-
148
"cosmossdk.io/log"
159
confixcmd "cosmossdk.io/tools/confix/cmd"
1610
"github.com/CosmWasm/wasmd/x/wasm"
1711
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
1812
cmtcfg "github.com/cometbft/cometbft/config"
1913
cmtcli "github.com/cometbft/cometbft/libs/cli"
2014
dbm "github.com/cosmos/cosmos-db"
15+
"github.com/cosmos/cosmos-sdk/client"
2116
"github.com/cosmos/cosmos-sdk/client/config"
2217
"github.com/cosmos/cosmos-sdk/client/debug"
2318
"github.com/cosmos/cosmos-sdk/client/flags"
19+
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
20+
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
2421
"github.com/cosmos/cosmos-sdk/client/keys"
2522
"github.com/cosmos/cosmos-sdk/client/pruning"
2623
"github.com/cosmos/cosmos-sdk/client/rpc"
24+
"github.com/cosmos/cosmos-sdk/client/snapshot"
2725
"github.com/cosmos/cosmos-sdk/server"
2826
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
2927
servertypes "github.com/cosmos/cosmos-sdk/server/types"
3028
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
3129
sdk "github.com/cosmos/cosmos-sdk/types"
30+
"github.com/cosmos/cosmos-sdk/types/tx/signing"
3231
"github.com/cosmos/cosmos-sdk/version"
3332
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
33+
"github.com/cosmos/cosmos-sdk/x/auth/tx"
34+
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
3435
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
3536
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
3637
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
@@ -40,6 +41,7 @@ import (
4041
"github.com/spf13/cobra"
4142

4243
"github.com/persistenceOne/persistenceCore/v16/app"
44+
"github.com/persistenceOne/persistenceCore/v16/app/constants"
4345
"github.com/persistenceOne/persistenceCore/v16/app/params"
4446
)
4547

@@ -67,7 +69,6 @@ func NewRootCmd() *cobra.Command {
6769
WithLegacyAmino(tempApp.LegacyAmino()).
6870
WithInput(os.Stdin).
6971
WithAccountRetriever(authtypes.AccountRetriever{}).
70-
WithBroadcastMode(flags.BroadcastSync).
7172
WithHomeDir(app.DefaultNodeHome).
7273
WithViper("")
7374

@@ -80,6 +81,7 @@ func NewRootCmd() *cobra.Command {
8081
cmd.SetOut(cmd.OutOrStdout())
8182
cmd.SetErr(cmd.ErrOrStderr())
8283

84+
initClientCtx = initClientCtx.WithCmdContext(cmd.Context())
8385
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
8486
if err != nil {
8587
return err
@@ -89,6 +91,22 @@ func NewRootCmd() *cobra.Command {
8991
if err != nil {
9092
return err
9193
}
94+
if !initClientCtx.Offline {
95+
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
96+
txConfigOpts := tx.ConfigOptions{
97+
EnabledSignModes: enabledSignModes,
98+
TextualCoinMetadataQueryFn: authtxconfig.NewGRPCCoinMetadataQueryFn(initClientCtx),
99+
}
100+
txConfig, err := tx.NewTxConfigWithOptions(
101+
initClientCtx.Codec,
102+
txConfigOpts,
103+
)
104+
if err != nil {
105+
return err
106+
}
107+
108+
initClientCtx = initClientCtx.WithTxConfig(txConfig)
109+
}
92110

93111
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
94112
return err

0 commit comments

Comments
 (0)