{"record":{"id":"d3ba4eb9ae3423ea","repo":"linera-io/linera-protocol","slug":"maximumfuelexceeded","errorCode":"MaximumFuelExceeded","errorMessage":"ExecutionError::MaximumFuelExceeded(vm_runtime)","messagePattern":"ExecutionError::MaximumFuelExceeded\\(vm_runtime\\)","errorType":"exception","errorClass":"ExecutionError","httpStatus":null,"severity":"error","filePath":"linera-execution/src/resources.rs","lineNumber":496,"sourceCode":"            .ok_or(ArithmeticError::Overflow)?;\n        self.update_balance(self.policy.http_request)\n    }\n\n    /// Tracks a number of fuel units used.\n    pub(crate) fn track_fuel(\n        &mut self,\n        fuel: u64,\n        vm_runtime: VmRuntime,\n    ) -> Result<(), ExecutionError> {\n        match vm_runtime {\n            VmRuntime::Wasm => {\n                self.tracker.as_mut().wasm_fuel = self\n                    .tracker\n                    .as_ref()\n                    .wasm_fuel\n                    .checked_add(fuel)\n                    .ok_or(ArithmeticError::Overflow)?;\n                ensure!(\n                    self.tracker.as_ref().wasm_fuel <= self.policy.maximum_wasm_fuel_per_block,\n                    ExecutionError::MaximumFuelExceeded(vm_runtime)\n                );\n            }\n            VmRuntime::Evm => {\n                self.tracker.as_mut().evm_fuel = self\n                    .tracker\n                    .as_ref()\n                    .evm_fuel\n                    .checked_add(fuel)\n                    .ok_or(ArithmeticError::Overflow)?;\n                ensure!(\n                    self.tracker.as_ref().evm_fuel <= self.policy.maximum_evm_fuel_per_block,\n                    ExecutionError::MaximumFuelExceeded(vm_runtime)\n                );\n            }\n        }\n        self.update_balance(self.policy.fuel_price(fuel, vm_runtime)?)","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-execution/src/resources.rs#L478-L514","documentation":"track_fuel accumulates Wasm fuel consumed within a block via consume_fuel; when the running total exceeds the policy's maximum_wasm_fuel_per_block, execution fails with MaximumFuelExceeded(VmRuntime::Wasm) (resources.rs:496). Every Wasm instruction executed by the block's operations and messages is metered against this per-block cap.","triggerScenarios":"A block whose combined operations and messages burn more Wasm fuel than maximum_wasm_fuel_per_block: long-running loops in a contract, heavy computation, or too many operations batched into one block.","commonSituations":"Batching many operations into a single proposed block; compute-heavy contract upgrades; policy caps tightened by a new epoch; benchmark contracts with unbounded loops.","solutions":["Split the work across multiple blocks (fewer operations per block)","Optimize the contract: remove hot loops, cache results, reduce per-operation fuel","If you operate the committee, raise maximum_wasm_fuel_per_block in the resource policy"],"exampleFix":"// before: all operations in one block\nblock.extend(operations);\npropose(block)?;\n\n// after: split into blocks sized under the per-block fuel cap\nfor chunk in operations.chunks(max_ops_per_block) {\n    propose(Block::new(chunk.to_vec()))?;\n}","handlingStrategy":"fallback","validationCode":"// Estimate Wasm fuel per operation (from a benchmark or previous run) and\n// cap the batch before proposing the block.\nfn fits_fuel_budget(ops: &[Operation], est_fuel: impl Fn(&Operation) -> u64, max: u64) -> bool {\n    ops.iter().map(&est_fuel).try_fold(0u64, |acc, f| acc.checked_add(f))\n        .map(|total| total <= max)\n        .unwrap_or(false)\n}\n\nif !fits_fuel_budget(&ops, estimate, policy.maximum_wasm_fuel_per_block) {\n    ops.truncate(smaller_batch_len); // propose a smaller block\n}","typeGuard":"fn is_wasm_fuel_exceeded(err: &ExecutionError) -> bool {\n    matches!(err, ExecutionError::MaximumFuelExceeded(VmRuntime::Wasm))\n}","tryCatchPattern":"match proposer.propose(block).await {\n    Ok(h) => h,\n    Err(ref e) if is_wasm_fuel_exceeded(e) => {\n        // fallback: split the block in half and propose sequentially\n        let (a, b) = block.operations.split_at(block.operations.len() / 2);\n        propose_all(vec![a.to_vec(), b.to_vec()]).await\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Benchmark per-operation fuel and size batches against maximum_wasm_fuel_per_block","Optimize hot loops in contracts before raising block sizes","Monitor per-block fuel usage so batches stay under the cap with headroom"],"tags":["fuel","wasm","resource-limits","block","linera"],"backgroundTag":"gas-limit-exceeded","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}