-
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?
Improve the Gov Module Mechanism by BLV Labs #534
Conversation
in the SubmitProposal function: - Get LUNC price based on UUSD - Calculate the amount of LUNC to send for the proposal during that time - Store the LUNC amount
…/gov-improve # Conflicts: # custom/gov/keeper/params.go # custom/gov/keeper/proposal.go # custom/gov/types/v2lunc1/query.pb.go
…/gov-improve # Conflicts: # custom/gov/keeper/params.go # custom/gov/types/v2lunc1/query.pb.go
add get min-deposit if get min deposit not exists
add logic get uusd
|
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.
I did not conduct a deep review or approval-review. This is just to show up some blocking things to merge this into the branch for testnet deployment.
app/app.go
Outdated
@@ -94,6 +95,7 @@ var ( | |||
v8_1.Upgrade, | |||
v8_2.Upgrade, | |||
v8_3.Upgrade, | |||
v8_4.Upgrade, |
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
cmd/terrad/testnet.go
Outdated
@@ -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 comment
The 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
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 comment
The 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.
custom/gov/keeper/grpc_query.go
Outdated
} | ||
|
||
// ProposalMinimalLUNCByUusd returns min Usd amount proposal needs to deposit | ||
func (q queryServer) ProposalMinimalLUNCByUusd(ctx context.Context, req *v2lunc1.QueryProposalRequest) (*v2lunc1.QueryMinimalDepositProposalResponse, error) { |
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.
The naming is misleading. It's not uusd that is configured but US Dollar. uusd is the denom for "USTC" on chain.
custom/gov/keeper/keeper.go
Outdated
} | ||
|
||
// GetDepositLimitBaseUusd: calculate the minimum LUNC amount to deposit base on Uusd for the proposal | ||
func (keeper Keeper) GetMinimumDepositBaseUusd(ctx sdk.Context) (math.Int, error) { |
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.
Same as above. Uusd is misleading.
custom/gov/types/v2lunc1/codec.go
Outdated
// governance module. | ||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | ||
legacy.RegisterAminoMsg(cdc, &govv1.MsgSubmitProposal{}, "cosmos-sdk/v1/MsgSubmitProposal") | ||
legacy.RegisterAminoMsg(cdc, &govv1.MsgDeposit{}, "cosmos-sdk/v1/MsgDeposit") |
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.
This will break classic legacy handling.
beaf7dc
to
d26e250
Compare
d26e250
to
43ef592
Compare
Spec or proposal link: https://commonwealth.im/terra-luna-classic-lunc/discussion/24630-proposal-to-improve-the-gov-module-mechanism-by-blv-labs
sidebar_position: 1
x/gov
Custom Governace Module Updates
Concepts
Disclaimer: This is work in progress. Mechanisms are susceptible to change.
The governance process is divided in a few steps that are outlined below:
deposit.
500 USD (
MinUusdDeposit
), proposal is confirmed and vote opens.on the result, the messages in the proposal will be executed.
Proposal submission
Right to submit a proposal
Every account can submit proposals by sending a
MsgSubmitProposal
transaction.Once a proposal is submitted, it is identified by its unique
proposalID
.Proposal Messages
A proposal includes an array of
sdk.Msg
s which are executed automatically if theproposal passes. The messages are executed by the governance
ModuleAccount
itself. Modulessuch as
x/upgrade
, that want to allow certain messages to be executed by governanceonly should add a whitelist within the respective msg server, granting the governance
module the right to execute the message once a quorum has been reached. The governance
module uses the
MsgServiceRouter
to check that these messages are correctly constructedand have a respective path to execute on but do not perform a full validity check.
Deposit
To prevent spam, proposals must be submitted with a deposit in the coins defined by the equation
luncMinDepositAmountBasedOnUusd
=MinUusdDeposit
/ real-time price of LUNC at the time of proposal submission.The value of
luncMinDepositAmountBasedOnUusd
will be stored in KVStores, using a key defined asUUSDMinKeyPrefix|proposalID
, where the proposal ID is appended to the prefix, represented as a single byte.When a proposal is submitted, it has to be accompanied with a deposit that must be
strictly positive, but can be inferior to
luncMinDepositAmountBasedOnUusd
. The submitter doesn't needto pay for the entire deposit on their own. The newly created proposal is stored in
an inactive proposal queue and stays there until its deposit passes the
luncMinDepositAmountBasedOnUusd
.Other token holders can increase the proposal's deposit by sending a
Deposit
transaction. If a proposal doesn't pass the
luncMinDepositAmountBasedOnUusd
before the deposit end time(the time when deposits are no longer accepted), the proposal will be destroyed: the
proposal will be removed from state and the deposit will be burned (see x/gov
EndBlocker
).When a proposal deposit passes the
luncMinDepositAmountBasedOnUusd
threshold (even during the proposalsubmission) before the deposit end time, the proposal will be moved into the
active proposal queue and the voting period will begin.
The deposit is kept in escrow and held by the governance
ModuleAccount
until theproposal is finalized (passed or rejected).
Deposit refund and burn
When a proposal is finalized, the coins from the deposit are either refunded or burned
according to the final tally of the proposal:
automatically refunded to its respective depositor (transferred from the governance
ModuleAccount
).governance
ModuleAccount
and the proposal information along with its depositinformation will be removed from state.
burning or refunding a deposit.
Vote
Voting period
Once a proposal reaches
luncMinDepositAmountBasedOnUusd
, it immediately entersVoting period
. Wedefine
Voting period
as the interval between the moment the vote opens andthe moment the vote closes.
Voting period
should always be shorter thanUnbonding period
to prevent double voting. The initial value ofVoting period
is 2 weeks.Stores
:::note
Stores are KVStores in the multi-store. The key to find the store is the first parameter in the list
:::
We will use one KVStore
Governance
to store five mappings:proposalID|'proposal'
toProposal
.proposalID|'addresses'|address
toVote
. This mapping allowsus to query all addresses that voted on the proposal along with their vote by
doing a range query on
proposalID:addresses
.ParamsKey|'Params'
toParams
. This map allows to query allx/gov params.
VotingPeriodProposalKeyPrefix|proposalID
to a single byte. This allowsus to know if a proposal is in the voting period or not with very low gas cost.
UUSDMinKeyPrefix|proposalID
to a single byte. This allows us to determine the minimum amount of LUNC that a specific proposal must deposit to pass the deposit phase.For pseudocode purposes, here are the two function we will use to read or write in stores:
load(StoreKey, Key)
: Retrieve item stored at keyKey
in store found at keyStoreKey
in the multistorestore(StoreKey, Key, value)
: Write valueValue
at keyKey
in store found at keyStoreKey
in the multistoreParameters
The governance module contains the following parameters:
min_uusd_deposit
is set to500
usd, but this value can beClient
CLI
A user can query and interact with the
gov
module using the CLI.We have added two new commands
MinimalDeposit
The
MinimalDeposit
command enables users to query the minimum LUNC deposit required for a specific proposal, calculated based on the UUSD value.Example:
CustomParams
The
CustomParams
command allows users to query the custom parameters of the module.Example:
Future Improvements
We have successfully upgraded the chain by increasing the consensus version to 5. Moving forward,
should the community require updates related to these matters, the BLV Team will be available to
assist with the implementation process.