Integrate slashing module in the app #53
@ -34,6 +34,7 @@ import (
|
|||||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||||
|
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
||||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||||
|
|
||||||
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
|
||||||
@ -48,6 +49,7 @@ import (
|
|||||||
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
|
||||||
|
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
|
||||||
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
|
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,6 +78,7 @@ type LaconicApp struct {
|
|||||||
AccountKeeper authkeeper.AccountKeeper
|
AccountKeeper authkeeper.AccountKeeper
|
||||||
BankKeeper bankkeeper.Keeper
|
BankKeeper bankkeeper.Keeper
|
||||||
StakingKeeper *stakingkeeper.Keeper
|
StakingKeeper *stakingkeeper.Keeper
|
||||||
|
SlashingKeeper slashingkeeper.Keeper
|
||||||
DistrKeeper distrkeeper.Keeper
|
DistrKeeper distrkeeper.Keeper
|
||||||
CrisisKeeper *crisiskeeper.Keeper
|
CrisisKeeper *crisiskeeper.Keeper
|
||||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||||
@ -142,6 +145,7 @@ func NewLaconicApp(
|
|||||||
&app.AccountKeeper,
|
&app.AccountKeeper,
|
||||||
&app.BankKeeper,
|
&app.BankKeeper,
|
||||||
&app.StakingKeeper,
|
&app.StakingKeeper,
|
||||||
|
&app.SlashingKeeper,
|
||||||
&app.DistrKeeper,
|
&app.DistrKeeper,
|
||||||
&app.CrisisKeeper,
|
&app.CrisisKeeper,
|
||||||
&app.ConsensusParamsKeeper,
|
&app.ConsensusParamsKeeper,
|
||||||
|
@ -6,11 +6,11 @@ modules:
|
|||||||
# During begin block slashing happens after distr.BeginBlocker so that
|
# During begin block slashing happens after distr.BeginBlocker so that
|
||||||
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
# there is nothing left over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.
|
||||||
# NOTE: staking module is required if HistoricalEntries param > 0
|
# NOTE: staking module is required if HistoricalEntries param > 0
|
||||||
begin_blockers: [distribution, staking]
|
begin_blockers: [distribution, slashing, staking]
|
||||||
end_blockers: [crisis, staking, auction, registry]
|
end_blockers: [crisis, staking, auction, registry]
|
||||||
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
|
||||||
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
|
||||||
init_genesis: [auth, bank, distribution, staking, crisis, genutil, auction, bond, registry, onboarding]
|
init_genesis: [auth, bank, distribution, staking, slashing, crisis, genutil, auction, bond, registry, onboarding]
|
||||||
override_store_keys:
|
override_store_keys:
|
||||||
- module_name: auth
|
- module_name: auth
|
||||||
kv_store_key: acc
|
kv_store_key: acc
|
||||||
@ -39,6 +39,9 @@ modules:
|
|||||||
- name: staking
|
- name: staking
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.staking.module.v1.Module
|
"@type": cosmos.staking.module.v1.Module
|
||||||
|
- name: slashing
|
||||||
|
config:
|
||||||
|
"@type": cosmos.slashing.module.v1.Module
|
||||||
- name: distribution
|
- name: distribution
|
||||||
config:
|
config:
|
||||||
"@type": cosmos.distribution.module.v1.Module
|
"@type": cosmos.distribution.module.v1.Module
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
)
|
)
|
||||||
@ -221,4 +222,16 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle slashing state. */
|
||||||
|
|
||||||
|
// reset start height on signing infos
|
||||||
|
app.SlashingKeeper.IterateValidatorSigningInfos(
|
||||||
|
ctx,
|
||||||
|
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
|
||||||
|
info.StartHeight = 0
|
||||||
|
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
1
go.mod
1
go.mod
@ -61,6 +61,7 @@ require (
|
|||||||
github.com/agnivade/levenshtein v1.1.1 // indirect
|
github.com/agnivade/levenshtein v1.1.1 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
||||||
|
github.com/bits-and-blooms/bitset v1.10.0 // indirect
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||||
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
||||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||||
|
Loading…
Reference in New Issue
Block a user