diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 1e242a9aeb..8b488369a1 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -1088,7 +1088,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jsonrpc-core" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)", @@ -1113,7 +1113,7 @@ dependencies = [ [[package]] name = "jsonrpc-macros" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)", "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)", @@ -1123,7 +1123,7 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1133,7 +1133,7 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1149,7 +1149,7 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git#0227e70fdce25cad9c71be222dc9e7f754c08033" +source = "git+https://github.com/paritytech/jsonrpc.git#24b9befa3389d9aa64b49b2573d1250143f17743" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git)", @@ -2358,7 +2358,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2379,7 +2379,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2416,7 +2416,7 @@ name = "rand_xorshift" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4363,7 +4363,7 @@ name = "twox-hash" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/substrate/core/basic-authorship/src/basic_authorship.rs b/substrate/core/basic-authorship/src/basic_authorship.rs index 0464d96dc4..d4d39c4541 100644 --- a/substrate/core/basic-authorship/src/basic_authorship.rs +++ b/substrate/core/basic-authorship/src/basic_authorship.rs @@ -26,7 +26,7 @@ use client::{self, error, Client as SubstrateClient, CallExecutor}; use client::{block_builder::api::BlockBuilder as BlockBuilderApi, runtime_api::Core}; use codec::{Decode, Encode}; use consensus_common::{self, evaluation}; -use primitives::{H256, Ed25519AuthorityId, ed25519, Blake2Hasher}; +use primitives::{H256, Blake2Hasher}; use runtime_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, AuthorityIdFor}; use runtime_primitives::generic::BlockId; use runtime_primitives::BasicInherentData; diff --git a/substrate/core/rpc-servers/src/lib.rs b/substrate/core/rpc-servers/src/lib.rs index ec823b15fd..bef0d4a368 100644 --- a/substrate/core/rpc-servers/src/lib.rs +++ b/substrate/core/rpc-servers/src/lib.rs @@ -49,9 +49,8 @@ pub fn rpc_handler( ) -> RpcHandler where Block: BlockT + 'static, ExHash: Send + Sync + 'static + sr_primitives::Serialize + sr_primitives::DeserializeOwned, - SignedBlock: serde::Serialize + sr_primitives::DeserializeOwned, S: apis::state::StateApi, - C: apis::chain::ChainApi, SignedBlock, Metadata=Metadata>, + C: apis::chain::ChainApi, Block::Hash, Block::Header, SignedBlock, Metadata=Metadata>, A: apis::author::AuthorApi, Y: apis::system::SystemApi, { diff --git a/substrate/core/rpc/src/chain/mod.rs b/substrate/core/rpc/src/chain/mod.rs index 3f57bfe6fc..7675f42e22 100644 --- a/substrate/core/rpc/src/chain/mod.rs +++ b/substrate/core/rpc/src/chain/mod.rs @@ -26,6 +26,7 @@ use rpc::Result as RpcResult; use rpc::futures::{stream, Future, Sink, Stream}; use runtime_primitives::generic::{BlockId, SignedBlock}; use runtime_primitives::traits::{Block as BlockT, Header, NumberFor}; +use serde::Serialize; use subscriptions::Subscriptions; @@ -37,7 +38,10 @@ use self::error::Result; build_rpc_trait! { /// Substrate blockchain API - pub trait ChainApi { + pub trait ChainApi where + Header: Serialize, + SignedBlock: Serialize, + { type Metadata; /// Get header of a relay chain block. @@ -148,7 +152,7 @@ impl Chain where } } -impl ChainApi, SignedBlock> for Chain where +impl ChainApi, Block::Hash, Block::Header, SignedBlock> for Chain where Block: BlockT + 'static, B: client::backend::Backend + Send + Sync + 'static, E: client::CallExecutor + Send + Sync + 'static, diff --git a/substrate/core/rpc/src/lib.rs b/substrate/core/rpc/src/lib.rs index 2e7d4b1fa8..90caaaf291 100644 --- a/substrate/core/rpc/src/lib.rs +++ b/substrate/core/rpc/src/lib.rs @@ -22,6 +22,7 @@ extern crate jsonrpc_core as rpc; extern crate jsonrpc_pubsub; extern crate parity_codec as codec; extern crate parking_lot; +extern crate serde; extern crate serde_json; extern crate sr_primitives as runtime_primitives; extern crate sr_version as runtime_version; diff --git a/substrate/core/service/src/components.rs b/substrate/core/service/src/components.rs index 29b6768374..397e3d7a89 100644 --- a/substrate/core/service/src/components.rs +++ b/substrate/core/service/src/components.rs @@ -27,7 +27,7 @@ use consensus_common::import_queue::ImportQueue; use network::{self, OnDemand}; use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use transaction_pool::txpool::{self, Options as TransactionPoolOptions, Pool as TransactionPool}; -use runtime_primitives::{BuildStorage, traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}, generic::{BlockId, SignedBlock}}; +use runtime_primitives::{BuildStorage, traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}, generic::BlockId}; use config::Configuration; use primitives::{Blake2Hasher, H256}; use rpc::{self, apis::system::SystemInfo}; @@ -136,7 +136,6 @@ pub trait StartRPC { impl StartRPC for C where C::RuntimeApi: Metadata>, - for<'de> SignedBlock>: ::serde::Deserialize<'de>, { type ServersHandle = (Option, Option>); diff --git a/substrate/core/sr-primitives/src/generic/block.rs b/substrate/core/sr-primitives/src/generic/block.rs index df9f656513..390bd22af5 100644 --- a/substrate/core/sr-primitives/src/generic/block.rs +++ b/substrate/core/sr-primitives/src/generic/block.rs @@ -19,10 +19,6 @@ #[cfg(feature = "std")] use std::fmt; -#[cfg(feature = "std")] -use serde::{Deserialize, Deserializer}; -#[cfg(feature = "std")] -use codec::Decode; use rstd::prelude::*; use codec::Codec; use traits::{self, Member, Block as BlockT, Header as HeaderT, MaybeSerialize}; @@ -73,17 +69,6 @@ pub struct Block { pub extrinsics: Vec, } -// TODO: Remove Deserialize for Block once RPC no longer needs it #1098 -#[cfg(feature = "std")] -impl<'a, Header: 'a, Extrinsic: 'a + MaybeSerialize> Deserialize<'a> for Block where - Block: Decode, -{ - fn deserialize>(de: D) -> Result { - let r = >::deserialize(de)?; - Decode::decode(&mut &r[..]).ok_or(::serde::de::Error::custom("Invalid value passed into decode")) - } -} - impl traits::Block for Block where Header: HeaderT, @@ -118,16 +103,3 @@ pub struct SignedBlock { /// Block justification. pub justification: Option, } - -// TODO: Remove Deserialize for SignedBlock once RPC no longer needs it #1098 -#[cfg(feature = "std")] -impl<'a, Block: BlockT,> Deserialize<'a> for SignedBlock where - Block::Header: 'a, - Block::Extrinsic: 'a + Codec + MaybeSerialize, - SignedBlock: Decode, -{ - fn deserialize>(de: D) -> Result { - let r = >::deserialize(de)?; - Decode::decode(&mut &r[..]).ok_or(::serde::de::Error::custom("Invalid value passed into decode")) - } -} diff --git a/substrate/core/sr-primitives/src/generic/header.rs b/substrate/core/sr-primitives/src/generic/header.rs index ec70d5d66b..3fed9e600d 100644 --- a/substrate/core/sr-primitives/src/generic/header.rs +++ b/substrate/core/sr-primitives/src/generic/header.rs @@ -16,9 +16,6 @@ //! Generic implementation of a block header. -#[cfg(feature = "std")] -use serde::{Deserialize, Deserializer}; - use codec::{Decode, Encode, Codec, Input, Output, HasCompact}; use traits::{self, Member, SimpleArithmetic, SimpleBitOps, MaybeDisplay, Hash as HashT, DigestItem as DigestItemT, MaybeSerializeDebug, MaybeSerializeDebugButNotDeserialize}; @@ -42,17 +39,6 @@ pub struct Header { pub digest: Digest, } -// TODO: Remove Deserialize for Header once RPC no longer needs it #1098 -#[cfg(feature = "std")] -impl<'a, Number: 'a, Hash: 'a + HashT, DigestItem: 'a> Deserialize<'a> for Header where - Header: Decode, -{ - fn deserialize>(de: D) -> Result { - let r = >::deserialize(de)?; - Decode::decode(&mut &r[..]).ok_or(::serde::de::Error::custom("Invalid value passed into decode")) - } -} - impl Decode for Header where Number: HasCompact, Hash: HashT, diff --git a/substrate/core/sr-primitives/src/traits.rs b/substrate/core/sr-primitives/src/traits.rs index 0354953bfb..67e441c792 100644 --- a/substrate/core/sr-primitives/src/traits.rs +++ b/substrate/core/sr-primitives/src/traits.rs @@ -441,7 +441,7 @@ impl Mem /// `parent_hash`, as well as a `digest` and a block `number`. /// /// You can also create a `new` one from those fields. -pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebug + 'static { +pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDeserialize + 'static { type Number: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec; type Hash: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>; type Hashing: Hash; @@ -481,7 +481,7 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebug + 'stat /// `Extrinsic` piece of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. -pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebug + 'static { +pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerializeDebugButNotDeserialize + 'static { type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; type Header: Header; type Hash: Member + MaybeSerializeDebug + ::rstd::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>;