forgot to remove some upstreamed utils for some reason :)

This commit is contained in:
Hongrui Fang 2022-06-17 23:26:18 +08:00
parent 4ac80516c5
commit c49e623504
No known key found for this signature in database
GPG key ID: 1C4711FFF64C0254
4 changed files with 30 additions and 54 deletions

View file

@ -18,7 +18,7 @@ import GHC.Generics qualified as GHC
import Generics.SOP (Generic, I (I))
import Agora.Effect (makeEffect)
import Agora.Utils (findTxOutByTxOutRef, isPubKey)
import Agora.Utils (isPubKey)
import Plutarch.Api.V1 (
AmountGuarantees (Positive),
KeyGuarantees (Sorted),
@ -30,6 +30,7 @@ import Plutarch.Api.V1 (
)
import Plutarch.Internal (punsafeCoerce)
import Plutarch.Api.V1.ScriptContext (pfindTxInByTxOutRef)
import "plutarch" Plutarch.Api.V1.Value (pnormalize)
import Plutarch.DataRepr (
DerivePConstantViaData (..),
@ -112,7 +113,7 @@ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $
\_cs (datum' :: Term _ PTreasuryWithdrawalDatum) txOutRef' txInfo' -> unTermCont $ do
datum <- tcont $ pletFields @'["receivers", "treasuries"] datum'
txInfo <- tcont $ pletFields @'["outputs", "inputs"] txInfo'
PJust txOut <- pmatchC $ findTxOutByTxOutRef # txOutRef' # pfromData txInfo.inputs
PJust ((pfield @"resolved" #) -> txOut) <- pmatchC $ pfindTxInByTxOutRef # txOutRef' # pfromData txInfo.inputs
effInput <- tcont $ pletFields @'["address", "value"] $ txOut
outputValues <-
pletC $

View file

@ -34,7 +34,6 @@ import Agora.Stake (
pgetStakeUsage,
)
import Agora.Utils (
findTxOutByTxOutRef,
getMintingPolicySymbol,
mustBePJust,
mustFindDatum',
@ -48,6 +47,7 @@ import Plutarch.Api.V1 (
)
import Plutarch.Api.V1.AssetClass (passetClass, passetClassValueOf)
import Plutarch.Api.V1.ScriptContext (
pfindTxInByTxOutRef,
pisTokenSpent,
ptxSignedBy,
pvalueSpent,
@ -163,7 +163,7 @@ proposalValidator proposal =
txInfo'
PSpending ((pfield @"_0" #) -> txOutRef) <- pmatchC $ pfromData ctx.purpose
PJust txOut <- pmatchC $ findTxOutByTxOutRef # txOutRef # txInfoF.inputs
PJust ((pfield @"resolved" #) -> txOut) <- pmatchC $ pfindTxInByTxOutRef # txOutRef # txInfoF.inputs
txOutF <- tcont $ pletFields @'["address", "value"] $ txOut
(pfromData -> proposalDatum, _) <-

View file

@ -6,7 +6,6 @@ Description: Plutarch utility functions that should be upstreamed or don't belon
Plutarch utility functions that should be upstreamed or don't belong anywhere else.
-}
module Agora.Utils (
findTxOutByTxOutRef,
scriptHashFromAddress,
findOutputsToAddress,
findTxOutDatum,
@ -20,7 +19,6 @@ module Agora.Utils (
validatorHashToAddress,
isScriptAddress,
isPubKey,
psingletonValue,
) where
--------------------------------------------------------------------------------
@ -47,19 +45,15 @@ import Plutarch.Api.V1 (
PMintingPolicy,
PTokenName (PTokenName),
PTuple,
PTxInInfo,
PTxOut,
PTxOutRef,
PValidatorHash,
PValue,
mintingPolicySymbol,
mkMintingPolicy,
)
import Plutarch.Api.V1.AssocMap (PMap (PMap))
import Plutarch.Api.V1.ScriptContext (pfindDatum, pfindTxInByTxOutRef)
import Plutarch.Api.V1.ScriptContext (pfindDatum)
import "liqwid-plutarch-extra" Plutarch.Api.V1.Value (psymbolValueOf)
import "plutarch" Plutarch.Api.V1.Value (PValue (PValue))
import Plutarch.Builtin (pforgetData, ppairDataBuiltin)
import Plutarch.Builtin (pforgetData)
import Plutarch.Extra.List (plookupTuple)
import Plutarch.Extra.TermCont (pletC, pmatchC)
@ -67,25 +61,6 @@ import Plutarch.Extra.TermCont (pletC, pmatchC)
All of these functions are quite inefficient.
-}
-- | Create a value with a single asset class.
psingletonValue ::
forall (keys :: KeyGuarantees) (amounts :: AmountGuarantees) (s :: S).
Term s (PCurrencySymbol :--> PTokenName :--> PInteger :--> PValue keys amounts)
psingletonValue = phoistAcyclic $
plam $ \sym tok int ->
let innerTup = pcon $ PMap $ psingleton #$ ppairDataBuiltin # pdata tok # pdata int
outerTup = pcon $ PMap $ psingleton #$ ppairDataBuiltin # pdata sym # pdata innerTup
res = pcon $ PValue outerTup
in res
-- | Finds the TxOut of an effect from TxInfo and TxOutRef
findTxOutByTxOutRef :: Term s (PTxOutRef :--> PBuiltinList (PAsData PTxInInfo) :--> PMaybe PTxOut)
findTxOutByTxOutRef = phoistAcyclic $
plam $ \txOutRef inputs ->
pmatch (pfindTxInByTxOutRef # txOutRef # inputs) $ \case
PJust ((pfield @"resolved" #) -> txOut) -> pcon $ PJust txOut
PNothing -> pcon PNothing
-- | Get script hash from an Address.
scriptHashFromAddress :: Term s (PAddress :--> PMaybe PValidatorHash)
scriptHashFromAddress = phoistAcyclic $

View file

@ -1,37 +1,37 @@
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,7664
Agora/Effects/Treasury Withdrawal Effect/effect/Simple,289254528,702155,3182
Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,448314458,1069267,3509
Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets,407878321,965148,3374
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/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,6654
Agora/Proposal/validator/cosignature/proposal,204468349,563576,6644
Agora/Proposal/validator/cosignature/stake,114125937,284821,4726
Agora/Proposal/validator/voting/proposal,166129664,437310,6583
Agora/Proposal/validator/voting/proposal,165922664,436410,6573
Agora/Proposal/validator/voting/stake,107127768,275725,4700
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/1 proposals/legal/retract votes and unlock stake while voting/1 proposals, voter, unlock stake + retract votes, VotingReady",189052005,492891,6583
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock the stake that has been used to create the proposal/1 proposals, creator, unlock stake, Finished",167586302,438831,6587
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Finished",166653391,439126,6587
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Locked",166653391,439126,6587
"Agora/Proposal/validator/unlocking/25 proposals/legal/retract votes and unlock stake while voting/25 proposals, voter, unlock stake + retract votes, VotingReady",1105824237,3030675,19333
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock the stake that has been used to create the proposal/25 proposals, creator, unlock stake, Finished",935680982,2549151,19483
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Finished",934748071,2549446,19434
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Locked",934748071,2549446,19434
Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,161811766,432942,6471
Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,160968344,431439,6474
Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,162664811,435045,6474
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,160681965,430212,6473
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,159273054,427507,6474
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,160404032,429911,6474
"Agora/Proposal/validator/unlocking/1 proposals/legal/retract votes and unlock stake while voting/1 proposals, voter, unlock stake + retract votes, VotingReady",188845005,491991,6573
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock the stake that has been used to create the proposal/1 proposals, creator, unlock stake, Finished",167379302,437931,6577
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Finished",166446391,438226,6577
"Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Locked",166446391,438226,6577
"Agora/Proposal/validator/unlocking/25 proposals/legal/retract votes and unlock stake while voting/25 proposals, voter, unlock stake + retract votes, VotingReady",1105617237,3029775,19323
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock the stake that has been used to create the proposal/25 proposals, creator, unlock stake, Finished",935473982,2548251,19473
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Finished",934541071,2548546,19424
"Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Locked",934541071,2548546,19424
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,262494214,690689,8180
Agora/Governor/validator/GATs minting,351739696,936062,8301
Agora/Governor/validator/mutate governor state,84905433,234687,7765
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

1 name cpu mem size
2 Agora/Effects/Treasury Withdrawal Effect/effect/Simple 289461528 289254528 703055 702155 3191 3182
3 Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries 448521458 448314458 1070167 1069267 3518 3509
4 Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets 408085321 407878321 966048 965148 3383 3374
5 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass 83758582 229228 7664 7665
6 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass 97345575 266935 3358
7 Agora/Stake/policy/stakeCreation 43114795 124549 2156
8 Agora/Stake/validator/stakeDepositWithdraw deposit 171823342 464745 4189
9 Agora/Stake/validator/stakeDepositWithdraw withdraw 171823342 464745 4177
10 Agora/Proposal/policy/proposalCreation 23140177 69194 1518
11 Agora/Proposal/validator/cosignature/proposal 204675349 204468349 564476 563576 6654 6644
12 Agora/Proposal/validator/cosignature/stake 114125937 284821 4726
13 Agora/Proposal/validator/voting/proposal 166129664 165922664 437310 436410 6583 6573
14 Agora/Proposal/validator/voting/stake 107127768 275725 4700
15 Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady 162018766 161811766 433842 432942 6481 6471
16 Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked 161175344 160968344 432339 431439 6484 6474
17 Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished 162871811 162664811 435945 435045 6484 6474
18 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished 160888965 160681965 431112 430212 6483 6473
19 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished 159480054 159273054 428407 427507 6484 6474
20 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished 160611032 160404032 430811 429911 6484 6474
21 Agora/Proposal/validator/unlocking/1 proposals/legal/retract votes and unlock stake while voting/1 proposals, voter, unlock stake + retract votes, VotingReady 189052005 188845005 492891 491991 6583 6573
22 Agora/Proposal/validator/unlocking/1 proposals/legal/unlock the stake that has been used to create the proposal/1 proposals, creator, unlock stake, Finished 167586302 167379302 438831 437931 6587 6577
23 Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Finished 166653391 166446391 439126 438226 6587 6577
24 Agora/Proposal/validator/unlocking/1 proposals/legal/unlock stake after voting/1 proposals, voter, unlock stake, Locked 166653391 166446391 439126 438226 6587 6577
25 Agora/Proposal/validator/unlocking/25 proposals/legal/retract votes and unlock stake while voting/25 proposals, voter, unlock stake + retract votes, VotingReady 1105824237 1105617237 3030675 3029775 19333 19323
26 Agora/Proposal/validator/unlocking/25 proposals/legal/unlock the stake that has been used to create the proposal/25 proposals, creator, unlock stake, Finished 935680982 935473982 2549151 2548251 19483 19473
27 Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Finished 934748071 934541071 2549446 2548546 19434 19424
28 Agora/Proposal/validator/unlocking/25 proposals/legal/unlock stake after voting/25 proposals, voter, unlock stake, Locked 934748071 934541071 2549446 2548546 19434 19424
29 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple 21017788 55883 806
30 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs 33204186 88241 900
31 Agora/Treasury/Validator/Positive/Allows for effect changes 29938856 79744 1390
32 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple 21017788 55883 806
33 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs 33204186 88241 900
34 Agora/Governor/policy/GST minting 43087287 120125 1829
35 Agora/Governor/validator/proposal creation 262494214 261928725 690689 689487 8180 8181
36 Agora/Governor/validator/GATs minting 351739696 352305185 936062 937264 8301 8302
37 Agora/Governor/validator/mutate governor state 84905433 234687 7765 7766