Rust-Substrate monthly-2022-01: Substrate โ€” Generic modular blockchain template written in Rust

Latest Release: monthly-2022-01

Automatic snapshot pre-release monthly-2022-01

Changes since last snapshot (monthly-2021-12)

Substrate changes


  • Inner hashing of value in state trie (runtime versioning). (#9732)
  • Emit ContractReverted error when revert flag is set (#10481)
  • Fix update_lock (#10485)
  • Remove Default bound for AccountId (#10403)
  • Preimage registrar and Scheduler integration (#10356)
  • Fix reset curator deposit when curator unassigns themself. (#10443)
  • Insufficient asset quota and deposits (#10382)
  • Introduce CheckNonZeroSender (#10413)
  • Add extrinsic to improve position in a bag of bags-list (#9829)
  • Add child-bounties pallet. (#10309)
  • contracts: Add storage deposits (#10082)
  • Minimum commission for validators (#10347)


  • Inner hashing of value in state trie (runtime versioning). (#9732)
  • SlotDuration: Always fetch the slot duration from the runtime (#10509)
  • Add ClassAccount storage to unique pallet (#9940)
  • Add logger configuration hook (#10440)
  • Automatically unsubscribe storage listeners when they're dropped (RCP node memory leak fix) (#10454)
  • Remove Prometheus metrics prefix (#9543)
  • allow try-runtime and TestExternalities to report PoV size (#10372)
  • No longer include :code and :heappages in execution proofs (#10419)


  • Inner hashing of value in state trie (runtime versioning). (#9732)
  • Customizable ink address (#10521)
  • add to (#10524)
  • Authentication of PeerIds in authority discovery records (#10317)
Source code(tar.gz)
Source code(zip)

Substrate ยท GitHub license GitLab Status PRs Welcome

Substrate is a next-generation framework for blockchain innovation ? .

Trying it out

Simply go to and follow the installation instructions. You can also try out one of the tutorials.

Contributions & Code of Conduct

Please follow the contributions guidelines as outlined in docs/CONTRIBUTING.adoc. In all communications and contributions, this project follows the Contributor Covenant Code of Conduct.


The security policy and procedures can be found in docs/


The reason for the split-licensing is to ensure that for the vast majority of teams using Substrate to create feature-chains, then all changes can be made entirely in Apache2-licensed code, allowing teams full freedom over what and how they release and giving licensing clarity to commercial teams.

In the interests of the community, we require any deeper improvements made to Substrate's core logic (e.g. Substrate's internal consensus, crypto or database code) to be contributed back so everyone can benefit.


  • Fixes for Referenda and Conviction Voting
    Fixes for Referenda and Conviction Voting

    Jan 24, 2022

    in progress

  • Update on_initialize weight calculations in MMR
    Update on_initialize weight calculations in MMR

    Jan 24, 2022

    Fixes @acatangiu take a look

  • Improve block-selection strategy
    Improve block-selection strategy

    Jan 24, 2022


    Round selection formula updated to match

    round_number =
          (1 - M) * session_start  
    +    M * (best_beefy + NEXT_POWER_OF_TWO((best_grandpa - best_beefy + 1) / 2)) 

    as outlined in

    Session boundary API that is used here is already implemented in

    A0-pleasereview B0-silent C1-low ๐Ÿ“Œ D3-trivial ๐Ÿงธ 
  • Fix lazy batch contract removal
    Fix lazy batch contract removal

    Jan 24, 2022

    This PR fixes a minor bug in lazy removal of smart contracts.

    A contract is removed in two steps. Firstly, it disappears from contract lookup (its info is gone). This phase is cheap and thus immediately performed. However, cleaning a storage may be an expensive operation, hence it is done lazily. We keep a (bounded) queue of the contracts to be removed and in the beginning of each block we try to remove as many as possible. The method process_deletion_queue_batch in frame/contracts/src/ is supposed to do so. However, PR #9669 has changed semantics a little bit (while -> if), which resulted in removing at most one contract at a time.

    A0-pleasereview B7-runtimenoteworthy C1-low ๐Ÿ“Œ D2-notlive ๐Ÿ’ค 
  • Corrected description of clear_attribute extrinsic
    Corrected description of clear_attribute extrinsic

    Jan 25, 2022

    Content of this PR is quite simple. During investigation of pallet_uniques I found wrong description for the clear_attribute extrinsic, this description was definitely copy-pasted from the set_attribute extrinsic. I want to fix this small issue.

  • [jsonrpsee]: enable custom subid gen through spawn_tasks
    [jsonrpsee]: enable custom subid gen through spawn_tasks

    Jan 25, 2022

    I don't like this PR but I haven't found another way to be able to pass down custom id_provider type to the servers.

    Also Option<Box<dyn IdProvider>> won't work because of

    Needed by

    Any suggestions?

  • Support get asset id by name in pallet_assets.
    Support get asset id by name in pallet_assets.

    Jan 26, 2022

    In pallet_assets, InspectMetadata trait is implemented. We can use assetId to query asset related information, but we can't query assetId in reverse according to the asset name.

  • Support get asset id by name in pallet_assets.
    Support get asset id by name in pallet_assets.

    Jan 26, 2022

    Support get asset id by name in pallet_assets as issue #10732 described.

  • [ci] pipeline chores
    [ci] pipeline chores

    Jan 26, 2022

    Part of

    A0-pleasereview B0-silent C1-low ๐Ÿ“Œ 
  • add CheckNonZeroSender in node-template-runtime
    add CheckNonZeroSender in node-template-runtime

    Jan 26, 2022 did not add the CheckNonZeroSender extension to the node template. This PR remedies that.

    A0-pleasereview B3-apinoteworthy C1-low ๐Ÿ“Œ 
  • pallet-vesting: Support multiple, merge-able vesting schedules
    pallet-vesting: Support multiple, merge-able vesting schedules

    Jun 24, 2021

    closes: polkadot companion:


    • Support multiple vesting schedules per account. Each account is allowed up to MaxVestingSchedules, which is a configurable pallet constant.
    • A user can merge two schedules together to create a new schedule. See the new merge_schedules extrinsic

    Follow up work

    • Look into adding a vesting derive to polkadot-js that helps with understanding the affects of merging a schedule


    • [x] make sure all instances of per_block are replace with One::one if it equals 0. (
    • [x] weights
    • [x] polkadot companion
    • [x] migration (check if any faulty schedules exist in polkadot)
    • [x] make sure tests cover (checked everything expect still need to figure out how force invalid vec length)
      • all dispatcherror paths are checked as noop <-- (a lot, and its important)
        • max length
        • validation of input โœ”๏ธ
        • etc
      • shows single vesting is working just like before โœ”๏ธ
      • shows multiple vesting works as expected โœ”๏ธ
        • as a vesting ends, the vec is auto cleaned up
        • the last assertion at the end of N blocks is that the user has no vesting storage item left โœ”๏ธ
      • merges two ongoing vesting schedules โœ”๏ธ
      • merges one ended and one ongoing schedule โœ”๏ธ
      • merges two ended schedules โœ”๏ธ
      • merge ongoing and yet to be started schedule โœ”๏ธ
      • merge ended and yet to be started schedule โœ”๏ธ
      • merge 2 not yet started schedules โœ”๏ธ
      • Check div by zero โœ”๏ธ
    A0-pleasereview A7-needspolkadotpr B7-runtimenoteworthy C3-medium ๐Ÿ“ฃ D1-audited ๐Ÿ‘ 
  • Add missing fields to the light sync state
    Add missing fields to the light sync state

    Sep 28, 2020

    Part of #6804.

    polkadot companion:

    A0-pleasereview B0-silent C1-low ๐Ÿ“Œ 
  • Merge metadata by module
    Merge metadata by module

    Jan 14, 2019

    This PR is an ongoing work on #840.

    Technically this PR does some joining on metadata depending on module prefix.

    A8-mergeoncegreen E5-breaksapi 
  • BREAKING Overlay transaction support.
    BREAKING Overlay transaction support.

    Jul 30, 2019

    BREAKING: this pr adds externalities, and change mutability of existing one, the corresponding

    This PR is a refactor of overlay_change to allow transactional support, it is similar to #2980 goals, but does not stack Ext, it only stacks storage.

    It also switches from a stack of hashmap (previously prospective and top) to a single hashmap (containing history of values) and a transaction global state. Those values with state are managed with 'historied-data' crate (simple vec of data to query in front of a reference global state).

    Under this design access to data is not badly impacted by the number of open transactional layers. I did fuzz this code a bit against a partial simple layered hashmap implementation.

    Usage from a runtime with a function, in a similar way as ext_try from #2980, there is the very simple with_transaction function: internally it uses three host functions ext_start_transaction, ext_commit_transaction and ext_discard_transaction. This does not look as good as the single ext_try but is clearer:ย memory mgmt seems way simplier (as there is none).

    Note that to call global state action, modification of local values need to be synchronize. eg discard_transaction on states must be follow by apply_discard_transaction for all values related to this state and then follow by ensure_running.

    Technically we only maintain a counter of current number of stacked transaction as a global state (this start at 1 and can be 0 only to update some values: case of discarding content, but will then return to 1 through 'finalize_discard' call). Local state is either committed or the number of stacked transaction when the value was changed, this state is stored with the value history.

    polkadot companion:

    A0-pleasereview B3-apinoteworthy E5-breaksapi 
  • Batch signature verification
    Batch signature verification

    Feb 22, 2020

    polkadot companion:

    A0-pleasereview E5-breaksapi 
  • [DO NOT MERGE] Test Benchmark Bot
    [DO NOT MERGE] Test Benchmark Bot

    Sep 1, 2021

    Testing the benchmark bot

    [skip ci]

  • Implement `pallet-bags-list` and its interfaces with `pallet-staking`
    Implement `pallet-bags-list` and its interfaces with `pallet-staking`

    Aug 5, 2021


    polkadot companion

    Notes for reviewers

    Below is a table describing how an extrinsic would affect an account (relative to SortedListProvider and CounterForNominators) given its role in staking:

    | extrinsic | Chilled | Nominator | Validator | |:------------------:|:----------------------:|:----------------------:|------------------------| | chill, chill_other | nothing, nothing | on_remove, dec counter | nothing, nothing | | nominate | on_insert, inc counter | nothing, nothing | on_insert, inc counter | | validate | nothing, nothing | on_remove, dec counter | nothing, nothing | | bond_extra | nothing, nothing | on_update, nothing | nothing, nothing | | rebond | nothing, nothing | on_update, nothing | nothing, nothing | | unbond | nothing, nothing | on_update, nothing | nothing, nothing |


    • [x] update benchmarks of extrinsics that call do_rebag to force a rebag (relates to some work done in
    • [x] Check the benchmark values for snapshot creation. There are some tests that tell us how many snapshot items we can take in a 2 second block.
    • [x] Write a remote-externalities-based test that checks the state of polkadot and substrate, and populates the list. Same as testing the migration basically: Done in companion.
    • [x] Test migration

    • [ ] (seperate_pr) Make all staking tests work with and without bags-list. For now we use bags-list only, and we do this in a follow up, to prevent a single super big PR.
    • [x] rename and fix docs, avoid using voter in bags-list, it should be id and vote-weight. Ideally we could also use something like priority instead of vote-weight.
    • [ ] (maybe+separate PR) Write a fuzzer/quick test that just bombards the SortedListProvider with random data and calls, and the internal state of the pallet should always remain correct. (
    • [ ] (seperate pr) weight refunds for when the operation does not affect nominators (and thus not the bags list)
    • [ ] (separate PR) Allow the ability to reorder yourself within a bag.

    original description for #9081 below:

    Problem: there are too many nominators, we can't keep all of them. Solution: truncate the list by stake.

    Problem: an attacker can kick out as many people as they can afford to; those people at the low end would need to re-nominate. Solution: don't actually take them out of the nominator set, but compute the top N members at runtime.

    Problem: computing the top N at runtime is expensive. Solution: create many bags, each of which holds voters within a particular stake range. Each bag is a linked list, so it can be added to and removed from in O(1). We can then iterate over the bags in order and truncate anywhere we desire. Given a realistic distribution of stake, it doesn't matter where we stop; the final bag is the one with the lowest-staked individuals.

    polkadot companion:

    A0-pleasereview B7-runtimenoteworthy E1-runtimemigration C1-low ๐Ÿ“Œ D1-audited ๐Ÿ‘ 
  • Reweigh Staking
    Reweigh Staking

    Sep 25, 2020

    This PR does a sanity check of the weights in the Staking pallet.

    A8-mergeoncegreen B0-silent C1-low ๐Ÿ“Œ 
  • Benchmarking also benchmark for decoding the call
    Benchmarking also benchmark for decoding the call

    Jul 13, 2021

    in the benchmarking macro, when user use the syntax: bench_name { $code }: $dispatch_name($origin, $args) verify { $code }, the benchmark only dispatch the call. This PR changes it, instead the benchmark decode the call and dispatch it.

    Breaking change

    Some benchmark code won't compile complaining about partially moved variables. It should be generally easily fixable using clone.

    A0-pleasereview B3-apinoteworthy C1-low ๐Ÿ“Œ D5-nicetohaveaudit โš ๏ธ 
  • update README.adoc
    update README.adoc

    Mar 20, 2021

    Fixes for better understanding and reading to developers. Added exact outputs and specific word names.

    Thank you for your Pull Request!

    Before you submitting, please check that:

    • [x] You added a brief description of the PR, e.g.:
      • What does it do?
      • What important points reviewers should know?
      • Is there something left for follow-up PRs?
    • [ ] You labeled the PR appropriately if you have permissions to do so:
      • [ ] A* for PR status (one required)
      • [ ] B* for changelog (one required)
      • [ ] C* for release notes (exactly one required)
      • [ ] D* for various implications/requirements
      • [ ] Github's project assignment
    • [ ] You mentioned a related issue if this PR related to it, e.g. Fixes #228 or Related #1337.
    • [ ] You asked any particular reviewers to review. If you aren't sure, start with GH suggestions.
    • [ ] Your PR adheres to the style guide
      • In particular, mind the maximal line length of 100 (120 in exceptional circumstances).
      • There is no commented code checked in unless necessary.
      • Any panickers have a proof or removed.
    • [ ] You bumped the runtime version if there are breaking changes in the runtime.
    • [ ] You updated any rustdocs which may have changed
    • [ ] Has the PR altered the external API or interfaces used by Polkadot? Do you have the corresponding Polkadot PR ready?

    Refer to the contributing guide for details.

    After you've read this notice feel free to remove it. Thank you!

    โœ„ -----------------------------------------------------------------------------

    A2-insubstantial B0-silent C1-low ๐Ÿ“Œ