Skip to content

Commit 1ed8993

Browse files
authored
🔧 Fix storage migration (#316)
## What? - Fix a bug in the storage migration of pallet funding from 2->3 ## Why? - ProjectStatus was wrongly migrated inside ProjectDetails ## How? - We added a new status `CalculatingWap` which changed the indices of all enums when encoded, which we forgot to account for ## Testing? Tested by forking Polkadot and Polimec with chopsticks using `npx @acala-network/chopsticks@latest xcm -r polkadot -p scripts/chopsticks/polimec-testing/polkadot-polimec.yml ` ## Anything Else? The new chopsticks script replaces the Council and TC with test accounts, which means we can quickly do sudo operations
1 parent 9497c32 commit 1ed8993

File tree

3 files changed

+154
-2
lines changed

3 files changed

+154
-2
lines changed

pallets/funding/src/storage_migrations.rs

+33-2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ pub mod v3 {
170170
use sp_core::{Decode, Encode, MaxEncodedLen, RuntimeDebug};
171171
use sp_std::marker::PhantomData;
172172

173+
#[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
174+
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
175+
pub enum OldProjectStatus {
176+
#[default]
177+
Application,
178+
EvaluationRound,
179+
AuctionInitializePeriod,
180+
AuctionOpening,
181+
AuctionClosing,
182+
CommunityRound,
183+
RemainderRound,
184+
FundingFailed,
185+
AwaitingProjectDecision,
186+
FundingSuccessful,
187+
ReadyToStartMigration,
188+
MigrationCompleted,
189+
}
173190
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
174191
pub struct OldProjectDetails<
175192
AccountId,
@@ -186,7 +203,7 @@ pub mod v3 {
186203
/// The price in USD per token decided after the Auction Round
187204
pub weighted_average_price: Option<Price>,
188205
/// The current status of the project
189-
pub status: ProjectStatus,
206+
pub status: OldProjectStatus,
190207
/// When the different project phases start and end
191208
pub phase_transition_points: PhaseTransitionPoints<BlockNumber>,
192209
/// Fundraising target amount in USD (6 decimals)
@@ -215,12 +232,26 @@ pub mod v3 {
215232
let mut items = 0;
216233
let mut translate = |_key, item: OldProjectDetailsOf<T>| -> Option<ProjectDetailsOf<T>> {
217234
items += 1;
235+
let new_status = match item.status {
236+
OldProjectStatus::Application => ProjectStatus::Application,
237+
OldProjectStatus::EvaluationRound => ProjectStatus::EvaluationRound,
238+
OldProjectStatus::AuctionInitializePeriod => ProjectStatus::AuctionInitializePeriod,
239+
OldProjectStatus::AuctionOpening => ProjectStatus::AuctionOpening,
240+
OldProjectStatus::AuctionClosing => ProjectStatus::AuctionClosing,
241+
OldProjectStatus::CommunityRound => ProjectStatus::CommunityRound,
242+
OldProjectStatus::RemainderRound => ProjectStatus::RemainderRound,
243+
OldProjectStatus::FundingFailed => ProjectStatus::FundingFailed,
244+
OldProjectStatus::AwaitingProjectDecision => ProjectStatus::AwaitingProjectDecision,
245+
OldProjectStatus::FundingSuccessful => ProjectStatus::FundingSuccessful,
246+
OldProjectStatus::ReadyToStartMigration => ProjectStatus::ReadyToStartMigration,
247+
OldProjectStatus::MigrationCompleted => ProjectStatus::MigrationCompleted,
248+
};
218249
Some(ProjectDetailsOf::<T> {
219250
issuer_account: item.issuer_account,
220251
issuer_did: item.issuer_did,
221252
is_frozen: item.is_frozen,
222253
weighted_average_price: item.weighted_average_price,
223-
status: item.status,
254+
status: new_status,
224255
phase_transition_points: item.phase_transition_points,
225256
fundraising_target_usd: item.fundraising_target_usd,
226257
remaining_contribution_tokens: item.remaining_contribution_tokens,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
db: ./db.sqlite
2+
mock-signature-host: true
3+
endpoint: wss://rpc.polimec.org
4+
import-storage:
5+
System:
6+
Account:
7+
# account0 - 50k PLMC
8+
- - - "5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z"
9+
- providers: 1
10+
data:
11+
free: "500000000000000"
12+
13+
# account1 - 50k PLMC
14+
- - - "5EoHniZVuKRKNXNtVZzw8Jbc8Qtgy8GN5QKDKSA78HEok7YW"
15+
- providers: 1
16+
data:
17+
free: "500000000000000"
18+
19+
# account2 - 50k PLMC
20+
- - - "5GeXY2mKL4ADz7mDtsuHvNrRky48NqdWb4u8c5Sg9N8s3T1y"
21+
- providers: 1
22+
data:
23+
free: "500000000000000"
24+
25+
# account3 - 50k PLMC
26+
- - - "5EfE8r9uWWMazvyh8tkcuuKSy6PbAZQSqq42CXYwGdvwjpb8"
27+
- providers: 1
28+
data:
29+
free: "500000000000000"
30+
31+
# account4 - 50k PLMC
32+
- - - "5C8ULBGhfaP2nmDcuFbiShQ1hMwWsB7ghbChDKAwdszSWnA5"
33+
- providers: 1
34+
data:
35+
free: "500000000000000"
36+
37+
# account5 - 50k PLMC
38+
- - - "5HGqvcE29nHekDEYND3ZZtobbP4UeCcALFgwEm5YUvroZJr6"
39+
- providers: 1
40+
data:
41+
free: "500000000000000"
42+
43+
# account6 - 50k PLMC
44+
- - - "5CGEmsGTJcYSBCdXvsjDUBxW2dtvte5M8By95gwMwToih37s"
45+
- providers: 1
46+
data:
47+
free: "500000000000000"
48+
49+
# account7 - 50k PLMC
50+
- - - "5GsWm46kXRF7p6ifSQjrdc8HgPbzY4uWgJdQSUcGGDczkDGa"
51+
- providers: 1
52+
data:
53+
free: "500000000000000"
54+
55+
# account8 - 50k PLMC
56+
- - - "5H4AWTrkHN6aaQCv2jn48HVZjGhiCqswt6sPBksFPrrf2FPY"
57+
- providers: 1
58+
data:
59+
free: "500000000000000"
60+
61+
# account9 - 50k PLMC
62+
- - - "5CabLepLT8e6NvJCtzrEZLEBRd1FxKXU72F2NvbYTVf3bNej"
63+
- providers: 1
64+
data:
65+
free: "500000000000000"
66+
67+
68+
ForeignAssets:
69+
Account:
70+
# account0 - 50k DOT, 50k USDT, 50k USDC
71+
[
72+
[
73+
[1984, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z],
74+
{ balance: 50000000 },
75+
],
76+
[
77+
[1337, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z],
78+
{ balance: 50000000 },
79+
],
80+
[
81+
[ 10, 5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z ],
82+
{ balance: 500000000000 },
83+
],
84+
]
85+
86+
Council:
87+
Members:
88+
[
89+
"5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z",
90+
]
91+
92+
TechnicalCommittee:
93+
Members:
94+
[
95+
"5Ca5mpGKqE8BTo7ZvF6S4aN7j2DoWPgp5L6p3q9hm25fsy1z",
96+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[settings]
2+
timeout = 1000
3+
provider = "native"
4+
5+
[relaychain]
6+
default_command = "polkadot"
7+
chain_spec_path = "/usr/local/paseo-local.plain.json"
8+
9+
[[relaychain.nodes]]
10+
name = "alice"
11+
12+
[[relaychain.nodes]]
13+
name = "bob"
14+
15+
[[parachains]]
16+
id = 3344
17+
chain_spec_path = "chain-specs/paseo/temp.json"
18+
19+
[[parachains.collators]]
20+
name = "polimec-collator"
21+
ws_port = 8888
22+
command = "./target/release/polimec-node"
23+
args = ["--offchain-worker when-authority --log ocw=trace"]
24+
# ss58 key: 5Do5UoayFvDrHroGS1YMqxTVUysSkrhNwVMzmj1foVb3vzzb
25+
keystore_key_types = ["aura", "plmc_sr"]

0 commit comments

Comments
 (0)