Skip to content

Commit

Permalink
Remove GovernanceActionId from the Voting script purpose (#5708)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 authored Jan 10, 2024
1 parent eaa817b commit 81ac3ed
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,6 @@
{all dead. dead})
{all dead. dead})
{all dead. dead}
!`$fUnsafeFromDataList_$cunsafeFromBuiltinData` :
all a. (\a -> data -> a) a -> data -> List a
= /\a ->
\(`$dUnsafeFromData` : (\a -> data -> a) a) ->
letrec
!go : list data -> List a
= \(l : list data) ->
chooseList
{data}
{Unit -> List a}
l
(\(ds : Unit) -> Nil {a})
(\(ds : Unit) ->
Cons
{a}
(`$dUnsafeFromData` (headList {data} l))
(go (tailList {data} l)))
Unit
in
\(d : data) -> go (unListData d)
!`$fUnsafeFromDataTxId_$cunsafeFromBuiltinData` : data -> bytestring
= \(d : data) ->
let
Expand Down Expand Up @@ -160,6 +140,26 @@
(unIData (headList {data} (tailList {data} args))))
(/\dead -> traceError {GovernanceActionId} reconstructCaseError)
{all dead. dead}
!`$fUnsafeFromDataList_$cunsafeFromBuiltinData` :
all a. (\a -> data -> a) a -> data -> List a
= /\a ->
\(`$dUnsafeFromData` : (\a -> data -> a) a) ->
letrec
!go : list data -> List a
= \(l : list data) ->
chooseList
{data}
{Unit -> List a}
l
(\(ds : Unit) -> Nil {a})
(\(ds : Unit) ->
Cons
{a}
(`$dUnsafeFromData` (headList {data} l))
(go (tailList {data} l)))
Unit
in
\(d : data) -> go (unListData d)
data TxOutRef | TxOutRef_match where
TxOutRef : bytestring -> integer -> TxOutRef
!`$fUnsafeFromDataTxOutRef_$cunsafeFromBuiltinData` : data -> TxOutRef
Expand Down Expand Up @@ -502,7 +502,7 @@
Proposing : integer -> ScriptPurpose
Rewarding : Credential -> ScriptPurpose
Spending : TxOutRef -> ScriptPurpose
Voting : Voter -> GovernanceActionId -> ScriptPurpose
Voting : Voter -> ScriptPurpose
!`$fUnsafeFromDataScriptContext_$cunsafeFromBuiltinData` :
data -> ScriptPurpose
= \(d : data) ->
Expand Down Expand Up @@ -546,11 +546,7 @@
(/\dead ->
Voting
(`$fUnsafeFromDataScriptContext_$cunsafeFromBuiltinData`
(headList {data} args))
(`$fUnsafeFromDataGovernanceAction_$cunsafeFromBuiltinData`
(headList
{data}
(tailList {data} args))))
(headList {data} args)))
(/\dead ->
ifThenElse
{all dead. ScriptPurpose}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2816
2807
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,6 @@
{all dead. dead})
{all dead. dead})
{all dead. dead}
in
letrec
data (List :: * -> *) a | List_match where
Nil : List a
Cons : a -> List a -> List a
in
let
!`$fUnsafeFromDataList_$cunsafeFromBuiltinData` :
all a. (\a -> data -> a) a -> data -> List a
= /\a ->
\(`$dUnsafeFromData` : (\a -> data -> a) a) ->
letrec
!go : list data -> List a
= \(l : list data) ->
chooseList
{data}
{Unit -> List a}
l
(\(ds : Unit) -> Nil {a})
(\(ds : Unit) ->
Cons
{a}
(`$dUnsafeFromData` (headList {data} l))
(go (tailList {data} l)))
Unit
in
\(d : data) -> go (unListData d)
!`$fUnsafeFromDataTxId_$cunsafeFromBuiltinData` : data -> bytestring
= \(d : data) ->
let
Expand Down Expand Up @@ -121,6 +94,33 @@
(unIData (headList {data} (tailList {data} args))))
(/\dead -> traceError {GovernanceActionId} reconstructCaseError)
{all dead. dead}
in
letrec
data (List :: * -> *) a | List_match where
Nil : List a
Cons : a -> List a -> List a
in
let
!`$fUnsafeFromDataList_$cunsafeFromBuiltinData` :
all a. (\a -> data -> a) a -> data -> List a
= /\a ->
\(`$dUnsafeFromData` : (\a -> data -> a) a) ->
letrec
!go : list data -> List a
= \(l : list data) ->
chooseList
{data}
{Unit -> List a}
l
(\(ds : Unit) -> Nil {a})
(\(ds : Unit) ->
Cons
{a}
(`$dUnsafeFromData` (headList {data} l))
(go (tailList {data} l)))
Unit
in
\(d : data) -> go (unListData d)
data TxOutRef | TxOutRef_match where
TxOutRef : bytestring -> integer -> TxOutRef
!`$fUnsafeFromDataTxOutRef_$cunsafeFromBuiltinData` : data -> TxOutRef
Expand Down Expand Up @@ -469,7 +469,7 @@
Proposing : integer -> ScriptPurpose
Rewarding : Credential -> ScriptPurpose
Spending : TxOutRef -> ScriptPurpose
Voting : Voter -> GovernanceActionId -> ScriptPurpose
Voting : Voter -> ScriptPurpose
!`$fUnsafeFromDataScriptContext_$cunsafeFromBuiltinData` :
data -> ScriptPurpose
= \(d : data) ->
Expand Down Expand Up @@ -513,11 +513,7 @@
(/\dead ->
Voting
(`$fUnsafeFromDataScriptContext_$cunsafeFromBuiltinData`
(headList {data} args))
(`$fUnsafeFromDataGovernanceAction_$cunsafeFromBuiltinData`
(headList
{data}
(tailList {data} args))))
(headList {data} args)))
(/\dead ->
ifThenElse
{all dead. ScriptPurpose}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2756
2747
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

### Changed

- Removed `GovernanceActionId` from the `Voting` script purpose. It is not needed because
the script for a given voter will be run only once for all votes.
6 changes: 3 additions & 3 deletions plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ data ScriptPurpose
| Spending V2.TxOutRef
| Rewarding V2.Credential
| Certifying TxCert
| Voting Voter GovernanceActionId
| Voting Voter
| Proposing Haskell.Integer
deriving stock (Generic, Haskell.Show, Haskell.Eq)
deriving (Pretty) via (PrettyShow ScriptPurpose)
Expand All @@ -339,8 +339,8 @@ instance PlutusTx.Eq ScriptPurpose where
a PlutusTx.== a'
Certifying a == Certifying a' =
a PlutusTx.== a'
Voting a b == Voting a' b' =
a PlutusTx.== a' PlutusTx.&& b PlutusTx.== b'
Voting a == Voting a' =
a PlutusTx.== a'
Proposing a == Proposing a' =
a PlutusTx.== a'
_ == _ = Haskell.False
Expand Down

1 comment on commit 81ac3ed

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Plutus Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 81ac3ed Previous: eaa817b Ratio
validation-decode-auction_1-2 555.4 μs 522.7 μs 1.06
validation-decode-ping-pong-1 492.4 μs 468.7 μs 1.05

This comment was automatically generated by workflow using github-action-benchmark.

CC: @input-output-hk/plutus-core

Please sign in to comment.