From 9d5425b806e93102d67ac9e6bc8638b80a98fec1 Mon Sep 17 00:00:00 2001 From: gamarin Date: Fri, 15 Jun 2018 16:18:50 +0200 Subject: [PATCH] latest change --- docs/spec/governance/state.md | 24 ++++++++++++++---------- docs/spec/governance/transactions.md | 14 ++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/spec/governance/state.md b/docs/spec/governance/state.md index 876c457eb9..15df741cdb 100644 --- a/docs/spec/governance/state.md +++ b/docs/spec/governance/state.md @@ -50,8 +50,9 @@ const ( type ProposalType byte const ( - ProposalTypePlainText = 0x1 - ProposalTypeSoftwareUpgrade = 0x2 + ProposalTypePlainText = 0x1 // Plain text proposals + ProposalTypeSoftwareUpgrade = 0x2 // Text proposal inducing a software upgrade + ProposalTypeParameterChange = 0x3 // Add or change a parameter in GlobalParams store ) type ProposalStatus byte @@ -156,14 +157,17 @@ And the pseudocode for the `ProposalProcessingQueue`: return proposal = load(Governance, ) // 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 ProposalProcessingQueue.pop() - validators = stakeKeeper.getAllValidators() + validators = + + + Keeper.getAllValidators() tmpValMap := map(sdk.Address)ValidatorGovInfo // 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) 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 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 if (!tmpValMap(validator).HasVoted) - slash validator by activeProcedure.GovernancePenalty + slash validator by tallyingProcedure.GovernancePenalty else 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 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 // refund deposits (non-voters already punished) proposal.CurrentStatus = ProposalStatusAccepted diff --git a/docs/spec/governance/transactions.md b/docs/spec/governance/transactions.md index 6192f908de..60089f32ed 100644 --- a/docs/spec/governance/transactions.md +++ b/docs/spec/governance/transactions.md @@ -41,6 +41,8 @@ upon receiving txGovSubmitProposal from sender do if (initialDeposit.Atoms <= 0) OR (sender.AtomBalance < initialDeposit.Atoms) // InitialDeposit is negative or null OR sender has insufficient funds throw + + if (txGovSubmitProposal.Type != ProposalTypePlainText) OR (txGovSubmitProposal.Type != ProposalTypeSoftwareUpgrade) sender.AtomBalance -= initialDeposit.Atoms @@ -59,9 +61,9 @@ upon receiving txGovSubmitProposal from sender do proposal.NoWithVetoVotes = 0 proposal.AbstainVotes = 0 - activeProcedure = load(params, 'ActiveProcedure') + depositProcedure = load(GlobalParams, 'DepositProcedure') - if (initialDeposit < activeProcedure.MinDeposit) + if (initialDeposit < depositProcedure.MinDeposit) // MinDeposit is not reached proposal.CurrentStatus = ProposalStatusOpen @@ -115,8 +117,6 @@ upon receiving txGovDeposit from sender do if (proposal == nil) // There is no proposal for this proposalID throw - - activeProcedure = load(params, 'ActiveProcedure') if (txGovDeposit.Deposit.Atoms <= 0) ORĀ (sender.AtomBalance < txGovDeposit.Deposit.Atoms) OR (proposal.CurrentStatus != ProposalStatusOpen) @@ -126,7 +126,9 @@ upon receiving txGovDeposit from sender do throw - if (CurrentBlock >= proposal.SubmitBlock + activeProcedure.MaxDepositPeriod) + depositProcedure = load(GlobalParams, 'DepositProcedure') + + if (CurrentBlock >= proposal.SubmitBlock + depositProcedure.MaxDepositPeriod) proposal.CurrentStatus = ProposalStatusClosed else @@ -136,7 +138,7 @@ upon receiving txGovDeposit from sender do proposal.Deposits.append({txGovVote.Deposit, sender}) proposal.TotalDeposit.Plus(txGovDeposit.Deposit) - if (proposal.TotalDeposit >= activeProcedure.MinDeposit) + if (proposal.TotalDeposit >= depositProcedure.MinDeposit) // MinDeposit is reached, vote opens proposal.VotingStartBlock = CurrentBlock