1. Jan 30, 2024
  2. Jan 22, 2024
  3. Jan 15, 2024
    • Liam Aharon's avatar
      Unbalanced and Balanced fungible conformance tests, and fungible fixes (#1296) · 46090ff1
      Liam Aharon authored
      Original PR https://github.com/paritytech/substrate/pull/14655
      
      ---
      
      Partial https://github.com/paritytech/polkadot-sdk/issues/225
      
      - [x] Adds conformance tests for Unbalanced
      - [x] Adds conformance tests for Balanced
      - Several minor fixes to fungible default implementations and the
      Balances pallet
      - [x] `Unbalanced::decrease_balance` can reap account when
      `Preservation` is `Preserve`
      - [x] `Balanced::pair` can return pairs of imbalances which do not
      cancel each other out
         - [x] Balances pallet `active_issuance` 'underflow'
      - [x] Refactors the conformance test file structure to match the
      fungible file structure: tests for traits in regular.rs go into a test
      file named regular.rs, tests for traits in freezes.rs go into a test
      file named freezes.rs, etc.
       - [x] Improve doc comments
       - [x] Simplify macros
      
      ## Fixes
      
      ### `Unbalanced::decrease_balance` can reap account when called with
      `Preservation::Preserve`
      There is a potential issue in the default implementation of
      `Unbalanced::decrease_balance`. The implementation can delete an account
      even when it is called with `preservation: Preservation::Preserve`. This
      seems to contradict the documentation of `Preservation::Preserve`:
      
      ```rust
      	/// The account may not be killed and our provider reference must remain (in the context of
      	/// tokens, this means that the account may not be dusted).
      	Preserve,
      ```
      
      I updated `Unbalanced::decrease_balance` to return
      `Err(TokenError::BelowMinimum)` when a withdrawal would cause the
      account to be reaped and `preservation: Preservation::Preserve`.
      
      - [ ] TODO Confirm with @gavofyork that this is correct behavior
      
      Test for this behavior:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L912-L937
      
      ### `Balanced::pair` returning non-canceling pairs
      
      `Balanced::pair` is supposed to create a pair of imbalances that cancel
      each other out. However this is not the case when the method is called
      with an amount greater than the total supply.
      
      In the existing default implementation, `Balanced::pair` creates a pair
      by first rescinding the balance, creating `Debt`, and then issuing the
      balance, creating `Credit`.
      
      When creating `Debt`, if the amount to create exceeds the
      `total_supply`, `total_supply` units of `Debt` are created *instead* of
      `amount` units of `Debt`. This can lead to non-canceling amount of
      `Credit` and `Debt` being created.
      
      To address this, I create the credit and debt directly in the method
      instead of calling `issue` and `rescind`.
      
      Test for this behavior:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L1323-L1346
      
      ### `Balances` pallet `active_issuance` 'underflow'
      
      This PR resolves an issue in the `Balances` pallet that can lead to odd
      behavior of `active_issuance`.
      
      Currently, the Balances pallet doesn't check if `InactiveIssuance`
      remains less than or equal to `TotalIssuance` when supply is
      deactivated. This allows `InactiveIssuance` to be greater than
      `TotalIssuance`, which can result in unexpected behavior from the
      perspective of the fungible API.
      
      `active_issuance` is derived from
      `TotalIssuance.saturating_sub(InactiveIssuance)`.
      
      If an `amount` is deactivated that causes `InactiveIssuance` to become
      greater TotalIssuance, `active_issuance` will return 0. However once in
      that state, reactivating an amount will not increase `active_issuance`
      by the reactivated `amount` as expected.
      
      Consider this test where the last assertion would fail due to this
      issue:
      
      
      https://github.com/paritytech/polkadot-sdk/blob/e5c876dd6b59e2b7dbacaa4538cb42c802db3730/substrate/frame/support/src/traits/tokens/fungible/conformance_tests/regular.rs#L1036-L1071
      
      
      
      To address this, I've modified the `deactivate` function to ensure
      `InactiveIssuance` never surpasses `TotalIssuance`.
      
      ---------
      
      Co-authored-by: default avatarMuharem <[email protected]>
      46090ff1
  4. Jan 05, 2024
  5. Dec 19, 2023
  6. Nov 30, 2023
  7. Nov 28, 2023
  8. Nov 01, 2023
  9. Oct 30, 2023
  10. Oct 24, 2023
  11. Oct 17, 2023
  12. Oct 16, 2023
  13. Oct 13, 2023
  14. Oct 01, 2023
  15. Sep 17, 2023
  16. Sep 06, 2023
  17. Aug 30, 2023
  18. Aug 25, 2023
    • gupnik's avatar
      Adds ability to provide defaults for types provided by `construct_runtime` (#14682) · 83ae0180
      gupnik authored
      
      
      * Adds ability to use defaults for verbatim types
      
      * Adds RuntimeOrigin and PalletInfo in DefaultConfig
      
      * Adds RuntimeEvent in DefaultConfig
      
      * Adds RuntimeEvent in DefaultConfig
      
      * Minor fix
      
      * Minor fix
      
      * Everything in frame_system can now have a default
      
      * Adds docs
      
      * Adds UI Test for no_bounds
      
      * Updates docs
      
      * Adds UI tests for verbatim
      
      * Minor update
      
      * Minor updates
      
      * Minor updates
      
      * Addresses review comments
      
      * Fixes test
      
      * Update frame/support/procedural/src/derive_impl.rs
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      
      * Minor fix
      
      * Minor
      
      * Fixes build
      
      * Uses runtime_type
      
      * Fixes comment
      
      * Fixes comment
      
      * Fixes test
      
      * Uses no_aggregated_types as an option in derive_impl
      
      * Uses specific imports
      
      * Fmt
      
      * Updates doc
      
      * Update frame/support/procedural/src/derive_impl.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Update frame/support/procedural/src/derive_impl.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Addresses review comment
      
      * Addresses review comment
      
      * fmt
      
      * Renames test files
      
      * Adds docs using docify
      
      * Fixes test
      
      * Fixes UI tests
      
      ---------
      
      Co-authored-by: default avatarKeith Yeung <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      83ae0180
  19. Aug 23, 2023
    • juangirini's avatar
      Restructure `frame_support` macro related exports (#14745) · 878c562c
      juangirini authored
      
      
      * make reexports private
      
      * make reexports private 2
      
      * make reexports private for runtime-benchmarking
      
      * make reexports private for try-runtime
      
      * fix for try-runtime
      
      * make reexports private for tests
      
      * fmt
      
      * make reexports private for tests
      
      * make reexports private for experimental
      
      * fix beefy
      
      * fix ui test
      
      * fix ui test
      
      * fix benches
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * fix contracts use
      
      * wip
      
      * wip
      
      * do not reexport sp_api::metadata_ir
      
      * fix CI checks
      
      * fix support tests
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * Update frame/support/src/lib.rs
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * import codec directly
      
      * fmt
      
      * fix node-cli tests
      
      ---------
      
      Co-authored-by: command-bot <>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      878c562c
  20. Aug 14, 2023
  21. Jul 14, 2023
  22. 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
  23. 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
    • PG Herveou's avatar
      quick updates (#14557) · 49150ee5
      PG Herveou authored
      49150ee5
  24. Jul 07, 2023
  25. Jun 19, 2023
  26. Jun 14, 2023
  27. Jun 02, 2023
  28. May 24, 2023
    • Bastian Köcher's avatar
      HoldReason: Improve usage (#13869) · 05da6d8e
      Bastian Köcher authored
      
      
      * HoldReason: Improve usage
      
      `HoldReason` was switched recently to use the `composite_enum` attribute that will merge the enums
      from all pallets in the runtime to `RuntimeHoldReason`. `pallet-nis` was still requiring that the
      variant was passed as constant to call `hold`. The proper implementation is to use the `HoldReason`
      from inside the pallet directly when calling `hold`. This is done by adding a `RuntimeHoldReason` as
      type to the `Config` trait and requiring that `Currency` is using the same reason. Besides that the
      pr changes the name `HoldIdentifier` in `pallet_balances::Config` to `RuntimeHoldReason`.
      
      * Update frame/nis/src/lib.rs
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      
      * Review comment
      
      * Fixes
      
      ---------
      
      Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
      05da6d8e
  29. May 23, 2023
  30. 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
  31. May 17, 2023
  32. May 04, 2023
    • Liam Aharon's avatar
      fungible conformance tests: Inspect and Mutate (#13852) · 9c53fd72
      Liam Aharon authored
      
      
      * typo
      
      * - create test files for each fungile trait
      - begin implementing tests for the Inspect trait
      
      * wrap inspect tests in a macro
      
      * first run of mutate tests
      
      * move test implementation out of ballances
      
      * make tests more generic
      
      * transfer tests
      
      * combine inspect and mutate tests
      
      * set balance failing tests
      
      * can_deposit tests
      
      * can_withdraw tests
      
      * test reducible_balance
      
      * remove balanced stub
      
      * revert set_balance return val fix
      
      * typo
      
      * macro and dust trap tests
      
      * disable test when it doesn't make sense
      
      * remove debug comment
      
      * reduce macro boilerplate
      
      * improved var naming
      
      * improve variable naming
      
      * remove redundant comment
      
      * remove placeholder tests
      
      * remove placeholder tests
      
      * simplify macro
      
      * Update frame/balances/src/tests/fungible_conformance_tests.rs
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      
      * use Balance from T
      
      * fix copyright
      
      * add test doc comments
      
      * improve test naming
      
      * clippy
      
      * fix rustdoc errors
      
      * fix rustdoc
      
      * improve macro
      
      * improve variable naming
      
      * remove redundant comment
      
      * use path
      
      ---------
      
      Co-authored-by: default avatarKian Paimani <[email protected]>
      9c53fd72
  33. Apr 27, 2023
  34. 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
  35. Apr 21, 2023
  36. Apr 17, 2023