I'm trying to implement pallet_contracts into my node, but that results in an error. I don't get why I'm getting this error and what I'm supposed to do with it.
Checking pallet-contracts v4.0.0-dev (https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.6.0#481165d9)
Compiling node-icv-runtime v1.1.0-dev (/Users/arjanvaneersel/Development/polkadot-hackathon-24q1/node/runtime)
error[E0449]: visibility qualifiers are not permitted here
--> /Users/arjanvaneersel/.cargo/git/checkouts/polkadot-sdk-cff69157b985ed76/481165d/substrate/frame/contracts/src/lib.rs:1247:3
|
1247 | environmental!(executing_contract: bool);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: trait items always share the visibility of their trait
= note: this error originates in the macro `environmental` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0449`.
error: could not compile `pallet-contracts` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `node-icv-runtime v1.1.0-dev (/Users/arjanvaneersel/Development/polkadot-hackathon-24q1/node/runtime)`
Caused by:
process didn't exit successfully: `/Users/arjanvaneersel/Development/polkadot-hackathon-24q1/node/target/release/build/node-icv-runtime-3e923a035f42d14e/build-script-build` (exit status: 101)
--- stdout
Information that should be included in a bug report.
Executing build command: env -u CARGO_ENCODED_RUSTFLAGS CARGO_TARGET_DIR="/Users/arjanvaneersel/Development/polkadot-hackathon-24q1/node/target/release/wbuild/node-icv-runtime/target" RUSTFLAGS="-C target-cpu=mvp -C target-feature=-sign-ext -C link-arg=--export-table -Clink-arg=--export=__heap_base -C link-arg=--import-memory " SKIP_WASM_BUILD="" "/Users/arjanvaneersel/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/arjanvaneersel/Development/polkadot-hackathon-24q1/node/target/release/wbuild/node-icv-runtime/Cargo.toml" "--color=always" "--profile" "release" "-Z" "build-std"
Using rustc version: rustc 1.77.0-nightly (25f8d01fd 2024-01-18)
--- stderr
Compiling pallet-contracts v4.0.0-dev (https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.6.0#481165d9)
warning: unstable feature specified for `-Ctarget-feature`: `sign-ext`
|
= note: this feature is not stably supported; its behavior can change in the future
warning: `pallet-template` (lib) generated 1 warning
error[E0449]: visibility qualifiers are not permitted here
--> /Users/arjanvaneersel/.cargo/git/checkouts/polkadot-sdk-cff69157b985ed76/481165d/substrate/frame/contracts/src/lib.rs:1247:3
|
1247 | environmental!(executing_contract: bool);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: trait items always share the visibility of their trait
= note: this error originates in the macro `environmental` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0449`.
error: could not compile `pallet-contracts` (lib) due to 3 previous errors
thread 'main' panicked at /Users/arjanvaneersel/.cargo/git/checkouts/polkadot-sdk-cff69157b985ed76/481165d/substrate/utils/wasm-builder/src/wasm_project.rs:822:37:
Copying the bloaty file to the project dir.: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Here relevant snippets of my runtime's Cargo.toml:
...
# Additional Dependencies
pallet-nfts = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.6.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.6.0", default-features = false }
pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.6.0", default-features = false }
# Local Dependencies
pallet-template = { path = "../pallets/template", default-features = false }
...
[features]
default = ["std"]
std = [
...
"pallet-contracts/std",
...
]
runtime-benchmarks = [
...
"pallet-contracts/runtime-benchmarks",
...
]
try-runtime = [
...
"pallet-contracts/try-runtime",
...
]
Here from lib.rs:
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
...
parameter_types! {
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
}
/// Configure pallet_contracts.
impl pallet_contracts::Config for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
/// The safest default is to allow no calls at all.
///
/// Runtimes should whitelist dispatchables that are allowed to be called from contracts
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to
/// change because that would break already deployed contracts. The `Call` structure itself
/// is not allowed to change the indices of existing pallets, too.
type CallFilter = Nothing;
type DepositPerItem = dynamic_params::contracts::DepositPerItem;
type DepositPerByte = dynamic_params::contracts::DepositPerByte;
type DefaultDepositLimit = dynamic_params::contracts::DefaultDepositLimit;
type CallStack = [pallet_contracts::Frame<Self>; 5];
type WeightPrice = pallet_transaction_payment::Pallet<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type Schedule = Schedule;
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
type UnsafeUnstableInterface = ConstBool<false>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
type RuntimeHoldReason = RuntimeHoldReason;
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = ();
#[cfg(feature = "runtime-benchmarks")]
type Migrations = pallet_contracts::migration::codegen::BenchMigrations;
type MaxDelegateDependencies = ConstU32<32>;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type Environment = ();
type Xcm = ();
}
...
// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub struct Runtime {
System: frame_system,
Timestamp: pallet_timestamp,
Aura: pallet_aura,
Grandpa: pallet_grandpa,
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
Sudo: pallet_sudo,
Nfts: pallet_nfts,
Identity: pallet_identity,
Contracts: pallet_contracts,
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
}
);
...
#[allow(unused_parens)]
type Migrations = (pallet_contracts::Migration<Runtime>);
...
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[frame_benchmarking, BaselineBench::<Runtime>]
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_contracts, Contracts]
[pallet_identity, Identity]
[pallet_nfts, Nfts]
[pallet_timestamp, Timestamp]
[pallet_sudo, Sudo]
[pallet_template, TemplateModule]
);
}
...
impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime
{
fn call(
origin: AccountId,
dest: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts::ContractExecResult<Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call(
origin,
dest,
value,
gas_limit,
storage_deposit_limit,
input_data,
pallet_contracts::DebugInfo::UnsafeDebug,
pallet_contracts::CollectEvents::UnsafeCollect,
pallet_contracts::Determinism::Enforced,
)
}
fn instantiate(
origin: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_contracts::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts::ContractInstantiateResult<AccountId, Balance, EventRecord>
{
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate(
origin,
value,
gas_limit,
storage_deposit_limit,
code,
data,
salt,
pallet_contracts::DebugInfo::UnsafeDebug,
pallet_contracts::CollectEvents::UnsafeCollect,
)
}
fn upload_code(
origin: AccountId,
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
determinism: pallet_contracts::Determinism,
) -> pallet_contracts::CodeUploadResult<Hash, Balance>
{
Contracts::bare_upload_code(
origin,
code,
storage_deposit_limit,
determinism,
)
}
fn get_storage(
address: AccountId,
key: Vec<u8>,
) -> pallet_contracts::GetStorageResult {
Contracts::get_storage(
address,
key
)
}
}
...
Does anyone have an idea how I can solve this error? Thanks in advance.