Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Update BEEFY+MMR integration. (#3480)
Browse files Browse the repository at this point in the history
* Update MMR leaf.

* Revert to older substrate.

* Add version docs.

* Fix spellcheck.
  • Loading branch information
tomusdrw authored Jul 16, 2021
1 parent 956d6ae commit 0c670d8
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 278 deletions.
34 changes: 31 additions & 3 deletions Cargo.lock

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

8 changes: 2 additions & 6 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ serde = { version = "1.0.123", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
static_assertions = "1.1.0"

beefy-primitives = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -36,8 +35,7 @@ pallet-offences = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy-mmr = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features=false, optional = true }
Expand Down Expand Up @@ -67,7 +65,6 @@ libsecp256k1 = "0.3.5"
default = ["std"]
no_std = []
std = [
"beefy-primitives/std",
"bitvec/std",
"parity-scale-codec/std",
"log/std",
Expand All @@ -83,8 +80,7 @@ std = [
"frame-support/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-beefy/std",
"pallet-mmr/std",
"pallet-beefy-mmr/std",
"pallet-session/std",
"pallet-staking/std",
"pallet-timestamp/std",
Expand Down
29 changes: 1 addition & 28 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub mod auctions;
pub mod crowdloan;
pub mod purchase;
pub mod impls;
pub mod mmr;
pub mod paras_sudo_wrapper;
pub mod paras_registrar;
pub mod slot_range;
Expand All @@ -37,8 +36,7 @@ mod mock;
#[cfg(test)]
mod integration_tests;

use beefy_primitives::crypto::AuthorityId as BeefyId;
use primitives::v1::{AccountId, AssignmentId, BlockNumber, ValidatorId};
use primitives::v1::{AssignmentId, BlockNumber, ValidatorId};
use sp_runtime::{Perquintill, Perbill, FixedPointNumber};
use frame_system::limits;
use frame_support::{
Expand Down Expand Up @@ -181,20 +179,6 @@ impl<T: pallet_session::Config> OneSessionHandler<T::AccountId> for AssignmentSe
fn on_disabled(_: usize) { }
}

/// Generates a `BeefyId` from the given `AccountId`. The resulting `BeefyId` is
/// a dummy value and this is a utility function meant to be used when migration
/// session keys.
pub fn dummy_beefy_id_from_account_id(a: AccountId) -> BeefyId {
let mut id = BeefyId::default();
let id_raw: &mut [u8] = id.as_mut();

// NOTE: AccountId is 32 bytes, whereas BeefyId is 33 bytes.
id_raw[1..].copy_from_slice(a.as_ref());
id_raw[0..4].copy_from_slice(b"beef");

id
}

#[cfg(test)]
mod multiplier_tests {
use super::*;
Expand Down Expand Up @@ -297,15 +281,4 @@ mod multiplier_tests {
println!("block = {} multiplier {:?}", blocks, multiplier);
}
}

#[test]
fn generate_dummy_unique_beefy_id_from_account_id() {
let acc1 = AccountId::new([0; 32]);
let acc2 = AccountId::new([1; 32]);

let beefy_id1 = dummy_beefy_id_from_account_id(acc1);
let beefy_id2 = dummy_beefy_id_from_account_id(acc2);

assert_ne!(beefy_id1, beefy_id2);
}
}
226 changes: 0 additions & 226 deletions runtime/common/src/mmr.rs

This file was deleted.

Loading

0 comments on commit 0c670d8

Please sign in to comment.