From 00d2b4bf3ea252791bf532d4e0fd33de41a59fc2 Mon Sep 17 00:00:00 2001 From: Sergei Shulepov Date: Thu, 14 Jan 2021 20:58:44 +0100 Subject: [PATCH] Remove polkadot-validation crate (#2271) --- polkadot/Cargo.lock | 28 ---- polkadot/Cargo.toml | 1 - polkadot/validation/Cargo.toml | 31 ----- polkadot/validation/README.adoc | 5 - polkadot/validation/src/block_production.rs | 146 -------------------- polkadot/validation/src/error.rs | 40 ------ polkadot/validation/src/lib.rs | 38 ----- 7 files changed, 289 deletions(-) delete mode 100644 polkadot/validation/Cargo.toml delete mode 100644 polkadot/validation/README.adoc delete mode 100644 polkadot/validation/src/block_production.rs delete mode 100644 polkadot/validation/src/error.rs delete mode 100644 polkadot/validation/src/lib.rs diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index 83cdd0272b..3be3cf423f 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -5884,34 +5884,6 @@ dependencies = [ "tracing-futures", ] -[[package]] -name = "polkadot-validation" -version = "0.8.27" -dependencies = [ - "futures 0.3.10", - "log", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "sc-basic-authorship", - "sc-block-builder", - "sc-client-api", - "sc-finality-grandpa", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-timestamp", - "sp-transaction-pool", - "sp-trie", - "substrate-prometheus-endpoint", - "thiserror", -] - [[package]] name = "polling" version = "2.0.2" diff --git a/polkadot/Cargo.toml b/polkadot/Cargo.toml index a69f8afab4..2d771ceeb4 100644 --- a/polkadot/Cargo.toml +++ b/polkadot/Cargo.toml @@ -38,7 +38,6 @@ members = [ "runtime/westend", "runtime/test-runtime", "statement-table", - "validation", "xcm", "xcm/xcm-builder", "xcm/xcm-executor", diff --git a/polkadot/validation/Cargo.toml b/polkadot/validation/Cargo.toml deleted file mode 100644 index 10bd546202..0000000000 --- a/polkadot/validation/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "polkadot-validation" -version = "0.8.27" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -polkadot-primitives = { path = "../primitives" } -parachain = { package = "polkadot-parachain", path = "../parachain" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } -sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } -consensus = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "master" } -runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master" } -futures = "0.3.8" -log = "0.4.13" -parity-scale-codec = { version = "1.3.6", default-features = false, features = ["derive"] } -grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master" } -primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master" } -txpool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "master" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } -block-builder = { package = "sc-block-builder", git = "https://github.com/paritytech/substrate", branch = "master" } -trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "master" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" } -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" } -thiserror = "1.0.23" - -[dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot/validation/README.adoc b/polkadot/validation/README.adoc deleted file mode 100644 index 1723bf2ae2..0000000000 --- a/polkadot/validation/README.adoc +++ /dev/null @@ -1,5 +0,0 @@ - -= Polkadot Validation - -placeholder -//TODO Write content :) (https://github.com/paritytech/polkadot/issues/159) diff --git a/polkadot/validation/src/block_production.rs b/polkadot/validation/src/block_production.rs deleted file mode 100644 index 517d8ced81..0000000000 --- a/polkadot/validation/src/block_production.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2020 Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Polkadot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Polkadot. If not, see . - -//! The block production pipeline of Polkadot. -//! -//! The `ProposerFactory` exported by this module will be wrapped by some -//! consensus engine, and triggered when it is time to create a block. - -use std::{ - pin::Pin, - sync::Arc, - time::Duration, -}; - -use sp_blockchain::HeaderBackend; -use block_builder::{BlockBuilderApi, BlockBuilderProvider}; -use consensus::{Proposal, RecordProof}; -use primitives::traits::SpawnNamed; -use polkadot_primitives::v0::{NEW_HEADS_IDENTIFIER, Block, Header, AttestedCandidate}; -use runtime_primitives::traits::{DigestFor, HashFor}; -use txpool_api::TransactionPool; - -use futures::prelude::*; -use inherents::InherentData; -use sp_api::{ApiExt, ProvideRuntimeApi}; -use prometheus_endpoint::Registry as PrometheusRegistry; - -use crate::Error; - -// Polkadot proposer factory. -pub struct ProposerFactory { - factory: sc_basic_authorship::ProposerFactory, -} - -impl ProposerFactory { - /// Create a new proposer factory. - pub fn new( - spawn_handle: Box, - client: Arc, - transaction_pool: Arc, - prometheus: Option<&PrometheusRegistry>, - ) -> Self { - let factory = sc_basic_authorship::ProposerFactory::new( - spawn_handle, - client, - transaction_pool, - prometheus, - ); - ProposerFactory { - factory, - } - } -} - -impl consensus::Environment - for ProposerFactory -where - TxPool: TransactionPool + 'static, - Client: BlockBuilderProvider + ProvideRuntimeApi + HeaderBackend + Send + Sync + 'static, - Client::Api: BlockBuilderApi - + ApiExt, - Backend: sc_client_api::Backend< - Block, - State = sp_api::StateBackendFor - > + 'static, - // Rust bug: https://github.com/rust-lang/rust/issues/24159 - sp_api::StateBackendFor: sp_api::StateBackend> + Send, -{ - type CreateProposer = Pin> + Send + 'static - >>; - type Proposer = Proposer; - type Error = Error; - - fn init( - &mut self, - parent_header: &Header, - ) -> Self::CreateProposer { - let proposer = self.factory.init(parent_header) - .into_inner() - .map_err(Into::into) - .map(|proposer| Proposer { proposer }); - - Box::pin(future::ready(proposer)) - } -} - -/// The Polkadot proposer logic. -pub struct Proposer, Backend> { - proposer: sc_basic_authorship::Proposer, -} - -impl consensus::Proposer for Proposer where - TxPool: TransactionPool + 'static, - Client: BlockBuilderProvider + ProvideRuntimeApi + HeaderBackend + Send + Sync + 'static, - Client::Api: BlockBuilderApi + ApiExt, - Backend: sc_client_api::Backend> + 'static, - // Rust bug: https://github.com/rust-lang/rust/issues/24159 - sp_api::StateBackendFor: sp_api::StateBackend> + Send, -{ - type Error = Error; - type Transaction = sp_api::TransactionFor; - type Proposal = Pin< - Box< - dyn Future>, - Self::Error, - >> - + Send - > - >; - - fn propose( - self, - inherent_data: InherentData, - inherent_digests: DigestFor, - max_duration: Duration, - record_proof: RecordProof, - ) -> Self::Proposal { - async move { - let mut inherent_data = inherent_data; - inherent_data.put_data(NEW_HEADS_IDENTIFIER, &Vec::::new()) - .map_err(Error::InherentError)?; - - self.proposer.propose( - inherent_data, - inherent_digests.clone(), - max_duration, - record_proof - ).await.map_err(Into::into) - }.boxed() - } -} diff --git a/polkadot/validation/src/error.rs b/polkadot/validation/src/error.rs deleted file mode 100644 index 0665a70f33..0000000000 --- a/polkadot/validation/src/error.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Polkadot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Polkadot. If not, see . - -//! Errors that can occur during the validation process. - -use thiserror::Error; - -/// Error type for validation -#[derive(Debug, Error)] -pub enum Error { - /// Client error - #[error(transparent)] - Client(#[from] sp_blockchain::Error), - /// Consensus error - #[error(transparent)] - Consensus(#[from] consensus::error::Error), - /// Unexpected error checking inherents - #[error("Unexpected error while checking inherents: {0}")] - InherentError(inherents::Error), -} - - -impl std::convert::From for Error { - fn from(inner: inherents::Error) -> Self { - Self::InherentError(inner) - } -} diff --git a/polkadot/validation/src/lib.rs b/polkadot/validation/src/lib.rs deleted file mode 100644 index ff86cdd11d..0000000000 --- a/polkadot/validation/src/lib.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017-2020 Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Polkadot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Polkadot. If not, see . - -//! Propagation and agreement of candidates. -//! -//! Authorities are split into groups by parachain, and each authority might come -//! up its own candidate for their parachain. Within groups, authorities pass around -//! their candidates and produce statements of validity. -//! -//! Any candidate that receives majority approval by the authorities in a group -//! may be subject to inclusion, unless any authorities flag that candidate as invalid. -//! -//! Wrongly flagging as invalid should be strongly disincentivized, so that in the -//! equilibrium state it is not expected to happen. Likewise with the submission -//! of invalid blocks. -//! -//! Groups themselves may be compromised by malicious authorities. - -pub use self::block_production::ProposerFactory; -pub use self::error::Error; -pub use parachain::wasm_executor::run_worker as run_validation_worker; - -mod error; - -pub mod block_production;