# Feature flags (Carbon 2.0)

> Every Cargo feature in carbon-core, the datasource and metrics crates, and generated decoders, with what each one enables.

This page lists every Cargo feature in the Carbon 2.0.0 crates and what turning it on adds. Use it when a module or type from another reference page is missing from your build, or when you want to trim dependencies.

## Summary

| Crate                                                      | Features                                                                                                                    | Default       |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `carbon-core`                                              | [`macros`](#macros), [`postgres`](#postgres), [`graphql`](#graphql), [`yellowstone`](#yellowstone)                          | `macros`      |
| `carbon-prometheus-metrics`                                | [`http-server`](#http-server)                                                                                               | `http-server` |
| Generated decoders (`carbon-*-decoder`)                    | [`serde`](#serde), [`postgres`](#postgres-decoder), [`graphql`](#graphql-decoder), [`base58`](#base58) (CLI-generated only) | none          |
| `carbon-macros`, `carbon-proc-macros`, `carbon-test-utils` | none                                                                                                                        |               |
| `carbon-log-metrics`                                       | none                                                                                                                        |               |
| Every datasource crate                                     | none                                                                                                                        |               |

## carbon-core

Defined in [`crates/core/Cargo.toml`](https://github.com/sevenlabs-hq/carbon/blob/v2.0.0/crates/core/Cargo.toml).

### `macros`

Re-exports the declarative and procedural macros at the `carbon_core` crate root. On by default.

```toml
carbon-core = "2.0.0" # includes "macros"
```

**Details.** Adds the `carbon-macros` and `carbon-proc-macros` dependencies and re-exports everything they export, so you can write `carbon_core::try_decode_instructions!`, `carbon_core::instruction_decoder_collection!` and `#[derive(carbon_core::InstructionType)]`. It also re-exports `log` (hidden from the docs) for use inside the generated macro code. Every decoder crate enables this feature on `carbon-core` itself, so turning it off in your own `Cargo.toml` has no effect once you depend on a decoder.

**Example.**

```toml
carbon-core = { version = "2.0.0", default-features = false } # no macro re-exports
```

**See also.** [Macros](https://carbon.sevenlabs.org/reference/macros.md).

### `postgres`

Adds the `carbon_core::postgres` module: Postgres row types, processors and SQL primitives built on `sqlx`.

```toml
carbon-core = { version = "2.0.0", features = ["postgres"] }
```

**Details.** Enables the optional dependencies `sqlx` (with `postgres`, `rust_decimal` and `bigdecimal`), `sqlx_migrator`, `num-traits` and `bigdecimal`. It also changes [`PipelineBuilder::build`](https://carbon.sevenlabs.org/reference/pipeline-builder.md#build): with this feature, `build` registers the six `postgres_*` metrics, so they appear in every metrics export even if you use no Postgres processor. You add `sqlx` yourself as well, with a runtime feature such as `runtime-tokio-rustls`, to open a connection pool.

**Example.**

`Cargo.toml`:

```toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres"] }
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres"] }
sqlx_migrator = "0.17.0"
```

**See also.** [Postgres reference](https://carbon.sevenlabs.org/reference/postgres.md), [Postgres guide](https://carbon.sevenlabs.org/guides/postgres.md), [Metrics](https://carbon.sevenlabs.org/reference/metrics.md#carbon-core-postgres-feature).

### `graphql`

Adds the `carbon_core::graphql` module: Juniper scalars for Solana types and an Axum router helper.

```toml
carbon-core = { version = "2.0.0", features = ["graphql"] }
```

**Details.** Enables the optional dependencies `juniper`, `axum` and `juniper_axum`, and compiles `carbon_core::graphql::primitives` and `carbon_core::graphql::server`. It does not enable `postgres`. The GraphQL code that generated decoders emit queries Postgres, so in practice you enable both.

**Example.**

`Cargo.toml`:

```toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres", "graphql"] }
axum = "0.8.7"
```

**See also.** [GraphQL reference](https://carbon.sevenlabs.org/reference/graphql.md), [GraphQL guide](https://carbon.sevenlabs.org/guides/graphql.md).

### `yellowstone`

Adds `carbon_core::transformers::yellowstone`, which converts Yellowstone gRPC protobuf messages into Solana transaction types.

```toml
carbon-core = { version = "2.0.0", features = ["yellowstone"] }
```

**Details.** Enables the optional dependencies `yellowstone-grpc-proto`, `solana-account-decoder-client-types`, `solana-transaction-error` and `wincode`. The module provides `create_tx_versioned`, `create_tx_meta`, `ConversionError` and `ConversionResult`. `carbon-yellowstone-grpc-datasource` and `carbon-helius-laserstream-datasource` turn this feature on for you; enable it yourself only to convert protobuf messages in your own datasource.

**Example.**

`Cargo.toml`:

```toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["yellowstone"] }
yellowstone-grpc-proto = { version = "=12.7.0", default-features = false }
```

**See also.** [Custom datasource](https://carbon.sevenlabs.org/guides/custom-datasource.md), [Yellowstone gRPC](https://carbon.sevenlabs.org/datasources/yellowstone-grpc.md).

### Implicit dependency features

`carbon-core` names its optional dependencies without the `dep:` prefix in `macros`, `postgres` and `graphql`. Cargo therefore also exposes `carbon-macros`, `carbon-proc-macros`, `sqlx`, `sqlx_migrator`, `num-traits`, `bigdecimal`, `juniper`, `axum` and `juniper_axum` as feature names. Enabling one of these adds the dependency but does not compile any Carbon module, because the code checks for `macros`, `postgres` and `graphql`. Use the named features above instead.

## carbon-prometheus-metrics

Defined in [`metrics/prometheus-metrics/Cargo.toml`](https://github.com/sevenlabs-hq/carbon/blob/v2.0.0/metrics/prometheus-metrics/Cargo.toml).

### `http-server`

Adds the built-in `/metrics` HTTP server. On by default.

```toml
carbon-prometheus-metrics = "2.0.0" # includes "http-server"
```

**Details.** Enables the optional dependencies `axum`, `tokio`, `tower` and `tower-http`. It provides `PrometheusServerConfig`, `PrometheusMetrics::with_server`, `PrometheusMetrics::start_server`, `run_metrics_server`, `run_default_metrics_server` and `run_metrics_server_with_config`. Without it, only `PrometheusMetrics::new`, `prometheus_text` and `format_snapshot` remain, and you serve the text from your own HTTP stack.

**Example.**

```toml
carbon-prometheus-metrics = { version = "2.0.0", default-features = false } # text rendering only
```

**See also.** [Metrics reference](https://carbon.sevenlabs.org/reference/metrics.md#prometheusmetrics), [Prometheus guide](https://carbon.sevenlabs.org/guides/prometheus.md).

## Datasource crates

No datasource crate defines features. Two of them turn on a `carbon-core` feature for you:

| Crate                                       | Version | Enables on `carbon-core` |
| ------------------------------------------- | ------- | ------------------------ |
| `carbon-yellowstone-grpc-datasource`        | 2.0.0   | `yellowstone`            |
| `carbon-helius-laserstream-datasource`      | 2.0.0   | `yellowstone`            |
| `carbon-helius-atlas-ws-datasource`         | 2.0.0   | none                     |
| `carbon-helius-gpa-v2-datasource`           | 2.0.0   | none                     |
| `carbon-helius-gtfa-datasource`             | 2.0.0   | none                     |
| `carbon-rpc-block-crawler-datasource`       | 2.0.0   | none                     |
| `carbon-rpc-block-subscribe-datasource`     | 2.0.0   | none                     |
| `carbon-rpc-gpa-datasource`                 | 2.0.0   | none                     |
| `carbon-rpc-program-subscribe-datasource`   | 2.0.0   | none                     |
| `carbon-rpc-transaction-crawler-datasource` | 2.0.0   | none                     |
| `carbon-stream-message-datasource`          | 2.0.0   | none                     |
| `carbon-validator-snapshot-datasource`      | 2.0.0   | none                     |

Every datasource depends on `carbon-core` with default features, so `macros` is always on in a pipeline that uses one.

`carbon-jetstreamer-datasource` and `carbon-jito-shredstream-grpc-datasource` are excluded from the 2.0.0 workspace. They remain at 1.0.0 on the Carbon 1.x and Solana 3 stack and do not work with `carbon-core` 2.0.0: mixing them in causes duplicate `solana-pubkey` type errors (see [Errors](https://carbon.sevenlabs.org/reference/errors.md#related-errors)).

## Generated decoders

Every decoder crate in the repository (63 of them at 2.0.0) and every decoder generated by [`carbon-cli parse`](https://carbon.sevenlabs.org/reference/cli.md) has the same feature set. All are off by default. Examples below use [`carbon-meteora-dlmm-decoder`](https://carbon.sevenlabs.org/decoders/meteora-dlmm.md); the same applies to [`carbon-token-program-decoder`](https://carbon.sevenlabs.org/decoders/token-program.md) and the rest.

### `serde`

Derives `serde::Serialize` and `serde::Deserialize` on every account, instruction, event and type in the decoder.

```toml
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["serde"] }
```

**Details.** Enables the optional `serde` dependency, plus `serde-big-array` in decoders that have fixed arrays longer than 32 elements (`meteora-dlmm` does, `token-program` does not), because serde only supports arrays up to 32 elements. The account and instruction enums are serialized with an adjacent tag, for example `{"type": "Swap", "data": {…}}`. A `Pubkey` serializes as a JSON array of 32 numbers, not a base58 string, unless the decoder also has [`base58`](#base58).

**Example.**

```rust
// With features = ["serde"]
let json = serde_json::to_string(&decoded_instruction)?;
```

**See also.** [Decoders](https://carbon.sevenlabs.org/concepts/decoders.md).

### `postgres` (decoder)

Adds `accounts::postgres` and `instructions::postgres`: one row type per account and instruction, plus `sqlx_migrator` migrations that create their tables.

```toml
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }
```

**Details.** Enables `carbon-core/postgres`, `sqlx`, `async-trait`, `sqlx_migrator` and the decoder's `serde` feature. You get types such as `accounts::postgres::LbPairRow` and the migrations `MeteoraDlmmAccountsMigration` and `MeteoraDlmmInstructionsMigration`, named after the program.

**Example.**

`Cargo.toml`:

```toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres"] }
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }
```

**See also.** [Postgres guide](https://carbon.sevenlabs.org/guides/postgres.md), [Postgres reference](https://carbon.sevenlabs.org/reference/postgres.md).

### `graphql` (decoder)

Adds the decoder's GraphQL schema types and a `graphql` module with `QueryRoot` and `GraphQLContext`, which read rows from Postgres.

```toml
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres", "graphql"] }
```

**Details.** Enables `carbon-core/graphql`, `juniper` and the decoder's `serde` feature. It does **not** enable the decoder's `postgres` feature, but the generated GraphQL code uses the Postgres row types and `sqlx`. Enabling `graphql` alone fails to compile with errors such as ``cannot find `postgres` in `instructions` `` and ``cannot find module or crate `sqlx` ``. Always enable `postgres` with it.

**Example.**

`Cargo.toml`:

```toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres", "graphql"] }
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres", "graphql"] }
```

**See also.** [GraphQL guide](https://carbon.sevenlabs.org/guides/graphql.md), [GraphQL reference](https://carbon.sevenlabs.org/reference/graphql.md).

### `base58`

Serializes `Pubkey` fields as base58 strings in serde output. Only in decoders you generate with `--with-base58 true`.

```toml
my-program-decoder = { path = "../decoder", features = ["base58"] }
```

**Details.** Defined as `base58 = ["serde"]` by the CLI renderer. It adds a private `base58` module with `serialize` and `serialize_option` helpers and `#[serde(serialize_with = …)]` attributes on `Pubkey` and `Option<Pubkey>` fields of instructions, instruction accounts and events. Deserialization is unchanged. None of the decoder crates published to crates.io define this feature.

**Example.**

```sh
npx -y @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 true
```

With pnpm, bun or yarn, replace `npx -y` with `pnpm dlx`, `bunx` or `yarn dlx`.

**See also.** [CLI reference](https://carbon.sevenlabs.org/reference/cli.md), [Generate a decoder](https://carbon.sevenlabs.org/guides/generate-a-decoder.md).

## Scaffolded indexer features

`carbon-cli scaffold` writes an indexer crate whose `[features]` table contains `default = []`, plus `postgres = []` and `graphql = []` when you choose those options. These features are empty markers: the scaffold enables the real `postgres`/`graphql` features directly on its `carbon-core` and decoder dependencies. See the [CLI reference](https://carbon.sevenlabs.org/reference/cli.md).

---

Carbon 2.0.0 documentation · Web: https://carbon.sevenlabs.org/reference/feature-flags · Last updated 2026-11-09 · Index of all pages: https://carbon.sevenlabs.org/llms.txt
