Skip to content

Commit ce6987a

Browse files
committed
add init gov dynamic quorum to v2 uprgade
1 parent add998d commit ce6987a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

app/upgrades/v3/upgrades.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package v3
22

33
import (
4+
"fmt"
5+
46
sdk "github.com/cosmos/cosmos-sdk/types"
57
"github.com/cosmos/cosmos-sdk/types/module"
68
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
79

810
"github.com/atomone-hub/atomone/app/keepers"
11+
govkeeper "github.com/atomone-hub/atomone/x/gov/keeper"
12+
v1 "github.com/atomone-hub/atomone/x/gov/types/v1"
913
)
1014

1115
// CreateUpgradeHandler returns a upgrade handler for AtomOne v3
@@ -22,7 +26,33 @@ func CreateUpgradeHandler(
2226
if err != nil {
2327
return vm, err
2428
}
29+
if err := initGovDynamicQuorum(ctx, keepers.GovKeeper); err != nil {
30+
return vm, err
31+
}
2532
ctx.Logger().Info("Upgrade complete")
2633
return vm, nil
2734
}
2835
}
36+
37+
// initGovDynamicQuorum initialized the gov module for the dynamic quorum
38+
// features, which means setting the new parameters min/max quorums and the
39+
// participation ema.
40+
func initGovDynamicQuorum(ctx sdk.Context, govKeeper *govkeeper.Keeper) error {
41+
ctx.Logger().Info("Initializing gov module for dynamic quorum...")
42+
params := govKeeper.GetParams(ctx)
43+
defaultParams := v1.DefaultParams()
44+
params.MinQuorum = defaultParams.MinQuorum
45+
params.MaxQuorum = defaultParams.MaxQuorum
46+
params.MinConstitutionAmendmentQuorum = defaultParams.MinConstitutionAmendmentQuorum
47+
params.MaxConstitutionAmendmentQuorum = defaultParams.MaxConstitutionAmendmentQuorum
48+
params.MinLawQuorum = defaultParams.MinLawQuorum
49+
params.MaxLawQuorum = defaultParams.MaxLawQuorum
50+
if err := govKeeper.SetParams(ctx, params); err != nil {
51+
return fmt.Errorf("set gov params: %w", err)
52+
}
53+
// NOTE(tb): Disregarding whales' votes, the current participation is less than 12%
54+
initParticipationEma := sdk.NewDecWithPrec(12, 2)
55+
govKeeper.SetParticipationEMA(ctx, initParticipationEma)
56+
ctx.Logger().Info("Gov module initialized for dynamic quorum")
57+
return nil
58+
}

0 commit comments

Comments
 (0)