Skip to content

Commit

Permalink
feat(aquavm)!: aquavm mem limits from config [fixes VM-425] (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
raftedproc committed Mar 5, 2024
1 parent b870e1a commit a732f5c
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 141 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,26 @@ jobs:
cli:
needs:
- nox-snapshot
uses: fluencelabs/cli/.github/workflows/tests.yml@main
uses: fluencelabs/cli/.github/workflows/tests.yml@renovate/fluencelabs-js-client-0.x
with:
ref: renovate/fluencelabs-js-client-0.x
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"

js-client:
needs:
- nox-snapshot
uses: fluencelabs/js-client/.github/workflows/tests.yml@master
with:
ref: js-client-v0.8.4
ref: js-client-v0.9.0
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"

aqua:
needs:
- nox-snapshot
uses: fluencelabs/aqua/.github/workflows/tests.yml@main
uses: fluencelabs/aqua/.github/workflows/tests.yml@renovate/fluencelabs-js-client-0.x
with:
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
ref: renovate/fluencelabs-js-client-0.x

# registry:
# needs:
Expand All @@ -108,4 +110,3 @@ jobs:
# with:
# nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
# if-no-artifacts-found: warn

93 changes: 47 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ marine-it-parser = "0.16.0"
marine-module-info-parser = "0.15.0"

# avm
avm-server = "=0.35.0"
air-interpreter-wasm = "=0.59.0"
avm-server = "=0.37.0"
air-interpreter-wasm = "=0.62.0"

# libp2p
libp2p = { version = "0.53.2", features = ["noise", "tcp", "dns", "websocket", "yamux", "tokio", "kad", "ping", "identify", "macros"] }
Expand Down
15 changes: 13 additions & 2 deletions aquamarine/src/aqua_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::{error::Error, task::Waker};

use avm_server::avm_runner::{AVMRunner, RawAVMOutcome};
use avm_server::{AVMMemoryStats, CallResults, ParticleParameters, RunnerError};
use avm_server::{AVMMemoryStats, AVMRuntimeLimits, CallResults, ParticleParameters, RunnerError};
use fluence_keypair::KeyPair;
use log::LevelFilter;

Expand Down Expand Up @@ -57,7 +57,18 @@ impl AquaRuntime for AVMRunner {

/// Creates `AVM` in background (on blocking threadpool)
fn create_runtime(config: Self::Config, waker: Waker) -> Result<Self, Self::Error> {
let vm = AVMRunner::new(config.air_interpreter, config.max_heap_size, i32::MAX)?;
let avm_runtime_limits = AVMRuntimeLimits::new(
config.air_size_limit,
config.particle_size_limit,
config.call_result_size_limit,
config.hard_limit_enabled,
);
let vm: AVMRunner = AVMRunner::new(
config.air_interpreter,
config.max_heap_size,
avm_runtime_limits,
i32::MAX,
)?;
waker.wake();
Ok(vm)
}
Expand Down
16 changes: 16 additions & 0 deletions aquamarine/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ pub struct VmConfig {
pub air_interpreter: PathBuf,
/// Maximum heap size in bytes available for the interpreter.
pub max_heap_size: Option<u64>,
/// Maximum AIR script size in bytes.
pub air_size_limit: Option<u64>,
/// Maximum particle size in bytes.
pub particle_size_limit: Option<u64>,
/// Maximum call result size in bytes.
pub call_result_size_limit: Option<u64>,
/// A knob to enable/disable hard limits behavior in AquaVM.
pub hard_limit_enabled: bool,
}

impl VmPoolConfig {
Expand All @@ -50,11 +58,19 @@ impl VmConfig {
current_peer_id: PeerId,
air_interpreter: PathBuf,
max_heap_size: Option<u64>,
air_size_limit: Option<u64>,
particle_size_limit: Option<u64>,
call_result_size_limit: Option<u64>,
hard_limit_enabled: bool,
) -> Self {
Self {
current_peer_id,
air_interpreter,
max_heap_size,
air_size_limit,
particle_size_limit,
call_result_size_limit,
hard_limit_enabled,
}
}
}
Expand Down
Loading

0 comments on commit a732f5c

Please sign in to comment.