> ## Documentation Index
> Fetch the complete documentation index at: https://optimism-373f39ad-soyboy-docs-op-supernode-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Sequencer Mode

> Understand how the kona-node sequencer actor builds L2 blocks, and the trait abstractions and programmatic configuration behind sequencer mode.

The Kona node can operate in **sequencer mode** to build and produce new L2 blocks. In this mode, the node acts as the sequencer for an OP Stack rollup, building L2 blocks on top of the current unsafe head and extending the L2 chain.

This page explains the design of sequencer mode and how to configure it programmatically through the Node SDK. To run `kona-node` as a sequencer from the command line, follow the [run a sequencer node](/rust/kona/node/run/sequencer) guide.

## Overview

When running in sequencer mode, the Kona node:

* **Builds L2 blocks** by collecting transactions from the mempool and constructing new blocks
* **Selects L1 origins** for new L2 blocks based on finalized L1 data
* **Manages block production timing** and ensures proper sequencing constraints
* **Integrates with conductor services** for leader election in multi-sequencer setups
* **Handles recovery scenarios** when the sequencer needs to catch up with L1

The sequencer uses the same core derivation pipeline as validator nodes but operates in reverse - instead of deriving L2 blocks from L1 data, it produces L2 blocks that will later be derivable from L1.

## Trait Abstractions

### Core Interfaces

The sequencer functionality is built around several key trait abstractions:

#### `RollupNodeService`

The main service trait that defines the node's operational mode and actor types:

```rust theme={null}
pub trait RollupNodeService {
    type SequencerActor: NodeActor<
        Error: Display,
        OutboundData = SequencerContext,
        Builder: AttributesBuilderConfig<AB = Self::AttributesBuilder>,
        InboundData = SequencerInboundData,
    >;

    fn mode(&self) -> NodeMode;
    // ... other methods
}
```

#### `AttributesBuilderConfig`

Configures how L2 block attributes are constructed:

```rust theme={null}
pub trait AttributesBuilderConfig {
    type AB: AttributesBuilder;
    fn build(self) -> Self::AB;
}
```

#### `SequencerActor`

The core actor responsible for block production:

* Builds L2 blocks using the `AttributesBuilder`
* Manages timing and L1 origin selection
* Handles admin RPC commands for sequencer control
* Coordinates with conductor services for leader election

## Programmatic Configuration

### Using the RollupNodeBuilder

To configure a Kona node programmatically for sequencer mode:

```rust theme={null}
use kona_node_service::{NodeMode, RollupNode, SequencerConfig};
use url::Url;

// Configure sequencer settings
let sequencer_config = SequencerConfig {
    sequencer_stopped: false,           // Start sequencer immediately
    sequencer_recovery_mode: false,     // Normal operation mode
    conductor_rpc_url: Some(            // Optional conductor integration
        Url::parse("http://conductor:8080").unwrap()
    ),
};

// Build and start the sequencer node
let node = RollupNode::builder(rollup_config)
    .with_mode(NodeMode::Sequencer)                    // Enable sequencer mode
    .with_sequencer_config(sequencer_config)           // Apply sequencer settings
    .with_l1_provider_rpc_url(l1_rpc_url)             // L1 data source
    .with_l2_engine_rpc_url(l2_engine_url)            // L2 execution engine
    .with_jwt_secret(jwt_secret)                       // Engine API authentication
    // ... other configuration
    .build()
    .start()
    .await?;
```

### Configuration Options

| Field                     | Description                                    | Default |
| ------------------------- | ---------------------------------------------- | ------- |
| `sequencer_stopped`       | Start sequencer in stopped state               | `false` |
| `sequencer_recovery_mode` | Enable recovery mode for catch-up              | `false` |
| `conductor_rpc_url`       | Conductor service endpoint for leader election | `None`  |

## Next Steps

* To run a sequencer from the command line, including the required flags and example configurations, see [run a sequencer node](/rust/kona/node/run/sequencer).
* For the full CLI flag catalogue, see the [Kona node CLI reference](/rust/kona/node/configuration).
