Skip to content

Commit a732f5c

Browse files
authored
feat(aquavm)!: aquavm mem limits from config [fixes VM-425] (#2111)
1 parent b870e1a commit a732f5c

File tree

19 files changed

+202
-141
lines changed

19 files changed

+202
-141
lines changed

.github/workflows/e2e.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,26 @@ jobs:
8282
cli:
8383
needs:
8484
- nox-snapshot
85-
uses: fluencelabs/cli/.github/workflows/tests.yml@main
85+
uses: fluencelabs/cli/.github/workflows/tests.yml@renovate/fluencelabs-js-client-0.x
8686
with:
87+
ref: renovate/fluencelabs-js-client-0.x
8788
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
8889

8990
js-client:
9091
needs:
9192
- nox-snapshot
9293
uses: fluencelabs/js-client/.github/workflows/tests.yml@master
9394
with:
94-
ref: js-client-v0.8.4
95+
ref: js-client-v0.9.0
9596
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
9697

9798
aqua:
9899
needs:
99100
- nox-snapshot
100-
uses: fluencelabs/aqua/.github/workflows/tests.yml@main
101+
uses: fluencelabs/aqua/.github/workflows/tests.yml@renovate/fluencelabs-js-client-0.x
101102
with:
102103
nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
104+
ref: renovate/fluencelabs-js-client-0.x
103105

104106
# registry:
105107
# needs:
@@ -108,4 +110,3 @@ jobs:
108110
# with:
109111
# nox-image: "${{ needs.nox-snapshot.outputs.nox-image }}"
110112
# if-no-artifacts-found: warn
111-

Cargo.lock

+47-46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ marine-it-parser = "0.16.0"
116116
marine-module-info-parser = "0.15.0"
117117

118118
# avm
119-
avm-server = "=0.35.0"
120-
air-interpreter-wasm = "=0.59.0"
119+
avm-server = "=0.37.0"
120+
air-interpreter-wasm = "=0.62.0"
121121

122122
# libp2p
123123
libp2p = { version = "0.53.2", features = ["noise", "tcp", "dns", "websocket", "yamux", "tokio", "kad", "ping", "identify", "macros"] }

aquamarine/src/aqua_runtime.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use std::{error::Error, task::Waker};
1818

1919
use avm_server::avm_runner::{AVMRunner, RawAVMOutcome};
20-
use avm_server::{AVMMemoryStats, CallResults, ParticleParameters, RunnerError};
20+
use avm_server::{AVMMemoryStats, AVMRuntimeLimits, CallResults, ParticleParameters, RunnerError};
2121
use fluence_keypair::KeyPair;
2222
use log::LevelFilter;
2323

@@ -57,7 +57,18 @@ impl AquaRuntime for AVMRunner {
5757

5858
/// Creates `AVM` in background (on blocking threadpool)
5959
fn create_runtime(config: Self::Config, waker: Waker) -> Result<Self, Self::Error> {
60-
let vm = AVMRunner::new(config.air_interpreter, config.max_heap_size, i32::MAX)?;
60+
let avm_runtime_limits = AVMRuntimeLimits::new(
61+
config.air_size_limit,
62+
config.particle_size_limit,
63+
config.call_result_size_limit,
64+
config.hard_limit_enabled,
65+
);
66+
let vm: AVMRunner = AVMRunner::new(
67+
config.air_interpreter,
68+
config.max_heap_size,
69+
avm_runtime_limits,
70+
i32::MAX,
71+
)?;
6172
waker.wake();
6273
Ok(vm)
6374
}

aquamarine/src/config.rs

+16
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ pub struct VmConfig {
3434
pub air_interpreter: PathBuf,
3535
/// Maximum heap size in bytes available for the interpreter.
3636
pub max_heap_size: Option<u64>,
37+
/// Maximum AIR script size in bytes.
38+
pub air_size_limit: Option<u64>,
39+
/// Maximum particle size in bytes.
40+
pub particle_size_limit: Option<u64>,
41+
/// Maximum call result size in bytes.
42+
pub call_result_size_limit: Option<u64>,
43+
/// A knob to enable/disable hard limits behavior in AquaVM.
44+
pub hard_limit_enabled: bool,
3745
}
3846

3947
impl VmPoolConfig {
@@ -50,11 +58,19 @@ impl VmConfig {
5058
current_peer_id: PeerId,
5159
air_interpreter: PathBuf,
5260
max_heap_size: Option<u64>,
61+
air_size_limit: Option<u64>,
62+
particle_size_limit: Option<u64>,
63+
call_result_size_limit: Option<u64>,
64+
hard_limit_enabled: bool,
5365
) -> Self {
5466
Self {
5567
current_peer_id,
5668
air_interpreter,
5769
max_heap_size,
70+
air_size_limit,
71+
particle_size_limit,
72+
call_result_size_limit,
73+
hard_limit_enabled,
5874
}
5975
}
6076
}

0 commit comments

Comments
 (0)