linera-io/linera-protocol · error · anyhow::Error
There should be at least one initial validator
Error message
There should be at least one initial validator
What it means
LocalNet, the Rust integration-test harness for a local Linera network, computes its shard topology in instantiate() and requires at least one initial validator; with num_initial_validators == 0 there is no committee to generate, so the harness aborts immediately after make_client().
Source
Thrown at linera-service/src/cli_wrappers/local_net.rs:438
async fn instantiate(self) -> Result<(Self::Net, ClientWrapper)> {
let storage_config = self.storage_config_builder.build(self.database).await?;
let mut net = LocalNet::new(
self.network,
self.testing_prng_seed,
self.namespace,
self.num_initial_validators,
self.num_proxies,
self.num_shards,
storage_config,
self.cross_chain_config,
self.path_provider,
self.block_exporters,
self.binary_dir,
self.export_blocks_to_committee,
self.block_export_transport,
);
let client = net.make_client().await;
ensure!(
self.num_initial_validators > 0,
"There should be at least one initial validator"
);
let total_number_shards = self.num_initial_validators * self.num_shards;
ensure!(
total_number_shards <= MAX_NUMBER_SHARDS,
"Total number of shards ({}) exceeds maximum allowed ({})",
self.num_shards,
MAX_NUMBER_SHARDS
);
net.generate_initial_validator_config().await?;
client
.create_genesis_config(
self.num_other_initial_chains,
self.initial_amount,
self.policy_config,
self.http_request_allow_list
.clone()View on GitHub (pinned to 6c226ddcb3)
Solutions
- Set at least one initial validator, e.g. `.with_num_initial_validators(4)`, matching your test's committee needs
- Skip the test when the configured size is 0 instead of instantiating
- Make the test read the count from the same source as the rest of its configuration to avoid divergent defaults
Example fix
// before let net = builder.with_num_initial_validators(0).build().instantiate().await?; // ensure fails // after let net = builder.with_num_initial_validators(4).build().instantiate().await?;
Defensive patterns
Strategy: validation
Validate before calling
assert!(
net_builder.num_initial_validators > 0,
"LocalNet requires at least one initial validator"
); Prevention
- Validate committee size inputs before building LocalNet
- Skip parameterized tests at size 0 instead of instantiating
- Derive the count from the test's own config to avoid divergent defaults
When it happens
Trigger: Building a LocalNet whose num_initial_validators is 0 (e.g. `.with_num_initial_validators(0)` or a builder whose field defaults/inputs resolve to 0) and calling instantiate().
Common situations: Parameterized test matrices that iterate committee sizes including zero; refactors that read the validator count from an env var or config defaulting to 0.
Related errors
- Total number of shards ({}) exceeds maximum allowed ({})
- Found issues while querying validators
- Found faulty validators
- Found one or several issue(s) while querying validator {}
- Failed to start node service
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/8b811dbdc55b13ca.
Report an issue: GitHub.