-
Notifications
You must be signed in to change notification settings - Fork 54
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
Transaction docs copy edit #589
Changes from all commits
5cfe980
fb6fbac
0cf4271
5b882cb
2d4abab
e328249
f116476
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,38 +1,48 @@ | ||
# Transaction Execution | ||
Transactions are being executed by the Miden Transaction Executor. Transaction execution results in a `ExecutedTransaction` object and consists of the following steps: | ||
The Miden transaction executor is the component that executes transactions. | ||
|
||
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 don't know how yet, but we could also try embedding this explanation here (https://crates.io/crates/miden-tx) into this chapter. My explanation has more information, but I like how concise the explanation on crate.io is. Also, when we show this code, it might be easier for some readers to follow. What do you think? ------8<------ The first requirement is to have a DataStore implementation. DataStore objects are responsible to load the data needed by the transactions executor, specially the account's code, the reference block data, and the note's inputs.
Once a store is available, a TransactionExecutor object can be used to execute a transaction. Consuming a zero or more notes, and possibly calling some of the account's code.
With the transaction execution done, it is then possible to create a proof:
And to verify a proof:
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. this is more of an API doc so I would add it separately in an API section of the docs, not in the architecture section ... let me know and i can do that 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. ok, indeed. Let's keep this as an architecture section |
||
Transaction execution consists of the following steps and results in a `ExecutedTransaction` object: | ||
|
||
1. Fetch the data required to execute a transaction from the data store. | ||
2. Compile the transaction into an executable [MASM](https://0xpolygonmiden.github.io/miden-vm/user_docs/assembly/main.html) program using the transaction compiler. | ||
3. Execute the transaction program and create an `ExecutedTransaction` object. | ||
4. Prove the `ExecutedTransaction` using the Transaction Prover. | ||
4. Prove the `ExecutedTransaction` using the transaction prover. | ||
|
||
<center> | ||
![Architecture core concepts](../../img/architecture/transaction/transaction-execution-process.png) | ||
![Transaction execution process](../../img/architecture/transaction/transaction-execution-process.png) | ||
</center> | ||
|
||
One of the main reasons for splitting execution and proving is that it allows to have "stateless provers" - i.e., the executed transaction contains all data needed to re-execute and prove a transaction (no database access is needed). This is very powerful and allows the distribution of proof generation much more easily. | ||
One of the main reasons for separating out the execution and proving steps is to allow _stateless provers_; i.e. the executed transaction has all the data it needs to re-execute and prove a transaction without database access. This supports easier proof-generation distribution. | ||
|
||
## Data store and transaction inputs | ||
|
||
The data store defines the interface that transaction objects use to fetch the data for transaction executions. Specifically, it provides the following inputs to the transaction: | ||
|
||
- `Account` data which includes the [AccountID](../accounts.md#account-id) and the [AccountCode](../accounts.md#code) that is executed during the transaction. | ||
- A `BlockHeader` which contains metadata about the block, commitments to the current state of the chain, and the hash of the proof that attests to the integrity of the chain. | ||
- A `ChainMmr` which authenticates consumed notes during transaction execution. Authentication is achieved by providing an inclusion-proof for the transaction's consumed notes against the `ChainMmr`-root associated with the latest block known at the time of transaction execution. | ||
- `InputNotes` consumed by the transaction that include the corresponding note data, e.g. the [note script](../notes.md#the-note-script) and serial number. | ||
|
||
!!! note | ||
- `InputNotes` must be already recorded on-chain in order for the transaction to succeed. - There is no nullifier-check during a transaction. Nullifiers are checked by the Miden operator during transaction verification. So at the transaction level, there is "double spending". | ||
|
||
## Transaction compiler | ||
|
||
Every transaction is executed within the Miden VM to generate a transaction proof. In Miden, there is a proof for every transaction. | ||
|
||
## The Data Store and Transaction Inputs | ||
The data store defines the interface that transaction objects use to fetch data required for transaction execution. It stores account, chain, and input note data required to execute a transaction against the account with the specified ID. | ||
The transaction compiler is responsible for building executable programs. The generated MASM programs can then be executed by the Miden VM which generates a zk-proof. In addition to transaction compilation, the transaction compiler provides methods for compiling Miden account code, note scripts, and transaction scripts. | ||
|
||
Specifically, it must provide the following inputs to the transaction | ||
Compilation results in an executable MASM program. The program includes the provided account interface and notes, an optional transaction script, and the [transaction kernel program](kernel.md). The transaction kernel program defines procedures and the memory layout for all parts of the transaction. | ||
|
||
- the `Account` including the [AccountID](https://0xpolygonmiden.github.io/miden-base/architecture/accounts.html#account-id) and the [AccountCode](https://0xpolygonmiden.github.io/miden-base/architecture/accounts.html#code) which will be executed during the transaction. | ||
- the `BlockHeader`, which contains metadata about the block, commitments to the current state of the chain and the hash of the proof that attests to the integrity of the chain. | ||
- the `ChainMmr`, which allows for efficient authentication of consumed notes during transaction execution. Authentication is achieved by providing an inclusion proof for the consumed notes in the transaction against the `ChainMmr`-root associated with the latest block known at the time of transaction execution. | ||
- the `InputNotes` that are being consumed in the transaction (InputNotes), including the corresponding note data, e.g. the [note script](https://0xpolygonmiden.github.io/miden-base/architecture/notes.html#script) and [serial number](https://0xpolygonmiden.github.io/miden-base/architecture/notes.html#serial-number). | ||
After compilation, assuming correctly-populated inputs, including the advice provider, the transaction can be executed. | ||
|
||
_Note: The `InputNotes` must all be already recorded on-chain in order for the transaction to succeed. And there is no Nullifier-check during a transaction. Nullifiers are being checked by the Miden Operator during transaction verification. So at the transaction level, there is "double spending"._ | ||
## Executed transactions and the transaction outputs | ||
|
||
## The Transaction Compiler | ||
Every transaction must be executed within the Miden VM to generate a transaction proof. In Miden there is a proof for every transaction. The transaction compiler is responsible for building executable programs. The generated programs - MASM programs - can then be executed on the Miden VM which generates a zkProof. In addition to transaction compilation, the transaction compiler provides methods which can be used to compile Miden account code, note scripts, and transaction scripts. | ||
The `ExecutedTransaction` object represents the result of a transaction not its proof. From this object, the account and storage delta can be extracted. Furthermore, the `ExecutedTransaction` is an input to the transaction prover. | ||
|
||
Compilation results in an executable MASM Program, including the provided account interface and notes, an optional transaction script and the [Transaction Kernel Program](kernel.md). The Transaction Kernel Program defines procedures and the memory layout for all parts of the transaction. A detailed description can be found in the next section. | ||
A successfully executed transaction results in a new account state which is a vector of all created notes (`OutputNotes`) and a vector of all the consumed notes (`InputNotes`) together with their nullifiers. | ||
|
||
Finally, after the transaction program has been compiled and the inputs including the advice provider were correctly populated, the transaction can be executed. | ||
## Transaction prover | ||
|
||
## The Executed Transaction and the Transaction Outputs | ||
The `ExecutedTransaction` object represents the result of a transaction - not its proof yet. From it, the account, and storage delta can be extracted. Furthermore, it serves as an input of the transaction prover to generate the proof. A successfully executed transaction results in a new state of the provided account, a vector of all created Notes (`OutputNotes`) and a vector of all the consumed Notes (`InputNotes`) together with their Nullifiers. | ||
The transaction prover proves the inputted `ExecutedTransaction` and returns a `ProvenTransaction` object. The Miden node verifies the `ProvenTransaction` object using the transaction verifier and, if valid, updates the [state](../state.md) databases. | ||
|
||
## The Transaction Prover | ||
The Transaction Prover proves the provided `ExecutedTransaction` and returns a `ProvenTransaction` object. This object can be verified by the Miden Node using the Transaction Verifier and if valid updating the [State](../../architecture/state.md) databases. | ||
<br/> |
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.
Do you think we need a transition to the next chapter, the kernel?
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.
let's chat about the flow in this doc because i need to understand it better, and to answer your question, maybe yes
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.
Sure, let's have a short call. I will ping you after lunch