Overview
Chainbench fetches real blockchain data before starting tests to use as parameters for RPC method calls. This ensures that benchmarks use realistic data patterns and valid addresses, transaction hashes, and block numbers from the target blockchain.How Test Data Works
Before spawning users, Chainbench:- Connects to the blockchain node
- Fetches the chain ID to identify the network
- Determines the block range to fetch based on configuration
- Retrieves blocks with transaction data
- Extracts useful information (addresses, tx hashes, block hashes, etc.)
- Stores this data in memory for use during the test
Test data is fetched once before the test starts and shared across all workers. This improves consistency and makes benchmarks more comparable across runs.
Test Data Sizes
You can control how much test data is generated using the--size flag:
| Size | Blocks | Use Case |
|---|---|---|
| XS | 10 | Quick validation tests |
| S | 100 | Default - suitable for most tests |
| M | 1,000 | More data variety |
| L | 10,000 | Extensive testing |
| XL | 100,000 | Maximum variety (longer generation time) |
Usage Example
Larger data sizes result in longer test data generation times but provide more variety in test parameters. For most benchmarks, size S (default) is sufficient.
Block Range Configuration
Chainbench determines which blocks to fetch based on several factors:Default Behavior
For each supported network, Chainbench has a configured starting block to avoid fetching from genesis:Custom Block Range
You can specify a custom block range:Block Range Selection Logic
Block Range Selection Logic
The test data system selects blocks using this logic:
- If
--start-blockand--end-blockare provided, use those values - If
--use-latest-blocksis set, ignore custom range and use latest blocks - Otherwise, use the network’s default start block and latest block as end
- Validate that the range is valid and within the node’s available history
Using Latest Blocks
For nodes with limited history (e.g., running in fast sync mode), use the--use-latest-blocks flag:
--use-latest-blocks:
- Chainbench fetches the latest N blocks (N = size)
- A background process continuously updates test data with new blocks
- Ensures all test data references are within the node’s available history
Dynamic Parameters
Chainbench uses parameter factories to generate realistic RPC call parameters from the test data.Available Data
For EVM chains, test data includes:- Block numbers: Random block numbers from the fetched range
- Block hashes: Hashes of fetched blocks
- Transaction hashes: Hashes from transactions in fetched blocks
- Addresses: Both
fromandtoaddresses from transactions (up to 100 per block) - Contract addresses: Known contract addresses for the network
Parameter Factories
Profiles use parameter factories to generate realistic call parameters:Parameter factories use a seeded random number generator (
get_rng()) to ensure consistency across runs and workers.Reference URL
You can fetch test data from a different node than the one being tested:- Testing a new node that doesn’t have historical data yet
- The node under test has limited archive access
- You want consistent test data across multiple test runs
Network-Specific Data
Chainbench includes predefined contract addresses for popular tokens on each network:eth_call and other contract-related operations.
Data Consistency
How Chainbench Ensures Consistency
How Chainbench Ensures Consistency
Chainbench uses several techniques to ensure consistent benchmarks:
- Seeded RNG: Each parameter factory uses a function-specific random seed
- Shared data: All workers use the same test data
- Deterministic selection: Same random seed produces same data selection
- Fixed block range: Unless using
--use-latest-blocks, the block range is fixed