diff --git a/src/commands/run.rs b/src/commands/run.rs index ae228d480a..abd1e59a1d 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -164,6 +164,12 @@ impl RunCommand { let engine = Engine::new(&config)?; let mut store = Store::new(&engine, Host::default()); + // If fuel has been configured, we want to add the configured + // fuel amount to this store. + if let Some(fuel) = self.common.fuel { + store.add_fuel(fuel)?; + } + let preopen_sockets = self.compute_preopen_sockets()?; // Make wasi available by default. diff --git a/src/lib.rs b/src/lib.rs index b3cb8961f7..1a9b20c54f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -234,9 +234,8 @@ struct CommonOptions { #[structopt(long)] enable_cranelift_nan_canonicalization: bool, - /// Executing wasm code will consume fuel, limiting its execution. #[structopt(long)] - consume_fuel: bool, + fuel: Option, /// Executing wasm code will yield when a global epoch counter /// changes, allowing for async operation without blocking the @@ -328,7 +327,11 @@ impl CommonOptions { config.dynamic_memory_guard_size(size); } - config.consume_fuel(self.consume_fuel); + // If fuel has been configured, set the `consume fuel` flag on the config. + if self.fuel.is_some() { + config.consume_fuel(true); + } + config.epoch_interruption(self.epoch_interruption); config.generate_address_map(!self.disable_address_map); config.paged_memory_initialization(self.paged_memory_initialization);