Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Revert "rename runtime api"
Browse files Browse the repository at this point in the history
This reverts commit 9376611.
  • Loading branch information
JoshOrndorff committed Nov 18, 2021
1 parent 71e0b7d commit e3a5f15
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
18 changes: 9 additions & 9 deletions nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use tracing::error;
use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
use sp_core::crypto::Public;
use sp_std::convert::TryInto;
use nimbus_primitives::{NimbusApi, NIMBUS_KEY_ID, NimbusId};
use nimbus_primitives::{AuthorFilterAPI, NIMBUS_KEY_ID, NimbusId};
mod import_queue;

const LOG_TARGET: &str = "filtering-consensus";
Expand Down Expand Up @@ -170,7 +170,7 @@ where
Proof = <EnableProofRecording as ProofRecording>::Proof,
>,
ParaClient: ProvideRuntimeApi<B> + Send + Sync,
ParaClient::Api: NimbusApi<B, NimbusId>,
ParaClient::Api: AuthorFilterAPI<B, NimbusId>,
CIDP: CreateInherentDataProviders<B, (PHash, PersistedValidationData, NimbusId)>,
{
async fn produce_candidate(
Expand All @@ -195,14 +195,14 @@ where
}

let at = BlockId::Hash(parent.hash());
// Get `NimbusApi` version.
// Get `AuthorFilterAPI` version.
let api_version = self.parachain_client.runtime_api()
.api_version::<dyn NimbusApi<B, NimbusId>>(&at)
.api_version::<dyn AuthorFilterAPI<B, NimbusId>>(&at)
.expect("Runtime api access to not error.");

if api_version.is_none() {
tracing::error!(
target: LOG_TARGET, "Could not find `NimbusApi` version.",
target: LOG_TARGET, "Could not find `AuthorFilterAPI` version.",
);
return None;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ where
// Rust bug: https://github.com/rust-lang/rust/issues/24159
sc_client_api::StateBackendFor<RBackend, PBlock>: sc_client_api::StateBackend<HashFor<PBlock>>,
ParaClient: ProvideRuntimeApi<Block> + Send + Sync + 'static,
ParaClient::Api: NimbusApi<Block, NimbusId>,
ParaClient::Api: AuthorFilterAPI<Block, NimbusId>,
CIDP: CreateInherentDataProviders<Block, (PHash, PersistedValidationData, NimbusId)> + 'static,
{
NimbusConsensusBuilder::new(
Expand Down Expand Up @@ -475,7 +475,7 @@ where
/// Build the nimbus consensus.
fn build(self) -> Box<dyn ParachainConsensus<Block>>
where
ParaClient::Api: NimbusApi<Block, NimbusId>,
ParaClient::Api: AuthorFilterAPI<Block, NimbusId>,
{
self.relay_chain_client.clone().execute_with(self)
}
Expand All @@ -497,7 +497,7 @@ where
BI: BlockImport<Block> + Send + Sync + 'static,
RBackend: Backend<PBlock> + 'static,
ParaClient: ProvideRuntimeApi<Block> + Send + Sync + 'static,
ParaClient::Api: NimbusApi<Block, NimbusId>,
ParaClient::Api: AuthorFilterAPI<Block, NimbusId>,
CIDP: CreateInherentDataProviders<Block, (PHash, PersistedValidationData, NimbusId)> + 'static,
{
type Output = Box<dyn ParachainConsensus<Block>>;
Expand All @@ -509,7 +509,7 @@ where
PBackend::State: sp_api::StateBackend<sp_runtime::traits::BlakeTwo256>,
Api: polkadot_client::RuntimeApiCollection<StateBackend = PBackend::State>,
PClient: polkadot_client::AbstractClient<PBlock, PBackend, Api = Api> + 'static,
ParaClient::Api: NimbusApi<Block, NimbusId>,
ParaClient::Api: AuthorFilterAPI<Block, NimbusId>,
{
Box::new(NimbusConsensus::new(
self.para_id,
Expand Down
4 changes: 2 additions & 2 deletions nimbus-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ sp_application_crypto::with_pair! {


sp_api::decl_runtime_apis! {
/// The runtime api used to predict whether a Nimbus author will be eligible in the given slot
/// The runtime api used to predict whether an author will be eligible in the given slot
#[api_version(2)]
pub trait NimbusApi<AuthorId: Codec> {
pub trait AuthorFilterAPI<AuthorId: Codec> {
#[changed_in(2)]
fn can_author(author: AuthorId, relay_parent: u32) -> bool;

Expand Down
4 changes: 2 additions & 2 deletions pallets/aura-style-filter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub mod pallet {
use sp_std::vec::Vec;

//TODO Now that the CanAuthor trait takes a slot number, I don't think this even needs to be a pallet.
// I think it could be just a simple type.
/// The Nimbus Aura pallet
// I think it could eb jsut a simple type.
/// The Author Filter pallet
#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);

Expand Down
2 changes: 1 addition & 1 deletion parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ impl_runtime_apis! {
}
}

impl nimbus_primitives::NimbusApi<Block, nimbus_primitives::NimbusId> for Runtime {
impl nimbus_primitives::AuthorFilterAPI<Block, nimbus_primitives::NimbusId> for Runtime {
fn can_author(author: nimbus_primitives::NimbusId, slot: u32, parent_header: &<Block as BlockT>::Header) -> bool {
// This runtime uses an entropy source that is updated during block initialization
// Therefore we need to initialize it to match the state it will be in when the
Expand Down
5 changes: 3 additions & 2 deletions parachain-template/runtime/src/pallet_account_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ pub mod pallet {
}
}

/// This pallet is compatible with the nimbus consensus system.
/// Any account stored in this pallet is a valid author.
/// This pallet is compatible with nimbus's author filtering system. Any account stored in this pallet
/// is a valid author. Notice that this implementation does not have an inner filter, so it
/// can only be the beginning of the nimbus filter pipeline.
impl<T: Config> CanAuthor<T::AccountId> for Pallet<T> {
fn can_author(author: &T::AccountId, _slot: &u32) -> bool {
StoredAccounts::<T>::get().contains(author)
Expand Down

0 comments on commit e3a5f15

Please sign in to comment.