Commit b31df3ec authored by Cecile Tonglet's avatar Cecile Tonglet
Browse files

Merge commit ecc5b41f (no conflict)

Parent branch: origin/master
Forked at: 5629242d
parents 89429096 ecc5b41f
Pipeline #98540 failed with stages
in 11 minutes and 6 seconds
name: Label PRs
on:
pull_request:
types: [opened,ready_for_review]
jobs:
label-new-prs:
runs-on: ubuntu-latest
steps:
- name: Label drafts
uses: andymckay/labeler@master
if: github.event.pull_request.draft == true
with:
add-labels: 'A3-inprogress'
remove-labels: 'A0-pleasereview'
- name: Label PRs
uses: andymckay/labeler@master
if: github.event.pull_request.draft == false && ! contains(github.event.pull_request.labels.*.name, 'A2-insubstantial')
with:
add-labels: 'A0-pleasereview'
remove-labels: 'A3-inprogress'
......@@ -16,8 +16,6 @@ image: paritytech/ci-linux:production
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
SCCACHE_DIR: "/ci-cache/${CI_PROJECT_NAME}/sccache"
CI_SERVER_NAME: "GitLab CI"
DOCKER_OS: "debian:stretch"
ARCH: "x86_64"
......@@ -157,9 +155,7 @@ build-wasm-release:
<<: *compiler_info
# Note: We likely only want to do this for tagged releases, hence the 'only:'
only:
# FIXME remove when ready to merge
- /^[0-9]+$/
# - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script:
- time wasm-pack build --target web --out-dir wasm --release cli -- --no-default-features --features browser
- mkdir -p ./artifacts/wasm
......@@ -192,6 +188,15 @@ build-linux-release: &build
- cp -r scripts/docker/* ./artifacts
- sccache -s
generate-impl-guide:
stage: build
image:
name: michaelfbryan/mdbook-docker-image:latest
entrypoint: [""]
script:
- mdbook build roadmap/implementors-guide
.publish-build: &publish-build
stage: publish
dependencies:
......@@ -285,4 +290,4 @@ check-labels:
only:
- /^[0-9]+$/
script:
- ./scripts/gitlab/check_tags.sh
- ./scripts/gitlab/check_labels.sh
This diff is collapsed.
......@@ -4,7 +4,7 @@ path = "src/main.rs"
[package]
name = "polkadot"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -44,6 +44,7 @@ members = [
"node/messages",
"node/overseer",
"node/primitives",
"node/service",
"parachain/test-parachains",
......
[package]
name = "polkadot-availability-store"
description = "Persistent database for parachain data"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-cli"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node"
edition = "2018"
......
......@@ -128,7 +128,6 @@ pub fn run() -> Result<()> {
authority_discovery_enabled,
6000,
grandpa_pause,
None,
).map(|(s, _, _)| s)
},
service::KusamaExecutor::native_version().runtime_version
......@@ -146,7 +145,6 @@ pub fn run() -> Result<()> {
authority_discovery_enabled,
6000,
grandpa_pause,
None,
).map(|(s, _, _)| s)
},
service::WestendExecutor::native_version().runtime_version
......@@ -164,7 +162,6 @@ pub fn run() -> Result<()> {
authority_discovery_enabled,
6000,
grandpa_pause,
None,
).map(|(s, _, _)| s)
},
service::PolkadotExecutor::native_version().runtime_version
......
[package]
name = "polkadot-collator"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation"
edition = "2018"
......
......@@ -50,7 +50,7 @@ use std::sync::Arc;
use std::time::Duration;
use std::pin::Pin;
use futures::{future, Future, Stream, FutureExt, TryFutureExt, StreamExt, task::Spawn};
use futures::{future, Future, Stream, FutureExt, StreamExt, task::Spawn};
use log::warn;
use sc_client_api::{StateBackend, BlockchainEvents};
use sp_blockchain::HeaderBackend;
......@@ -100,24 +100,17 @@ impl Network for polkadot_network::protocol::Service {
}
}
/// Error to return when the head data was invalid.
#[derive(Clone, Copy, Debug)]
pub struct InvalidHead;
/// Collation errors.
#[derive(Debug)]
pub enum Error {
/// Error on the relay-chain side of things.
Polkadot(String),
/// Error on the collator side of things.
Collator(InvalidHead),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Polkadot(ref err) => write!(f, "Polkadot node error: {}", err),
Error::Collator(_) => write!(f, "Collator node error: Invalid head data"),
}
}
}
......@@ -147,7 +140,7 @@ pub trait BuildParachainContext {
/// This can be implemented through an externally attached service or a stub.
/// This is expected to be a lightweight, shared type like an Arc.
pub trait ParachainContext: Clone {
type ProduceCandidate: Future<Output = Result<(BlockData, HeadData), InvalidHead>>;
type ProduceCandidate: Future<Output = Option<(BlockData, HeadData)>>;
/// Produce a candidate, given the relay parent hash, the latest ingress queue information
/// and the last parachain head.
......@@ -167,8 +160,7 @@ pub async fn collate<P>(
local_validation_data: LocalValidationData,
mut para_context: P,
key: Arc<CollatorPair>,
)
-> Result<parachain::Collation, Error>
) -> Option<parachain::Collation>
where
P: ParachainContext,
P::ProduceCandidate: Send,
......@@ -177,7 +169,7 @@ pub async fn collate<P>(
relay_parent,
global_validation,
local_validation_data,
).map_err(Error::Collator).await?;
).await?;
let pov_block = PoVBlock {
block_data,
......@@ -204,7 +196,7 @@ pub async fn collate<P>(
pov: pov_block,
};
Ok(collation)
Some(collation)
}
#[cfg(feature = "service-rewr")]
......@@ -341,8 +333,13 @@ fn build_collator_service<SP, P, C, R, Extrinsic>(
local_validation,
parachain_context,
key,
).map_ok(move |collation| {
network.distribute_collation(targets, collation)
).map(move |collation| {
match collation {
Some(collation) => network.distribute_collation(targets, collation),
None => log::trace!("Skipping collation as `collate` returned `None`"),
}
Ok(())
});
future::Either::Right(collation_work)
......@@ -376,7 +373,6 @@ pub async fn start_collator<P>(
para_id: ParaId,
key: Arc<CollatorPair>,
config: Configuration,
informant_prefix: Option<String>,
) -> Result<(), polkadot_service::Error>
where
P: 'static + BuildParachainContext,
......@@ -397,7 +393,6 @@ where
false,
6000,
None,
informant_prefix,
)?;
let spawn_handle = service.spawn_task_handle();
build_collator_service(
......@@ -416,7 +411,6 @@ where
false,
6000,
None,
informant_prefix,
)?;
let spawn_handle = service.spawn_task_handle();
build_collator_service(
......@@ -435,7 +429,6 @@ where
false,
6000,
None,
informant_prefix,
)?;
let spawn_handle = service.spawn_task_handle();
build_collator_service(
......@@ -470,7 +463,7 @@ mod tests {
struct DummyParachainContext;
impl ParachainContext for DummyParachainContext {
type ProduceCandidate = future::Ready<Result<(BlockData, HeadData), InvalidHead>>;
type ProduceCandidate = future::Ready<Option<(BlockData, HeadData)>>;
fn produce_candidate(
&mut self,
......@@ -479,10 +472,10 @@ mod tests {
_local_validation: LocalValidationData,
) -> Self::ProduceCandidate {
// send messages right back.
future::ok((
future::ready(Some((
BlockData(vec![1, 2, 3, 4, 5,]),
HeadData(vec![9, 9, 9]),
))
)))
}
}
......@@ -501,21 +494,20 @@ mod tests {
}
}
// Make sure that the future returned by `start_collator` implementes `Send`.
// Make sure that the future returned by `start_collator` implements `Send`.
#[test]
fn start_collator_is_send() {
fn check_send<T: Send>(_: T) {}
let cli = Cli::from_iter(&["-dev"]);
let task_executor = Arc::new(|_, _| unimplemented!());
let config = cli.create_configuration(&cli.run.base, task_executor).unwrap();
let task_executor = |_, _| unimplemented!();
let config = cli.create_configuration(&cli.run.base, task_executor.into()).unwrap();
check_send(start_collator(
BuildDummyParachainContext,
0.into(),
Arc::new(CollatorPair::generate().0),
config,
None,
));
}
}
......@@ -47,7 +47,7 @@ services:
- "--name"
- "${VALIDATOR_NANE:-AlicesNode}"
- "--reserved-nodes"
- "${VALIDATOR_RESERVED_NODES:-/dns4/sentry/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi}"
- "${VALIDATOR_RESERVED_NODES:-/dns/sentry/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi}"
# Not only bind to localhost.
- "--ws-external"
- "--rpc-external"
......@@ -90,7 +90,7 @@ services:
- "--name"
- "${SENTRY_NAME:-CharliesNode}"
- "--bootnodes"
- "${SENTRY_BOOTNODES:-/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR}"
- "${SENTRY_BOOTNODES:-/dns/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR}"
- "--no-telemetry"
- "--rpc-cors"
- "all"
......
[package]
name = "polkadot-erasure-coding"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-network"
version = "0.8.8"
version = "0.8.13"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol"
edition = "2018"
......
[package]
name = "polkadot-network-test"
version = "0.8.8"
version = "0.8.13"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
......@@ -7,3 +7,7 @@ description = "Message types used by Subsystems"
[dependencies]
polkadot-primitives = { path = "../../primitives" }
polkadot-statement-table = { path = "../../statement-table" }
polkadot-node-primitives = { path = "../primitives" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
futures = "0.3.5"
......@@ -22,7 +22,17 @@
//!
//! Subsystems' APIs are defined separately from their implementation, leading to easier mocking.
use polkadot_primitives::Hash;
use futures::channel::{mpsc, oneshot};
use sc_network::{ObservedRole, ReputationChange, PeerId, config::ProtocolId};
use polkadot_primitives::{BlockNumber, Hash, Signature};
use polkadot_primitives::parachain::{
AbridgedCandidateReceipt, PoVBlock, ErasureChunk, BackedCandidate, Id as ParaId,
SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex,
};
use polkadot_node_primitives::{
MisbehaviorReport, SignedFullStatement,
};
/// Signals sent by an overseer to a subsystem.
#[derive(PartialEq, Clone, Debug)]
......@@ -35,24 +45,174 @@ pub enum OverseerSignal {
Conclude,
}
/// A message type used by the Validation Subsystem.
/// A notification of a new backed candidate.
#[derive(Debug)]
pub struct NewBackedCandidate(pub BackedCandidate);
/// Messages received by the Candidate Selection subsystem.
#[derive(Debug)]
pub enum CandidateSelectionMessage {
/// We recommended a particular candidate to be seconded, but it was invalid; penalize the collator.
/// The hash is the relay parent.
Invalid(Hash, AbridgedCandidateReceipt),
}
/// Messages received by the Candidate Backing subsystem.
#[derive(Debug)]
pub enum ValidationSubsystemMessage {
ValidityAttestation,
pub enum CandidateBackingMessage {
/// Registers a stream listener for updates to the set of backable candidates that could be backed
/// in a child of the given relay-parent, referenced by its hash.
RegisterBackingWatcher(Hash, mpsc::Sender<NewBackedCandidate>),
/// Note that the Candidate Backing subsystem should second the given candidate in the context of the
/// given relay-parent (ref. by hash). This candidate must be validated.
Second(Hash, AbridgedCandidateReceipt),
/// Note a validator's statement about a particular candidate. Disagreements about validity must be escalated
/// to a broader check by Misbehavior Arbitration. Agreements are simply tallied until a quorum is reached.
Statement(Hash, SignedFullStatement),
}
/// A message type used by the CandidateBacking Subsystem.
/// Blanket error for validation failing.
#[derive(Debug)]
pub enum CandidateBackingSubsystemMessage {
RegisterBackingWatcher,
Second,
pub struct ValidationFailed;
/// Messages received by the Validation subsystem
#[derive(Debug)]
pub enum CandidateValidationMessage {
/// Validate a candidate, sending a side-channel response of valid or invalid.
///
/// Provide the relay-parent in whose context this should be validated, the full candidate receipt,
/// and the PoV.
Validate(
Hash,
AbridgedCandidateReceipt,
PoVBlock,
oneshot::Sender<Result<(), ValidationFailed>>,
),
}
/// Chain heads.
///
/// Up to `N` (5?) chain heads.
pub struct View(pub Vec<Hash>);
/// Events from network.
pub enum NetworkBridgeEvent {
/// A peer has connected.
PeerConnected(PeerId, ObservedRole),
/// A peer has disconnected.
PeerDisconnected(PeerId),
/// Peer has sent a message.
PeerMessage(PeerId, Vec<u8>),
/// Peer's `View` has changed.
PeerViewChange(PeerId, View),
/// Our `View` has changed.
OurViewChange(View),
}
/// Messages received by the network bridge subsystem.
pub enum NetworkBridgeSubsystemMessage {
/// Register an event producer on startup.
RegisterEventProducer(ProtocolId, fn(NetworkBridgeEvent) -> AllMessages),
/// Report a peer for their actions.
ReportPeer(PeerId, ReputationChange),
/// Send a message to multiple peers.
SendMessage(Vec<PeerId>, ProtocolId, Vec<u8>),
}
/// Availability Distribution Message.
pub enum AvailabilityDistributionMessage {
/// Distribute an availability chunk to other validators.
DistributeChunk(Hash, ErasureChunk),
/// Fetch an erasure chunk from networking by candidate hash and chunk index.
FetchChunk(Hash, u32),
/// Event from the network bridge.
NetworkBridgeUpdate(NetworkBridgeEvent),
}
/// Bitfield distribution message.
pub enum BitfieldDistributionMessage {
/// Distribute a bitfield via gossip to other validators.
DistributeBitfield(Hash, SignedAvailabilityBitfield),
/// Event from the network bridge.
NetworkBridgeUpdate(NetworkBridgeEvent),
}
/// Availability store subsystem message.
pub enum AvailabilityStoreMessage {
/// Query a `PoVBlock` from the AV store.
QueryPoV(Hash, oneshot::Sender<Option<PoVBlock>>),
/// Query an `ErasureChunk` from the AV store.
QueryChunk(Hash, ValidatorIndex, oneshot::Sender<ErasureChunk>),
/// Store an `ErasureChunk` in the AV store.
StoreChunk(Hash, ValidatorIndex, ErasureChunk),
}
/// A request to the Runtime API subsystem.
pub enum RuntimeApiRequest {
/// Get the current validator set.
Validators(oneshot::Sender<Vec<ValidatorId>>),
/// Get a signing context for bitfields and statements.
SigningContext(oneshot::Sender<SigningContext>),
/// Get the validation code for a specific para, assuming execution under given block number, and
/// an optional block number representing an intermediate parablock executed in the context of
/// that block.
ValidationCode(ParaId, BlockNumber, Option<BlockNumber>, oneshot::Sender<ValidationCode>),
}
/// A message to the Runtime API subsystem.
pub enum RuntimeApiMessage {
/// Make a request of the runtime API against the post-state of the given relay-parent.
Request(Hash, RuntimeApiRequest),
}
/// Statement distribution message.
pub enum StatementDistributionMessage {
/// We have originated a signed statement in the context of
/// given relay-parent hash and it should be distributed to other validators.
Share(Hash, SignedFullStatement),
}
/// This data becomes intrinsics or extrinsics which should be included in a future relay chain block.
pub enum ProvisionableData {
/// This bitfield indicates the availability of various candidate blocks.
Bitfield(Hash, SignedAvailabilityBitfield),
/// The Candidate Backing subsystem believes that this candidate is valid, pending availability.
BackedCandidate(BackedCandidate),
/// Misbehavior reports are self-contained proofs of validator misbehavior.
MisbehaviorReport(Hash, MisbehaviorReport),
/// Disputes trigger a broad dispute resolution process.
Dispute(Hash, Signature),
}
/// Message to the Provisioner.
///
/// In all cases, the Hash is that of the relay parent.
pub enum ProvisionerMessage {
/// This message allows potential block authors to be kept updated with all new authorship data
/// as it becomes available.
RequestBlockAuthorshipData(Hash, mpsc::Sender<ProvisionableData>),
/// This data should become part of a relay chain block
ProvisionableData(ProvisionableData),
}
/// A message type tying together all message types that are used across Subsystems.
#[derive(Debug)]
pub enum AllMessages {
Validation(ValidationSubsystemMessage),
CandidateBacking(CandidateBackingSubsystemMessage),
/// Message for the validation subsystem.
CandidateValidation(CandidateValidationMessage),
/// Message for the candidate backing subsystem.
CandidateBacking(CandidateBackingMessage),
}
/// A message type that a subsystem receives from an overseer.
......
......@@ -20,22 +20,24 @@
use std::time::Duration;
use futures::{
channel::oneshot,
pending, pin_mut, executor, select, stream,
FutureExt, StreamExt,
};
use futures_timer::Delay;
use kv_log_macro as log;
use polkadot_primitives::parachain::{BlockData, PoVBlock};
use polkadot_overseer::{Overseer, Subsystem, SubsystemContext, SpawnedSubsystem};
use messages::{
AllMessages, CandidateBackingSubsystemMessage, FromOverseer, ValidationSubsystemMessage
AllMessages, CandidateBackingMessage, FromOverseer, CandidateValidationMessage
};
struct Subsystem1;
impl Subsystem1 {
async fn run(mut ctx: SubsystemContext<CandidateBackingSubsystemMessage>) {
async fn run(mut ctx: SubsystemContext<CandidateBackingMessage>) {
loop {
match ctx.try_recv().await {
Ok(Some(msg)) => {
......@@ -52,15 +54,24 @@ impl Subsystem1 {
}
Delay::new(Duration::from_secs(1)).await;
ctx.send_msg(AllMessages::Validation(
ValidationSubsystemMessage::ValidityAttestation
let (tx, _) = oneshot::channel();
ctx.send_msg(AllMessages::CandidateValidation(
CandidateValidationMessage::Validate(
Default::default(),
Default::default(),
PoVBlock {
block_data: BlockData(Vec::new()),
},
tx,
)
)).await.unwrap();
}
}
}
impl Subsystem<CandidateBackingSubsystemMessage> for Subsystem1 {
fn start(&mut self, ctx: SubsystemContext<CandidateBackingSubsystemMessage>) -> SpawnedSubsystem {
impl Subsystem<CandidateBackingMessage> for Subsystem1 {
fn start(&mut self, ctx: SubsystemContext<CandidateBackingMessage>) -> SpawnedSubsystem {
SpawnedSubsystem(Box::pin(async move {
Self::run(ctx).await;
}))
......@@ -70,7 +81,7 @@ impl Subsystem<CandidateBackingSubsystemMessage> for Subsystem1 {
struct Subsystem2;
impl Subsystem2 {
async fn run(mut ctx: SubsystemContext<ValidationSubsystemMessage>) {
async fn run(mut ctx: SubsystemContext<CandidateValidationMessage>) {
ctx.spawn(Box::pin(async {
loop {
log::info!("Job tick");
......@@ -94,8 +105,8 @@ impl Subsystem2 {
}
}
impl Subsystem<ValidationSubsystemMessage> for Subsystem2 {
fn start(&mut self, ctx: SubsystemContext<ValidationSubsystemMessage>) -> SpawnedSubsystem {
impl Subsystem<CandidateValidationMessage> for Subsystem2 {
fn start(&mut self, ctx: SubsystemContext<CandidateValidationMessage>) -> SpawnedSubsystem {
SpawnedSubsystem(Box::pin(async move {
Self::run(ctx).await;
}))
......