Skip to content

Commit 076b726

Browse files
committed
wip merge babe in runtime
1 parent a71f7ce commit 076b726

File tree

2 files changed

+9
-73
lines changed

2 files changed

+9
-73
lines changed

pallets/admin-utils/src/lib.rs

+1-49
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use frame_system::pallet_prelude::BlockNumberFor;
1212
// - we could use a type parameter for `AuthorityId`, but there is
1313
// no sense for this as GRANDPA's `AuthorityId` is not a parameter -- it's always the same
1414
use sp_consensus_grandpa::AuthorityList;
15-
use sp_runtime::{traits::Member, DispatchResult, RuntimeAppPublic};
15+
use sp_runtime::DispatchResult;
1616

1717
mod benchmarking;
1818

@@ -28,7 +28,6 @@ pub mod pallet {
2828
use frame_support::traits::tokens::Balance;
2929
use frame_system::pallet_prelude::*;
3030
use pallet_evm_chain_id::{self, ChainId};
31-
use sp_runtime::BoundedVec;
3231

3332
/// The main data structure of the module.
3433
#[pallet::pallet]
@@ -45,22 +44,9 @@ pub mod pallet {
4544
/// Because this pallet emits events, it depends on the runtime's definition of an event.
4645
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
4746

48-
/// Implementation of the AuraInterface
49-
type Aura: crate::AuraInterface<<Self as Config>::AuthorityId, Self::MaxAuthorities>;
50-
5147
/// Implementation of [`GrandpaInterface`]
5248
type Grandpa: crate::GrandpaInterface<Self>;
5349

54-
/// The identifier type for an authority.
55-
type AuthorityId: Member
56-
+ Parameter
57-
+ RuntimeAppPublic
58-
+ MaybeSerializeDeserialize
59-
+ MaxEncodedLen;
60-
61-
/// The maximum number of authorities that the pallet can hold.
62-
type MaxAuthorities: Get<u32>;
63-
6450
/// Weight information for extrinsics in this pallet.
6551
type WeightInfo: WeightInfo;
6652

@@ -85,25 +71,6 @@ pub mod pallet {
8571
/// Dispatchable functions allows users to interact with the pallet and invoke state changes.
8672
#[pallet::call]
8773
impl<T: Config> Pallet<T> {
88-
/// The extrinsic sets the new authorities for Aura consensus.
89-
/// It is only callable by the root account.
90-
/// The extrinsic will call the Aura pallet to change the authorities.
91-
#[pallet::call_index(0)]
92-
#[pallet::weight(<T as Config>::WeightInfo::swap_authorities(new_authorities.len() as u32))]
93-
pub fn swap_authorities(
94-
origin: OriginFor<T>,
95-
new_authorities: BoundedVec<<T as Config>::AuthorityId, T::MaxAuthorities>,
96-
) -> DispatchResult {
97-
ensure_root(origin)?;
98-
99-
T::Aura::change_authorities(new_authorities.clone());
100-
101-
log::debug!("Aura authorities changed: {:?}", new_authorities);
102-
103-
// Return a successful DispatchResultWithPostInfo
104-
Ok(())
105-
}
106-
10774
/// The extrinsic sets the default take for the network.
10875
/// It is only callable by the root account.
10976
/// The extrinsic will call the Subtensor pallet to set the default take.
@@ -1281,21 +1248,6 @@ pub mod pallet {
12811248
}
12821249
}
12831250

1284-
impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
1285-
type Public = <T as Config>::AuthorityId;
1286-
}
1287-
1288-
// Interfaces to interact with other pallets
1289-
use sp_runtime::BoundedVec;
1290-
1291-
pub trait AuraInterface<AuthorityId, MaxAuthorities> {
1292-
fn change_authorities(new: BoundedVec<AuthorityId, MaxAuthorities>);
1293-
}
1294-
1295-
impl<A, M> AuraInterface<A, M> for () {
1296-
fn change_authorities(_: BoundedVec<A, M>) {}
1297-
}
1298-
12991251
pub trait GrandpaInterface<Runtime>
13001252
where
13011253
Runtime: frame_system::Config,

runtime/src/lib.rs

+8-24
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,6 @@ impl frame_system::Config for Runtime {
371371
type PostTransactions = ();
372372
}
373373

374-
impl pallet_aura::Config for Runtime {
375-
type AuthorityId = AuraId;
376-
type DisabledValidators = ();
377-
type MaxAuthorities = ConstU32<32>;
378-
type AllowMultipleBlocksPerSlot = ConstBool<false>;
379-
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
380-
}
381-
382374
parameter_types! {
383375
pub EpochDuration: u64 = prod_or_fast!(
384376
EPOCH_DURATION_IN_SLOTS as u64,
@@ -1541,13 +1533,6 @@ impl pallet_subtensor::Config for Runtime {
15411533

15421534
use sp_runtime::BoundedVec;
15431535

1544-
pub struct AuraPalletIntrf;
1545-
impl pallet_admin_utils::AuraInterface<AuraId, ConstU32<32>> for AuraPalletIntrf {
1546-
fn change_authorities(new: BoundedVec<AuraId, ConstU32<32>>) {
1547-
Aura::change_authorities(new);
1548-
}
1549-
}
1550-
15511536
pub struct GrandpaInterfaceImpl;
15521537
impl pallet_admin_utils::GrandpaInterface<Runtime> for GrandpaInterfaceImpl {
15531538
fn schedule_change(
@@ -1561,9 +1546,6 @@ impl pallet_admin_utils::GrandpaInterface<Runtime> for GrandpaInterfaceImpl {
15611546

15621547
impl pallet_admin_utils::Config for Runtime {
15631548
type RuntimeEvent = RuntimeEvent;
1564-
type AuthorityId = AuraId;
1565-
type MaxAuthorities = ConstU32<32>;
1566-
type Aura = AuraPalletIntrf;
15671549
type Grandpa = GrandpaInterfaceImpl;
15681550
type Balance = Balance;
15691551
type WeightInfo = pallet_admin_utils::weights::SubstrateWeight<Runtime>;
@@ -1590,10 +1572,10 @@ impl<F: FindAuthor<u32>> FindAuthor<H160> for FindAuthorTruncated<F> {
15901572
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
15911573
{
15921574
if let Some(author_index) = F::find_author(digests) {
1593-
pallet_aura::Authorities::<Runtime>::get()
1575+
pallet_babe::Authorities::<Runtime>::get()
15941576
.get(author_index as usize)
15951577
.and_then(|authority_id| {
1596-
let raw_vec = authority_id.to_raw_vec();
1578+
let raw_vec = authority_id.0.to_raw_vec();
15971579
raw_vec.get(4..24).map(H160::from_slice)
15981580
})
15991581
} else {
@@ -1672,7 +1654,7 @@ impl pallet_evm::Config for Runtime {
16721654
type Runner = pallet_evm::runner::stack::Runner<Self>;
16731655
type OnChargeTransaction = ();
16741656
type OnCreate = ();
1675-
type FindAuthor = FindAuthorTruncated<Aura>;
1657+
type FindAuthor = FindAuthorTruncated<Babe>;
16761658
type GasLimitPovSizeRatio = GasLimitPovSizeRatio;
16771659
type SuicideQuickClearLimit = SuicideQuickClearLimit;
16781660
type Timestamp = Timestamp;
@@ -1810,7 +1792,7 @@ construct_runtime!(
18101792
System: frame_system = 0,
18111793
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 1,
18121794
Timestamp: pallet_timestamp = 2,
1813-
Aura: pallet_aura = 3,
1795+
// Aura: pallet_aura = 3,
18141796
Grandpa: pallet_grandpa = 4,
18151797
Balances: pallet_balances = 5,
18161798
TransactionPayment: pallet_transaction_payment = 6,
@@ -2521,11 +2503,13 @@ impl_runtime_apis! {
25212503

25222504
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
25232505
fn slot_duration() -> sp_consensus_aura::SlotDuration {
2524-
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
2506+
unimplemented!()
2507+
// sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
25252508
}
25262509

25272510
fn authorities() -> Vec<AuraId> {
2528-
pallet_aura::Authorities::<Runtime>::get().into_inner()
2511+
unimplemented!()
2512+
// pallet_aura::Authorities::<Runtime>::get().into_inner()
25292513
}
25302514
}
25312515

0 commit comments

Comments
 (0)