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 umbrella crate for minimal template #5155

Merged
merged 59 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
275b4d3
Use umbrella crate for minimal template
pgherveou Jul 26, 2024
6630adc
Add missing cargo changes
pgherveou Jul 26, 2024
93d6364
format cargo.toml with taplo
pgherveou Jul 26, 2024
694294d
Update cargo.toml formatting (2)
pgherveou Jul 26, 2024
a7c49f0
remove minimal/Cargo.toml
pgherveou Jul 26, 2024
b6d704d
Update cargo.toml
pgherveou Jul 26, 2024
64910cf
Add experimental feature flag
pgherveou Jul 26, 2024
1ef3029
Fix minimal template pallet::config check
pgherveou Jul 28, 2024
59167aa
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
pgherveou Jul 28, 2024
d96d3b2
a few fixes from kian
kianenigma Aug 13, 2024
4341776
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 13, 2024
8cea3d8
fix toml
kianenigma Aug 13, 2024
122d3f2
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 14, 2024
ce2238c
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 15, 2024
0cdcdcf
Merge branch 'master' of github.com:paritytech/polkadot-sdk into pg/u…
kianenigma Aug 15, 2024
472c7d9
fix and prdoc
kianenigma Aug 15, 2024
24d5e5c
Merge branch 'pg/use-umbrella-crate-for-minimal-template' of github.c…
kianenigma Aug 15, 2024
903ab6f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into pg/u…
kianenigma Aug 16, 2024
4a4e46a
docs
kianenigma Aug 16, 2024
53fa677
fix feature
kianenigma Aug 16, 2024
24cf78c
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 16, 2024
e9cbcb3
Test fix CI clippy job
pgherveou Aug 20, 2024
525abf6
Tweak experimental flag for tests
pgherveou Aug 20, 2024
4a60415
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
pgherveou Aug 20, 2024
9b71984
Fix clippy
pgherveou Aug 21, 2024
ea08cc2
Fix clippy 2
pgherveou Aug 21, 2024
4867813
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
pgherveou Aug 21, 2024
9f60b3a
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 21, 2024
9867d6b
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 22, 2024
3e5f624
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 23, 2024
6a9ad9e
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
pgherveou Aug 23, 2024
3f88968
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 23, 2024
09fd0a5
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 25, 2024
055ee73
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 26, 2024
9076909
use no-default-features for anyhow
pgherveou Aug 26, 2024
e987766
taplo fix
pgherveou Aug 26, 2024
0f5e103
fix revive
pgherveou Aug 26, 2024
6093140
Do not add pallet-contracts when arch = riscv
pgherveou Aug 26, 2024
5d270ac
fixed anyhow dep
pgherveou Aug 26, 2024
3ede08d
Fix prdoc
pgherveou Aug 26, 2024
69968aa
Patch generate-umbrella for crate that do not support riscv
pgherveou Aug 26, 2024
7b1d5e6
Add missing pallet prdoc complains about
pgherveou Aug 26, 2024
bb7f6f9
add missing :
pgherveou Aug 26, 2024
2829fc5
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 26, 2024
3bc01aa
fix fmt
pgherveou Aug 26, 2024
69d998e
fix missing default features
pgherveou Aug 26, 2024
f87dd47
Revert "fix missing default features"
pgherveou Aug 27, 2024
1dc603d
Update Cargo.toml
pgherveou Aug 27, 2024
5928b87
fixes
pgherveou Aug 27, 2024
f6c0d2b
fix
pgherveou Aug 27, 2024
4f4256a
Rollback changes and update polkadot-sdk feature flags
pgherveou Aug 27, 2024
6c3f759
Update substrate/frame/revive/src/wasm/runtime.rs
pgherveou Aug 27, 2024
6fc20c3
rollback package.metadata.polkadot-sdk changes
pgherveou Aug 27, 2024
4677583
use runtime-full instead of runtime
pgherveou Aug 27, 2024
7031a43
Update umbrella
pgherveou Aug 27, 2024
80f4dd0
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
kianenigma Aug 27, 2024
5eff776
Update features runtime
pgherveou Aug 27, 2024
bb30654
Merge branch 'master' into pg/use-umbrella-crate-for-minimal-template
pgherveou Aug 28, 2024
fac0344
Update Cargo.lock
pgherveou Aug 28, 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
36 changes: 3 additions & 33 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 @@ -32,10 +32,7 @@ use frame::{
runtime,
},
prelude::*,
runtime::{
apis::{self, impl_runtime_apis, ExtrinsicInclusionMode},
prelude::*,
},
runtime::{apis, prelude::*},
};
use sp_genesis_builder::PresetId;

Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_5155.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Use umbrella crate for minimal template

doc:
- audience: Runtime Dev
description: |
Minor additions to the `polkadot-sdk-frame` crate and making it ready for usage in more templates. This PR already integrates it in the minimal template.


crates:
- name: polkadot-sdk-frame
bump: patch
27 changes: 20 additions & 7 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,34 @@ pub mod runtime {
pub use frame_executive::*;

/// Macro to amalgamate the runtime into `struct Runtime`.
///
/// Consider using the new version of this [`frame_construct_runtime`].
pub use frame_support::construct_runtime;

/// Macro to amalgamate the runtime into `struct Runtime`.
///
/// This is the newer version of [`construct_runtime`].
pub use frame_support::runtime as frame_construct_runtime;

/// Macro to easily derive the `Config` trait of various pallet for `Runtime`.
pub use frame_support::derive_impl;

/// Macros to easily impl traits such as `Get` for types.
// TODO: using linking in the Get in the line above triggers an ICE :/
pub use frame_support::{ord_parameter_types, parameter_types};

/// For building genesis config.
pub use frame_support::genesis_builder_helper::{build_state, get_preset};

/// Const types that can easily be used in conjuncture with `Get`.
pub use frame_support::traits::{
ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128, ConstU16,
ConstU32, ConstU64, ConstU8,
};

/// Used for simple fee calculation.
pub use frame_support::weights::{self, FixedFee, NoFee};

/// Primary types used to parameterize `EnsureOrigin` and `EnsureRootWithArg`.
pub use frame_system::{
EnsureNever, EnsureNone, EnsureRoot, EnsureRootWithSuccess, EnsureSigned,
Expand All @@ -201,11 +214,16 @@ pub mod runtime {
/// Types to define your runtime version.
pub use sp_version::{create_runtime_str, runtime_version, RuntimeVersion};

#[cfg(feature = "std")]
pub use sp_version::NativeVersion;

/// Macro to implement runtime APIs.
pub use sp_api::impl_runtime_apis;

#[cfg(feature = "std")]
pub use sp_version::NativeVersion;
// Types often used in the runtime APIs.
pub use sp_core::OpaqueMetadata;
pub use sp_inherents::{CheckInherentsResult, InherentData};
pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode};
}

/// Types and traits for runtimes that implement runtime APIs.
Expand All @@ -223,11 +241,6 @@ pub mod runtime {
// moved to file similarly.
#[allow(ambiguous_glob_reexports)]
pub mod apis {
// Types often used in the runtime APIs.
pub use sp_core::OpaqueMetadata;
pub use sp_inherents::{CheckInherentsResult, InherentData};
pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode};

pub use frame_system_rpc_runtime_api::*;
pub use sp_api::{self, *};
pub use sp_block_builder::*;
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: maybe this can be rolled back as well

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use frame_support::derive_impl;

mod common;

use common::outer_enums::{pallet, pallet2};

pub type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, RuntimeCall, (), ()>;
Expand Down Expand Up @@ -75,8 +73,10 @@ frame_support::construct_runtime!(
}
);

#[cfg(feature = "experimental")]
#[test]
fn module_error_outer_enum_expand_explicit() {
use common::outer_enums::{pallet, pallet2};
// The Runtime has *all* parts explicitly defined.

// Check that all error types are propagated
Expand All @@ -90,9 +90,7 @@ fn module_error_outer_enum_expand_explicit() {
frame_system::Error::NonZeroRefCount => (),
frame_system::Error::CallFiltered => (),
frame_system::Error::MultiBlockMigrationsOngoing => (),
#[cfg(feature = "experimental")]
frame_system::Error::InvalidTask => (),
#[cfg(feature = "experimental")]
frame_system::Error::FailedTask => (),
frame_system::Error::NothingAuthorized => (),
frame_system::Error::Unauthorized => (),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use frame_support::derive_impl;

mod common;

use common::outer_enums::{pallet, pallet2};

pub type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, RuntimeCall, (), ()>;
Expand Down Expand Up @@ -75,8 +73,10 @@ frame_support::construct_runtime!(
}
);

#[cfg(feature = "experimental")]
#[test]
fn module_error_outer_enum_expand_implicit() {
use common::outer_enums::{pallet, pallet2};
// The Runtime has *all* parts implicitly defined.

// Check that all error types are propagated
Expand All @@ -90,9 +90,7 @@ fn module_error_outer_enum_expand_implicit() {
frame_system::Error::NonZeroRefCount => (),
frame_system::Error::CallFiltered => (),
frame_system::Error::MultiBlockMigrationsOngoing => (),
#[cfg(feature = "experimental")]
frame_system::Error::InvalidTask => (),
#[cfg(feature = "experimental")]
frame_system::Error::FailedTask => (),
frame_system::Error::NothingAuthorized => (),
frame_system::Error::Unauthorized => (),
Expand Down
34 changes: 3 additions & 31 deletions templates/minimal/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,15 @@ futures-timer = { workspace = true }
jsonrpsee = { features = ["server"], workspace = true }
serde_json = { workspace = true, default-features = true }

sc-cli = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sc-transaction-pool = { workspace = true, default-features = true }
sc-transaction-pool-api = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-consensus-manual-seal = { workspace = true, default-features = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-basic-authorship = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }

sp-timestamp = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
sp-api = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }

substrate-frame-rpc-system = { workspace = true, default-features = true }

# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
# certainly no dependency on the runtime.
frame = { features = [
"experimental",
"runtime",
], workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["experimental", "node"] }
minimal-template-runtime = { workspace = true }

[build-dependencies]
substrate-build-script-utils = { workspace = true, default-features = true }
polkadot-sdk = { workspace = true, features = ["substrate-build-script-utils"] }
kianenigma marked this conversation as resolved.
Show resolved Hide resolved

[features]
default = ["std"]
std = [
"minimal-template-runtime/std",
"polkadot-sdk/std",
]
2 changes: 1 addition & 1 deletion templates/minimal/node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

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
9 changes: 6 additions & 3 deletions templates/minimal/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
// limitations under the License.

use minimal_template_runtime::{BalancesConfig, SudoConfig, WASM_BINARY};
use sc_service::{ChainType, Properties};
use polkadot_sdk::{
sc_service::{ChainType, Properties},
sp_keyring::AccountKeyring,
*,
};
use serde_json::{json, Value};
use sp_keyring::AccountKeyring;

/// This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec;
Expand All @@ -42,8 +45,8 @@ pub fn development_config() -> Result<ChainSpec, String> {

/// Configure initial storage state for FRAME pallets.
fn testnet_genesis() -> Value {
use frame::traits::Get;
use minimal_template_runtime::interface::{Balance, MinimumBalance};
use polkadot_sdk::polkadot_sdk_frame::traits::Get;
let endowment = <MinimumBalance as Get<Balance>>::get().max(1) * 1000;
let balances = AccountKeyring::iter()
.map(|a| (a.to_account_id(), endowment))
Expand Down
2 changes: 1 addition & 1 deletion templates/minimal/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use sc_cli::RunCmd;
use polkadot_sdk::{sc_cli::RunCmd, *};

#[derive(Debug, Clone)]
pub enum Consensus {
Expand Down
3 changes: 1 addition & 2 deletions templates/minimal/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
use polkadot_sdk::{sc_cli::SubstrateCli, sc_service::PartialComponents, *};

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down
2 changes: 1 addition & 1 deletion templates/minimal/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ mod command;
mod rpc;
mod service;

fn main() -> sc_cli::Result<()> {
fn main() -> polkadot_sdk::sc_cli::Result<()> {
command::run()
}
11 changes: 7 additions & 4 deletions templates/minimal/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@

use jsonrpsee::RpcModule;
use minimal_template_runtime::interface::{AccountId, Nonce, OpaqueBlock};
use sc_transaction_pool_api::TransactionPool;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use polkadot_sdk::{
sc_transaction_pool_api::TransactionPool,
sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
*,
};
use std::sync::Arc;

pub use sc_rpc_api::DenyUnsafe;
pub use polkadot_sdk::sc_rpc_api::DenyUnsafe;

/// Full client dependencies.
pub struct FullDeps<C, P> {
Expand Down Expand Up @@ -57,7 +60,7 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{System, SystemApiServer};
use polkadot_sdk::substrate_frame_rpc_system::{System, SystemApiServer};
let mut module = RpcModule::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

Expand Down
15 changes: 9 additions & 6 deletions templates/minimal/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

use futures::FutureExt;
use minimal_template_runtime::{interface::OpaqueBlock as Block, RuntimeApi};
use sc_client_api::backend::Backend;
use sc_executor::WasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_runtime::traits::Block as BlockT;
use polkadot_sdk::{
sc_client_api::backend::Backend,
sc_executor::WasmExecutor,
sc_service::{error::Error as ServiceError, Configuration, TaskManager},
sc_telemetry::{Telemetry, TelemetryWorker},
sc_transaction_pool_api::OffchainTransactionPoolFactory,
sp_runtime::traits::Block as BlockT,
*,
};
use std::sync::Arc;

use crate::cli::Consensus;
Expand Down
14 changes: 5 additions & 9 deletions templates/minimal/pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ publish = false
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = [
"derive",
], workspace = true }
scale-info = { features = [
"derive",
], workspace = true }
frame = { features = [
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
polkadot-sdk = { workspace = true, default-features = false, features = [
"experimental",
"runtime",
], workspace = true }
] }


[features]
default = ["std"]
std = ["codec/std", "frame/std", "scale-info/std"]
std = ["codec/std", "polkadot-sdk/std", "scale-info/std"]
Loading
Loading