Skip to content

Commit 67f1d25

Browse files
Apply suggestions from code review
Co-authored-by: Dra Murphy <149679879+kmurphypolygon@users.noreply.github.com>
1 parent ed7b0e5 commit 67f1d25

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

docs/zkEVM/architecture/protocol/sequencing-batches.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,51 @@ It is carried out by the sequencer through an executor, as depicted in the figur
1919

2020
![Figure: Pre-execution](../../../img/zkEVM/sqb-batch-preexecution.png)
2121

22-
While no proof is generated during the pre-execution stage, it ensures that the subsequent proof generation process by the prover can be successfully accomplished. This expedites the overall sequencing of batches.
22+
While no proof is generated during the pre-execution stage, batch pre-execution ensures that the prover's subsequent proof generation is successful, and expedites batch sequencing overall.
2323

24-
A fast executor is employed, which is a _single-computation_ executor, making it capable of executing within blocktime.
24+
A fast executor is used for batch pre-execution. This is a _single-computation_ executor, capable of executing within blocktime.
2525

26-
The sequencer communicates with this executor to perform the pre-execution process swiftly.
26+
The sequencer communicates with the executor for swift batch pre-execution.
2727

2828
Upon determining the transactions that correctly fill a specific batch through successful batch pre-execution, the sequencer records the batch in the node’s StateDB as a _closed batch_.
2929

30-
Closure may occur when either one of the following conditions is fulfilled:
30+
A closed batch means one of the following conditions has been fulfilled:
3131

3232
- The maximum number of execution trace rows is reached.
3333
- The maximum gas limit is attained.
3434
- The allocated time expires.
3535

36-
During batch pre-execution, and for batch closure, the sequencer and the executor update the Merkle tree of the zkEVM with L2 state changes, which is stored in the Prover HashDB. This is illustrated the figure below.
36+
During batch pre-execution, and for batch closure, the sequencer and the executor update the Merkle tree of the zkEVM with L2 state changes and store them in the prover's hash DB. This is illustrated in the figure below:
3737

3838
![Figure: Update L2 state](../../../img/zkEVM/sqb-l2-state-update-01.png)
3939

40-
The zkEVM's throughput depends highly on the speed at which we are able to close batches, which is directly impacted by the batch pre-execution process.
40+
The zkEVM's throughput depends on the speed at which we are able to close batches, which is directly impacted by the batch pre-execution process.
4141

42-
In fact, most of the performance problems occur here because excessive interaction with the HashDB is inefficient.
42+
Performance problems can occur here because of excessive and inefficient interaction with the hash DB.
4343

44-
Efforts are currently underway to optimize this process:
4544

46-
- Reducing the time spent on frequent updates during transaction processing, by accumulating all state changes caused by a transaction, and only update the HashDB at the end of a transaction's pre-execution.
45+
Optimizing this process may mean reducing the time spent on frequent updates during transaction processing by accumulating all state changes caused by a transaction and only updating the database at the end of a transaction's pre-execution.
4746

4847
## Sending batches to L1
4948

5049
The next step is to send a call to the smart contract to sequence batches.
5150

52-
Once a batch is closed, the sequencer stores the data of the batch in the node’s StateDB.
51+
Once a batch is closed, the sequencer stores the data of the batch in the node’s state DB.
5352

54-
Then, the $\texttt{sequenceSender}$ looks for closed batches and sends them to the [L1 smart contract](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/PolygonZkEVM.sol) via the $\texttt{EthTxManager}$, who makes sure that the transaction is included in a batch.
53+
Then, the $\texttt{sequenceSender}$ looks for closed batches and sends them to the [L1 smart contract](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/PolygonZkEVM.sol) via the $\texttt{EthTxManager}$ which makes sure the transaction is included in a batch.
5554

5655
This process is depicted in the figure below.
5756

5857
![Figure: Sequence sender and ETH Tx Manager](../../../img/zkEVM/sqb-seq-sender-tx-manager.png)
5958

60-
In order to sequence a batch, the sequencer calls the $\texttt{sequenceBatches()}$ function in the L1 Smart Contract.
59+
In order to sequence a batch, the sequencer calls the $\texttt{sequenceBatches()}$ function in the L1 smart contract which can sequence one or multiple batches at once.
6160

62-
The name of the function is in plural because it is capable of sequencing several batches at once.
6361

6462
This step provides L2 data availability in the L1 execution layer, because we are registering in L1 all the bytes of the L2 transactions.
6563

6664
The calldata for the L1 $\texttt{sequenceBatches()}$​ function needs to include the following information:
6765

68-
- The L2 transactions data, which is an array containing data for each batch. It includes all transactions within the batch along with a timestamp indicating its closure time.
66+
- The L2 transactions data, which is an array containing data for each batch. It includes all transactions within the batch along with a timestamp indicating its closure time.
6967
- Additionally, the L2 coinbase address, representing the Ethereum address for receiving user fees.
7068
- Lastly, a timestamp indicating when the L2 transactions were sequenced.
7169

@@ -75,11 +73,11 @@ The sequencer undertakes the responsibility of paying for data availability in L
7573

7674
When the sequencer successfully closes a batch and executes transactions, they receive a reward for their services. This reward, denominated in L2 Ether, is routed to the L2 coinbase address.
7775

78-
Crucially, the L2 coinbase address is situated within Layer 2 because users compensate the sequencer with L2 Ether.
76+
The L2 coinbase address is situated within layer 2 because users compensate the sequencer with L2 Ether.
7977

80-
This L2 Ether, representing the reward, is a reflection of the Ether in L1 that users have previously transferred to L2 through transactions via the Bridge.
78+
This L2 Ether, representing the reward, is a mapping of the Ether in L1 that users have previously transferred to L2 through transactions via the bridge.
8179

82-
Importantly, there exists a direct and fixed one-to-one correspondence between L1 ETH and L2 ETH, as we can observe in the figure below.
80+
There is a direct and fixed one-to-one correspondence between L1 ETH and L2 ETH, as we can observe in the figure below.
8381

8482
![Figure: L1 ETH and L2 ETH equivalence](../../../img/zkEVM/sqb-l1-and-l2-eth-equiv.png)
8583

@@ -89,7 +87,7 @@ Let's briefly explain how the sequencing operation and the proving process link
8987

9088
In particularly, we look at how the prover can match each sequenced batch with its data.
9189

92-
When the smart contract receives a call to sequence batches, it initiates creation of cryptographic pointers for each batch.
90+
When the smart contract receives a transaction for sequencing into batches, it creates a cryptographic pointer for each batch.
9391

9492
These pointers play a crucial role in identifying a batch uniquely, specifying its position, and encapsulating its data.
9593

@@ -99,7 +97,7 @@ The use of cryptographic pointers ensures a robust and unambiguous link between
9997

10098
![Figure: Sequence of batches - ... timeline](../../../img/zkEVM/sqb-batches-timeline.png)
10199

102-
These pointers are constructed using a hash that accumulates data, incorporating information from all preceding blocks.
100+
The pointers are constructed with previous hashes and information from the batches.
103101

104102
The procedural steps for this process are illustrated in the figure below:
105103

@@ -112,8 +110,8 @@ Pointers are generated by executing the KECCAK hash function on:
112110
- The batch timestamp.
113111
- The L2 coinbase.
114112

115-
Due to the inter-connected nature of their creation, with each pointer encapsulating the previous one in the input of the hash, they are aptly referred to as *accumulated input hash* or $\texttt{accInputHash}$.
113+
A pointer is referred to as an *accumulated input hash* or $\texttt{accInputHash}$.
116114

117115
Such a construction, where previous pointers are linked to the current pointer, guarantees that batch data is proved in the correct and sequential order.
118116

119-
Upon completion of the sequencing process, the batch enters a state of being *virtualized*, residing within a _virtual state_.
117+
When the sequencing process completes, the batch enters a _virtual state_.

0 commit comments

Comments
 (0)