> ## Documentation Index
> Fetch the complete documentation index at: https://docs.optimism.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Enabling Sequencer Defined Metering

> Turn Sequencer Defined Metering on or off on an OP Stack sequencer, and confirm which gate is holding it back.

> [!WARNING]
>
> SDM is not yet live. Stock public `op-reth` supports the SDM consensus and verification
> mechanism, but it does **not** implement a refund-producing policy. Enabling its operator gate does
> not cause it to issue refunds or append post-exec transactions.

This guide covers the operator control surface for **Sequencer Defined Metering (SDM)**: turning it
on, confirming it, and turning it off. For what SDM does and what changes on your chain when it
activates, see the [SDM explainer](https://docs.optimism.io/op-stack/features/sdm.md).

## Before you start

Run versions of `op-reth`, and of `op-node` or `kona-node`, that implement the
[Lagoon hardfork](https://docs.optimism.io/op-stack/protocol/hardforks/lagoon.md).

Verifier operators do not opt in to anything and have no SDM configuration. If you run verifier
nodes only, running up-to-date software is all you need to do, and the rest of this page does not
apply to you.

## Chain operator opt-in

A sequencer appends a post-exec transaction only if Lagoon is active at the block's timestamp and
the operator has opted in on that node. If either is false, the node builds blocks under legacy
gas accounting and appends nothing.

The opt-in can be set before or after Lagoon, and does nothing until Lagoon activates. You do not
have to time it, and nothing needs changing at the activation itself.

It can be set three ways:

| Surface | Value | Notes |
| - | - | - |
| `--rollup.operator-sdm-opt-in` | `true` / `false` | CLI flag, read at boot. Defaults to `false`. |
| `OP_RETH_OPERATOR_SDM_OPT_IN` | `true` / `false` | Environment binding for the same flag. |
| `admin_setOperatorSdmOptIn` | `true` / `false` | Admin RPC. Applies to the next produced block, no restart. |

The RPC only changes the value in memory. A restart loses it, and a standby sequencer that takes
over starts from its own configuration. Set the CLI flag or environment variable for the value you
want to stick, and use the RPC when you need to change it without restarting.

## Confirming which gate is holding

`admin_sdmStatus` reports both gates. It takes an optional query timestamp and defaults to the
current time. On a sequencer that has opted in while Lagoon is still unscheduled:

```json title="admin_sdmStatus" theme={null}
{
  "operatorSdmOptIn": true,
  "protocolActive": false,
  "effective": false,
  "activationTime": null
}
```

`effective` is the AND of the two gates, and is the field that tells you whether the node is
producing rebates. `activationTime` is the Lagoon activation timestamp once one is scheduled, and `null`
before that.

To inspect a receipt produced by an SDM-enabled sequencer:

```bash title="Inspect a receipt" theme={null}
cast receipt <TX_HASH> --rpc-url <RPC_URL> --json | jq '.opGasRefund'
```

You can also fetch the containing block and check whether its last transaction has type `0x7D`.
A block without rebates has no post-exec transaction, so absence alone does not tell you whether
the protocol is active. Check `admin_sdmStatus` instead.

## Disabling SDM

To stop a sequencer issuing rebates:

1. Call `admin_setOperatorSdmOptIn(false)` on it. This applies from the next payload and needs no
   restart.
2. Check `admin_sdmStatus` to confirm `effective` is now `false`.
3. Set `OP_RETH_OPERATOR_SDM_OPT_IN=false` (or the CLI flag) in the deployment, or a restart will
   turn it back on.

Steps 1 and 2 with `cast`:

```bash title="Disable SDM at runtime" theme={null}
cast rpc admin_setOperatorSdmOptIn false --rpc-url <SEQUENCER_ADMIN_RPC_URL>
cast rpc admin_sdmStatus --rpc-url <SEQUENCER_ADMIN_RPC_URL> | jq '.effective'
```

This only affects blocks the sequencer builds from then on. Post-exec transactions already in the
chain stay valid and verifiers keep validating them, so there is nothing to coordinate with
verifier operators and no config or hardfork change to make.

## Stock `op-reth` production behavior

Released public `op-reth` uses a null refund policy. It never creates a non-empty refund payload and
never appends a post-exec transaction, even when Lagoon is active and
`admin_setOperatorSdmOptIn(true)` has been called. The admin surface remains available for protocol
compatibility and downstream sequencer integrations; it is not a policy-selection interface in
stock `op-reth`.

## Refund policies and OP Enterprise

Refund policies are tuned to a chain's needs, and are a premium feature for OP Enterprise
customers. The policy is what decides which transactions get rebated and by how much, so it varies
from sequencer to sequencer. If you are interested in becoming an OP Enterprise customer,
[contact the OP Enterprise team](https://optimism.io/learn-more).

## Debug replay

`debug_replaySDMBlock` is an operator and research diagnostic. It re-executes a historical block's
non-post-exec transactions under standard gas accounting to recover each transaction's raw
(pre-rebate) gas, reports that alongside the block's claimed refunds, and flags any claim that
breaks the spec's [validity rules](https://specs.optimism.io/protocol/lagoon/sdm.html#validity-rules).

It does not recompute what the refunds should have been: that requires the sequencer's policy, which
stock `op-reth` does not implement. The endpoint requires historical state and should not be exposed
on public RPC interfaces.

## Next steps

* Read the [SDM explainer](https://docs.optimism.io/op-stack/features/sdm.md) for the mechanism, canonical gas and settlement.
* See what else ships in the [Lagoon hardfork](https://docs.optimism.io/op-stack/protocol/hardforks/lagoon.md).
