This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Fix: L1Msg tx is allowed to skip by sequencer.#759
Closed
kunxian-xia wants to merge 10 commits into
Closed
Conversation
|
oh i have picked the patch from v0.5.x to develop already... |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes two changes
num_l1_msgsandnum_l2_txsare done in tx circuit and copy their sum back to pi circuit.Issue Link
The rollup contract allows the sequencer to skip "malicious" L1 enforced tx (i.e.
L1Msgtx) that could cause circuit overflow. Therefore the semantic ofnum_txsin a chunk is different from the one we have right now.num_txs = len(chunk.txs).num_txs = num_l1_msgs + num_l2_txsandnum_l1_msgscount in these skipped L1 msgs. This means that the num of txs that are handled by the EVM circuit does not necessarily equal to the newnum_txsdefinition.Previously we rely on the assumption that
num_txs = len(chunk.txs)to make sure that(BlockNumber, tx_id, tx.block_num+1)row in tx table.The rules that we use (you can find more details at #733) is
cum_num_txs, prev_cum_num_txsandprev_cum_num_txs = cum_num_txs - num_txs.tx.block.prev_cum_num_txs < tx_id <= tx.block.cum_num_txs.tx_id' = tx_id + 1(it's strictly increasing by 1).Note that the evm circuit also relies on the rules 2 & 3 to make sure that txs in chunk cannot be skipped.
EndTx -> BeginTx: next.state.tx_id = curr.state.tx_id + 1;EndTx -> EndInnerBlock: curr.state.tx_id == curr.block.cum_num_txs`.However this rule no longer holds if we use the new definition of
num_txsin block table to get each block'scum_num_txs, prev_cum_num_txs. We give an example of how block table and tx table will look like below.block table
tx table
It's easy to see that the 5th row will fail the 2nd rule. We can use a simple method to fix this issue:
The tx table using this method will look like:
It's easy to see that we can now pass the rule 2's check. But this method breaks the 3rd rule that evm circuit relies on. This means that we also need make changes to evm circuit (oops not good) which is not desirable.
Design choice
We want to keep the changes as small as possible. For example, we don't want to make changes to evm circuit. To achieve that, we decide to keep the original semantic of
num_txs, cum_num_txsin block table (do not usenum_l1_msgs + num_l2_txsasnum_txs).That is, the new definition is only applied in the calculation of chunk_data_hash. And we count the
num_l1_msgsandnum_l2_txsin tx table. And then enforce that the sum equals to thenum_txsin pi column using copy constraints.Continuing our previous example, block table assigned by this method will look like:
block table
tx table
Type of change