Questions tagged [rust]
Questions about the Rust programming language, the primary language used in the Substrate ecosystem.
30
questions with no upvoted or accepted answers
4
votes
1
answer
18
views
error[E0282]: type annotations needed --> /libp2p-noise-0.32.0/src/protocol/x25519.rs:221:45
While running this project https://github.com/jimmychu0807/substrate-offchain-worker-demo
I'm geting this error:
error[E0282]: type annotations needed --> /libp2p-noise-0.32.0/src/protocol/x25519....
4
votes
0
answers
132
views
How to solve this Failed to compact generated WASM binary.: Error(UnknownOpcode(192))
For one assignment I have run the command cargo build --release so that I can build the pallet. After that I was getting the error
After that according to this- Error Building Substrate contract Node(...
3
votes
0
answers
25
views
How to use enum with associated value(s) in ink smart contract
I have an ink smart contract message that takes an enum as argument. The code is shown below;
#[derive(Encode, Decode)]
#[cfg_attr(
feature = "std",
derive(Debug, PartialEq, Eq, ...
3
votes
0
answers
88
views
Not enough data to fill buffer
When running an API function using rust, we get this error:
GenericError { reason: "Failed to get unsigned proposals: FailedToDecodeReturnValue { function: \"DKGApi_get_unsigned_proposals\&...
3
votes
0
answers
55
views
Cargo-contract forcibly calls nightly-2022-06-30 regardless of specified toolchain
I am experiencing an issue when using cargo-contract (version 1.5.1) to build a project (command: cargo +nightly contract build). The specified toolchain is not being recognized, and the process is ...
3
votes
1
answer
272
views
build failed with substrate chain on rocksdb in linux
I followed this tutorial https://docs.substrate.io/tutorials/get-started/build-local-blockchain/. I got the below error when run cargo build --release. How can I fix it?
cargo build -v --release
...
3
votes
1
answer
88
views
Division operation in `u128` results false value
In my node, Balance type is u128. I have following variable
let per_block = 100_000_000_000_000_000_u128;
let total = 50_000_000_000_000_000_000_000_u128;
let ratio = per_block.checked_div(total);
...
3
votes
0
answers
52
views
NPOS not working after adding the EVM to node config in substrate
I have implemented the NPOS with EVM blockchain using the substrate.
NPOS working fine but after adding EVM to Genesis config in node the NPOS is not working and the staking election failed.
Smart ...
2
votes
1
answer
39
views
What is the use of Get trait here?
In the referenda pallet, type Tracks uses two trait, Get and TracksInfo
substrate/frame/referenda/src/lib.rs
/// Information concerning the different referendum tracks.
#[pallet::constant]
...
2
votes
1
answer
111
views
How can I decode this error message {"ok":{"flags":["Revert"],"data":"0x000110"}}?
I'm using polkadotjs to call my ink! smart contracts and I seem to be having trouble with calls that require parameters. For the call below I am getting the revert flag {"ok":{"flags&...
2
votes
1
answer
84
views
How to fix "module group is private" error when using frame-support-procedural-tools v3.0.0?
I'm trying to use orml-tokens in my Substrate project and encountered the following error:
error[E0603]: module `group` is private
--> /home/kianoush/.cargo/registry/src/github.com-...
1
vote
0
answers
17
views
I am having issues with implementing swap fees on transfer for DEX
Below is my lib.rs file for the token contract and it uses the Cardinal Cryptography PSP22 sample at https://github.com/Cardinal-Cryptography/PSP22
I am trying to implement swap for the transfer taxes ...
1
vote
2
answers
29
views
How to print / output from within async tokio test
I am writing a new test and when I run this code, the println's do not output in the terminal.
#[tokio::test]
async fn can_fetch_child_keys() {
if std::option_env!("TEST_WS").is_none() {
...
1
vote
0
answers
14
views
How to Modify static buffer size for my ink smart contract to Resolving 'OutputBufferTooSmall' Error for Larger Vectors in ink smart contract
I'm facing an 'OutputBufferTooSmall' error in my [Language/Framework] code when working with larger vectors. I suspect this is related to the maximum allowed input/output sizes. I need guidance on how ...
1
vote
0
answers
14
views
"ContractTrapped" Error even with successful cross-contract call
let result_call = ink::env::call::build_call::<Environment>()
.call(self.escrow_address)
.gas_limit(0)
.transferred_value(0)
...
1
vote
0
answers
22
views
How to change the gas cost in ink! e2e tests
I want to be able to adjust the gas cost used in specific ink! end-to-end (e2e) tests, but my attempts to do so have consistently resulted in a return value of zero when using the weight_to_fee ...
1
vote
1
answer
29
views
Need help in Ink e2e tests
I need help with that code. Can anyone pls help me out ??
mod p{
#[ink(storage)]
pub struct Foobar {
/// Stores a single `bool` value on the storage.
value: ...
1
vote
0
answers
19
views
BoundedBTreeMap error with Debug trait
Consider the following snippet
#[weight = 100_000_000] //TODO: update weights
pub fn test(
_origin,
_outputs: frame_support::BoundedBTreeSet<JoyBalanceOf<...
1
vote
0
answers
51
views
Call a smart contract method from the offchain worker
As the title is descriptive I would like to call a method on a Sample contract deployed to runtime evm, from the off-chain worker.
For example:
Contract Sample {
Public five=5;
}
Call Sample.five() ...
1
vote
0
answers
59
views
Problem to run docker image
I'm trying to run the image pulled from dockerhub: https://hub.docker.com/repository/docker/gertdjali/escrow but doesn't work.
I ran the image locally by terminal './scripts/docker_run.sh' as ...
1
vote
0
answers
49
views
Best tools & settings for `VSCode` for *offline* Substrate development
Substrate builds are resource intensive. Running some of rust's best-in-class tools like rust-analyzer at least with default settings leads to continuous full use of most resources and take ...
0
votes
0
answers
50
views
Rust Compile Error: Unresolved imports crate::pallet, crate::types::Types::Config
I am working on a Rust project where I have multiple modules. I'm facing an issue with unresolved imports when I try to compile my code. Here's the relevant code structure:
types.rs
pub mod Types {
...
0
votes
1
answer
63
views
Encountered incremental compilation error
I have encountered following error from time to time while compiling substrate-node-template
error: internal compiler error: encountered incremental compilation error with mir_built(76e5305fbe3bf3e0-...
0
votes
0
answers
189
views
Getting rust-analyzer error while running a substrate based chain
My problem
Running cargo build does not give any error in terminal but rust-analyzer of Visual studio code gives me 85 errors and 8 warnings.
I followed the installation guide from the substrate docs. ...
0
votes
0
answers
37
views
Bags-list pallet test case not running
I am using the polkadot version 0.9.36, I run test cases of all the pallets in the frame by using the cargo test command, every pallet test case is working fine but when I run the bags-list pallet ...
0
votes
0
answers
47
views
Running substrate-node-template throws macOS memory error
I am using substrate-node-template. I don't have any issue building the substrate-node-template in release mode, and when I try to run it the first time it works fine, but if I stop and try to run it ...
0
votes
1
answer
28
views
Multiple test mock runtimes with slightly different configs based off common base?
We have some custom pallet unit tests that use multiple mock runtimes that are configured slightly differently. The problem is that when we have to make changes to the runtime, we have to apply those ...
0
votes
1
answer
36
views
Build fails when trying to create workspace from selected pallets and primitives
I want to put some pallets and primitive code in a workspace. Here is my code https://github.com/zeitgeistpm/external
However this does not build, neither workspace builds nor individual components.
...
0
votes
2
answers
2k
views
error: linking with `cc` failed: exit status: 1 (Mac m1)
Not able to build a project because of this issue:
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-arch" "arm64" "/var/folders/5w/...
0
votes
1
answer
27
views
How can I access a value obtained at runtime in primitives npos elections?
I want to change the weight/score of targets on the basis of values got during runtime, in my research I found the score of a target is being calculated in primitives/npos-elections/phragmen.rs in fn ...