Questions tagged [wasm]
The wasm tag has no usage guidance.
103 questions
15
votes
5
answers
2k
views
cannot run substrate on a fresh macbook m2
I have a brand new macbook m2.
I followed all the steps on https://docs.substrate.io/install/macos
% rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/bear/.rustup
installed ...
13
votes
2
answers
311
views
What is the proper way of executing a runtime upgrade on a parachain?
I would like to upgrade my parachain.
What is the proper way of executing a runtime upgrade on a parachain?
Which RPC method to call?
Should this be applied to collators or rpc-nodes?
12
votes
2
answers
459
views
Why does Substrate have a Wasm runtime?
Having a Wasm runtime is a key design decision in Substrate's architecture. It's clear that it's a key part of Substrate's forkless upgradability feature, but I'm still curious to understand what ...
12
votes
2
answers
223
views
Wasm interpreter in pallet-contracts
I have a question about how pallet-contracts interprets a Wasm contract. Are the following assumptions correct?
pallet-contracts interprets contracts through the simple wasmi interpreter
gas metering ...
10
votes
4
answers
2k
views
ERROR: Loading of original wasm failed
I having some trouble running the Flipper example from the Ink! webpage.
The cargo contract build outputs the following error log:
ERROR: Loading of original wasm failed
Caused by:
0: Loading of ...
9
votes
1
answer
121
views
Smart Contract blockspace allocation in Hybrid Chains
In Rob Habermeier's blogpost about Hybrid Chains, he mentions allocating contract execution to a limited fraction of the chain's blockspace.
Is that some functionality that pallet-contracts provides?
...
8
votes
1
answer
165
views
What is the relationship between `sandbox`, `executor` and `runtime`?
I was recently reading the code for Substrate wasmtime, but I ran into some problems. I don't really understand the difference between runtime and sandbox.
For example, in the runtime.rs file, we can ...
8
votes
1
answer
103
views
Performance of same logic with a contract using pallet-contracts vs. a native pallet (excluding metering)
I'm wondering what is current state of the art of Substrate's pallet-contracts performance as compared to the same functional implementation as a pallet.
I acknowledge that different logic can have ...
8
votes
4
answers
147
views
Managing deployment of complex set of wasm contracts
We need to deploy a set of several smart contracts, x-compiled from Solidity to wasm, and maintain that deployment (deploy new contract instances and migrate to them once in a while).
So what we ...
7
votes
5
answers
4k
views
The wasm32-unknown-unknown target is not supported by default
I'm attempting to implement a custom pallet, but I keep running into this compile error:
error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" ...
7
votes
1
answer
146
views
Is the WASM blob created from ink! contract always deterministic
The contract's source code is provided during the contract verification on a block explorer (or some other source verifier).
The block explorer needs to compile that source and verify if the generated ...
7
votes
2
answers
333
views
How is wasmi different from wasmtime?
I found wasmi is a dependency in multiple substrate crates, but there's one crate that also uses wasmtime. How is wasmi different from wasmtime?
7
votes
2
answers
126
views
How to change the number of heap pages
We are running into an allocator memory error where the number of heap pages appears to be insufficient to run a transaction on our validator (substrate-node).
This is the error in question:
2022-04-...
6
votes
1
answer
222
views
Building a substrate node template with a global cargo `target` directory
I'm trying to build a substrate-node-template with the following command:
cargo build
I have my cargo target-dir set inside a global ~/.cargo/config.toml file:
[build]
target-dir = "/home/foo/....
6
votes
1
answer
227
views
How to interact between a smart contract written in Solidity from a smart contract written in ink!?
In the repository of the cargo-contract CLI tool, which currently "helps you develop smart contracts in Parity's ink!, which is a Rust eDSL allowing you to write smart contracts for blockchains ...
6
votes
1
answer
141
views
Best way to handle Solidity's `uint256` in ink!
I have been working on creating a guide to port Solidity smart contracts to ink! smart contracts. I was hoping for some input on how to best handle Solidity's uint256 in ink!.
Solidity is optimized ...
6
votes
1
answer
118
views
cannot create module: instance allocation for this module requires 74376 bytes which exceeds the configured maximum of 65536 bytes
Try in to benchmark node pallets after Polkadot upgrade from 0.9.36 to 0.9.38 and get cannot create module: instance allocation for this module requires 74376 bytes which exceeds the configured ...
6
votes
1
answer
217
views
How to attach debugger to the Runtime WASM
Using lldb (like with VSCode), it is fairly easy to attach it to the client, allowing to debug the client side of the node. However, once the wasmtime is executing the Wasm Runtime, the debugger is ...
5
votes
1
answer
450
views
Is possible to extract the runtime version from WASM file?
Is possible to extract the runtime version from the WASM file?
Sometimes, I want to verify the WASM file's content locally.
5
votes
2
answers
274
views
How to use `--execution` and `--wasm-execution` when setting up a node?
I want to know the design relationship between them.
From the node binary help:
--execution <STRATEGY>
The execution strategy that should be used by all execution contexts [possible ...
5
votes
2
answers
209
views
"ERROR: Loading of original wasm failed" after upgrading rustup
I'm getting the following error when compiling a rust ink! 4.0;
ERROR: Loading of original wasm failed
It's started happening to me after I rustup update and now my rustc versions are:
stable-...
5
votes
1
answer
109
views
Substrate Error after updating from polkadot version polkadot 0.9.30 to polkadot 0.9.42
I have a running chain which was on polkadot-v0.9.30 and updated all the libraries on to polkadot-v0.9.42
No error found while uploading but got error after updating
panicked at 'Sensible defaults ...
5
votes
0
answers
204
views
How to check if a pallet can be compiled to no-std/WASM?
How to check if a pallet can be compiled to no-std/WASM?
I ran:
cargo build --no-default-features --target wasm32-unknown-unknown
But this didn't work. IIUC, we need some ENV to build the pallet to ...
4
votes
1
answer
214
views
How can I pass a Vec<u8> via chain extension to pallet?
I am working on chain extension to call rmrk pallet methods. One of the methods needs a BoundedVec that I need to pass via ink smart contract. What data type can I use to do this on smart contract ...
4
votes
1
answer
80
views
Implications of invalid encoded extrinsic calls
We are seeing the following error whenever an invalidly encoded but properly signed extrinsic is submitted in our substrate based chain.
{
"jsonrpc": "2.0",
"error&...
4
votes
2
answers
82
views
Alternative to BlakeTwo256 for WASM Compatibility in a no_std Environment in Rust
I'm developing a Rust script that I need to convert to WebAssembly (WASM). In this script, I'm using the BlakeTwo256 hasher, which is imported from the sp_runtime crate. However, I'm unable to compile ...
4
votes
1
answer
60
views
How to benchmark a crate's WASM execution performance?
How to benchmark the code's WASM execution performance?
I wrote a crate and want to use it in the runtime.
I want to know its WASM execution time in ms. How can I get that?
4
votes
2
answers
61
views
WebAssembly runtime file into ValidationCode
I have a CLI tool that gets a WebAssembly runtime file:
let validation_code_content = fs::read_to_string(path_validation_code)
.expect("Should have been able to read the validation code ...
3
votes
1
answer
53
views
Is the genesis built on the MAC different from the genesis built on Linux
If you register parathread with genesis and WASM generated on the MAC, then run the blockchain on Linux. Will this future run blockchain and fail?
3
votes
1
answer
83
views
Error while dividing two u128/Balance types
#[ink(storage)]
pub struct Variables {
a: u128,
b: u128,
multiplier: u128
}
impl Variables {
#[ink(constructor)]
pub fn new(a: u128, b: u128) ->...
3
votes
1
answer
86
views
How to return uint256 datatype from ink! wasm contract? How to make compatibility with IERC20?
IERC20 interface contains methods with uint256 datatype.
If you try to call ink! wasm contract from Solidity (compiled by solang to target subtrate) you will have an issue.
interface IERC20{
...
3
votes
1
answer
137
views
Provide more details about the compilation target of Polkadot's wasm runtime
I am trying to compile my own runtime, as PoC, but I don't use Rust's toolchain and some things are unclear how to do it at the moment.
With Substrate, you can write your blockchain logic in any ...
3
votes
1
answer
59
views
Prevent unused imports from bloating up runtime wasm
I recently wrote a pallet that uses a (non-substrate) Rust crate as a dependency.
This crate conveniently supports no-std and Wasm, but it is also quite extensive and there's a lot of code that my ...
3
votes
1
answer
192
views
Compiling runtime with std targeting wasm32-unknown-unknown
We are exploring how to wrap part of the runtime logic into a re-usable WASM blob that can be wrapped in a JS library.
To do that, we are investigating using wasm-pack and wasm-bindgen. Unfortunately, ...
3
votes
2
answers
36
views
Is there any way to extract "method" and "params" of unchecked extrinsic using ScaleCode/TypeInfo traits?
I'm wondering if there is any way to extract information about method and parameter of Extrinsic(Unchecked/CheckedExtrinsic) using TypeInfo and Scale codec.
In polkadotJs there is toString method on ...
3
votes
2
answers
226
views
Specialization impl does not specialize any associated items
I'm fairly new to Rust and ink! itself.
I'm trying to compile and build an extremely basic PSP22 Contract.
I get the following error when I compile & build:
(running cargo +nightly contract build)
...
3
votes
1
answer
77
views
Chatbot Trained on Substrate-based Chains and Repositories for General Reference and Help [closed]
I'd like to propose an idea for creating a general reference and help tool utilizing a chatbot trained on data from Substrate-based chains (e.g., Polkadot, Kusama, Parachains) and their associated ...
3
votes
2
answers
90
views
Wasm traps in ink contract but not in a `wasm-pack` test
I have a contract that implements some ZKP verification logic with plonk. The verification logic is contained in some other crate that can be compiled to Wasm, and there are wasm-pack tests like this:
...
3
votes
0
answers
33
views
How can I use complex structure in ink! version3
how can i use the complex structure(like Mapping<String, Vec<Map<String, String>>>) in ink!
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
#[ink::...
3
votes
0
answers
55
views
How to solve the error secp256k1-sys v0.4.2? [duplicate]
I'm adding a pallet2 to pallet1's runtime cargo.toml then I'm getting this error.
Thanks in advance!!
Compiling secp256k1-sys v0.4.2
error: the wasm32-unknown-unknown target is not supported by ...
2
votes
1
answer
73
views
large wasm size for polkadot 0.9.17
We have recently upgraded our runtime to polkadot 0.9.17. We noticed the wasm runtime seems too large i.e. 5.3 MB which exceeds the limit.
Is there a way or best approach to reduce the wasm size?
...
2
votes
1
answer
69
views
Wasmi is not related to the polkadot or substrate?
Does wasmi only function as an interpreter that changes the rust code to wasm?
Wasmi is not related to the function of Polkadot, such as scale codec(encode, decode extrinsics) or signing and signature ...
2
votes
1
answer
147
views
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)? Since the Host might need to store things onto ...
2
votes
2
answers
214
views
Contract storage needs nested orderbooks; best practice way to structure dapp?
For my dapp I need storage which can reference a mutable amount of events, all of which have their own orderbook. Expanded, it looks something like this:
CoreStorage {
coin_storage: CoinStore, //...
2
votes
1
answer
68
views
Embedding javascript (wasm) in substrate runtime
I have some javascript code that I need to embed in my substrate runtime. It's not possible / practical to rewrite the javascript code in rust. I was wondering if instead it would be possible to ...
2
votes
2
answers
559
views
How to enable `std` features in pallets?
I'm trying to implement simple PoW for my node. After debugging all other stuff I've encountered the problem where finality-grandpa and storage do not get compiled because standard library macros are (...
2
votes
1
answer
109
views
Collator panicked at 'Storage root must match that calculated.'
We have a few collators for the Kintsugi parachain actively syncing and producing blocks when they suddenly fall-over due to the following error:
Apr 02 21:06:00 ubuntu-s-2vcpu-4gb-amd-fra1-01 ...
2
votes
1
answer
49
views
What is default --execution <strategy> and recommended value for node/validator operator?
When executing node as a validator, the documentation states here that there is differents execution strategy available, however as this is optionnal switches, what is default if nothing is set ?
...
2
votes
1
answer
86
views
How to generate only the Wasm runtime during compilation?
Normally, when you run cargo build, both the native and Wasm runtime, along with the whole client is generated as part of the build process.
How would you compile just the Wasm runtime, so that you ...
2
votes
1
answer
127
views
unreachable` instruction executed when running overhead benchmark
for some reason running overhead benchmarks fails in our parachain.
cargo run --release --features=runtime-benchmarks benchmark overhead --chain local
results with following stacktrace
Error: Client(...