Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
323 changes: 195 additions & 128 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ substrate-client = { git = "https://github.com/paritytech/substrate", branch = "

[dev-dependencies]
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
2 changes: 1 addition & 1 deletion network/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<F, P> ChainContext for (F, P) where
F: Fn(&Hash) -> Option<Known> + Send + Sync,
P: Send + Sync + std::ops::Deref,
P::Target: ProvideRuntimeApi,
<P::Target as ProvideRuntimeApi>::Api: ParachainHost<Block>,
<P::Target as ProvideRuntimeApi>::Api: ParachainHost<Block, Error = ClientError>,
{
fn is_known(&self, block_hash: &Hash) -> Option<Known> {
(self.0)(block_hash)
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>,
P::Api: ParachainHost<Block, Error = substrate_client::error::Error>,
N: NetworkService,
T: Clone + Executor + Send + 'static,
E: Future<Item=(),Error=()> + Clone + Send + 'static,
Expand Down
4 changes: 3 additions & 1 deletion network/src/tests/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use polkadot_primitives::parachain::{
};
use parking_lot::Mutex;
use substrate_client::error::Result as ClientResult;
use substrate_client::runtime_api::{Core, RuntimeVersion, StorageProof, ApiExt};
use sr_api::{Core, RuntimeVersion, StorageProof, ApiExt};
use sr_primitives::traits::{ApiRef, ProvideRuntimeApi};

use std::collections::HashMap;
Expand Down Expand Up @@ -231,6 +231,8 @@ impl Core<Block> for RuntimeApi {
}

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

fn map_api_result<F: FnOnce(&Self) -> Result<R, E>, R, E>(
&self,
_: F
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>,
P::Api: ParachainHost<Block, Error = substrate_client::error::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 primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ serde = { version = "1.0", optional = true, features = ["derive"] }
parity-scale-codec = { version = "1.0.5", default-features = false, features = ["bit-vec", "derive"] }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
application-crypto = { package = "substrate-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand All @@ -26,7 +26,7 @@ default = ["std"]
std = [
"parity-scale-codec/std",
"primitives/std",
"substrate-client/std",
"sr-api/std",
"rstd/std",
"sr-version/std",
"runtime_primitives/std",
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ pub struct Status {
pub fee_schedule: FeeSchedule,
}

substrate_client::decl_runtime_apis! {
sr_api::decl_runtime_apis! {
/// The API for querying the state of parachains on-chain.
pub trait ParachainHost {
/// Get the current validators.
Expand Down
8 changes: 6 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ serde_derive = { version = "1.0", optional = true }

authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offchain-primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand All @@ -27,6 +27,8 @@ substrate-primitives = { git = "https://github.com/paritytech/substrate", defaul
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
tx-pool-api = { package = "substrate-transaction-pool-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
block-builder-api = { package = "substrate-block-builder-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }

authority-discovery = { package = "srml-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand Down Expand Up @@ -85,7 +87,9 @@ std = [
"inherents/std",
"substrate-primitives/std",
"polkadot-parachain/std",
"client/std",
"sr-api/std",
"tx-pool-api/std",
"block-builder-api/std",
"offchain-primitives/std",
"rstd/std",
"sr-io/std",
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/attestations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as Pa
use sr_primitives::RuntimeDebug;
use sr_staking_primitives::SessionIndex;

use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifier};
use system::ensure_none;

/// Parachain blocks included in a recent relay-chain block.
Expand Down Expand Up @@ -178,7 +178,7 @@ pub type InherentType = MoreAttestations;

impl<T: Trait> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = MakeFatalError<RuntimeString>;
type Error = MakeFatalError<inherents::Error>;
const INHERENT_IDENTIFIER: InherentIdentifier = MORE_ATTESTATIONS_IDENTIFIER;

fn create_inherent(data: &InherentData) -> Option<Self::Call> {
Expand Down
19 changes: 9 additions & 10 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas}, ValidityError,
};
use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api, impl_runtime_apis,
};
use sr_primitives::{
create_runtime_str, generic, impl_opaque_keys,
ApplyResult, Permill, Perbill, RuntimeDebug,
Expand Down Expand Up @@ -625,8 +621,8 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;

impl_runtime_apis! {
impl client_api::Core<Block> for Runtime {
sr_api::impl_runtime_apis! {
impl sr_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
Expand All @@ -640,7 +636,7 @@ impl_runtime_apis! {
}
}

impl client_api::Metadata<Block> for Runtime {
impl sr_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
}
Expand All @@ -655,11 +651,14 @@ impl_runtime_apis! {
Executive::finalize_block()
}

fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
fn inherent_extrinsics(data: inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
data.create_extrinsics()
}

fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
fn check_inherents(
block: Block,
data: inherents::InherentData,
) -> inherents::CheckInherentsResult {
data.check_extrinsics(&block)
}

Expand All @@ -668,7 +667,7 @@ impl_runtime_apis! {
}
}

impl client_api::TaggedTransactionQueue<Block> for Runtime {
impl tx_pool_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use srml_support::{
traits::{Currency, Get, WithdrawReason, ExistenceRequirement, Randomness},
};

use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
use inherents::{ProvideInherent, InherentData, MakeFatalError, InherentIdentifier};

use system::ensure_none;
use crate::attestations::{self, IncludedBlocks};
Expand Down Expand Up @@ -874,7 +874,7 @@ pub type InherentType = Vec<AttestedCandidate>;

impl<T: Trait> ProvideInherent for Module<T> {
type Call = Call<T>;
type Error = MakeFatalError<RuntimeString>;
type Error = MakeFatalError<inherents::Error>;
const INHERENT_IDENTIFIER: InherentIdentifier = NEW_HEADS_IDENTIFIER;

fn create_inherent(data: &InherentData) -> Option<Self::Call> {
Expand Down
1 change: 1 addition & 0 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ polkadot-executor = { path = "../executor" }
polkadot-network = { path = "../network" }
polkadot-rpc = { path = "../rpc" }
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down
3 changes: 2 additions & 1 deletion service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use log::info;
pub use service::{AbstractService, Roles, PruningMode, TransactionPoolOptions, Error};
pub use service::{ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert};
pub use service::config::{DatabaseConfig, full_version_from_strs};
pub use client::{backend::Backend, runtime_api::{Core as CoreApi, ConstructRuntimeApi}, ExecutionStrategy, CallExecutor};
pub use client::{backend::Backend, ExecutionStrategy, CallExecutor};
pub use sr_api::{Core as CoreApi, ConstructRuntimeApi};
pub use consensus_common::SelectChain;
pub use polkadot_network::{PolkadotProtocol};
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
Expand Down
2 changes: 2 additions & 0 deletions validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ consensus = { package = "substrate-consensus-common", git = "https://github.com/
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
block-builder = { package = "substrate-block-builder", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
bitvec = { version = "0.14.0", default-features = false, features = ["alloc"] }
Expand Down
8 changes: 6 additions & 2 deletions validation/src/attestation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use std::{thread, time::{Duration, Instant}, sync::Arc};

use client::{error::Result as ClientResult, BlockchainEvents, BlockBody};
use client::block_builder::api::BlockBuilder;
use block_builder::BlockBuilderApi;
use client::blockchain::HeaderBackend;
use consensus::SelectChain;
use availability_store::Store as AvailabilityStore;
Expand All @@ -38,6 +38,7 @@ use polkadot_primitives::parachain::{CandidateReceipt, ParachainHost};
use runtime_primitives::traits::{ProvideRuntimeApi};
use babe_primitives::BabeApi;
use keystore::KeyStorePtr;
use sr_api::ApiExt;

use tokio::{timer::Interval, runtime::current_thread::Runtime as LocalRuntime};
use log::{warn, debug};
Expand Down Expand Up @@ -123,7 +124,10 @@ pub(crate) fn start<C, N, P, SC>(
<C::Collation as IntoFuture>::Future: Send + 'static,
P: BlockchainEvents<Block> + BlockBody<Block>,
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + BlockBuilder<Block> + BabeApi<Block>,
P::Api: ParachainHost<Block> +
BlockBuilderApi<Block> +
BabeApi<Block> +
ApiExt<Block, Error = client::error::Error>,
N: Network + Send + Sync + 'static,
N::TableRouter: Send + 'static,
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
Expand Down
11 changes: 8 additions & 3 deletions validation/src/collation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<C: Collators, P> CollationFetch<C, P> {
}

impl<C: Collators, P: ProvideRuntimeApi> Future for CollationFetch<C, P>
where P::Api: ParachainHost<Block>,
where P::Api: ParachainHost<Block, Error = client::error::Error>,
{
type Item = (Collation, OutgoingMessages);
type Error = C::Error;
Expand All @@ -115,7 +115,12 @@ impl<C: Collators, P: ProvideRuntimeApi> Future for CollationFetch<C, P>
futures::try_ready!(poll)
};

let res = validate_collation(&*self.client, &self.relay_parent, &collation, self.max_block_data_size);
let res = validate_collation(
&*self.client,
&self.relay_parent,
&collation,
self.max_block_data_size,
);

match res {
Ok(e) => {
Expand Down Expand Up @@ -388,7 +393,7 @@ pub fn validate_collation<P>(
max_block_data_size: Option<u64>,
) -> Result<OutgoingMessages, Error> where
P: ProvideRuntimeApi,
P::Api: ParachainHost<Block>,
P::Api: ParachainHost<Block, Error = client::error::Error>,
{
use parachain::{IncomingMessage, ValidationParams};

Expand Down
3 changes: 1 addition & 2 deletions validation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

//! Errors that can occur during the validation process.

use runtime_primitives::RuntimeString;
use polkadot_primitives::parachain::ValidatorId;

/// Error type for validation
Expand All @@ -38,7 +37,7 @@ pub enum Error {
NotValidator(ValidatorId),
/// Unexpected error checking inherents
#[display(fmt = "Unexpected error while checking inherents: {}", _0)]
InherentError(RuntimeString),
InherentError(inherents::Error),
/// Proposer destroyed before finishing proposing or evaluating
#[display(fmt = "Proposer destroyed before finishing proposing or evaluating")]
PrematureDestruction,
Expand Down
Loading