{"record":{"id":"86c354ee61b157dd","repo":"linera-io/linera-protocol","slug":"total-number-of-shards-exceeds-maximum-allowe","errorCode":null,"errorMessage":"Total number of shards ({}) exceeds maximum allowed ({})","messagePattern":"Total number of shards \\((.+?)\\) exceeds maximum allowed \\((.+?)\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"linera-service/src/cli_wrappers/local_net.rs","lineNumber":443,"sourceCode":"            self.namespace,\n            self.num_initial_validators,\n            self.num_proxies,\n            self.num_shards,\n            storage_config,\n            self.cross_chain_config,\n            self.path_provider,\n            self.block_exporters,\n            self.binary_dir,\n            self.export_blocks_to_committee,\n            self.block_export_transport,\n        );\n        let client = net.make_client().await;\n        ensure!(\n            self.num_initial_validators > 0,\n            \"There should be at least one initial validator\"\n        );\n        let total_number_shards = self.num_initial_validators * self.num_shards;\n        ensure!(\n            total_number_shards <= MAX_NUMBER_SHARDS,\n            \"Total number of shards ({}) exceeds maximum allowed ({})\",\n            self.num_shards,\n            MAX_NUMBER_SHARDS\n        );\n        net.generate_initial_validator_config().await?;\n        client\n            .create_genesis_config(\n                self.num_other_initial_chains,\n                self.initial_amount,\n                self.policy_config,\n                self.http_request_allow_list\n                    .clone()\n                    .or_else(|| Some(vec![\"localhost\".to_owned()])),\n            )\n            .await?;\n        net.run().await?;\n        Ok((net, client))","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/cli_wrappers/local_net.rs#L425-L461","documentation":"LocalNet::instantiate checks that num_initial_validators * num_shards stays within MAX_NUMBER_SHARDS (1000); beyond that the generated validator/shard topology would be invalid, so instantiation fails. Note the message prints num_shards, but the limit actually applies to the product validators times shards.","triggerScenarios":"Configuring the LocalNet builder with shard counts such that validators x shards exceeds 1000, e.g. 4 validators with `.with_num_shards(300)` gives 1200 > 1000.","commonSituations":"Scaling stress tests beyond devnet-sized topologies; copying a topology constant from another test; forgetting that num_shards is per validator.","solutions":["Lower num_shards so validators x shards <= 1000 (e.g. 4 validators -> at most 250 shards each)","Reduce num_initial_validators","If genuinely needed, change MAX_NUMBER_SHARDS in your fork — but prefer smaller test topologies"],"exampleFix":"// before\nbuilder.with_num_initial_validators(4).with_num_shards(300); // 4 * 300 = 1200 > 1000 -> error\n\n// after\nbuilder.with_num_initial_validators(4).with_num_shards(200); // 4 * 200 = 800 <= 1000","handlingStrategy":"validation","validationCode":"const MAX_NUMBER_SHARDS: usize = 1000;\nlet total = num_initial_validators * num_shards;\nassert!(total <= MAX_NUMBER_SHARDS, \"validators x shards = {total} exceeds {MAX_NUMBER_SHARDS}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute validators x shards before configuring LocalNet","Keep test topologies at devnet scale","Remember num_shards is per validator, not global"],"tags":["test-harness","localnet","shards","capacity","integration-tests"],"backgroundTag":"shard-limit-exceeded","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}