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

Use the umbrella crate for the parachain template #5991

Merged
merged 14 commits into from
Oct 14, 2024
96 changes: 3 additions & 93 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion substrate/frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,10 @@ pub mod pallet_prelude {
pub use scale_info::TypeInfo;
pub use sp_inherents::MakeFatalError;
pub use sp_runtime::{
traits::{MaybeSerializeDeserialize, Member, ValidateUnsigned},
traits::{
CheckedAdd, CheckedConversion, CheckedDiv, CheckedMul, CheckedShl, CheckedShr,
CheckedSub, MaybeSerializeDeserialize, Member, One, ValidateUnsigned, Zero,
},
transaction_validity::{
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource,
TransactionTag, TransactionValidity, TransactionValidityError, UnknownTransaction,
Expand Down
68 changes: 7 additions & 61 deletions templates/parachain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ edition.workspace = true
publish = false
build = "build.rs"

# [[bin]]
# name = "parachain-template-node"

[dependencies]
clap = { features = ["derive"], workspace = true }
log = { workspace = true, default-features = true }
Expand All @@ -22,82 +19,31 @@ jsonrpsee = { features = ["server"], workspace = true }
futures = { workspace = true }
serde_json = { workspace = true, default-features = true }
docify = { workspace = true }
color-print = { workspace = true }

polkadot-sdk = { workspace = true, features = ["node"] }

# Local
parachain-template-runtime = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, default-features = true }
frame-benchmarking-cli = { workspace = true, default-features = true }
pallet-transaction-payment-rpc = { workspace = true, default-features = true }
sc-basic-authorship = { workspace = true, default-features = true }
sc-chain-spec = { workspace = true, default-features = true }
sc-cli = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sc-sysinfo = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sc-tracing = { workspace = true, default-features = true }
sc-transaction-pool = { workspace = true, default-features = true }
sc-transaction-pool-api = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-consensus-aura = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-genesis-builder = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-timestamp = { workspace = true, default-features = true }
substrate-frame-rpc-system = { workspace = true, default-features = true }
prometheus-endpoint = { workspace = true, default-features = true }

# Polkadot
polkadot-cli = { features = ["rococo-native"], workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
xcm = { workspace = true }

# Cumulus
cumulus-client-cli = { workspace = true, default-features = true }
cumulus-client-collator = { workspace = true, default-features = true }
cumulus-client-consensus-aura = { workspace = true, default-features = true }
cumulus-client-consensus-common = { workspace = true, default-features = true }
cumulus-client-consensus-proposer = { workspace = true, default-features = true }
cumulus-client-service = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }
cumulus-primitives-parachain-inherent = { workspace = true, default-features = true }
cumulus-relay-chain-interface = { workspace = true, default-features = true }
color-print = { workspace = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }

[features]
default = ["std"]
std = [
"log/std",
"parachain-template-runtime/std",
"xcm/std",
"polkadot-sdk/std",
]
runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"parachain-template-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"polkadot-sdk/runtime-benchmarks",
]
try-runtime = [
"parachain-template-runtime/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
"polkadot-sdk/try-runtime",
]
2 changes: 1 addition & 1 deletion templates/parachain/node/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
use polkadot_sdk::substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys();
Expand Down
2 changes: 2 additions & 0 deletions templates/parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use polkadot_sdk::*;

use parachain_template_runtime as runtime;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
Expand Down
1 change: 1 addition & 0 deletions templates/parachain/node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use polkadot_sdk::*;
use std::path::PathBuf;

/// Sub-commands supported by the collator.
Expand Down
2 changes: 2 additions & 0 deletions templates/parachain/node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use polkadot_sdk::*;

use cumulus_client_service::storage_proof_size::HostFunctions as ReclaimHostFunctions;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
Expand Down
2 changes: 2 additions & 0 deletions templates/parachain/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#![warn(missing_docs)]

use polkadot_sdk::*;

mod chain_spec;
mod cli;
mod command;
Expand Down
2 changes: 2 additions & 0 deletions templates/parachain/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use std::sync::Arc;

use parachain_template_runtime::{opaque::Block, AccountId, Balance, Nonce};

use polkadot_sdk::*;

use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand Down
4 changes: 3 additions & 1 deletion templates/parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
// std
use std::{sync::Arc, time::Duration};

use cumulus_client_cli::CollatorOptions;
// Local Runtime Types
use parachain_template_runtime::{
apis::RuntimeApi,
opaque::{Block, Hash},
};

use polkadot_sdk::*;

// Cumulus Imports
use cumulus_client_cli::CollatorOptions;
use cumulus_client_collator::service::CollatorService;
#[docify::export(lookahead_collator)]
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
Expand Down
47 changes: 9 additions & 38 deletions templates/parachain/pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,16 @@ publish = false
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = [
"derive",
], workspace = true }
scale-info = { features = [
"derive",
], workspace = true }
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }

# frame deps
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }

# primitive deps
sp-runtime = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
frame = { workspace = true, default-features = false, features = [
"experimental",
"runtime",
] }

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
std = [
"codec/std",
"scale-info/std",

"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",

"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
runtime-benchmarks = ["frame/runtime-benchmarks"]
std = ["codec/std", "frame/std", "scale-info/std"]
try-runtime = ["frame/try-runtime"]
2 changes: 1 addition & 1 deletion templates/parachain/pallets/template/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Benchmarking setup for pallet-template

use super::*;
use frame_benchmarking::v2::*;
use frame::{deps::frame_benchmarking::v2::*, prelude::*};

#[benchmarks]
mod benchmarks {
Expand Down
8 changes: 2 additions & 6 deletions templates/parachain/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@ mod benchmarking;
// To see a full list of `pallet` macros and their use cases, see:
// <https://paritytech.github.io/polkadot-sdk/master/pallet_example_kitchensink/index.html>
// <https://paritytech.github.io/polkadot-sdk/master/frame_support/pallet_macros/index.html>
#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*, DefaultNoBound};
use frame_system::pallet_prelude::*;
use sp_runtime::traits::{CheckedAdd, One};
use frame::prelude::*;

/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
pub trait Config: frame_system::Config {
/// Because this pallet emits events, it depends on the runtime's definition of an event.
/// <https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_runtime_types/index.html>
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// A type representing the weights required by the dispatchables of this pallet.
Expand Down
Loading
Loading