-
Notifications
You must be signed in to change notification settings - Fork 49
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
Improve the Gov Module Mechanism by BLV Labs #534
base: blv/gov
Are you sure you want to change the base?
Changes from 66 commits
cff38ea
a92ee1b
ee4aa1a
5af0ad2
02fc71c
062774b
03990d2
4e366a6
9b22f54
22141bd
6d7fa29
b80170f
76927b6
2badfc1
e26da00
f63eefb
b422289
5e4b632
562e610
7df5045
d1213e8
435086a
c7429a4
869d296
eeef11a
5bf6106
a4cc750
fb0f953
a749a91
f8a724e
0c594e7
fa14819
61ea499
6e9ed9b
6265c9d
03ec02b
fa06f7e
5240f63
10bcfdc
909c3ed
3fa6092
2c81f7b
00dfc79
eb941ca
9e52573
6e0cf5e
a5ae5fa
68f6d12
36a1f6e
3914bc8
6035640
bec6d63
e957bfa
a7ad120
6e3a28c
30c7ccc
0832c67
4cd9346
ae8d370
2f33b29
d780c04
4c44c75
7955ba0
2f1168f
69c5019
71143d8
43ef592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//nolint:revive | ||
package v8_4 | ||
|
||
import ( | ||
"github.com/classic-terra/core/v3/app/upgrades" | ||
) | ||
|
||
const UpgradeName = "v8_4" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateV84UpgradeHandler, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//nolint:revive | ||
package v8_4 | ||
|
||
import ( | ||
"github.com/classic-terra/core/v3/app/keepers" | ||
"github.com/classic-terra/core/v3/app/upgrades" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
func CreateV84UpgradeHandler( | ||
mm *module.Manager, | ||
cfg module.Configurator, | ||
_ upgrades.BaseAppParamManager, | ||
keepers *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
return mm.RunMigrations(ctx, cfg, fromVM) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ import ( | |
"path/filepath" | ||
"time" | ||
|
||
govv2lunc1 "github.com/classic-terra/core/v3/custom/gov/types/v2lunc1" | ||
tmconfig "github.com/cometbft/cometbft/config" | ||
tmos "github.com/cometbft/cometbft/libs/os" | ||
tmrand "github.com/cometbft/cometbft/libs/rand" | ||
"github.com/cometbft/cometbft/types" | ||
tmtime "github.com/cometbft/cometbft/types/time" | ||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
|
@@ -309,7 +309,7 @@ func initGenFiles( | |
appGenState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankGenState) | ||
|
||
// set gov in the genesis state | ||
var govGenState govv1.GenesisState | ||
var govGenState govv2lunc1.GenesisState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please avoid namings like "lunc" in types, if you want to use something non-generic, you might use "terra" or similar |
||
clientCtx.Codec.MustUnmarshalJSON(appGenState[govtypes.ModuleName], &govGenState) | ||
votingPeriod := time.Minute * 3 | ||
govGenState.Params.VotingPeriod = &votingPeriod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,23 @@ import ( | |
"fmt" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
core "github.com/classic-terra/core/v3/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" | ||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" | ||
|
||
core "github.com/classic-terra/core/v3/types" | ||
customgovkeeper "github.com/classic-terra/core/v3/custom/gov/keeper" | ||
) | ||
|
||
// MinInitialDeposit Decorator will check Initial Deposits for MsgSubmitProposal | ||
type MinInitialDepositDecorator struct { | ||
govKeeper govkeeper.Keeper | ||
govKeeper customgovkeeper.Keeper | ||
treasuryKeeper TreasuryKeeper | ||
} | ||
|
||
// NewMinInitialDeposit returns new min initial deposit decorator instance | ||
func NewMinInitialDepositDecorator(govKeeper govkeeper.Keeper, treasuryKeeper TreasuryKeeper) MinInitialDepositDecorator { | ||
func NewMinInitialDepositDecorator(govKeeper customgovkeeper.Keeper, treasuryKeeper TreasuryKeeper) MinInitialDepositDecorator { | ||
return MinInitialDepositDecorator{ | ||
govKeeper: govKeeper, | ||
treasuryKeeper: treasuryKeeper, | ||
|
@@ -38,9 +38,8 @@ func IsMsgSubmitProposal(msg sdk.Msg) bool { | |
} | ||
|
||
// HandleCheckMinInitialDeposit | ||
func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper govkeeper.Keeper, treasuryKeeper TreasuryKeeper) (err error) { | ||
func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper customgovkeeper.Keeper, treasuryKeeper TreasuryKeeper) (err error) { | ||
var initialDepositCoins sdk.Coins | ||
|
||
switch submitPropMsg := msg.(type) { | ||
case *govv1beta1.MsgSubmitProposal: | ||
initialDepositCoins = submitPropMsg.GetInitialDeposit() | ||
|
@@ -49,18 +48,19 @@ func HandleCheckMinInitialDeposit(ctx sdk.Context, msg sdk.Msg, govKeeper govkee | |
default: | ||
return fmt.Errorf("could not dereference msg as MsgSubmitProposal") | ||
} | ||
minDeposit := govKeeper.GetParams(ctx).MinDeposit | ||
requiredAmount := sdk.NewDecFromInt(minDeposit[0].Amount).Mul(treasuryKeeper.GetMinInitialDepositRatio(ctx)).TruncateInt() | ||
|
||
requiredDepositCoins := sdk.NewCoins( | ||
sdk.NewCoin(core.MicroLunaDenom, requiredAmount), | ||
) | ||
|
||
if !initialDepositCoins.IsAllGTE(requiredDepositCoins) { | ||
return fmt.Errorf("not enough initial deposit provided. Expected %q; got %q", requiredDepositCoins, initialDepositCoins) | ||
// set offset price change 3% | ||
offsetPrice := sdk.NewDecWithPrec(97, 2) | ||
minLuncAmount, err := govKeeper.GetMinimumDepositBaseUusd(ctx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please to not use "Lunc" in variables. The denom would be "minUlunaAmount" if you want to include the denom in the variable name. Lunc would not be the microunit. |
||
minInitialDepositRatio := treasuryKeeper.GetMinInitialDepositRatio(ctx) | ||
if err == nil && minLuncAmount.GT(sdk.ZeroInt()) { | ||
requiredDeposit := sdk.NewDecFromInt(minLuncAmount).Mul(minInitialDepositRatio).Mul(offsetPrice).TruncateInt() | ||
requiredDepositCoins := sdk.NewCoins(sdk.NewCoin(core.MicroLunaDenom, requiredDeposit)) | ||
if initialDepositCoins.IsAllLT(requiredDepositCoins) { | ||
return fmt.Errorf("not enough initial deposit provided. Expected %q; got %q", requiredDepositCoins, initialDepositCoins) | ||
} | ||
return nil | ||
} | ||
|
||
return nil | ||
return fmt.Errorf("could not get minimum deposit base uusd") | ||
} | ||
|
||
// AnteHandle handles checking MsgSubmitProposal | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change to
v10_1
as the current prepared release will use v10