Skip to content

Commit

Permalink
🚑️ Fix corrupted Linear Release entries (#465)
Browse files Browse the repository at this point in the history
## What?

During a [previous runtime upgrade](https://github.com/Polimec/polimec-node/pull/383/files#diff-bbe1a30f3b7ec00a084641777c8b3da45df415b120b4e205d016c625a77284a0), we simplified the `RuntimeHoldReason`, but we forgot to migrate the `LinearRelease:Vesting` keys to reflect this change.

### Reasoning

I tried to `translate` the current entries, but the types were conflicting. Then I started to `drain` the entries and add the new ones, but since I was operating on the same storage I had few non deterministic results. Since we only have 15 entries, I decided to perform a simple migration that removes the current corrupted entries, and create new ones, with the right key.

### Testing

Tested via `chopsticks` and via the `try-runtime-cli`

### New Migration:
* Implemented a new migration for the Linear Release `Vesting` in `runtimes/polimec/src/custom_migrations/linear_release.rs`. (`runtimes/polimec/src/custom_migrations/linear_release.rs` - [runtimes/polimec/src/custom_migrations/linear_release.rsR1-R110](diffhunk://#diff-c47feabf076eb45e19f973367310bbee30b1b6c39cec965f9a22c5bb0cdb6d0cR1-R110))
* Included the new migration script in the `mod.rs` and `lib.rs` files of the `polimec` runtime. (`runtimes/polimec/src/custom_migrations/mod.rs` - [[1]](diffhunk://#diff-63e5609b322bad6be8ef1b127b8161c52602cff85ab9cf67f6b5ac03be68fc3aR21) `runtimes/polimec/src/lib.rs` - [[2]](diffhunk://#diff-fa44a5ad015c5d189a690374b9164d3a58b7218228b56c151327dd62d143ee1bR178)

### Dependency Updates:
* Updated `jwt-compact` and `substrate-fixed` dependencies in `Cargo.toml` to use specific versions instead of git references. (`Cargo.toml` - [Cargo.tomlL76-R84](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542L76-R84))

### Integration Tests Configuration:
* Added new entries to the `std` array in `integration-tests/Cargo.toml`. (`integration-tests/Cargo.toml` - [integration-tests/Cargo.tomlR152](diffhunk://#diff-ca620c1799a0fbfe846664793344b0d95a4f906636d2fbf307bff69f6ec81849R152))
* Added `.gitignore` and `package.json` files to the `integration-tests/chopsticks/.papi/descriptors` directory. (`integration-tests/chopsticks/.papi/descriptors/.gitignore` - [[1]](diffhunk://#diff-690eb99abc62e8194923cf1778d83fd7d93265fb81da24befdadf202d2136e92R1-R3) `integration-tests/chopsticks/.papi/descriptors/package.json` - [[2]](diffhunk://#diff-6d0112b7a63eb37cb4615006d54aca7b3aabf27e34cb439624e11b66c2a751b8R1-R24)
* Added a new `polkadot-api.json` configuration file for integration tests. (`integration-tests/chopsticks/.papi/polkadot-api.json` - [integration-tests/chopsticks/.papi/polkadot-api.jsonR1-R24](diffhunk://#diff-960b223eb17890451aebb5ad607cd709f7bd8ec42023cb94d48e006ad6234ef8R1-R24))
  • Loading branch information
lrazovic authored Mar 5, 2025
2 parents 22f81ae + 400b6bb commit fbeff8e
Show file tree
Hide file tree
Showing 18 changed files with 291 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ genesis-wasm
fly.toml
bin/
integration-tests/chopsticks/db/*
/integration-tests/chopsticks/node_modules/*
/integration-tests/chopsticks/.papi/*
integration-tests/chopsticks/node_modules/*
integration-tests/chopsticks/.papi/descriptors/*
109 changes: 102 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ macros-tests = { path = "macros/tests" }
# External pallets (with default disabled)
orml-oracle = { version = "0.13.0", default-features = false }
orml-traits = { version = "0.13.0", default-features = false }
jwt-compact = { git = "https://github.com/lrazovic/jwt-compact", default-features = false }
jwt-compact = { version = "0.9.0-beta.0", package = "jwt-compact-frame", default-features = false }

# Internal support (with default disabled)
shared-configuration = { path = "runtimes/shared-configuration", default-features = false }
polimec-common = { path = "polimec-common/common", default-features = false }
polimec-common-test-utils = { path = "polimec-common/test-utils", default-features = false }

# External support (with default disabled)
substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false }
substrate-fixed = { version = "0.5.9", default-features = false }

# External (without extra features and with default disabled if necessary)
parity-scale-codec = { version = "3.6.12", default-features = false }
Expand Down Expand Up @@ -247,4 +247,4 @@ cumulus-pallet-session-benchmarking = { version = "16.0.0", default-features = f
# Runtimes
polimec-runtime = { path = "runtimes/polimec" }
rococo-runtime-constants = { version = "14.0.0" }
rococo-runtime = { version = "14.0.0" }
rococo-runtime = { version = "14.0.0" }
1 change: 1 addition & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ std = [
"xcm-executor/std",
"xcm-fee-payment-runtime-api/std",
"xcm/std",
"assets-common/std"
]
development-settings = [ "polimec-runtime/development-settings" ]
runtime-benchmarks = [
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/chopsticks/.papi/descriptors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!package.json
24 changes: 24 additions & 0 deletions integration-tests/chopsticks/.papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.1.0-autogenerated.16545816865329173211",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"browser": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": "*"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions integration-tests/chopsticks/.papi/polkadot-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 0,
"descriptorPath": ".papi/descriptors",
"entries": {
"polkadot": {
"wsUrl": "wss://rpc.ibp.network/polkadot",
"metadata": ".papi/metadata/polkadot.scale",
"genesis": "0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"
},
"bridge": {
"wsUrl": "wss://sys.ibp.network/bridgehub-polkadot",
"metadata": ".papi/metadata/bridge.scale",
"genesis": "0xdcf691b5a3fbe24adc99ddc959c0561b973e329b1aef4c4b22e7bb2ddecb4464"
},
"pah": {
"wsUrl": "wss://sys.ibp.network/statemint",
"metadata": ".papi/metadata/pah.scale",
"genesis": "0x68d56f15f85d3136970ec16946040bc1752654e906147f7e43e9d539d7c3de2f"
},
"polimec": {
"metadata": ".papi/metadata/polimec.scale"
}
}
}
15 changes: 15 additions & 0 deletions nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,18 @@ try-runtime = [
]
on-chain-release-build = [ "polimec-runtime/on-chain-release-build" ]
development-settings = [ "polimec-runtime/development-settings" ]
std = [
"cumulus-primitives-core/std",
"frame-benchmarking/std",
"log/std",
"pallet-funding/std",
"polimec-common/std",
"polkadot-primitives/std",
"serde/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-runtime/std",
"xcm/std"
]
4 changes: 2 additions & 2 deletions pallets/funding/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use sp_runtime::{
use sp_std::collections::btree_map::BTreeMap;
use std::{cell::RefCell, marker::PhantomData};
use system::EnsureSigned;
use xcm::v4::PalletInfo as XcmPalletInfo;
use xcm_builder::{ParentIsPreset, SiblingParachainConvertsVia};
use xcm_executor::traits::XcmAssetTransfers;

Expand Down Expand Up @@ -153,7 +152,6 @@ parameter_types! {
pub const MetadataDepositBase: Balance = free_deposit();
pub const MetadataDepositPerByte: Balance = free_deposit();
pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT;

}

impl pallet_assets::Config<ContributionTokensInstance> for TestRuntime {
Expand Down Expand Up @@ -236,6 +234,7 @@ impl system::Config for TestRuntime {
parameter_types! {
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
}

impl pallet_balances::Config for TestRuntime {
type AccountStore = System;
type Balance = Balance;
Expand Down Expand Up @@ -285,6 +284,7 @@ parameter_types! {
pub const MinVestedTransfer: u64 = 256 * 2;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
Expand Down
5 changes: 2 additions & 3 deletions pallets/linear-release/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ pub mod pallet {
/// Overarching hold reason.
type RuntimeHoldReason: Parameter + MaxEncodedLen + Copy;

type Currency: InspectHold<AccountIdOf<Self>, Balance = BalanceOf<Self>>
+ MutateHold<AccountIdOf<Self>, Balance = BalanceOf<Self>, Reason = Self::RuntimeHoldReason>
+ BalancedHold<AccountIdOf<Self>, Balance = BalanceOf<Self>>
type Currency: MutateHold<AccountIdOf<Self>, Balance = BalanceOf<Self>, Reason = Self::RuntimeHoldReason>
+ BalancedHold<AccountIdOf<Self>, Balance = BalanceOf<Self>, Reason = Self::RuntimeHoldReason>
+ Mutate<AccountIdOf<Self>, Balance = BalanceOf<Self>>;

/// Convert the block number into a balance.
Expand Down
1 change: 1 addition & 0 deletions pallets/proxy-bonding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ std = [
"serde/std",
"sp-io/std",
"sp-runtime/std",
"xcm/std"
]

try-runtime = [
Expand Down
Loading

0 comments on commit fbeff8e

Please sign in to comment.