Skip to content

Commit

Permalink
cli, cli-opt, consensus transition and rpc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raj-RR1 committed Aug 17, 2023
1 parent cbe1390 commit 88094e8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
4 changes: 2 additions & 2 deletions node/cli-opt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::{fmt, str::FromStr};

/// Block authoring scheme to be used by the dev service.
#[derive(Debug)]
#[derive(Debug, Copy, Clone)]
pub enum Sealing {
/// Author a block immediately upon receiving a transaction into the
/// transaction pool
Expand Down Expand Up @@ -85,6 +85,6 @@ pub struct RpcConfig {
pub eth_statuses_cache: usize,
pub fee_history_limit: u64,
pub max_past_logs: u32,
pub relay_chain_rpc_url: Option<url::Url>,
pub relay_chain_rpc_url: Vec<url::Url>,
pub tracing_raw_max_memory_usage: usize,
}
2 changes: 2 additions & 0 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ pub struct NewFullBase {
pub client: Arc<FullClient>,
/// The networking service of the node.
pub network: Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
/// The syncing service of the node.
pub sync: Arc<SyncingService<Block>>,
/// The transaction pool of the node.
pub transaction_pool: Arc<TransactionPool>,
/// The rpc handlers of the node.
Expand Down
23 changes: 19 additions & 4 deletions node/consensus-transition/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Module implementing the logic for verifying and importing AuRa blocks.

use crate::{
aura_err, authorities, find_pre_digest, slot_author, AuthorityId, CompatibilityMode, Error,
aura_err, authorities, standalone::SealVerificationError, find_pre_digest, slot_author, AuthorityId, CompatibilityMode, Error,
};
use parity_scale_codec::{Codec, Decode, Encode};
use log::{debug, info, trace};
Expand Down Expand Up @@ -145,6 +145,7 @@ where
async fn check_inherents<B: BlockT>(
&self,
block: B,
//at_hash: B::Hash, --Raj
block_id: BlockId<B>,
inherent_data: sp_inherents::InherentData,
create_inherent_data_providers: CIDP::InherentDataProviders,
Expand Down Expand Up @@ -201,6 +202,19 @@ where
&mut self,
mut block: BlockImportParams<B, ()>,
) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {

// Skip checks that include execution, if being told so or when importing only state.
//
// This is done for example when gap syncing and it is expected that the block after the gap
// was checked/chosen properly, e.g. by warp syncing to this block using a finality proof.
// Or when we are importing state only and can not verify the seal.
if block.with_state() || block.state_action.skip_execution_checks() {
// When we are importing only the state of a block, it will be the best block.
block.fork_choice = Some(ForkChoiceStrategy::Custom(block.with_state()));

return Ok(block)
}

let hash = block.header.hash();
let parent_hash = *block.header.parent_hash();
let authorities = authorities(
Expand All @@ -219,6 +233,7 @@ where

let mut inherent_data = create_inherent_data_providers
.create_inherent_data()
.await
.map_err(Error::<B>::Inherent)?;

let slot_now = create_inherent_data_providers.slot();
Expand Down Expand Up @@ -250,14 +265,14 @@ where
.client
.runtime_api()
.has_api_with::<dyn BlockBuilderApi<B>, _>(
&BlockId::Hash(parent_hash),
parent_hash,
|v| v >= 2,
)
.map_err(|e| e.to_string())?
{
self.check_inherents(
new_block.clone(),
BlockId::Hash(parent_hash),
parent_hash,
inherent_data,
create_inherent_data_providers,
block.origin.into(),
Expand All @@ -283,7 +298,7 @@ where
block.fork_choice = Some(ForkChoiceStrategy::LongestChain);
block.post_hash = Some(hash);

Ok((block, None))
Ok(block)
},
CheckedHeader::Deferred(a, b) => {
debug!(target: "aura", "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
Expand Down
19 changes: 16 additions & 3 deletions node/consensus-transition/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ where
}

/// Parameters of [`build_aura_worker`].
pub struct BuildAuraWorkerParams<C, I, PF, SO, L, BS, N> {
pub struct BuildAuraWorkerParams<C, SC, I, PF, SO, L, CIDP, BS, N> {
/// The duration of a slot.
pub slot_duration: SlotDuration,
/// The client to interact with the chain.
pub client: Arc<C>,
/// A select chain implementation to select the best block.
pub select_chain: SC,
/// The block import.
pub block_import: I,
/// The proposer factory to build proposer instances.
Expand All @@ -262,6 +266,8 @@ pub struct BuildAuraWorkerParams<C, I, PF, SO, L, BS, N> {
pub sync_oracle: SO,
/// Hook into the sync module to control the justification sync process.
pub justification_sync_link: L,
/// Something that can create the inherent data providers.
pub create_inherent_data_providers: CIDP,
/// Should we force the authoring of blocks?
pub force_authoring: bool,
/// The backoff strategy when we miss slots.
Expand Down Expand Up @@ -303,7 +309,14 @@ pub fn build_aura_worker<P, B, C, PF, I, SO, L, BS, Error>(
force_authoring,
compatibility_mode,
}: BuildAuraWorkerParams<C, I, PF, SO, L, BS, NumberFor<B>>,
) -> impl sc_consensus_slots::SlotWorker<B, <PF::Proposer as Proposer<B>>::Proof>
) -> impl sc_consensus_slots::SlotWorker<B,
Proposer = PF::Proposer,
BlockImport = I,
SyncOracle = SO,
JustificationSyncLink = L,
Claim = P::Public,
AuxData = Vec<AuthorityId<P>>,
>

where
B: BlockT,
Expand All @@ -315,7 +328,7 @@ where
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync + 'static,
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
Error: std::error::Error + Send + From<ConsensusError> + 'static,
SO: SyncOracle + Send + Sync + Clone,
L: sc_consensus::JustificationSyncLink<B>,
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + Sync + 'static,
Expand Down
6 changes: 6 additions & 0 deletions node/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub trait RuntimeApiCollection:
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ edgeware_rpc_primitives_debug::DebugRuntimeApi<Block>
+ edgeware_rpc_primitives_txpool::TxPoolRuntimeApi<Block>
+ nimbus_primitives::NimbusApi<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ session_keys_primitives::VrfApi<Block>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
Expand All @@ -52,6 +55,9 @@ where
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ edgeware_rpc_primitives_debug::DebugRuntimeApi<Block>
+ edgeware_rpc_primitives_txpool::TxPoolRuntimeApi<Block>,
+ nimbus_primitives::NimbusApi<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ session_keys_primitives::VrfApi<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}
11 changes: 11 additions & 0 deletions node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ use sc_client_api::{
client::BlockchainEvents,
BlockOf,
};
use sc_consensus_babe::BabeWorkerHandle;
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApi};
use sc_network::NetworkService;
use sc_transaction_pool::{ChainApi, Pool};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
use sp_keystore::KeystorePtr;
// Frontier
use fc_rpc::{
EthBlockDataCacheTask, EthTask, OverrideHandle, RuntimeApiStorageOverride,
Expand All @@ -73,6 +75,15 @@ pub mod client;
pub mod tracing;
use client::RuntimeApiCollection;


/// Extra dependencies for BABE.
pub struct BabeDeps {
/// A handle to the BABE worker for issuing requests.
pub babe_worker_handle: BabeWorkerHandle<Block>,
/// The keystore that manages the keys of the node.
pub keystore: KeystorePtr,
}

/// Extra dependencies for GRANDPA
pub struct GrandpaDeps<B> {
/// Voting round info.
Expand Down
2 changes: 1 addition & 1 deletion node/rpc/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn extend_with_tracing<C, BE>(
}
}

/// Spawn the tasks that are required to run a Moonbeam tracing node.
/// Spawn the tasks that are required to run an Edgeware tracing node.
pub fn spawn_tracing_tasks<B, C, BE>(
rpc_config: &edgeware_cli_opt::RpcConfig,
params: SpawnTasksParams<B, C, BE>,
Expand Down

0 comments on commit 88094e8

Please sign in to comment.