-
Notifications
You must be signed in to change notification settings - Fork 56
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
[Docs]: Update Transaction
#1114
base: main
Are you sure you want to change the base?
Changes from all commits
45ebeff
79f11b5
c9cf249
9108c96
0380230
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Transaction | ||
|
||
`Transaction`s are a mechanism by which the state of the chain is updated. That is, all changes in account and note states result from executing `Transaction`s. In Miden, `Transaction`s can originate either from the users or from the network itself. | ||
|
||
Miden aims for the following characteristics in `Transaction`s: | ||
|
||
- **Parallel transaction execution**: Because a transaction is always performed against a single account, Miden obtains asynchronicity. | ||
- **Private transaction execution**: Local execution of transactions enables preservation of sensitive data. | ||
|
||
## What is the purpose of a transaction? | ||
|
||
In Miden, a `Transaction` represents the state transition of a single account. A `Transaction` takes a single [account](accounts.md) and zero or more [notes](notes.md), and none or one script (piece of code executed after all notes have been executed) as input, and outputs the same account with a potentially updated state, together with some potential newly created notes. | ||
|
||
![Transaction diagram](../img/architecture/transaction/transaction-diagram.png) | ||
|
||
## Transaction core components | ||
|
||
WIP | ||
Comment on lines
+16
to
+18
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 we are missing quite a bit of information about what transactions are and what they can do and maybe this is the section this info is supposed to go to? The things we should cover (at the high level):
We don't need to go into all of the above topics in depth, but we should make sure a somewhat technical person can come away with good understanding of how transactions work and what they provide. I would also add a "real-world" example of how transactions accomplish some task - e.g., transferring funds from one account to another. |
||
|
||
## Transaction types | ||
|
||
There are two types of transactions in Miden: **local transactions** and **network transactions**. | ||
|
||
![Local vs network transactions](../img/architecture/transaction/local-vs-network-transaction.png) | ||
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 know this comes from our deck, but this diagram is actually not correct. All steps happen in both cases - just who does them differs. |
||
|
||
### Local transactions | ||
|
||
This is where clients executing the transactions also generate the proofs of their correct execution. So, no additional work needs to be performed by the network. | ||
|
||
Local transactions are useful for several reasons: | ||
|
||
1. They are cheaper (i.e., lower fees) as zk-proofs are already generated by the clients. | ||
2. They allow fairly complex computations because the proof size doesn't grow linearly with the complexity of the computation. | ||
3. They enable privacy as neither the account state nor account code are needed to verify the zk-proof. | ||
Comment on lines
+28
to
+34
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 we can improve this section to make sure it really stands out. Local transactions is something that most other chains cannot do. They basically enabled theoretically unbounded computation complexity (e.g., no more gas limits). I would also make sure that this is not just for users - apps can benefit from this too. e.g., we can have apps running their logic off-chain (either in a centralized or decentralized mode) to minimize fees, not be subject to network congestion etc. |
||
|
||
### Network transactions | ||
|
||
This is where the operator executes the transaction and generates the proofs. | ||
|
||
Network transactions are useful for two reasons: | ||
|
||
1. Clients may not have sufficient resources to generate zk-proofs. | ||
2. Executing many transactions against the same public account by different clients is challenging, as the account state changes after every transaction. Due to this, the Miden node/operator acts as a "synchronizer" to execute transactions sequentially by feeding the output of the previous transaction into the input of the next. | ||
Comment on lines
+42
to
+43
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. The first point is not correct - I would get rid of it. Network transactions are there basically for 2 reasons:
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. Could you clarify why the first point is not true? I have the feeling that the second point is a very specific use case of networked tx's and does not really have it's place there. But it could be argued. 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.
Network transactions do not help resource-constrained clients. That is, for the network transaction to happen, the client still needs to put a note intended for this transaction on-chain. So, they still need to generate a proof for this transaction. What helps resource-constrained clients is delegated proving - but that's different from network transactions.
Yeah, we probably don't need to describe it in such detail but maybe there is a good way to mention it in 1 - 2 sentences as an example of what network transactions could be used for. 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.
Does that mean that in Miden there is no way for a user to make a transaction without executing the VM and Prover? Would a user have the ability to make a transaction like in Ethereum by simply signing a message? ( I guess this would work for public accounts but not for local / private accounts ) 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.
Without executing - no, without proving, yes. That is, the user could execute a transaction but delegate proving to someone else (at the expense of giving up privacy to this someone).
Doing something like this today would be pretty difficult. The biggest question is, what message would the user sign? For example, if we want someone else to execute a transaction on our behalf, we need to give them enough info to complete the transaction. Currently, the means a signature over a message that is derived from: initial account state, final account state, all input notes of the transaction, all output notes of a transaction. If someone can produce such a message (and a corresponding signature), then someone else can create a transaction for them. However, building such a messages for a general transaction would mean executing the VM (to get the final state of the account and output notes). For a specialized transaction, we can probably compute these without running the VM (e.g., if we consume a P2ID note, we know how the account will be updated - so, no need to run the VM to get the account's final state). Another option could be to re-define what is being signed (and this can be specified on per-account basis). Maybe it is enough to sign over initial account state + input notes, but this needs to be analyzed more carefully to make sure we don't open up any attack vectors. |
||
|
||
## Transaction lifecycle | ||
|
||
In Miden, every `Transaction` is executed within the Miden VM. Throughout its lifetime, a `Transaction` progresses through various phases: | ||
|
||
1. **Compilation:** All `Transaction` inputs (account, notes, script) are compiled into an executable Miden program. | ||
2. **Execution:** The `Transaction` program is executed within the Miden VM, which produces outputs (updated account, notes). | ||
3. **Proving:** The executed `Transaction` is proven by the Miden prover. | ||
|
||
![Transaction execution process](../img/architecture/transaction/transaction-execution-process.png) | ||
|
||
> **Info** | ||
> - 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. | ||
Comment on lines
+45
to
+56
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'm not sure we need to mention compilation/execution/proving in this section - it feels like lower-level details that can be explained somewhere else. I would talk about proving costs and delegated proving though - but maybe as a part of some other section above. |
This file was deleted.
This file was deleted.
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.
To me this digram is somewhat confusing. I would use something simpler (which have a simpler version in the deck). The proportions of the graphic are also off (it is too big).