1. Apr 24, 2024
  2. Mar 13, 2024
  3. Mar 05, 2024
    • Kian Paimani's avatar
      Repot all templates into a single directory (#3460) · 4c810609
      Kian Paimani authored
      The first step towards
      https://github.com/paritytech/polkadot-sdk/issues/3155
      
      Brings all templates under the following structure
      
      ```
      templates
      |   parachain
      |   |   polkadot-launch
      |   |   runtime              --> parachain-template-runtime
      |   |   pallets              --> pallet-parachain-template
      |   |   node                 --> parachain-template-node
      |   minimal
      |   |   runtime              --> minimal-template-runtime
      |   |   pallets              --> pallet-minimal-template
      |   |   node                 --> minimal-template-node
      |   solochain
      |   |   runtime              --> solochain-template-runtime
      |   |   pallets              --> pallet-template (the naming is not consistent here)
      |   |   node                 --> solochain-template-node
      ```
      
      The only note-worthy changes in this PR are: 
      
      - More `Cargo.toml` fields are forwarded to use the one from the
      workspace.
      - parachain template now has weights and benchmarks
      - adds a shell pallet to the minimal template
      - remove a few unused deps 
      
      
      A list of possible follow-ups: 
      
      - [ ] Unify READMEs, create a parent README for all
      - [ ] remove references to `docs.substrate.io` in templates
      - [ ] make all templates use `#[derive_impl]`
      - [ ] update and unify all licenses
      - [ ] Remove polkadot launch, use
      https://github.com/paritytech/polkadot-sdk/blob/35349df993ea2e7c4769914ef5d199e787b23d4c/cumulus/zombienet/examples/small_network.toml
      instead.
      4c810609
  4. Mar 04, 2024
    • Gavin Wood's avatar
      FRAME: Create `TransactionExtension` as a replacement for `SignedExtension` (#2280) · fd5f9292
      Gavin Wood authored
      Closes #2160
      
      First part of [Extrinsic
      Horizon](https://github.com/paritytech/polkadot-sdk/issues/2415
      
      )
      
      Introduces a new trait `TransactionExtension` to replace
      `SignedExtension`. Introduce the idea of transactions which obey the
      runtime's extensions and have according Extension data (né Extra data)
      yet do not have hard-coded signatures.
      
      Deprecate the terminology of "Unsigned" when used for
      transactions/extrinsics owing to there now being "proper" unsigned
      transactions which obey the extension framework and "old-style" unsigned
      which do not. Instead we have __*General*__ for the former and
      __*Bare*__ for the latter. (Ultimately, the latter will be phased out as
      a type of transaction, and Bare will only be used for Inherents.)
      
      Types of extrinsic are now therefore:
      - Bare (no hardcoded signature, no Extra data; used to be known as
      "Unsigned")
      - Bare transactions (deprecated): Gossiped, validated with
      `ValidateUnsigned` (deprecated) and the `_bare_compat` bits of
      `TransactionExtension` (deprecated).
        - Inherents: Not gossiped, validated with `ProvideInherent`.
      - Extended (Extra data): Gossiped, validated via `TransactionExtension`.
        - Signed transactions (with a hardcoded signature).
        - General transactions (without a hardcoded signature).
      
      `TransactionExtension` differs from `SignedExtension` because:
      - A signature on the underlying transaction may validly not be present.
      - It may alter the origin during validation.
      - `pre_dispatch` is renamed to `prepare` and need not contain the checks
      present in `validate`.
      - `validate` and `prepare` is passed an `Origin` rather than a
      `AccountId`.
      - `validate` may pass arbitrary information into `prepare` via a new
      user-specifiable type `Val`.
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`. It is encoded *for the entire transaction* and
      passed in to each extension as a new argument to `validate`. This
      facilitates the ability of extensions to acts as underlying crypto.
      
      There is a new `DispatchTransaction` trait which contains only default
      function impls and is impl'ed for any `TransactionExtension` impler. It
      provides several utility functions which reduce some of the tedium from
      using `TransactionExtension` (indeed, none of its regular functions
      should now need to be called directly).
      
      Three transaction version discriminator ("versions") are now
      permissible:
      - 0b000000100: Bare (used to be called "Unsigned"): contains Signature
      or Extra (extension data). After bare transactions are no longer
      supported, this will strictly identify an Inherents only.
      - 0b100000100: Old-school "Signed" Transaction: contains Signature and
      Extra (extension data).
      - 0b010000100: New-school "General" Transaction: contains Extra
      (extension data), but no Signature.
      
      For the New-school General Transaction, it becomes trivial for authors
      to publish extensions to the mechanism for authorizing an Origin, e.g.
      through new kinds of key-signing schemes, ZK proofs, pallet state,
      mutations over pre-authenticated origins or any combination of the
      above.
      
      ## Code Migration
      
      ### NOW: Getting it to build
      
      Wrap your `SignedExtension`s in `AsTransactionExtension`. This should be
      accompanied by renaming your aggregate type in line with the new
      terminology. E.g. Before:
      
      ```rust
      /// The SignedExtension to the basic transaction logic.
      pub type SignedExtra = (
      	/* snip */
      	MySpecialSignedExtension,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
      ```
      
      After:
      
      ```rust
      /// The extension to the basic transaction logic.
      pub type TxExtension = (
      	/* snip */
      	AsTransactionExtension<MySpecialSignedExtension>,
      );
      /// Unchecked extrinsic type as expected by this runtime.
      pub type UncheckedExtrinsic =
      	generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
      ```
      
      You'll also need to alter any transaction building logic to add a
      `.into()` to make the conversion happen. E.g. Before:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let extra: SignedExtra = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */),
      	);
      	let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		extra,
      	)
      }
      ```
      
      After:
      
      ```rust
      fn construct_extrinsic(
      		/* snip */
      ) -> UncheckedExtrinsic {
      	let tx_ext: TxExtension = (
      		/* snip */
      		MySpecialSignedExtension::new(/* snip */).into(),
      	);
      	let payload = SignedPayload::new(call.clone(), tx_ext.clone()).unwrap();
      	let signature = payload.using_encoded(|e| sender.sign(e));
      	UncheckedExtrinsic::new_signed(
      		/* snip */
      		Signature::Sr25519(signature),
      		tx_ext,
      	)
      }
      ```
      
      ### SOON: Migrating to `TransactionExtension`
      
      Most `SignedExtension`s can be trivially converted to become a
      `TransactionExtension`. There are a few things to know.
      
      - Instead of a single trait like `SignedExtension`, you should now
      implement two traits individually: `TransactionExtensionBase` and
      `TransactionExtension`.
      - Weights are now a thing and must be provided via the new function `fn
      weight`.
      
      #### `TransactionExtensionBase`
      
      This trait takes care of anything which is not dependent on types
      specific to your runtime, most notably `Call`.
      
      - `AdditionalSigned`/`additional_signed` is renamed to
      `Implicit`/`implicit`.
      - Weight must be returned by implementing the `weight` function. If your
      extension is associated with a pallet, you'll probably want to do this
      via the pallet's existing benchmarking infrastructure.
      
      #### `TransactionExtension`
      
      Generally:
      - `pre_dispatch` is now `prepare` and you *should not reexecute the
      `validate` functionality in there*!
      - You don't get an account ID any more; you get an origin instead. If
      you need to presume an account ID, then you can use the trait function
      `AsSystemOriginSigner::as_system_origin_signer`.
      - You get an additional ticket, similar to `Pre`, called `Val`. This
      defines data which is passed from `validate` into `prepare`. This is
      important since you should not be duplicating logic from `validate` to
      `prepare`, you need a way of passing your working from the former into
      the latter. This is it.
      - This trait takes two type parameters: `Call` and `Context`. `Call` is
      the runtime call type which used to be an associated type; you can just
      move it to become a type parameter for your trait impl. `Context` is not
      currently used and you can safely implement over it as an unbounded
      type.
      - There's no `AccountId` associated type any more. Just remove it.
      
      Regarding `validate`:
      - You get three new parameters in `validate`; all can be ignored when
      migrating from `SignedExtension`.
      - `validate` returns a tuple on success; the second item in the tuple is
      the new ticket type `Self::Val` which gets passed in to `prepare`. If
      you use any information extracted during `validate` (off-chain and
      on-chain, non-mutating) in `prepare` (on-chain, mutating) then you can
      pass it through with this. For the tuple's last item, just return the
      `origin` argument.
      
      Regarding `prepare`:
      - This is renamed from `pre_dispatch`, but there is one change:
      - FUNCTIONALITY TO VALIDATE THE TRANSACTION NEED NOT BE DUPLICATED FROM
      `validate`!!
      - (This is different to `SignedExtension` which was required to run the
      same checks in `pre_dispatch` as in `validate`.)
      
      Regarding `post_dispatch`:
      - Since there are no unsigned transactions handled by
      `TransactionExtension`, `Pre` is always defined, so the first parameter
      is `Self::Pre` rather than `Option<Self::Pre>`.
      
      If you make use of `SignedExtension::validate_unsigned` or
      `SignedExtension::pre_dispatch_unsigned`, then:
      - Just use the regular versions of these functions instead.
      - Have your logic execute in the case that the `origin` is `None`.
      - Ensure your transaction creation logic creates a General Transaction
      rather than a Bare Transaction; this means having to include all
      `TransactionExtension`s' data.
      - `ValidateUnsigned` can still be used (for now) if you need to be able
      to construct transactions which contain none of the extension data,
      however these will be phased out in stage 2 of the Transactions Horizon,
      so you should consider moving to an extension-centric design.
      
      ## TODO
      
      - [x] Introduce `CheckSignature` impl of `TransactionExtension` to
      ensure it's possible to have crypto be done wholly in a
      `TransactionExtension`.
      - [x] Deprecate `SignedExtension` and move all uses in codebase to
      `TransactionExtension`.
        - [x] `ChargeTransactionPayment`
        - [x] `DummyExtension`
        - [x] `ChargeAssetTxPayment` (asset-tx-payment)
        - [x] `ChargeAssetTxPayment` (asset-conversion-tx-payment)
        - [x] `CheckWeight`
        - [x] `CheckTxVersion`
        - [x] `CheckSpecVersion`
        - [x] `CheckNonce`
        - [x] `CheckNonZeroSender`
        - [x] `CheckMortality`
        - [x] `CheckGenesis`
        - [x] `CheckOnlySudoAccount`
        - [x] `WatchDummy`
        - [x] `PrevalidateAttests`
        - [x] `GenericSignedExtension`
        - [x] `SignedExtension` (chain-polkadot-bulletin)
        - [x] `RefundSignedExtensionAdapter`
      - [x] Implement `fn weight` across the board.
      - [ ] Go through all pre-existing extensions which assume an account
      signer and explicitly handle the possibility of another kind of origin.
      - [x] `CheckNonce` should probably succeed in the case of a non-account
      origin.
      - [x] `CheckNonZeroSender` should succeed in the case of a non-account
      origin.
      - [x] `ChargeTransactionPayment` and family should fail in the case of a
      non-account origin.
        - [ ] 
      - [x] Fix any broken tests.
      
      ---------
      
      Signed-off-by: default avatargeorgepisaltu <[email protected]>
      Signed-off-by: default avatarAlexandru Vasile <[email protected]>
      Signed-off-by: default avatardependabot[bot] <[email protected]>
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Signed-off-by: default avatarAlexandru Gheorghe <[email protected]>
      Signed-off-by: default avatarAndrei Sandu <[email protected]>
      Co-authored-by: default avatarNikhil Gupta <[email protected]>
      Co-authored-by: default avatargeorgepisaltu <[email protected]>
      Co-authored-by: default avatarChevdor <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarMaciej <[email protected]>
      Co-authored-by: default avatarJavier Viola <[email protected]>
      Co-authored-by: default avatarMarcin S. <[email protected]>
      Co-authored-by: default avatarTsvetomir Dimitrov <[email protected]>
      Co-authored-by: default avatarJavier Bullrich <[email protected]>
      Co-authored-by: default avatarKoute <[email protected]>
      Co-authored-by: default avatarAdrian Catangiu <[email protected]>
      Co-authored-by: Vladimir Istyufeev's avatarVladimir Istyufeev <[email protected]>
      Co-authored-by: default avatarRoss Bulat <[email protected]>
      Co-authored-by: default avatarGonçalo Pestana <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarSvyatoslav Nikolsky <[email protected]>
      Co-authored-by: default avatarAndré Silva <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatars0me0ne-unkn0wn <[email protected]>
      Co-authored-by: default avatarordian <[email protected]>
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      Co-authored-by: default avatarAaro Altonen <[email protected]>
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatarAlexandru Vasile <[email protected]>
      Co-authored-by: default avatarAlexander Samusev <[email protected]>
      Co-authored-by: default avatarJulian Eager <[email protected]>
      Co-authored-by: default avatarMichal Kucharczyk <[email protected]>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarDónal Murray <[email protected]>
      Co-authored-by: default avataryjh <[email protected]>
      Co-authored-by: default avatarTom Mi <[email protected]>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      Co-authored-by: default avatarWill | Paradox | ParaNodes.io <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarJoshy Orndorff <[email protected]>
      Co-authored-by: default avatarJoshy Orndorff <[email protected]>
      Co-authored-by: default avatarPG Herveou <[email protected]>
      Co-authored-by: default avatarAlexander Theißen <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarJuan Girini <[email protected]>
      Co-authored-by: default avatarbader y <[email protected]>
      Co-authored-by: default avatarJames Wilson <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      Co-authored-by: default avatarasynchronous rob <[email protected]>
      Co-authored-by: default avatarParth <[email protected]>
      Co-authored-by: default avatarAndrew Jones <[email protected]>
      Co-authored-by: default avatarJonathan Udd <[email protected]>
      Co-authored-by: default avatarSerban Iorga <[email protected]>
      Co-authored-by: default avatarEgor_P <[email protected]>
      Co-authored-by: default avatarBranislav Kontur <[email protected]>
      Co-authored-by: default avatarEvgeny Snitko <[email protected]>
      Co-authored-by: default avatarJust van Stam <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatargupnik <[email protected]>
      Co-authored-by: default avatardzmitry-lahoda <[email protected]>
      Co-authored-by: default avatarzhiqiangxu <[email protected]>
      Co-authored-by: default avatarNazar Mokrynskyi <[email protected]>
      Co-authored-by: default avatarAnwesh <[email protected]>
      Co-authored-by: default avatarcheme <[email protected]>
      Co-authored-by: default avatarSam Johnson <[email protected]>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: default avatarJegor Sidorenko <[email protected]>
      Co-authored-by: default avatarMuharem <[email protected]>
      Co-authored-by: default avatarjoepetrowski <[email protected]>
      Co-authored-by: default avatarAlexandru Gheorghe <[email protected]>
      Co-authored-by: default avatarGabriel Facco de Arruda <[email protected]>
      Co-authored-by: default avatarSquirrel <[email protected]>
      Co-authored-by: default avatarAndrei Sandu <[email protected]>
      Co-authored-by: default avatargeorgepisaltu <[email protected]>
      Co-authored-by: command-bot <>
      fd5f9292
  5. Feb 28, 2024
    • Oliver Tale-Yazdi's avatar
      Multi-Block-Migrations, `poll` hook and new System callbacks (#1781) · eefd5fe4
      Oliver Tale-Yazdi authored
      This MR is the merge of
      https://github.com/paritytech/substrate/pull/14414 and
      https://github.com/paritytech/substrate/pull/14275. It implements
      [RFC#13](https://github.com/polkadot-fellows/RFCs/pull/13), closes
      https://github.com/paritytech/polkadot-sdk/issues/198.
      
      ----- 
      
      This Merge request introduces three major topicals:
      
      1. Multi-Block-Migrations
      1. New pallet `poll` hook for periodic service work
      1. Replacement hooks for `on_initialize` and `on_finalize` in cases
      where `poll` cannot be used
      
      and some more general changes to FRAME.  
      The changes for each topical span over multiple crates. They are listed
      in topical order below.
      
      # 1.) Multi-Block-Migrations
      
      Multi-Block-Migrations are facilitated by creating `pallet_migrations`
      and configuring `System::Config::MultiBlockMigrator` to point to it.
      Executive picks this up and triggers one step of the migrations pallet
      per block.
      The chain is in lockdown mode for as long as an MBM is ongoing.
      Executive does this by polling `MultiBlockMigrator::ongoing` and not
      allowing any transaction in a block, if true.
      
      A MBM is defined through trait `SteppedMigration`. A condensed version
      looks like this:
      ```rust
      /// A migration that can proceed in multiple steps.
      pub trait SteppedMigration {
      	type Cursor: FullCodec + MaxEncodedLen;
      	type Identifier: FullCodec + MaxEncodedLen;
      
      	fn id() -> Self::Identifier;
      
      	fn max_steps() -> Option<u32>;
      
      	fn step(
      		cursor: Option<Self::Cursor>,
      		meter: &mut WeightMeter,
      	) -> Result<Option<Self::Cursor>, SteppedMigrationError>;
      }
      ```
      
      `pallet_migrations` can be configured with an aggregated tuple of these
      migrations. It then starts to migrate them one-by-one on the next
      runtime upgrade.
      Two things are important here:
      - 1. Doing another runtime upgrade while MBMs are ongoing is not a good
      idea and can lead to messed up state.
      - 2. **Pallet Migrations MUST BE CONFIGURED IN `System::Config`,
      otherwise it is not used.**
      
      The pallet supports an `UpgradeStatusHandler` that can be used to notify
      external logic of upgrade start/finish (for example to pause XCM
      dispatch).
      
      Error recovery is very limited in the case that a migration errors or
      times out (exceeds its `max_steps`). Currently the runtime dev can
      decide in `FailedMigrationHandler::failed` how to handle this. One
      follow-up would be to pair this with the `SafeMode` pallet and enact
      safe mode when an upgrade fails, to allow governance to rescue the
      chain. This is currently not possible, since governance is not
      `Mandatory`.
      
      ## Runtime API
      
      - `Core`: `initialize_block` now returns `ExtrinsicInclusionMode` to
      inform the Block Author whether they can push transactions.
      
      ### Integration
      
      Add it to your runtime implementation of `Core` and `BlockBuilder`:
      ```patch
      diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
      @@ impl_runtime_apis! {
      	impl sp_block_builder::Core<Block> for Runtime {
      -		fn initialize_block(header: &<Block as BlockT>::Header) {
      +		fn initialize_block(header: &<Block as BlockT>::Header) -> RuntimeExecutiveMode {
      			Executive::initialize_block(header)
      		}
      
      		...
      	}
      ```
      
      # 2.) `poll` hook
      
      A new pallet hook is introduced: `poll`. `Poll` is intended to replace
      mostly all usage of `on_initialize`.
      The reason for this is that any code that can be called from
      `on_initialize` cannot be migrated through an MBM. Currently there is no
      way to statically check this; the implication is to use `on_initialize`
      as rarely as possible.
      Failing to do so can result in broken storage invariants.
      
      The implementation of the poll hook depends on the `Runtime API` changes
      that are explained above.
      
      # 3.) Hard-Deadline callbacks
      
      Three new callbacks are introduced and configured on `System::Config`:
      `PreInherents`, `PostInherents` and `PostTransactions`.
      These hooks are meant as replacement for `on_initialize` and
      `on_finalize` in cases where the code that runs cannot be moved to
      `poll`.
      The reason for this is to make the usage of HD-code (hard deadline) more
      explicit - again to prevent broken invariants by MBMs.
      
      # 4.) FRAME (general changes)
      
      ## `frame_system` pallet
      
      A new memorize storage item `InherentsApplied` is added. It is used by
      executive to track whether inherents have already been applied.
      Executive and can then execute the MBMs directly between inherents and
      transactions.
      
      The `Config` gets five new items:
      - `SingleBlockMigrations` this is the new way of configuring migrations
      that run in a single block. Previously they were defined as last generic
      argument of `Executive`. This shift is brings all central configuration
      about migrations closer into view of the developer (migrations that are
      configured in `Executive` will still work for now but is deprecated).
      - `MultiBlockMigrator` this can be configured to an engine that drives
      MBMs. One example would be the `pallet_migrations`. Note that this is
      only the engine; the exact MBMs are injected into the engine.
      - `PreInherents` a callback that executes after `on_initialize` but
      before inherents.
      - `PostInherents` a callback that executes after all inherents ran
      (including MBMs and `poll`).
      - `PostTransactions` in symmetry to `PreInherents`, this one is called
      before `on_finalize` but after all transactions.
      
      A sane default is to set all of these to `()`. Example diff suitable for
      any chain:
      ```patch
      @@ impl frame_system::Config for Test {
       	type MaxConsumers = ConstU32<16>;
      +	type SingleBlockMigrations = ();
      +	type MultiBlockMigrator = ();
      +	type PreInherents = ();
      +	type PostInherents = ();
      +	type PostTransactions = ();
       }
      ```
      
      An overview of how the block execution now looks like is here. The same
      graph is also in the rust doc.
      
      <details><summary>Block Execution Flow</summary>
      <p>
      
      ![Screenshot 2023-12-04 at 19 11
      29](https://github.com/paritytech/polkadot-sdk/assets/10380170/e88a80c4-ef11-4faa-8df5-8b33a724c054)
      
      </p>
      </details> 
      
      ## Inherent Order
      
      Moved to https://github.com/paritytech/polkadot-sdk/pull/2154
      
      
      
      ---------------
      
      
      ## TODO
      
      - [ ] Check that `try-runtime` still works
      - [ ] Ensure backwards compatibility with old Runtime APIs
      - [x] Consume weight correctly
      - [x] Cleanup
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarJuan Girini <[email protected]>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      Co-authored-by: default avatarGavin Wood <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      eefd5fe4
    • Liam Aharon's avatar
      Runtime Upgrade ref docs and Single Block Migration example pallet (#1554) · 12ce4f7d
      Liam Aharon authored
      Closes https://github.com/paritytech/polkadot-sdk-docs/issues/55
      
      - Changes 'current storage version' terminology to less ambiguous
      'in-code storage version' (suggestion by @ggwpez)
      - Adds a new example pallet `pallet-example-single-block-migrations`
      - Adds a new reference doc to replace
      https://docs.substrate.io/maintain/runtime-upgrades/ (temporarily living
      in the pallet while we wait for developer hub PR to merge)
      - Adds documentation for the `storage_alias` macro
      - Improves `trait Hooks` docs 
      - Improves `trait GetStorageVersion` docs
      - Update the suggested patterns for using `VersionedMigration`, so that
      version unchecked migrations are never exported
      - Prevents accidental usage of version unchecked migrations in runtimes
      
      https://github.com/paritytech/substrate/pull/14421#discussion_r1255467895
      - Unversioned migration code is kept inside `mod version_unchecked`,
      versioned code is kept in `pub mod versioned`
      - It is necessary to use modules to limit visibility because the inner
      migration must be `pub`. See
      https://github.com/rust-lang/rust/issues/30905 and
      
      https://internals.rust-lang.org/t/lang-team-minutes-private-in-public-rules/4504/40
      for more.
      
      ### todo
      
      - [x] move to reference docs to proper place within sdk-docs (now that
      https://github.com/paritytech/polkadot-sdk/pull/2102
      
       is merged)
      - [x] prdoc
      
      ---------
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarJuan <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: command-bot <>
      Co-authored-by: default avatargupnik <[email protected]>
      12ce4f7d
    • Liam Aharon's avatar
      Introduce storage attr macro `#[disable_try_decode_storage]` and set it on... · 95da6583
      Liam Aharon authored
      Introduce storage attr macro `#[disable_try_decode_storage]` and set it on `System::Events` and `ParachainSystem::HostConfiguration` (#3454)
      
      Closes https://github.com/paritytech/polkadot-sdk/issues/2560
      
      Allows marking storage items with `#[disable_try_decode_storage]`, and
      uses it with `System::Events`.
      
      Question: what's the recommended way to write a test for this? I
      couldn't find a test for similar existing macro `#[whitelist_storage]`.
      95da6583
  6. Feb 27, 2024
  7. Feb 23, 2024
    • Sebastian Kunert's avatar
      PoV Reclaim Runtime Side (#3002) · 3386377b
      Sebastian Kunert authored
      
      
      # Runtime side for PoV Reclaim
      
      ## Implementation Overview
      - Hostfunction to fetch the storage proof size has been added to the
      PVF. It uses the size tracking recorder that was introduced in my
      previous PR.
      - Mechanisms to use the reclaim HostFunction have been introduced.
      - 1. A SignedExtension that checks the node-reported proof size before
      and after application of an extrinsic. Then it reclaims the difference.
      - 2. A manual helper to make reclaiming easier when manual interaction
      is required, for example in `on_idle` or other hooks.
      - In order to utilize the manual reclaiming, I modified `WeightMeter` to
      support the reduction of consumed weight, at least for storage proof
      size.
      
      ## How to use
      To enable the general functionality for a parachain:
      1. Add the SignedExtension to your parachain runtime. 
      2. Provide the HostFunction to the node
      3. Enable proof recording during block import
      
      ## TODO
      - [x] PRDoc
      
      ---------
      
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      3386377b
  8. Dec 20, 2023
    • joe petrowski's avatar
      Add Authorize Upgrade Pattern to Frame System (#2682) · 280aa0b5
      joe petrowski authored
      Adds the `authorize_upgrade` -> `enact_authorized_upgrade` pattern to
      `frame-system`. This will be useful for upgrading bridged chains that
      are under the governance of Polkadot without passing entire runtime Wasm
      blobs over a bridge.
      
      Notes:
      
      - Changed `enact_authorized_upgrade` to `apply_authorized_upgrade`.
      Personal opinion, "apply" more accurately expresses what it's doing. Can
      change back if outvoted.
      - Remove `check_version` in favor of two extrinsics, so as to make
      _checked_ the default.
      - Left calls in `parachain-system` and marked as deprecated to prevent
      breaking the API. They just call into the `frame-system` functions.
      - Updated `frame-system` benchmarks to v2 syntax.
      
      ---------
      
      Co-authored-by: command-bot <>
      280aa0b5
  9. Dec 15, 2023
  10. Dec 11, 2023
  11. Dec 08, 2023
    • Sam Johnson's avatar
      Tasks: general system for recognizing and executing service work (#1343) · ac3f14d2
      Sam Johnson authored
      `polkadot-sdk` version of original tasks PR located here:
      https://github.com/paritytech/substrate/pull/14329
      
      Fixes #206
      
      ## Status
      - [x] Generic `Task` trait
      - [x] `RuntimeTask` aggregated enum, compatible with
      `construct_runtime!`
      - [x] Casting between `Task` and `RuntimeTask` without needing `dyn` or
      `Box`
      - [x] Tasks Example pallet
      - [x] Runtime tests for Tasks example pallet
      - [x] Parsing for task-related macros
      - [x] Retrofit parsing to make macros optional
      - [x] Expansion for task-related macros
      - [x] Adds support for args in tasks
      - [x] Retrofit tasks example pallet to use macros instead of manual
      syntax
      - [x] Weights
      - [x] Cleanup
      - [x] UI tests
      - [x] Docs
      
      ## Target Syntax
      Adapted from
      https://github.com/paritytech/polkadot-sdk/issues/206#issue-1865172283
      
      
      
      ```rust
      // NOTE: this enum is optional and is auto-generated by the other macros if not present
      #[pallet::task]
      pub enum Task<T: Config> {
          AddNumberIntoTotal {
              i: u32,
          }
      }
      
      /// Some running total.
      #[pallet::storage]
      pub(super) type Total<T: Config<I>, I: 'static = ()> =
      StorageValue<_, (u32, u32), ValueQuery>;
      
      /// Numbers to be added into the total.
      #[pallet::storage]
      pub(super) type Numbers<T: Config<I>, I: 'static = ()> =
      StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
      
      #[pallet::tasks_experimental]
      impl<T: Config<I>, I: 'static> Pallet<T, I> {
      	/// Add a pair of numbers into the totals and remove them.
      	#[pallet::task_list(Numbers::<T, I>::iter_keys())]
      	#[pallet::task_condition(|i| Numbers::<T, I>::contains_key(i))]
      	#[pallet::task_index(0)]
      	pub fn add_number_into_total(i: u32) -> DispatchResult {
      		let v = Numbers::<T, I>::take(i).ok_or(Error::<T, I>::NotFound)?;
      		Total::<T, I>::mutate(|(total_keys, total_values)| {
      			*total_keys += i;
      			*total_values += v;
      		});
      		Ok(())
      	}
      }
      ```
      
      ---------
      
      Co-authored-by: default avatarNikhil Gupta <[email protected]>
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: Nikhil Gupta <>
      Co-authored-by: default avatarGavin Wood <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatargupnik <[email protected]>
      ac3f14d2
  12. Dec 05, 2023
  13. Nov 30, 2023
  14. Nov 15, 2023
  15. Nov 05, 2023
  16. Oct 30, 2023
  17. Oct 27, 2023
    • juangirini's avatar
      feat: FRAME umbrella crate. (#1337) · 43415ef5
      juangirini authored
      ### Original PR https://github.com/paritytech/substrate/pull/14137
      
      This PR brings in the first version of the "_`frame` umbrella crate_".
      This crate is intended to serve two purposes:
      
      1. documentation
      2. easier development with frame. Ideally, we want most users to be able
      to build a frame-based pallet and runtime using just `frame` (plus
      `scale-codec` and `scale-info`).
      
      The crate is not finalized and is not yet intended for external use.
      Therefore, the version is set to `0.0.1-dev`, this PR is `silent`, and
      the entire crate is hidden behind the `experimental` flag. The main
      intention in merging it early on is to be able to iterate on it in the
      rest of
      [`developer-hub`](https://github.com/paritytech/polkadot-sdk-docs/)
      efforts.
      
      The public API of the `frame` crate is at the moment as follows: 
      
      ```
      pub mod frame
      pub use frame::log
      pub use frame::pallet
      pub mod frame::arithmetic
      pub use frame::arithmetic::<<sp_arithmetic::*>>
      pub use frame::arithmetic::<<sp_arithmetic::traits::*>>
      pub mod frame::deps
      pub use frame::deps::codec
      pub use frame::deps::frame_executive
      pub use frame::deps::frame_support
      pub use frame::deps::frame_system
      pub use frame::deps::scale_info
      pub use frame::deps::sp_api
      pub use frame::deps::sp_arithmetic
      pub use frame::deps::sp_block_builder
      pub use frame::deps::sp_consensus_aura
      pub use frame::deps::sp_consensus_grandpa
      pub use frame::deps::sp_core
      pub use frame::deps::sp_inherents
      pub use frame::deps::sp_io
      pub use frame::deps::sp_offchain
      pub use frame::deps::sp_runtime
      pub use frame::deps::sp_std
      pub use frame::deps::sp_version
      pub mod frame::derive
      pub use frame::derive::CloneNoBound
      pub use frame::derive::Debug
      pub use frame::derive::Debug
      pub use frame::derive::DebugNoBound
      pub use frame::derive::Decode
      pub use frame::derive::Decode
      pub use frame::derive::DefaultNoBound
      pub use frame::derive::Encode
      pub use frame::derive::Encode
      pub use frame::derive::EqNoBound
      pub use frame::derive::PartialEqNoBound
      pub use frame::derive::RuntimeDebug
      pub use frame::derive::RuntimeDebugNoBound
      pub use frame::derive::TypeInfo
      pub use frame::derive::TypeInfo
      pub mod frame::prelude
      pub use frame::prelude::<<frame_support::pallet_prelude::*>>
      pub use frame::prelude::<<frame_system::pallet_prelude::*>>
      pub use frame::prelude::<<sp_std::prelude::*>>
      pub use frame::prelude::CloneNoBound
      pub use frame::prelude::Debug
      pub use frame::prelude::Debug
      pub use frame::prelude::DebugNoBound
      pub use frame::prelude::Decode
      pub use frame::prelude::Decode
      pub use frame::prelude::DefaultNoBound
      pub use frame::prelude::Encode
      pub use frame::prelude::Encode
      pub use frame::prelude::EqNoBound
      pub use frame::prelude::PartialEqNoBound
      pub use frame::prelude::RuntimeDebug
      pub use frame::prelude::RuntimeDebugNoBound
      pub use frame::prelude::TypeInfo
      pub use frame::prelude::TypeInfo
      pub use frame::prelude::frame_system
      pub mod frame::primitives
      pub use frame::primitives::BlakeTwo256
      pub use frame::primitives::H160
      pub use frame::primitives::H256
      pub use frame::primitives::H512
      pub use frame::primitives::Hash
      pub use frame::primitives::Keccak256
      pub use frame::primitives::U256
      pub use frame::primitives::U512
      pub mod frame::runtime
      pub mod frame::runtime::apis
      pub use frame::runtime::apis::<<frame_system_rpc_runtime_api::*>>
      pub use frame::runtime::apis::<<sp_api::*>>
      pub use frame::runtime::apis::<<sp_block_builder::*>>
      pub use frame::runtime::apis::<<sp_consensus_aura::*>>
      pub use frame::runtime::apis::<<sp_consensus_grandpa::*>>
      pub use frame::runtime::apis::<<sp_offchain::*>>
      pub use frame::runtime::apis::<<sp_session::runtime_api::*>>
      pub use frame::runtime::apis::<<sp_transaction_pool::runtime_api::*>>
      pub use frame::runtime::apis::ApplyExtrinsicResult
      pub use frame::runtime::apis::CheckInherentsResult
      pub use frame::runtime::apis::InherentData
      pub use frame::runtime::apis::OpaqueMetadata
      pub use frame::runtime::apis::impl_runtime_apis
      pub use frame::runtime::apis::sp_api
      pub mod frame::runtime::prelude
      pub use frame::runtime::prelude::<<frame_executive::*>>
      pub use frame::runtime::prelude::ConstBool
      pub use frame::runtime::prelude::ConstI128
      pub use frame::runtime::prelude::ConstI16
      pub use frame::runtime::prelude::ConstI32
      pub use frame::runtime::prelude::ConstI64
      pub use frame::runtime::prelude::ConstI8
      pub use frame::runtime::prelude::ConstU128
      pub use frame::runtime::prelude::ConstU16
      pub use frame::runtime::prelude::ConstU32
      pub use frame::runtime::prelude::ConstU64
      pub use frame::runtime::prelude::ConstU8
      pub use frame::runtime::prelude::NativeVersion
      pub use frame::runtime::prelude::RuntimeVersion
      pub use frame::runtime::prelude::construct_runtime
      pub use frame::runtime::prelude::create_runtime_str
      pub use frame::runtime::prelude::derive_impl
      pub use frame::runtime::prelude::frame_support
      pub use frame::runtime::prelude::ord_parameter_types
      pub use frame::runtime::prelude::parameter_types
      pub use frame::runtime::prelude::runtime_version
      pub mod frame::runtime::testing_prelude
      pub use frame::runtime::testing_prelude::BuildStorage
      pub use frame::runtime::testing_prelude::Storage
      pub mod frame::runtime::types_common
      pub type frame::runtime::types_common::AccountId = <<frame::runtime::types_common::Signature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId
      pub type frame::runtime::types_common::BlockNumber = u32
      pub type frame::runtime::types_common::BlockOf<T, Extra> = sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<frame::runtime::types_common::BlockNumber, sp_runtime::traits::BlakeTwo256>, sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<sp_runtime::multiaddress::MultiAddress<frame::runtime::types_common::AccountId, ()>, <T as frame_system::pallet::Config>::RuntimeCall, frame::runtime::types_common::Signature, Extra>>
      pub type frame::runtime::types_common::OpaqueBlock = sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<frame::runtime::types_common::BlockNumber, sp_runtime::traits::BlakeTwo256>, sp_runtime::OpaqueExtrinsic>
      pub type frame::runtime::types_common::Signature = sp_runtime::MultiSignature
      pub type frame::runtime::types_common::SystemSignedExtensionsOf<T> = (frame_system::extensions::check_non_zero_sender::CheckNonZeroSender<T>, frame_system::extensions::check_spec_version::CheckSpecVersion<T>, frame_system::extensions::check_tx_version::CheckTxVersion<T>, frame_system::extensions::check_genesis::CheckGenesis<T>, frame_system::extensions::check_mortality::CheckMortality<T>, frame_system::extensions::check_nonce::CheckNonce<T>, frame_system::extensions::check_weight::CheckWeight<T>)
      pub mod frame::testing_prelude
      pub use frame::testing_prelude::<<frame_executive::*>>
      pub use frame::testing_prelude::<<frame_system::mocking::*>>
      pub use frame::testing_prelude::BuildStorage
      pub use frame::testing_prelude::ConstBool
      pub use frame::testing_prelude::ConstI128
      pub use frame::testing_prelude::ConstI16
      pub use frame::testing_prelude::ConstI32
      pub use frame::testing_prelude::ConstI64
      pub use frame::testing_prelude::ConstI8
      pub use frame::testing_prelude::ConstU128
      pub use frame::testing_prelude::ConstU16
      pub use frame::testing_prelude::ConstU32
      pub use frame::testing_prelude::ConstU64
      pub use frame::testing_prelude::ConstU8
      pub use frame::testing_prelude::NativeVersion
      pub use frame::testing_prelude::RuntimeVersion
      pub use frame::testing_prelude::Storage
      pub use frame::testing_prelude::TestState
      pub use frame::testing_prelude::assert_err
      pub use frame::testing_prelude::assert_err_ignore_postinfo
      pub use frame::testing_prelude::assert_error_encoded_size
      pub use frame::testing_prelude::assert_noop
      pub use frame::testing_prelude::assert_ok
      pub use frame::testing_prelude::assert_storage_noop
      pub use frame::testing_prelude::construct_runtime
      pub use frame::testing_prelude::create_runtime_str
      pub use frame::testing_prelude::derive_impl
      pub use frame::testing_prelude::frame_support
      pub use frame::testing_prelude::frame_system
      pub use frame::testing_prelude::if_std
      pub use frame::testing_prelude::ord_parameter_types
      pub use frame::testing_prelude::parameter_types
      pub use frame::testing_prelude::runtime_version
      pub use frame::testing_prelude::storage_alias
      pub mod frame::traits
      pub use frame::traits::<<frame_support::traits::*>>
      pub use frame::traits::<<sp_runtime::traits::*>>
      ```
      
      ---
      
      The road to full stabilization is
      
      - [ ] https://github.com/paritytech/polkadot-sdk/issues/127
      
      
      - [ ] have a more intentional version bump, as opposed to the current bi
      weekly force-major-bump
      - [ ] revise the internal API of `frame`, especially what goes into the
      `prelude`s.
      - [ ] migrate all internal pallets and runtime to use `frame`
      
      ---------
      
      Co-authored-by: default avatarkianenigma <[email protected]>
      Co-authored-by: default avatarKian Paimani <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarFrancisco Aguirre <[email protected]>
      43415ef5
  18. Oct 10, 2023
    • Oliver Tale-Yazdi's avatar
      [FRAME] Warn on unchecked weight witness (#1818) · 64877492
      Oliver Tale-Yazdi authored
      Adds a warning to FRAME pallets when a function argument that starts
      with `_` is used in the weight formula.
      This is in most cases an error since the weight witness needs to be
      checked.
      
      Example:
      
      ```rust
      #[pallet::call_index(0)]
      #[pallet::weight(T::SystemWeightInfo::remark(_remark.len() as u32))]
      pub fn remark(_origin: OriginFor<T>, _remark: Vec<u8>) -> DispatchResultWithPostInfo {
      	Ok(().into())
      }
      ```
      
      Produces this warning:
      
      ```pre
      warning: use of deprecated constant `pallet::warnings::UncheckedWeightWitness_0::_w`: 
                       It is deprecated to not check weight witness data.
                       Please instead ensure that all witness data for weight calculation is checked before usage.
               
                       For more info see:
                           <https://github.com/paritytech/polkadot-sdk/pull/1818>
         --> substrate/frame/system/src/lib.rs:424:40
          |
      424 |         pub fn remark(_origin: OriginFor<T>, _remark: Vec<u8>) -> DispatchResultWithPostInfo {
          |                                              ^^^^^^^
          |
          = note: `#[warn(deprecated)]` on by default
      ```
      
      Can be suppressed like this, since in this case it is legit:
      
      ```rust
      #[pallet::call_index(0)]
      #[pallet::weight(T::SystemWeightInfo::remark(remark.len() as u32))]
      pub fn remark(_origin: OriginFor<T>, remark: Vec<u8>) -> DispatchResultWithPostInfo {
      	let _ = remark; // We dont need to check the weight witness.
      	Ok(().into())
      }
      ```
      
      Changes:
      - Add warning on uncheded weight witness
      - Respect `subkeys` limit in `System::kill_prefix`
      - Fix HRMP pallet and other warnings
      - Update`proc_macro_warning` dependency
      - Delete random folder `substrate/src/src` 🙈
      
       
      - Adding Prdoc
      
      ---------
      
      Signed-off-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarjoe petrowski <[email protected]>
      64877492
  19. Aug 25, 2023
  20. Aug 14, 2023
  21. Aug 09, 2023
  22. Jul 18, 2023
  23. Jul 14, 2023
    • juangirini's avatar
      Replace system config `Index` for `Nonce` (#14290) · 6a29a70a
      juangirini authored
      * replace Index by Nonce
      
      * replace Index by Nonce
      
      * replace Index by Nonce
      
      * replace Index by Nonce
      
      * replace Index by Nonce
      
      * wip
      
      * remove index in lieu of nonce
      
      * wip
      
      * remove accountnonce in lieu of nonce
      
      * add minor improvement
      
      * rebase and merge conflicts
      6a29a70a
  24. Jul 13, 2023
    • gupnik's avatar
      Moves `Block` to `frame_system` instead of `construct_runtime` and removes... · 5e7b27e9
      gupnik authored
      
      Moves `Block` to `frame_system` instead of `construct_runtime` and removes `Header` and `BlockNumber` (#14437)
      
      * Initial setup
      
      * Adds node block
      
      * Uses UncheckedExtrinsic and removes Where section
      
      * Updates frame_system to use Block
      
      * Adds deprecation warning
      
      * Fixes pallet-timestamp
      
      * Removes Header and BlockNumber
      
      * Addresses review comments
      
      * Addresses review comments
      
      * Adds comment about compiler bug
      
      * Removes where clause
      
      * Refactors code
      
      * Fixes errors in cargo check
      
      * Fixes errors in cargo check
      
      * Fixes warnings in cargo check
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Uses import instead of full path for BlockNumber
      
      * Uses import instead of full path for Header
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Fixes imports in benchmarks
      
      * Formatting
      
      * Fixes construct_runtime tests
      
      * Formatting
      
      * Minor updates
      
      * Fixes construct_runtime ui tests
      
      * Fixes construct_runtime ui tests with 1.70
      
      * Fixes docs
      
      * Fixes docs
      
      * Adds u128 mock block type
      
      * Fixes split example
      
      * fixes for cumulus
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Updates new tests
      
      * Fixes fully-qualified path in few places
      
      * Formatting
      
      * Update frame/examples/default-config/src/lib.rs
      
      Co-authored-by: default avatarJuan <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarJuan <[email protected]>
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Addresses some review comments
      
      * Fixes build
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Update frame/democracy/src/lib.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/democracy/src/lib.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/support/procedural/src/construct_runtime/mod.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Addresses review comments
      
      * Updates trait bounds
      
      * Minor fix
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Removes unnecessary bound
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Updates test
      
      * Fixes build
      
      * Adds a bound for header
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Removes where block
      
      * Minor fix
      
      * Minor fix
      
      * Fixes tests
      
      * ".git/.scripts/commands/update-ui/update-ui.sh" 1.70
      
      * Updates test
      
      * Update primitives/runtime/src/traits.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Update primitives/runtime/src/traits.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Updates doc
      
      * Updates doc
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarJuan <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      5e7b27e9
  25. Jul 12, 2023
    • Michal Kucharczyk's avatar
      `GenesisBuild<T,I>` deprecated. `BuildGenesisConfig` added. (#14306) · 87d41d0a
      Michal Kucharczyk authored
      
      
      * frame::support: GenesisConfig types for Runtime enabled
      
      * frame::support: macro generating GenesisBuild::build for RuntimeGenesisConfig
      
      * frame: ambiguity BuildStorage vs GenesisBuild fixed
      
      * fix
      
      * RuntimeGenesisBuild added
      
      * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"
      
      This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293.
      
      * Revert "fix"
      
      This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b.
      
      * Revert "RuntimeGenesisBuild added"
      
      This reverts commit 3c131b618138ced29c01ab8d15d8c6410c9e128b.
      
      * Revert "Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed""
      
      This reverts commit 2b1ecd467231eddec69f8d328039ba48a380da3d.
      
      * Revert "Revert "fix""
      
      This reverts commit fd7fa629adf579d83e30e6ae9fd162637fc45e30.
      
      * Code review suggestions
      
      * frame: BuildGenesisConfig added, BuildGenesis deprecated
      
      * frame: some pallets updated with BuildGenesisConfig
      
      * constuct_runtime: support for BuildGenesisConfig
      
      * frame::support: genesis_build macro supports BuildGenesisConfig
      
      * frame: BuildGenesisConfig added, BuildGenesis deprecated
      
      * Cargo.lock update
      
      * test-runtime: fixes
      
      * Revert "fix"
      
      This reverts commit a2f76dd24e9a16cf9230d45825ed28787211118b.
      
      * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"
      
      This reverts commit 950f3d019d0e21c55a739c44cc19cdabd3ff0293.
      
      * self review
      
      * doc fixed
      
      * ui tests fixed
      
      * fmt
      
      * tests fixed
      
      * genesis_build macrto fixed for non-generic GenesisConfig
      
      * BuildGenesisConfig constraints added
      
      * warning fixed
      
      * some duplication removed
      
      * fmt
      
      * fix
      
      * doc tests fix
      
      * doc fix
      
      * cleanup: remove BuildModuleGenesisStorage
      
      * self review comments
      
      * fix
      
      * Update frame/treasury/src/tests.rs
      
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      
      * Update frame/support/src/traits/hooks.rs
      
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      
      * doc fix: GenesisBuild exposed
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * frame: more serde(skip) + cleanup
      
      * Update frame/support/src/traits/hooks.rs
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * frame: phantom fields moved to the end of structs
      
      * chain-spec: Default::default cleanup
      
      * test-runtime: phantom at the end
      
      * merge master fixes
      
      * fix
      
      * fix
      
      * fix
      
      * fix
      
      * fix (facepalm)
      
      * Update frame/support/procedural/src/pallet/expand/genesis_build.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * fmt
      
      * fix
      
      * fix
      
      ---------
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      87d41d0a
  26. Jun 12, 2023
  27. Jun 04, 2023
  28. Jun 01, 2023
    • Michal Kucharczyk's avatar
      frame: support for serde added (#14261) · dc716127
      Michal Kucharczyk authored
      
      
      * frame: support for serde added
      
      - enabled `serde` features in dependent crates, no gate feature introduced, linker should do the job and strip unused code.
      
      - frame::staking: added impl of `serde::Serialize, serde::Deserialize` for `enum Forcing`
      
      - primitives::runtime: impl_opaque_keys macro provides `Serialize/Deserialize` impl if `serde` is enabled
      
      - primitives::staking: added impl of `serde::Serialize`, `serde::Deserialize` for `enum StakerStatus`
      
      * frame::support: serde for pallets' GenesisConfig enabled in no-std
      
      * Cargo.lock updated
      
      * Update primitives/staking/Cargo.toml
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * fix
      
      * Cargo.lock update + missed serde/std in beefy
      
      ---------
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      dc716127
  29. May 30, 2023
    • Kian Paimani's avatar
      Default Pallet Config Trait / derive_impl (#13454) · 263a5d6c
      Kian Paimani authored
      
      
      * first draft, probably won't work
      
      * first draft, probably won't work
      
      * good progress..
      
      * good milestone, still a lot to do.
      
      * EVERYTHING WORKS
      
      * Update frame/support/procedural/src/derive_impl.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Update frame/support/procedural/src/derive_impl.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * clean up + cargo fmt
      
      * import tokens WIP
      
      * export_tokens working with impl Trait
      
      * WIP / notes
      
      * use macro_magic 0.2.0's export_tokens to access foreign items
      
      * token importing working properly using macro_magic 0.2.5
      
      * combine_impls almost working
      
      * successfully get foreign path via macro_magic 0.2.6
      
      * combine_impls using implementing_type generics
      
      * working + clean up
      
      * more clean up
      
      * decrease rightwards drift and add docs to combine_impls
      
      * add support for macros to impl_item_ident in case we hit that
      
      * add docs for impl_item_ident method
      
      * fix no_std issues
      
      * re-export of macro_magic working in pallets 🎉
      
      * clean up + fully resolve no_std issue with macro_magic with v0.2.11
      
      * remove trait item code for different trait item types since this
      is now handled directly by combine_impls
      
      * clean up
      
      * remove dev comments
      
      * only generate default trait if #[pallet::default_trait] is attached
      
      * authorship and most other pallets now compiling
      
      * compiling 🎉
      
      * add check for more than two pallet attributes on Config trait
      
      * remove unused import in nomination-pool
      
      * clean up debug code
      
      * upgrade to macro_magic v0.2.12
      
      * add neater #[register_default_config(SomeIdent)] macro
      
      * really just a thin wrapper around #[export_tokens]
      
      * upgrade to macro_magic 0.3.1
      
      * rewrite parsing to be compatible with syn 2.x, compiling 🎉
      
      
      
      * remove unused keywords
      
      * macro stubs for the new pallet:: macros, preliminary docs
      
      * upgrade to macro_magic v0.3.2
      
      * rename register_default_config => register_default_impl
      
      * bump to macro_magic v0.3.3
      
      * custom disambiguation_path working as 2nd arg to derive_impl
      
      * overhaul docs
      
      * fixes, ident-style paths shortcut working
      
      * remove ident-style shortcut because it makes testing difficult
      
      * add passing UI tests for derive_impl
      
      * switch to `ForeignPath as DisambiguationPath` syntax + update docs
      
      * add UI test for bad foreign path
      
      * add UI test for bad disambiguation path
      
      * add UI test for missing disambiguation path
      
      * add UI test for attached to non impl
      
      * fix derive_impl_attr_args_parsing test
      
      * move tests to bottom
      
      * fix nightly issue
      
      * add doc notes on importing/re-exporting
      
      * remove explicit use of macro_magic::use_attr
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * use explicit macro_magic::use_attr
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * remove unneeded {}
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * remove unneeded collect
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * add docs for TestDefaultConfig
      
      * remove unneeded `#[export_tokens]` on `DefaultConfig`
      
      * add docs for auto-generated `DefaultConfig`
      
      * no need to clone
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * clean up combine_impls + compiling again
      
      * remove unused dependency
      
      * simplify struct definition
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * fix register_default_impl docs
      
      * reduce rightward drift / refactor
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * fix derive_impl after keith's changes
      
      * simplify disambiguation_path calculation
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * compiling again
      
      * simplify parsing of trait item
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * rename preludes => prelude
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * fix other places where we used preludes instead of prelude
      
      * fix indents
      
      * simplify PalletAttr parsing
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * go back to having no_default and constant as keywords
      
      * make it more clear that disambiguation_path is optional
      
      * make default_trait_items just a Vec instead of Option<Vec>
      
      * rename foreign_path => default_impl_path within substrate
      
      * fix docs
      
      * Change {} to ;
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * highlight full end-to-end example with link
      
      * add pallet-default-config-example, start by copying dev mode code
      
      * update dev-mode specific docs
      
      * use Person and Points instead of Dummy and Bar
      
      * add docs to example pallet
      
      * revert changes to pallets other than the default config example
      
      * fix outdated references to basic example pallet
      
      * re-order docs to be a bit more clear
      
      * better errors for extra attributes
      
      * add UI tests for duplicate/extra attributes on trait items
      
      * change `#[pallet::default_config]` to option on `#[pallet::config()]`
      
      * update UI tests
      * add UI test covering missing `#[pallet::config(with_default)]` when
        `#[pallet::no_default]` is used
      
      * add note about new optional conventions
      
      * improve docs about `DefaultConfig` and link to these from a few places
      
      * fix doc comment
      
      * fix old comment referencing `pallet::default_config`
      
      * use u32 instead of u64 for block number
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * use () instead of u32 for `AccountData`
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * use ConstU32<10> for BlockHashCount instead of ConstU64<10>
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * people are not dummies
      
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      
      * fix wording
      
      Co-authored-by: default avatarJust van Stam <[email protected]>
      
      * Person => People and compiling again
      
      * add docs for `prelude` module in frame_system
      
      * update Cargo.lock
      
      * cleaner example
      
      * tweaks
      
      * update docs more
      
      * update docs more
      
      * update docs more
      
      * update docs more
      
      * fix ui tests
      
      * err
      
      * Update frame/support/test/tests/pallet_ui.rs
      
      * update ui tests
      
      ---------
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: default avatarSam Johnson <[email protected]>
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      Co-authored-by: default avatarLiam Aharon <[email protected]>
      Co-authored-by: default avatarJust van Stam <[email protected]>
      263a5d6c
  30. May 25, 2023
    • Michal Kucharczyk's avatar
      frame: GenesisBuild::build allowed in no_std (#14107) · e31a214a
      Michal Kucharczyk authored
      * frame: GenesisBuild::build allowed in no_std
      
      i`GenesisBuild::build` function will be required for no_std in no native
      runtime world.
      
      `GenesisBuild::build` macro generated function allows to build the runtime
      GenesisConfig assembled from all pallets' GenesisConfigs.
      
      * fixes
      
      * GenesisBuild::build avaiable in no-std
      
      - #[cfg(feature = "std")] is not longer added to GenesisBuild implementation.
      
      * system: hash69 available for no-std
      
      * elections-phragmen: panic message fixed for no_std
      
      * frame::suport: doc updated
      
      * test-runtime: default for GenesisConfig
      
      * frame::test-pallet: serde/std added to std feature deps
      
      * Cargo.toml: deps sorted
      
      * Cargo.lock update
      
      cargo update -p frame-support-test-pallet -p frame-support-test
      
      * frame ui tests: cleanup
      
      ---------
      
      Co-authored-by: parity-processbot <>
      e31a214a
  31. May 20, 2023
    • Michal Kucharczyk's avatar
      frame: Enable GenesisConfig in no_std (#14108) · 613420a0
      Michal Kucharczyk authored
      * frame: Default for GenesisConfig in no_std
      
      `Default` for `GenesisConfig` will be required for no_std in no native
      runtime world. It must be possible to instantiate default GenesisConfig
      for pallets and runtime.
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * hash69 in no_std reverted
      
      * derive(DefaultNoBound) for GenesisConfig used when possible
      
      * treasury: derive(Default)
      
      * Cargo.lock update
      
      * genesis_config: compiler error improved
      
      When std feature is not enabled for pallet, the GenesisConfig will be
      defined, but serde::{Serialize,Deserialize} traits will not be
      implemented.
      
      The compiler error indicates the reason of latter errors.
      
      This is temporary and serde traits will be enabled with together with
      `serde` support in frame.
      
      ---------
      
      Co-authored-by: command-bot <>
      613420a0
  32. May 16, 2023
  33. May 15, 2023
  34. May 11, 2023
  35. May 04, 2023
    • Arkadiy Paronyan's avatar
      Statement store (#13701) · bfafbf7b
      Arkadiy Paronyan authored
      
      
      * WIP Statement store
      
      * Sync with networking changes in master
      
      * WIP statement pallet
      
      * Statement validation
      
      * pallet tests
      
      * Validation queue
      
      * Store maintenance
      
      * Basic statement refactoring + tests + docs
      
      * Store metrics
      
      * Store tests
      
      * Store maintenance test
      
      * cargo fmt
      
      * Build fix
      
      * OCW Api
      
      * Offchain worker
      
      * Enable host functions
      
      * fmt
      
      * Minor tweaks
      
      * Fixed a warning
      
      * Removed tracing
      
      * Manual expiration
      
      * Reworked constraint management
      
      * Updated pallet constraint calculation
      
      * Added small test
      
      * Added remove function to the APIs
      
      * Copy-paste spec into readme
      
      * Comments
      
      * Made the store optional
      
      * Removed network protocol controller
      
      * fmt
      
      * Clippy fixes
      
      * fmt
      
      * fmt
      
      * More clippy fixes
      
      * More clippy fixes
      
      * More clippy fixes
      
      * Update client/statement-store/README.md
      
      Co-authored-by: default avatarcheme <[email protected]>
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Removed sstore from node-template
      
      * Sort out data path
      
      * Added offline check
      
      * Removed dispatch_statement
      
      * Renamed into_generic
      
      * Fixed commit placement
      
      * Use HashSet for tracking peers/statements
      
      * fmt
      
      * Use ExtendedHostFunctions
      
      * Fixed benches
      
      * Tweaks
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarcheme <[email protected]>
      
      * Fixed priority mixup
      
      * Rename
      
      * newtypes for priorities
      
      * Added MAX_TOPICS
      
      * Fixed key filtering logic
      
      * Remove empty entrie
      
      * Removed prefix from signing
      
      * More documentation
      
      * fmt
      
      * Moved store setup from sc-service to node
      
      * Handle maintenance task in sc-statement-store
      
      * Use statement iterator
      
      * Renamed runtime API mod
      
      * fmt
      
      * Remove dump_encoded
      
      * fmt
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Fixed build after applying review suggestions
      
      * License exceptions
      
      * fmt
      
      * Store options
      
      * Moved pallet consts to config trait
      
      * Removed global priority
      
      * Validate fields when decoding
      
      * Limit validation channel size
      
      * Made a comment into module doc
      
      * Removed submit_encoded
      
      ---------
      
      Co-authored-by: default avatarcheme <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      bfafbf7b
  36. Apr 26, 2023
    • Gavin Wood's avatar
      Various minor fixes (#13945) · 781ea7cb
      Gavin Wood authored
      
      
      * Fix: Incorrect implementation of can_reserve check
      
      * Fix: Incorrect migration of consumer counting for existing accounts with frozen amounts
      
      * Fix: Inconsistent implementation between assets can_deposit and new_account
      
      * Fixes
      
      * Fixes
      
      * Another fix
      
      * Update tests.rs
      
      * Update fungible_tests.rs
      
      * Use `can_accrue_consumers` in the body of `can_inc_consumer`
      
      ---------
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      Co-authored-by: parity-processbot <>
      781ea7cb