fluentbase_runtime/syscall_handler/host/fuel.rs
1/// Builtin to query remaining engine fuel.
2use crate::RuntimeContext;
3use rwasm::{StoreTr, TrapCode, Value};
4
5/// Writes the remaining fuel (or `u64::MAX` if metering is disabled) into `result[0]`.
6pub fn syscall_fuel_handler(
7 caller: &mut impl StoreTr<RuntimeContext>,
8 _params: &[Value],
9 result: &mut [Value],
10) -> Result<(), TrapCode> {
11 let fuel_remaining = caller.remaining_fuel().unwrap_or(u64::MAX);
12 result[0] = Value::I64(fuel_remaining as i64);
13 Ok(())
14}
15
16pub fn syscall_fuel_impl(_ctx: &RuntimeContext) -> u64 {
17 unimplemented!()
18}