Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the circuit breaker module. #2031

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ linters-settings:
- cosmossdk.io/log
- cosmossdk.io/math
- cosmossdk.io/store
- cosmossdk.io/x/circuit
- cosmossdk.io/x/evidence
- cosmossdk.io/x/feegrant
- cosmossdk.io/x/tx/signing
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Bump wasmd to `v0.50.0` [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Update stargate queries for Attribute, Exchange, Marker, IBCRateLimit, Metadata, Msgfees, and Oracle modules [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Update stargate queries for Quarantine and Sanction modules [#2016](https://github.com/provenance-io/provenance/pull/2016).
* Add the circuit breaker module [#2031](https://github.com/provenance-io/provenance/pull/2031).

### Improvements

Expand Down
13 changes: 12 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/circuit"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
circuittypes "cosmossdk.io/x/circuit/types"
"cosmossdk.io/x/evidence"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
evidencetypes "cosmossdk.io/x/evidence/types"
Expand Down Expand Up @@ -249,6 +252,7 @@ type App struct {
BankKeeper bankkeeper.BaseKeeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
CircuitKeeper circuitkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
Expand Down Expand Up @@ -360,7 +364,7 @@ func New(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, consensusparamtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey, circuittypes.StoreKey,
authzkeeper.StoreKey, group.StoreKey, crisistypes.StoreKey,

ibcexported.StoreKey,
Expand Down Expand Up @@ -465,6 +469,9 @@ func New(
appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, govAuthority, authcodec.NewBech32Codec(valAddrPrefix), authcodec.NewBech32Codec(consAddrPrefix),
)

app.CircuitKeeper = circuitkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[circuittypes.StoreKey]), govAuthority, app.AccountKeeper.AddressCodec())
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)

app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, govAuthority)

app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, govAuthority)
Expand Down Expand Up @@ -765,6 +772,7 @@ func New(
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
circuit.NewAppModule(appCodec, app.CircuitKeeper),

// PROVENANCE
metadata.NewAppModule(appCodec, app.MetadataKeeper, app.AccountKeeper),
Expand Down Expand Up @@ -873,6 +881,7 @@ func New(
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,

quarantine.ModuleName,
sanction.ModuleName,
Expand Down Expand Up @@ -921,6 +930,7 @@ func New(
hold.ModuleName,
exchange.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,

ibcratelimit.ModuleName,
ibchookstypes.ModuleName,
Expand Down Expand Up @@ -1001,6 +1011,7 @@ func (app *App) setAnteHandler() {
TxSigningHandlerMap: app.txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
MsgFeesKeeper: app.MsgFeesKeeper,
CircuitKeeper: &app.CircuitKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
})
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

storetypes "cosmossdk.io/store/types"
circuittypes "cosmossdk.io/x/circuit/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -50,7 +51,7 @@ type appUpgrade struct {
// or vice versa, please add comments explaining why in both entries.
var upgrades = map[string]appUpgrade{
"umber-rc1": { // upgrade for v1.19.0-rc1
Added: []string{crisistypes.ModuleName},
Added: []string{crisistypes.ModuleName, circuittypes.ModuleName},
Deleted: []string{"reward"},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
Expand Down Expand Up @@ -89,7 +90,7 @@ var upgrades = map[string]appUpgrade{
},
},
"umber": { // upgrade for v1.19.0
Added: []string{crisistypes.ModuleName},
Added: []string{crisistypes.ModuleName, circuittypes.ModuleName},
Deleted: []string{"reward"},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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.0
cosmossdk.io/x/evidence v0.1.1
cosmossdk.io/x/feegrant v0.1.1
cosmossdk.io/x/tx v0.13.3
Expand Down Expand Up @@ -55,7 +56,6 @@ require (
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/x/circuit v0.1.0 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down
5 changes: 4 additions & 1 deletion internal/antewrapper/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package antewrapper

import (
storetypes "cosmossdk.io/store/types"
circuitante "cosmossdk.io/x/circuit/ante"
txsigning "cosmossdk.io/x/tx/signing"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -21,6 +22,7 @@ type HandlerOptions struct {
ExtensionOptionChecker cosmosante.ExtensionOptionChecker
FeegrantKeeper msgfeestypes.FeegrantKeeper
MsgFeesKeeper msgfeestypes.MsgFeesKeeper
CircuitKeeper circuitante.CircuitBreaker
TxSigningHandlerMap *txsigning.HandlerMap
SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params types.Params) error
}
Expand All @@ -45,7 +47,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

decorators := []sdk.AnteDecorator{
cosmosante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
NewFeeMeterContextDecorator(), // NOTE : fee gas meter also has the functionality of GasTracerContextDecorator in previous versions
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
NewFeeMeterContextDecorator(), // NOTE : fee gas meter also has the functionality of GasTracerContextDecorator in previous versions
NewTxGasLimitDecorator(),
NewMinGasPricesDecorator(),
NewMsgFeesDecorator(options.MsgFeesKeeper),
Expand Down
1 change: 1 addition & 0 deletions internal/antewrapper/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (s *AnteTestSuite) SetupTest(isCheckTx bool) {
TxSigningHandlerMap: s.encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
MsgFeesKeeper: s.app.MsgFeesKeeper,
CircuitKeeper: &s.app.CircuitKeeper,
},
)

Expand Down
Loading