mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
Add AIR script to the AquaVM's anomaly data (#280)
Save AIR script to AnomlalyData struct. Increments versions of `avm-data-store` to 0.3.0 and `avm-server` to 0.22.0.
This commit is contained in:
parent
cc4fba4455
commit
4acfb19e08
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -233,14 +233,14 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "avm-data-store"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "avm-server"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
dependencies = [
|
||||
"air-interpreter-interface",
|
||||
"avm-data-store",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "avm-server"
|
||||
description = "Fluence AIR VM"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
air-interpreter-interface = { version = "0.10.0", path = "../../crates/air-lib/interpreter-interface" }
|
||||
avm-data-store = { version = "0.2.0", path = "../../crates/data-store" }
|
||||
avm-data-store = { version = "0.3.0", path = "../../crates/data-store" }
|
||||
fluence-faas = "0.16.2"
|
||||
polyplets = { version = "0.2.0", path = "../../crates/air-lib/polyplets" }
|
||||
|
||||
|
@ -83,6 +83,7 @@ impl<E> AVM<E> {
|
||||
particle_parameters: ParticleParameters<'_, '_>,
|
||||
call_results: CallResults,
|
||||
) -> AVMResult<AVMOutcome, E> {
|
||||
let air = air.into();
|
||||
let particle_id = particle_parameters.particle_id.as_str();
|
||||
let prev_data = self.data_store.read_data(particle_id)?;
|
||||
let current_data = data.into();
|
||||
@ -92,7 +93,7 @@ impl<E> AVM<E> {
|
||||
let outcome = self
|
||||
.runner
|
||||
.call(
|
||||
air,
|
||||
air.clone(),
|
||||
prev_data,
|
||||
current_data.clone(),
|
||||
particle_parameters.init_peer_id.clone().into_owned(),
|
||||
@ -106,6 +107,7 @@ impl<E> AVM<E> {
|
||||
let memory_delta = self.memory_stats().memory_size - memory_size_before;
|
||||
if self.data_store.detect_anomaly(execution_time, memory_delta) {
|
||||
self.save_anomaly_data(
|
||||
&air,
|
||||
¤t_data,
|
||||
&particle_parameters,
|
||||
&outcome,
|
||||
@ -134,6 +136,7 @@ impl<E> AVM<E> {
|
||||
|
||||
fn save_anomaly_data(
|
||||
&mut self,
|
||||
air_script: &str,
|
||||
current_data: &[u8],
|
||||
particle_parameters: &ParticleParameters<'_, '_>,
|
||||
avm_outcome: &RawAVMOutcome,
|
||||
@ -149,9 +152,10 @@ impl<E> AVM<E> {
|
||||
serde_json::to_vec(avm_outcome).map_err(AVMError::AnomalyDataSeError)?;
|
||||
|
||||
let anomaly_data = AnomalyData::new(
|
||||
air_script,
|
||||
&ser_particle,
|
||||
&prev_data,
|
||||
¤t_data,
|
||||
current_data,
|
||||
&ser_avm_outcome,
|
||||
execution_time,
|
||||
memory_delta,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "avm-data-store"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "Definition of the AVM DataStore trait"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
|
@ -49,6 +49,7 @@ pub trait DataStore {
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct AnomalyData<'data> {
|
||||
pub air_script: &'data str,
|
||||
pub particle: &'data [u8], // it's byte because of the restriction on trait objects methods
|
||||
pub prev_data: &'data [u8],
|
||||
pub current_data: &'data [u8],
|
||||
@ -59,6 +60,7 @@ pub struct AnomalyData<'data> {
|
||||
|
||||
impl<'data> AnomalyData<'data> {
|
||||
pub fn new(
|
||||
air_script: &'data str,
|
||||
particle: &'data [u8],
|
||||
prev_data: &'data [u8],
|
||||
current_data: &'data [u8],
|
||||
@ -67,6 +69,7 @@ impl<'data> AnomalyData<'data> {
|
||||
memory_delta: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
air_script,
|
||||
particle,
|
||||
prev_data,
|
||||
current_data,
|
||||
|
Loading…
Reference in New Issue
Block a user