Skip to content

Commit

Permalink
Merge branch 'development' into amar-comprehensive-chronicle-structur…
Browse files Browse the repository at this point in the history
…ed-logging
  • Loading branch information
4meta5 authored Jul 16, 2024
2 parents 336bfd0 + 78cf56d commit d5ec826
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/pr-test-try_runtime.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Check try-runtime
on:
pull_request:
paths:
- '.github/actions/cargo-command/**'
- '.github/workflows/pr-test-try_runtime.yaml'
- 'pallets/**'
- 'primitives/**'
- 'runtime/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
try-runtime:
runs-on: [self-hosted, general]
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y librocksdb-dev
- name: Install try-runtime-cli
run: cargo install --git https://github.com/paritytech/try-runtime-cli --tag v0.7.0 --locked
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build testnet runtime
uses: ./.github/actions/cargo-command
with:
package: timechain-runtime
feature: try-runtime
- name: Download current snapshot
run: curl -LO https://github.com/Analog-Labs/nomination-candidates/releases/download/v0.0.0/testnet.v118.snap
- name: Run try-runtime test
run: try-runtime --runtime target/release/wbuild/timechain-runtime/timechain_runtime.wasm on-runtime-upgrade --checks all --disable-idempotency-checks snap --path testnet.v118.snap
Binary file modified config/subxt/testnet.default.scale
Binary file not shown.
Binary file modified config/subxt/testnet.development.scale
Binary file not shown.
2 changes: 1 addition & 1 deletion primitives/src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub enum ShardStatus {
Created,
Committed,
Online,
Offline,
Offline = 4, // To remove the "= 4", please write a migration!
}

impl Default for ShardStatus {
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ polkadot-sdk = { workspace = true, features = [
"sp-api",
"sp-arithmetic",
"sp-authority-discovery",
"sp-application-crypto",
"sp-block-builder",
"sp-consensus-babe",
"sp-core",
Expand Down
52 changes: 52 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ pub mod opaque {
pub type Hash = <BlakeTwo256 as HashT>::Output;
}

impl_opaque_keys! {
pub struct OldSessionKeys {
pub babe: Babe,
pub grandpa: Grandpa,
pub im_online: ImOnline,
}
}

impl_opaque_keys! {
pub struct SessionKeys {
pub babe: Babe,
Expand All @@ -160,6 +168,49 @@ impl_opaque_keys! {
}
}

pub type Migrations = migration::Outstanding;

pub mod migration {
use super::*;

/// Upgrade Session keys to include AUDI key.
/// When this is removed, should also remove `OldSessionKeys`.
pub struct UpgradeSessionKeys;
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
fn on_runtime_upgrade() -> Weight {
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block
}
}

pub type Outstanding =
(pallet_staking::migrations::v15::MigrateV14ToV15<Runtime>, UpgradeSessionKeys);
}

// remove this when removing `OldSessionKeys`
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
SessionKeys {
grandpa: old.grandpa,
babe: old.babe,
im_online: old.im_online,
authority_discovery: {
// From Session::upgrade_keys():
//
// Care should be taken that the raw versions of the
// added keys are unique for every `ValidatorId, KeyTypeId` combination.
// This is an invariant that the session pallet typically maintains internally.
//
// So, produce a dummy value that's unique for the `ValidatorId, KeyTypeId` combination.
let mut id: AuthorityDiscoveryId =
sp_application_crypto::sr25519::Public::from_raw([0u8; 32]).into();
let id_raw: &mut [u8] = id.as_mut();
id_raw[0..32].copy_from_slice(v.as_ref());
id_raw[0..4].copy_from_slice(b"audi");
id
},
}
}

// To learn more about runtime versioning, see:
// <https://docs.substrate.io/main-docs/build/upgrade#runtime-versioning>
#[cfg(not(feature = "development"))]
Expand Down Expand Up @@ -1111,6 +1162,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
Migrations,
>;

#[cfg(feature = "runtime-benchmarks")]
Expand Down

0 comments on commit d5ec826

Please sign in to comment.