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

Commit

Permalink
more compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Nov 28, 2019
1 parent f38267c commit 4796fc5
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 83 deletions.
32 changes: 28 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
log = "0.4.8"
exit-future = "0.1.4"
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }

[dev-dependencies]
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down
7 changes: 3 additions & 4 deletions network/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//! will be noted as non-beneficial to Substrate's peer-set management utility.

use sr_primitives::{generic::BlockId, traits::ProvideRuntimeApi};
use substrate_client::error::Error as ClientError;
use sp_blockchain::Error as ClientError;
use substrate_network::{config::Roles, PeerId};
use substrate_network::consensus_gossip::{
self as network_gossip, ValidationResult as GossipValidationResult,
Expand Down Expand Up @@ -897,12 +897,11 @@ mod tests {
}
});
let encoded = statement.encode();
let intent = MessageIntent::Broadcast;
validator.inner.write().attestation_view.new_local_leaf(hash_a, MessageValidationData::default());

{
let mut message_allowed = validator.message_allowed();
assert!(!message_allowed(&peer_a, MessageIntent::Broadcast { previous_attempts: 0 }, &topic_a, &encoded[..]));
assert!(!message_allowed(&peer_a, MessageIntent::Broadcast, &topic_a, &encoded[..]));
}

validator
Expand All @@ -915,7 +914,7 @@ mod tests {
.note_aware_under_leaf(&hash_a, c_hash);
{
let mut message_allowed = validator.message_allowed();
assert!(message_allowed(&peer_a, MessageIntent::Broadcast { previous_attempts: 0 }, &topic_a, &encoded[..]));
assert!(message_allowed(&peer_a, MessageIntent::Broadcast, &topic_a, &encoded[..]));
}
}

Expand Down
2 changes: 1 addition & 1 deletion network/src/gossip/message_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
use sr_primitives::traits::{BlakeTwo256, Hash as HashT};
use polkadot_primitives::Hash;
use std::collections::{HashMap, HashSet};
use substrate_client::error::Error as ClientError;
use sp_blockchain::Error as ClientError;
use super::{MAX_CHAIN_HEADS, GossipValidationResult, LeavesVec, ChainContext};

/// Construct a topic for a message queue root deterministically.
Expand Down
2 changes: 1 addition & 1 deletion network/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<P, E: Clone, N: NetworkService, T: Clone> Clone for Router<P, E, N, T> {
}

impl<P: ProvideRuntimeApi + Send + Sync + 'static, E, N, T> Router<P, E, N, T> where
P::Api: ParachainHost<Block, Error = substrate_client::error::Error>,
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
N: NetworkService,
T: Clone + Executor + Send + 'static,
E: Future<Item=(),Error=()> + Clone + Send + 'static,
Expand Down
2 changes: 1 addition & 1 deletion network/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl crate::gossip::ChainContext for TestChainContext {
}

fn leaf_unrouted_roots(&self, leaf: &Hash, with_queue_root: &mut dyn FnMut(&Hash))
-> Result<(), substrate_client::error::Error>
-> Result<(), sp_blockchain::Error>
{
for root in self.ingress_roots.get(leaf).into_iter().flat_map(|roots| roots) {
with_queue_root(root)
Expand Down
4 changes: 2 additions & 2 deletions network/src/tests/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use polkadot_primitives::parachain::{
FeeSchedule, HeadData, Retriable, CollatorId
};
use parking_lot::Mutex;
use substrate_client::error::Result as ClientResult;
use sp_blockchain::Result as ClientResult;
use sr_api::{Core, RuntimeVersion, StorageProof, ApiExt};
use sr_primitives::traits::{ApiRef, ProvideRuntimeApi};

Expand Down Expand Up @@ -231,7 +231,7 @@ impl Core<Block> for RuntimeApi {
}

impl ApiExt<Block> for RuntimeApi {
type Error = substrate_client::error::Error;
type Error = sp_blockchain::Error;

fn map_api_result<F: FnOnce(&Self) -> Result<R, E>, R, E>(
&self,
Expand Down
2 changes: 1 addition & 1 deletion network/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<P, E, N, T> ValidationNetwork<P, E, N, T> where N: NetworkService {
/// A long-lived network which can create parachain statement routing processes on demand.
impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
P: ProvideRuntimeApi + Send + Sync + 'static,
P::Api: ParachainHost<Block, Error = substrate_client::error::Error>,
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
E: Clone + Future<Item=(),Error=()> + Send + Sync + 'static,
N: NetworkService,
T: Clone + Executor + Send + Sync + 'static,
Expand Down
4 changes: 2 additions & 2 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jsonrpc-core = "14.0.3"
polkadot-primitives = { path = "../primitives" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "sc-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
frame-system-rpc = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool-api = { package = "sp-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
polkadot-runtime = { path = "../runtime" }

37 changes: 31 additions & 6 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,55 @@ use std::sync::Arc;

use polkadot_primitives::{Block, AccountId, Nonce, Balance};
use sr_primitives::traits::ProvideRuntimeApi;
use transaction_pool::txpool::{ChainApi, Pool};
use txpool_api::TransactionPool;
use polkadot_runtime::UncheckedExtrinsic;

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpc_core::IoHandler<substrate_rpc::Metadata>;

/// Instantiate all RPC extensions.
pub fn create<C, P>(client: Arc<C>, pool: Arc<Pool<P>>) -> RpcExtension where
pub fn create_full<C, P>(client: Arc<C>, pool: Arc<P>) -> RpcExtension where
C: ProvideRuntimeApi,
C: client::blockchain::HeaderBackend<Block>,
C: Send + Sync + 'static,
C::Api: frame_system_rpc::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
P: ChainApi + Sync + Send + 'static,
P: TransactionPool + Sync + Send + 'static,
{
use frame_system_rpc::{System, SystemApi};
use frame_rpc_system::{FullSystem, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
SystemApi::to_delegate(System::new(client.clone(), pool))
SystemApi::to_delegate(FullSystem::new(client.clone(), pool))
);
io.extend_with(
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
);
io
}

/// Instantiate all RPC extensions for light node.
pub fn create_light<C, P, F>(
client: Arc<C>,
remote_blockchain: Arc<dyn client::light::blockchain::RemoteBlockchain<Block>>,
fetcher: Arc<F>,
pool: Arc<P>,
) -> RpcExtension
where
C: ProvideRuntimeApi,
C: client::blockchain::HeaderBackend<Block>,
C: Send + Sync + 'static,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
P: TransactionPool + Sync + Send + 'static,
F: client::light::fetcher::Fetcher<Block> + 'static,
{
use frame_rpc_system::{LightSystem, SystemApi};

let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
SystemApi::<AccountId, Nonce>::to_delegate(LightSystem::new(client, remote_blockchain, fetcher, pool))
);
io
}
3 changes: 2 additions & 1 deletion service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git =
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "sc-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool = { package = "sc-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool-api = { package = "sp-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand Down
39 changes: 27 additions & 12 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use polkadot_primitives::{parachain, Hash, BlockId};
use polkadot_runtime::GenesisConfig;
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
use transaction_pool::txpool::{Pool as TransactionPool};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use inherents::InherentDataProviders;
use log::info;
Expand Down Expand Up @@ -67,7 +66,7 @@ impl Default for CustomConfiguration {
}

/// Chain API type for the transaction pool.
pub type TxChainApi<Backend, Executor> = transaction_pool::FullChainApi<
pub type TxChainApi<Backend, Executor> = txpool::FullChainApi<
client::Client<Backend, Executor, Block, RuntimeApi>,
Block,
>;
Expand All @@ -86,9 +85,13 @@ macro_rules! new_full_start {
.with_select_chain(|_, backend| {
Ok(client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = txpool::FullChainApi::new(client.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue(|_config, client, mut select_chain, _| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
Expand Down Expand Up @@ -118,8 +121,9 @@ macro_rules! new_full_start {
import_setup = Some((block_import, grandpa_link, babe_link));
Ok(import_queue)
})?
.with_rpc_extensions(|client, pool, _backend| -> polkadot_rpc::RpcExtension {
polkadot_rpc::create(client, pool)
.with_rpc_extensions(|client, pool, _backend, _fetcher, _remote_blockchain|
-> Result<polkadot_rpc::RpcExtension, _> {
Ok(polkadot_rpc::create_full(client, pool))
})?;

(builder, import_setup, inherent_data_providers)
Expand Down Expand Up @@ -337,9 +341,15 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
.with_select_chain(|_, backend| {
Ok(LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(TransactionPool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_transaction_pool(|config, client, fetcher| {
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _| {
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
Expand Down Expand Up @@ -376,8 +386,13 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
.with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)?
.with_rpc_extensions(|client, pool, _backend| -> polkadot_rpc::RpcExtension {
polkadot_rpc::create(client, pool)
.with_rpc_extensions(|client, pool, _backend, fetcher, remote_blockchain|
-> Result<polkadot_rpc::RpcExtension, _> {
let fetcher = fetcher
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
let remote_blockchain = remote_blockchain
.ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
Ok(polkadot_rpc::create_light(client, remote_blockchain, fetcher, pool))
})?
.build()
}
5 changes: 3 additions & 2 deletions validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/pa
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "sc-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool-api = { package = "sp-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
block-builder = { package = "substrate-block-builder", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down
Loading

0 comments on commit 4796fc5

Please sign in to comment.