Transaction Flow
Last updated
Last updated
The process for a rollup transaction has two requirements.
The transaction needs to be written to L1 (Ethereum). This is typically performed by pt-batcher
, but any user can send an L1 transaction to submit an L2 transaction, in which case pt-batcher
is bypassed.
The transaction needs to be executed to modify the state (by pt-geth
). Afterwards, pt-proposer
writes a to the post-transaction state to L1. Note that pt-proposer
does not need to write a commitment after each transaction to L1, it is OK to commit to the state after a block of transactions.
has two main jobs:
Compress transactions into batches.
Post those batches to L1 to ensure availability and integrity.
The batcher aggregates into . This allows for more data per compression frame, and therefore a better compression ratio. You can read more about this process .
When a channel is full or times out it is compressed and written.
The maximum time that a channel can be open, from the first transaction to the last, is specified in units of L1 block time (so a value of 5 means 5*12=60 seconds). You can specify it either as an environment variable (OP_BATCHER_MAX_CHANNEL_DURATION
) or a command line parameters (--max-channel-duration
). Alternatively, you can set it to zero (the default) to avoid posting smaller, less cost efficient, transactions.
A channel is full when the anticipated compressed size is the target L1 transaction size. This is controlled by two parameters:
The target L1 transaction size, which you can specify in bytes on the command line (--target-l1-tx-size-bytes
) or as an environment variable (OP_BATCHER_TARGET_L1_TX_SIZE_BYTES
)
The expected compression ratio, which you can specify as a decimal value, again either on the command line (--approx-compr-ratio
) or as an environment variable (OP_BATCHER_APPROX_COMPR_RATIO
).
You can see the code that implements this process in and .
When a channel is full it is posted, either as a single transaction or as multiple transactions (depending on data size) to L1.
Processed L2 transactions exist in one of three states:
unsafe transactions are already processed, but not written to L1 yet. A batcher fault might cause these transactions to be dropped.
safe transactions are already processed and written to L1. However, they might be dropped due to a reorganization at the L1 level.
When are transactions irrevocable?
Once a transaction is finalized, you can rely that it has "happened". While the state after the transaction is subject to fault challenges, the transaction itself is fix and immutable.
Get the number of the L2 block in which the transaction is recorded.
Get the number of the latest finalized block. If the result is greater than the block number of the transaction, or equal, the transaction is finalized.
Get the number of the latest safe block. If the result is greater than the block number of the transaction, or equal, the transaction is safe.
If the transaction isn't finalized or safe, it's unsafe.
State processing can be divided into two steps:
Output proposals are not immediately valid. They can only be considered authoritative once the fault challenge period (7 days on the production network, less on test networks) has passed.
finalized transactions are written to L1 in an L1 block that is old enough to be .
You can see the code that builds the channels to be written to L1 in and . The transactions themselves are sent in , which calls
This is the procedure to see a transaction's status. The directions here are for , but the concept is the same regardless of the method you use.
Applying the transaction to the old state to produce the new state, which is performed by .
Proposing the new of the state. Merkle roots are used because the actual state is long and would cost too much to write to L1. This step is performed by pt-proposer
.
The state is stored and modified by . It is a slightly modified version of the standard .
The state root proposals are posted by
to on L1.