Skip to content

Commit

Permalink
Release v6.0.2 (#1076)
Browse files Browse the repository at this point in the history
* Bump versions

* Remove old migration

* Remove migration

* Fix
  • Loading branch information
AurevoirXavier authored Mar 30, 2023
1 parent 2694c09 commit e60facb
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 145 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2021"
homepage = "https://darwinia.network"
license = "GPL-3.0"
repository = "https://github.com/darwinia-network/darwinia"
version = "6.0.1"
version = "6.0.2"

[workspace.dependencies]
# crates.io
Expand Down
21 changes: 0 additions & 21 deletions pallet/ecdsa-authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,6 @@ pub mod pallet {
pub type MessageRootToSign<T: Config> =
StorageValue<_, MessageRootSigned<T::MaxAuthorities>, OptionQuery>;

// TODO: Remove these in the next version.
/// The incoming message root waiting for signing.
#[pallet::storage]
#[pallet::getter(fn new_message_root_to_sign)]
pub type NewMessageRootToSign<T: Config> = StorageValue<_, (), OptionQuery>;
/// Record the previous message root.
///
/// Use for checking if the message root getter get the same message root as the previous one.
/// And if this is empty, it means the message root is require to be relayed.
#[pallet::storage]
pub type PreviousMessageRoot<T: Config> = StorageValue<_, (), OptionQuery>;

#[pallet::genesis_config]
pub struct GenesisConfig<T>
where
Expand Down Expand Up @@ -224,15 +212,6 @@ pub mod pallet {
Default::default()
}
}

fn on_runtime_upgrade() -> Weight {
frame_support::log::info!("Hook from darwinia_ecdsa_authority::on_runtime_upgrade");

<NewMessageRootToSign<T>>::kill();
<PreviousMessageRoot<T>>::kill();

T::DbWeight::get().reads_writes(0, 2)
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
Expand Down
17 changes: 9 additions & 8 deletions runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ substrate-wasm-builder = { workspace = true }

[dependencies]
# crates.io
array-bytes = { workspace = true }
codec = { workspace = true, package = "parity-scale-codec" }
scale-info = { workspace = true }
static_assertions = { workspace = true }
# crates.io optional
array-bytes = { workspace = true, optional = true }

# cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand All @@ -30,13 +31,13 @@ parachain-info = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true, optional = true }

# darwinia
darwinia-account-migration = { workspace = true }
darwinia-common-runtime = { workspace = true }
darwinia-deposit = { workspace = true }
darwinia-ecdsa-authority = { workspace = true }
darwinia-message-gadget = { workspace = true }
darwinia-message-transact = { workspace = true }
darwinia-precompile-assets = { workspace = true }
darwinia-account-migration = { workspace = true }
darwinia-common-runtime = { workspace = true }
darwinia-deposit = { workspace = true }
darwinia-ecdsa-authority = { workspace = true }
darwinia-message-gadget = { workspace = true }
darwinia-message-transact = { workspace = true }
darwinia-precompile-assets = { workspace = true }
# darwinia-precompile-bls12-381 = { workspace = true }
darwinia-precompile-deposit = { workspace = true }
darwinia-precompile-staking = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ pub type Executive = frame_executive::Executive<
>;

/// Darwinia proposal base fee.
pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5000 * UNIT;
pub const DARWINIA_PROPOSAL_REQUIREMENT: Balance = 5_000 * UNIT;

/// Runtime version.
#[sp_version::runtime_version]
pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Crab2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_0_1_0,
spec_version: 6_0_2_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
80 changes: 2 additions & 78 deletions runtime/crab/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,6 @@ use crate::*;
#[allow(unused_imports)]
use frame_support::{log, migration, storage::unhashed};

// Crab2
// AccountMigration::Vestings 0x1fb3231abc71c5a12c573bc57e9d12d1c5b10e12d951c676432baac73459815c
//
// Crab
// Vesting::Vesting 0x5f27b51b5ec208ee9cb25b55d87282435f27b51b5ec208ee9cb25b55d8728243
// Expired.
// 0x5f27b51b5ec208ee9cb25b55d87282435f27b51b5ec208ee9cb25b55d87282433f2770dc0c68232d160e98225bc421c9608c62275934b164899ca6270c4b89c5d84b2390d4316fda980cd1b3acfad525
// {
// locked: 1,000,000,000
// perBlock: 500,000,000
// startingBlock: 6,740,780
// }
// 100,000,000,000 - (CRAB_LAST_FINALIZE_HEIGHT - 8,421,033) * 1
// 0x5f27b51b5ec208ee9cb25b55d87282435f27b51b5ec208ee9cb25b55d8728243c06c2bc8f107407659c073c78f8a3b94360a95cd317b649c62ea53444ca50e9403031cec3fb9ac3650d4b72b88260f0c
// {
// locked: 100,000,000,000
// perBlock: 1
// startingBlock: 8,421,033
// }
// Expired.
// 0x5f27b51b5ec208ee9cb25b55d87282435f27b51b5ec208ee9cb25b55d8728243d52763ae3a2afb1c9c77d6426427422f72f9aa4c12882beefc97bba96617ed811690f68bb917e4b77d2dcc6d717a4422
// {
// locked: 1,000,000,000
// perBlock: 1,000,000,000
// startingBlock: 6,829,787
// }
const BROKEN_STORAGES: &[&str] = &[
"0x1fb3231abc71c5a12c573bc57e9d12d1c5b10e12d951c676432baac73459815c3f2770dc0c68232d160e98225bc421c9608c62275934b164899ca6270c4b89c5d84b2390d4316fda980cd1b3acfad525",
"0x1fb3231abc71c5a12c573bc57e9d12d1c5b10e12d951c676432baac73459815cc06c2bc8f107407659c073c78f8a3b94360a95cd317b649c62ea53444ca50e9403031cec3fb9ac3650d4b72b88260f0c",
"0x1fb3231abc71c5a12c573bc57e9d12d1c5b10e12d951c676432baac73459815cd52763ae3a2afb1c9c77d6426427422f72f9aa4c12882beefc97bba96617ed811690f68bb917e4b77d2dcc6d717a4422",
];
const CRAB_LAST_FINALIZE_HEIGHT: BlockNumber = 14_741_053;
const DECIMAL_OFFSET: Balance = 1_000_000_000;

pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
#[cfg(feature = "try-runtime")]
Expand All @@ -74,50 +40,8 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}
}

#[allow(clippy::identity_op)]
fn migrate() -> frame_support::weights::Weight {
#[derive(codec::Encode, codec::Decode, frame_support::RuntimeDebug)]
struct VestingInfo {
locked: Balance,
per_block: Balance,
starting_block: BlockNumber,
}

if let Ok(k) = array_bytes::hex2bytes(BROKEN_STORAGES[0]) {
// If `is_some` which means it hasn't been migrated yet.
// But actually, without this correction, the account migration will fail.
if unhashed::get::<VestingInfo>(&k).is_some() {
log::info!("purge `storage({})`", BROKEN_STORAGES[0]);
unhashed::kill(&k);
}
}
if let Ok(k) = array_bytes::hex2bytes(BROKEN_STORAGES[1]) {
// If `is_some` which means it hasn't been migrated yet.
// But actually, without this correction, the account migration will fail.
if unhashed::get::<VestingInfo>(&k).is_some() {
let v = vec![VestingInfo {
locked: (100_000_000_000_u128
- (CRAB_LAST_FINALIZE_HEIGHT - 8_421_033) as Balance * 1_u128)
* DECIMAL_OFFSET,
// Crab2's block time is twice longer than Crab.
per_block: 1 * DECIMAL_OFFSET * 2,
starting_block: 0,
}];

log::info!("correct `storage({})` to `{v:?}`", BROKEN_STORAGES[1]);
unhashed::put::<Vec<VestingInfo>>(&k, &v);
}
}
if let Ok(k) = array_bytes::hex2bytes(BROKEN_STORAGES[2]) {
// If `is_some` which means it hasn't been migrated yet.
// But actually, without this correction, the account migration will fail.
if unhashed::get::<VestingInfo>(&k).is_some() {
log::info!("purge `storage({})`", BROKEN_STORAGES[2]);
unhashed::kill(&k);
}
}

// frame_support::weights::Weight::zero()
frame_support::weights::Weight::zero()
// RuntimeBlockWeights::get().max_block
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(3, 3)
// <Runtime as frame_system::Config>::DbWeight::get().reads_writes(3, 3)
}
14 changes: 7 additions & 7 deletions runtime/darwinia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ parachain-info = { workspace = true }
cumulus-pallet-session-benchmarking = { workspace = true, optional = true }

# darwinia
darwinia-account-migration = { workspace = true }
darwinia-common-runtime = { workspace = true }
darwinia-deposit = { workspace = true }
darwinia-ecdsa-authority = { workspace = true }
darwinia-message-gadget = { workspace = true }
darwinia-message-transact = { workspace = true }
darwinia-precompile-assets = { workspace = true }
darwinia-account-migration = { workspace = true }
darwinia-common-runtime = { workspace = true }
darwinia-deposit = { workspace = true }
darwinia-ecdsa-authority = { workspace = true }
darwinia-message-gadget = { workspace = true }
darwinia-message-transact = { workspace = true }
darwinia-precompile-assets = { workspace = true }
# darwinia-precompile-bls12-381 = { workspace = true }
darwinia-precompile-deposit = { workspace = true }
darwinia-precompile-staking = { workspace = true }
Expand Down
Loading

0 comments on commit e60facb

Please sign in to comment.