apply requests
This commit is contained in:
parent
bd6ee42c5a
commit
37ce8d51c6
|
@ -24,7 +24,7 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
|
|||
genesisState := GenesisState{
|
||||
Accounts: genaccs,
|
||||
StakeData: stake.DefaultGenesisState(),
|
||||
SlashingData: slashing.HubDefaultGenesisState(),
|
||||
SlashingData: slashing.DefaultGenesisState(),
|
||||
}
|
||||
|
||||
stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState)
|
||||
|
|
|
@ -172,7 +172,7 @@ func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisStat
|
|||
// start with the default staking genesis state
|
||||
stakeData := stake.DefaultGenesisState()
|
||||
|
||||
slashingData := slashing.HubDefaultGenesisState()
|
||||
slashingData := slashing.DefaultGenesisState()
|
||||
|
||||
// get genesis flag account information
|
||||
genaccs := make([]GenesisAccount, len(appGenTxs))
|
||||
|
|
|
@ -77,7 +77,7 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
|
|||
genesis := GenesisState{
|
||||
Accounts: genesisAccounts,
|
||||
StakeData: stakeGenesis,
|
||||
SlashingData: slashing.HubDefaultGenesisState(),
|
||||
SlashingData: slashing.DefaultGenesisState(),
|
||||
GovData: govGenesis,
|
||||
}
|
||||
|
||||
|
|
|
@ -30,17 +30,12 @@ func NewKeeper(cdc *codec.Codec, key *sdk.KVStoreKey, tkey *sdk.TransientStoreKe
|
|||
}
|
||||
|
||||
// Allocate substore used for keepers
|
||||
func (k Keeper) Subspace(space string) Space {
|
||||
_, ok := k.spaces[space]
|
||||
func (k Keeper) Subspace(spacename string) Space {
|
||||
_, ok := k.spaces[spacename]
|
||||
if ok {
|
||||
panic("subspace already occupied")
|
||||
}
|
||||
|
||||
return k.UnsafeSubspace(space)
|
||||
}
|
||||
|
||||
// Get substore without checking existing allocation
|
||||
func (k Keeper) UnsafeSubspace(spacename string) Space {
|
||||
if spacename == "" {
|
||||
panic("cannot use empty string for subspace")
|
||||
}
|
||||
|
@ -51,3 +46,12 @@ func (k Keeper) UnsafeSubspace(spacename string) Space {
|
|||
|
||||
return space
|
||||
}
|
||||
|
||||
// Get existing subspace from keeper
|
||||
func (k Keeper) GetSubspace(spacename string) (Space, bool) {
|
||||
space, ok := k.spaces[spacename]
|
||||
if !ok {
|
||||
return Space{}, false
|
||||
}
|
||||
return *space, ok
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package space
|
||||
|
||||
/*
|
||||
To prevent namespace collision between comsumer modules, we define type
|
||||
"space". A Space can only be generated by the keeper, and the keeper checks
|
||||
the existence of the space having the same name before generating the
|
||||
space.
|
||||
|
||||
Consumer modules must take a space(via Keeper.Subspace), not the keeper
|
||||
itself. This isolates each modules from the others and make them modify theparameters safely. Keeper can be treated as master permission for all
|
||||
subspaces(via Keeper.GetSubspace), so should be passed to proper modules
|
||||
(ex. gov)
|
||||
*/
|
|
@ -30,7 +30,7 @@ func NewSpace(cdc *codec.Codec, key sdk.StoreKey, tkey sdk.StoreKey, space strin
|
|||
key: key,
|
||||
tkey: tkey,
|
||||
|
||||
space: []byte(space + "/"),
|
||||
space: append([]byte(space), '/'),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ type GenesisState struct {
|
|||
}
|
||||
|
||||
// HubDefaultGenesisState - default GenesisState used by Cosmos Hub
|
||||
func HubDefaultGenesisState() GenesisState {
|
||||
func DefaultGenesisState() GenesisState {
|
||||
return GenesisState{
|
||||
Params: HubDefaultParams(),
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
func TestCannotUnjailUnlessJailed(t *testing.T) {
|
||||
// initial setup
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, DefaultParams())
|
||||
slh := NewHandler(keeper)
|
||||
amtInt := int64(100)
|
||||
addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt)
|
||||
|
@ -30,7 +30,7 @@ func TestCannotUnjailUnlessJailed(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestJailedValidatorDelegations(t *testing.T) {
|
||||
ctx, _, stakeKeeper, _, slashingKeeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, stakeKeeper, _, slashingKeeper := createTestInput(t, DefaultParams())
|
||||
|
||||
stakeParams := stakeKeeper.GetParams(ctx)
|
||||
stakeParams.UnbondingTime = 0
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestHookOnValidatorBonded(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
addr := sdk.ConsAddress(addrs[0])
|
||||
keeper.onValidatorBonded(ctx, addr)
|
||||
period := keeper.getValidatorSlashingPeriodForHeight(ctx, addr, ctx.BlockHeight())
|
||||
|
@ -17,7 +17,7 @@ func TestHookOnValidatorBonded(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHookOnValidatorBeginUnbonding(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
addr := sdk.ConsAddress(addrs[0])
|
||||
keeper.onValidatorBonded(ctx, addr)
|
||||
keeper.onValidatorBeginUnbonding(ctx, addr)
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
// Have to change these parameters for tests
|
||||
// lest the tests take forever
|
||||
func keeperTestParams() Params {
|
||||
params := HubDefaultParams()
|
||||
params := DefaultParams()
|
||||
params.SignedBlocksWindow = 1000
|
||||
params.DowntimeUnbondDuration = 60 * 60
|
||||
params.DoubleSignUnbondDuration = 60 * 60
|
||||
|
@ -70,7 +70,7 @@ func TestHandleDoubleSign(t *testing.T) {
|
|||
func TestSlashingPeriodCap(t *testing.T) {
|
||||
|
||||
// initial setup
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, DefaultParams())
|
||||
sk = sk.WithHooks(keeper.Hooks())
|
||||
amtInt := int64(100)
|
||||
addr, amt := addrs[0], sdk.NewInt(amtInt)
|
||||
|
@ -298,7 +298,7 @@ func TestHandleNewValidator(t *testing.T) {
|
|||
func TestHandleAlreadyJailed(t *testing.T) {
|
||||
|
||||
// initial setup
|
||||
ctx, _, sk, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, sk, _, keeper := createTestInput(t, DefaultParams())
|
||||
amtInt := int64(100)
|
||||
addr, val, amt := addrs[0], pks[0], sdk.NewInt(amtInt)
|
||||
sh := stake.NewHandler(sk)
|
||||
|
|
|
@ -45,7 +45,7 @@ type Params struct {
|
|||
}
|
||||
|
||||
// Default parameters used by Cosmos Hub
|
||||
func HubDefaultParams() Params {
|
||||
func DefaultParams() Params {
|
||||
return Params{
|
||||
// defaultMaxEvidenceAge = 60 * 60 * 24 * 7 * 3
|
||||
// TODO Temporarily set to 2 minutes for testnets.
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetSetValidatorSigningInfo(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
info, found := keeper.getValidatorSigningInfo(ctx, sdk.ConsAddress(addrs[0]))
|
||||
require.False(t, found)
|
||||
newInfo := ValidatorSigningInfo{
|
||||
|
@ -29,7 +29,7 @@ func TestGetSetValidatorSigningInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetSetValidatorSigningBitArray(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
signed := keeper.getValidatorSigningBitArray(ctx, sdk.ConsAddress(addrs[0]), 0)
|
||||
require.False(t, signed) // treat empty key as unsigned
|
||||
keeper.setValidatorSigningBitArray(ctx, sdk.ConsAddress(addrs[0]), 0, true)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetSetValidatorSlashingPeriod(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
addr := sdk.ConsAddress(addrs[0])
|
||||
height := int64(5)
|
||||
require.Panics(t, func() { keeper.getValidatorSlashingPeriodForHeight(ctx, addr, height) })
|
||||
|
@ -60,7 +60,7 @@ func TestGetSetValidatorSlashingPeriod(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestValidatorSlashingPeriodCap(t *testing.T) {
|
||||
ctx, _, _, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, _, _, _, keeper := createTestInput(t, DefaultParams())
|
||||
addr := sdk.ConsAddress(addrs[0])
|
||||
height := int64(5)
|
||||
newPeriod := ValidatorSlashingPeriod{
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestBeginBlocker(t *testing.T) {
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, HubDefaultParams())
|
||||
ctx, ck, sk, _, keeper := createTestInput(t, DefaultParams())
|
||||
addr, pk, amt := addrs[2], pks[2], sdk.NewInt(100)
|
||||
|
||||
// bond the validator
|
||||
|
|
Loading…
Reference in New Issue