L2 Scaling Solutions

Production engineering guide for l2 scaling solutions in Web3 and blockchain systems.

L2 scaling solutions address the need to increase transaction throughput and reduce latency and cost for blockchain applications, particularly in environments where on-chain computation is expensive or constrained. They matter when a blockchain application experiences high load—such as a token launch, a decentralized exchange, or a gaming platform—where users face slow confirmation times and elevated gas fees. L2 solutions enable applications to process transactions off-chain while maintaining security and finality guarantees provided by the underlying Layer 1 (L1) blockchain.

Transaction Processing and Finality

The core of any L2 scaling solution is its ability to process transactions efficiently and deliver finality. Transactions are submitted to an L2 system, which batches them and submits proofs or state roots back to the L1 for verification.

To submit a batch of transactions, an L2 node sends a SubmitBatch request to the L1 contract:

{
  "batchNumber": 123,
  "transactions": [
    {
      "sender": "0x1234567890123456789012345678901234567890",
      "recipient": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
      "amount": "1000000000000000000",
      "nonce": 42,
      "data": "0x010203"
    }
  ],
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "timestamp": 1700000000
}

The L1 contract validates the batch by verifying the state root and, optionally, a Merkle proof of the transactions. A critical failure mode is when the submitted state root does not match the actual state computed by the L2 node. This leads to a mismatched state, causing users to receive incorrect balances or failed transactions.

When a batch is submitted, the L1 emits a BatchSubmitted event with the batch number and root. Clients listen for this event and begin tracking finality. Finality is achieved when the batch is included in an L1 block and sufficient confirmations have passed. A common configuration is to require 32 L1 blocks (about 16 minutes on Ethereum) before a batch is considered finalized.

The L2 system can also use a challenge period to allow participants to submit proofs of incorrect state transitions. A StateRootChallenge transaction includes a proof that a given state root is incorrect, and if accepted, the L1 updates the state root and pays a reward to the challenger.

Sequencer and Rollup Types

L2 systems use a sequencer to order transactions. The sequencer is responsible for receiving transactions, applying them to the state, and producing a new state root. The choice of sequencer architecture determines the trade-offs between latency, decentralization, and fault tolerance.

A centralized sequencer submits batches at regular intervals. The sequence is defined by a Sequence endpoint:

POST /sequence
Content-Type: application/json

{
  "transactions": [
    {
      "txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
      "sender": "0x1234567890123456789012345678901234567890",
      "value": 1000000000,
      "gasLimit": 21000,
      "data": "0x0102"
    }
  ],
  "timestamp": 1700000000
}

The sequencer responds with a SequenceResponse:

{
  "batchNumber": 123,
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "batchHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "submitted": true,
  "finalized": false,
  "confirmations": 0
}

A validity rollup requires that every batch includes a cryptographic proof (e.g., ZK-SNARKs) that the state transition is correct. The proof is verified in the L1 contract, and the L1 can challenge any incorrect proof. A failure occurs when the proof is valid but the state root does not match the actual state. This leads to a state mismatch error:

{
  "error": "StateMismatch",
  "expectedRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "actualRoot": "0x112233445566778899aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff",
  "batchNumber": 123
}

In contrast, optimistic rollups assume that batches are correct unless challenged. They use a challenge window—typically 7 days—during which any participant can submit a fraud proof. The fraud proof consists of a sequence of Merkle proofs showing the disagreement between the current state and the claimed state.

A common mistake is using a challengeWindow of 100 blocks instead of 100 seconds, leading to suboptimal finality times. The L1 contract checks the challengeWindow parameter, and if it is too small, the system cannot effectively challenge long-running batches.

Data Availability and Proof Submission

Data availability is critical for L2 systems. Without it, the L1 cannot verify the full content of a batch. The L2 system must ensure that the data for each batch is available on-chain for at least the duration of the challenge window.

Batches are published to a data availability layer, typically via a PublishBatch endpoint:

POST /publish-batch
Content-Type: application/json

{
  "batchNumber": 123,
  "data": "0x0102030405060708090a0b0c0d0e0f...",
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "submitter": "0x1234567890123456789012345678901234567890"
}

The data is stored in a content-addressable store (e.g., IPFS or a blob storage layer). The L1 contract references the batch data via a content hash (e.g., CID or a hash of the batch data).

To submit a proof for a batch, the L2 system calls SubmitProof:

POST /submit-proof
Content-Type: application/json

{
  "batchNumber": 123,
  "proof": [
    "0x01020304",
    "0x05060708",
    "0x090a0b0c"
  ],
  "proofType": "zk-snark",
  "verifier": "0x1234567890123456789012345678901234567890",
  "timestamp": 1700000000
}

A mismatch in the proofType field leads to verification failures. The L1 contract expects a specific format (e.g., b32-encoded SNARK proof), and using a proofType: "zksnark" instead of zk-snark causes the verifier to fail silently.

A sharp edge is the proof submission delay: if proofs are submitted after the challenge window, they are accepted but do not affect the finality of the batch. This leads to a late proof error:

{
  "error": "LateProof",
  "batchNumber": 123,
  "proofSubmittedAt": 1700000000,
  "challengeWindowEnd": 1700000000,
  "reason": "Proof submitted after challenge window end, not eligible for challenge"
}

State Verification and Client Interaction

Clients interacting with L2 systems must verify the state of the rollup. A typical client uses a getState endpoint:

GET /state?blockNumber=123

The response includes the state root, the latest finalized batch, and a list of recent transactions:

{
  "blockNumber": 123,
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "finalizedBatch": 120,
  "transactions": [
    {
      "txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
      "sender": "0x1234567890123456789012345678901234567890",
      "recipient": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
      "amount": 1000000000,
      "status": "finalized"
    }
  ],
  "proof": [
    "0x01020304",
    "0x05060708"
  ]
}

Clients must validate the state root by verifying the Merkle proof of the transactions. A common failure is when the client uses a MerkleProof with incorrect depth or incorrect leaf indexing.

The L2 system can also support state proofs for individual accounts. A client calls:

GET /account/0x1234567890123456789012345678901234567890?blockNumber=123

The response includes the account’s balance, nonce, and a Merkle proof that the account exists in the state tree:

{
  "account": "0x1234567890123456789012345678901234567890",
  "balance": "1000000000000000000",
  "nonce": 42,
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "proof": [
    "0x01020304",
    "0x05060708",
    "0x090a0b0c"
  ],
  "path": [ "left", "right", "left" ]
}

A subtle failure occurs when the path array is misaligned—e.g., sending [ "left", "left", "right" ] instead of [ "left", "right", "left" ]—leading to an incorrect inclusion proof.

Fault Tolerance and Sequencer Failures

An L2 system must handle sequencer outages. When the sequencer goes offline, the system enters sequencer downtime mode. Transactions are accepted but not batched until the sequencer resumes.

During downtime, a backup sequencer (or multiple sequencers) can take over. The system uses a SwitchSequencer event to signal the change:

{
  "oldSequencer": "0x1234567890123456789012345678901234567890",
  "newSequencer": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
  "timestamp": 1700000000,
  "batchNumber": 123
}

The L1 contract checks that the new sequencer is active and that the batch number is continuous. A failure occurs when the new sequencer submits a batch with batchNumber: 124 while the old sequencer had already submitted 123. This leads to a batch gap:

{
  "error": "BatchGap",
  "expectedBatch": 123,
  "receivedBatch": 124,
  "sequencer": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef",
  "reason": "Missing batch 123 from previous sequencer"
}

The L2 system can also use checkpointing to reduce the cost of state verification. A checkpoint is a state root that is periodically submitted to the L1 and can be used as a reference point. Clients can use a getCheckpoint endpoint:

GET /checkpoint?epoch=5

The response includes the checkpoint state root and a list of recent batches that were processed since the last checkpoint.

A common mistake is failing to submit checkpoints at regular intervals. If the checkpointing interval is set to 100 batches but the sequencer submits only 80 batches between checkpoints, clients must verify the full state from the last checkpoint, increasing overhead.

Finality and Rollup Upgrades

Rollups are upgradeable. The L1 contract supports rollup upgrades, where a new version of the rollup logic is deployed. The upgrade process involves publishing a new rollup contract and submitting a RollupUpgrade transaction:

{
  "oldVersion": "1.0",
  "newVersion": "2.0",
  "newContractAddress": "0x1234567890123456789012345678901234567890",
  "upgradeTimestamp": 1700000000,
  "upgradeReason": "Improved state tree structure and gas pricing model"
}

Clients must verify that the new rollup contract is active and that all batches are compatible with the new version. A failure occurs when a batch is submitted using the old contract but the new contract expects a different format for transaction data.

Finality is achieved when the rollup upgrade is finalized on the L1. The system uses a FinalizeUpgrade event to signal the completion. Clients listen for this event and begin using the new version.

A sharp edge is the upgrade compatibility window: during the transition, both old and new rollup versions operate in parallel. The L1 contract maintains a currentRollupVersion and a upgradeStartBlock. Clients must handle both versions until the upgrade is finalized.

Rollups can also perform state transitions during upgrades. A StateTransition event includes a new state root and a list of changes to the rollup’s configuration:

{
  "transitionId": 1,
  "fromVersion": "1.0",
  "toVersion": "2.0",
  "stateRoot": "0x883b9c7d1a4e2f6c5b1a9d8e7c6b5a4f3e2d1c0b9a8d7c6b5a4f3e2d1c0b9a8d",
  "changes": [
    {
      "parameter": "challengeWindow",
      "oldValue": 32,
      "newValue": 64
    },
    {
      "parameter": "maxBatchSize",
      "oldValue": 1000,
      "newValue": 2000
    }
  ]
}

A silent failure occurs when the changes array is not properly ordered, leading to inconsistent rollup behavior. The L1 contract expects the changes to be applied in sequence, but a client may apply them in parallel, causing divergent states.

This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.