diff --git a/app/ante_handler.go b/app/ante_handler.go index 26cd309..726de88 100644 --- a/app/ante_handler.go +++ b/app/ante_handler.go @@ -3,6 +3,7 @@ package app import ( errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" + circuitante "cosmossdk.io/x/circuit/ante" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" globalfeeante "github.com/OmniFlix/omniflixhub/v5/x/globalfee/ante" @@ -36,6 +37,7 @@ type HandlerOptions struct { GlobalFeeKeeper globalfeekeeper.Keeper StakingKeeper stakingkeeper.Keeper + CircuitKeeper circuitante.CircuitBreaker } func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { @@ -75,6 +77,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { options.FeegrantKeeper, options.TxFeeChecker, ), + circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewSetPubKeyDecorator(options.AccountKeeper), ante.NewValidateSigCountDecorator(options.AccountKeeper), diff --git a/app/app.go b/app/app.go index 9e37270..c63235b 100644 --- a/app/app.go +++ b/app/app.go @@ -263,6 +263,7 @@ func NewOmniFlixApp( BypassMinFeeMsgTypes: GetDefaultBypassFeeMessages(), GlobalFeeKeeper: app.GlobalFeeKeeper, StakingKeeper: *app.StakingKeeper, + CircuitKeeper: &app.CircuitKeeper, }, ) if err != nil { diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index bc08796..712b428 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -44,6 +44,9 @@ import ( crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + circuittypes "cosmossdk.io/x/circuit/types" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -155,6 +158,7 @@ type AppKeepers struct { IBCHooksKeeper ibchookskeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper AuthzKeeper authzkeeper.Keeper + CircuitKeeper circuitkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper GlobalFeeKeeper globalfeekeeper.Keeper GroupKeeper groupkeeper.Keeper @@ -272,6 +276,13 @@ func NewAppKeeper( appKeepers.AccountKeeper, ) + appKeepers.CircuitKeeper = circuitkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[circuittypes.StoreKey]), + govModAddress, + addresscodec.NewBech32Codec(bech32AccountAddressPrefix), + ) + appKeepers.StakingKeeper = stakingkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), diff --git a/app/keepers/keys.go b/app/keepers/keys.go index df0f919..817335b 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -2,6 +2,7 @@ package keepers import ( storetypes "cosmossdk.io/store/types" + circuittypes "cosmossdk.io/x/circuit/types" evidencetypes "cosmossdk.io/x/evidence/types" "cosmossdk.io/x/feegrant" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -58,6 +59,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { capabilitytypes.StoreKey, crisistypes.StoreKey, feegrant.StoreKey, + circuittypes.StoreKey, wasmtypes.StoreKey, globalfeetypes.StoreKey, group.StoreKey, diff --git a/app/modules.go b/app/modules.go index e9b9194..42dc8ae 100644 --- a/app/modules.go +++ b/app/modules.go @@ -3,6 +3,7 @@ package app // sdk v.50.x migration TODO:Eventually should get rid of this in favor of NewBasicManagerFromManager import ( + circuittypes "cosmossdk.io/x/circuit/types" "cosmossdk.io/x/nft" "github.com/CosmWasm/wasmd/x/wasm" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" @@ -43,6 +44,8 @@ import ( "cosmossdk.io/x/feegrant" feegrantmodule "cosmossdk.io/x/feegrant/module" + "cosmossdk.io/x/circuit" + "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -130,6 +133,7 @@ var ( ibchooks.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, authzmodule.AppModuleBasic{}, + circuit.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, @@ -232,6 +236,7 @@ func appModules( ), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + circuit.NewAppModule(appCodec, app.CircuitKeeper), upgrade.NewAppModule(app.UpgradeKeeper, addresscodec.NewBech32Codec(appparams.Bech32AccountAddrPrefix)), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), @@ -339,6 +344,7 @@ func orderBeginBlockers() []string { authtypes.ModuleName, crisistypes.ModuleName, feegrant.ModuleName, + circuittypes.ModuleName, globalfee.ModuleName, tokenfactorytypes.ModuleName, group.ModuleName, @@ -375,6 +381,7 @@ func orderEndBlockers() []string { distrtypes.ModuleName, ibcexported.ModuleName, feegrant.ModuleName, + circuittypes.ModuleName, globalfee.ModuleName, group.ModuleName, tokenfactorytypes.ModuleName, @@ -415,6 +422,7 @@ func orderInitGenesis() []string { upgradetypes.ModuleName, vestingtypes.ModuleName, feegrant.ModuleName, + circuittypes.ModuleName, ibchookstypes.ModuleName, wasmtypes.ModuleName, globalfee.ModuleName, diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go index 41eadca..6ed3512 100644 --- a/app/upgrades/v5/constants.go +++ b/app/upgrades/v5/constants.go @@ -2,6 +2,7 @@ package v5 import ( store "cosmossdk.io/store/types" + circuittypes "cosmossdk.io/x/circuit/types" "github.com/OmniFlix/omniflixhub/v5/app/upgrades" ) @@ -11,6 +12,8 @@ var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateV5UpgradeHandler, StoreUpgrades: store.StoreUpgrades{ - Added: []string{}, + Added: []string{ + circuittypes.StoreKey, + }, }, } diff --git a/go.mod b/go.mod index 4f5d4c2..72805f5 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 + cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/nft v0.1.1