Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d4570a0
feat(xcm): add XcmPaymentApi and DryRunApi to all runtimes
franciscoaguirre Jun 25, 2024
c44c69f
fix: fmt
franciscoaguirre Jul 12, 2024
2e748fb
feat(coretime-kusama-runtime): add XcmPaymentApi and DryRunApi
franciscoaguirre Jun 26, 2024
ee2e870
fix: fmt
franciscoaguirre Jul 12, 2024
555eb1a
fix(encointer): AssetId -> XcmAssetId
franciscoaguirre Jul 12, 2024
f1cf7f9
feat(xcm-fee-payment-runtime-api): update Cargo.lock
franciscoaguirre Jul 12, 2024
7d867b5
fix(kusama-runtime): feature propagation
franciscoaguirre Jul 12, 2024
6b05e7d
doc: update CHANGELOG
franciscoaguirre Jun 25, 2024
5e3e2db
doc: update CHANGELOG
franciscoaguirre Jul 12, 2024
138c5cc
test(asset-hub-polkadot): add XCM fee estimation test (not working)
franciscoaguirre Jul 12, 2024
5fbe49a
fix(asset-hub-polkadot-integration-tests): reverse order A -> B to B …
franciscoaguirre Jul 15, 2024
57df088
fix: fmt
franciscoaguirre Jul 15, 2024
d464252
feat(asset-hub-kusama-integration-tests): add test for XCM fee estima…
franciscoaguirre Jul 15, 2024
4a53b10
chore: address feedback
franciscoaguirre Jul 15, 2024
1c215b1
feat(integration-tests-helpers): use XCM runtime apis to estimate del…
franciscoaguirre Jul 15, 2024
7a2fd64
feat(integration-tests-helpers): use XCM runtime apis to estimate del…
franciscoaguirre Jul 15, 2024
5aa919a
fix: fmt
franciscoaguirre Jul 15, 2024
181b9d4
feat(people): add delivery fees
franciscoaguirre Jul 16, 2024
e59f4a1
feat(people-kusama-integration-tests): teleport tests with delivery fees
franciscoaguirre Jul 16, 2024
708aa26
revert(people): delivery fees
franciscoaguirre Jul 16, 2024
0d1794c
fix: fmt
franciscoaguirre Jul 16, 2024
92ff22c
feat(people-polkadot): teleport test with delivery fees
franciscoaguirre Jul 16, 2024
ffc6c1b
feat(coretime-kusama-integration-tests): initial setup and test
franciscoaguirre Jul 16, 2024
c1cc4c3
fix: fmt
franciscoaguirre Jul 16, 2024
59ed358
feat(bridge-hub-kusama-integration-tests): teleport test with deliver…
franciscoaguirre Jul 16, 2024
9b22b37
feat(bridge-hub-polkadot-integration-tests): add teleport test with d…
franciscoaguirre Jul 16, 2024
55b5191
WIP
franciscoaguirre Jul 17, 2024
5068ea7
Merge branch 'main' into xcm-runtime-apis
franciscoaguirre Jul 22, 2024
79a8340
Merge branch 'xcm-runtime-apis' of github.com:franciscoaguirre/polkad…
franciscoaguirre Jul 22, 2024
899dcd7
fix: fmt
franciscoaguirre Jul 22, 2024
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
Prev Previous commit
Next Next commit
feat(coretime-kusama-runtime): add XcmPaymentApi and DryRunApi
  • Loading branch information
franciscoaguirre committed Jul 12, 2024
commit 2e748fb4b97386da74b9f5eda1e2eda8b52bc835
1 change: 1 addition & 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 @@ -105,6 +105,12 @@ pub type LocationToAccountId = (
GlobalConsensusEthereumConvertsFor<AccountId>,
);

#[test]
fn convert_hydradx_location_to_account_id() {
let location = Location::new(1, [Parachain(2034)]);
dbg!(&LocationToAccountId::convert_location(&location));
}

/// Means for transacting the native currency on this chain.
pub type FungibleTransactor = FungibleAdapter<
// Use this currency:
Expand Down
3 changes: 3 additions & 0 deletions system-parachains/coretime/coretime-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -147,6 +148,7 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"xcm-fee-payment-runtime-api/std",
]

runtime-benchmarks = [
Expand Down Expand Up @@ -175,6 +177,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
]

try-runtime = [
Expand Down
50 changes: 48 additions & 2 deletions system-parachains/coretime/coretime-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use frame_support::{
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, Contains,
EitherOfDiverse, EverythingBut, InstanceFilter, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
weights::{ConstantMultiplier, Weight, WeightToFee as _},
PalletId,
};
use frame_system::{
Expand Down Expand Up @@ -72,7 +72,11 @@ use system_parachains_constants::{
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::latest::prelude::*;
use xcm::prelude::*;
use xcm_fee_payment_runtime_api::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};
use xcm_config::{
FellowshipLocation, GovernanceLocation, KsmRelayLocation, StakingPot,
XcmOriginToTransactDispatchOrigin,
Expand Down Expand Up @@ -796,6 +800,48 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
let acceptable_assets = vec![AssetId(xcm_config::KsmRelayLocation::get())];
PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
match asset.try_as::<AssetId>() {
Ok(asset_id) if asset_id.0 == xcm_config::KsmRelayLocation::get() => {
// for native token
Ok(WeightToFee::weight_to_fee(&weight))
},
Ok(asset_id) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");
Err(XcmPaymentApiError::AssetNotFound)
},
Err(_) => {
log::trace!(target: "xcm::xcm_fee_payment_runtime_api", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");
Err(XcmPaymentApiError::VersionedConversionFailed)
}
}
}

fn query_xcm_weight(message: VersionedXcm<()>) -> Result<Weight, XcmPaymentApiError> {
PolkadotXcm::query_xcm_weight(message)
}

fn query_delivery_fees(destination: VersionedLocation, message: VersionedXcm<()>) -> Result<VersionedAssets, XcmPaymentApiError> {
PolkadotXcm::query_delivery_fees(destination, message)
}
}

impl xcm_fee_payment_runtime_api::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
}
}

impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {
fn collect_collation_info(header: &<Block as BlockT>::Header) -> cumulus_primitives_core::CollationInfo {
ParachainSystem::collect_collation_info(header)
Expand Down