runtime: Increase default WASM VM stack size and remove wasm-strip dependency

This commit is contained in:
parazyd
2025-08-09 12:07:52 +02:00
committed by skoupidi
parent d4670375f8
commit a7d3fbdb71
11 changed files with 24 additions and 17 deletions

View File

@@ -40,7 +40,7 @@ jobs:
run: | run: |
pip install ghp-import pip install ghp-import
pip install prettytable pip install prettytable
sudo apt -y install make wget libasound2-dev libfontconfig1-dev wabt sudo apt -y install make wget libasound2-dev libfontconfig1-dev
wget "https://github.com/badboy/mdbook-toc/releases/download/0.14.1/mdbook-toc-0.14.1-x86_64-unknown-linux-gnu.tar.gz" wget "https://github.com/badboy/mdbook-toc/releases/download/0.14.1/mdbook-toc-0.14.1-x86_64-unknown-linux-gnu.tar.gz"
wget "https://github.com/lzanini/mdbook-katex/releases/download/v0.5.7/mdbook-katex-v0.5.7-x86_64-unknown-linux-gnu.tar.gz" wget "https://github.com/lzanini/mdbook-katex/releases/download/v0.5.7/mdbook-katex-v0.5.7-x86_64-unknown-linux-gnu.tar.gz"
wget "https://github.com/badboy/mdbook-mermaid/releases/download/v0.12.6/mdbook-mermaid-v0.12.6-x86_64-unknown-linux-gnu.tar.gz" wget "https://github.com/badboy/mdbook-mermaid/releases/download/v0.12.6/mdbook-mermaid-v0.12.6-x86_64-unknown-linux-gnu.tar.gz"

View File

@@ -98,14 +98,13 @@ The following dependencies are also required:
| openssl | libssl-dev | | openssl | libssl-dev |
| sqlcipher | libsqlcipher-dev | | sqlcipher | libsqlcipher-dev |
| sqlite3 | libsqlite3-dev | | sqlite3 | libsqlite3-dev |
| wabt | wabt |
Users of Debian-based systems (e.g. Ubuntu) can simply run the Users of Debian-based systems (e.g. Ubuntu) can simply run the
following to install the required dependencies: following to install the required dependencies:
```shell ```shell
# apt-get update # apt-get update
# apt-get install -y git cmake make gcc g++ pkg-config libasound2-dev libclang-dev libfontconfig1-dev liblzma-dev libssl-dev libsqlcipher-dev libsqlite3-dev wabt # apt-get install -y git cmake make gcc g++ pkg-config libasound2-dev libclang-dev libfontconfig1-dev liblzma-dev libssl-dev libsqlcipher-dev libsqlite3-dev
``` ```
Alternatively, users can try using the automated script under `contrib` Alternatively, users can try using the automated script under `contrib`

View File

@@ -29,22 +29,22 @@ setup_mac() {
} }
setup_apt() { setup_apt() {
apt_deps="git cmake make gcc g++ pkg-config libasound2-dev libclang-dev libfontconfig1-dev liblzma-dev libssl-dev libsqlcipher-dev libsqlite3-dev wabt" apt_deps="git cmake make gcc g++ pkg-config libasound2-dev libclang-dev libfontconfig1-dev liblzma-dev libssl-dev libsqlcipher-dev libsqlite3-dev"
$1 install $apt_deps || return 1 $1 install $apt_deps || return 1
} }
setup_pacman() { setup_pacman() {
pacman_deps="git cmake make gcc pkgconf alsa-lib openssl sqlcipher wabt" pacman_deps="git cmake make gcc pkgconf alsa-lib openssl sqlcipher"
$1 -Sy $pacman_deps || return 1 $1 -Sy $pacman_deps || return 1
} }
setup_xbps() { setup_xbps() {
xbps_deps="git make gcc pkg-config alsa-lib-devel openssl-devel sqlcipher-devel wabt" xbps_deps="git make gcc pkg-config alsa-lib-devel openssl-devel sqlcipher-devel"
$1 -S $xbps_deps || return 1 $1 -S $xbps_deps || return 1
} }
setup_dnf() { setup_dnf() {
dnf_deps="git make gcc pkg-config findutils lato-fonts fontconfig-devel perl-FindBin perl-File-Compare alsa-lib-devel python3-devel alsa-lib-devel openssl-devel sqlcipher-devel libsq3-devel wabt" dnf_deps="git make gcc pkg-config findutils lato-fonts fontconfig-devel perl-FindBin perl-File-Compare alsa-lib-devel python3-devel alsa-lib-devel openssl-devel sqlcipher-devel libsq3-devel"
$1 install -y $dnf_deps || return 1 $1 install -y $dnf_deps || return 1
} }
@@ -64,7 +64,7 @@ setup_emerge() {
} }
setup_pkg() { setup_pkg() {
pkg_deps="git bash gcc findutils cantarell-fonts gmake devel/automake rust wabt llvm cmake sqlcipher pkgconf python python3" pkg_deps="git bash gcc findutils cantarell-fonts gmake devel/automake rust llvm cmake sqlcipher pkgconf python python3"
$1 install -y $pkg_deps || return 1 $1 install -y $pkg_deps || return 1
} }

View File

@@ -11,7 +11,7 @@ ARG RUST_VER
RUN apt-get update && apt-get install -y build-essential cmake jq wget \ RUN apt-get update && apt-get install -y build-essential cmake jq wget \
pkg-config clang libclang-dev llvm-dev libudev-dev libfreetype6-dev libasound2-dev \ pkg-config clang libclang-dev llvm-dev libudev-dev libfreetype6-dev libasound2-dev \
libexpat1-dev curl gcc make libssl-dev fonts-lato libfontconfig-dev python3-dev libsqlite3-dev \ libexpat1-dev curl gcc make libssl-dev fonts-lato libfontconfig-dev python3-dev libsqlite3-dev \
libsqlcipher-dev wabt libsqlcipher-dev
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}" RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}"

View File

@@ -13,7 +13,7 @@ RUN dnf -y install gcc gcc-c++ kernel-headers cmake jq wget \
openssl-devel findutils fontconfig-devel \ openssl-devel findutils fontconfig-devel \
lato-fonts alsa-lib-devel python3-devel \ lato-fonts alsa-lib-devel python3-devel \
perl-FindBin perl-File-Compare perl-lib sqlite-devel \ perl-FindBin perl-File-Compare perl-lib sqlite-devel \
perl-interpreter sqlcipher-devel wabt perl-interpreter sqlcipher-devel
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}" RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}"

View File

@@ -12,7 +12,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install
build-essential cmake jq wget curl \ build-essential cmake jq wget curl \
pkg-config clang libclang-dev llvm-dev libudev-dev libfreetype6-dev \ pkg-config clang libclang-dev llvm-dev libudev-dev libfreetype6-dev \
libexpat1-dev curl gcc make libssl-dev fonts-lato libfontconfig-dev \ libexpat1-dev curl gcc make libssl-dev fonts-lato libfontconfig-dev \
libasound2-dev python3-dev libsqlite3-dev libsqlcipher-dev wabt libasound2-dev python3-dev libsqlite3-dev libsqlcipher-dev
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}" RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain "${RUST_VER}"

View File

@@ -24,7 +24,7 @@ ARG BINS
RUN apt-get update RUN apt-get update
RUN apt-get install -y git cmake make gcc g++ pkg-config \ RUN apt-get install -y git cmake make gcc g++ pkg-config \
libasound2-dev libclang-dev libssl-dev libsqlcipher-dev \ libasound2-dev libclang-dev libssl-dev libsqlcipher-dev \
libsqlite3-dev wabt wget libsqlite3-dev wget
## Rust installation ## Rust installation
RUN wget -O install-rustup.sh https://sh.rustup.rs && \ RUN wget -O install-rustup.sh https://sh.rustup.rs && \

View File

@@ -42,7 +42,6 @@ $(WASM_BIN): $(WASM_SRC) $(PROOFS_BIN)
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \
--release --package $(PKGNAME) --release --package $(PKGNAME)
cp -f ../../../target/$(WASM_TARGET)/release/$@ $@ cp -f ../../../target/$(WASM_TARGET)/release/$@ $@
wasm-strip $@
test-integration: all test-integration: all
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \

View File

@@ -32,7 +32,6 @@ $(WASM_BIN): $(WASM_SRC)
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \
--release --package $(PKGNAME) --release --package $(PKGNAME)
cp -f ../../../target/$(WASM_TARGET)/release/$@ $@ cp -f ../../../target/$(WASM_TARGET)/release/$@ $@
wasm-strip $@
test-integration: all test-integration: all
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \

View File

@@ -42,7 +42,6 @@ $(WASM_BIN): $(WASM_SRC) $(PROOFS_BIN)
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \
--release --package $(PKGNAME) --release --package $(PKGNAME)
cp -f ../../../target/$(WASM_TARGET)/release/$@ $@ cp -f ../../../target/$(WASM_TARGET)/release/$@ $@
wasm-strip $@
test-integration: all test-integration: all
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \ RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \

View File

@@ -32,7 +32,8 @@ use darkfi_serial::serialize;
use tracing::{debug, error, info}; use tracing::{debug, error, info};
use wasmer::{ use wasmer::{
imports, sys::CompilerConfig, wasmparser::Operator, AsStoreMut, AsStoreRef, Function, imports, sys::CompilerConfig, wasmparser::Operator, AsStoreMut, AsStoreRef, Function,
FunctionEnv, Instance, Memory, MemoryView, Module, Pages, Store, Value, WASM_PAGE_SIZE, FunctionEnv, Instance, Memory, MemoryType, MemoryView, Module, Pages, Store, Value,
WASM_PAGE_SIZE,
}; };
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
use wasmer_middlewares::{ use wasmer_middlewares::{
@@ -183,6 +184,14 @@ impl Runtime {
compiler_config.push_middleware(metering); compiler_config.push_middleware(metering);
let mut store = Store::new(compiler_config); let mut store = Store::new(compiler_config);
// Create a larger Memory for the instance
let memory_type = MemoryType::new(
Pages(256), // init: 16 MB (256 * 64KB)
Some(Pages(4096)), // max: 256 MB
false,
);
let memory = Memory::new(&mut store, memory_type)?;
debug!(target: "runtime::vm_runtime", "Compiling module"); debug!(target: "runtime::vm_runtime", "Compiling module");
let module = Module::new(&store, wasm_bytes)?; let module = Module::new(&store, wasm_bytes)?;
@@ -202,7 +211,7 @@ impl Runtime {
contract_section: ContractSection::Null, contract_section: ContractSection::Null,
contract_return_data: Cell::new(None), contract_return_data: Cell::new(None),
logs, logs,
memory: None, memory: Some(memory.clone()),
objects: RefCell::new(vec![]), objects: RefCell::new(vec![]),
verifying_block_height, verifying_block_height,
block_target, block_target,
@@ -214,6 +223,8 @@ impl Runtime {
let imports = imports! { let imports = imports! {
"env" => { "env" => {
"memory" => memory,
"drk_log_" => Function::new_typed_with_env( "drk_log_" => Function::new_typed_with_env(
&mut store, &mut store,
&ctx, &ctx,