Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
854 changes: 535 additions & 319 deletions Cargo.lock

Large diffs are not rendered by default.

154 changes: 79 additions & 75 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion demo/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ sp-consensus-aura = { workspace = true }
sp-partner-chains-consensus-aura = { workspace = true }
sp-consensus = { workspace = true }
sc-consensus = { workspace = true }
sc-consensus-beefy = { workspace = true }
sc-consensus-beefy-rpc = { workspace = true }
sp-consensus-beefy = { workspace = true }
sc-consensus-grandpa = { workspace = true }
sc-consensus-grandpa-rpc = { workspace = true }
sp-consensus-grandpa = { workspace = true }
Expand All @@ -52,7 +55,6 @@ sp-keyring = { workspace = true }
authority-selection-inherents = { workspace = true }
frame-system = { workspace = true }
pallet-transaction-payment = { workspace = true }
sp-block-production-log = { workspace = true }
sidechain-domain = { workspace = true }
sidechain-slots = { workspace = true }
sp-sidechain = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions demo/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub fn pc_create_chain_spec(config: &CreateChainSpecConfig<SessionKeys>) -> serd
system: partner_chains_demo_runtime::SystemConfig::default(),
balances: partner_chains_demo_runtime::BalancesConfig::default(),
aura: partner_chains_demo_runtime::AuraConfig::default(),
beefy: partner_chains_demo_runtime::BeefyConfig::default(),
grandpa: partner_chains_demo_runtime::GrandpaConfig::default(),
sudo: partner_chains_demo_runtime::SudoConfig::default(),
transaction_payment: Default::default(),
Expand Down
30 changes: 2 additions & 28 deletions demo/node/src/inherent_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use sp_block_participation::{
BlockParticipationApi,
inherent_data::{BlockParticipationDataSource, BlockParticipationInherentDataProvider},
};
use sp_block_production_log::{BlockAuthorInherentProvider, BlockProductionLogApi};
use sp_blockchain::HeaderBackend;
use sp_consensus_aura::{
Slot, inherents::InherentDataProvider as AuraIDP, sr25519::AuthorityPair as AuraPair,
Expand Down Expand Up @@ -54,7 +53,6 @@ where
T: ProvideRuntimeApi<Block> + Send + Sync + 'static,
T: HeaderBackend<Block>,
T::Api: SessionValidatorManagementApi<Block, CrossChainPublic, SessionKeys, ScEpochNumber>,
T::Api: BlockProductionLogApi<Block, BlockAuthor, Slot>,
T::Api: BlockParticipationApi<Block, BlockAuthor, Slot>,
T::Api: GovernedMapIDPApi<Block>,
T::Api: TokenBridgeIDPRuntimeApi<Block>,
Expand All @@ -64,7 +62,6 @@ where
TimestampIDP,
McHashIDP,
AriadneIDP,
BlockAuthorInherentProvider<Slot, BlockAuthor>,
BlockParticipationInherentDataProvider<BlockAuthor, DelegatorKey, Slot>,
GovernedMapInherentDataProvider,
TokenBridgeInherentDataProvider<AccountId>,
Expand Down Expand Up @@ -111,8 +108,6 @@ where
mc_hash.mc_epoch(),
)
.await?;
let block_producer_id_provider =
BlockAuthorInherentProvider::new(client.as_ref(), parent_hash, *slot)?;

let payouts = BlockParticipationInherentDataProvider::new(
client.as_ref(),
Expand Down Expand Up @@ -140,16 +135,7 @@ where
)
.await?;

Ok((
slot,
timestamp,
mc_hash,
ariadne_data_provider,
block_producer_id_provider,
payouts,
governed_map,
bridge,
))
Ok((slot, timestamp, mc_hash, ariadne_data_provider, payouts, governed_map, bridge))
}
}

Expand All @@ -175,15 +161,13 @@ impl<T> CreateInherentDataProviders<Block, (Slot, McBlockHash)> for VerifierCIDP
where
T: ProvideRuntimeApi<Block> + Send + Sync + HeaderBackend<Block>,
T::Api: SessionValidatorManagementApi<Block, CrossChainPublic, SessionKeys, ScEpochNumber>,
T::Api: BlockProductionLogApi<Block, BlockAuthor, Slot>,
T::Api: BlockParticipationApi<Block, BlockAuthor, Slot>,
T::Api: GovernedMapIDPApi<Block>,
T::Api: TokenBridgeIDPRuntimeApi<Block>,
{
type InherentDataProviders = (
TimestampIDP,
AriadneIDP,
BlockAuthorInherentProvider<Slot, BlockAuthor>,
BlockParticipationInherentDataProvider<BlockAuthor, DelegatorKey, Slot>,
GovernedMapInherentDataProvider,
TokenBridgeInherentDataProvider<AccountId>,
Expand Down Expand Up @@ -237,9 +221,6 @@ where
)
.await?;

let block_producer_id_provider =
BlockAuthorInherentProvider::new(client.as_ref(), parent_hash, verified_block_slot)?;

let payouts = BlockParticipationInherentDataProvider::new(
client.as_ref(),
block_participation_data_source.as_ref(),
Expand All @@ -266,14 +247,7 @@ where
)
.await?;

Ok((
timestamp,
ariadne_data_provider,
block_producer_id_provider,
payouts,
governed_map,
bridge,
))
Ok((timestamp, ariadne_data_provider, payouts, governed_map, bridge))
}
}

Expand Down
35 changes: 31 additions & 4 deletions demo/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ use partner_chains_demo_runtime::{
opaque::{Block, SessionKeys},
};
use partner_chains_demo_runtime::{BlockNumber, BlockProducerMetadataType, CrossChainPublic, Hash};
use sc_consensus_beefy::communication::notification::{
BeefyBestBlockStream, BeefyVersionedFinalityProofStream,
};
use sc_consensus_beefy_rpc::Beefy;
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
Expand All @@ -28,6 +32,7 @@ use sidechain_domain::mainchain_epoch::MainchainEpochConfig;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_consensus_beefy::AuthorityIdBound;
use sp_session_validator_management_query::SessionValidatorManagementQuery;
use sp_sidechain::GetEpochDurationApi;
use std::sync::Arc;
Expand All @@ -47,23 +52,35 @@ pub struct GrandpaDeps<B> {
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
}

/// Dependencies for BEEFY
pub struct BeefyDeps<AuthorityId: AuthorityIdBound> {
/// Receives notifications about finality proof events from BEEFY.
pub beefy_finality_proof_stream: BeefyVersionedFinalityProofStream<Block, AuthorityId>,
/// Receives notifications about best block events from BEEFY.
pub beefy_best_block_stream: BeefyBestBlockStream<Block>,
/// Executor to drive the subscription manager in the BEEFY RPC handler.
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
}

/// Full client dependencies.
pub struct FullDeps<C, P, B, T> {
pub struct FullDeps<C, P, B, T, AuthorityId: AuthorityIdBound> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps<B>,
/// BEEFY specific dependencies.
pub beefy: BeefyDeps<AuthorityId>,
/// Data sources.
pub data_sources: DataSources,
/// Source of system time
pub time_source: Arc<T>,
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P, B, T>(
deps: FullDeps<C, P, B, T>,
pub fn create_full<C, P, B, T, AuthorityId: AuthorityIdBound>(
deps: FullDeps<C, P, B, T, AuthorityId>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>,
Expand Down Expand Up @@ -93,10 +110,11 @@ where
T: TimeSource + Send + Sync + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_beefy_rpc::BeefyApiServer;
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcModule::new(());
let FullDeps { client, pool, grandpa, data_sources, time_source } = deps;
let FullDeps { client, pool, grandpa, beefy, data_sources, time_source } = deps;

module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
Expand Down Expand Up @@ -137,6 +155,15 @@ where
.into_rpc(),
)?;

module.merge(
Beefy::<Block, AuthorityId>::new(
beefy.beefy_finality_proof_stream,
beefy.beefy_best_block_stream,
beefy.subscription_executor,
)?
.into_rpc(),
)?;

// Extend this RPC with a custom API by using the following syntax.
// `YourRpcStruct` should have a reference to a client, which is needed
// to call into the runtime.
Expand Down
Loading
Loading