Polkadot-SDK FRAME @ 2024
Polkadot SDK and FRAME
Note:
Stable + Meaningful Releases
--
Past
substrate
,cumulus
,polkadot
(which containedxcm
)- Git based dependency
- YOLO-major bump everything at all times.
--
Now
--
Now
stableYYMM
- Every 3 month, maintained for 1 year with a monthly patching schedule.
- PRs need to specify
major
/minor
/patch
on the crates they alter. - No change? no bump 👆
- paritytech/release-registry
Getting Started
--
Templates
- Maintained by Parity as part of
polkadot-sdk
, always updated with our stable releases.polkadot-sdk-parachain-template
polkadot-sdk-solochain-template
polkadot-sdk-minimal-template
- All updated automatically after each
stableYYMM
release. - Un-opinionated
- External opinionated templates also listed, open to more suggestions.
- PoP
- OpenZeppelin
Notes:
- Make `polkadot-sdk` templates OMNI and GREAT again -- part 2 · Issue #5242 · paritytech/polkadot-sdk · GitHub
- We notice a cunning simplification in the template's
Cargo.toml
for the runtime.. 🤔
--
Umbrella Crates
[dependencies]
codec = { workspace = true }
scale-info = { workspace = true }
polkadot-sdk = { version = "x.y.z", features = [
"pallet-balances", "pallet-sudo", "pallet-timestamp", "runtime"]
}
[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"polkadot-sdk/std",
]
--
polkadot-sdk
Crate
- Umbrella crate to declutter your
Cargo.toml
- Less confusion with which version to use
- And enablement of features like
std
,runtime-benchmark
,try-runtime
- And enablement of features like
--
polkadot-sdk
Crate
- Will it kill my compile time?
- Migration:
use polkadot_sdk::*
, the rest of your code remains as-is.
Note:
- Compile time: A bit, but not too bad.
feature = node
,feature = runtime
- polkadot_sdk_docs::reference_docs::umbrella_crate - Rust
--
- Then, if we look at the
runtime/lib.rs
, we also notice less clutter 🤔
--
polkadot-sdk-frame
Crate
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::{vec, vec::Vec};
use polkadot_sdk::{polkadot_sdk_frame as frame, *};
use frame::{
prelude::*,
runtime::{apis, prelude::*},
};
--
polkadot-sdk-frame
Crate
polkadot-sdk
simplifies yourCargo.toml
polkadot-sdk-frame
simplifies your runtime and palletlib.rs
by providing sensible preludes.
Note:
polkadot_sdk_frame - Rust
Fetching Title#nysy
--
Past (substrate-node-template
)
--
API Documentation
- Simple, underrated, important enabler.
- Fundamental types and macros now all have API documentation, with correct and extensive examples
pallet::call
,pallet::storage
--
--
Note:
API Documentation:
- all released crates:
docs.rs
- master: https://paritytech.github.io/polkadot-sdk/
- ⚠️ One doc-only crate cannot yet be published and is only visible in the latter.
Note:
--
API Documentation:
- These docs are tightly integrated with polkadot-sdk
- THEY CANNOT GET OUTDATED!
Reflection
All of this, releases, stable and well-documented API, is to say polkadot-sdk
is a step closer to a mature mono-repo.
and we shall keep it that way.
FRAME Updates
- Easier getting started:
dev_mode
- Easier test setup:
[config(with_default)]
and#[derive_impl()]
- Syntax:
#[runtime]
macro - Advanced:
#[pallet::task]
- Advanced:
#[pallet::feeless_if]
- Advanced:
#[pallet::view_function]
Soon™️
All of this is opt-in.
--
Before
impl frame_system::Config for Test {
type BaseCallFilter = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Block = Block;
type Hash = sp_core::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<16>;
}
--
After
#[derive_implTestDefaultConfig]
impl frame_system::Config for Test {
type Block = frame_system::mocking::MockBlock<Test>;
}
Or
#[derive_implTestDefaultConfig]
impl frame_system::Config for Test {
type Block = frame_system::mocking::MockBlock<Test>;
type AccountData = pallet_balances::AccountData<u64>;
}
Node
- How cool would it be to download a node that could run any wasm runtime?
- No need to maintain it, update it, etc.
- No need to compile it 🫠
--
Omni Node
- Capable of running (most) parachains, and a local dev chain.
- Early docs
- First iteration will be released with
stable2412
Closing Remarks
- A lot of what I have said are initiatives that need contributors to push through the finish line!
- Mentor-able, tip-able issues in the speaker notes
- Developing a blockchain with Polkadot-SDK has gotten even simpler now, but..
- Contracts will always be easier!
Note:
- All good-first issues: Issues · paritytech/polkadot-sdk · GitHub
- All mentor issues: Issues · paritytech/polkadot-sdk · GitHub
- Made with 💎 Obsidian-Digital-Garden
- © Kian Paimani 2024. Content on this site is licensed under a Creative Commons Attribution 4.0 International License.