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

Commit 1f576dd

Browse files
andresilvagavofyork
authored andcommitted
Backports to v0.6 (#493)
* Fix compilation in wasm (#465) Also fix the weird file structure by making `wasm_executor.rs` -> `wasm_executor/mod.rs`. * Changes for substrate#3699 (#466) * change upstream and branch * Fix build * remove doc renamings * Fix tests * . * Revert changing fork and branch * Update Cargo.toml * Update parachains.rs * wasm_executor: fix wasm signature checker (#471) Signed-off-by: yjhmelody <[email protected]> * Update to latest Substrate master (#472) * Update to latest Substrate master * Fix * Fix compilation * fix var name for post_upward_message (#474) Signed-off-by: yjhmelody <[email protected]> * integrate minor weight/fee changes (#482) * Update cargo files * Make it build again. * Fix build * revert cargo file * New lockfile * Bump. * Update to latest Substrate master (#486) * Only register one gossip validator for full nodes (#487) * Support `account_nextIndex` RPC. (#460) * Use node-rpc extensions to support account_nextIndex. * Remove todo. * Update lock. * Use new srml_system_rpc crate. * Update to substrate=master * Update lockfile. * Update to polkadot-master. * Apply suggestions from code review Co-Authored-By: Bastian Köcher <[email protected]> * Update to latest substrate master (#491) * update to latest substrate master * Fix compilation
1 parent 72969c3 commit 1f576dd

File tree

23 files changed

+865
-663
lines changed

23 files changed

+865
-663
lines changed

Cargo.lock

Lines changed: 617 additions & 482 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ log = "0.4.6"
1010
tokio = "0.1.7"
1111
futures = "0.1.17"
1212
exit-future = "0.1"
13-
structopt = "0.2"
13+
structopt = "0.3.3"
1414
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
1515
service = { package = "polkadot-service", path = "../service" }

cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub trait Worker: IntoExit {
7272

7373
#[derive(Debug, StructOpt, Clone)]
7474
enum PolkadotSubCommands {
75-
#[structopt(name = "validation-worker", raw(setting = "structopt::clap::AppSettings::Hidden"))]
75+
#[structopt(name = "validation-worker", setting = structopt::clap::AppSettings::Hidden)]
7676
ValidationWorker(ValidationWorkerCommand),
7777
}
7878

network/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ substrate-network = { git = "https://github.com/paritytech/substrate", branch =
1616
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
1717
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
1818
futures = "0.1"
19+
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
1920
log = "0.4"
2021
exit-future = "0.1.4"
2122
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }

network/src/gossip.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,6 @@ impl NewLeafActions {
342342
}
343343
}
344344

345-
/// Register a gossip validator for a non-authority node.
346-
pub fn register_non_authority_validator(service: Arc<PolkadotNetworkService>) {
347-
service.with_gossip(|gossip, ctx|
348-
gossip.register_validator(
349-
ctx,
350-
POLKADOT_ENGINE_ID,
351-
Arc::new(substrate_network::consensus_gossip::DiscardAll)),
352-
);
353-
}
354-
355345
/// A registered message validator.
356346
///
357347
/// Create this using `register_validator`.

network/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ pub mod validation;
2626
pub mod gossip;
2727

2828
use codec::{Decode, Encode};
29-
use futures::sync::{oneshot, mpsc};
29+
use futures::sync::oneshot;
3030
use futures::prelude::*;
31+
use futures03::{channel::mpsc, compat::Compat, StreamExt};
3132
use polkadot_primitives::{Block, Hash, Header};
3233
use polkadot_primitives::parachain::{
3334
Id as ParaId, BlockData, CollatorId, CandidateReceipt, Collation, PoVBlock,
@@ -108,7 +109,7 @@ impl NetworkService for PolkadotNetworkService {
108109
Err(_) => mpsc::unbounded().1, // return empty channel.
109110
};
110111

111-
GossipMessageStream::new(topic_stream)
112+
GossipMessageStream::new(Box::new(Compat::new(topic_stream.map(Ok))))
112113
}
113114

114115
fn gossip_message(&self, topic: Hash, message: GossipMessage) {
@@ -151,14 +152,14 @@ impl GossipService for consensus_gossip::ConsensusGossip<Block> {
151152

152153
/// A stream of gossip messages and an optional sender for a topic.
153154
pub struct GossipMessageStream {
154-
topic_stream: mpsc::UnboundedReceiver<TopicNotification>,
155+
topic_stream: Box<dyn Stream<Item = TopicNotification, Error = ()> + Send>,
155156
}
156157

157158
impl GossipMessageStream {
158159
/// Create a new instance with the given topic stream.
159-
pub fn new(topic_stream: mpsc::UnboundedReceiver<TopicNotification>) -> Self {
160+
pub fn new(topic_stream: Box<dyn Stream<Item = TopicNotification, Error = ()> + Send>) -> Self {
160161
Self {
161-
topic_stream
162+
topic_stream,
162163
}
163164
}
164165
}

network/src/tests/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl NetworkService for TestNetwork {
148148
fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream {
149149
let (tx, rx) = mpsc::unbounded();
150150
let _ = self.gossip.send_listener.unbounded_send((topic, tx));
151-
GossipMessageStream::new(rx)
151+
GossipMessageStream::new(Box::new(rx))
152152
}
153153

154154
fn gossip_message(&self, topic: Hash, message: GossipMessage) {

parachain/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.5", default-features =
1010
wasmi = { version = "0.4.3", optional = true }
1111
derive_more = { version = "0.14", optional = true }
1212
serde = { version = "1.0", default-features = false, features = [ "derive" ] }
13+
substrate-primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
1314
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
1415
lazy_static = { version = "1.3.0", optional = true }
1516
parking_lot = { version = "0.7.1", optional = true }
@@ -31,6 +32,7 @@ std = [
3132
"wasmi",
3233
"derive_more",
3334
"serde/std",
35+
"substrate-primitives/std",
3436
"rstd/std",
3537
"shared_memory",
3638
"lazy_static",

parachain/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub mod wasm_api;
5454
use rstd::vec::Vec;
5555

5656
use codec::{Encode, Decode, CompactAs};
57+
use substrate_primitives::RuntimeDebug;
5758

5859
/// Validation parameters for evaluating the parachain validity function.
5960
// TODO: balance downloads (https://github.com/paritytech/polkadot/issues/220)
@@ -78,8 +79,11 @@ pub struct ValidationResult {
7879
}
7980

8081
/// Unique identifier of a parachain.
81-
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Default, Clone, Copy, CompactAs, Encode, Decode)]
82-
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize, Debug))]
82+
#[derive(
83+
Clone, CompactAs, Copy, Decode, Default, Encode, Eq,
84+
Hash, Ord, PartialEq, PartialOrd, RuntimeDebug
85+
)]
86+
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
8387
pub struct Id(u32);
8488

8589
impl From<Id> for u32 {

parachain/src/wasm_executor.rs renamed to parachain/src/wasm_executor/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ use super::{
3232
UpwardMessage, IncomingMessage};
3333

3434
#[cfg(not(target_os = "unknown"))]
35-
pub use validation_host::run_worker;
36-
pub use validation_host::EXECUTION_TIMEOUT_SEC;
35+
pub use validation_host::{run_worker, EXECUTION_TIMEOUT_SEC};
3736

3837
mod validation_host;
3938

@@ -46,7 +45,7 @@ mod ids {
4645
pub const POST_MESSAGE: usize = 1;
4746

4847
/// Post a message to this parachain's relay chain.
49-
pub const POST_UPWARDS_MESSAGE: usize = 2;
48+
pub const POST_UPWARD_MESSAGE: usize = 2;
5049
}
5150

5251
/// WASM code execution mode.
@@ -125,7 +124,7 @@ impl fmt::Display for ExternalitiesError {
125124
}
126125

127126
impl wasmi::HostError for ExternalitiesError {}
128-
impl ::std::error::Error for ExternalitiesError {}
127+
impl std::error::Error for ExternalitiesError {}
129128

130129
struct Resolver {
131130
max_memory: u32, // in pages.
@@ -144,7 +143,7 @@ impl ModuleImportResolver for Resolver {
144143
let (params, ret_ty): (&[ValueType], Option<ValueType>) =
145144
(&[ValueType::I32, ValueType::I32, ValueType::I32], None);
146145

147-
if signature.params() != params && signature.return_type() != ret_ty {
146+
if signature.params() != params || signature.return_type() != ret_ty {
148147
Err(WasmError::Instantiation(
149148
format!("Export {} has a bad signature", field_name)
150149
))
@@ -156,11 +155,11 @@ impl ModuleImportResolver for Resolver {
156155
}
157156
}
158157
"ext_upwards_post_message" => {
159-
let index = ids::POST_UPWARDS_MESSAGE;
158+
let index = ids::POST_UPWARD_MESSAGE;
160159
let (params, ret_ty): (&[ValueType], Option<ValueType>) =
161160
(&[ValueType::I32, ValueType::I32], None);
162161

163-
if signature.params() != params && signature.return_type() != ret_ty {
162+
if signature.params() != params || signature.return_type() != ret_ty {
164163
Err(WasmError::Instantiation(
165164
format!("Export {} has a bad signature", field_name)
166165
))
@@ -269,7 +268,7 @@ impl<'a, E: 'a + Externalities> Externals for ValidationExternals<'a, E> {
269268
) -> Result<Option<RuntimeValue>, Trap> {
270269
match index {
271270
ids::POST_MESSAGE => self.ext_post_message(args).map(|_| None),
272-
ids::POST_UPWARDS_MESSAGE => self.ext_post_upward_message(args).map(|_| None),
271+
ids::POST_UPWARD_MESSAGE => self.ext_post_upward_message(args).map(|_| None),
273272
_ => panic!("no externality at given index"),
274273
}
275274
}

0 commit comments

Comments
 (0)