latest change
This commit is contained in:
parent
09ea8dac11
commit
9d5425b806
|
@ -50,8 +50,9 @@ const (
|
||||||
type ProposalType byte
|
type ProposalType byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProposalTypePlainText = 0x1
|
ProposalTypePlainText = 0x1 // Plain text proposals
|
||||||
ProposalTypeSoftwareUpgrade = 0x2
|
ProposalTypeSoftwareUpgrade = 0x2 // Text proposal inducing a software upgrade
|
||||||
|
ProposalTypeParameterChange = 0x3 // Add or change a parameter in GlobalParams store
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProposalStatus byte
|
type ProposalStatus byte
|
||||||
|
@ -156,14 +157,17 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||||
return
|
return
|
||||||
|
|
||||||
proposal = load(Governance, <proposalID|'proposal'>) // proposal is a const key
|
proposal = load(Governance, <proposalID|'proposal'>) // proposal is a const key
|
||||||
activeProcedure = load(params, 'ActiveProcedure')
|
votingProcedure = load(GlobalParams, 'VotingProcedure')
|
||||||
|
|
||||||
if (CurrentBlock == proposal.VotingStartBlock + activeProcedure.VotingPeriod && proposal.CurrentStatus == ProposalStatusActive)
|
if (CurrentBlock == proposal.VotingStartBlock + votingProcedure.VotingPeriod && proposal.CurrentStatus == ProposalStatusActive)
|
||||||
|
|
||||||
// End of voting period, tally
|
// End of voting period, tally
|
||||||
|
|
||||||
ProposalProcessingQueue.pop()
|
ProposalProcessingQueue.pop()
|
||||||
validators = stakeKeeper.getAllValidators()
|
validators =
|
||||||
|
|
||||||
|
|
||||||
|
Keeper.getAllValidators()
|
||||||
tmpValMap := map(sdk.Address)ValidatorGovInfo
|
tmpValMap := map(sdk.Address)ValidatorGovInfo
|
||||||
|
|
||||||
// Initiate mapping at 0. Validators that remain at 0 at the end of tally will be punished
|
// Initiate mapping at 0. Validators that remain at 0 at the end of tally will be punished
|
||||||
|
@ -184,16 +188,16 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||||
|
|
||||||
_, isVal = stakeKeeper.getValidator(voterAddress)
|
_, isVal = stakeKeeper.getValidator(voterAddress)
|
||||||
if (isVal)
|
if (isVal)
|
||||||
tmpValMap(voterAddress).Vote = vote
|
tmpValMap(voterAddress).Vote = vote
|
||||||
|
|
||||||
|
|
||||||
|
tallyingProcedure = load(GlobalParams, 'TallyingProcedure')
|
||||||
|
|
||||||
// Slash validators that did not vote, or update tally if they voted
|
// Slash validators that did not vote, or update tally if they voted
|
||||||
for each validator in validators
|
for each validator in validators
|
||||||
if (validator.bondHeight < CurrentBlock - activeProcedure.GracePeriod)
|
if (validator.bondHeight < CurrentBlock - tallyingProcedure.GracePeriod)
|
||||||
// only slash if validator entered validator set before grace period
|
// only slash if validator entered validator set before grace period
|
||||||
if (!tmpValMap(validator).HasVoted)
|
if (!tmpValMap(validator).HasVoted)
|
||||||
slash validator by activeProcedure.GovernancePenalty
|
slash validator by tallyingProcedure.GovernancePenalty
|
||||||
else
|
else
|
||||||
proposal.updateTally(tmpValMap(validator).Vote, (validator.TotalShares - tmpValMap(validator).Minus))
|
proposal.updateTally(tmpValMap(validator).Vote, (validator.TotalShares - tmpValMap(validator).Minus))
|
||||||
|
|
||||||
|
@ -201,7 +205,7 @@ And the pseudocode for the `ProposalProcessingQueue`:
|
||||||
|
|
||||||
// Check if proposal is accepted or rejected
|
// Check if proposal is accepted or rejected
|
||||||
totalNonAbstain := proposal.YesVotes + proposal.NoVotes + proposal.NoWithVetoVotes
|
totalNonAbstain := proposal.YesVotes + proposal.NoVotes + proposal.NoWithVetoVotes
|
||||||
if (proposal.Votes.YesVotes/totalNonAbstain > activeProcedure.Threshold AND proposal.Votes.NoWithVetoVotes/totalNonAbstain < activeProcedure.Veto)
|
if (proposal.Votes.YesVotes/totalNonAbstain > tallyingProcedure.Threshold AND proposal.Votes.NoWithVetoVotes/totalNonAbstain < tallyingProcedure.Veto)
|
||||||
// proposal was accepted at the end of the voting period
|
// proposal was accepted at the end of the voting period
|
||||||
// refund deposits (non-voters already punished)
|
// refund deposits (non-voters already punished)
|
||||||
proposal.CurrentStatus = ProposalStatusAccepted
|
proposal.CurrentStatus = ProposalStatusAccepted
|
||||||
|
|
|
@ -42,6 +42,8 @@ upon receiving txGovSubmitProposal from sender do
|
||||||
// InitialDeposit is negative or null OR sender has insufficient funds
|
// InitialDeposit is negative or null OR sender has insufficient funds
|
||||||
throw
|
throw
|
||||||
|
|
||||||
|
if (txGovSubmitProposal.Type != ProposalTypePlainText) OR (txGovSubmitProposal.Type != ProposalTypeSoftwareUpgrade)
|
||||||
|
|
||||||
sender.AtomBalance -= initialDeposit.Atoms
|
sender.AtomBalance -= initialDeposit.Atoms
|
||||||
|
|
||||||
proposalID = generate new proposalID
|
proposalID = generate new proposalID
|
||||||
|
@ -59,9 +61,9 @@ upon receiving txGovSubmitProposal from sender do
|
||||||
proposal.NoWithVetoVotes = 0
|
proposal.NoWithVetoVotes = 0
|
||||||
proposal.AbstainVotes = 0
|
proposal.AbstainVotes = 0
|
||||||
|
|
||||||
activeProcedure = load(params, 'ActiveProcedure')
|
depositProcedure = load(GlobalParams, 'DepositProcedure')
|
||||||
|
|
||||||
if (initialDeposit < activeProcedure.MinDeposit)
|
if (initialDeposit < depositProcedure.MinDeposit)
|
||||||
// MinDeposit is not reached
|
// MinDeposit is not reached
|
||||||
|
|
||||||
proposal.CurrentStatus = ProposalStatusOpen
|
proposal.CurrentStatus = ProposalStatusOpen
|
||||||
|
@ -116,8 +118,6 @@ upon receiving txGovDeposit from sender do
|
||||||
// There is no proposal for this proposalID
|
// There is no proposal for this proposalID
|
||||||
throw
|
throw
|
||||||
|
|
||||||
activeProcedure = load(params, 'ActiveProcedure')
|
|
||||||
|
|
||||||
if (txGovDeposit.Deposit.Atoms <= 0) OR (sender.AtomBalance < txGovDeposit.Deposit.Atoms) OR (proposal.CurrentStatus != ProposalStatusOpen)
|
if (txGovDeposit.Deposit.Atoms <= 0) OR (sender.AtomBalance < txGovDeposit.Deposit.Atoms) OR (proposal.CurrentStatus != ProposalStatusOpen)
|
||||||
|
|
||||||
// deposit is negative or null
|
// deposit is negative or null
|
||||||
|
@ -126,7 +126,9 @@ upon receiving txGovDeposit from sender do
|
||||||
|
|
||||||
throw
|
throw
|
||||||
|
|
||||||
if (CurrentBlock >= proposal.SubmitBlock + activeProcedure.MaxDepositPeriod)
|
depositProcedure = load(GlobalParams, 'DepositProcedure')
|
||||||
|
|
||||||
|
if (CurrentBlock >= proposal.SubmitBlock + depositProcedure.MaxDepositPeriod)
|
||||||
proposal.CurrentStatus = ProposalStatusClosed
|
proposal.CurrentStatus = ProposalStatusClosed
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -136,7 +138,7 @@ upon receiving txGovDeposit from sender do
|
||||||
proposal.Deposits.append({txGovVote.Deposit, sender})
|
proposal.Deposits.append({txGovVote.Deposit, sender})
|
||||||
proposal.TotalDeposit.Plus(txGovDeposit.Deposit)
|
proposal.TotalDeposit.Plus(txGovDeposit.Deposit)
|
||||||
|
|
||||||
if (proposal.TotalDeposit >= activeProcedure.MinDeposit)
|
if (proposal.TotalDeposit >= depositProcedure.MinDeposit)
|
||||||
// MinDeposit is reached, vote opens
|
// MinDeposit is reached, vote opens
|
||||||
|
|
||||||
proposal.VotingStartBlock = CurrentBlock
|
proposal.VotingStartBlock = CurrentBlock
|
||||||
|
|
Loading…
Reference in New Issue