Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
659256b
Initial commit
tiagobndr May 27, 2025
d21b766
Add the XCM Precompile to the Mock Network
tiagobndr May 28, 2025
3126166
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 28, 2025
8f7fdd4
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr May 28, 2025
ddacec4
fix: PR comments
tiagobndr May 28, 2025
b341837
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli May 28, 2025
9306406
update: test for xcm precompile
sphamjoli May 29, 2025
b963c4f
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli May 29, 2025
240b8ea
update: charge gas for precompile
sphamjoli May 29, 2025
43c77ce
Merge branch 'tb/integ_xcm_precompile_pallet_xcm' of https://github.c…
sphamjoli May 29, 2025
a57e581
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 29, 2025
26b3f6e
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr May 29, 2025
2bd9c17
fix: PR comments
tiagobndr May 29, 2025
39f124b
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 29, 2025
e2c632b
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr May 30, 2025
a040a1b
doc: add prdoc
tiagobndr May 30, 2025
10a0a83
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli May 30, 2025
7b7acdc
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr May 30, 2025
3b1ad85
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr May 30, 2025
fd8f350
Merge branch 'tb/integ_xcm_precompile_pallet_xcm' of https://github.c…
sphamjoli May 30, 2025
6442869
Merge branch 'tb/integ_xcm_precompile_pallet_xcm' of https://github.c…
sphamjoli May 30, 2025
ea60b5e
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli May 30, 2025
10e27f9
fix: PR comments
sphamjoli May 30, 2025
2a10514
fix: CI
sphamjoli May 30, 2025
51c4683
fix: CI
sphamjoli May 30, 2025
79d8a5f
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 30, 2025
56bd6fc
fix: revert changes on charging weight for precompile calls
tiagobndr Jun 2, 2025
6969f17
fix: PR comments
tiagobndr Jun 2, 2025
2b732f4
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 2, 2025
f1ab023
fix: use depth-limited decoding for XCM messages
tiagobndr Jun 2, 2025
cb26365
fix: add Weight::MAX to the Weigher::weight() call
tiagobndr Jun 2, 2025
b7738d3
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 2, 2025
bf0cfae
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
athei Jun 2, 2025
eea0712
feat(xcm-precompile): refund excess weight
franciscoaguirre Jun 2, 2025
d46a1e8
fix(pallet-revive): use to_usize instead of try_into
franciscoaguirre Jun 2, 2025
6c9d83c
fix: fmt
franciscoaguirre Jun 2, 2025
8c57620
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
franciscoaguirre Jun 2, 2025
fa2dd49
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli Jun 2, 2025
859193c
fix: PR comments
tiagobndr Jun 3, 2025
e1694a9
fix: PR comment regarding removing Clone
tiagobndr Jun 3, 2025
7a6c735
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 3, 2025
6ec2d74
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 3, 2025
bf67b1e
Update substrate/frame/revive/src/precompiles/builtin/modexp.rs
franciscoaguirre Jun 3, 2025
f5ae802
fix: add benchmarks for weigh_message
tiagobndr Jun 3, 2025
56872ec
run benchmarks for westend and add todos for all runtimes
tiagobndr Jun 4, 2025
09bdb41
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 4, 2025
742c423
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 4, 2025
723d3ea
fix: move XCM precompile tests from mod.rs to precompiles.rs
tiagobndr Jun 4, 2025
06627c7
fix: add weigh_message benchmark to all runtimes
tiagobndr Jun 4, 2025
ab76d38
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 4, 2025
5368ddf
fix: clippy
franciscoaguirre Jun 4, 2025
7bcb6cf
fix(xcm-precompile): add execute weight info
franciscoaguirre Jun 4, 2025
3024678
Update from github-actions[bot] running command 'bench --runtime asse…
github-actions[bot] Jun 4, 2025
f674007
fix: handle error in weigh_message benchmark
franciscoaguirre Jun 4, 2025
87f59d3
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
franciscoaguirre Jun 4, 2025
d7dca77
fix: update weights to those from reference hardware
franciscoaguirre Jun 4, 2025
f299795
revert: remove unnecessary changes
franciscoaguirre Jun 4, 2025
0885f63
chore: wrap weight in RuntimeCosts::Precompile inside the function
franciscoaguirre Jun 4, 2025
c708434
fix: add weigh_message benchmark to staking-async
tiagobndr Jun 4, 2025
a29e51b
chore: define LOG_TARGET constant for logging
tiagobndr Jun 4, 2025
5665007
fix: update prdoc
tiagobndr Jun 4, 2025
5333e1f
chore: narrow IXcm import to IXcmCalls
tiagobndr Jun 4, 2025
c87d86e
refactor: introduce revert macro to standardize error logging
tiagobndr Jun 4, 2025
97f58bf
refactor: set ALICE as default mapped account in the genesis config
tiagobndr Jun 4, 2025
c141c83
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 4, 2025
9a1ec3a
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 4, 2025
fd8fccb
chore: use a function instead of a macro to revert
tiagobndr Jun 5, 2025
8a435b8
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jun 5, 2025
047d8b5
fix: CI
tiagobndr Jun 5, 2025
43c3a7d
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 5, 2025
ea843df
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
franciscoaguirre Jun 5, 2025
ac19567
fix: export ALICE from mock network instead
tiagobndr Jun 5, 2025
3b9ac22
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli Jun 6, 2025
a0cbd43
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
sphamjoli Jun 7, 2025
faceac5
fix(xcm-precompile): small weight fix
franciscoaguirre Jun 10, 2025
115ac42
fix: fmt
franciscoaguirre Jun 10, 2025
84f40f7
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
tiagobndr Jun 11, 2025
d5a5f66
Merge branch 'master' into tb/integ_xcm_precompile_pallet_xcm
athei Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
use pallet_assets::precompiles::{InlineIdConfig, ERC20};
use pallet_nfts::{DestroyWitness, PalletFeatures};
use pallet_revive::evm::runtime::EthExtra;
use pallet_xcm::EnsureXcm;
use pallet_xcm::{precompiles::XcmPrecompile, EnsureXcm};
use parachains_common::{
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
Expand Down Expand Up @@ -1080,6 +1080,7 @@ impl pallet_revive::Config for Runtime {
type Precompiles = (
ERC20<Self, InlineIdConfig<0x120>, TrustBackedAssetsInstance>,
ERC20<Self, InlineIdConfig<0x320>, PoolAssetsInstance>,
XcmPrecompile<Self>,
);
type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
9 changes: 9 additions & 0 deletions polkadot/runtime/rococo/src/weights/pallet_xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
9 changes: 9 additions & 0 deletions polkadot/runtime/westend/src/weights/pallet_xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,13 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
8 changes: 8 additions & 0 deletions polkadot/xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ tracing = { workspace = true }

frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-revive = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }

pallet-timestamp = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
Expand All @@ -49,6 +51,8 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-revive/std",
"pallet-timestamp/std",
"scale-info/std",
"serde",
"sp-core/std",
Expand All @@ -66,6 +70,8 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-revive/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand All @@ -80,6 +86,8 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/try-runtime",
"pallet-revive/try-runtime",
"pallet-timestamp/try-runtime",
"polkadot-runtime-parachains/try-runtime",
"sp-runtime/try-runtime",
]
16 changes: 15 additions & 1 deletion polkadot/xcm/pallet-xcm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::*;
use frame_benchmarking::v2::*;
use frame_support::{assert_ok, weights::Weight};
use frame_system::RawOrigin;
use xcm::latest::prelude::*;
use xcm::{latest::prelude::*, MAX_INSTRUCTIONS_TO_DECODE};
use xcm_builder::EnsureDelivery;
use xcm_executor::traits::FeeReason;

Expand Down Expand Up @@ -680,6 +680,20 @@ mod benchmarks {
Ok(())
}

#[benchmark]
fn weigh_message() -> Result<(), BenchmarkError> {
let msg = Xcm(vec![ClearOrigin; MAX_INSTRUCTIONS_TO_DECODE.into()]);
let versioned_msg = VersionedXcm::from(msg);

#[block]
{
crate::Pallet::<T>::query_xcm_weight(versioned_msg)
.map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?;
}

Ok(())
}

impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext_with_balances(Vec::new()),
Expand Down
7 changes: 7 additions & 0 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
pub mod benchmarking;
#[cfg(test)]
mod mock;
pub mod precompiles;
#[cfg(test)]
mod tests;

Expand Down Expand Up @@ -107,6 +108,8 @@ pub trait WeightInfo {
fn claim_assets() -> Weight;
fn add_authorized_alias() -> Weight;
fn remove_authorized_alias() -> Weight;

fn weigh_message() -> Weight;
}

/// fallback implementation
Expand Down Expand Up @@ -199,6 +202,10 @@ impl WeightInfo for TestWeightInfo {
fn remove_authorized_alias() -> Weight {
Weight::from_parts(100_000, 0)
}

fn weigh_message() -> Weight {
Weight::from_parts(100_000, 0)
}
}

#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
Expand Down
32 changes: 31 additions & 1 deletion polkadot/xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ use xcm_executor::{
};
use xcm_simulator::helpers::derive_topic_id;

use crate::{self as pallet_xcm, TestWeightInfo};
use crate::{self as pallet_xcm, precompiles::XcmPrecompile, TestWeightInfo};
use pallet_timestamp;

pub type AccountId = AccountId32;
pub type Balance = u128;
Expand Down Expand Up @@ -139,6 +140,17 @@ pub mod pallet_test_notifier {
}
}

parameter_types! {
pub const MinimumPeriod: u64 = 1;
}

impl pallet_timestamp::Config for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type WeightInfo = ();
}

construct_runtime!(
pub enum Test
{
Expand All @@ -148,6 +160,8 @@ construct_runtime!(
ParasOrigin: origin,
XcmPallet: pallet_xcm,
TestNotifier: pallet_test_notifier,
Revive: pallet_revive,
Timestamp: pallet_timestamp,
}
);

Expand Down Expand Up @@ -320,6 +334,16 @@ impl pallet_assets::Config for Test {
type BenchmarkHelper = XcmBenchmarkHelper;
}

#[derive_impl(pallet_revive::config_preludes::TestDefaultConfig)]
impl pallet_revive::Config for Test {
type AddressMapper = pallet_revive::AccountId32Mapper<Self>;
type Currency = Balances;
type Precompiles = (XcmPrecompile<Self>,);
type Time = Timestamp;
type UploadOrigin = frame_system::EnsureSigned<AccountId>;
type InstantiateOrigin = frame_system::EnsureSigned<AccountId>;
}

// This child parachain is a system parachain trusted to teleport native token.
pub const SOME_SYSTEM_PARA: u32 = 1001;

Expand Down Expand Up @@ -717,6 +741,8 @@ pub(crate) fn buy_limited_execution<C>(
BuyExecution { fees: fees.into(), weight_limit }
}

pub const ALICE: AccountId32 = AccountId::new([0u8; 32]);

pub(crate) fn new_test_ext_with_balances(
balances: Vec<(AccountId, Balance)>,
) -> sp_io::TestExternalities {
Expand All @@ -741,6 +767,10 @@ pub(crate) fn new_test_ext_with_balances_and_xcm_version(
.assimilate_storage(&mut t)
.unwrap();

pallet_revive::GenesisConfig::<Test> { mapped_accounts: vec![ALICE] }
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
Expand Down
Loading