-
Notifications
You must be signed in to change notification settings - Fork 20
Fix links in Rewards module; migrate Transaction #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
63c306e
0a39747
56cb7ec
021604b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
| \section{Transactions} | ||
| \label{sec:transactions} | ||
| \modulenote{\ConwayModule{Transaction}}, where we define transactions. | ||
| --- | ||
| source_branch: master | ||
| source_path: src/Ledger/Conway/Specification/Transaction.lagda | ||
| --- | ||
|
|
||
| A transaction consists of a transaction body, a collection of witnesses and some optional auxiliary | ||
| data. | ||
| # Transactions {#sec:transactions} | ||
|
|
||
| \begin{code}[hide] | ||
| A transaction consists of a transaction body, a collection of witnesses | ||
| and some optional auxiliary data. | ||
|
|
||
| <!-- | ||
| ```agda | ||
| {-# OPTIONS --safe #-} | ||
| -------------------------------------------------------------------------------- | ||
| -- NOTE: Everything in this module is part of TransactionStructure | ||
|
|
@@ -31,45 +35,49 @@ open import Relation.Nullary.Decidable using (⌊_⌋) | |
| data Tag : Type where | ||
| Spend Mint Cert Rewrd Vote Propose : Tag | ||
| unquoteDecl DecEq-Tag = derive-DecEq ((quote Tag , DecEq-Tag) ∷ []) | ||
| ``` | ||
| --> | ||
|
|
||
| Here are some key components of the transaction body. | ||
|
|
||
| + `txIns`{.AgdaField} denotes a set of transaction inputs; each input consists of a | ||
| transaction id and an index that points to a unique output from a previous transaction. | ||
|
|
||
| + `txOuts`{.AgdaField} denotes an indexed collection of transaction outputs; each output | ||
| consists of an address and a coin value. | ||
|
|
||
| + `txFee`{.AgdaField} denotes a transaction fee to be added to the fee pot. | ||
|
|
||
| + `txId`{.AgdaField} denotes the hash of the serialized form of the | ||
| transaction---the form in which the transaction is included in a block. | ||
|
|
||
| In addition to these, the Conway era introduces some new fields to the transaction body. | ||
|
|
||
| + `txGovVotes`{.AgdaField} denotes the list of votes for governance actions. | ||
|
|
||
| + `txGovProposals`{.AgdaField} denotes the list of governance proposals. | ||
|
|
||
| + `txDonation`{.AgdaField} denotes the amount of `Coin`{.AgdaFunction} to donate to | ||
| treasury, e.g., to return funds to the treasury after a governance action. | ||
|
|
||
| + `currentTreasury`{.AgdaField} denotes the current value of the treasury; this serves | ||
| as a precondition to executing Plutus scripts that access the value of the treasury. | ||
|
|
||
|
|
||
| ## Transaction Types | ||
|
|
||
| \end{code} | ||
|
|
||
| \begin{NoConway} | ||
| Some key ingredients in the transaction body are: | ||
| \begin{itemize} | ||
| \item A set \txIns{} of transaction inputs, each of which identifies an output from | ||
| a previous transaction. A transaction input consists of a transaction id and an | ||
| index to uniquely identify the output. | ||
| \item An indexed collection \txOuts{} of transaction outputs. | ||
| The \TxOut{} type is an address paired with a coin value. | ||
| \item A transaction fee. This value will be added to the fee pot. | ||
| \item The hash \txid{} of the serialized form of the | ||
| transaction that was included in the block. | ||
| \end{itemize} | ||
| \end{NoConway} | ||
| \begin{Conway} | ||
| Ingredients of the transaction body introduced in the Conway era are the following: | ||
| \begin{itemize} | ||
| \item \txvote{}, the list of votes for goverance actions; | ||
| \item \txprop{}, the list of governance proposals; | ||
| \item \txDonation{}, amount of \Coin{} to donate to treasury, e.g., to return money | ||
| to the treasury after a governance action; | ||
| \item \currentTreasury{}, the current value of the treasury. This field serves as a | ||
| precondition to executing Plutus scripts that access the value of the treasury. | ||
| \end{itemize} | ||
| \end{Conway} | ||
|
|
||
| \begin{figure*}[ht] | ||
| \begin{code}[hide] | ||
| ```agda | ||
| record TransactionStructure : Type₁ where | ||
| field | ||
| \end{code} | ||
| \emph{Abstract types} | ||
| \begin{code} | ||
| ``` | ||
|
|
||
| *Abstract types* | ||
| ```agda | ||
| Ix TxId AuxiliaryData : Type | ||
| ``` | ||
|
|
||
| \end{code} | ||
| \begin{code}[hide] | ||
| <!-- | ||
| ```agda | ||
| ⦃ DecEq-Ix ⦄ : DecEq Ix | ||
| ⦃ DecEq-TxId ⦄ : DecEq TxId | ||
| adHashingScheme : isHashableSet AuxiliaryData | ||
|
|
@@ -114,26 +122,29 @@ record TransactionStructure : Type₁ where | |
| open GovActions hiding (Vote; yes; no; abstain) public | ||
|
|
||
| open import Ledger.Conway.Specification.Certs govStructure | ||
| \end{code} | ||
| \begin{NoConway} | ||
| \emph{Derived types} | ||
| \begin{code} | ||
| ``` | ||
| --> | ||
|
|
||
| *Derived types* | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comment |
||
| ```agda | ||
| TxIn = TxId × Ix | ||
| TxOut = Addr × Value × Maybe (Datum ⊎ DataHash) × Maybe Script | ||
| UTxO = TxIn ⇀ TxOut | ||
| RdmrPtr = Tag × Ix | ||
| ProposedPPUpdates = KeyHash ⇀ PParamsUpdate | ||
| Update = ProposedPPUpdates × Epoch | ||
| \end{code} | ||
| \begin{code}[hide] | ||
| ``` | ||
|
|
||
| <!-- | ||
| ```agda | ||
| record HasUTxO {a} (A : Type a) : Type a where | ||
| field UTxOOf : A → UTxO | ||
| open HasUTxO ⦃...⦄ public | ||
| \end{code} | ||
| \end{NoConway} | ||
| \emph{Transaction types} | ||
| \begin{AgdaMultiCode} | ||
| \begin{code} | ||
| ``` | ||
| --> | ||
|
|
||
| *Transaction types* | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comments |
||
| ```agda | ||
| record TxBody : Type where | ||
| field | ||
| txIns : ℙ TxIn | ||
|
|
@@ -155,8 +166,10 @@ record TransactionStructure : Type₁ where | |
| reqSignerHashes : ℙ KeyHash | ||
| scriptIntegrityHash : Maybe ScriptHash | ||
| -- txup : Maybe Update -- deprecated; leave for now | ||
| \end{code} | ||
| \begin{code}[hide] | ||
| ``` | ||
|
|
||
| <!-- | ||
| ```agda | ||
| record HasTxBody {a} (A : Type a) : Type a where | ||
| field TxBodyOf : A → TxBody | ||
| open HasTxBody ⦃...⦄ public | ||
|
|
@@ -176,10 +189,11 @@ record TransactionStructure : Type₁ where | |
| instance | ||
| HasDonations-TxBody : HasDonations TxBody | ||
| HasDonations-TxBody .DonationsOf = TxBody.txDonation | ||
| \end{code} | ||
| ``` | ||
| --> | ||
|
|
||
|
|
||
| \begin{NoConway} | ||
| \begin{code} | ||
| ```agda | ||
| record TxWitnesses : Type where | ||
| field | ||
| vkSigs : VKey ⇀ Sig | ||
|
|
@@ -197,8 +211,10 @@ record TransactionStructure : Type₁ where | |
| txsize : ℕ | ||
| isValid : Bool | ||
| txAD : Maybe AuxiliaryData | ||
| \end{code} | ||
| \begin{code}[hide] | ||
| ``` | ||
|
|
||
| <!-- | ||
| ```agda | ||
| instance | ||
| HasTxBody-Tx : HasTxBody Tx | ||
| HasTxBody-Tx .TxBodyOf = Tx.body | ||
|
|
@@ -223,17 +239,14 @@ record TransactionStructure : Type₁ where | |
|
|
||
| HasDonations-Tx : HasDonations Tx | ||
| HasDonations-Tx .DonationsOf = DonationsOf ∘ TxBodyOf | ||
| \end{code} | ||
| \end{NoConway} | ||
| \end{AgdaMultiCode} | ||
| \caption{Transactions and related types} | ||
| \label{fig:defs:transactions} | ||
| \end{figure*} | ||
|
|
||
| \begin{NoConway} | ||
| \begin{figure*}[ht] | ||
| \begin{AgdaMultiCode} | ||
| \begin{code} | ||
| ``` | ||
| --> | ||
|
|
||
|
|
||
| ## Transaction Functions | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auxiliary functions?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better if the header of the section of each module where functions related to that module are defined should refer to the name of the module itself; we already do this elsewhere, e.g., "Certification Functions" (or "Certificates Functions"?), "Governance Functions", etc. Making the subsection titles more specific, less generic, seems preferable to me. |
||
|
|
||
|
|
||
| ```agda | ||
| getValue : TxOut → Value | ||
| getValue (_ , v , _) = v | ||
|
|
||
|
|
@@ -266,15 +279,13 @@ record TransactionStructure : Type₁ where | |
| lookupScriptHash : ScriptHash → Tx → UTxO → Maybe Script | ||
| lookupScriptHash sh tx utxo = lookupᵐ? m sh | ||
| where m = setToMap (mapˢ < hash , id > (txscripts tx utxo)) | ||
| \end{code} | ||
| \end{AgdaMultiCode} | ||
| \caption{Functions related to transactions} | ||
| \label{fig:defs:transaction-funs} | ||
| \end{figure*} | ||
| \end{NoConway} | ||
|
|
||
| \begin{code}[hide] | ||
| ``` | ||
|
|
||
| <!-- | ||
| ```agda | ||
| instance | ||
| HasCoin-TxOut : HasCoin TxOut | ||
| HasCoin-TxOut .getCoin = coin ∘ proj₁ ∘ proj₂ | ||
| \end{code} | ||
| ``` | ||
| --> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make these headings into subsubsections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... that might be a good idea. I'm not sure. We've always had these kinds of type labels, since the era of pdfs. Of course, that doesn't mean it's the right way to present them. But I wonder if it's best to keep record types contained in a single subsection, rather than spreading their fields across subsections. 🤔 That might be better for getting a "high level" understanding of the code. Though I suppose splitting a large record up into subsections with explanatory prose would make it easier to explain things at a "low level."
Well, I'll leave it for now and we can discuss whether improvements should be made in a future issue/PR.