Skip to content
Merged
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ pallet-asset-conversion-tx-payment = { path = "substrate/frame/transaction-payme
pallet-asset-rate = { path = "substrate/frame/asset-rate", default-features = false }
pallet-asset-rewards = { path = "substrate/frame/asset-rewards", default-features = false }
pallet-asset-tx-payment = { path = "substrate/frame/transaction-payment/asset-tx-payment", default-features = false }
pallet-assets = { path = "substrate/frame/assets", default-features = false }
pallet-assets = { path = "substrate/frame/assets", default-features = false, features = ["precompiles"] }
pallet-assets-freezer = { path = "substrate/frame/assets-freezer", default-features = false }
pallet-assets-holder = { path = "substrate/frame/assets-holder", default-features = false }
pallet-atomic-swap = { default-features = false, path = "substrate/frame/atomic-swap" }
Expand Down
11 changes: 11 additions & 0 deletions prdoc/pr_9796.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: "pallet-assets: gate precompiles behind feature flag"

doc:
- audience: Runtime Dev
description: |
Assets pallet includes pallet-revive precompiles and subsequently pull a lot of EVM related dependencies by default. This change
hides the precompiles behind a feature flag `precompiles`, so downstream users can opt-in to the precompiles if they need them.

crates:
- name: pallet-assets
bump: minor
14 changes: 9 additions & 5 deletions substrate/frame/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true }
ethereum-standards = { workspace = true }
ethereum-standards = { workspace = true, optional = true }
impl-trait-for-tuples = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
Expand All @@ -28,7 +28,7 @@ frame-support = { workspace = true }
# `system` module provides us with all sorts of useful stuff and macros depend on it being around.
frame-benchmarking = { optional = true, workspace = true }
frame-system = { workspace = true }
pallet-revive = { workspace = true }
pallet-revive = { workspace = true, optional = true }
sp-core = { workspace = true }

[dev-dependencies]
Expand All @@ -44,7 +44,7 @@ std = [
"frame-system/std",
"log/std",
"pallet-balances/std",
"pallet-revive/std",
"pallet-revive?/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
Expand All @@ -55,13 +55,17 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-revive/runtime-benchmarks",
"pallet-revive",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-revive/try-runtime",
"pallet-revive?/try-runtime",
"sp-runtime/try-runtime",
]
precompiles = [
"pallet-revive",
"ethereum-standards"
]
3 changes: 2 additions & 1 deletion substrate/frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub mod benchmarking;
pub mod migration;
#[cfg(test)]
pub mod mock;
#[cfg(feature = "precompiles")]
pub mod precompiles;
#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -1204,7 +1205,7 @@ pub mod pallet {
ensure!(details.status == AssetStatus::Live, Error::<T, I>::AssetNotLive);
ensure!(origin == details.owner, Error::<T, I>::NoPermission);
if details.owner == owner {
return Ok(())
return Ok(());
}

let metadata_deposit = Metadata::<T, I>::get(&id).deposit;
Expand Down
12 changes: 12 additions & 0 deletions substrate/frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use super::*;
use crate as pallet_assets;

#[cfg(feature = "precompiles")]
use crate::precompiles::{InlineIdConfig, ERC20};
use codec::Encode;
use frame_support::{
Expand All @@ -31,6 +32,16 @@ use sp_runtime::BuildStorage;

type Block = frame_system::mocking::MockBlock<Test>;

#[cfg(not(feature = "precompiles"))]
construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Assets: pallet_assets,
}
);
#[cfg(feature = "precompiles")]
construct_runtime!(
pub enum Test
{
Expand All @@ -56,6 +67,7 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
}

#[cfg(feature = "precompiles")]
#[derive_impl(pallet_revive::config_preludes::TestDefaultConfig)]
impl pallet_revive::Config for Test {
type AddressMapper = pallet_revive::TestAccountMapper<Self>;
Expand Down
Loading