From f66d4d15ead2c5ac582da94b7628e12bf26dde29 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:59:18 +0330 Subject: [PATCH 1/2] fix: deduct tx fees --- app/ante.go | 5 ++++- app/app.go | 3 ++- app/keepers/keepers.go | 2 +- app/modules.go | 12 ++++++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/ante.go b/app/ante.go index 7f4afcaf..c5917e34 100644 --- a/app/ante.go +++ b/app/ante.go @@ -28,7 +28,8 @@ type HandlerOptions struct { IBCKeeper *ibckeeper.Keeper BankKeeper bankkeeper.Keeper TxCounterStoreKey storetypes.StoreKey - WasmConfig wasmtypes.WasmConfig + WasmConfig *wasmtypes.WasmConfig + WasmKeeper *wasmkeeper.Keeper Cdc codec.BinaryCodec StakingKeeper stakingkeeper.Keeper @@ -60,11 +61,13 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey), + wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewSetPubKeyDecorator(options.AccountKeeper), diff --git a/app/app.go b/app/app.go index 8217e740..982c34b7 100644 --- a/app/app.go +++ b/app/app.go @@ -255,7 +255,8 @@ func NewSgeApp( IBCKeeper: app.AppKeepers.IBCKeeper, BankKeeper: app.AppKeepers.BankKeeper, TxCounterStoreKey: app.AppKeepers.GetKey(wasmtypes.StoreKey), - WasmConfig: wasmConfig, + WasmConfig: &wasmConfig, + WasmKeeper: &app.WasmKeeper, Cdc: appCodec, StakingKeeper: *app.AppKeepers.StakingKeeper, diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 5b9728a8..c2a05ba8 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -440,7 +440,7 @@ func NewAppKeeper( ContractDebugMode: false, } - wasmCapabilities := "iterator,staking,stargate" + wasmCapabilities := "iterator,staking,stargate,cosmwasm_1_1" appKeepers.WasmKeeper = wasmkeeper.NewKeeper( appCodec, diff --git a/app/modules.go b/app/modules.go index e3aa6c99..e426a7dd 100644 --- a/app/modules.go +++ b/app/modules.go @@ -90,7 +90,7 @@ var mAccPerms = map[string][]string{ icatypes.ModuleName: nil, // cosmwasm - wasmtypes.ModuleName: {}, + wasmtypes.ModuleName: {authtypes.Burner}, // sge betmoduletypes.BetFeeCollectorFunder{}.GetModuleAcc(): nil, @@ -199,7 +199,15 @@ func appModules( app.BankKeeper, app.interfaceRegistry, ), - wasm.NewAppModule(appCodec, &app.AppKeepers.WasmKeeper, app.AppKeepers.StakingKeeper, app.AppKeepers.AccountKeeper, app.AppKeepers.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), + wasm.NewAppModule( + appCodec, + &app.AppKeepers.WasmKeeper, + app.AppKeepers.StakingKeeper, + app.AppKeepers.AccountKeeper, + app.AppKeepers.BankKeeper, + app.MsgServiceRouter(), + app.GetSubspace(wasmtypes.ModuleName), + ), app.IBCModule, params.NewAppModule(app.ParamsKeeper), app.TransferModule, From 4ddf6c97690ebaeb405d952cce5463a41dc385dc Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:17:16 +0330 Subject: [PATCH 2/2] fix: add wasmconfig check --- app/ante.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/ante.go b/app/ante.go index c5917e34..098f62ac 100644 --- a/app/ante.go +++ b/app/ante.go @@ -51,6 +51,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") } + if options.WasmConfig == nil { + return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder") + } + sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { sigGasConsumer = ante.DefaultSigVerificationGasConsumer