Skip to content

Commit ae55b36

Browse files
author
jarrodwatts
committed
Batches, Blocks, and Transactions
1 parent 2aec907 commit ae55b36

20 files changed

+55
-0
lines changed

docs/cdk/concepts/admin-upgradeability.md

Whitespace-only changes.

docs/cdk/concepts/agglayer.md

Whitespace-only changes.

docs/cdk/concepts/blocks.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Batches, Blocks, and Transactions
2+
3+
To understand how transactions are handled on L2s built with the CDK, there are four key concepts to understand:
4+
5+
- **Transaction**: Signed instruction to perform an action on the blockchain.
6+
- **Block**: A group of transactions and a hash of the previous block in the chain.
7+
- **Batch**: A group of many transactions from multiple blocks.
8+
9+
To best understand how these concepts relate to each other, on this page, we will follow a real transaction from the Polygon zkEVM to see how it first gets included in a block on the L2, then in a batch, and finally, a sequence that is sent to Ethereum.
10+
11+
![Batches, blocks, transactions](../../img/cdk/sequence-batch-block-transaction.png)
12+
13+
## Transaction
14+
15+
A transaction is a cryptographically signed instructions from an account to update the state of the blockchain. Users can send transactions to L2 chains built with the CDK using the same tools and libraries they use to interact with Ethereum such as MetaMask.
16+
17+
Transactions are included in both blocks and batches. An example Polygon zkEVM transaction [`0xdd`](https://zkevm.polygonscan.com/tx/0xdd3f79c24886310ddf868ad1d36aadc6a3b6495048f68aad765c658c42426ef8) performs a `Simple Swap` function call, and part of block [`12952601`](https://zkevm.polygonscan.com/block/12952601) on the L2.
18+
19+
![Transaction with Block Number](../../img/cdk/transaction-block.png)
20+
21+
## Block
22+
23+
Blocks contain multiple transactions and the hash of the previous block in the chain to link blocks together. Following our example transaction from above, the `0xdd` transaction is included in block [`12952601`](https://zkevm.polygonscan.com/block/12952601), which contains [2 total transactions](https://zkevm.polygonscan.com/txs?block=12952601).
24+
25+
![Block and Batch](../../img/cdk/block-batch.png)
26+
27+
## Batch
28+
29+
Batches contain multiple transactions from multiple blocks. The two total 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).
30+
31+
As there is also a `Sequence Tx Hash` field associated with this batch, we can infer that this batch is part of a sequence of batches that have already been sent to Ethereum.
32+
33+
![Batch of transactions](../../img/cdk/batch-overview.png)
34+
35+
By inspecting the transactions in the batch, we can see:
36+
37+
- Our original example transaction is included in this batch.
38+
- The batch contains many transactions from many different blocks.
39+
40+
![Transaction found inside batch](../../img/cdk/transaction-in-batch.png)
41+
42+
If the L2 is a [rollup](./layer2s.md), 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.
43+
44+
![Sequence Transaction](../../img/cdk/sequence-transaction.png)
45+
46+
By inspecting the `Sequence Tx Hash` transaction, we can see 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 example transaction.
47+
48+
![Last Batch Sequenced](../../img/cdk/last-batch-sequenced.png)

docs/cdk/concepts/bridging.md

Whitespace-only changes.

docs/cdk/concepts/gas-fees.md

Whitespace-only changes.

docs/cdk/concepts/transaction-finality.md

Whitespace-only changes.

docs/cdk/concepts/transaction-lifecycle.md

Whitespace-only changes.

docs/img/cdk/batch-block-tx.png

35.7 KB
Loading

docs/img/cdk/batch-overview.png

192 KB
Loading
168 KB
Loading

0 commit comments

Comments
 (0)