Configuration Reference

Complete reference for all Prism configuration options.

Table of Contents


Configuration File

Prism uses TOML configuration files. The configuration file location can be specified via the PRISM_CONFIG environment variable.

# Use custom config file
export PRISM_CONFIG=/path/to/config.toml
cargo make run-server

If PRISM_CONFIG is not set, Prism looks for config/config.toml in the current directory.

Configuration Loading Priority

  1. TOML file values (from PRISM_CONFIG or default path)

  2. Environment variables with PRISM__ prefix (override TOML values)

  3. Built-in defaults (used if not specified)

Environment Variable Overrides

Use PRISM__ prefix with __ as separator for nested fields:


Server Configuration

HTTP server settings for binding address, port, and request handling.

Configuration Block

Options

Option
Type
Default
Description

bind_address

string

"127.0.0.1"

IP address to bind the server. Use "0.0.0.0" to listen on all interfaces

bind_port

integer

3030

Port number for the HTTP server. Must be > 0

max_concurrent_requests

integer

100

Maximum number of concurrent RPC requests. Limits memory and prevents overload

request_timeout_seconds

integer

30

Global request timeout in seconds. Requests exceeding this are cancelled

Examples

Public Server (listen on all interfaces):

High-Throughput Configuration:

Development Configuration:


Upstream Providers

Configuration for upstream Ethereum RPC providers.

Configuration Block

Options

Option
Type
Required
Default
Description

name

string

Yes

-

Human-readable identifier for metrics and logs

chain_id

integer

Yes

-

Ethereum chain ID (1 for mainnet, 11155111 for Sepolia, etc.)

https_url

string

Yes

-

HTTP(S) endpoint URL for JSON-RPC requests

wss_url

string

No

-

WebSocket URL for subscriptions (e.g., newHeads)

weight

integer

No

1

Load balancing weight. Higher weight = more traffic

timeout_seconds

integer

No

30

Request timeout for this provider

circuit_breaker_threshold

integer

No

2

Consecutive failures before circuit opens

circuit_breaker_timeout_seconds

integer

No

1

Seconds to wait before retrying after circuit opens

Multiple Providers Example

Provider Selection Behavior

  • Weight: Determines relative traffic distribution. Provider with weight 3 receives ~3x traffic of weight 1 provider

  • Circuit Breaker: Automatically isolates failing providers to prevent cascade failures

  • WebSocket: Required for real-time chain tip updates and reorg detection


Cache Configuration

Advanced caching system with multi-layer architecture.

Basic Cache Settings

Option
Type
Default
Description

enabled

boolean

true

Master switch for caching. Set to false to disable all caching

cache_ttl_seconds

integer

300

Default TTL for cache entries (currently not actively used)

Cache Manager Configuration

Option
Type
Default
Description

retain_blocks

integer

1000

Number of recent blocks to retain in cache

enable_auto_cleanup

boolean

true

Enable automatic background cleanup of old cache entries

cleanup_interval_seconds

integer

300

Interval for background cleanup tasks (5 minutes)

Log Cache Configuration

Event log caching with partial-range support.

Option
Type
Default
Description

chunk_size

integer

1000

Number of blocks per chunk for log storage

max_exact_results

integer

10000

Maximum number of individual log records to cache

max_bitmap_entries

integer

100000

Maximum bitmap entries for efficient range tracking

safety_depth

integer

12

Blocks from tip to consider "safe" (reorg protection)

Memory Impact:

  • max_exact_results = 10000 ≈ 30-60MB (depending on log size)

  • max_bitmap_entries = 100000 ≈ 10-20MB

Block Cache Configuration

Block header and body caching with hot window optimization.

Option
Type
Default
Description

hot_window_size

integer

200

Number of recent blocks kept in O(1) hot window

max_headers

integer

10000

Maximum block headers to cache

max_bodies

integer

10000

Maximum block bodies to cache

safety_depth

integer

12

Blocks from tip to consider "safe"

Memory Impact:

  • max_headers = 10000 ≈ 5-10MB

  • max_bodies = 10000 ≈ 10-30MB (varies with transaction count)

  • hot_window_size = 200 ≈ 1-2MB

Transaction Cache Configuration

Transaction and receipt caching.

Option
Type
Default
Description

max_transactions

integer

50000

Maximum transactions to cache

max_receipts

integer

50000

Maximum receipts to cache

safety_depth

integer

12

Blocks from tip to consider "safe"

Memory Impact:

  • max_transactions = 50000 ≈ 20-40MB

  • max_receipts = 50000 ≈ 30-50MB

Reorg Manager Configuration

Chain reorganization detection and cache invalidation.

Option
Type
Default
Description

safety_depth

integer

12

Blocks from tip considered safe from reorgs (~2.5 minutes on mainnet)

max_reorg_depth

integer

100

Maximum depth to search for divergence point during reorg

coalesce_window_ms

integer

100

Milliseconds to batch reorg events (prevents cache thrashing)

Cache Tuning Examples

Low Memory Configuration (< 1GB):

High Memory Configuration (8GB+):

DeFi Application (high eth_getLogs traffic):


Authentication Configuration

API key authentication and quota management.

Configuration Block

Option
Type
Default
Description

enabled

boolean

false

Enable API key authentication

database_url

string

"sqlite://./db/auth.db"

SQLite database URL for API keys

Creating API Keys

Use the CLI to manage API keys:

Using API Keys

Include the API key in requests:

Header (recommended):

Query parameter:


Metrics and Logging

Observability configuration for Prometheus metrics and structured logging.

Metrics Configuration

Option
Type
Default
Description

enabled

boolean

true

Enable Prometheus metrics collection

prometheus_port

integer

9090

Port for /metrics endpoint (optional)

Access metrics at: http://localhost:3030/metrics

Logging Configuration

Option
Type
Default
Description

level

string

"info"

Log level: trace, debug, info, warn, error

format

string

"pretty"

Output format: pretty (human-readable) or json (structured)

Logging Examples

Production (JSON logs for aggregation):

Development (readable logs):

Troubleshooting (verbose):

Health Check Configuration

Option
Type
Default
Description

interval_seconds

integer

60

Interval between upstream health checks (using eth_blockNumber)


Advanced Features

Advanced routing and optimization features.

Consensus Validation

Multi-upstream validation for critical methods.

Option
Type
Default
Description

enabled

boolean

false

Enable consensus validation

max_count

integer

3

Maximum upstreams to query

min_count

integer

2

Minimum upstreams for consensus

timeout_seconds

integer

10

Timeout for consensus requests

dispute_behavior

string

"PreferBlockHeadLeader"

How to resolve disputes

methods

array

[eth_getBlockByNumber, ...]

Methods requiring consensus

See Routing Strategies for details.

Hedging (Tail Latency Reduction)

Parallel request execution to reduce P99 latency.

Option
Type
Default
Description

enabled

boolean

false

Enable request hedging

latency_quantile

float

0.95

Latency percentile for hedge trigger

min_delay_ms

integer

50

Minimum delay before hedging

max_delay_ms

integer

2000

Maximum delay before hedging

max_parallel

integer

2

Maximum parallel requests

See Routing Strategies for details.

Scoring Engine

Multi-factor upstream ranking and selection.

Option
Type
Default
Description

enabled

boolean

false

Enable scoring-based selection

window_seconds

integer

1800

Metric collection window (30 min)

min_samples

integer

10

Minimum samples before scoring

max_block_lag

integer

5

Max block lag before penalty

top_n

integer

3

Top upstreams for selection

weights.latency

float

8.0

Latency factor weight

weights.error_rate

float

4.0

Error rate factor weight

weights.throttle_rate

float

3.0

Throttle factor weight

weights.block_head_lag

float

2.0

Block lag factor weight

weights.total_requests

float

1.0

Request count factor weight

See Routing Strategies for details.


Example Configurations

Development

Production

High-Performance DeFi


Configuration Validation

Always validate configuration before deploying:


Environment-Specific Configs

Organize configs by environment:

Load specific config:


Next: Learn about the Caching System or explore the API Reference.

Last updated