Skip to content

Commit 2e1a426

Browse files
authored
Merge branch 'main' into xavier/async
2 parents e643bd2 + 351f328 commit 2e1a426

File tree

8 files changed

+113
-186
lines changed

8 files changed

+113
-186
lines changed

Cargo.lock

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/crab/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub type Executive = frame_executive::Executive<
6565
frame_system::ChainContext<Runtime>,
6666
Runtime,
6767
AllPalletsWithSystem,
68-
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v2::MigrateToV2<Runtime>),
68+
migration::CustomOnRuntimeUpgrade,
6969
>;
7070

7171
/// Runtime version.

runtime/crab/src/migration.rs

Lines changed: 50 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,13 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
2929
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::DispatchError> {
3030
log::info!("pre");
3131

32-
assert!(Balances::free_balance(ROOT) != 0);
33-
34-
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
35-
log::info!("{k:?}");
36-
log::info!("{v:?}");
37-
});
38-
3932
Ok(Vec::new())
4033
}
4134

4235
#[cfg(feature = "try-runtime")]
4336
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
4437
log::info!("post");
4538

46-
assert!(Balances::free_balance(ROOT) == 0);
47-
48-
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, v)| {
49-
log::info!("{k:?}");
50-
log::info!("{v:?}");
51-
52-
assert!(!v.is_empty());
53-
});
54-
5539
Ok(())
5640
}
5741

@@ -61,72 +45,60 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
6145
}
6246

6347
fn migrate() -> frame_support::weights::Weight {
64-
let mut r = 0;
65-
let mut w = 4;
66-
let _ =
67-
migration::clear_storage_prefix(b"MessageGadget", b"CommitmentContract", &[], None, None);
68-
let _ = Balances::transfer_all(RuntimeOrigin::signed(ROOT), Treasury::account_id(), true);
69-
let lock_ids = [
70-
// Democracy lock.
71-
*b"democrac",
72-
// Fee market lock.
73-
*b"da/feecr",
74-
];
75-
76-
<pallet_balances::Locks<Runtime>>::iter().for_each(|(k, mut v)| {
77-
if v.is_empty() {
78-
// Clear the storage entry if the vector is empty.
79-
80-
<pallet_balances::Locks<Runtime>>::remove(k);
81-
82-
w += 1;
83-
} else {
84-
// Find matching lock ids and remove them.
85-
86-
let mut changed = false;
87-
88-
v.retain(|l| {
89-
if lock_ids.contains(&l.id) {
90-
// Mark as changed, the storage entry needs to be updated.
91-
changed = true;
92-
93-
// To remove.
94-
false
95-
} else {
96-
// To keep.
97-
true
98-
}
99-
});
100-
101-
if changed {
102-
if v.is_empty() {
103-
// Clear the storage entry if the vector is empty.
104-
105-
<pallet_balances::Locks<Runtime>>::remove(k);
106-
} else {
107-
<pallet_balances::Locks<Runtime>>::insert(k, v);
108-
}
109-
110-
w += 1;
48+
if let Ok(a) =
49+
array_bytes::hex_n_into::<_, AccountId, 20>("0xacfa39b864e42d1bd3792783a571d2958af0bf1f")
50+
{
51+
let mut l = <pallet_balances::Locks<Runtime>>::get(a);
52+
53+
if let Some(i) = l.iter().position(|l| l.id == *b"phrelect") {
54+
l.remove(i);
55+
56+
if l.is_empty() {
57+
<pallet_balances::Locks<Runtime>>::remove(a);
58+
} else {
59+
<pallet_balances::Locks<Runtime>>::insert(a, l);
11160
}
11261
}
62+
}
11363

114-
r += 1;
64+
[
65+
"0xd891ce6a97b4f01a8b9b36d0298aa3631fe2eef5",
66+
"0x88a39b052d477cfde47600a7c9950a441ce61cb4",
67+
"0x0a1287977578f888bdc1c7627781af1cc000e6ab",
68+
"0x0b001c95e86d64c1ad6e43944c568a6c31b53887",
69+
"0x7ae2a0914db8bfbdad538b0eac3fa473a0e07843",
70+
"0xacfa39b864e42d1bd3792783a571d2958af0bf1f",
71+
"0x5af9a1be7bc22f9a6b2ce90acd69c23dceeb23c2",
72+
"0x1678a973ae9750d25c126cdbce891bb8cfacd520",
73+
"0x4ed7ae57608cf4f60753cde4f49cf821c293ed2a",
74+
"0x5b7544b3f6abd9e03fba494796b1ee6f9543e2e4",
75+
"0x44cda595218ddb3810fb66c2e982f50ea00255ee",
76+
]
77+
.iter()
78+
.filter_map(|a| array_bytes::hex_n_into::<_, AccountId, 20>(a).ok())
79+
.for_each(|a| {
80+
let freeze = <pallet_balances::Freezes<Runtime>>::get(a)
81+
.into_iter()
82+
.map(|f| f.amount)
83+
.max()
84+
.unwrap_or(0);
85+
let frozen = <pallet_balances::Locks<Runtime>>::get(a)
86+
.into_iter()
87+
.map(|l| l.amount)
88+
.max()
89+
.unwrap_or(0);
90+
let frozen = freeze.max(frozen);
91+
let _ = <frame_system::Account<Runtime>>::try_mutate(a, |a| {
92+
if a.data.frozen == frozen {
93+
Err(())
94+
} else {
95+
a.data.frozen = frozen;
96+
97+
Ok(())
98+
}
99+
});
115100
});
116101

117-
w += migration_helper::PalletCleaner {
118-
name: b"EcdsaAuthority",
119-
values: &[
120-
b"Authorities",
121-
b"NextAuthorities",
122-
b"Nonce",
123-
b"AuthoritiesChangeToSign",
124-
b"MessageRootToSign",
125-
],
126-
maps: &[],
127-
}
128-
.remove_all();
129-
130102
// frame_support::weights::Weight::zero()
131-
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(r as _, w as _)
103+
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(1, 23)
132104
}

runtime/crab/src/pallets/evm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl pallet_evm::Config for Runtime {
169169
type FindAuthor = FindAuthor<pallet_session::FindAccountFromAuthorIndex<Self, Aura>>;
170170
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
171171
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
172-
type OnChargeTransaction = ();
172+
type OnChargeTransaction = pallet_evm::EVMFungibleAdapter<Balances, ()>;
173173
type OnCreate = ();
174174
type PrecompilesType = CrabPrecompiles<Self>;
175175
type PrecompilesValue = PrecompilesValue;

runtime/darwinia/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub type Executive = frame_executive::Executive<
6565
frame_system::ChainContext<Runtime>,
6666
Runtime,
6767
AllPalletsWithSystem,
68-
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v2::MigrateToV2<Runtime>),
68+
migration::CustomOnRuntimeUpgrade,
6969
>;
7070

7171
/// Runtime version.

0 commit comments

Comments
 (0)