Skip to content

Commit

Permalink
Remove deprecated locks (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Feb 4, 2024
1 parent 08b08ad commit 270ed00
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 70 deletions.
3 changes: 2 additions & 1 deletion runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ on-chain-release-build = [

runtime-benchmarks = [
# crates.io
# "array-bytes",
# TODO: optional
# "array-bytes

# cumulus
"cumulus-pallet-parachain-system/runtime-benchmarks",
Expand Down
64 changes: 25 additions & 39 deletions runtime/crab/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,47 +41,33 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}

fn migrate() -> frame_support::weights::Weight {
let items: &[(&[u8], &[&[u8]])] = &[
(b"MessageGadget", &[b"CommitmentContract"]),
(
b"EcdsaAuthority",
&[
b"Authorities",
b"NextAuthorities",
b"Nonce",
b"AuthoritiesChangeToSign",
b"MessageRootToSign",
],
),
(
b"Council",
&[b"Proposals", b"ProposalOf", b"Voting", b"ProposalCount", b"Members", b"Prime"],
),
(
b"Democracy",
&[
b"PublicPropCount",
b"PublicProps",
b"DepositOf",
b"ReferendumCount",
b"LowestUnbaked",
b"ReferendumInfoOf",
b"VotingOf",
b"LastTabledWasExternal",
b"NextExternal",
b"Blacklist",
b"Cancellations",
b"MetadataOf",
],
),
];
// substrate
use pallet_balances::Locks;

let w = items.iter().fold(0, |w, (p, is)| {
w + is.iter().fold(0, |w, i| {
w + migration::clear_storage_prefix(p, i, &[], None, None).backend as u64
})
[
("0xd891ce6a97b4f01a8b9b36d0298aa3631fe2eef5", b"phrelect"),
("0xabcf7060a68f62624f7569ada9d78b5a5db0782a", b"phrelect"),
("0x88a39b052d477cfde47600a7c9950a441ce61cb4", b"phrelect"),
("0x9f33a4809aa708d7a399fedba514e0a0d15efa85", b"phrelect"),
("0x0a1287977578f888bdc1c7627781af1cc000e6ab", b"phrelect"),
("0xe59261f6d4088bcd69985a3d369ff14cc54ef1e5", b"phrelect"),
("0x7ae2a0914db8bfbdad538b0eac3fa473a0e07843", b"democrac"),
("0xacfa39b864e42d1bd3792783a571d2958af0bf1f", b"democrac"),
("0x3e25247cff03f99a7d83b28f207112234fee73a6", b"phrelect"),
("0xb2960e11b253c107f973cd778bbe1520e35e8602", b"phrelect"),
("0x4ed7ae57608cf4f60753cde4f49cf821c293ed2a", b"democrac"),
("0x5b7544b3f6abd9e03fba494796b1ee6f9543e2e4", b"phrelect"),
("0x44cda595218ddb3810fb66c2e982f50ea00255ee", b"phrelect"),
]
.iter()
.for_each(|(acct, lid)| {
if let Ok(acct) = array_bytes::hex_n_into::<_, AccountId, 20>(acct) {
<Locks<Runtime>>::mutate(acct, |ls| {
ls.retain(|l| &l.id != *lid);
});
}
});

// frame_support::weights::Weight::zero()
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, w)
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, 26)
}
36 changes: 19 additions & 17 deletions runtime/darwinia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ scale-info = { workspace = true }
static_assertions = { workspace = true }
strum = { workspace = true, features = ["derive"] }
# crates.io optional
array-bytes = { workspace = true, optional = true }
# TODO: optional
array-bytes = { workspace = true }

# cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -117,21 +118,21 @@ pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
# pallet-tx-pause = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
pallet-whitelist = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-staking = { workspace = true }
sp-std = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
pallet-whitelist = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-staking = { workspace = true }
sp-std = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
# substrate optional
frame-benchmarking = { workspace = true, optional = true }
frame-system-benchmarking = { workspace = true, optional = true }
Expand Down Expand Up @@ -293,7 +294,8 @@ on-chain-release-build = [

runtime-benchmarks = [
# crates.io
"array-bytes",
# TODO: optional
# "array-bytes",

# cumulus
"cumulus-pallet-parachain-system/runtime-benchmarks",
Expand Down
33 changes: 20 additions & 13 deletions runtime/darwinia/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,27 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {

fn migrate() -> frame_support::weights::Weight {
// substrate
use frame_support::pallet_prelude::StorageVersion;
use sp_core::H160;
use sp_std::str::FromStr;
use pallet_balances::Locks;

const REVERT_BYTECODE: [u8; 5] = [0x60, 0x00, 0x60, 0x00, 0xFD];
// CONVICTION_VOTING_ADDRESS equals to the addr(1538) in the pallet-evm runtime.
const CONVICTION_VOTING_ADDRESS: &str = "0x0000000000000000000000000000000000000602";
if let Ok(addr) = H160::from_str(CONVICTION_VOTING_ADDRESS) {
EVM::create_account(addr, REVERT_BYTECODE.to_vec());
return RuntimeBlockWeights::get().max_block;
}

StorageVersion::new(1).put::<pallet_referenda::Pallet<Runtime>>();
[
("0xabcf7060a68f62624f7569ada9d78b5a5db0782a", b"phrelect"),
("0x88a39b052d477cfde47600a7c9950a441ce61cb4", b"phrelect"),
("0x9f33a4809aa708d7a399fedba514e0a0d15efa85", b"phrelect"),
("0x0a1287977578f888bdc1c7627781af1cc000e6ab", b"phrelect"),
("0xe59261f6d4088bcd69985a3d369ff14cc54ef1e5", b"phrelect"),
("0x7ae2a0914db8bfbdad538b0eac3fa473a0e07843", b"phrelect"),
("0x3e25247cff03f99a7d83b28f207112234fee73a6", b"phrelect"),
("0xb2960e11b253c107f973cd778bbe1520e35e8602", b"phrelect"),
]
.iter()
.for_each(|(acct, lid)| {
if let Ok(acct) = array_bytes::hex_n_into::<_, AccountId, 20>(acct) {
<Locks<Runtime>>::mutate(acct, |ls| {
ls.retain(|l| &l.id != *lid);
});
}
});

// frame_support::weights::Weight::zero()
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, 5)
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, 16)
}

0 comments on commit 270ed00

Please sign in to comment.