-
Notifications
You must be signed in to change notification settings - Fork 125
In-circuit anchor transaction checks #67
Comments
The Anchor Checks:What do we need to check?
Annotations
Circuit LayoutWe don't need a more circuit to prove the anchor transaction, and using the
How to constrainUse the New Public InputThe old public input format: https://www.notion.so/taikoxyz/New-public-input-circuit-3c556ac6452b47e486f2315c0dbe1fc0?pvs=4 The new oneBecause we need check the anchor transaction's parameters, so we need extra inputs from l1 contract:
ConclusionThe easiest way to check the anchor transaction is trying to constant all the fields with fixed cells, TBD
|
What do you mean with "from witness" here?
So we are going to with a new transaction type? I heard from David that that may not be the plan anymore.
Can you explain a bit more how you will handle the anchor transaction and all other transactions, ensuring the anchor transaction has the expected data while still checking that all other transaction data matches the ones passed into the smart contract.
What is still an open question about this? |
I mean that
Because we don't need sign the anchor transaction anymore, so if we reuse the same tx types, it is not easy to deal with in l2-node. Let me ask David to double check
I think the main problem is that if we support both legacy and 1559, the rlp_decode and tx_table(maybe any other parts) need to be refactored. Away from PSE 🤣 |
Right, hopefully the rlp circuit @smtmfft is working on will make this easy! |
Maybe an extra |
The another import thing is that the execution of anchor transaction MUST be success! (because our zkevm has invalid tx |
I think just an extra fixed selector to handle it should work, it's basically just merging in the anchor transaction data into the txlist data right? Not sure why this would be too complex? Something like this:
We rlc all tx_list_bytes and hash it so that we can check that it equals the value in the public input |
No need to worry about that, with the fixed amount of gas supplied it cannot fail. |
Yeah, I think so
Oh, I mean the |
Right :) Please think about how it could be simplified if you think it's a problem. |
Now, the pi_circuit also checks the tx_table's constrains, it doesn't make scene. I mean if we can put these constrains to the tx_circuit. |
Not sure when PSE will support 1559, but for us, supporting 1559 seems inevitable now. I think we can enable it in outside gadgets such as RLP or TX circuit, However, since protocol/node goes ahead further, it might delay we enable evm/state (kind of core circuits) for a long time, as which do not support 1559 tx. |
The architectureThe new architecture based on master branch(taiko-pi-test branch is too old, and the TxTable's layout between two branches are different). Data FlowHow It works?So, we need three
Finally, all these tables will be associated with The AnchorCircuit's goalIn Anchor circuit we only care about the InputWe use the OutputThe ConstantsWe need some fixed fields for storing the Anchor's constants:
We can fill the fixed column with witness data for convenience, the verification will be failed when we use different constants TxTable2The Q&AQ: Why do we need check both Q: Why do we need three tables, TxCircuit
AnchorCircuit
The tx's id will be increased by 1 in AnchorCircuit. InvalidCircuit
Add invalid flag into TxTable please review and comment cc @smtmfft |
In addition, we don't need the |
The Anchor's Nonce will be checked in the invalid circuit, because both the |
I think we need them (see comment in protocols PR).
I guess it depends on what is easiest, but I don't think it really needs to go through the invalid circuit checks. We just force the anchor transaction to always be valid, that means the prover has to fill in a valid |
So these will all have their own separate columns, as in actually different tables? If so, why not just insert the anchor tx bytes before the tx list bytes, check if the data is valid, and then decode the data in a single tx table? |
Yeah, This is the second way we discussed |
But, we already have the invalid TxTable, and we only add an extra table for anchor transaction. But if we insert the rlp bytes into the head of txlist, we need copy the input's bytes and add more other logic in our RlpCircuit, maybe the RlpCircuit will get more complicated. |
|
Just a copy from 2 columns to a new combined column like described here is pretty simple I think: #67 (comment). Compared to having to work with multiple tx tables with different data so you also kind of have to copy data from one to the other? Could be that I'm missing something!
What does the RLP circuit need to know about the anchor transaction? |
Make sence, we need increase the rlp list len by one when we insert an anchor transaction rlp into it and check the list length by rules:
|
My misunderstood |
Very cool!
|
I mean the circuit for checking invalid transactions (ruby's job)
Maybe some transactions are not valid after evm execution, because the transactions come from L1's txList. |
Update |
With the latest protocol changes, the anchor transaction checks have been moved from the smart contract to inside the circuit. So we now have to extend the circuits to be able to check what we previously did on-chain: https://github.com/taikoxyz/taiko-mono/blob/69ede688d9c51e8265b4724c32566992b290b223/packages/protocol/contracts/L1/libs/LibProving.sol#L325.
So unless there's a problem with the 1st method and somehow 2nd method is easier, would just stick with approach 1.
The data that needs to be checked, except for the standard transaction data:
L1 signalRoot
is the storage root of the L1 signal smart contract account, which needs to be checked using the MPT circuit. The witness data for this Merkle proof is L1 data, not L2 data like all other MPT checks!L2 signalRoot
is the storage root of the L2 signal smart contract account, which needs to be checked using the MPT circuit. The witness data for this Merkle proof is L2 data like normal.Because the Anchor transaction always has the same byte length, should be easy to just paste and verify the necessary data in front of the main tx list data.
There are 2 additional MPT checks that need to inserted in the MPT circuit and witness data supplied to be able to do so, in once case it's L1 witness data so this may need some more work to be able to get this data from somewhere (passed in by the node directly seems to make sense because there the data should be more directly available because an L2 node needs to communicate with an L1 node already).
Because the anchor function can fail when the prover sets some incorrect values (like the basefee) we need to enforce that the tx is successful.
The text was updated successfully, but these errors were encountered: