Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.11.0 (with New MMR) #675

Merged
merged 12 commits into from Jul 20, 2021
681 changes: 332 additions & 349 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions node/service/src/chain_spec/crab.rs
Expand Up @@ -187,8 +187,8 @@ pub fn crab_build_spec_genesis() -> GenesisConfig {
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
darwinia_democracy: Default::default(),
pallet_collective_Instance2: Default::default(),
pallet_collective_Instance1: Default::default(),
pallet_collective_Instance2: Default::default(),
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_claims: ClaimsConfig {
Expand Down Expand Up @@ -296,8 +296,8 @@ pub fn crab_testnet_genesis(
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
darwinia_democracy: Default::default(),
pallet_collective_Instance2: Default::default(),
pallet_collective_Instance1: Default::default(),
pallet_collective_Instance2: Default::default(),
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_claims: ClaimsConfig {
Expand Down
4 changes: 2 additions & 2 deletions node/service/src/chain_spec/darwinia.rs
Expand Up @@ -286,8 +286,8 @@ pub fn darwinia_build_spec_genesis() -> GenesisConfig {
pallet_grandpa: Default::default(),
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
pallet_collective_Instance2: Default::default(),
pallet_collective_Instance1: Default::default(),
pallet_collective_Instance2: Default::default(),
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_vesting: VestingConfig {
Expand Down Expand Up @@ -425,8 +425,8 @@ pub fn darwinia_testnet_genesis(
pallet_grandpa: Default::default(),
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
pallet_collective_Instance2: Default::default(),
pallet_collective_Instance1: Default::default(),
pallet_collective_Instance2: Default::default(),
darwinia_elections_phragmen: Default::default(),
pallet_membership_Instance1: Default::default(),
darwinia_vesting: Default::default(),
Expand Down
55 changes: 39 additions & 16 deletions runtime/crab/src/lib.rs
Expand Up @@ -204,11 +204,11 @@ frame_support::construct_runtime! {
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 11,
ImOnline: pallet_im_online::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned} = 12,
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 13,
HeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage} = 31,
DarwiniaHeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage} = 31,

// Governance stuff; uncallable initially.
Council: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 14,
TechnicalCommittee: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 15,
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 14,
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 15,
PhragmenElection: darwinia_elections_phragmen::{Pallet, Call, Storage, Config<T>, Event<T>} = 26,
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Config<T>, Event<T>} = 16,
Treasury: darwinia_treasury::{Pallet, Call, Storage, Event<T>} = 32,
Expand Down Expand Up @@ -507,7 +507,7 @@ sp_api::impl_runtime_apis! {
block_number_of_member_leaf: u64,
block_number_of_last_leaf: u64
) -> HeaderMMRRuntimeDispatchInfo<Hash> {
HeaderMMR::gen_proof_rpc(block_number_of_member_leaf, block_number_of_last_leaf )
DarwiniaHeaderMMR::gen_proof_rpc(block_number_of_member_leaf, block_number_of_last_leaf )
}
}

Expand Down Expand Up @@ -663,25 +663,48 @@ pub struct CustomOnRuntimeUpgrade;
impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
// --- substrate ---
// use frame_support::migration;

Ok(())
}

fn on_runtime_upgrade() -> Weight {
// --- substrate ---
use frame_support::migration;
migrate()
}
}

migration::move_pallet(b"Instance0DarwiniaBalances", b"Balances");
migration::move_pallet(b"Instance1DarwiniaBalances", b"Kton");
fn migrate() -> Weight {
// --- paritytech ---
use frame_support::{migration, storage::StorageMap};

migration::move_pallet(b"Instance0Collective", b"Instance2Collective");
const BAD_SCHEDULE_KEY: BlockNumber = 2332800;

migration::move_pallet(b"Instance0Membership", b"Instance1Membership");
log::info!("Moving storage `Instance0DarwiniaBalances` to `Balances`");
migration::move_pallet(b"Instance0DarwiniaBalances", b"Balances");
log::info!("Moving storage `Instance1DarwiniaBalances` to `Kton`");
migration::move_pallet(b"Instance1DarwiniaBalances", b"Kton");

migration::move_pallet(b"DarwiniaPhragmenElection", b"PhragmenElection");
// Tech.Comm to Instance2
log::info!("Moving storage `Instance1Collective` to `Instance2Collective`");
migration::move_pallet(b"Instance1Collective", b"Instance2Collective");
// Council to Instance1
log::info!("Moving storage `Instance0Collective` to `Instance1Collective`");
migration::move_pallet(b"Instance0Collective", b"Instance1Collective");

RuntimeBlockWeights::get().max_block
}
log::info!("Moving storage `Instance0Membership` to `Instance1Membership`");
migration::move_pallet(b"Instance0Membership", b"Instance1Membership");

log::info!("Moving storage `DarwiniaPhragmenElection` to `PhragmenElection`");
migration::move_pallet(b"DarwiniaPhragmenElection", b"PhragmenElection");

#[cfg(feature = "try-runtime")]
assert!(<pallet_scheduler::Agenda<Runtime>>::contains_key(
BAD_SCHEDULE_KEY
));
log::info!("Removing bad schedule");
<pallet_scheduler::Agenda<Runtime>>::remove(BAD_SCHEDULE_KEY);
#[cfg(feature = "try-runtime")]
assert!(!<pallet_scheduler::Agenda<Runtime>>::contains_key(
BAD_SCHEDULE_KEY
));

RuntimeBlockWeights::get().max_block
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/collective.rs
@@ -1,4 +1,4 @@
pub use pallet_collective::{Instance1 as TechnicalCollective, Instance2 as CouncilCollective};
pub use pallet_collective::{Instance1 as CouncilCollective, Instance2 as TechnicalCollective};

// --- substrate ---
use frame_system::{EnsureOneOf, EnsureRoot};
Expand Down
6 changes: 5 additions & 1 deletion runtime/crab/src/pallets/header_mmr.rs
Expand Up @@ -2,4 +2,8 @@
use crate::*;
use darwinia_header_mmr::Config;

impl Config for Runtime {}
impl Config for Runtime {
type WeightInfo = ();

const INDEXING_PREFIX: &'static [u8] = b"header-mmr-";
}
2 changes: 1 addition & 1 deletion runtime/crab/src/pallets/proxy.rs
Expand Up @@ -62,7 +62,7 @@ impl InstanceFilter<Call> for ProxyType {
Call::Scheduler(..) |
Call::Proxy(..) |
Call::Multisig(..) |
Call::HeaderMMR(..) // Specifically omitting the entire CrabIssuing pallet
Call::DarwiniaHeaderMMR(..) // Specifically omitting the entire CrabIssuing pallet
),
ProxyType::Governance => matches!(
c,
Expand Down
13 changes: 8 additions & 5 deletions runtime/darwinia/src/lib.rs
Expand Up @@ -251,12 +251,12 @@ frame_support::construct_runtime! {
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 13,
ImOnline: pallet_im_online::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned} = 14,
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 15,
HeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage} = 35,
DarwiniaHeaderMMR: darwinia_header_mmr::{Pallet, Call, Storage} = 35,

// Governance stuff; uncallable initially.
Democracy: darwinia_democracy::{Pallet, Call, Storage, Config, Event<T>} = 37,
Council: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 16,
TechnicalCommittee: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 17,
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 16,
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Config<T>, Event<T>} = 17,
PhragmenElection: darwinia_elections_phragmen::{Pallet, Call, Storage, Config<T>, Event<T>} = 18,
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Config<T>, Event<T>} = 19,
Treasury: darwinia_treasury::{Pallet, Call, Storage, Event<T>} = 20,
Expand Down Expand Up @@ -551,7 +551,7 @@ impl_runtime_apis! {
block_number_of_member_leaf: u64,
block_number_of_last_leaf: u64
) -> HeaderMMRRuntimeDispatchInfo<Hash> {
HeaderMMR::gen_proof_rpc(block_number_of_member_leaf, block_number_of_last_leaf )
DarwiniaHeaderMMR::gen_proof_rpc(block_number_of_member_leaf, block_number_of_last_leaf )
}
}

Expand Down Expand Up @@ -588,7 +588,10 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
migration::move_pallet(b"Instance0DarwiniaBalances", b"Balances");
migration::move_pallet(b"Instance1DarwiniaBalances", b"Kton");

migration::move_pallet(b"Instance0Collective", b"Instance2Collective");
// Tech.Comm to Instance2
migration::move_pallet(b"Instance1Collective", b"Instance2Collective");
// Council to Instance1
migration::move_pallet(b"Instance0Collective", b"Instance1Collective");
AurevoirXavier marked this conversation as resolved.
Show resolved Hide resolved

migration::move_pallet(b"Instance0Membership", b"Instance1Membership");

Expand Down
2 changes: 1 addition & 1 deletion runtime/darwinia/src/pallets/collective.rs
@@ -1,4 +1,4 @@
pub use pallet_collective::{Instance1 as TechnicalCollective, Instance2 as CouncilCollective};
pub use pallet_collective::{Instance1 as CouncilCollective, Instance2 as TechnicalCollective};

// --- substrate ---
use frame_system::{EnsureOneOf, EnsureRoot};
Expand Down
6 changes: 5 additions & 1 deletion runtime/darwinia/src/pallets/header_mmr.rs
Expand Up @@ -2,4 +2,8 @@
use crate::*;
use darwinia_header_mmr::Config;

impl Config for Runtime {}
impl Config for Runtime {
type WeightInfo = ();

const INDEXING_PREFIX: &'static [u8] = b"header-mmr-";
}
2 changes: 1 addition & 1 deletion runtime/darwinia/src/pallets/proxy.rs
Expand Up @@ -64,7 +64,7 @@ impl InstanceFilter<Call> for ProxyType {
// Specifically omitting the entire EthereumBacking pallet
Call::EthereumRelay(..) |
// Specifically omitting the entire TronBacking pallet
Call::HeaderMMR(..) // Specifically omitting the entire EthereumRelayAuthorities pallet
Call::DarwiniaHeaderMMR(..) // Specifically omitting the entire EthereumRelayAuthorities pallet
),
ProxyType::Governance => matches!(
c,
Expand Down
2 changes: 1 addition & 1 deletion runtime/darwinia/src/pallets/relay_authorities.rs
Expand Up @@ -29,7 +29,7 @@ impl Config<EthereumRelayAuthoritiesInstance> for Runtime {
type AddOrigin = ApproveOrigin;
type RemoveOrigin = ApproveOrigin;
type ResetOrigin = ApproveOrigin;
type DarwiniaMMR = HeaderMMR;
type DarwiniaMMR = DarwiniaHeaderMMR;
type Sign = EthereumBacking;
type OpCodes = OpCodes;
type SignThreshold = SignThreshold;
Expand Down