diff --git a/Cargo.lock b/Cargo.lock index db917a7..f11f382 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1250,7 +1250,7 @@ dependencies = [ [[package]] name = "ic-repl" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ansi_term", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6827c55..64febb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ic-repl" -version = "0.5.0" +version = "0.5.1" authors = ["DFINITY Team"] edition = "2021" default-run = "ic-repl" diff --git a/src/exp.rs b/src/exp.rs index 0806187..e42cf93 100644 --- a/src/exp.rs +++ b/src/exp.rs @@ -175,6 +175,7 @@ impl Exp { "wasm_profiling" => match args.as_slice() { [IDLValue::Text(file)] | [IDLValue::Text(file), IDLValue::Record(_)] => { use ic_wasm::instrumentation::{instrument, Config}; + let use_new_metering = helper.use_new_metering; let path = resolve_path(&helper.base_path, file); let blob = std::fs::read(&path) .with_context(|| format!("Cannot read {path:?}"))?; @@ -224,7 +225,7 @@ impl Exp { trace_only_funcs, start_address: start_page.map(|page| page * 65536), page_limit, - use_new_metering: false, + use_new_metering, } } Some(_) => unreachable!(), @@ -232,7 +233,7 @@ impl Exp { trace_only_funcs: vec![], start_address: None, page_limit: None, - use_new_metering: false, + use_new_metering, }, }; instrument(&mut m, config).map_err(|e| anyhow::anyhow!("{e}"))?; diff --git a/src/helper.rs b/src/helper.rs index a964fa8..aa90ecf 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -94,6 +94,7 @@ pub struct MyHelper { pub base_path: std::path::PathBuf, pub history: Vec, pub messages: RefCell>, + pub use_new_metering: bool, } impl MyHelper { @@ -116,6 +117,7 @@ impl MyHelper { agent_url: self.agent_url.clone(), offline: self.offline.clone(), messages: self.messages.clone(), + use_new_metering: self.use_new_metering, } } pub fn new(agent: Agent, agent_url: String, offline: Option) -> Self { @@ -137,6 +139,7 @@ impl MyHelper { agent, agent_url, offline, + use_new_metering: false, }; res.fetch_root_key_if_needed().unwrap(); res.load_prelude().unwrap(); diff --git a/src/main.rs b/src/main.rs index ab17c71..51e5cf7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,7 +64,8 @@ fn repl(opts: Opts) -> anyhow::Result<()> { .history_ignore_space(true) .completion_type(CompletionType::List) .build(); - let h = MyHelper::new(agent, url.to_string(), offline); + let mut h = MyHelper::new(agent, url.to_string(), offline); + h.use_new_metering = opts.use_new_metering; if let Some(file) = opts.send { use crate::offline::{send_messages, Messages}; let json = std::fs::read_to_string(file)?; @@ -149,6 +150,9 @@ struct Opts { #[clap(short, long, conflicts_with("script"), conflicts_with("offline"))] /// Send signed messages send: Option, + #[clap(short, long)] + /// Use new metering with wasm_profiling. This option will be removed once the mainnet is using the new metering. + use_new_metering: bool, } fn main() -> anyhow::Result<()> {