1
1
package v3
2
2
3
3
import (
4
+ "fmt"
5
+
4
6
sdk "github.com/cosmos/cosmos-sdk/types"
5
7
"github.com/cosmos/cosmos-sdk/types/module"
6
8
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7
9
8
10
"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"
9
13
)
10
14
11
15
// CreateUpgradeHandler returns a upgrade handler for AtomOne v3
@@ -22,7 +26,33 @@ func CreateUpgradeHandler(
22
26
if err != nil {
23
27
return vm , err
24
28
}
29
+ if err := initGovDynamicQuorum (ctx , keepers .GovKeeper ); err != nil {
30
+ return vm , err
31
+ }
25
32
ctx .Logger ().Info ("Upgrade complete" )
26
33
return vm , nil
27
34
}
28
35
}
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