Skip to main content
18 votes
Accepted

Why does Substrate have a Wasm runtime?

I'd divide the question further into two parts. Does Substrate Really Need a Virtual Machine? Historically, Substrate was split from Polkadot early on. So we will have to bring Polkadot into the ...
pepyakin's user avatar
  • 2,184
16 votes
Accepted

Wasm interpreter in pallet-contracts

All your assumptions are correct. And yes we have a double layer of execution right now. There exists an API that allows us to have the execution engine within the the client (native code) which would ...
Alexander Theißen's user avatar
12 votes
Accepted

cannot run substrate on a fresh macbook m2

solved by downgrading nightly from 1.70 to 1.68 interestingly, I couldn't really downgrade by simply calling rustup commands I had to do rustup install nightly-2023-01-01 to make 1.68available, then I ...
Bernardo Rodrigues's user avatar
11 votes
Accepted

What is the relationship between `sandbox`, `executor` and `runtime`?

Commonly, "Runtime" refers to something that performs or aids execution. However, historically, what we call a "Runtime" differs from how the word is commonly used. "Runtime&...
pepyakin's user avatar
  • 2,184
11 votes
Accepted

The wasm32-unknown-unknown target is not supported by default

Pallets compile to WASM which means that all dependencies need to work in a no-std environment. In your case it looks like one of your dependencies tries to generate random numbers. This does not work ...
Oliver Tale-Yazdi's user avatar
11 votes
Accepted

ERROR: Loading of original wasm failed

Solved! This was caused by the nightly toolchain. Switching to the stable toolchain solved this issue. Edit: As pointed out by Shunsuke, this is specific to the 1.70.0 nightly build. 1.68.0 version ...
statisticalanomaly's user avatar
9 votes
Accepted

What is the proper way of executing a runtime upgrade on a parachain?

The flow of upgrading the runtime in a parachain can definitely be different from the the flow one can be used to when running a solo chain. For this scenario what is recommended is following the ...
Alejandro Martínez's user avatar
9 votes
Accepted

Is the WASM blob created from ink! contract always deterministic

Currently we don't persist the information necessary to have a deterministic build. There is this GitHub issue for it: https://github.com/paritytech/cargo-contract/issues/525. The underlying issue is ...
cmichi's user avatar
  • 2,800
8 votes

large wasm size for polkadot 0.9.17

You should use the compressed runtime artefact generated by the build. For instance in the case of Kusama it is kusama_runtime-v9170.compact.compressed.wasm (note the *.compressed.wasm) as per the ...
Jaco's user avatar
  • 5,865
8 votes

cannot run substrate on a fresh macbook m2

I had the same error, and solved it by adding a rust-toolchain.toml file in my project root folder to override the toolchain. The content of rust-toolchain.toml is: [toolchain] channel = "nightly-...
Jupiter's user avatar
  • 81
7 votes
Accepted

How can I pass a Vec<u8> via chain extension to pallet?

You can only use read_as() for types whose size is known at compile time (thus the requirement that types implement MaxEncodedLen). If you don't know the size ahead of time, like in the case of a Vec, ...
HCastano's user avatar
  • 1,071
7 votes

Performance of same logic with a contract using pallet-contracts vs. a native pallet (excluding metering)

Smart contracts via pallet-contracts are run using a Wasm interpreter, namely wasmi, while native pallets are run via Wasm JIT, namely Wasmtime, (or native). Therefore the underlying question is: What ...
Robin's user avatar
  • 71
7 votes

What is the proper way of executing a runtime upgrade on a parachain?

Just to add to the above answer: One good trick to providing the correct hash for authorizeUpgrade: you can select the "hash a file" option on the right and then pick a file on disk and it ...
Squirrel's user avatar
  • 3,849
7 votes
Accepted

Is possible to extract the runtime version from WASM file?

tldr: Yes it is possible :) There is a tool (and a bunch of crates) that actually aims at getting as many info as possible from a substrate wasm blob without requiring any node, it is called subwasm: ...
Chevdor's user avatar
  • 566
6 votes
Accepted

Wasmi is not related to the polkadot or substrate?

wasmi is a Wasm executor that uses interpretation rather than compilation. Whenever the node software needs to execute some Wasm binary, it needs to use a Wasm executor like wasmi or wasmtime. This ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes
Accepted

How to use `--execution` and `--wasm-execution` when setting up a node?

With --execution you configure what kind of execution will be used. As you already have seen you can configure stuff like NativeElseWasm or Wasm or NativeThenWasm etc. This just configures which kind ...
bkchr's user avatar
  • 11.6k
5 votes

Wasm interpreter in pallet-contracts

Overall your assumptions are correct. WASM Smart Contracts are currently interpreted by the wasmi Interpreter. There exists indeed considerations to switch to the wasmer compiler/runtime. AFAIK those ...
Achim's user avatar
  • 575
5 votes
Accepted

Building a substrate node template with a global cargo `target` directory

What seems to be happening is that the wasm_builder builds the runtime in a nested location in the target directory: target debug wbuild node-template-runtime ...
Dcompoze's user avatar
  • 620
5 votes
Accepted

What are the design decisions behind Runtime memory management

Why is the Runtime memory management designed such that the Host manages the memory shared with the Wasm Runtime (imports memory + allocation functions)? The design in which allocation functions are ...
pepyakin's user avatar
  • 2,184
5 votes
Accepted

Cannot run benchmarking: "Did not find the benchmarking metadata."

It turned out that I was missing one crucial thing: impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { #[cfg(feature = "runtime-benchmarks")] type ExtendHostFunctions = ...
pmikolajczyk41's user avatar
4 votes

Is the genesis built on the MAC different from the genesis built on Linux

If you create a genesis on Mac and on Linux, they may differ, and that is OKAY. There will be no issues running a genesis generated on Mac with a node running on Linux. The genesis of a chain is ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes

How can I read JSON files in substrate

You definitely should not do this. You cannot use std inside the runtime. The Substrate runtime does not have access to the file system of the computer, so any kind of File::open stuff is definitely ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes
Accepted

How is wasmi different from wasmtime?

Wasmi is a WASM Interpreter used by the pallet-contracts. Like every pallet also pallet-contracts is compiled to WASM itself as part of the WASM runtime. The WASM runtime is executed through the more ...
Daan van der Plas's user avatar
4 votes
Accepted

Implications of invalid encoded extrinsic calls

Great question! What are the security implications of panicking inside the WASM when an extrinsic can not get decoded successfully? Before a transaction enters the tx pool the tx is validated using ...
Daan van der Plas's user avatar
4 votes

ERROR: Loading of original wasm failed

For cases where updated nightly is still preferred for whatever reason: rustup update rustup install nightly-2023-02-07-aarch64-apple-darwin rustup component add rust-src --toolchain nightly-2023-02-...
blairmunroakusa's user avatar
4 votes

Smart Contract blockspace allocation in Hybrid Chains

I looked into this a little bit. It looks like there is nothing built in at the moment. In frame there is one signed extension CheckedWeight that make sure that the weight for a specific DispatchClass ...
Pierre's user avatar
  • 206
4 votes
Accepted

How to interact between a smart contract written in Solidity from a smart contract written in ink!?

But how would it be possible to build smart contracts written in ink! that call public functions in smart contracts written in Solidity and vice versa? We need to distinguish between Solidity ...
xermicus's user avatar
3 votes

How to enable `std` features in pallets?

standard library macros are (for some reason) out of scope. TL;DR: you cannont use std in runtime development As you see on the node template all runtime files must not use std because they target ...
Nuke's user avatar
  • 1,842
3 votes

Collator panicked at 'Storage root must match that calculated.'

This is probably related to the broken state cache. See here for more information. For now you can run your nodes with --state-cache-size 0 to prevent this bug.
bkchr's user avatar
  • 11.6k
3 votes

Why does Substrate have a Wasm runtime?

WASM runtime provides more architecture flexibility, for eg. OCW's implementation is more neat on WASM runtime pattern. Also, forkless upgrade itself is so important that illustrate WASM's worth. When ...
ironman_ch_parami's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible