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

Construct Runtime v2 #1378

Merged
merged 64 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
496bbac
Moves from older repo
gupnik Sep 4, 2023
cec8668
Adds disable_unsigned
gupnik Sep 5, 2023
73327a1
Fixes kitchensink build
gupnik Sep 5, 2023
40919d7
Merge branch 'master' into gupnik/crv2
gupnik Sep 5, 2023
99a43cf
Makes pallet_index mandatory
gupnik Sep 6, 2023
1467f0a
Adds UI Test
gupnik Sep 6, 2023
140e05f
Merge branch 'master' into gupnik/crv2
gupnik Sep 7, 2023
6568852
Adds UI Tests
gupnik Sep 11, 2023
2a70549
Minor CI fixes
gupnik Sep 11, 2023
6a59057
Merge branch 'master' into gupnik/crv2
gupnik Sep 11, 2023
9beb3ba
Adds more UI tests
gupnik Sep 12, 2023
88fa35a
Adds some docs
gupnik Sep 12, 2023
8ab5c66
Updates tests for construct_runtime_v2
gupnik Sep 13, 2023
977a553
Adds docs
gupnik Sep 13, 2023
c232d49
Merge branch 'master' into gupnik/crv2
gupnik Sep 13, 2023
df4fc3d
Minor update in doc
gupnik Sep 13, 2023
88fa662
Minor updates
gupnik Sep 13, 2023
a3d9319
Removes Todo
gupnik Sep 15, 2023
d5dd8ec
Merge branch 'master' into gupnik/crv2
gupnik Sep 15, 2023
e2ab4f6
Addresses review comments
gupnik Sep 18, 2023
ed2d9e9
Merge branch 'master' into gupnik/crv2
gupnik Sep 18, 2023
d1cd1a9
Update substrate/frame/support/procedural/src/construct_runtime_v2/mo…
gupnik Sep 19, 2023
2df5888
Update substrate/frame/support/procedural/src/construct_runtime_v2/ex…
gupnik Sep 19, 2023
51f1a70
Addresses review comment
gupnik Sep 19, 2023
996fefe
Uses type alias for pallets
gupnik Sep 25, 2023
fc3b765
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
Oct 12, 2023
0498dc4
Updates as per latest syntax
Oct 12, 2023
502fda4
Renames construct_runtime_v2 to runtime
Oct 12, 2023
e8b5371
Fixes kitchensink build
Oct 12, 2023
dcc0b60
Updates tests and docs
Oct 12, 2023
8a4b13c
fmt
Oct 12, 2023
1e44e9b
Minor fix
Oct 12, 2023
6660575
Minor fixes
Oct 12, 2023
9aa6aaf
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
gupnik Feb 3, 2024
985faef
Adds missing pallets in v2
gupnik Feb 3, 2024
5be682d
Fixes build and adds RuntimeTask support
gupnik Feb 8, 2024
aba35c6
Fixes test
gupnik Feb 8, 2024
7733d61
Adds task to tt_default_parts_v2
gupnik Feb 8, 2024
143ba02
Merge branch 'master' into gupnik/crv2
codeknix Feb 8, 2024
0774bca
Adds TaskExample in v2
gupnik Feb 8, 2024
2c17eda
Fixes UI Tests
gupnik Feb 9, 2024
61fb110
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
gupnik Feb 9, 2024
19db6d7
Updates docs
gupnik Feb 12, 2024
69a49a4
Adds legacy_ordering
gupnik Feb 12, 2024
dd1df58
Adds UI Test for legacy_ordering
gupnik Feb 13, 2024
c3c0be3
Fixes UT
gupnik Feb 13, 2024
a8fd228
Updates docs
gupnik Feb 13, 2024
044d106
Merge branch 'master' into gupnik/crv2
codeknix Feb 13, 2024
2f8b62c
".git/.scripts/commands/fmt/fmt.sh"
Feb 13, 2024
c779b74
Adds PrDoc
gupnik Feb 13, 2024
d1c976b
Merge branch 'gupnik/crv2' of github.com:paritytech/polkadot-sdk into…
gupnik Feb 13, 2024
1aac057
Minor fix
gupnik Feb 13, 2024
d150a5b
Updates docs
gupnik Feb 14, 2024
7ad4fc7
Update prdoc/pr_1378.prdoc
codeknix Feb 14, 2024
d22e45b
Addresses review comments
gupnik Feb 19, 2024
017bd41
Merge branch 'master' into gupnik/crv2
codeknix Feb 19, 2024
0aeb0f3
Fmt
gupnik Feb 19, 2024
a5401ed
Merge branch 'gupnik/crv2' of github.com:paritytech/polkadot-sdk into…
gupnik Feb 19, 2024
fcdb613
Merge branch 'master' into gupnik/crv2
codeknix Feb 27, 2024
761cedb
Incorporates changes for improved error reporting
gupnik Feb 27, 2024
e5c7f79
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gupn…
gupnik Mar 11, 2024
97a4425
Minor fix
gupnik Mar 11, 2024
29c2259
Feature gates under experimental
gupnik Mar 13, 2024
d71dbbc
Minor fix
gupnik Mar 13, 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
29 changes: 26 additions & 3 deletions substrate/bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,42 @@ impl pallet_template::Config for Runtime {
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub struct Runtime {
#[frame_support::construct_runtime_v2]
mod runtime {
#[frame::runtime]
pub struct Runtime;

#[frame::pallets]
#[frame::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId
)]
gupnik marked this conversation as resolved.
Show resolved Hide resolved
pub struct Pallets {
#[frame::pallet_index(0)]
System: frame_system,
#[frame::pallet_index(1)]
Timestamp: pallet_timestamp,
#[frame::pallet_index(2)]
Aura: pallet_aura,
#[frame::pallet_index(3)]
Grandpa: pallet_grandpa,
#[frame::pallet_index(4)]
Balances: pallet_balances,
#[frame::pallet_index(5)]
TransactionPayment: pallet_transaction_payment,
#[frame::pallet_index(6)]
Sudo: pallet_sudo,
// Include the custom logic from the pallet-template in the runtime.
#[frame::pallet_index(7)]
TemplateModule: pallet_template,
}
);
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
Expand Down
112 changes: 98 additions & 14 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use frame_election_provider_support::{
onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight,
};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
instances::{Instance1, Instance2},
ord_parameter_types,
Expand Down Expand Up @@ -2009,84 +2008,169 @@ impl pallet_broker::Config for Runtime {
type PriceAdapter = pallet_broker::Linear;
}

construct_runtime!(
pub struct Runtime
{
#[frame_support::construct_runtime_v2]
mod runtime {
#[frame::runtime]
pub struct Runtime;

#[frame::pallets]
#[frame::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId
)]
pub struct Pallets {
#[frame::pallet_index(0)]
gupnik marked this conversation as resolved.
Show resolved Hide resolved
System: frame_system,
#[frame::pallet_index(1)]
Utility: pallet_utility,
#[frame::pallet_index(2)]
Babe: pallet_babe,
#[frame::pallet_index(3)]
Timestamp: pallet_timestamp,
// Authorship must be before session in order to note author in the correct session and era
// for im-online and staking.
#[frame::pallet_index(4)]
Authorship: pallet_authorship,
#[frame::pallet_index(5)]
Indices: pallet_indices,
#[frame::pallet_index(6)]
Balances: pallet_balances,
#[frame::pallet_index(7)]
TransactionPayment: pallet_transaction_payment,
#[frame::pallet_index(8)]
AssetTxPayment: pallet_asset_tx_payment,
#[frame::pallet_index(9)]
AssetConversionTxPayment: pallet_asset_conversion_tx_payment,
#[frame::pallet_index(10)]
ElectionProviderMultiPhase: pallet_election_provider_multi_phase,
#[frame::pallet_index(11)]
Staking: pallet_staking,
#[frame::pallet_index(12)]
Session: pallet_session,
#[frame::pallet_index(13)]
Democracy: pallet_democracy,
Council: pallet_collective::<Instance1>,
TechnicalCommittee: pallet_collective::<Instance2>,
#[frame::pallet_index(14)]
Council: pallet_collective<Instance1>,
#[frame::pallet_index(15)]
TechnicalCommittee: pallet_collective<Instance2>,
#[frame::pallet_index(16)]
Elections: pallet_elections_phragmen,
TechnicalMembership: pallet_membership::<Instance1>,
#[frame::pallet_index(17)]
TechnicalMembership: pallet_membership<Instance1>,
#[frame::pallet_index(18)]
Grandpa: pallet_grandpa,
#[frame::pallet_index(19)]
Treasury: pallet_treasury,
#[frame::pallet_index(20)]
AssetRate: pallet_asset_rate,
#[frame::pallet_index(21)]
Contracts: pallet_contracts,
#[frame::pallet_index(22)]
Sudo: pallet_sudo,
#[frame::pallet_index(23)]
ImOnline: pallet_im_online,
#[frame::pallet_index(24)]
AuthorityDiscovery: pallet_authority_discovery,
#[frame::pallet_index(25)]
Offences: pallet_offences,
Historical: pallet_session_historical::{Pallet},
#[frame::pallet_index(26)]
Historical: pallet_session_historical + Pallet,
#[frame::pallet_index(27)]
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
#[frame::pallet_index(28)]
Identity: pallet_identity,
#[frame::pallet_index(29)]
Society: pallet_society,
#[frame::pallet_index(30)]
Recovery: pallet_recovery,
#[frame::pallet_index(31)]
Vesting: pallet_vesting,
#[frame::pallet_index(32)]
Scheduler: pallet_scheduler,
#[frame::pallet_index(33)]
Glutton: pallet_glutton,
#[frame::pallet_index(34)]
Preimage: pallet_preimage,
#[frame::pallet_index(35)]
Proxy: pallet_proxy,
#[frame::pallet_index(36)]
Multisig: pallet_multisig,
#[frame::pallet_index(37)]
Bounties: pallet_bounties,
#[frame::pallet_index(38)]
Tips: pallet_tips,
Assets: pallet_assets::<Instance1>,
PoolAssets: pallet_assets::<Instance2>,
#[frame::pallet_index(39)]
Assets: pallet_assets<Instance1>,
#[frame::pallet_index(40)]
PoolAssets: pallet_assets<Instance2>,
#[frame::pallet_index(41)]
Mmr: pallet_mmr,
#[frame::pallet_index(42)]
Lottery: pallet_lottery,
#[frame::pallet_index(43)]
Nis: pallet_nis,
#[frame::pallet_index(44)]
Uniques: pallet_uniques,
#[frame::pallet_index(45)]
Nfts: pallet_nfts,
#[frame::pallet_index(46)]
NftFractionalization: pallet_nft_fractionalization,
#[frame::pallet_index(47)]
Salary: pallet_salary,
#[frame::pallet_index(48)]
CoreFellowship: pallet_core_fellowship,
#[frame::pallet_index(49)]
TransactionStorage: pallet_transaction_storage,
VoterList: pallet_bags_list::<Instance1>,
#[frame::pallet_index(50)]
VoterList: pallet_bags_list<Instance1>,
#[frame::pallet_index(51)]
StateTrieMigration: pallet_state_trie_migration,
#[frame::pallet_index(52)]
ChildBounties: pallet_child_bounties,
#[frame::pallet_index(53)]
Referenda: pallet_referenda,
#[frame::pallet_index(54)]
Remark: pallet_remark,
#[frame::pallet_index(55)]
RootTesting: pallet_root_testing,
#[frame::pallet_index(56)]
ConvictionVoting: pallet_conviction_voting,
#[frame::pallet_index(57)]
Whitelist: pallet_whitelist,
AllianceMotion: pallet_collective::<Instance3>,
#[frame::pallet_index(58)]
AllianceMotion: pallet_collective<Instance3>,
#[frame::pallet_index(59)]
Alliance: pallet_alliance,
#[frame::pallet_index(60)]
NominationPools: pallet_nomination_pools,
RankedPolls: pallet_referenda::<Instance2>,
#[frame::pallet_index(61)]
RankedPolls: pallet_referenda<Instance2>,
#[frame::pallet_index(62)]
RankedCollective: pallet_ranked_collective,
#[frame::pallet_index(63)]
AssetConversion: pallet_asset_conversion,
#[frame::pallet_index(64)]
FastUnstake: pallet_fast_unstake,
#[frame::pallet_index(65)]
MessageQueue: pallet_message_queue,
#[frame::pallet_index(66)]
Pov: frame_benchmarking_pallet_pov,
#[frame::pallet_index(67)]
TxPause: pallet_tx_pause,
#[frame::pallet_index(68)]
SafeMode: pallet_safe_mode,
#[frame::pallet_index(69)]
Statement: pallet_statement,
#[frame::pallet_index(70)]
Broker: pallet_broker,
}
);
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, AccountIndex>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@
//! This macro returns the ` :: expanded { Error }` list of additional parts we would like to
//! expose.

mod expand;
mod parse;
pub(crate) mod expand;
pub(crate) mod parse;

use cfg_expr::Predicate;
use frame_support_procedural_tools::{
Expand Down Expand Up @@ -496,7 +496,7 @@ fn construct_runtime_final_expansion(
Ok(res)
}

fn decl_all_pallets<'a>(
pub(crate) fn decl_all_pallets<'a>(
runtime: &'a Ident,
pallet_declarations: impl Iterator<Item = &'a Pallet>,
features: &HashSet<&str>,
Expand Down Expand Up @@ -660,7 +660,7 @@ fn decl_all_pallets<'a>(
)
}

fn decl_pallet_runtime_setup(
pub(crate) fn decl_pallet_runtime_setup(
runtime: &Ident,
pallet_declarations: &[Pallet],
scrate: &TokenStream2,
Expand Down Expand Up @@ -752,7 +752,7 @@ fn decl_pallet_runtime_setup(
)
}

fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
pub(crate) fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
quote!(
#[cfg(test)]
mod __construct_runtime_integrity_test {
Expand All @@ -767,7 +767,7 @@ fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
)
}

fn decl_static_assertions(
pub(crate) fn decl_static_assertions(
runtime: &Ident,
pallet_decls: &[Pallet],
scrate: &TokenStream2,
Expand Down Expand Up @@ -798,7 +798,7 @@ fn decl_static_assertions(
}
}

fn check_pallet_number(input: TokenStream2, pallet_num: usize) -> Result<()> {
pub(crate) fn check_pallet_number(input: TokenStream2, pallet_num: usize) -> Result<()> {
let max_pallet_num = {
if cfg!(feature = "tuples-96") {
96
Expand Down
Loading
Loading