From feb3f2daaf4f2ec968c6ca34cbb0f29bd1b87985 Mon Sep 17 00:00:00 2001 From: fanghr Date: Mon, 6 Jun 2022 21:19:51 +0800 Subject: [PATCH] apply Emily's suggestions --- agora-specs/Sample/Proposal.hs | 2 +- agora/Agora/Proposal.hs | 4 ++-- agora/Agora/Proposal/Scripts.hs | 10 +++++----- bench.csv | 32 ++++++++++++++++---------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/agora-specs/Sample/Proposal.hs b/agora-specs/Sample/Proposal.hs index 1d352b9..23357c2 100644 --- a/agora-specs/Sample/Proposal.hs +++ b/agora-specs/Sample/Proposal.hs @@ -408,7 +408,7 @@ mkTransitionTxInfo :: ProposalStartingTime -> -- | Valid time range of the transaction. POSIXTimeRange -> - -- | Add a unchanged stake or not. + -- | Whether to add an unchanged stake or not. Bool -> TxInfo mkTransitionTxInfo from to effects votes startingTime validTime shouldAddUnchangedStake = diff --git a/agora/Agora/Proposal.hs b/agora/Agora/Proposal.hs index 02093f5..2705291 100644 --- a/agora/Agora/Proposal.hs +++ b/agora/Agora/Proposal.hs @@ -369,9 +369,9 @@ newtype PProposalVotes (s :: S) deriving (PlutusType, PIsData) via (DerivePNewtype PProposalVotes (PMap 'Unsorted PResultTag PInteger)) -- | Retract votes given the option and the amount of votes. -pretractVotes :: Term s (PProposalVotes :--> PResultTag :--> PInteger :--> PProposalVotes) +pretractVotes :: Term s (PResultTag :--> PInteger :--> PProposalVotes :--> PProposalVotes) pretractVotes = phoistAcyclic $ - plam $ \votes rt count -> + plam $ \rt count votes -> let voteMap :: Term _ (PMap 'Unsorted PResultTag PInteger) voteMap = pto votes in pcon $ diff --git a/agora/Agora/Proposal/Scripts.hs b/agora/Agora/Proposal/Scripts.hs index 0d2084c..2d40389 100644 --- a/agora/Agora/Proposal/Scripts.hs +++ b/agora/Agora/Proposal/Scripts.hs @@ -416,19 +416,19 @@ proposalValidator proposal = pguardC "Stake input relevant" $ pmatch stakeUsage $ \case PDidNothing -> - ptrace "Not relevant" $ + ptraceIfFalse "Stake should be relevant" $ pconstant False PCreated -> - ptraceIfFalse "Too early" $ + ptraceIfFalse "Removing creator's locks means status is Finished" $ proposalF.status #== pconstantData Finished PVotedFor rt -> - ptraceIfFalse "Result tag not match" $ + ptraceIfFalse "Result tag should match the one given in the redeemer" $ rt #== retractFrom -- The count of removing votes is equal to the 'stakeAmount' of input stake. retractCount <- pletC $ - pmatch stakeInF.stakedAmount $ (\(PDiscrete v) -> pextract # v) + pmatch stakeInF.stakedAmount $ \(PDiscrete v) -> pextract # v -- The votes can only change when the proposal still allows voting. let shouldUpdateVotes = @@ -439,7 +439,7 @@ proposalValidator proposal = pif shouldUpdateVotes ( let -- Remove votes and leave other parts of the proposal as it. - expectedVotes = pretractVotes # proposalF.votes # retractFrom # retractCount + expectedVotes = pretractVotes # retractFrom # retractCount # proposalF.votes expectedProposalOut = mkRecordConstr diff --git a/bench.csv b/bench.csv index 32fcd3f..e331364 100644 --- a/bench.csv +++ b/bench.csv @@ -2,32 +2,32 @@ name,cpu,mem,size Agora/Effects/Treasury Withdrawal Effect/effect/Simple,289461528,703055,3191 Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,448521458,1070167,3518 Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets,408085321,966048,3383 -Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass,83758582,229228,7665 +Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass,83758582,229228,7664 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass,97345575,266935,3358 Agora/Stake/policy/stakeCreation,43114795,124549,2156 Agora/Stake/validator/stakeDepositWithdraw deposit,171823342,464745,4189 Agora/Stake/validator/stakeDepositWithdraw withdraw,171823342,464745,4177 Agora/Proposal/policy/proposalCreation,23140177,69194,1518 -Agora/Proposal/validator/cosignature/proposal,204675349,564476,6565 +Agora/Proposal/validator/cosignature/proposal,204675349,564476,6654 Agora/Proposal/validator/cosignature/stake,114125937,284821,4726 -Agora/Proposal/validator/voting/proposal,166129664,437310,6494 +Agora/Proposal/validator/voting/proposal,166129664,437310,6583 Agora/Proposal/validator/voting/stake,107127768,275725,4700 -Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,162018766,433842,6392 -Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,161175344,432339,6395 -Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,162871811,435945,6395 -Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,160888965,431112,6394 -Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,159480054,428407,6395 -Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,160611032,430811,6395 -Agora/Proposal/validator/unlocking/legal/retract votes and unlock stake while voting,171592676,462566,6467 -Agora/Proposal/validator/unlocking/legal/unlock the stake that has been used to create the proposal,149988973,407906,6474 -Agora/Proposal/validator/unlocking/legal/unlock stake after voting/Locked,149056062,408201,6468 -Agora/Proposal/validator/unlocking/legal/unlock stake after voting/Finished,149056062,408201,6468 +Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,162018766,433842,6481 +Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,161175344,432339,6484 +Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,162871811,435945,6484 +Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,160888965,431112,6483 +Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,159480054,428407,6484 +Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,160611032,430811,6484 +Agora/Proposal/validator/unlocking/legal/retract votes and unlock stake while voting,171454676,461966,6556 +Agora/Proposal/validator/unlocking/legal/unlock the stake that has been used to create the proposal,149988973,407906,6563 +Agora/Proposal/validator/unlocking/legal/unlock stake after voting/Locked,149056062,408201,6557 +Agora/Proposal/validator/unlocking/legal/unlock stake after voting/Finished,149056062,408201,6557 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,1390 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900 Agora/Governor/policy/GST minting,43087287,120125,1829 -Agora/Governor/validator/proposal creation,261928725,689487,8181 -Agora/Governor/validator/GATs minting,352305185,937264,8302 -Agora/Governor/validator/mutate governor state,84905433,234687,7766 +Agora/Governor/validator/proposal creation,262494214,690689,8180 +Agora/Governor/validator/GATs minting,351739696,936062,8301 +Agora/Governor/validator/mutate governor state,84905433,234687,7765