Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction Finality Explainer #987

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions pages/stack/transactions/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"transaction-flow": "Transaction Flow",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"transaction-flow": "Transaction Flow",
"transaction-flow": "Transaction flow",

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just apply sentence case uniformely

"deposit-flow": "Deposit Flow",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"deposit-flow": "Deposit Flow",
"deposit-flow": "Deposit flow",

"withdrawal-flow": "Withdrawal Flow",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"withdrawal-flow": "Withdrawal Flow",
"withdrawal-flow": "Withdrawal flow",

"transaction-finality":"Transaction finality",
"forced-transaction": "Forced Transaction"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"forced-transaction": "Forced Transaction"
"forced-transaction": "Forced transaction"

}
142 changes: 142 additions & 0 deletions pages/stack/transactions/transaction-finality.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
title: Transaction Finality
lang: en-US
description: Learn about finality in OP Stack and the steps to achieve transaction settlement.
---

import Image from 'next/image'
import { Callout } from 'nextra/components'

# Overview
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Overview
# Transaction finality


This guide explains how transaction finality works in OP Stack, covering the fundamental concepts of Fault Proofs and Challenges.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This guide explains how transaction finality works in OP Stack, covering the fundamental concepts of Fault Proofs and Challenges.
This guide explains how transaction finality works in the OP Stack and addresses common misconceptions around transaction finality and the Fault Proof System.


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

OP Stack is an extension of Ethereum's consensus mechanism. Instead of running an entirely separate consensus protocol, the OP Stack leverages Ethereum's consensus.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OP Stack is an extension of Ethereum's consensus mechanism. Instead of running an entirely separate consensus protocol, the OP Stack leverages Ethereum's consensus.
The OP Stack derives its security from Ethereum by utilizing Ethereum's consensus mechanism. Instead of running an entirely separate consensus protocol, the OP Stack derives a layer 2 blockchain by reading the finalized state on Ethereum.

This enables it to take advantage of Ethereum's transaction ordering mechanism and finalize its own blocks without requiring a new consensus layer.

## Transaction Processing

State machines, such as the Ethereum Virtual Machine (EVM), rely on input lists (transactions) to evolve from one state to another. The order of the transactions is critical because incorrect ordering can lead to an invalid state.

For example, if a user attempts to send 1 ETH to two different parties at the same time, only one transaction can be valid. The order determines which transaction succeeds, making transaction ordering an essential aspect of consensus.

### Commutative vs. Non-Commutative Operations

Commutative operations allow the order of inputs to change without affecting the outcome. However, non-commutative operations (like sending funds) require strict ordering. Therefore, both the availability and the order of the transaction list are fundamental to ensuring the system's integrity.

### Consensus and Ordering

Consensus determines the valid chain or list of transactions. In the OP Stack, Ethereum's Proof of Stake (PoS) consensus mechanism is used to achieve transaction ordering and finality.

### Why Use Ethereum's Consensus?

By publishing blocks on Ethereum, the OP Stack effectively outsources its consensus mechanism. Instead of creating a separate consensus protocol, the OP Stack relies on Ethereum's ordering and finality guarantees.

### Key benefits of this approach:

* OP Stack inherits Ethereum's security and transaction ordering properties.
* It simplifies the design and development process by eliminating the need for a separate consensus protocol.
* Attack vectors, such as double-spends, are mitigated by Ethereum's security mechanisms.
Comment on lines +17 to +39
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Transaction Processing
State machines, such as the Ethereum Virtual Machine (EVM), rely on input lists (transactions) to evolve from one state to another. The order of the transactions is critical because incorrect ordering can lead to an invalid state.
For example, if a user attempts to send 1 ETH to two different parties at the same time, only one transaction can be valid. The order determines which transaction succeeds, making transaction ordering an essential aspect of consensus.
### Commutative vs. Non-Commutative Operations
Commutative operations allow the order of inputs to change without affecting the outcome. However, non-commutative operations (like sending funds) require strict ordering. Therefore, both the availability and the order of the transaction list are fundamental to ensuring the system's integrity.
### Consensus and Ordering
Consensus determines the valid chain or list of transactions. In the OP Stack, Ethereum's Proof of Stake (PoS) consensus mechanism is used to achieve transaction ordering and finality.
### Why Use Ethereum's Consensus?
By publishing blocks on Ethereum, the OP Stack effectively outsources its consensus mechanism. Instead of creating a separate consensus protocol, the OP Stack relies on Ethereum's ordering and finality guarantees.
### Key benefits of this approach:
* OP Stack inherits Ethereum's security and transaction ordering properties.
* It simplifies the design and development process by eliminating the need for a separate consensus protocol.
* Attack vectors, such as double-spends, are mitigated by Ethereum's security mechanisms.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend removing this section because I think it distracts from the key concept we're trying to illustrate in this document: Transaction finality


## Sequencer Operations

The sequencer (block producer) processes transactions in the following steps:

1. Pre-publishing Distribution:
* The sequencer receives transactions from users.
* It creates blocks containing these transactions.
* It distributes these blocks to network nodes before L1 publication.
* Nodes mark these blocks as "unsafe."

2. L1 Publication:
* The sequencer publishes the blocks to Ethereum (L1).
* Once included in L1, the blocks are marked as "safe."
* Blocks achieve "finalized" status after L1 finalization (approximately 20 minutes).

Comment on lines +41 to +55
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Sequencer Operations
The sequencer (block producer) processes transactions in the following steps:
1. Pre-publishing Distribution:
* The sequencer receives transactions from users.
* It creates blocks containing these transactions.
* It distributes these blocks to network nodes before L1 publication.
* Nodes mark these blocks as "unsafe."
2. L1 Publication:
* The sequencer publishes the blocks to Ethereum (L1).
* Once included in L1, the blocks are marked as "safe."
* Blocks achieve "finalized" status after L1 finalization (approximately 20 minutes).

Similar to my comment above, I think this is good context, but it detracts from the concept that we're trying to describe. I think the h2 below covers these details succinctly.

### Sequencer Trust Assumptions

The sequencer operates with the following trust assumptions:

* It can temporarily withhold transactions.
* It may attempt to reorder transactions before L1 publication.
* Once transactions are published on L1, the sequencer cannot modify or censor them.
* The sequencer cannot affect finalized transactions.

## Transaction Finality States

In the OP Stack, transaction finality progresses through three key stages:

1. **Unsafe:** The L2 sequencer creates a block containing the transaction, but the transaction data has not yet been posted to Ethereum (L1). The block is circulated within the L2 network for speed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. **Unsafe:** The L2 sequencer creates a block containing the transaction, but the transaction data has not yet been posted to Ethereum (L1). The block is circulated within the L2 network for speed.
1. **Unsafe:** The sequencer creates a block containing the transaction, but the transaction data has not yet been posted to Ethereum (L1). The block is circulated within the L2 network for speed.


2. **Safe:** The sequencer's batcher posts the transaction data to L1. At this point, any L2 node can derive the transaction.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. **Safe:** The sequencer's batcher posts the transaction data to L1. At this point, any L2 node can derive the transaction.
2. **Safe:** The batcher posts the transaction data to L1. At this point, any L2 node can derive the transaction.


3. **Finalized:** Transactions are finalized once more than 65 Ethereum blocks (approximately 20 minutes) have passed, ensuring that the L1 data is secure and cannot be reorganized.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. **Finalized:** Transactions are finalized once more than 65 Ethereum blocks (approximately 20 minutes) have passed, ensuring that the L1 data is secure and cannot be reorganized.
3. **Finalized:** Transactions are finalized once more than 65 Ethereum blocks (approximately 10-15 minutes) have passed, ensuring that the L1 data is secure and cannot be reorganized.

65 blocks * 12s blocks / 60s = 13 min


<Image src="/img/op-stack/protocol/tx-finality.png" alt="Transaction Finality Diagram." width={0} height={0} sizes="100vw" style={{ width: '100%', height: 'auto' }} quality={100} />

### Transaction Validity

When a block is submitted to Ethereum, it is either valid or invalid. If the block is valid, the state is updated accordingly. If it is invalid, the block is discarded. Nodes execute valid blocks and update the state as required.
Comment on lines +77 to +79
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Transaction Validity
When a block is submitted to Ethereum, it is either valid or invalid. If the block is valid, the state is updated accordingly. If it is invalid, the block is discarded. Nodes execute valid blocks and update the state as required.
### Transaction validity
When a transaction is submitted to the network, it is either valid or invalid. If the transaction is valid, the sequencer puts it in a block. If it is invalid, the transaction is discarded. There is no way the sequencer can write an invalid transaction to a new block.

Lets move this under the "Common misconceptions" header


### Reorgs and Finality

Once a block is included in a finalized Ethereum block, it cannot be reorganized. Therefore, blocks enjoy the same finality guarantees as Ethereum blocks, and this finality is managed by the OP Stack architecture.

Comment on lines +81 to +84
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Reorgs and Finality
Once a block is included in a finalized Ethereum block, it cannot be reorganized. Therefore, blocks enjoy the same finality guarantees as Ethereum blocks, and this finality is managed by the OP Stack architecture.
### Reorgs and finality
Once a transaction is included in a finalized Ethereum block, it cannot be reorganized.

Lets move this under the "Common misconceptions" header

### Handling Reorgs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Handling Reorgs

Lets put this content under "Reorgs and finality"


If an Ethereum reorganization (reorg) occurs:

1. L2 nodes detect the L1 reorg.
2. Affected L2 blocks revert to an "unsafe" status.
3. The sequencer typically republishes the same transactions.
4. The system returns to a consistent state after reprocessing.

## The Role of the Proof System
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## The Role of the Proof System
## Common misconceptions


The proof system is entirely separate from the core OP Stack protocol. It is an application-level validation system designed to ensure the accuracy of certain claims about the transaction state.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The proof system is entirely separate from the core OP Stack protocol. It is an application-level validation system designed to ensure the accuracy of certain claims about the transaction state.
The biggest misconception about transaction finality is that a transaction needs to wait for the entire challenge window to become finalized. The reality is the OP Stack transaction finality takes minutes, not over a week. This section detangles the concept of transaction finality and the Fault Proof System's challenger mechanism.


### What Is a Claim?

A claim in the context of OP Stack is a statement asserting the state of the system at a specific block height. For instance, a claim might assert that at block 1,000,000, the state hash is `XYZ`. If other participants believe this claim to be incorrect, they can challenge it.

### Fault Proofs and Challenges

Challenges focus on proving whether a given claim is valid. The outcome of a challenge does not impact the underlying chain. For example, if a claim about the transaction state at a specific block is proven wrong, it only affects the app-level functionality and does not alter the OP Stack protocol.

## 7-Day Challenge Period in OP Stack

The 7-day challenge period provides time for challenges to be raised and resolved.
Although OP Stack finalizes transactions quickly (within 20 minutes), the 7-day challenge window serves two critical purposes:

1. It allows time to validate and dispute the correctness of batches posted to Ethereum by the op-batcher, particularly important in scenarios like 51% attacks.
2. It provides a security period for withdrawal processing, ensuring the integrity of cross-chain operations.

### Why Seven Days?

The 7-day challenge period is a reasonable time frame that allows participants to organize a response, potentially even initiating a L1 hard fork to address critical issues. In the OP Stack, this challenge period also serves as a safeguard for app-level bridges and custom designs that may be built on top of the core protocol.
Comment on lines +98 to +116
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### What Is a Claim?
A claim in the context of OP Stack is a statement asserting the state of the system at a specific block height. For instance, a claim might assert that at block 1,000,000, the state hash is `XYZ`. If other participants believe this claim to be incorrect, they can challenge it.
### Fault Proofs and Challenges
Challenges focus on proving whether a given claim is valid. The outcome of a challenge does not impact the underlying chain. For example, if a claim about the transaction state at a specific block is proven wrong, it only affects the app-level functionality and does not alter the OP Stack protocol.
## 7-Day Challenge Period in OP Stack
The 7-day challenge period provides time for challenges to be raised and resolved.
Although OP Stack finalizes transactions quickly (within 20 minutes), the 7-day challenge window serves two critical purposes:
1. It allows time to validate and dispute the correctness of batches posted to Ethereum by the op-batcher, particularly important in scenarios like 51% attacks.
2. It provides a security period for withdrawal processing, ensuring the integrity of cross-chain operations.
### Why Seven Days?
The 7-day challenge period is a reasonable time frame that allows participants to organize a response, potentially even initiating a L1 hard fork to address critical issues. In the OP Stack, this challenge period also serves as a safeguard for app-level bridges and custom designs that may be built on top of the core protocol.
### The role of proof system
The following is a quick refresher on the Fault Proof System. It is a system designed to ensure the accuracy of certain claims about the transaction state on the L2.
A claim in the context of OP Stack is a statement asserting the state of the system at a specific block height. For instance, a claim might assert that at block 1,000,000, the state hash is `XYZ`. If other participants believe this claim to be incorrect, they can challenge it.
Challenges focus on proving whether a given claim is valid. The outcome of a challenge does not impact the underlying chain. For example, if a claim about the transaction state at a specific block is proven wrong, it only affects the application level functionality and does not alter the OP Stack protocol.
The challenge period provides time for challenges to be raised and resolved.
Although OP Stack finalizes transactions quickly (within 20 minutes), the 7-day challenge window serves two critical purposes:
1. It allows time to dispute the correctness of output state roots posted to Ethereum by the proposer.
2. It provides a security period for withdrawal processing, ensuring the integrity of cross-chain operations.


### Bridge Independence
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Bridge Independence
### Bridge independence


Key aspects of bridge systems include:

* Bridges are application-level constructs.
* They operate independently of the core OP Stack protocol.
* Bridge security does not affect the validity of L2 transactions.
* Bridge failures do not cause L2 reorgs or state changes.

### Example: Custom Bridges in OP Stack

A custom bridge might be developed by a user to allow ERC-20 tokens to move between layers. However, this bridge is application-level and not native to the OP Stack. If there is an issue with the bridge, such as incorrect proof validation, it does not impact the protocol itself but affects the subjective value of the bridged assets.
Comment on lines +127 to +129
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Example: Custom Bridges in OP Stack
A custom bridge might be developed by a user to allow ERC-20 tokens to move between layers. However, this bridge is application-level and not native to the OP Stack. If there is an issue with the bridge, such as incorrect proof validation, it does not impact the protocol itself but affects the subjective value of the bridged assets.
For example, a custom bridge might be developed to allow ERC-20 tokens to move between layers. However, this bridge is application-level and not native to the OP Stack. If there is an issue with the bridge, such as incorrect proof validation, it does not impact the protocol itself but affects the subjective value of the bridged assets.


### Withdrawal Delays vs. Finality
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Withdrawal Delays vs. Finality
### Withdrawal delays vs. finality


One common misconception is confusing withdrawal delays with transaction finality:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big misconception, lets bump it towards the top of this section


* Transaction finality occurs in approximately 20 minutes.
* Withdrawal delays (often 7 days) are separate from transaction finality.
* Withdrawal delays are application-level security features.
* These delays affect only L1 withdrawals, not L2 transaction finality.

## Conclusion

Transaction finality in the OP Stack relies on Ethereum's consensus mechanism. The OP Stack inherits Ethereum's finality guarantees, while the proof system adds a layer of validation for app-level functionality.
Binary file added public/img/op-stack/protocol/tx-finality.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Arweave
authrpc
Badgeholder's
Badgeholders
badgeholders
basefee
BGEZ
BGTZ
Expand Down Expand Up @@ -169,7 +170,6 @@ leveldb
lightkdf
logfile
logfmt
marketshare
MAXAGE
maxage
MAXBACKUPS
Expand Down Expand Up @@ -204,7 +204,6 @@ MTHI
MTLO
MULT
multiaddr
Multichain
multichain
multiclient
multisigs
Expand Down Expand Up @@ -303,7 +302,7 @@ replayability
reproven
REQUIREDBLOCKS
requiredblocks
Rollouts
rollouts
Rollups
rollups
Routescan
Expand Down
Loading