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 58 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
27 changes: 27 additions & 0 deletions prdoc/pr_1378.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
title: Construct Runtime V2 - An outer macro approach to define the runtime

doc:
- audience: Runtime Dev
description: |
Introduces `#[frame_support::runtime]` that can be attached to a mod to define a runtime. The items
in this mod can be attached to the following attributes to define the key components of the runtime.
1. `#[runtime::runtime]` attached to a struct defines the main runtime
2. `#[runtime::derive]` attached to the runtime struct defines the types generated by the runtime
3. `#[runtime::pallet_index]` must be attached to a pallet to define its index
4. `#[runtime::disable_call]` can be optionally attached to a pallet to disable its calls
5. `#[runtime::disable_unsigned]` can be optionally attached to a pallet to disable unsigned calls
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
6. A pallet instance can be defined as `TemplateModule: pallet_template<Instance>`
An optional attribute can be defined as `#[frame_support::runtime(legacy_ordering)]` to ensure that
the order of hooks is same as the order of pallets (and not based on the pallet_index). This is to support
legacy runtimes and should be avoided for new ones.
Copy link
Member

Choose a reason for hiding this comment

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

@bkchr do you have an opinion on this?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. Not sure this is such a great idea (ordering based on the index). But also wasn't the idea that this would be changed with the new Poll logic? Aka that the runtime implementor needs to explicitly state this order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Not sure this is such a great idea (ordering based on the index).

I thought this was causing a lot of issues as the user expectation would be to have everything as per the pallet_index. I would also imagine this to be better but please let me know your concerns.

But also wasn't the idea that this would be changed with the new Poll logic? Aka that the runtime implementor needs to explicitly state this order?

I am not aware of this. Could you please link the issue?

Copy link
Member

Choose a reason for hiding this comment

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

For the poll hook it can explicitly be set, yes. But my question was about the on_initialize etc that have fixed order.

Copy link
Member

Choose a reason for hiding this comment

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

I thought this was causing a lot of issues as the user expectation would be to have everything as per the pallet_index

Yeah that is a good point 👍

For the poll hook it can explicitly be set, yes. But my question was about the on_initialize etc that have fixed order.

If we have poll explicit and have everything fixed up with on_initialize, the order of on_initialize shouldn't be that important anymore. By "fixed up" on_initialize I mean that pallets should not call into other pallets in this stage if possible, to not run into race conditions that stuff is not yet setup. They should setup their own state and then in poll they can do whatever they need.


migrations:
db: []

runtime: []

crates:
- name: frame-support
- name: frame-support-procedural

host_functions: []
54 changes: 41 additions & 13 deletions substrate/bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,47 @@ impl pallet_template::Config for Runtime {
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime {
System: frame_system,
Timestamp: pallet_timestamp,
Aura: pallet_aura,
Grandpa: pallet_grandpa,
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
Sudo: pallet_sudo,
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
}
);
#[frame_support::runtime]
mod runtime {
#[runtime::runtime]
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeFreezeReason,
RuntimeHoldReason,
RuntimeSlashReason,
RuntimeLockId,
RuntimeTask
)]
pub struct Runtime;

#[runtime::pallet_index(0)]
pub type System = frame_system;

#[runtime::pallet_index(1)]
pub type Timestamp = pallet_timestamp;

#[runtime::pallet_index(2)]
pub type Aura = pallet_aura;

#[runtime::pallet_index(3)]
pub type Grandpa = pallet_grandpa;

#[runtime::pallet_index(4)]
pub type Balances = pallet_balances;

#[runtime::pallet_index(5)]
pub type TransactionPayment = pallet_transaction_payment;

#[runtime::pallet_index(6)]
pub type Sudo = pallet_sudo;

// Include the custom logic from the pallet-template in the runtime.
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
#[runtime::pallet_index(7)]
pub type TemplateModule = pallet_template;
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
Expand Down
Loading
Loading