Skip to content

Commit

Permalink
Fixes for ante, wasm_config and genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
Satchitananda committed Nov 26, 2023
1 parent 9dae82c commit b2fde24
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
39 changes: 30 additions & 9 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package odin

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
Expand Down Expand Up @@ -121,25 +120,47 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

// anteDecorators := []sdk.AnteDecorator{
// ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
// NewMinCommissionDecorator(options.Cdc),
// wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
// wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
// ante.NewRejectExtensionOptionsDecorator(),
// ante.NewMempoolFeeDecorator(),
// ante.NewValidateBasicDecorator(),
// ante.NewTxTimeoutHeightDecorator(),
// ante.NewValidateMemoDecorator(options.AccountKeeper),
// ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
// ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
// // SetPubKeyDecorator must be called before all signature verification decorators
// ante.NewSetPubKeyDecorator(options.AccountKeeper),
// ante.NewValidateSigCountDecorator(options.AccountKeeper),
// ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
// ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
// ante.NewIncrementSequenceDecorator(options.AccountKeeper),
// ibcante.NewAnteDecorator(options.IBCKeeper),
// }

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
NewMinCommissionDecorator(options.Cdc),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
ante.NewDeductFeeDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeegrantKeeper,
options.TxFeeChecker,
),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
11 changes: 7 additions & 4 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
ibctypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"

distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

Expand Down Expand Up @@ -42,6 +42,7 @@ import (
coinswaptypes "github.com/ODIN-PROTOCOL/odin-core/x/coinswap/types"
minttypes "github.com/ODIN-PROTOCOL/odin-core/x/mint/types"
oracletypes "github.com/ODIN-PROTOCOL/odin-core/x/oracle/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)

// GenesisState defines a type alias for the Odin genesis application state.
Expand All @@ -56,7 +57,7 @@ func NewDefaultGenesisState() GenesisState {
stakingGenesis := stakingtypes.DefaultGenesisState()
distrGenesis := distrtypes.DefaultGenesisState()
mintGenesis := minttypes.DefaultGenesisState()
govGenesis := govtypes.DefaultGenesisState()
govGenesis := govv1.DefaultGenesisState()
crisisGenesis := crisistypes.DefaultGenesisState()
slashingGenesis := slashingtypes.DefaultGenesisState()
oracleGenesis := oracletypes.DefaultGenesisState()
Expand All @@ -71,7 +72,9 @@ func NewDefaultGenesisState() GenesisState {
mintGenesis.Params.MintDenom = denom
mintGenesis.Params.MintAir = true

govGenesis.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(denom, sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)))
govGenesis.Params.MinDeposit = sdk.NewCoins(
sdk.NewCoin(denom, sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)),
)
crisisGenesis.ConstantFee = sdk.NewCoin(denom, sdk.TokensFromConsensusPower(10000, sdk.DefaultPowerReduction))
slashingGenesis.Params.SignedBlocksWindow = 30000 // approximately 1 day
slashingGenesis.Params.MinSignedPerWindow = sdk.NewDecWithPrec(5, 2) // 5%
Expand All @@ -91,7 +94,7 @@ func NewDefaultGenesisState() GenesisState {
govtypes.ModuleName: cdc.MustMarshalJSON(govGenesis),
crisistypes.ModuleName: cdc.MustMarshalJSON(crisisGenesis),
slashingtypes.ModuleName: cdc.MustMarshalJSON(slashingGenesis),
ibchost.ModuleName: ibc.AppModuleBasic{}.DefaultGenesis(cdc),
ibcexported.ModuleName: ibc.AppModuleBasic{}.DefaultGenesis(cdc),
upgradetypes.ModuleName: upgrade.AppModuleBasic{}.DefaultGenesis(cdc),
evidencetypes.ModuleName: evidence.AppModuleBasic{}.DefaultGenesis(cdc),
authz.ModuleName: authzmodule.AppModuleBasic{}.DefaultGenesis(cdc),
Expand Down
10 changes: 5 additions & 5 deletions app/wasm_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package odin

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)

const (
Expand All @@ -12,14 +12,14 @@ const (
)

// GasRegisterConfig is defaults plus a custom compile amount
func GasRegisterConfig() wasmkeeper.WasmGasRegisterConfig {
gasConfig := wasmkeeper.DefaultGasRegisterConfig()
func GasRegisterConfig() wasmtypes.WasmGasRegisterConfig {
gasConfig := wasmtypes.DefaultGasRegisterConfig()
gasConfig.InstanceCost = DefaultInstanceCost
gasConfig.CompileCost = DefaultCompileCost

return gasConfig
}

func NewWasmGasRegister() wasmkeeper.WasmGasRegister {
return wasmkeeper.NewWasmGasRegister(GasRegisterConfig())
func NewWasmGasRegister() wasmtypes.WasmGasRegister {
return wasmtypes.NewWasmGasRegister(GasRegisterConfig())
}

0 comments on commit b2fde24

Please sign in to comment.