Skip to content

Commit

Permalink
Add wasm-precompiled feature to tanssi-relay binary (#725)
Browse files Browse the repository at this point in the history
* Add wasm-precompiled feature to tanssi-relay binary

* Add to zombie_tanssi_relay as well
  • Loading branch information
tmpolaczyk authored Oct 21, 2024
1 parent 2e13202 commit c09974c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
3 changes: 3 additions & 0 deletions solo-chains/client/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub enum Subcommand {
#[command(subcommand)]
Key(sc_cli::KeySubcommand),

/// Precompile the WASM runtime into native code
PrecompileWasm(sc_cli::PrecompileWasmCmd),

/// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),
}
Expand Down
12 changes: 12 additions & 0 deletions solo-chains/client/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@ pub fn run() -> Result<()> {
}
}
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
Some(Subcommand::PrecompileWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.async_run(|mut config| {
let (_, backend, _, task_manager) =
polkadot_service::new_chain_ops(&mut config, None)?;
Ok((
cmd.run(backend, config.chain_spec)
.map_err(Error::SubstrateCli),
task_manager,
))
})?)
}
Some(Subcommand::ChainInfo(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run::<polkadot_service::Block>(&config))?)
Expand Down
9 changes: 6 additions & 3 deletions solo-chains/node/tanssi-relay-service/src/dev_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,16 @@ fn new_partial_basics(
extra_pages: h as u32,
});

let executor = WasmExecutor::builder()
let mut wasm_builder = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();
.with_runtime_cache_size(config.runtime_cache_size);
if let Some(ref wasmtime_precompiled_path) = config.wasmtime_precompiled {
wasm_builder = wasm_builder.with_wasmtime_precompiled_path(wasmtime_precompiled_path);
}
let executor = wasm_builder.build();

let (client, backend, keystore_container, task_manager) =
service::new_full_parts::<Block, RuntimeApi, _>(
Expand Down
2 changes: 1 addition & 1 deletion test/configs/zombieDancelight.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"relaychain": {
"chain_spec_path": "specs/tanssi-relay.json",
"default_command": "../target/release/tanssi-relay",
"default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy"],
"default_args": ["--no-hardware-benchmarks", "-lparachain=debug", "--database=paritydb", "--no-beefy", "--wasmtime-precompiled=wasm"],
"genesis": {
"runtimeGenesis": {
"patch": {
Expand Down
9 changes: 7 additions & 2 deletions test/moonwall.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
"name": "dev_tanssi_relay",
"envVars": ["DEBUG_COLORS=1"],
"testFileDir": ["suites/dev-tanssi-relay", "suites/common-all", "suites/common-tanssi"],
"runScripts": ["download-ethereum-client-test-files.sh"],
"runScripts": [
"download-ethereum-client-test-files.sh",
"compile-wasm.ts compile -b ../target/release/tanssi-relay -o wasm -c dancelight-dev -a='--mock-container-chain=2000 --mock-container-chain=2001'"
],
"multiThreads": true,
"timeout": 240000,
"reporters": ["basic"],
Expand All @@ -69,8 +72,9 @@
"--reserved-only",
"--alice",
"--tmp",
"--chain=dancelight-dev",
"--chain=tmp/dancelight-dev-raw.json",
"--no-hardware-benchmarks",
"--wasmtime-precompiled=wasm",
"--unsafe-force-node-key-generation"
],
"disableDefaultEthProviders": true,
Expand Down Expand Up @@ -700,6 +704,7 @@
"testFileDir": ["suites/zombie-tanssi-relay"],
"runScripts": [
"build-spec-dancelight.sh",
"compile-wasm.ts compile -b ../target/release/tanssi-relay -o wasm -c specs/tanssi-relay.json",
"compile-wasm.ts compile -b ../target/release/container-chain-simple-node -o wasm -c specs/single-container-template-container-2000.json",
"compile-wasm.ts compile -b ../target/release/container-chain-frontier-node -o wasm -c specs/single-container-template-container-2001.json"
],
Expand Down

0 comments on commit c09974c

Please sign in to comment.