Updated Transaction Snark Statement #12000
Replies: 4 comments 10 replies
-
Can you clarify in the prose what the two parallel ledgers correspond to earlier in the doc? Is it that the first ledger reflects only the first pass with the fees and legacy transactions and the second pass does all the zkapp account updates assuming that the first ledger pass has already been completed? I was able to infer this from the rest of the presentation but it could be more clear to save the next person reading some time I think.
I don’t fully understand why this happens. Can you be more specific about the case where this happens? Assuming that this does happen: I didn’t follow the presentation in the prose, but in the code snippet comment, using the subscripts and naming the extra carrying information as the “block midpoint” elucidated this for me. I like this representation, I think it’s a good way to think about the problem. Everything is clear for me up to here:
Why are these checks exhausted and why do these rules reduce recursively except in this extra case? I’ll also follow up with @mrmr1993 in person tomorrow and either myself or maybe he will clarify. |
Beta Was this translation helpful? Give feedback.
-
Why do the two phases help? |
Beta Was this translation helpful? Give feedback.
-
I'm looking at https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-zkapps.md and trying to understand the reasoning. |
Beta Was this translation helpful? Give feedback.
-
I don't believe this two-pass systems solves any issues if you use a Bitcoin-like mempool. |
Beta Was this translation helpful? Give feedback.
-
As part of making the network secure against transaction pool DDoS attacks once zkApps are introduced to the network, we are splitting up transaction application within a block into 2 distinct phases. In the first phase, we apply normal signed commands in their entirety, and we apply the fee payer portion of zkApps commands. Once we are done with that phase, we take the ledger we achieved and use that to attempt to apply all of the account updates from each of the zkApps commands, skipping the command entirely if any of the account updates fail.
At the transaction snark level, this is modeled as if we are modifying 2 ledgers in parallel: the first pass ledger and the second pass ledger. The sequencing of building these ledgers and associated witnesses correctly are done outside of the snark, but from within the snark we must treat the ledger applications as if they are happening at the same time. This brings some unique challenges to our transaction snark statements, and requires us to expand the statements to not only support parallel ledgers we apply to, but also to ensure that the sequence second phase ledgers are properly connected to the final first phase ledger achieved by a transaction within a given block.
This writeup describes what those changes are, explains why they are necessary, and reviews the new merge rules necessary to reason about these statements safely.
This is an open discussion and is up for review. Please point out any discrepancies you find so we can address them.
Reviewing the old statement
To review the current transaction snark statement format, a transaction snark statement attests to a valid transition from a source ledger to a target ledger, as transitioned by a set of proven transaction applications. We can represent a transaction snark statement with the syntax
S -> T
to represent that the source ledgerS
has been taken to the target ledgerT
, as attested to by the associated snark proof.New statement
With the updated fee payment model for zkapps, transaction snark statements must now reason about 2 separate passes of ledger transitions rather than just a single ledger transition. The data flow of these ledger transitions is split up over a series of individual base snark statements, which can even span across multiple trees of the transaction parallel scan state. We can represent these 2 ledger transitions with the syntax
(S1 -> T1, S2 -> T2)
, where the first transition takesS1
toT1
, and the second transition takesS2
toT2
.A sequence of transaction snark statements attesting to 2 parallel transitions on ledgers at the same time need to eventually pair up to ensure that the sequences join together correctly. Concretely, each pair of transitions
(S1 -> T1, S2 -> T2)
has an inherent assumption that there exists some transition that bringsT1 -> S2
so that eventually we can build a transition takingS1 -> T2
, making the ledger transition across multiple proof statements finally whole. It is, however, possible that we can have 2 of these assumption at once, in the case where we have merged together 2 transaction snark statements from 2 different incomplete sequences of parallel ledger transitions. For this reason, the new transaction snark statements must track 2 assumptions regarding what ledgers will eventually connect the 2 parallel ledger transitions together: a lower assumption, and an upper assumption. We syntactically represent the entire new transaction snark statement as[X, Y] (S1 -> T1, S2 -> T2)
to represent that the parallel ledger transitions hold assumptionsX
andY
as the ledgers which will eventually glue the 2 sets of transitions together.This is rather confusing to think about, so I will attempt to describe this in a slightly simpler way. With the parallel ledger application scheme, for the entire sequence of transactions included in a single block, the transaction snark statement of the entire sequence would be
[0, 0] (A -> C, C -> E)
. This statement shows that the first pass starts with ledgerA
and gives us ledgerC
, and that the second pass starts with ledgerC
and gives us ledgerE
, so the statement as a whole attests to the transition of ledgerA
to ledgerE
. There are no assumption necessary in this statement because the target of the first pass is equal to the source of the second pass. When we represent the base statements of transactions within this sequence, however, we take on an assumption. Let's take the base statement for the first transaction in the sequence as an example:[C, C] (A -> B, C -> D)
. This transaction statement can only attest to the ledger transitions done by this transaction to each of the parallel ledgers, but cannot attest that the ledger achieved in total by the end of the first pass is the ledger that was used to start the second pass. As such, it takes on an assumption forC
, stating thatC
must eventually be matched as the target/source pair for each of the ledger passes.In this case, we are only looking at statements within a single sequence of transactions, so the lower and upper assumptions are always the same. However, in the parallel scan state, we may end up merging statements together which both have assumptions from different transaction sequences, which is when we will use both the lower and upper assumptions. For instance, we we merge a statement on the left containing an assumption
[X, X]
into a statement on the right containing an assumption[Y, Y]
, then we will get a statement containing both assumptions[X, Y]
. In this situation, we are looking to satisfy a pending assumption of a ledgerX
on the left hand side, and a pending assumption of ledgerY
on the right hand side.Merging rules
Open question: is a merge rule needed for the case$[X,Y](..,..)\cup[Y,Z](..,..)$ ?
A simple example
A
:[L3,L3] (L1→L2, L3→L4)
B
:[L3,L3] (L2→L3, L4→L5)
C
:[L7,L7] (L5→L6, L7→L8)
D
:[L7,L7] (L6→L7, L8→L9)
A∪B
:[0,0] (L1→L3, L3→L5)
C∪D
:[0,0] (L5→L7,L7→L9)
B∪C
:[L3,L7] (L2→L6, L4→L8)
Here we assume:
L3→L4
,L6→L7
.A∪(B∪C)
:[L3,L3] (L1→L2, L3→L4) ∪ [L3,L7] (L2→L6, L4→L8)
=[L7,L7] (L1→L6,L7→L8)
Here we assume:
L6→L7
.We proved that
L3→L4
because(B∪C)∪D
:[L3,L7] (L2→L6, L4→L8) ∪ [L7,L7] (L6→L7, L8→L9)
=[L3,L3] (L2→L3, L4→L9)
Here we assume:
L3→L4
.We proved that
L6→L7
.Implications in the blockchain state and blockchain snark
Because transaction sequences for a single block can span across more than one tree of the parallel scan state, the blockchain state must now fold over the transaction snark statements emitted from the staged ledger, and the blockchain snark must use the transaction snark statement merge rules to constrain what the next emitted statement is allowed to be. To facilitate this, we will add a new field to the blockchain state which stores the last emitted transaction snark scan statement.
Lightweight proof and pseudocode by Matthew
@mrmr1993 was kind enough to write up a lightweight proof attesting to the fact that the described method of updating the transaction snark statement is correct. The rules for merging were written independently of this proof, so please check this for discrepancies against the documented merge rules.
Beta Was this translation helpful? Give feedback.
All reactions