Feature flags
Every Cargo feature in carbon-core, the datasource and metrics crates, and generated decoders, with what each one enables.
On this page
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, postgres, graphql, yellowstone | macros |
carbon-prometheus-metrics | http-server | http-server |
Generated decoders (carbon-*-decoder) | serde, postgres, graphql, 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/.
macros#
Re-exports the declarative and procedural macros at the carbon_core crate root. On by default.
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_, carbon_ and #[derive(carbon_. 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.
carbon-core = { version = "2.0.0", default-features = false } # no macro re-exportsSee also. Macros.
postgres#
Adds the carbon_ module: Postgres row types, processors and SQL primitives built on sqlx.
carbon-core = { version = "2.0.0", features = ["postgres"] }Details. Enables the optional dependencies sqlx (with postgres, rust_ and bigdecimal), sqlx_, num-traits and bigdecimal. It also changes PipelineBuilder::: 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.
[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, Postgres guide, Metrics.
graphql#
Adds the carbon_ module: Juniper scalars for Solana types and an Axum router helper.
carbon-core = { version = "2.0.0", features = ["graphql"] }Details. Enables the optional dependencies juniper, axum and juniper_, and compiles carbon_ and carbon_. It does not enable postgres. The GraphQL code that generated decoders emit queries Postgres, so in practice you enable both.
Example.
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres", "graphql"] }
axum = "0.8.7"See also. GraphQL reference, GraphQL guide.
yellowstone#
Adds carbon_, which converts Yellowstone gRPC protobuf messages into Solana transaction types.
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_, create_, 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.
[dependencies]
carbon-core = { version = "2.0.0", features = ["yellowstone"] }
yellowstone-grpc-proto = { version = "=12.7.0", default-features = false }See also. Custom datasource, Yellowstone gRPC.
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_, num-traits, bigdecimal, juniper, axum and juniper_ 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/.
http-server#
Adds the built-in /metrics HTTP server. On by default.
carbon-prometheus-metrics = "2.0.0" # includes "http-server"Details. Enables the optional dependencies axum, tokio, tower and tower-http. It provides PrometheusServerConfig, PrometheusMetrics::, PrometheusMetrics::, run_, run_ and run_. Without it, only PrometheusMetrics::, prometheus_ and format_ remain, and you serve the text from your own HTTP stack.
Example.
carbon-prometheus-metrics = { version = "2.0.0", default-features = false } # text rendering onlySee also. Metrics reference, Prometheus guide.
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).
Generated decoders#
Every decoder crate in the repository (63 of them at 2.0.0) and every decoder generated by carbon-cli parse has the same feature set. All are off by default. Examples below use carbon-meteora-dlmm-decoder; the same applies to carbon-token-program-decoder and the rest.
serde#
Derives serde:: and serde:: on every account, instruction, event and type in the decoder.
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.
Example.
// With features = ["serde"]
let json = serde_json::to_string(&decoded_instruction)?;See also. Decoders.
postgres (decoder)#
Adds accounts:: and instructions::: one row type per account and instruction, plus sqlx_ migrations that create their tables.
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }Details. Enables carbon-core/, sqlx, async-trait, sqlx_ and the decoder's serde feature. You get types such as accounts:: and the migrations MeteoraDlmmAccountsMigration and MeteoraDlmmInstructionsMigration, named after the program.
Example.
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres"] }
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }See also. Postgres guide, Postgres reference.
graphql (decoder)#
Adds the decoder's GraphQL schema types and a graphql module with QueryRoot and GraphQLContext, which read rows from Postgres.
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres", "graphql"] }Details. Enables carbon-core/, 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.
[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, GraphQL reference.
base58#
Serializes Pubkey fields as base58 strings in serde output. Only in decoders you generate with --with-base58 true.
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_ helpers and #[serde(serialize_ attributes on Pubkey and Option< fields of instructions, instruction accounts and events. Deserialization is unchanged. None of the decoder crates published to crates.io define this feature.
Example.
npx -y @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 truepnpm dlx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 truebunx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 trueyarn dlx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 trueSee also. CLI reference, Generate a decoder.
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.