|
1 | 1 | # Batches, blocks, and transactions |
2 | 2 |
|
3 | | -The following definition are key to understanding how transactions are handled on L2s built with the CDK: |
| 3 | +The following definitions are key to understanding how transactions are handled on L2s built with the CDK: |
4 | 4 |
|
5 | 5 | - Transaction: A signed instruction to perform an action on the blockchain. |
6 | 6 | - Block: A group of transactions and a hash of the previous block in the chain. |
7 | 7 | - Batch: A group of many transactions from multiple blocks. |
8 | 8 |
|
9 | | -See the figure below to best understand how these concepts relate to each other. We follow a real transaction from the Polygon zkEVM to track how it first gets included in a block on the L2, then a batch, and finally, a sequence sent to Ethereum. |
| 9 | +Transactions are included in blocks, and these blocks fill batches, which are then sequenced. See the figure below to best understand how these elements relate to each other. |
10 | 10 |
|
11 | 11 |  |
12 | 12 |
|
13 | 13 | ## Transaction |
14 | 14 |
|
15 | | -A transaction is a cryptographically signed instruction from an account to update the state of the blockchain. Users can leverage familiar tools and libraries, like MetaMask and Ethers.js, typically used for interacting with Ethereum, to send these transactions to CDK-built L2 chains. |
| 15 | +A transaction is a cryptographically signed instruction from an account to update the state of the blockchain. |
16 | 16 |
|
17 | | -Transactions are included in blocks, and these blocks fill batches. Consider a Polygon zkEVM transaction as an example, [`0xdd`](https://zkevm.polygonscan.com/tx/0xdd3f79c24886310ddf868ad1d36aadc6a3b6495048f68aad765c658c42426ef8), which performs a `Simple Swap` function call, and is included in block number [`12952601`](https://zkevm.polygonscan.com/block/12952601) on the L2. |
| 17 | +Let's take a look at a real transaction in the Polygon zkEVM (which is in a way a CDK rollup), and inspect how the transaction is recorded in the [explorer](https://zkevm.polygonscan.com/) as part of a block, then a batch, and ultimately in a sequence. |
| 18 | + |
| 19 | +Consider the Polygon zkEVM transaction with the transaction hash, [`0xdd ... 6ef8`](https://zkevm.polygonscan.com/tx/0xdd3f79c24886310ddf868ad1d36aadc6a3b6495048f68aad765c658c42426ef8), which performs a `Simple Swap` function call, and is included in block number [`12952601`](https://zkevm.polygonscan.com/block/12952601) on the L2. |
18 | 20 |
|
19 | 21 |  |
20 | 22 |
|
21 | 23 | ## Block |
22 | 24 |
|
23 | | -To link blocks together, blocks contain multiple transactions as well as the hash of the previous block in the chain. Following the transaction example from above, the `0xdd` transaction is included in block [`12952601`](https://zkevm.polygonscan.com/block/12952601), which contains [2 transactions in total](https://zkevm.polygonscan.com/txs?block=12952601). |
| 25 | +Each block must include the hash of the previous block, along with multiple transactions, to establish a link to the block before it. |
| 26 | + |
| 27 | +Continuing with the above transaction, identified by the hash `0xdd ... 6ef8` and contained in block [`12952601`](https://zkevm.polygonscan.com/block/12952601), we observe that this block contains [2 transactions in total](https://zkevm.polygonscan.com/txs?block=12952601). |
24 | 28 |
|
25 | | -We can see this `0xdd` transaction is included in both a block and a batch, specifically, it is included in the block `12952601` and the batch `2041736`: |
| 29 | +Also, as depicted in the figure below, block `12952601` is in turn contained in batch `2041736`. |
26 | 30 |
|
27 | 31 |  |
28 | 32 |
|
29 | 33 | ## Batch |
30 | 34 |
|
31 | | -Batches contain multiple transactions from multiple blocks. The two transactions from our example block `12952601` are included in batch [`2041736`](https://zkevm.polygonscan.com/batch/2041736), which contains [10 total transactions](https://zkevm.polygonscan.com/txs?batch=2041736). |
| 35 | +Batches contain multiple transactions from multiple blocks. |
32 | 36 |
|
33 | | -This means the batch `2041736` includes the two transactions from block `12952601` as well as eight transactions from other blocks. |
| 37 | +The two transactions from our example block `12952601` are included in batch [`2041736`](https://zkevm.polygonscan.com/batch/2041736), which contains [10 transactions](https://zkevm.polygonscan.com/txs?batch=2041736) in total. |
34 | 38 |
|
35 | | -The presence of the `Sequence Tx Hash` field, associated with this batch, indicates that this batch has been sent to Ethereum along with other batches in a single transaction. |
| 39 | +This means batch `2041736` includes the two transactions from block `12952601` as well as eight transactions from other blocks. |
| 40 | + |
| 41 | +As observed in the figure below, the presence of the `Sequence Tx Hash` field associated indicates that the batch has been sent to Ethereum along with other batches in a single transaction. |
36 | 42 |
|
37 | 43 |  |
38 | 44 |
|
39 | | -By inspecting the transactions in the batch, we can see: |
| 45 | +Further inspection of the transactions in the batch, as depicted in the figure below, reveals that: |
40 | 46 |
|
41 | | -- Our original transaction example is included in this batch. |
42 | | -- The batch contains many transactions from different blocks. |
| 47 | +- Our transaction example, with hash `0xdd ... 6ef8`, is included in this batch. |
| 48 | +- The batch contains several transactions from different blocks. |
43 | 49 |
|
44 | 50 |  |
45 | 51 |
|
46 | | -If the L2 is a [rollup](./layer2s.md) (meaning it uses Ethereum for it’s [data availability](../glossary/index.md#data-availability), it sends an array of batches to Ethereum, by providing the array as an argument to the `sequenceBatches` function of a smart contract on Ethereum. |
| 52 | +Since Polygon zkEVM is a [rollup](./layer2s.md) (that is, it uses Ethereum for [data availability](../glossary/index.md#data-availability)), it sends an array of batches to Ethereum, by providing the array as an argument to the `sequenceBatches()` function of a smart contract on Ethereum. |
47 | 53 |
|
48 | 54 |  |
49 | 55 |
|
50 | | -By inspecting the `Sequence Tx Hash` transaction, we can see that the `sequenceBatches` function is called with the array of batches as an argument. One of these batches is the batch we have been following, `2041736`, which contains our original transaction example: |
| 56 | +We can inspect the `Sequence Tx Hash` transaction to ascertain if batch `2041736`, containing our original transaction example, was indeed part of the argument to the `sequenceBatches()` function. |
| 57 | + |
| 58 | +In this case, batch `2041736` happens to be the last batch to be sequenced, as depicted in the figure below. |
51 | 59 |
|
52 | 60 |  |
53 | 61 |
|
54 | 62 | ## Further reading |
55 | 63 |
|
56 | | -- [Blocks in the zkEVM Etrog upgrade](../../zkEVM/architecture/protocol/etrog-upgrade.md/?h=blocks#etrog-blocks). |
| 64 | +- [Blocks in the zkEVM Etrog upgrade](../../zkEVM/architecture/protocol/etrog-upgrade.md/?h=blocks#etrog-blocks). |
0 commit comments