From c98f39c6aa254a24104856631d139be50cad60df Mon Sep 17 00:00:00 2001 From: Seungheon Oh Date: Thu, 16 Jun 2022 13:28:55 -0500 Subject: [PATCH] `countingVote`,`create`,`startVoting` to `execute`,`create`,`vote` Let's embrace consistancy between Haskell types and Plutarch types. --- agora-specs/Sample/Effect/GovernorMutation.hs | 2 +- agora-specs/Sample/Proposal.hs | 6 +++--- agora-specs/Sample/Shared.hs | 4 ++-- agora-specs/Spec/Proposal.hs | 6 +++--- agora/Agora/Governor.hs | 4 ++-- agora/Agora/Proposal.hs | 6 +++--- bench.csv | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/agora-specs/Sample/Effect/GovernorMutation.hs b/agora-specs/Sample/Effect/GovernorMutation.hs index 00a6067..053df7b 100644 --- a/agora-specs/Sample/Effect/GovernorMutation.hs +++ b/agora-specs/Sample/Effect/GovernorMutation.hs @@ -185,7 +185,7 @@ invalidNewGovernorDatum = GovernorDatum { proposalThresholds = def - { countVoting = Tagged (-1) + { vote = Tagged (-1) } , nextProposalId = ProposalId 42 , proposalTimings = def diff --git a/agora-specs/Sample/Proposal.hs b/agora-specs/Sample/Proposal.hs index 9ccc38a..2379ecd 100644 --- a/agora-specs/Sample/Proposal.hs +++ b/agora-specs/Sample/Proposal.hs @@ -532,7 +532,7 @@ advanceProposalSuccess params = outcome0WinningVotes = ProposalVotes $ updateMap - (\_ -> Just $ untag (def :: ProposalThresholds).countVoting + 1) + (\_ -> Just $ untag (def :: ProposalThresholds).vote + 1) (ResultTag 0) emptyVotes' @@ -611,7 +611,7 @@ advanceProposalFailureTimeout params = outcome0WinningVotes = ProposalVotes $ updateMap - (\_ -> Just $ untag (def :: ProposalThresholds).countVoting + 1) + (\_ -> Just $ untag (def :: ProposalThresholds).vote + 1) (ResultTag 0) emptyVotes' @@ -720,7 +720,7 @@ advanceFinishedPropsoal = outcome0WinningVotes = ProposalVotes $ AssocMap.fromList - [ (ResultTag 0, untag (def :: ProposalThresholds).countVoting + 1) + [ (ResultTag 0, untag (def :: ProposalThresholds).vote + 1) , (ResultTag 1, 0) ] diff --git a/agora-specs/Sample/Shared.hs b/agora-specs/Sample/Shared.hs index b7f72f2..dda6ae0 100644 --- a/agora-specs/Sample/Shared.hs +++ b/agora-specs/Sample/Shared.hs @@ -189,9 +189,9 @@ proposalValidatorAddress = scriptHashAddress proposalValidatorHash instance Default ProposalThresholds where def = ProposalThresholds - { countVoting = Tagged 1000 + { execute = Tagged 1000 , create = Tagged 1 - , startVoting = Tagged 10 + , vote = Tagged 10 } authorityToken :: AuthorityToken diff --git a/agora-specs/Spec/Proposal.hs b/agora-specs/Spec/Proposal.hs index bc45e14..f4beee5 100644 --- a/agora-specs/Spec/Proposal.hs +++ b/agora-specs/Spec/Proposal.hs @@ -185,7 +185,7 @@ specs = ( ResultTag 0 , case initialState of Draft -> 0 - _ -> untag (def :: ProposalThresholds).countVoting + 1 + _ -> untag (def :: ProposalThresholds).vote + 1 ) , (ResultTag 1, 0) ] @@ -232,7 +232,7 @@ specs = ( ResultTag 0 , case initialState of Draft -> 0 - _ -> untag (def :: ProposalThresholds).countVoting + 1 + _ -> untag (def :: ProposalThresholds).vote + 1 ) , (ResultTag 1, 0) ] @@ -301,7 +301,7 @@ specs = , votes = ProposalVotes ( AssocMap.fromList - [ (ResultTag 0, untag (def :: ProposalThresholds).countVoting + 1) + [ (ResultTag 0, untag (def :: ProposalThresholds).vote + 1) , (ResultTag 1, 0) ] ) diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index b654a2d..7afcb52 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -189,11 +189,11 @@ governorDatumValid = phoistAcyclic $ plam $ \datum -> unTermCont $ do thresholds <- tcont $ - pletFields @'["execute", "draft", "vote"] $ + pletFields @'["execute", "create", "vote"] $ pfield @"proposalThresholds" # datum PDiscrete execute' <- pmatchC thresholds.execute - PDiscrete draft' <- pmatchC thresholds.draft + PDiscrete draft' <- pmatchC thresholds.create PDiscrete vote' <- pmatchC thresholds.vote execute <- tclet $ pextract # execute' diff --git a/agora/Agora/Proposal.hs b/agora/Agora/Proposal.hs index 0ed8168..00fb0ce 100644 --- a/agora/Agora/Proposal.hs +++ b/agora/Agora/Proposal.hs @@ -140,14 +140,14 @@ PlutusTx.makeIsDataIndexed ''ProposalStatus [('Draft, 0), ('VotingReady, 1), ('L to 'Proposal's when they are created. -} data ProposalThresholds = ProposalThresholds - { countVoting :: Tagged GTTag Integer + { execute :: Tagged GTTag Integer -- ^ How much GT minimum must a particular 'ResultTag' accumulate for it to pass. , create :: Tagged GTTag Integer -- ^ How much GT required to "create" a proposal. -- -- It is recommended this be a high enough amount, in order to prevent DOS from bad -- actors. - , startVoting :: Tagged GTTag Integer + , vote :: Tagged GTTag Integer -- ^ How much GT required to allow voting to happen. -- (i.e. to move into 'VotingReady') } @@ -327,7 +327,7 @@ newtype PProposalThresholds (s :: S) = PProposalThresholds s ( PDataRecord '[ "execute" ':= PDiscrete GTTag - , "draft" ':= PDiscrete GTTag + , "create" ':= PDiscrete GTTag , "vote" ':= PDiscrete GTTag ] ) diff --git a/bench.csv b/bench.csv index 4e2dada..e739ddf 100644 --- a/bench.csv +++ b/bench.csv @@ -13,11 +13,11 @@ Agora/Proposal/validator/cosignature/stake,162540553,402961,4561 Agora/Proposal/validator/voting/proposal,181998338,491168,5652 Agora/Proposal/validator/voting/stake,127693475,328703,4614 Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,98071575,260351,5030 -Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,97228153,258848,5039 -Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,98924620,262454,5039 +Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,97228153,258848,5033 +Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,98924620,262454,5033 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,96941774,257621,5032 -Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,95532863,254916,5039 -Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,96663841,257320,5039 +Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,95532863,254916,5033 +Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,96663841,257320,5033 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900 Agora/Treasury/Validator/Positive/Allows for effect changes,29938856,79744,1841