Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pallet_xcm_core_buyer #452

Merged
merged 23 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7806893
Implement pallet_xcm_core_buyer
tmpolaczyk Feb 29, 2024
568562d
Add more validations and more tests
tmpolaczyk Mar 13, 2024
f05db9b
zepter & toml-maid
tmpolaczyk Mar 13, 2024
0aa4e38
Make benchmarks compile
tmpolaczyk Mar 13, 2024
fdc5f1e
Implement and run benchmarks
tmpolaczyk Mar 14, 2024
824ab4c
Change account derivation and store XCM weights in pallet storage
tmpolaczyk Mar 14, 2024
dd5f5ce
Add set_xcm_weights benchmark
tmpolaczyk Mar 15, 2024
396b791
typescript-api
tmpolaczyk Mar 15, 2024
2f36563
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 15, 2024
69cd633
toml-maid
tmpolaczyk Mar 15, 2024
4cc6262
Add docs, use XCM reanchor, use ParaId::into_account_truncating
tmpolaczyk Mar 18, 2024
d69e4f1
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 18, 2024
efff20f
PR comments
tmpolaczyk Mar 19, 2024
71a6dbd
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 19, 2024
8a09a2d
Add typescript tests
tmpolaczyk Mar 19, 2024
5623627
fmt
tmpolaczyk Mar 19, 2024
cfc4a3f
Create tanssi-relay-encoder crate
tmpolaczyk Mar 20, 2024
3bfce07
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 20, 2024
128bc1c
Add westend encoded call and allow configuring relay chain
tmpolaczyk Mar 20, 2024
efb6837
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 21, 2024
7c01f66
Fix unused import
tmpolaczyk Mar 21, 2024
00a4c51
Merge remote-tracking branch 'origin/master' into tomasz-xcm-coretime
tmpolaczyk Mar 22, 2024
e9db42a
typescript-api
tmpolaczyk Mar 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
370 changes: 199 additions & 171 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pallet-registrar = { path = "pallets/registrar", default-features = false }
pallet-registrar-runtime-api = { path = "pallets/registrar/rpc/runtime-api", default-features = false }
pallet-services-payment = { path = "pallets/services-payment", default-features = false }
pallet-stream-payment = { path = "pallets/stream-payment", default-features = false }
pallet-xcm-core-buyer = { path = "pallets/xcm-core-buyer", default-features = false }

container-chain-template-frontier-runtime = { path = "container-chains/templates/frontier/runtime", default-features = false }
container-chain-template-simple-runtime = { path = "container-chains/templates/simple/runtime", default-features = false }
Expand Down Expand Up @@ -200,6 +201,8 @@ polkadot-runtime-parachains = { git = "https://github.com/moondance-labs/polkado
staging-xcm = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
staging-xcm-builder = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
staging-xcm-executor = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
rococo-runtime = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
rococo-runtime-constants = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
westend-runtime = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }
westend-runtime-constants = { git = "https://github.com/moondance-labs/polkadot-sdk", branch = "tanssi-polkadot-v1.6.0", default-features = false }

Expand Down
14 changes: 0 additions & 14 deletions pallets/services-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

//! # Author Noting Pallet
//!
//! This pallet notes the author of the different containerChains that have registered:
//!
//! The set of container chains is retrieved thanks to the GetContainerChains trait
//! For each containerChain, we inspect the Header stored in the relayChain as
//! a generic header. This is the first requirement for containerChains.
//!
//! The second requirement is that an Aura digest with the slot number for the containerChains
//! needs to exist
//!
//! Using those two requirements we can select who the author was based on the collators assigned
//! to that containerChain, by simply assigning the slot position.

//! # Services Payment pallet
//!
//! This pallet allows for block creation services to be paid for by a
Expand Down
14 changes: 0 additions & 14 deletions pallets/services-payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

//! # Author Noting Pallet
//!
//! This pallet notes the author of the different containerChains that have registered:
//!
//! The set of container chains is retrieved thanks to the GetContainerChains trait
//! For each containerChain, we inspect the Header stored in the relayChain as
//! a generic header. This is the first requirement for containerChains.
//!
//! The second requirement is that an Aura digest with the slot number for the containerChains
//! needs to exist
//!
//! Using those two requirements we can select who the author was based on the collators assigned
//! to that containerChain, by simply assigning the slot position.

use {
crate::{
self as pallet_services_payment, ProvideBlockProductionCost, ProvideCollatorAssignmentCost,
Expand Down
14 changes: 0 additions & 14 deletions pallets/services-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

//! # Author Noting Pallet
//!
//! This pallet notes the author of the different containerChains that have registered:
//!
//! The set of container chains is retrieved thanks to the GetContainerChains trait
//! For each containerChain, we inspect the Header stored in the relayChain as
//! a generic header. This is the first requirement for containerChains.
//!
//! The second requirement is that an Aura digest with the slot number for the containerChains
//! needs to exist
//!
//! Using those two requirements we can select who the author was based on the collators assigned
//! to that containerChain, by simply assigning the slot position.

use {
crate::{
mock::*, pallet as pallet_services_payment, BlockProductionCredits,
Expand Down
81 changes: 81 additions & 0 deletions pallets/xcm-core-buyer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[package]
name = "pallet-xcm-core-buyer"
authors = { workspace = true }
description = "Allows collators to buy parathread cores on demand"
edition = "2021"
license = "GPL-3.0-only"
version = "0.1.0"

[package.metadata.docs.rs]
targets = [ "x86_64-unknown-linux-gnu" ]

[dependencies]

dp-core = { workspace = true }
log = { workspace = true }
serde = { workspace = true, optional = true }
tp-traits = { workspace = true }

# Polkadot
staging-xcm = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

# Nimbus
nimbus-primitives = { workspace = true }

[dev-dependencies]
bounded-collections = { workspace = true }
num-traits = { workspace = true }
pallet-balances = { workspace = true, features = [ "std" ] }
similar-asserts = { workspace = true }
sp-io = { workspace = true, features = [ "std" ] }

[features]
default = [ "std" ]
std = [
"bounded-collections/std",
"dp-core/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
"nimbus-primitives/std",
"pallet-balances/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"serde?/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"tp-traits/std",
"staging-xcm/std"
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"nimbus-primitives/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"tp-traits/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"nimbus-primitives/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
60 changes: 60 additions & 0 deletions pallets/xcm-core-buyer/src/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (C) Moondance Labs Ltd.
// This file is part of Tanssi.

// Tanssi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Tanssi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

#![cfg(feature = "runtime-benchmarks")]

//! Benchmarking
use {
crate::{Call, Config, Pallet},
frame_benchmarking::v2::*,
frame_support::{
traits::{EnsureOriginWithArg, OriginTrait},
BoundedVec,
},
frame_system::RawOrigin,
sp_std::vec,
tp_traits::ParaId,
};

#[benchmarks]
mod benchmarks {
use super::*;

// TODO
#[benchmark]
fn set_boot_nodes(x: Linear<1, 200>, y: Linear<1, 10>) {
// x: url len, y: num boot_nodes
let boot_nodes = BoundedVec::try_from(vec![
BoundedVec::try_from(vec![b'A'; x as usize])
.unwrap();
y as usize
])
.unwrap();
let para_id = ParaId::from(2);
let origin = T::SetBootNodesOrigin::try_successful_origin(&para_id)
.expect("failed to create SetBootNodesOrigin");
// Worst case is when caller is not root
let raw_origin = origin.as_system_ref();
assert!(matches!(raw_origin, Some(RawOrigin::Signed(..))));

#[extrinsic_call]
Pallet::<T>::set_boot_nodes(origin as T::RuntimeOrigin, para_id, boot_nodes.clone());

assert_eq!(Pallet::<T>::boot_nodes(&para_id), boot_nodes);
}

impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
}
Loading
Loading