diff --git a/Cargo.lock b/Cargo.lock index 11298437..da4f5a4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,13 +176,14 @@ dependencies = [ [[package]] name = "air-test-utils" -version = "0.3.0" +version = "0.4.0" dependencies = [ "air", "air-interpreter-interface", "avm-interface", "avm-server", "fstrings", + "maplit", "marine-rs-sdk", "object-pool", "once_cell", @@ -319,7 +320,7 @@ dependencies = [ [[package]] name = "avm-interface" -version = "0.26.1" +version = "0.27.0" dependencies = [ "air-interpreter-interface", "air-utils", @@ -335,7 +336,7 @@ dependencies = [ [[package]] name = "avm-server" -version = "0.26.1" +version = "0.27.0" dependencies = [ "air-interpreter-interface", "air-utils", diff --git a/air/tests/test_module/issues/issue_177.rs b/air/tests/test_module/issues/issue_177.rs index eb8ccfc7..4d15c995 100644 --- a/air/tests/test_module/issues/issue_177.rs +++ b/air/tests/test_module/issues/issue_177.rs @@ -45,7 +45,7 @@ fn issue_177() { // client 1: demand result for (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) let client_result_1 = client .runner - .call(script, "", "", client_peer_id, 0, 0, HashMap::new()) + .call(script, "", "", client_peer_id, 0, 0, None, HashMap::new()) .expect("call should be success"); let expected_call_requests = maplit::hashmap! { 1 => CallRequestParams::new("getDataSrv", "-relay-", vec![], vec![]), @@ -59,7 +59,16 @@ fn issue_177() { // client 2: send result to the specified relay let client_result_2 = client .runner - .call(script, client_result_1.data, "", client_peer_id, 0, 0, call_results) + .call( + script, + client_result_1.data, + "", + client_peer_id, + 0, + 0, + None, + call_results, + ) .expect("call should be success"); assert!(client_result_2.call_requests.is_empty()); assert_eq!(client_result_2.next_peer_pks, vec![relay_peer_id.to_string()]); @@ -74,6 +83,7 @@ fn issue_177() { client_peer_id, 0, 0, + None, HashMap::new(), ) .expect("call should be success"); @@ -96,6 +106,7 @@ fn issue_177() { client_peer_id, 0, 0, + None, call_results, ) .expect("call should be success"); @@ -114,6 +125,7 @@ fn issue_177() { client_peer_id, 0, 0, + None, call_results, ) .expect("call should be success"); @@ -132,6 +144,7 @@ fn issue_177() { client_peer_id, 0, 0, + None, call_results, ) .expect("call should be success"); @@ -147,6 +160,7 @@ fn issue_177() { client_peer_id, 0, 0, + None, HashMap::new(), ) .expect("call should be success"); @@ -163,7 +177,16 @@ fn issue_177() { // demand a result for (call %init_peer_id% ("peer" "timeout") [1000 "timeout"]) let client_result_4 = client .runner - .call(script, client_result_3.data, "", client_peer_id, 0, 0, call_results) + .call( + script, + client_result_3.data, + "", + client_peer_id, + 0, + 0, + None, + call_results, + ) .expect("call should be success"); let expected_call_requests = maplit::hashmap! { 3 => CallRequestParams::new("peer", "timeout", vec![json!(1000u64), json!("timeout")], vec![ @@ -178,9 +201,16 @@ fn issue_177() { }; // timeout requests provided - let client_result_5 = client - .runner - .call(script, client_result_4.data, "", client_peer_id, 0, 0, call_results); + let client_result_5 = client.runner.call( + script, + client_result_4.data, + "", + client_peer_id, + 0, + 0, + None, + call_results, + ); // before patch the interpreter crashed here assert!(client_result_5.is_ok()); } diff --git a/avm/interface/CHANGELOG.md b/avm/interface/CHANGELOG.md index 0979b3c3..34ecdd02 100644 --- a/avm/interface/CHANGELOG.md +++ b/avm/interface/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.27.0] - 2022-11-22 + +### Added + +- Add `current_peer_id` field to the `ParticleParameters` + +### Changed + +- `ParticleParameters` now has only single lifetime parameter + ## [0.26.1] - 2022-09-13 ### Fixed diff --git a/avm/interface/Cargo.toml b/avm/interface/Cargo.toml index 9d44c74e..59de49b9 100644 --- a/avm/interface/Cargo.toml +++ b/avm/interface/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "avm-interface" description = "Fluence AIR VM interfacing" -version = "0.26.1" +version = "0.27.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" diff --git a/avm/interface/src/particle_parameters.rs b/avm/interface/src/particle_parameters.rs index 670fbd8e..e56ea421 100644 --- a/avm/interface/src/particle_parameters.rs +++ b/avm/interface/src/particle_parameters.rs @@ -20,25 +20,28 @@ use std::borrow::Cow; /// Represents parameters obtained from a particle. #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ParticleParameters<'init_peer_id, 'particle_id> { - pub init_peer_id: Cow<'init_peer_id, str>, - pub particle_id: Cow<'particle_id, str>, +pub struct ParticleParameters<'ctx> { + pub init_peer_id: Cow<'ctx, str>, + pub particle_id: Cow<'ctx, str>, pub timestamp: u64, pub ttl: u32, + pub current_peer_id: Cow<'ctx, str>, } -impl<'init_peer_id, 'particle_id> ParticleParameters<'init_peer_id, 'particle_id> { +impl<'ctx> ParticleParameters<'ctx> { pub fn new( - init_peer_id: Cow<'init_peer_id, str>, - particle_id: Cow<'particle_id, str>, + init_peer_id: Cow<'ctx, str>, + particle_id: Cow<'ctx, str>, timestamp: u64, ttl: u32, + current_peer_id: Cow<'ctx, str>, ) -> Self { Self { init_peer_id, particle_id, timestamp, ttl, + current_peer_id, } } } diff --git a/avm/server/CHANGELOG.md b/avm/server/CHANGELOG.md index 26efeb82..dc850388 100644 --- a/avm/server/CHANGELOG.md +++ b/avm/server/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.27.0] - 2022-11-22 + +### Changed + +- Move `current_peer_id` field/argument to the `ParticleParameters`. + It is removed from both `AVMConfig` and `AVMRunner::new`, but added to `AVMRunner::call`/`AVMRunner::call_tracing`. +- `ParticleParameters` now has only single lifetime parameter +- Update `avm-interface` version + ## [0.26.1] - 2022-09-13 ### Other diff --git a/avm/server/Cargo.toml b/avm/server/Cargo.toml index cd7ed3a0..d8213fa9 100644 --- a/avm/server/Cargo.toml +++ b/avm/server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "avm-server" description = "Fluence AIR VM" -version = "0.26.1" +version = "0.27.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" @@ -20,7 +20,7 @@ air-utils = { version = "0.1.0", path = "../../crates/air-lib/utils" } avm-data-store = { version = "0.4.1", path = "../../crates/data-store" } marine-runtime = "0.23.1" polyplets = { version = "0.3.2", path = "../../crates/air-lib/polyplets" } -avm-interface = { version = "0.26.1", path = "../../avm/interface" } +avm-interface = { version = "0.27.0", path = "../../avm/interface" } eyre = "0.6.8" thiserror = "1.0.37" diff --git a/avm/server/src/avm.rs b/avm/server/src/avm.rs index d1eb0734..28520c71 100644 --- a/avm/server/src/avm.rs +++ b/avm/server/src/avm.rs @@ -62,7 +62,6 @@ impl AVM { pub fn new(config: AVMConfig) -> AVMResult { let AVMConfig { air_wasm_path, - current_peer_id, max_heap_size, logging_mask, mut data_store, @@ -70,7 +69,7 @@ impl AVM { data_store.initialize()?; - let runner = AVMRunner::new(air_wasm_path, current_peer_id, max_heap_size, logging_mask) + let runner = AVMRunner::new(air_wasm_path, max_heap_size, logging_mask) .map_err(AVMError::RunnerError)?; let runner = SendSafeRunner(runner); let avm = Self { runner, data_store }; @@ -83,7 +82,7 @@ impl AVM { &mut self, air: impl Into, data: impl Into>, - particle_parameters: ParticleParameters<'_, '_>, + particle_parameters: ParticleParameters<'_>, call_results: CallResults, ) -> AVMResult { let air = air.into(); @@ -102,6 +101,7 @@ impl AVM { particle_parameters.init_peer_id.clone().into_owned(), particle_parameters.timestamp, particle_parameters.ttl, + particle_parameters.current_peer_id.clone(), call_results, ) .map_err(AVMError::RunnerError)?; @@ -144,7 +144,7 @@ impl AVM { &mut self, air_script: &str, current_data: &[u8], - particle_parameters: &ParticleParameters<'_, '_>, + particle_parameters: &ParticleParameters<'_>, avm_outcome: &RawAVMOutcome, execution_time: Duration, memory_delta: usize, diff --git a/avm/server/src/config.rs b/avm/server/src/config.rs index b74a03bd..eb3a305b 100644 --- a/avm/server/src/config.rs +++ b/avm/server/src/config.rs @@ -22,9 +22,6 @@ pub struct AVMConfig { /// Path to a AIR interpreter Wasm file. pub air_wasm_path: PathBuf, - /// Current peer id. - pub current_peer_id: String, - /// Maximum heap size in bytes available for the interpreter. pub max_heap_size: Option, diff --git a/avm/server/src/runner.rs b/avm/server/src/runner.rs index a86ceebf..422a928b 100644 --- a/avm/server/src/runner.rs +++ b/avm/server/src/runner.rs @@ -30,7 +30,6 @@ use std::path::PathBuf; pub struct AVMRunner { marine: Marine, - current_peer_id: String, /// file name of the AIR interpreter .wasm wasm_filename: String, } @@ -48,7 +47,6 @@ impl AVMRunner { /// Create AVM with the provided config. pub fn new( air_wasm_path: PathBuf, - current_peer_id: impl Into, max_heap_size: Option, logging_mask: i32, ) -> RunnerResult { @@ -57,11 +55,9 @@ impl AVMRunner { let marine_config = make_marine_config(wasm_dir, &wasm_filename, max_heap_size, logging_mask); let marine = Marine::with_raw_config(marine_config)?; - let current_peer_id = current_peer_id.into(); let avm = Self { marine, - current_peer_id, wasm_filename, }; @@ -78,13 +74,14 @@ impl AVMRunner { init_peer_id: impl Into, timestamp: u64, ttl: u32, + current_peer_id: impl Into, call_results: CallResults, ) -> RunnerResult { let args = prepare_args( air, prev_data, data, - self.current_peer_id.clone(), + current_peer_id.into(), init_peer_id.into(), timestamp, ttl, @@ -117,6 +114,7 @@ impl AVMRunner { init_peer_id: impl Into, timestamp: u64, ttl: u32, + current_peer_id: impl Into, call_results: CallResults, tracing_params: String, tracing_output_mode: u8, @@ -125,7 +123,7 @@ impl AVMRunner { air, prev_data, data, - self.current_peer_id.clone(), + current_peer_id.into(), init_peer_id.into(), timestamp, ttl, @@ -165,11 +163,6 @@ impl AVMRunner { max_memory_size: stats[0].max_memory_size, } } - - #[inline] - pub fn set_peer_id(&mut self, current_peer_id: impl Into) { - self.current_peer_id = current_peer_id.into(); - } } #[allow(clippy::too_many_arguments)] diff --git a/crates/air-lib/test-utils/Cargo.toml b/crates/air-lib/test-utils/Cargo.toml index 64418f06..a1ad922d 100644 --- a/crates/air-lib/test-utils/Cargo.toml +++ b/crates/air-lib/test-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "air-test-utils" -version = "0.3.0" +version = "0.4.0" description = "Test utils for the AIR interpreter" authors = ["Fluence Labs"] edition = "2018" @@ -26,5 +26,8 @@ once_cell = "1.16.0" semver = "1.0.14" serde_json = "1.0.89" +[dev-dependencies] +maplit = "1.0.2" + [features] test_with_native_code = [] diff --git a/crates/air-lib/test-utils/src/native_test_runner.rs b/crates/air-lib/test-utils/src/native_test_runner.rs index e5ef942b..e2272b0f 100644 --- a/crates/air-lib/test-utils/src/native_test_runner.rs +++ b/crates/air-lib/test-utils/src/native_test_runner.rs @@ -38,19 +38,23 @@ impl AirRunner for NativeAirRunner { init_peer_id: impl Into, timestamp: u64, ttl: u32, + override_current_peer_id: Option, call_results: avm_server::CallResults, ) -> Result> { // some inner parts transformations let raw_call_results = into_raw_result(call_results); let raw_call_results = serde_json::to_vec(&raw_call_results).unwrap(); + let current_peer_id = + override_current_peer_id.unwrap_or_else(|| self.current_peer_id.clone()); + let outcome = air::execute_air( air.into(), prev_data.into(), data.into(), RunParameters { init_peer_id: init_peer_id.into(), - current_peer_id: self.current_peer_id.clone(), + current_peer_id, timestamp, ttl, }, diff --git a/crates/air-lib/test-utils/src/test_runner.rs b/crates/air-lib/test-utils/src/test_runner.rs index e1c730be..4c1bccae 100644 --- a/crates/air-lib/test-utils/src/test_runner.rs +++ b/crates/air-lib/test-utils/src/test_runner.rs @@ -37,6 +37,7 @@ pub trait AirRunner { init_peer_id: impl Into, timestamp: u64, ttl: u32, + override_current_peer_id: Option, call_results: avm_server::CallResults, ) -> Result>; } @@ -51,6 +52,7 @@ pub struct TestRunParameters { pub init_peer_id: String, pub timestamp: u64, pub ttl: u32, + pub override_current_peer_id: Option, } impl TestRunner { @@ -69,6 +71,7 @@ impl TestRunner { init_peer_id, timestamp, ttl, + override_current_peer_id, } = test_run_params; let mut call_results = HashMap::new(); @@ -84,6 +87,7 @@ impl TestRunner { init_peer_id.clone(), timestamp, ttl, + override_current_peer_id.clone(), call_results, ) .map_err(|e| e.to_string())?; @@ -128,6 +132,7 @@ impl TestRunParameters { init_peer_id: init_peer_id.into(), timestamp, ttl, + override_current_peer_id: None, } } @@ -136,6 +141,7 @@ impl TestRunParameters { init_peer_id: init_peer_id.into(), timestamp: 0, ttl: 0, + override_current_peer_id: None, } } @@ -144,6 +150,7 @@ impl TestRunParameters { init_peer_id: String::new(), timestamp, ttl: 0, + override_current_peer_id: None, } } @@ -152,6 +159,73 @@ impl TestRunParameters { init_peer_id: String::new(), timestamp: 0, ttl, + override_current_peer_id: None, } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::call_services::{set_variables_call_service, VariableOptionSource}; + + use avm_interface::CallRequestParams; + use fstrings::f; + use fstrings::format_args_f; + use serde_json::json; + + #[test] + fn test_override_current_peer_id() { + let spell_id = "spell_id"; + let host_peer_id = "host_peer_id"; + let script = f!(r#"(call "{}" ("service" "func") [])"#, spell_id); + + let variables = maplit::hashmap! { + "func".to_owned() => json!("success"), + }; + + let mut client = create_avm( + set_variables_call_service(variables, VariableOptionSource::FunctionName), + host_peer_id, + ); + + let current_result_1 = client + .runner + .call(&script, "", "", spell_id, 0, 0, None, HashMap::new()) + .expect("call should be success"); + + let expected_current_call_requests = HashMap::new(); + let expected_current_next_peers_pks = vec![spell_id.to_owned()]; + + assert_eq!( + current_result_1.call_requests, + expected_current_call_requests + ); + assert_eq!( + current_result_1.next_peer_pks, + expected_current_next_peers_pks + ); + + let spell_result_1 = client + .runner + .call( + script, + "", + "", + spell_id, + 0, + 0, + Some(spell_id.to_owned()), + HashMap::new(), + ) + .expect("call should be success"); + + let expected_spell_call_requests = maplit::hashmap! { + 1 => CallRequestParams::new("service", "func", vec![], vec![]), + }; + let expected_spell_next_peers_pks = Vec::::new(); + + assert_eq!(spell_result_1.call_requests, expected_spell_call_requests); + assert_eq!(spell_result_1.next_peer_pks, expected_spell_next_peers_pks); + } +} diff --git a/crates/air-lib/test-utils/src/wasm_test_runner.rs b/crates/air-lib/test-utils/src/wasm_test_runner.rs index 845bd7d8..6569c05d 100644 --- a/crates/air-lib/test-utils/src/wasm_test_runner.rs +++ b/crates/air-lib/test-utils/src/wasm_test_runner.rs @@ -24,15 +24,16 @@ use std::path::PathBuf; const AVM_MAX_HEAP_SIZE: u64 = 10 * 1024 * 1024; const AIR_WASM_PATH: &str = "../target/wasm32-wasi/debug/air_interpreter_server.wasm"; -pub struct WasmAirRunner(object_pool::Reusable<'static, AVMRunner>); +pub struct WasmAirRunner { + current_peer_id: String, + runner: object_pool::Reusable<'static, AVMRunner>, +} fn make_pooled_avm_runner() -> AVMRunner { - let fake_current_peer_id = ""; let logging_mask = i32::MAX; AVMRunner::new( PathBuf::from(AIR_WASM_PATH), - fake_current_peer_id, Some(AVM_MAX_HEAP_SIZE), logging_mask, ) @@ -51,10 +52,12 @@ impl AirRunner for WasmAirRunner { ) }); - let mut runner = pool.pull(make_pooled_avm_runner); - runner.set_peer_id(current_peer_id); + let runner = pool.pull(make_pooled_avm_runner); - Self(runner) + Self { + current_peer_id: current_peer_id.into(), + runner, + } } fn call( @@ -65,15 +68,20 @@ impl AirRunner for WasmAirRunner { init_peer_id: impl Into, timestamp: u64, ttl: u32, + override_current_peer_id: Option, call_results: avm_server::CallResults, ) -> Result> { - Ok(self.0.call( + let current_peer_id = + override_current_peer_id.unwrap_or_else(|| self.current_peer_id.clone()); + + Ok(self.runner.call( air, prev_data, data, init_peer_id, timestamp, ttl, + current_peer_id, call_results, )?) } diff --git a/tools/cli/air-trace/README.md b/tools/cli/air-trace/README.md index 31dcb862..4517b0c9 100644 --- a/tools/cli/air-trace/README.md +++ b/tools/cli/air-trace/README.md @@ -10,7 +10,6 @@ Executes an AIR script with data in WASM AquaVM. It has two modes of parameter All common parameters are optional. Their position is before the mode selector (`--plain` or `--anomaly`). + `--call-results PATH` parameter allows you to provide call results for current execution. -+ `--current-peer-id STR` by default is "some_id". + `--max-heap-size N` defines maximum heap size for WASM runtime. + `--interpreter PATH` option defines the AquaVM WASM binary to be executed. By default, it is "target/wasm32-wasi/release/air_interpreter_server.wasm", but you can define a global value with the `AIR_INTERPRETER_WASM_PATH` environment variable. The default presumes that the tool is run from the root of this repository. Feel free to use option or environment variable to run from any location. + with the `--json` option, tracing info is output (to stderr) in machine-readable JSON format. The output can be later processed with `air-trace stats` subcommand. diff --git a/tools/cli/air-trace/src/run.rs b/tools/cli/air-trace/src/run.rs index d93fca77..82574b81 100644 --- a/tools/cli/air-trace/src/run.rs +++ b/tools/cli/air-trace/src/run.rs @@ -31,9 +31,6 @@ use std::path::{Path, PathBuf}; #[derive(Parser, Debug)] #[clap(about = "Run AIR script with AquaVM")] pub(crate) struct Args { - #[clap(long)] - current_peer_id: Option, - #[clap(long = "call-results")] call_results_path: Option, @@ -82,13 +79,7 @@ pub(crate) fn run(args: Args) -> anyhow::Result<()> { let global_tracing_params = args.tracing_params.clone(); init_tracing(global_tracing_params, tracing_json); - let current_peer_id = args.current_peer_id.as_deref().unwrap_or("some_id"); - let mut runner = get_runner( - args.native, - current_peer_id, - &args.air_interpreter_path, - args.max_heap_size, - )?; + let mut runner = get_runner(args.native, &args.air_interpreter_path, args.max_heap_size)?; let execution_data = match &args.source { Source::Anomaly(anomaly) => data::anomaly::load(anomaly)?, @@ -108,6 +99,7 @@ pub(crate) fn run(args: Args) -> anyhow::Result<()> { particle.init_peer_id.clone().into_owned(), particle.timestamp, particle.ttl, + particle.current_peer_id.clone().into(), call_results.clone(), args.tracing_params.clone(), tracing_json, @@ -124,20 +116,14 @@ pub(crate) fn run(args: Args) -> anyhow::Result<()> { #[cfg(feature = "wasm")] fn get_runner( native: bool, - current_peer_id: impl Into, air_interpreter_wasm_path: &Path, max_heap_size: Option, ) -> anyhow::Result> { if native { - self::native::create_native_avm_runner(current_peer_id) - .context("Failed to instantiate a native AVM") + self::native::create_native_avm_runner().context("Failed to instantiate a native AVM") } else { - self::wasm::create_wasm_avm_runner( - current_peer_id, - air_interpreter_wasm_path, - max_heap_size, - ) - .context("Failed to instantiate WASM AVM") + self::wasm::create_wasm_avm_runner(air_interpreter_wasm_path, max_heap_size) + .context("Failed to instantiate WASM AVM") } } diff --git a/tools/cli/air-trace/src/run/data/anomaly.rs b/tools/cli/air-trace/src/run/data/anomaly.rs index d55724d3..54e538ec 100644 --- a/tools/cli/air-trace/src/run/data/anomaly.rs +++ b/tools/cli/air-trace/src/run/data/anomaly.rs @@ -39,7 +39,7 @@ pub(crate) fn load(args: &AnomalyDataArgs) -> anyhow::Result = + let particle: ParticleParameters<'static> = serde_json::from_reader(&*anomaly_data.particle.to_vec()) .context("Anomaly particle is not a valid JSON")?; diff --git a/tools/cli/air-trace/src/run/data/mod.rs b/tools/cli/air-trace/src/run/data/mod.rs index 34e20094..77de2cb4 100644 --- a/tools/cli/air-trace/src/run/data/mod.rs +++ b/tools/cli/air-trace/src/run/data/mod.rs @@ -23,5 +23,5 @@ pub(crate) struct ExecutionData<'ctx> { pub(crate) air_script: String, pub(crate) current_data: String, pub(crate) prev_data: String, - pub(crate) particle: ParticleParameters<'ctx, 'ctx>, + pub(crate) particle: ParticleParameters<'ctx>, } diff --git a/tools/cli/air-trace/src/run/data/plain.rs b/tools/cli/air-trace/src/run/data/plain.rs index 56f053af..b4a2d641 100644 --- a/tools/cli/air-trace/src/run/data/plain.rs +++ b/tools/cli/air-trace/src/run/data/plain.rs @@ -26,12 +26,14 @@ const DEFAULT_DATA: &str = ""; #[derive(clap::Args, Debug)] pub(crate) struct PlainDataArgs { - #[clap(long)] - init_peer_id: Option, + #[clap(long, default_value = "some_id")] + init_peer_id: String, #[clap(long, help = "default: current time")] timestamp: Option, #[clap(long, help = "default: max possible ttl")] ttl: Option, + #[clap(long, default_value = "some_id")] + current_peer_id: String, #[clap(long = "script", help = "read from stdin by default")] air_script_path: Option, @@ -54,9 +56,17 @@ pub(crate) fn load(args: &PlainDataArgs) -> anyhow::Result> { let timestamp = args.timestamp.unwrap_or_else(unix_timestamp_now); let ttl = args.ttl.unwrap_or(u32::MAX); - let init_peer_id = args.init_peer_id.as_deref().unwrap_or("some_id"); + let init_peer_id = &args.init_peer_id; + let current_peer_id = &args.current_peer_id; + + let particle = ParticleParameters::new( + init_peer_id.into(), + "".into(), + timestamp, + ttl, + current_peer_id.into(), + ); - let particle = ParticleParameters::new(init_peer_id.into(), "".into(), timestamp, ttl); Ok(ExecutionData { air_script, prev_data, diff --git a/tools/cli/air-trace/src/run/native.rs b/tools/cli/air-trace/src/run/native.rs index 6b72e85f..706a5da7 100644 --- a/tools/cli/air-trace/src/run/native.rs +++ b/tools/cli/air-trace/src/run/native.rs @@ -18,9 +18,7 @@ use super::runner::AirRunner; use air_interpreter_interface::RunParameters; use avm_interface::raw_outcome::RawAVMOutcome; -struct NativeAvmRunner { - current_peer_id: String, -} +struct NativeAvmRunner {} impl AirRunner for NativeAvmRunner { fn call_tracing( @@ -31,6 +29,7 @@ impl AirRunner for NativeAvmRunner { init_peer_id: String, timestamp: u64, ttl: u32, + current_peer_id: String, call_results: avm_interface::CallResults, // We use externally configured logger. _tracing_params: String, @@ -48,7 +47,7 @@ impl AirRunner for NativeAvmRunner { data, RunParameters { init_peer_id, - current_peer_id: self.current_peer_id.clone(), + current_peer_id, timestamp, ttl, }, @@ -60,10 +59,6 @@ impl AirRunner for NativeAvmRunner { } } -pub(crate) fn create_native_avm_runner( - current_peer_id: impl Into, -) -> anyhow::Result> { - Ok(Box::new(NativeAvmRunner { - current_peer_id: current_peer_id.into(), - })) +pub(crate) fn create_native_avm_runner() -> anyhow::Result> { + Ok(Box::new(NativeAvmRunner {})) } diff --git a/tools/cli/air-trace/src/run/runner.rs b/tools/cli/air-trace/src/run/runner.rs index 04e7ab66..ae3fb4b0 100644 --- a/tools/cli/air-trace/src/run/runner.rs +++ b/tools/cli/air-trace/src/run/runner.rs @@ -27,6 +27,7 @@ pub(crate) trait AirRunner { init_peer_id: String, timestamp: u64, ttl: u32, + current_peer_id: String, call_results: CallResults, tracing_params: String, tracing_output_mode: u8, diff --git a/tools/cli/air-trace/src/run/wasm.rs b/tools/cli/air-trace/src/run/wasm.rs index 46d4148b..9af71268 100644 --- a/tools/cli/air-trace/src/run/wasm.rs +++ b/tools/cli/air-trace/src/run/wasm.rs @@ -28,6 +28,7 @@ impl AirRunner for WasmAvmRunner { init_peer_id: String, timestamp: u64, ttl: u32, + current_peer_id: String, call_results: avm_interface::CallResults, tracing_params: String, tracing_output_mode: u8, @@ -39,6 +40,7 @@ impl AirRunner for WasmAvmRunner { init_peer_id, timestamp, ttl, + current_peer_id, call_results, tracing_params, tracing_output_mode, @@ -47,15 +49,11 @@ impl AirRunner for WasmAvmRunner { } pub(crate) fn create_wasm_avm_runner( - current_peer_id: impl Into, air_interpreter_wasm_path: &Path, max_heap_size: Option, ) -> anyhow::Result> { - let current_peer_id = current_peer_id.into(); - Ok(Box::new(WasmAvmRunner(AVMRunner::new( air_interpreter_wasm_path.to_owned(), - current_peer_id, max_heap_size, 0, )?)))