Skip to content

Commit

Permalink
Release v6.5.0 (#1321)
Browse files Browse the repository at this point in the history
* Plan B

* Add migrations

* Avoid potential panic

* Bump versions

* Bump version

* Fix compile

* Fix migration

* Satisfy idempotency test
  • Loading branch information
AurevoirXavier authored Nov 17, 2023
1 parent a48eef9 commit dc0ddab
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 53 deletions.
44 changes: 22 additions & 22 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.4.0"
version = "6.5.0"

[workspace.dependencies]
# crates.io
Expand Down
2 changes: 1 addition & 1 deletion pallet/message-gadget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-evm/try-runtime",
"sp-runtime/try-runtime",
"sp-runtime?/try-runtime",
]
35 changes: 23 additions & 12 deletions pallet/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ pub mod pallet {
// Deposit helper for runtime benchmark.
#[cfg(feature = "runtime-benchmarks")]
use darwinia_deposit::Config as DepositConfig;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

/// Empty trait acts as a place holder to satisfy the `#[pallet::config]` macro.
#[cfg(not(feature = "runtime-benchmarks"))]
pub trait DepositConfig {}
Expand Down Expand Up @@ -344,7 +347,8 @@ pub mod pallet {
}

#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
Expand Down Expand Up @@ -957,23 +961,30 @@ pub mod pallet {
return None;
}

let bn = <frame_system::Pallet<T>>::block_number();

log::info!(
"[pallet::staking] assembling new collators for new session {index} at #{:?}",
<frame_system::Pallet<T>>::block_number(),
"[pallet::staking] assembling new collators for new session {index} at #{bn:?}",
);

if let Ok(collators) = Self::elect() {
// TODO?: if we really need this event
Self::deposit_event(Event::Elected { collators: collators.clone() });
if !collators.is_empty() {
// TODO?: if we really need this event
Self::deposit_event(Event::Elected { collators: collators.clone() });

Some(collators)
} else {
// Impossible case.
//
// But if there is an issue, retain the old collators; do not alter the session
// collators if any error occurs to prevent the chain from stalling.
None
return Some(collators);
}
}

log::error!(
"[pallet::staking] fail to elect collators for new session {index} at #{bn:?}"
);

// Impossible case.
//
// But if there is an issue, retain the old collators; do not alter the session
// collators if any error occurs to prevent the chain from stalling.
None
}

/// Shift the exposure cache states.
Expand Down
8 changes: 3 additions & 5 deletions pallet/staking/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ pub mod v1 {
{
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
assert_eq!(StorageVersion::get::<Pallet<T>>(), 0, "Can only upgrade from version 0.");

Ok(Vec::new())
}

Expand All @@ -52,7 +50,7 @@ pub mod v1 {

if version != 0 {
log::warn!(
"[pallet::staking] skipping v0 to v1 migration: executed on wrong storage version. Expected version 1, found {version:?}",
"[pallet::staking] skipping v0 to v1 migration: executed on wrong storage version. Expected version 0, found {version:?}",
);

return T::DbWeight::get().reads(1);
Expand Down Expand Up @@ -125,10 +123,10 @@ pub mod v1 {

// Check that everything decoded fine.
<ExposureCache1<T>>::iter_keys().for_each(|k| {
assert!(<ExposureCache0<T>>::try_get(k).is_ok(), "Can not decode V1 `Exposure`.");
assert!(<ExposureCache1<T>>::try_get(k).is_ok(), "Can not decode V1 `Exposure`.");
});
<ExposureCache2<T>>::iter_keys().for_each(|k| {
assert!(<ExposureCache0<T>>::try_get(k).is_ok(), "Can not decode V1 `Exposure`.");
assert!(<ExposureCache2<T>>::try_get(k).is_ok(), "Can not decode V1 `Exposure`.");
});

Ok(())
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 @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migration::CustomOnRuntimeUpgrade,
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1<Runtime>),
>;

/// Darwinia proposal base fee.
Expand All @@ -82,7 +82,7 @@ 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_4_0_2,
spec_version: 6_5_0_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
4 changes: 2 additions & 2 deletions runtime/darwinia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migration::CustomOnRuntimeUpgrade,
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1<Runtime>),
>;

/// Darwinia proposal base fee.
Expand All @@ -82,7 +82,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Darwinia2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_4_0_2,
spec_version: 6_5_0_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
8 changes: 4 additions & 4 deletions runtime/darwinia/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ fn migrate() -> frame_support::weights::Weight {
const REVERT_BYTECODE: [u8; 5] = [0x60, 0x00, 0x60, 0x00, 0xFD];
const USDT_ADDRESS: &str = "0x0000000000000000000000000000000000000403";

EVM::create_account(
H160::from_str(USDT_ADDRESS).expect("USDT_ADDRESS is not a valid address"),
REVERT_BYTECODE.to_vec(),
);
if let Ok(a) = H160::from_str(USDT_ADDRESS) {
EVM::create_account(a, REVERT_BYTECODE.to_vec());
}

<Runtime as frame_system::Config>::DbWeight::get().reads_writes(5, 5)

// frame_support::weights::Weight::zero()
Expand Down
4 changes: 2 additions & 2 deletions runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migration::CustomOnRuntimeUpgrade,
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1<Runtime>),
>;

/// Darwinia proposal base fee.
Expand All @@ -83,7 +83,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Pangolin2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_4_0_7,
spec_version: 6_5_0_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
4 changes: 2 additions & 2 deletions runtime/pangoro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migration::CustomOnRuntimeUpgrade,
(migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1<Runtime>),
>;

/// Darwinia proposal base fee.
Expand All @@ -82,7 +82,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Pangoro2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_4_0_7,
spec_version: 6_5_0_0,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down

0 comments on commit dc0ddab

Please sign in to comment.