> Source: https://docs.logos.co/lez/sequencing/run-decentralised-lez-sequencer
> Markdown index of all Logos docs: https://docs.logos.co/llms.txt

# Run a decentralised LEZ sequencer

#### Stake a Bedrock key into the LEZ sequencer committee and produce blocks on your round-robin turn.

> **Tip: Version**
>
> This document is accurate for **Testnet v0.3.2**.

Zone sequencers order mempool transactions into blocks and inscribe them on the Zone's [channel](https://docs.logos.co/get-started/glossary.md#channel) on [Bedrock](https://docs.logos.co/get-started/glossary.md#bedrock). The LEZ is sequenced by a committee of sequencer who take turns doing this in a round-robin schedule. Anybody who meets the minimum stake can join the committee, and membership in the committee is granted automatically, without explicit approval.

This procedure shows how to build the sequencer from the [`v0.3.2`](https://github.com/logos-blockchain/logos-execution-zone/releases/tag/v0.3.2) release, prepare a node home, stake its Bedrock key, and confirm the node produces blocks on its turn. It's for operators who want to run a committee member on a local network, in preparation for 

The stake is what makes misbehaviour costly. A member that inscribes an invalid or misplaced block is slashed, and slashing burns the key's whole stake. Being offline isn't slashed.

> **Info: Prerequisites**
>
>
> - A supported OS:
>   - Linux
>   - macOS
>
>   The service setup in [Step 7](#step-7-run-the-node-as-a-service) is for Linux with systemd only.
> - The [Rust toolchain](https://www.rust-lang.org/tools/install). `rustup` installs the pinned 1.98.1 on the first build.
> - [`just`](https://github.com/casey/just), Python 3.
> - Only to rebuild the zkVM artifacts: the [RISC Zero toolchain](https://dev.risczero.com/api/zkvm/install), installed with `rzup install`. The repository uses risc0 3.0.5 and commits the built artifacts, so [Step 1](#step-1-build-the-sequencer-from-the-release-tag) doesn't need it.
> - For the public testnet:
>   - A funded key in that node's wallet, such as the `PoWClaim` key funded by [mining](https://docs.logos.co/blockchain/get-started/run-blockchain-node-from-cli.md#step-4-mine-tokens-to-fund-your-node).
>   - A [Logos Blockchain node](https://docs.logos.co/blockchain/get-started/run-blockchain-node-from-cli.md) version [`0.3.4`](https://github.com/logos-blockchain/logos-blockchain/releases/tag/0.3.4).
>   - A [public account](https://docs.logos.co/get-started/glossary.md#public-account) holding at least the network's minimum stake, in an [LEZ CLI wallet](https://docs.logos.co/lez/get-started/run-lez-wallet-via-cli.md).
> - For a local network:
>    - [Docker](https://docs.docker.com/get-docker/).

## What to expect

- You can run a sequencer that the committee accredits and that publishes LEZ blocks on its round-robin turn.
- You can check accreditation by finding your node's Bedrock key in the channel's `accredited_keys`.
- You can leave the committee cleanly and get your stake back once the exit delay has passed.

## Step 1: Build the sequencer from the release tag

Run every command in this procedure from the repository root.

1. Clone the repository and check out the release:

   ```bash
   git clone https://github.com/logos-blockchain/logos-execution-zone.git
   cd logos-execution-zone
   git checkout v0.3.2
   ```

1. Build the wallet and the sequencer, including the `submit_stake` tool:

   ```bash
   cargo build --release -p wallet -p sequencer_service --features sequencer_service/submit_stake
   ```

   - This builds `sequencer_service`, `bedrock_pubkey`, `submit_stake`, and `wallet` into `target/release`.

1. Put the binaries on your `PATH`. Repeat this in every new terminal you open during the procedure:

   ```bash
   export PATH="$PWD/target/release:$PATH"
   ```

## Step 2: Choose the network to join

Join the public testnet, or start a local network to try the flow first. You only need one of the options below. Each one sets the shell variables that the rest of the procedure uses, so run the later steps in the same terminal.

### Option A—Join the public testnet

> **Warning**
>
> The joining sequencer config for the public testnet isn't published with the v0.3.2 release yet. Every node on a channel has to agree on its genesis and `channel_params`, so don't substitute the debug config. Ask the LEZ team on the [Logos Discord](https://discord.gg/logosnetwork) for the current config before you continue.

1. Set the variables for the testnet. Replace `<your-bedrock-node>` with your Bedrock node's API address, and `<joining-config>` with an absolute path to the testnet joining config (`just setup-sequencer` resolves a relative path against the repository root and doesn't expand `~`):

   ```bash
   NODE_HOME=~/.logos-execution-zone/sequencer
   SEQUENCER_RPC=https://testnet.lez.logos.co
   NODE_URL=http://<your-bedrock-node>
   CHANNEL_ID=0101010101010101010101010101010101010101010101010101010101010101
   CONFIG=<joining-config>
   NODE_RPC=http://127.0.0.1:3040
   ```

   - `NODE_HOME` is a new directory that [Step 3](#step-3-prepare-the-node-home) creates. It holds the node's staked key, so it must not exist yet.
   - `SEQUENCER_RPC` is any committee member's RPC. The node's own wallet talks to it.
   - The channel ID for each release is listed on [Testnet endpoints](https://docs.logos.co/get-started/testnet-endpoints.md).

1. Set `FUNDING_KEY` to the public part of the funded key in your Bedrock node's wallet, such as the `public_key` of the auto-claim target printed in [Step 4](https://docs.logos.co/blockchain/get-started/run-blockchain-node-from-cli.md#step-4-mine-tokens-to-fund-your-node) of the Blockchain node page:

   ```bash
   FUNDING_KEY=<bedrock-wallet-public-key>
   ```

### Option B—Start a local network

You need four terminals for this option. Run [Step 1](#step-1-build-the-sequencer-from-the-release-tag)'s `export PATH` in each one.

1. **In terminal 1**, clear the previous local run and start Bedrock. It stays in the foreground:

   ```bash
   just clean
   just run-bedrock
   ```

1. **In terminal 2**, start the first sequencer, which creates the channel:

   ```bash
   just run-sequencer
   ```

   Wait for the first `Publishing block` line before continuing.

   **Expected result:**

   ```text
   Channel does not exist yet; starting it as channel creator
   Publishing block 2 on pin <msg id>
   ```

1. **In terminal 3**, import the accounts that the local genesis funds:

   ```bash
   just wallet-import-test-accounts
   ```

   **Expected result:** the output lists `Public/CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r` and `Public/2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2`.

1. Still in terminal 3, check that the joining node's home doesn't exist yet. `just clean` doesn't remove it:

   ```bash
   ls ~/.logos-execution-zone/sequencer
   ```

   **Expected result:** `No such file or directory`. If the directory is left over from a previous local run, remove it. If it belongs to another node, such as a testnet one, keep it and use a different path for `NODE_HOME` in the next action.

1. Set the variables for the local network. Run the rest of the procedure in terminal 3, except where a step says otherwise:

   ```bash
   NODE_HOME=~/.logos-execution-zone/sequencer
   SEQUENCER_RPC=http://127.0.0.1:3040
   NODE_URL=http://localhost:18080
   CHANNEL_ID=0101010101010101010101010101010101010101010101010101010101010101
   CONFIG=lez/sequencer/service/configs/debug/sequencer_config.json
   NODE_RPC=http://127.0.0.1:3041
   ```

   - The debug config's `funding_key` already matches the local Bedrock node's wallet, so you don't set `FUNDING_KEY`.

## Step 3: Prepare the node home

`just setup-sequencer` creates the node home. It submits nothing, so it doesn't need funds.

1. Patch the setup script. At `v0.3.2`, `tools/setup_sequencer.py` writes the node wallet's config in an older format that the v0.3.2 wallet rejects. Use the following command to update the script as a quick workaround:

   ```bash
   sed -i.orig 's|"sequencers": \[{"sequencer_addr": args.sequencer}\],|"sequencer": {"sequencer_addr": args.sequencer},|' \
       tools/setup_sequencer.py
   ```

1. Create the node home:

   ```bash
   just setup-sequencer "$NODE_HOME" --sequencer "$SEQUENCER_RPC" --node-url "$NODE_URL" --config "$CONFIG"
   ```

   - If the command fails, it leaves a partial home behind. Delete `$NODE_HOME` before you run it again.

   **Expected result:** the command prints `<NODE_HOME> is ready.`, followed by the funding account, the Bedrock key, and the paths it wrote. The home contains:

   | File | Contents |
   |:---|:---|
   | `sequencer_config.json` | A copy of `$CONFIG`, with `home` and `node_url` set for this node. |
   | `wallet/` | The node's own wallet, pointed at `$SEQUENCER_RPC`. |
   | `wallet-seed` | That wallet's password and recovery phrase, in plain text. |
   | `bedrock_signing_key` | The Bedrock key that the stake accredits. |
   | `stake-funding-account` | A new account in the node's wallet that the stake is paid from. |

   > **Danger**
   >
   > `bedrock_signing_key` is the staked identity. If you lose it, you lose the seat. Back it up, restrict its permissions, and never run two nodes with the same key: two nodes inscribing for one key produce misplaced blocks, which are slashed.
   >
   > The node's wallet holds the key that's needed to unstake, and `wallet-seed` holds its password and recovery phrase in the clear. Anyone who can read the home controls the stake, so restrict its permissions and back it up. `just setup-sequencer` creates `bedrock_signing_key` readable by every user on the machine:
   >
   > ```bash
   > chmod 700 "$NODE_HOME"
   > chmod 600 "$NODE_HOME/bedrock_signing_key"
   > ```

1. (Public testnet only) Set the config's `funding_key` to your Bedrock wallet key:

   ```bash
   python3 -c 'import json, sys; p = sys.argv[1]; c = json.load(open(p)); c["bedrock_config"]["funding_key"] = sys.argv[2]; json.dump(c, open(p, "w"), indent=4)' \
       "$NODE_HOME/sequencer_config.json" "$FUNDING_KEY"
   ```

1. Read the funding account and the Bedrock public key into variables for the next steps:

   ```bash
   FUNDING=$(cat "$NODE_HOME/stake-funding-account")
   SEQUENCER_KEY=$(bedrock_pubkey "$NODE_HOME/sequencer_config.json" --home "$NODE_HOME")
   ```

## Step 4: Start the node and let it catch up

The node follows the chain as soon as it starts, and starts producing once the committee accredits its key. Start it in its own terminal, terminal 4 on a local network, and set `NODE_HOME` and `PATH` there too.

> **Warning**
>
> Your Blockchain node must be in `Online` mode before you can begin this step: `curl -s http://<your-bedrock-node>/cryptarchia/info` must report `"state":"Online"`. While it's still `Bootstrapping`, the sequencer can't backfill the channel and logs `408 Request Timeout` errors.

1. Start the node. **On the public testnet**:

   ```bash
   RUST_LOG=info,kameo=warn sequencer_service "$NODE_HOME/sequencer_config.json" \
       --home "$NODE_HOME" --listen-address 127.0.0.1
   ```

   **On a local network**, the first sequencer already holds ports 3040 and 9000:

   ```bash
   RUST_LOG=info,kameo=warn sequencer_service "$NODE_HOME/sequencer_config.json" \
       --home "$NODE_HOME" --listen-address 127.0.0.1 \
       --port 3041 --metrics-address 127.0.0.1:9001
   ```

   - The sequencer RPC has no caller authentication. `--listen-address 127.0.0.1` keeps it on the local machine; only bind it to a public address if a firewall protects the port.

   **Expected result:**

   ```text
   Channel already exists; joining as a non channel creator
   ```

   If the log says `Channel does not exist yet; starting it as channel creator` instead, stop the node; see [Troubleshooting](#the-node-starts-its-own-channel).

1. Back in your working terminal, compare your node's last block ID with a committee member's. Repeat until they match:

   ```bash
   for rpc in "$NODE_RPC" "$SEQUENCER_RPC"; do
     curl -s -X POST -H 'Content-Type: application/json' \
       --data '{"jsonrpc":"2.0","method":"getLastBlockId","params":[],"id":1}' "$rpc"
     echo
   done
   ```

   - The node's RPC only starts listening once it has caught up on the channel, about 12 seconds after launch on a local network. Until then, the line for `$NODE_RPC` is empty.
   - While it catches up, the node can log warnings such as `Finalized block 1 did not apply`. They stop once its block ID matches the committee member's.

## Step 5: Stake the node's key

1. Read the channel's minimum stake from the node's own config. Every node on the channel has to agree on `channel_params`, so this is the value the committee enforces. Save it in the home, because you need the staked amount to unstake:

   ```bash
   MIN=$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["bedrock_config"]["channel_params"]["minimum_sequencer_stake"])' \
       "$NODE_HOME/sequencer_config.json")
   echo "$MIN" > "$NODE_HOME/stake-amount"
   echo "$MIN"
   ```

   **Expected result:** the channel's minimum stake. The local debug config sets it to `149`. On the public testnet it's `25000000000`.

1. Fund the node's funding account from your funded account. Replace `<funded-account>` with your account ID:

   ```bash
   wallet auth-transfer send --from Public/<funded-account> --to "Public/$FUNDING" --amount "$MIN"
   ```

   On a local network, send from a genesis account through the debug wallet instead:

   ```bash
   just run-wallet auth-transfer send --from Public/CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r \
       --to "Public/$FUNDING" --amount "$MIN"
   ```

   **Expected result:** `Transaction is included in block <n>`.

1. Create the ownership account in the node's wallet. It holds the stake and receives the producer rewards. Save its ID in the home, because you need it to unstake:

   ```bash
   OWNERSHIP=$(LEE_WALLET_HOME_DIR="$NODE_HOME/wallet" wallet account new public \
       | sed -n 's|.*account_id Public/\([^ ]*\).*|\1|p')
   echo "$OWNERSHIP" > "$NODE_HOME/stake-ownership-account"
   ```

1. Submit the stake:

   ```bash
   submit_stake --wallet "$NODE_HOME/wallet" stake \
       --funding-account "$FUNDING" \
       --ownership-account "$OWNERSHIP" \
       --sequencer-key "$SEQUENCER_KEY" \
       --amount "$MIN"
   ```

   **Expected result:** `Submitted transaction <tx hash>`.

## Step 6: Confirm the key is accredited

The committee only changes on finalised state, and the change needs a member's turn plus co-signatures from two thirds of the members, so accreditation can take several minutes.

1. Check the channel until your key appears in `accredited_keys`:

   ```bash
   curl -s "$NODE_URL/channel/$CHANNEL_ID"
   ```

   **Expected result:** `{"accredited_keys":["<SEQUENCER_KEY>", ...], ...}`, with the value of `$SEQUENCER_KEY` in the list.

1. Watch the node's log. From now on, it produces blocks on its turn:

   ```text
   [2026-09-29T21:19:40Z INFO  sequencer_core] Publishing block 30 on pin 8312aa4a2a10ca38cb1db8c55fb3306f4f8fab1...
   ```

   - A turn can take up to one full rotation of the committee to come round.

## Step 7: Run the node as a service

On the public testnet, run the node under systemd so that it survives reboots. The node shuts down cleanly on `SIGTERM`. Skip this step on a local network.

1. Stop the foreground node from [Step 4](#step-4-start-the-node-and-let-it-catch-up) with `Ctrl-C`.

1. Write the service unit:

   ```bash
   sudo tee /etc/systemd/system/lez-sequencer.service >/dev/null <<EOF
   [Unit]
   Description=LEZ sequencer
   Wants=network-online.target
   After=network-online.target

   [Service]
   User=$USER
   Environment=RUST_LOG=info,kameo=warn
   ExecStart=$PWD/target/release/sequencer_service $(realpath "$NODE_HOME")/sequencer_config.json --home $(realpath "$NODE_HOME") --listen-address 127.0.0.1
   Restart=on-failure
   TimeoutStopSec=60

   [Install]
   WantedBy=multi-user.target
   EOF
   ```

1. Enable and start the service, then follow its log:

   ```bash
   sudo systemctl daemon-reload
   sudo systemctl enable --now lez-sequencer
   journalctl -u lez-sequencer -f
   ```

1. Confirm the node is producing blocks:

   ```bash
   journalctl -u lez-sequencer | grep "Publishing block"
   ```

   **Expected result:** one `Publishing block <n> on pin <msg id>` line for each block your node produced on its turn.

## Step 8: Leave the committee

Stopping the process doesn't remove the node from the committee. Request the unstake first, and stop the node only once the key has left `accredited_keys`.

1. Request the unstake. Replace `<destination-account>` with the account that receives the stake, as a bare base58 account ID with no `Public/` prefix:

   ```bash
   submit_stake --wallet "$NODE_HOME/wallet" unstake-request \
       --ownership-account "$(cat "$NODE_HOME/stake-ownership-account")" \
       --amount "$(cat "$NODE_HOME/stake-amount")" --destination <destination-account>
   ```

   - `--destination` doesn't accept the `Public/` prefix that the wallet commands use. On a local network, a genesis account such as `2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2` works as the destination.
   - The amount is the whole stake from [Step 5](#step-5-stake-the-nodes-key). A partial release must leave at least the minimum, or the program drops the request without reporting an error.
   - On a local network, submit the request while the first sequencer holds the turn: wait for `Turn update: our_turn=true` in terminal 2. The two local nodes don't share pending transactions, and the request goes only to the first sequencer, so it can expire while your node holds the turn.

   **Expected result:** `Submitted transaction <tx hash>`.

1. Check the channel until your key is no longer in `accredited_keys`:

   ```bash
   curl -s "$NODE_URL/channel/$CHANNEL_ID"
   ```

   - The request is only valid for 16 blocks. If it expires, the sequencer it was sent to logs `Execution outside of the validity window` for its transaction hash. Submit the request again.

1. Stop the node. On the public testnet:

   ```bash
   sudo systemctl disable --now lez-sequencer
   ```

   On a local network, press `Ctrl-C` in terminal 4.

   **Expected result:** after `exit_delay` blocks (100 by default), a sequencer includes the `FinalizeUnstake` transaction and the destination account receives the stake.

## Troubleshooting

### The key never appears in `accredited_keys`

Either the stake reverted, or the committee can't land the change yet.

- The stake reverts if it's below `minimum_sequencer_stake`, if the funding account isn't funded, or if the ownership account already backs another key.
- The committee follows finalised state and needs a member's turn plus two thirds of the members' co-signatures, so offline members, or another change in flight, hold it back.

Check the funding account's balance:

```bash
LEE_WALLET_HOME_DIR="$NODE_HOME/wallet" wallet account get --account-id "Public/$FUNDING"
```

If the funds are still there, the stake reverted: stake again with at least the minimum. Otherwise, wait for the change to settle.

- At `v0.3.2`, `just committee-watch` fails with a `KeyError`, because it looks up the stake program's account under the wrong ID. Use the `accredited_keys` check from [Step 6](#step-6-confirm-the-key-is-accredited) instead.

### The node starts its own channel

The log shows `Channel does not exist yet; starting it as channel creator`. The `channel_id` in the node's config is wrong or, on a local network, the node started before the first sequencer created the channel.

Stop the node, correct `channel_id` in `$NODE_HOME/sequencer_config.json` or wait for the first sequencer's first block, and delete the node's `rocksdb-<channel id>` directory in `$NODE_HOME`.

### The node can't pay Bedrock fees

The log shows `Failed to fund channel transaction`. The config's `funding_key` isn't a key in the Bedrock node's wallet, or that key holds no funds. Set `funding_key` to a funded key from that node's wallet, as in [Step 3](#step-3-prepare-the-node-home), and restart the node.

### Known constraints

- **Reachability:** members share mempool transactions and co-sign committee changes over gossip. A node that no member can connect to still produces on its turn, because its blocks go through Bedrock, but it only includes transactions sent to its own RPC, and it counts as offline for committee changes.
- **Downtime:** being offline isn't slashed and doesn't remove the node from the committee. A missed turn passes to the next member after `posting_timeout` idle slots, and the node earns no rewards for it. Slashing covers only invalid or misplaced blocks.
- **Clock:** turns follow Bedrock slots, not the local clock, but block timestamps come from the producing node's system clock and nothing checks them. Keep the clock synced with NTP.
- **Distribution:** v0.3.2 ships no prebuilt binaries or published Docker images for this flow. Build from source.
