Skip to content

Conversation

@kianenigma
Copy link
Contributor

@kianenigma kianenigma commented Oct 17, 2023

closes #1882

Breaking Changes

This PR introduces a new item to pallet_balances::Config:

trait Config {
++    type RuntimeFreezeReasons;
}

This value is only used to check it against type MaxFreeze. A similar check has been added for MaxHolds against RuntimeHoldReasons, which is already given to pallet_balances.

In all contexts, you should pass the real RuntimeFreezeReasons generated by construct_runtime to type RuntimeFreezeReasons. Passing () would also work, but it would imply that the runtime uses no freezes at all.

@kianenigma kianenigma added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Oct 17, 2023
@kianenigma kianenigma requested review from a team October 17, 2023 07:21
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Copy link
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

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

If we have many of these lines up to migrate to DefaultConfig, it might be best to wait for that. Thoughts?

I think we would wait forever... i did some replacements and it seems to compile. Will push in a minute.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez requested a review from a team October 17, 2023 10:21
type ReserveIdentifier = TestId;
type WeightInfo = ();
type RuntimeHoldReason = TestId;
type RuntimeFreezeReason = RuntimeFreezeReason;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be TestId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably me or oliver did too much copy pasta :D I will double check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually probably not, it should be the default one.

@paritytech-ci paritytech-ci requested review from a team October 18, 2023 09:51
ggwpez and others added 2 commits October 18, 2023 12:16
@kianenigma kianenigma enabled auto-merge (squash) October 24, 2023 09:29
@kianenigma kianenigma merged commit 35eb133 into master Oct 24, 2023
@kianenigma kianenigma deleted the kiz-variant-count branch October 24, 2023 10:01
ordian added a commit that referenced this pull request Oct 26, 2023
* tsv-disabling: (36 commits)
  Removed TODO from test-case for hard-coded delivery fee estimation (#2042)
  Expose collection attributes from `Inspect` trait (#1914)
  `polkadot-parachain-primitives` should not depend on `frame-support`. (#1897)
  [testnet] Align testnet system parachain runtimes using `RelayTreasuryLocation` and `SystemParachains` in the same way (#2023)
  Sort the benchmarks before listing them (#2026)
  publish pallet-root-testing (#2017)
  Contracts: Add benchmarks to include files (#2022)
  Small optimisation to `--profile dev` wasm builds (#1851)
  basic-authorship: Improve time recording and logging (#2010)
  Application Crypto and BEEFY Support for paired (ECDSA,BLS) crypto (#1815)
  [ci] Run check-rust-feature-propagation in pr and master (#2012)
  Improve features dev-ex (#1831)
  Remove obsolete comment. (#2008)
  Refactor candidates test in paras_inherent (#2004)
  PVF: Add worker check during tests and benches (#1771)
  Bump actions/setup-node from 3.8.1 to 4.0.0 (#1997)
  polkadot: enable tikv-jemallocator/unprefixed_malloc_on_supported_platforms (#2002)
  Make `IdentityInfo` generic in `pallet-identity` (#1661)
  Ensure correct variant count in `Runtime[Hold/Freeze]Reason` (#1900)
  `CheckWeight`: Add more logging (#1996)
  ...
s0me0ne-unkn0wn pushed a commit that referenced this pull request Oct 29, 2023
closes #1882

## Breaking Changes

This PR introduces a new item to `pallet_balances::Config`:

```diff
trait Config {
++    type RuntimeFreezeReasons;
}
```

This value is only used to check it against `type MaxFreeze`. A similar
check has been added for `MaxHolds` against `RuntimeHoldReasons`, which
is already given to `pallet_balances`.

In all contexts, you should pass the real `RuntimeFreezeReasons`
generated by `construct_runtime` to `type RuntimeFreezeReasons`. Passing
`()` would also work, but it would imply that the runtime uses no
freezes at all.

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
svyatonik added a commit to svyatonik/runtimes that referenced this pull request Nov 3, 2023
@Polkadot-Forum
Copy link

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/polkadot-release-analysis-v1-3-0/4614/1

bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this pull request Mar 25, 2024
…ech#1900)

closes paritytech#1882

## Breaking Changes

This PR introduces a new item to `pallet_balances::Config`:

```diff
trait Config {
++    type RuntimeFreezeReasons;
}
```

This value is only used to check it against `type MaxFreeze`. A similar
check has been added for `MaxHolds` against `RuntimeHoldReasons`, which
is already given to `pallet_balances`.

In all contexts, you should pass the real `RuntimeFreezeReasons`
generated by `construct_runtime` to `type RuntimeFreezeReasons`. Passing
`()` would also work, but it would imply that the runtime uses no
freezes at all.

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
@kianenigma kianenigma mentioned this pull request Mar 25, 2024
6 tasks
bkchr pushed a commit that referenced this pull request Apr 10, 2024
@wischli
Copy link

wischli commented May 15, 2024

IIUC, there is no migration required for teams which introduce RuntimeFreezeReason and/or switch from the () hold reason to the macro generated one?

- type RuntimeHoldReason = ();
+ type RuntimeHoldReason = RuntimeHoldReason;

I would really appreciate a comment on this and apologize for the minor comment creep.

@bkchr
Copy link
Member

bkchr commented May 15, 2024

Yes that is the correct thing to do.

@wischli
Copy link

wischli commented May 16, 2024

Yes that is the correct thing to do.

Really appreciate the quick response. Does your statement include the "no migration required" part as well?

Let me elaborate: Say some pallet has used the () hold reason and now introduces some enum HoldEnum as reason. Then it appears to me that all accounts with reserved funds for the () reason need to be migrated to some HoldEnum variant, independent of the number of variants of HoldEnum (e.g. one vs multiple).

Same for the freezes.

@bkontur
Copy link
Contributor

bkontur commented May 16, 2024

Yes that is the correct thing to do.

Really appreciate the quick response. Does your statement include the "no migration required" part as well?

Let me elaborate: Say some pallet has used the () hold reason and now introduces some enum HoldEnum as reason. Then it appears to me that all accounts with reserved funds for the () reason need to be migrated to some HoldEnum variant, independent of the number of variants of HoldEnum (e.g. one vs multiple).

Same for the freezes.

iirc, VariantCount impl for () returns 0 here: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/support/src/traits/misc.rs#L46-L48, so with type RuntimeHoldReason = (); you shouldn't be able to store any holds: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/balances/src/lib.rs#L476-L485. But this change was introduced here: #2657, so I am not sure what is your current polkadot-sdk version.

@bkontur
Copy link
Contributor

bkontur commented May 16, 2024

Yes that is the correct thing to do.

Really appreciate the quick response. Does your statement include the "no migration required" part as well?
Let me elaborate: Say some pallet has used the () hold reason and now introduces some enum HoldEnum as reason. Then it appears to me that all accounts with reserved funds for the () reason need to be migrated to some HoldEnum variant, independent of the number of variants of HoldEnum (e.g. one vs multiple).
Same for the freezes.

iirc, VariantCount impl for () returns 0 here: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/support/src/traits/misc.rs#L46-L48, so with type RuntimeHoldReason = (); you shouldn't be able to store any holds: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/balances/src/lib.rs#L476-L485. But this change was introduced here: #2657, so I am not sure what is your current polkadot-sdk version.

@wischli I just wanted to say that this change shouldn't require migration. However, it could depend on the version of pallet-balances. If your version doesn't include #2657 and you have type MaxHolds = ConstU32<1>;, then you probably need to check the actual stored Holds, for example:
image
Based on that, you might need to perform some migrations, which should be pretty straightforward.

Also, we have check-migrations CI jobs for runtimes. These jobs check storage or other aspects before and after runtime upgrades. For example, in your case, if you stored holds for a () reason and then a new runtime upgrade changes the reason type from () to RuntimeHoldReason, then without any migration, these CI jobs should fail with an error like "undecodable keys" or something similar. This failure occurs because it won't be able to decode Holds with () to Holds with RuntimeHoldReason. Thus, we will know that we need to add a migration.

@bkchr
Copy link
Member

bkchr commented May 16, 2024

Also, we have check-migrations CI jobs for runtimes.

This is basically just try-runtime with all the checks enabled.

aurexav added a commit to darwinia-network/darwinia that referenced this pull request Jun 21, 2024
aurexav added a commit to darwinia-network/darwinia that referenced this pull request Jun 28, 2024
* Setup deps

* Remove Koi from account migration test

* paritytech/polkadot-sdk#1495

* Bump

* paritytech/polkadot-sdk#1524

* !! paritytech/polkadot-sdk#1363

* paritytech/polkadot-sdk#1492

* paritytech/polkadot-sdk#1911

* paritytech/polkadot-sdk#1900

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1661

* paritytech/polkadot-sdk#2144

* paritytech/polkadot-sdk#2048

* paritytech/polkadot-sdk#1672

* paritytech/polkadot-sdk#2303

* paritytech/polkadot-sdk#1256

* Remove identity and vesting

* Fixes

* paritytech/polkadot-sdk#2657

* paritytech/polkadot-sdk#1313

* paritytech/polkadot-sdk#2331

* paritytech/polkadot-sdk#2409 part.1

* paritytech/polkadot-sdk#2767

* paritytech/polkadot-sdk#2521

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1222

* paritytech/polkadot-sdk#1234 part.1

* Satisfy compiler

* XCM V4 part.1

* paritytech/polkadot-sdk#1246

* Remove pallet-democracy part.1

* paritytech/polkadot-sdk#2142

* paritytech/polkadot-sdk#2428

* paritytech/polkadot-sdk#3228

* XCM V4 part.2

* Bump

* Build all runtimes

* Build node

* Remove pallet-democracy

Signed-off-by: Xavier Lau <[email protected]>

* Format

* Fix pallet tests

* Fix precompile tests

* Format

* Fixes

* Async, remove council, common pallet config

* Fix `ethtx-forward` test case (#1519)

* Fix ethtx-forward tests

* Format

* Fix following the review

* Fixes

* Fixes

* Use default impl

* Benchmark helper

* Bench part.1

* Bench part.2

* Bench part.3

* Fix all tests

* Typo

* Feat

* Fix EVM tracing build

* Reuse upstream `proof_size_base_cost()` (#1521)

* Format issue

* Fixes

* Fix CI

---------

Signed-off-by: Xavier Lau <[email protected]>
Co-authored-by: Bear Wang <[email protected]>
Patrick8rz added a commit to Patrick8rz/darwinia that referenced this pull request Sep 6, 2025
* Setup deps

* Remove Koi from account migration test

* paritytech/polkadot-sdk#1495

* Bump

* paritytech/polkadot-sdk#1524

* !! paritytech/polkadot-sdk#1363

* paritytech/polkadot-sdk#1492

* paritytech/polkadot-sdk#1911

* paritytech/polkadot-sdk#1900

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1661

* paritytech/polkadot-sdk#2144

* paritytech/polkadot-sdk#2048

* paritytech/polkadot-sdk#1672

* paritytech/polkadot-sdk#2303

* paritytech/polkadot-sdk#1256

* Remove identity and vesting

* Fixes

* paritytech/polkadot-sdk#2657

* paritytech/polkadot-sdk#1313

* paritytech/polkadot-sdk#2331

* paritytech/polkadot-sdk#2409 part.1

* paritytech/polkadot-sdk#2767

* paritytech/polkadot-sdk#2521

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1222

* paritytech/polkadot-sdk#1234 part.1

* Satisfy compiler

* XCM V4 part.1

* paritytech/polkadot-sdk#1246

* Remove pallet-democracy part.1

* paritytech/polkadot-sdk#2142

* paritytech/polkadot-sdk#2428

* paritytech/polkadot-sdk#3228

* XCM V4 part.2

* Bump

* Build all runtimes

* Build node

* Remove pallet-democracy

Signed-off-by: Xavier Lau <[email protected]>

* Format

* Fix pallet tests

* Fix precompile tests

* Format

* Fixes

* Async, remove council, common pallet config

* Fix `ethtx-forward` test case (#1519)

* Fix ethtx-forward tests

* Format

* Fix following the review

* Fixes

* Fixes

* Use default impl

* Benchmark helper

* Bench part.1

* Bench part.2

* Bench part.3

* Fix all tests

* Typo

* Feat

* Fix EVM tracing build

* Reuse upstream `proof_size_base_cost()` (#1521)

* Format issue

* Fixes

* Fix CI

---------

Signed-off-by: Xavier Lau <[email protected]>
Co-authored-by: Bear Wang <[email protected]>
jacksonLewis88 added a commit to jacksonLewis88/darwinia that referenced this pull request Sep 25, 2025
* Setup deps

* Remove Koi from account migration test

* paritytech/polkadot-sdk#1495

* Bump

* paritytech/polkadot-sdk#1524

* !! paritytech/polkadot-sdk#1363

* paritytech/polkadot-sdk#1492

* paritytech/polkadot-sdk#1911

* paritytech/polkadot-sdk#1900

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1661

* paritytech/polkadot-sdk#2144

* paritytech/polkadot-sdk#2048

* paritytech/polkadot-sdk#1672

* paritytech/polkadot-sdk#2303

* paritytech/polkadot-sdk#1256

* Remove identity and vesting

* Fixes

* paritytech/polkadot-sdk#2657

* paritytech/polkadot-sdk#1313

* paritytech/polkadot-sdk#2331

* paritytech/polkadot-sdk#2409 part.1

* paritytech/polkadot-sdk#2767

* paritytech/polkadot-sdk#2521

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1222

* paritytech/polkadot-sdk#1234 part.1

* Satisfy compiler

* XCM V4 part.1

* paritytech/polkadot-sdk#1246

* Remove pallet-democracy part.1

* paritytech/polkadot-sdk#2142

* paritytech/polkadot-sdk#2428

* paritytech/polkadot-sdk#3228

* XCM V4 part.2

* Bump

* Build all runtimes

* Build node

* Remove pallet-democracy

Signed-off-by: Xavier Lau <[email protected]>

* Format

* Fix pallet tests

* Fix precompile tests

* Format

* Fixes

* Async, remove council, common pallet config

* Fix `ethtx-forward` test case (#1519)

* Fix ethtx-forward tests

* Format

* Fix following the review

* Fixes

* Fixes

* Use default impl

* Benchmark helper

* Bench part.1

* Bench part.2

* Bench part.3

* Fix all tests

* Typo

* Feat

* Fix EVM tracing build

* Reuse upstream `proof_size_base_cost()` (#1521)

* Format issue

* Fixes

* Fix CI

---------

Signed-off-by: Xavier Lau <[email protected]>
Co-authored-by: Bear Wang <[email protected]>
kinetic-smith803tr added a commit to kinetic-smith803tr/darwinia that referenced this pull request Sep 26, 2025
* Setup deps

* Remove Koi from account migration test

* paritytech/polkadot-sdk#1495

* Bump

* paritytech/polkadot-sdk#1524

* !! paritytech/polkadot-sdk#1363

* paritytech/polkadot-sdk#1492

* paritytech/polkadot-sdk#1911

* paritytech/polkadot-sdk#1900

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1661

* paritytech/polkadot-sdk#2144

* paritytech/polkadot-sdk#2048

* paritytech/polkadot-sdk#1672

* paritytech/polkadot-sdk#2303

* paritytech/polkadot-sdk#1256

* Remove identity and vesting

* Fixes

* paritytech/polkadot-sdk#2657

* paritytech/polkadot-sdk#1313

* paritytech/polkadot-sdk#2331

* paritytech/polkadot-sdk#2409 part.1

* paritytech/polkadot-sdk#2767

* paritytech/polkadot-sdk#2521

Signed-off-by: Xavier Lau <[email protected]>

* paritytech/polkadot-sdk#1222

* paritytech/polkadot-sdk#1234 part.1

* Satisfy compiler

* XCM V4 part.1

* paritytech/polkadot-sdk#1246

* Remove pallet-democracy part.1

* paritytech/polkadot-sdk#2142

* paritytech/polkadot-sdk#2428

* paritytech/polkadot-sdk#3228

* XCM V4 part.2

* Bump

* Build all runtimes

* Build node

* Remove pallet-democracy

Signed-off-by: Xavier Lau <[email protected]>

* Format

* Fix pallet tests

* Fix precompile tests

* Format

* Fixes

* Async, remove council, common pallet config

* Fix `ethtx-forward` test case (#1519)

* Fix ethtx-forward tests

* Format

* Fix following the review

* Fixes

* Fixes

* Use default impl

* Benchmark helper

* Bench part.1

* Bench part.2

* Bench part.3

* Fix all tests

* Typo

* Feat

* Fix EVM tracing build

* Reuse upstream `proof_size_base_cost()` (#1521)

* Format issue

* Fixes

* Fix CI

---------

Signed-off-by: Xavier Lau <[email protected]>
Co-authored-by: Bear Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R1-breaking_change This PR introduces a breaking change and should be highlighted in the upcoming release. T1-FRAME This PR/Issue is related to core FRAME, the framework.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integrity test for MaxHolds and MaxFreezes