Added 'add_fuel' command line option (#3792)
* Added 'add_fuel' command line option * Added default value to 'add_fuel' config option * Added 'add_fuel' to run command Store instantiation * Added comment * Added warning for add-fuel without consume-fuel * Formatting * Changed out --add-fuel and --consume-fuel to --fuel * Formatting * Update src/lib.rs * Update src/commands/run.rs Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
This commit is contained in:
@@ -164,6 +164,12 @@ impl RunCommand {
|
|||||||
let engine = Engine::new(&config)?;
|
let engine = Engine::new(&config)?;
|
||||||
let mut store = Store::new(&engine, Host::default());
|
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()?;
|
let preopen_sockets = self.compute_preopen_sockets()?;
|
||||||
|
|
||||||
// Make wasi available by default.
|
// Make wasi available by default.
|
||||||
|
|||||||
@@ -234,9 +234,8 @@ struct CommonOptions {
|
|||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
enable_cranelift_nan_canonicalization: bool,
|
enable_cranelift_nan_canonicalization: bool,
|
||||||
|
|
||||||
/// Executing wasm code will consume fuel, limiting its execution.
|
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
consume_fuel: bool,
|
fuel: Option<u64>,
|
||||||
|
|
||||||
/// Executing wasm code will yield when a global epoch counter
|
/// Executing wasm code will yield when a global epoch counter
|
||||||
/// changes, allowing for async operation without blocking the
|
/// changes, allowing for async operation without blocking the
|
||||||
@@ -328,7 +327,11 @@ impl CommonOptions {
|
|||||||
config.dynamic_memory_guard_size(size);
|
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.epoch_interruption(self.epoch_interruption);
|
||||||
config.generate_address_map(!self.disable_address_map);
|
config.generate_address_map(!self.disable_address_map);
|
||||||
config.paged_memory_initialization(self.paged_memory_initialization);
|
config.paged_memory_initialization(self.paged_memory_initialization);
|
||||||
|
|||||||
Reference in New Issue
Block a user