Refactor avm-server interface mod to new crate (#294)

* Refactor `avm-server` interface mod to new crate (#294)

The new crate name is `avm-interface`.

It allows to build fully native air-trace, including pure WASM build.

* Make fully native air-trace build

Unless `wasm` feature is enabled (default), fully native build is
produced.  You may build WASM air-trace binary with

`cargo build --target wasm32-wasi --no-default-features --release -p air-trace`

* Fix tracing output on native air-trace build

Wrong option was used.
This commit is contained in:
Ivan Boldyrev 2022-08-19 12:29:21 +03:00 committed by GitHub
parent dcab0023d8
commit 5c7e88e0f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 221 additions and 131 deletions

32
Cargo.lock generated
View File

@ -13,7 +13,7 @@ dependencies = [
[[package]]
name = "air"
version = "0.25.0"
version = "0.26.0"
dependencies = [
"air-execution-info-collector",
"air-interpreter-data",
@ -72,9 +72,10 @@ version = "0.1.0"
[[package]]
name = "air-interpreter"
version = "0.25.0"
version = "0.26.0"
dependencies = [
"air",
"air-interpreter-interface",
"air-log-targets",
"log",
"marine-rs-sdk",
@ -165,6 +166,7 @@ version = "0.3.0"
dependencies = [
"air",
"air-interpreter-interface",
"avm-interface",
"avm-server",
"fstrings",
"marine-rs-sdk",
@ -175,13 +177,14 @@ dependencies = [
[[package]]
name = "air-trace"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"air",
"air-interpreter-interface",
"air-test-utils",
"anyhow",
"avm-server",
"avm-data-store",
"avm-interface",
"clap 3.2.16",
"itertools 0.10.3",
"serde",
@ -269,12 +272,29 @@ dependencies = [
]
[[package]]
name = "avm-server"
version = "0.24.0"
name = "avm-interface"
version = "0.25.0"
dependencies = [
"air-interpreter-interface",
"air-utils",
"avm-data-store",
"log",
"maplit",
"polyplets",
"serde",
"serde_json",
"thiserror",
"tracing",
]
[[package]]
name = "avm-server"
version = "0.25.0"
dependencies = [
"air-interpreter-interface",
"air-utils",
"avm-data-store",
"avm-interface",
"eyre",
"log",
"maplit",

View File

@ -2,6 +2,7 @@
members = [
"air",
"air-interpreter",
"avm/interface",
"avm/server",
"crates/air-lib/air-parser",
"crates/air-lib/execution-info-collector",

View File

@ -1,6 +1,6 @@
[package]
name = "air-interpreter"
version = "0.25.0"
version = "0.26.0"
description = "Crate-wrapper for air"
authors = ["Fluence Labs"]
edition = "2018"
@ -19,6 +19,7 @@ path = "src/marine.rs"
[dependencies]
air = { path = "../air" }
air-interpreter-interface = { path = "../crates/air-lib/interpreter-interface" }
air-log-targets = { path = "../crates/air-lib/log-targets" }
marine-rs-sdk = { version = "0.7.0", features = ["logger"] }

View File

@ -1,6 +1,6 @@
[package]
name = "air"
version = "0.25.0"
version = "0.26.0"
description = "Interpreter of AIR scripts intended to coordinate request flow in the Fluence network"
authors = ["Fluence Labs"]
edition = "2018"
@ -18,14 +18,13 @@ doctest = false
air-parser = { path = "../crates/air-lib/air-parser" }
air-execution-info-collector = { path = "../crates/air-lib/execution-info-collector" }
air-interpreter-data = { path = "../crates/air-lib/interpreter-data" }
air-interpreter-interface = { path = "../crates/air-lib/interpreter-interface" }
air-interpreter-interface = { path = "../crates/air-lib/interpreter-interface", default-features = false }
air-log-targets = { path = "../crates/air-lib/log-targets" }
air-lambda-ast = { path = "../crates/air-lib/lambda/ast" }
air-lambda-parser = { path = "../crates/air-lib/lambda/parser" }
air-trace-handler = { path = "../crates/air-lib/trace-handler" }
air-utils = { version = "0.1.0", path = "../crates/air-lib/utils" }
polyplets = { path = "../crates/air-lib/polyplets" }
marine-rs-sdk = { version = "0.7.0", features = ["logger"] }
serde = { version = "1.0.118", features = [ "derive", "rc" ] }
serde_json = "1.0.61"
@ -47,6 +46,7 @@ wasm-bindgen = "=0.2.65"
[dev_dependencies]
air-test-utils = { path = "../crates/air-lib/test-utils" }
fluence-app-service = "0.18.0"
marine-rs-sdk = { version = "0.7.0", features = ["logger"] }
# the feature just silence a warning in the criterion 0.3.x.
criterion = { version = "0.3.3", features = ["html_reports"] }

29
avm/interface/Cargo.toml Normal file
View File

@ -0,0 +1,29 @@
[package]
name = "avm-interface"
description = "Fluence AIR VM interfacing"
version = "0.25.0"
authors = ["Fluence Labs"]
edition = "2018"
license = "Apache-2.0"
documentation = "https://docs.rs/avm-interface"
repository = "https://github.com/fluencelabs/aquavm/tree/master/avm/interface"
publish = true # this crate is used by the node
keywords = ["fluence", "air", "webassembly", "programming-language"]
categories = ["wasm"]
[lib]
name = "avm_interface"
path = "src/lib.rs"
[dependencies]
air-interpreter-interface = { version = "0.11.0", path = "../../crates/air-lib/interpreter-interface", default-features = false }
air-utils = { version = "0.1.0", path = "../../crates/air-lib/utils" }
avm-data-store = { version = "0.4.0", path = "../../crates/data-store" }
polyplets = { version = "0.3.0", path = "../../crates/air-lib/polyplets" }
thiserror = "1.0.29"
maplit = "1.0.2"
serde_json = "1.0.61"
serde = "1.0.118"
log = "0.4.14"
tracing = "0.1.35"

View File

@ -15,10 +15,9 @@
*/
use super::JValue;
use crate::errors::CallSeDeErrors;
use crate::RunnerResult;
use crate::SecurityTetraplet;
use crate::CallSeDeErrors;
use polyplets::SecurityTetraplet;
use serde::Deserialize;
use serde::Serialize;
@ -60,7 +59,7 @@ impl CallRequestParams {
pub(crate) fn from_raw(
call_params: air_interpreter_interface::CallRequestParams,
) -> RunnerResult<Self> {
) -> Result<Self, CallSeDeErrors> {
let arguments: Vec<JValue> =
serde_json::from_str(&call_params.arguments).map_err(|de_error| {
CallSeDeErrors::CallParamsArgsDeFailed {
@ -86,7 +85,9 @@ impl CallRequestParams {
}
}
pub(crate) fn from_raw_call_requests(raw_call_params: Vec<u8>) -> RunnerResult<CallRequests> {
pub(crate) fn from_raw_call_requests(
raw_call_params: Vec<u8>,
) -> Result<CallRequests, CallSeDeErrors> {
let call_requests: air_interpreter_interface::CallRequests =
match serde_json::from_slice(&raw_call_params) {
Ok(requests) => requests,
@ -101,7 +102,7 @@ pub(crate) fn from_raw_call_requests(raw_call_params: Vec<u8>) -> RunnerResult<C
call_requests
.into_iter()
.map(|(call_id, call_params)| -> RunnerResult<_> {
.map(|(call_id, call_params)| -> Result<_, _> {
let call_params = CallRequestParams::from_raw(call_params)?;
Ok((call_id, call_params))
})

66
avm/interface/src/lib.rs Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright 2021 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mod call_request_parameters;
mod call_service_result;
mod outcome;
mod particle_parameters;
pub mod raw_outcome;
use serde_json::Error as SerdeError;
use thiserror::Error as ThisError;
#[derive(Debug, ThisError)]
#[allow(clippy::enum_variant_names)]
pub enum CallSeDeErrors {
/// Errors encountered while trying to serialize call results.
#[error("error occurred while call results `{call_results:?}` deserialization: {se_error}")]
CallResultsSeFailed {
call_results: air_interpreter_interface::CallResults,
se_error: SerdeError,
},
/// This error is encountered when deserialization pof call requests failed for some reason.
#[error("'{raw_call_request:?}' can't been serialized with error '{error}'")]
CallRequestsDeError {
raw_call_request: Vec<u8>,
error: SerdeError,
},
/// Errors encountered while trying to deserialize arguments from call parameters returned
/// by the interpreter. In the corresponding struct such arguments are Vec<JValue> serialized
/// to a string.
#[error("error occurred while deserialization of arguments from call params `{call_params:?}`: {de_error}")]
CallParamsArgsDeFailed {
call_params: air_interpreter_interface::CallRequestParams,
de_error: SerdeError,
},
/// Errors encountered while trying to deserialize tetraplets from call parameters returned
/// by the interpreter. In the corresponding struct such tetraplets are
/// Vec<Vec<SecurityTetraplet>> serialized to a string.
#[error("error occurred while deserialization of tetraplets from call params `{call_params:?}`: {de_error}")]
CallParamsTetrapletsDeFailed {
call_params: air_interpreter_interface::CallRequestParams,
de_error: SerdeError,
},
}
type JValue = serde_json::Value;
pub use call_request_parameters::*;
pub use call_service_result::*;
pub use outcome::*;
pub use particle_parameters::*;

View File

@ -15,9 +15,7 @@
*/
use super::CallRequests;
use crate::avm_runner::RawAVMOutcome;
use crate::AVMError;
use crate::AVMResult;
use crate::raw_outcome::RawAVMOutcome;
use serde::Deserialize;
use serde::Serialize;
@ -68,11 +66,11 @@ impl AVMOutcome {
}
}
pub(crate) fn from_raw_outcome<E>(
pub fn from_raw_outcome(
raw_outcome: RawAVMOutcome,
memory_delta: usize,
execution_time: Duration,
) -> AVMResult<Self, E> {
) -> Result<Self, ErrorAVMOutcome> {
use air_interpreter_interface::INTERPRETER_SUCCESS;
let RawAVMOutcome {
@ -92,11 +90,10 @@ impl AVMOutcome {
);
if ret_code == INTERPRETER_SUCCESS {
return Ok(avm_outcome);
Ok(avm_outcome)
} else {
Err(ErrorAVMOutcome::new(ret_code, error_message, avm_outcome))
}
let error_outcome = ErrorAVMOutcome::new(ret_code, error_message, avm_outcome);
Err(AVMError::InterpreterFailed(error_outcome))
}
}

View File

@ -14,8 +14,9 @@
* limitations under the License.
*/
use crate::CallSeDeErrors;
use super::CallRequests;
use crate::RunnerResult;
use air_interpreter_interface::InterpreterOutcome;
@ -33,7 +34,7 @@ pub struct RawAVMOutcome {
}
impl RawAVMOutcome {
pub fn from_interpreter_outcome(outcome: InterpreterOutcome) -> RunnerResult<Self> {
pub fn from_interpreter_outcome(outcome: InterpreterOutcome) -> Result<Self, CallSeDeErrors> {
let InterpreterOutcome {
ret_code,
error_message,
@ -42,7 +43,7 @@ impl RawAVMOutcome {
next_peer_pks,
} = outcome;
let call_requests = crate::interface::from_raw_call_requests(call_requests)?;
let call_requests = crate::from_raw_call_requests(call_requests)?;
let raw_avm_outcome = Self {
ret_code,

View File

@ -1,7 +1,7 @@
[package]
name = "avm-server"
description = "Fluence AIR VM"
version = "0.24.0"
version = "0.25.0"
authors = ["Fluence Labs"]
edition = "2018"
license = "Apache-2.0"
@ -21,6 +21,7 @@ air-utils = { version = "0.1.0", path = "../../crates/air-lib/utils" }
avm-data-store = { version = "0.4.0", path = "../../crates/data-store" }
marine-runtime = "0.18.0"
polyplets = { version = "0.3.0", path = "../../crates/air-lib/polyplets" }
avm-interface = { version = "0.25.0", path = "../../avm/interface" }
eyre = "0.6.5"
thiserror = "1.0.29"

View File

@ -18,14 +18,15 @@ use super::avm_runner::AVMRunner;
use super::AVMDataStore;
use super::AVMError;
use super::AVMMemoryStats;
use super::AVMOutcome;
use super::CallResults;
use crate::config::AVMConfig;
use crate::interface::raw_outcome::RawAVMOutcome;
use crate::interface::ParticleParameters;
use crate::AVMResult;
use avm_data_store::AnomalyData;
use avm_interface::raw_outcome::RawAVMOutcome;
use avm_interface::AVMOutcome;
use avm_interface::CallResults;
use avm_interface::ParticleParameters;
use std::ops::Deref;
use std::ops::DerefMut;
use std::time::Duration;
@ -118,7 +119,8 @@ impl<E> AVM<E> {
// persist resulted data
self.data_store.store_data(&outcome.data, particle_id)?;
let outcome = AVMOutcome::from_raw_outcome(outcome, memory_delta, execution_time)?;
let outcome = AVMOutcome::from_raw_outcome(outcome, memory_delta, execution_time)
.map_err(AVMError::InterpreterFailed)?;
Ok(outcome)
}

View File

@ -14,7 +14,8 @@
* limitations under the License.
*/
use crate::interface::ErrorAVMOutcome;
pub use avm_interface::CallSeDeErrors;
use avm_interface::ErrorAVMOutcome;
use marine::IValue;
use marine::MarineError;
@ -72,39 +73,3 @@ pub enum RunnerError {
#[error(transparent)]
CallSeDeErrors(#[from] CallSeDeErrors),
}
#[derive(Debug, ThisError)]
#[allow(clippy::enum_variant_names)]
pub enum CallSeDeErrors {
/// Errors encountered while trying to serialize call results.
#[error("error occurred while call results `{call_results:?}` deserialization: {se_error}")]
CallResultsSeFailed {
call_results: air_interpreter_interface::CallResults,
se_error: SerdeError,
},
/// This error is encountered when deserialization pof call requests failed for some reason.
#[error("'{raw_call_request:?}' can't been serialized with error '{error}'")]
CallRequestsDeError {
raw_call_request: Vec<u8>,
error: SerdeError,
},
/// Errors encountered while trying to deserialize arguments from call parameters returned
/// by the interpreter. In the corresponding struct such arguments are Vec<JValue> serialized
/// to a string.
#[error("error occurred while deserialization of arguments from call params `{call_params:?}`: {de_error}")]
CallParamsArgsDeFailed {
call_params: air_interpreter_interface::CallRequestParams,
de_error: SerdeError,
},
/// Errors encountered while trying to deserialize tetraplets from call parameters returned
/// by the interpreter. In the corresponding struct such tetraplets are
/// Vec<Vec<SecurityTetraplet>> serialized to a string.
#[error("error occurred while deserialization of tetraplets from call params `{call_params:?}`: {de_error}")]
CallParamsTetrapletsDeFailed {
call_params: air_interpreter_interface::CallRequestParams,
de_error: SerdeError,
},
}

View File

@ -1,28 +0,0 @@
/*
* Copyright 2021 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
mod call_request_parameters;
mod call_service_result;
mod outcome;
mod particle_parameters;
pub mod raw_outcome;
type JValue = serde_json::Value;
pub use call_request_parameters::*;
pub use call_service_result::*;
pub use outcome::*;
pub use particle_parameters::*;

View File

@ -27,18 +27,18 @@
mod avm;
mod config;
mod errors;
mod interface;
mod runner;
pub use avm::AVM;
pub use config::AVMConfig;
pub use errors::AVMError;
pub use interface::*;
pub use runner::AVMMemoryStats;
pub use avm_interface::*;
pub mod avm_runner {
pub use crate::interface::raw_outcome::RawAVMOutcome;
pub use crate::runner::AVMRunner;
pub use avm_interface::raw_outcome::RawAVMOutcome;
}
// Re-exports

View File

@ -14,13 +14,13 @@
* limitations under the License.
*/
use super::CallResults;
use crate::raw_outcome::RawAVMOutcome;
use crate::RunnerError;
use crate::RunnerResult;
use air_interpreter_interface::InterpreterOutcome;
use air_utils::measure;
use avm_interface::raw_outcome::RawAVMOutcome;
use avm_interface::CallResults;
use marine::IValue;
use marine::Marine;
use marine::MarineConfig;
@ -192,7 +192,7 @@ fn prepare_args(
)
.into_ivalue();
let call_results = crate::interface::into_raw_result(call_results);
let call_results = avm_interface::into_raw_result(call_results);
let call_results = measure!(
serde_json::to_vec(&call_results).expect("the default serializer shouldn't fail"),
tracing::Level::INFO,

View File

@ -16,8 +16,12 @@ name = "air_interpreter_interface"
path = "src/lib.rs"
[dependencies]
marine-rs-sdk = "0.7.0"
fluence-it-types = "0.3.0"
marine-rs-sdk = { version = "0.7.0", optional = true }
fluence-it-types = { version = "0.3.0", optional = true }
serde = "1.0.118"
serde_json = "1.0.56"
[features]
default = ["marine"]
marine = ["marine-rs-sdk", "fluence-it-types"]

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#[cfg(feature = "marine")]
use marine_rs_sdk::marine;
use serde::Deserialize;
use serde::Serialize;
@ -23,7 +24,7 @@ pub type CallRequests = HashMap<u32, CallRequestParams>;
/// Contains arguments of a call instruction and all other necessary information
/// required for calling a service.
#[marine]
#[cfg_attr(feature = "marine", marine)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CallRequestParams {
/// Id of a service that should be called.

View File

@ -14,8 +14,10 @@
* limitations under the License.
*/
#[cfg(feature = "marine")]
use marine_rs_sdk::marine;
#[cfg(feature = "marine")]
use fluence_it_types::IValue;
use serde::Deserialize;
use serde::Serialize;
@ -23,7 +25,7 @@ use serde::Serialize;
pub const INTERPRETER_SUCCESS: i64 = 0;
/// Describes a result returned at the end of the interpreter execution_step.
#[marine]
#[cfg_attr(feature = "marine", marine)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct InterpreterOutcome {
/// A return code, where INTERPRETER_SUCCESS means success.
@ -43,6 +45,7 @@ pub struct InterpreterOutcome {
pub call_requests: Vec<u8>,
}
#[cfg(feature = "marine")]
impl InterpreterOutcome {
pub fn from_ivalue(ivalue: IValue) -> Result<Self, String> {
const OUTCOME_FIELDS_COUNT: usize = 5;
@ -73,8 +76,10 @@ impl InterpreterOutcome {
}
}
#[cfg(feature = "marine")]
use fluence_it_types::ne_vec::NEVec;
#[cfg(feature = "marine")]
fn try_as_record(ivalue: IValue) -> Result<NEVec<IValue>, String> {
match ivalue {
IValue::Record(record_values) => Ok(record_values),
@ -85,6 +90,7 @@ fn try_as_record(ivalue: IValue) -> Result<NEVec<IValue>, String> {
}
}
#[cfg(feature = "marine")]
fn try_as_i64(ivalue: IValue, field_name: &str) -> Result<i64, String> {
match ivalue {
IValue::S64(value) => Ok(value),
@ -92,6 +98,7 @@ fn try_as_i64(ivalue: IValue, field_name: &str) -> Result<i64, String> {
}
}
#[cfg(feature = "marine")]
fn try_as_string(ivalue: IValue, field_name: &str) -> Result<String, String> {
match ivalue {
IValue::String(value) => Ok(value),
@ -99,6 +106,7 @@ fn try_as_string(ivalue: IValue, field_name: &str) -> Result<String, String> {
}
}
#[cfg(feature = "marine")]
fn try_as_byte_vec(ivalue: IValue, field_name: &str) -> Result<Vec<u8>, String> {
let byte_vec = match ivalue {
IValue::Array(array) => {
@ -123,6 +131,7 @@ fn try_as_byte_vec(ivalue: IValue, field_name: &str) -> Result<Vec<u8>, String>
Ok(byte_vec)
}
#[cfg(feature = "marine")]
fn try_as_string_vec(ivalue: IValue, field_name: &str) -> Result<Vec<String>, String> {
match ivalue {
IValue::Array(ar_values) => {

View File

@ -14,14 +14,17 @@
* limitations under the License.
*/
#[cfg(feature = "marine")]
use fluence_it_types::ne_vec::NEVec;
#[cfg(feature = "marine")]
use fluence_it_types::IValue;
#[cfg(feature = "marine")]
use marine_rs_sdk::marine;
use serde::Deserialize;
use serde::Serialize;
/// Parameters that a host side should pass to an interpreter and that necessary for execution.
#[marine]
#[cfg_attr(feature = "marine", marine)]
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct RunParameters {
/// Peer id of a peer that start this particle.
@ -48,6 +51,7 @@ impl RunParameters {
}
}
#[cfg(feature = "marine")]
pub fn into_ivalue(self) -> IValue {
let run_parameters = vec![
IValue::String(self.init_peer_id),

View File

@ -16,6 +16,7 @@ path = "src/lib.rs"
[dependencies]
air = { path = "../../../air" }
air-interpreter-interface = { path = "../interpreter-interface" }
avm-interface = { path = "../../../avm/interface" }
avm-server = { path = "../../../avm/server" }
marine-rs-sdk = "0.7.0"

View File

@ -35,7 +35,7 @@ mod native_test_runner;
mod wasm_test_runner;
pub use air::interpreter_data::*;
pub use avm_server::raw_outcome::*;
pub use avm_interface::raw_outcome::*;
pub use avm_server::*;
pub mod prelude {

View File

@ -1,6 +1,6 @@
[package]
name = "air-trace"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
description = "AIR performance tracing tool"
authors = ["Fluence Labs"]
@ -10,9 +10,10 @@ keywords = ["fluence", "air", "tracing"]
[dependencies]
air = { path = "../../../air" }
air-test-utils = { path = "../../../crates/air-lib/test-utils" }
air-interpreter-interface = { path = "../../../crates/air-lib/interpreter-interface" }
avm-server = { path = "../../../avm/server" }
air-test-utils = { path = "../../../crates/air-lib/test-utils", optional = true }
air-interpreter-interface = { path = "../../../crates/air-lib/interpreter-interface", default-features = false }
avm-data-store = { path = "../../../crates/data-store" }
avm-interface = { path = "../../../avm/interface" }
anyhow = "1.0.56"
clap = { version = "3.1.18", features = ["derive", "env"] }
@ -23,4 +24,4 @@ tracing-subscriber = { version = "0.3.11", default-features = false, features =
[features]
default = ["wasm"]
wasm = []
wasm = ["air-test-utils"]

View File

@ -47,7 +47,6 @@ Please, note that currently tracing outputs to stdout, and execution result is a
## Known limitations
1. At detailed tracing levels (debug etc), trace formatting time is comparable to traced code execution time and can give incorrect results.
2. Native builds of the utility still depend on Marine, and cannot be built for architectures unsupported by Marine, like Apple Silicon or WASM. It is yet to be resolved with some refactoring.
## Installation
@ -68,3 +67,14 @@ You need to have Rust toolchain and its `cargo` utility installed. Run this com
``` sh
cargo install --path tools/cli/air-trace
```
## `air-trace` native build
You can have fully native or WASM `air-trace` build with the following commands:
``` sh
cargo build --no-default-features --release -p air-trace
cargo build --no-default-features --release -p air-trace --target wasm32-wasi
```
This build doesn't need the AIR interpreter server binary.

View File

@ -21,7 +21,7 @@ mod runner;
mod wasm;
use self::runner::AirRunner;
use air_test_utils::CallResults;
use avm_interface::CallResults;
use anyhow::Context as _;
use clap::{Parser, Subcommand};
@ -71,12 +71,15 @@ enum Source {
pub(crate) fn run(args: Args) -> anyhow::Result<()> {
let tracing_json = (!args.json) as u8;
#[cfg(feature = "wasm")]
let global_tracing_params = if args.native {
// for native, there is single tracing configuration, and no runner
args.tracing_params.clone()
} else {
args.runner_tracing_params
};
#[cfg(not(feature = "wasm"))]
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");

View File

@ -16,8 +16,8 @@
use super::ExecutionData;
use crate::run::load_data;
use air_test_utils::ParticleParameters;
use avm_server::AnomalyData;
use avm_data_store::AnomalyData;
use avm_interface::ParticleParameters;
use anyhow::Context;
use clap::Parser;

View File

@ -17,7 +17,7 @@
pub(crate) mod anomaly;
pub(crate) mod plain;
use avm_server::ParticleParameters;
use avm_interface::ParticleParameters;
pub(crate) struct ExecutionData<'ctx> {
pub(crate) air_script: String,

View File

@ -16,7 +16,7 @@
use super::ExecutionData;
use crate::utils::unix_timestamp_now;
use air_test_utils::ParticleParameters;
use avm_interface::ParticleParameters;
use anyhow::Context;

View File

@ -16,6 +16,7 @@
use super::runner::AirRunner;
use air_interpreter_interface::RunParameters;
use avm_interface::raw_outcome::RawAVMOutcome;
struct NativeAvmRunner {
current_peer_id: String,
@ -30,12 +31,12 @@ impl AirRunner for NativeAvmRunner {
init_peer_id: String,
timestamp: u64,
ttl: u32,
call_results: air_test_utils::CallResults,
call_results: avm_interface::CallResults,
// We use externally configured logger.
_tracing_params: String,
_tracing_output_mode: u8,
) -> anyhow::Result<air_test_utils::RawAVMOutcome> {
use air_test_utils::into_raw_result;
) -> anyhow::Result<RawAVMOutcome> {
use avm_interface::into_raw_result;
// some inner parts transformations
let raw_call_results = into_raw_result(call_results);
@ -53,7 +54,7 @@ impl AirRunner for NativeAvmRunner {
},
raw_call_results,
);
let outcome = air_test_utils::RawAVMOutcome::from_interpreter_outcome(outcome)?;
let outcome = RawAVMOutcome::from_interpreter_outcome(outcome)?;
Ok(outcome)
}

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
use avm_server::avm_runner::*;
use avm_server::CallResults;
use avm_interface::raw_outcome::RawAVMOutcome;
use avm_interface::CallResults;
pub(crate) trait AirRunner {
#[allow(clippy::too_many_arguments)]

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
use super::runner::AirRunner;
use avm_server::avm_runner::AVMRunner;
use air_test_utils::avm_runner::AVMRunner;
use std::path::Path;
pub(crate) struct WasmAvmRunner(AVMRunner);
@ -28,10 +28,10 @@ impl AirRunner for WasmAvmRunner {
init_peer_id: String,
timestamp: u64,
ttl: u32,
call_results: avm_server::CallResults,
call_results: avm_interface::CallResults,
tracing_params: String,
tracing_output_mode: u8,
) -> anyhow::Result<air_test_utils::RawAVMOutcome> {
) -> anyhow::Result<avm_interface::raw_outcome::RawAVMOutcome> {
Ok(self.0.call_tracing(
air,
prev_data,