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

Commit

Permalink
Merge branch 'master' into ao-validator-discovery-previous-sessions
Browse files Browse the repository at this point in the history
* master:
  backing: reorder votes to match bitfield in backed candidate (#2006)
  Switch to wasm-builder 3.0.0 (#2004)
  Make sure we inform statement listeners about received statements (#1999)
  Update docker.md (#2000)
  Bump tracing from 0.1.21 to 0.1.22 (#2001)
  Bump assert_cmd from 1.0.1 to 1.0.2 (#2003)
  Bump color-eyre from 0.5.7 to 0.5.8 (#2002)
  *: Update authority discovery and remove WorkerConfig (#1953)
  companion for substrate#7546 (#1954)
  • Loading branch information
ordian committed Nov 24, 2020
2 parents 5304563 + ede1959 commit 60aede3
Show file tree
Hide file tree
Showing 47 changed files with 918 additions and 970 deletions.
1,558 changes: 722 additions & 836 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ readme = "README.md"

[dependencies]
cli = { package = "polkadot-cli", path = "cli" }
color-eyre = "0.5.7"
color-eyre = "0.5.8"
thiserror = "1.0.22"
futures = "0.3.8"
service = { package = "polkadot-service", path = "node/service" }
parity-util-mem = { version = "*", default-features = false, features = ["jemalloc-global"] }

[dev-dependencies]
assert_cmd = "1.0.1"
assert_cmd = "1.0.2"
nix = "0.19.0"
tempfile = "3.1.0"

Expand Down
1 change: 0 additions & 1 deletion cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ pub fn run() -> Result<()> {
config,
service::IsCollator::No,
grandpa_pause,
None,
).map(|full| full.task_manager),
}
})
Expand Down
12 changes: 6 additions & 6 deletions doc/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ the polkadot binary, pulled from our package repository.
Let´s first check the version we have. The first time you run this command, the polkadot docker image will be downloaded. This takes a bit of time and bandwidth, be patient:

```bash
docker run --rm -it parity/polkadot:latest polkadot --version
docker run --rm -it parity/polkadot:latest --version
```

You can also pass any argument/flag that polkadot supports:

```bash
docker run --rm -it parity/polkadot:latest polkadot --chain westend --name "PolkaDocker"
docker run --rm -it parity/polkadot:latest --chain westend --name "PolkaDocker"
```

Once you are done experimenting and picking the best node name :) you can start polkadot as daemon, exposes the polkadot ports and mount a volume that will keep your blockchain data locally:

```bash
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest polkadot --chain westend
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest --chain westend
```

Additionally if you want to have custom node name you can add the `--name "YourName"` at the end

```bash
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest polkadot --chain westend --name "PolkaDocker"
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest --chain westend --name "PolkaDocker"
```

```bash
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest polkadot --rpc-external --chain westend
docker run -d -p 30333:30333 -p 9933:9933 -v /my/local/folder:/data parity/polkadot:latest --rpc-external --chain westend
```

If you want to connect to rpc port 9933, then must add polkadot startup parameter: `--rpc-external`.
Expand Down Expand Up @@ -70,7 +70,7 @@ If you run into issues with polkadot when using docker, please run the following
(replace the tag with the appropriate one if you do not use latest):

```bash
docker run --rm -it parity/polkadot:latest polkadot --version
docker run --rm -it parity/polkadot:latest --version
```

This will show you the polkadot version as well as the git commit ref that was used to build your container.
Expand Down
2 changes: 1 addition & 1 deletion node/collation-generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
polkadot-erasure-coding = { path = "../../erasure-coding" }
polkadot-node-primitives = { path = "../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/av-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ futures-timer = "3.0.2"
kvdb = "0.7.0"
kvdb-rocksdb = "0.9.1"
thiserror = "1.0.22"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"

parity-scale-codec = { version = "1.3.5", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion node/core/backing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ polkadot-node-subsystem-util = { path = "../../subsystem-util" }
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
thiserror = "1.0.22"

Expand Down
100 changes: 96 additions & 4 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use polkadot_primitives::v1::{
ValidatorIndex, SigningContext, PoV, CandidateHash,
CandidateDescriptor, AvailableData, ValidatorSignature, Hash, CandidateReceipt,
CandidateCommitments, CoreState, CoreIndex, CollatorId, ValidationOutputs,
ValidityAttestation,
};
use polkadot_node_primitives::{
FromTableMisbehavior, Statement, SignedFullStatement, MisbehaviorReport, ValidationResult,
Expand Down Expand Up @@ -256,7 +257,7 @@ fn table_attested_to_backed(
) -> Option<BackedCandidate> {
let TableAttestedCandidate { candidate, validity_votes, group_id: para_id } = attested;

let (ids, validity_votes): (Vec<_>, Vec<_>) = validity_votes
let (ids, validity_votes): (Vec<_>, Vec<ValidityAttestation>) = validity_votes
.into_iter()
.map(|(id, vote)| (id, vote.into()))
.unzip();
Expand All @@ -267,15 +268,30 @@ fn table_attested_to_backed(

validator_indices.resize(group.len(), false);

for id in ids.iter() {
// The order of the validity votes in the backed candidate must match
// the order of bits set in the bitfield, which is not necessarily
// the order of the `validity_votes` we got from the table.
let mut vote_positions = Vec::with_capacity(validity_votes.len());
for (orig_idx, id) in ids.iter().enumerate() {
if let Some(position) = group.iter().position(|x| x == id) {
validator_indices.set(position, true);
vote_positions.push((orig_idx, position));
} else {
tracing::warn!(
target: LOG_TARGET,
"Logic error: Validity vote from table does not correspond to group",
);

return None;
}
}
vote_positions.sort_by_key(|(_orig, pos_in_group)| *pos_in_group);

Some(BackedCandidate {
candidate,
validity_votes,
validity_votes: vote_positions.into_iter()
.map(|(pos_in_votes, _pos_in_group)| validity_votes[pos_in_votes].clone())
.collect(),
validator_indices,
})
}
Expand Down Expand Up @@ -1003,7 +1019,7 @@ mod tests {
use polkadot_primitives::v1::{
ScheduledCore, BlockData, CandidateCommitments,
PersistedValidationData, ValidationData, TransientValidationData, HeadData,
ValidityAttestation, GroupRotationInfo,
GroupRotationInfo,
};
use polkadot_subsystem::{
messages::RuntimeApiRequest,
Expand Down Expand Up @@ -2123,4 +2139,80 @@ mod tests {
).await;
});
}

#[test]
fn candidate_backing_reorders_votes() {
use sp_core::Encode;

let relay_parent = [1; 32].into();
let para_id = ParaId::from(10);
let session_index = 5;
let signing_context = SigningContext { parent_hash: relay_parent, session_index };
let validators = vec![
Sr25519Keyring::Alice,
Sr25519Keyring::Bob,
Sr25519Keyring::Charlie,
Sr25519Keyring::Dave,
Sr25519Keyring::Ferdie,
Sr25519Keyring::One,
];

let validator_public = validator_pubkeys(&validators);
let validator_groups = {
let mut validator_groups = HashMap::new();
validator_groups.insert(para_id, vec![0, 1, 2, 3, 4, 5]);
validator_groups
};

let table_context = TableContext {
signing_context,
validator: None,
groups: validator_groups,
validators: validator_public.clone(),
};

let fake_attestation = |idx: u32| {
let candidate: CommittedCandidateReceipt = Default::default();
let hash = candidate.hash();
let mut data = vec![0; 64];
data[0..32].copy_from_slice(hash.0.as_bytes());
data[32..36].copy_from_slice(idx.encode().as_slice());

let sig = ValidatorSignature::try_from(data).unwrap();
statement_table::generic::ValidityAttestation::Implicit(sig)
};

let attested = TableAttestedCandidate {
candidate: Default::default(),
validity_votes: vec![
(5, fake_attestation(5)),
(3, fake_attestation(3)),
(1, fake_attestation(1)),
],
group_id: para_id,
};

let backed = table_attested_to_backed(attested, &table_context).unwrap();

let expected_bitvec = {
let mut validator_indices = BitVec::<bitvec::order::Lsb0, u8>::with_capacity(6);
validator_indices.resize(6, false);

validator_indices.set(1, true);
validator_indices.set(3, true);
validator_indices.set(5, true);

validator_indices
};

// Should be in bitfield order, which is opposite to the order provided to the function.
let expected_attestations = vec![
fake_attestation(1).into(),
fake_attestation(3).into(),
fake_attestation(5).into(),
];

assert_eq!(backed.validator_indices, expected_bitvec);
assert_eq!(backed.validity_votes, expected_attestations);
}
}
2 changes: 1 addition & 1 deletion node/core/bitfield-signing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/candidate-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
thiserror = "1.0.22"
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/candidate-validation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"

sp-core = { package = "sp-core", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/chain-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/proposer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
futures = "0.3.8"
futures-timer = "3.0.2"
tracing = "0.1.21"
tracing = "0.1.22"
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/provisioner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
thiserror = "1.0.22"
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/core/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }

Expand Down
2 changes: 1 addition & 1 deletion node/network/availability-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
parity-scale-codec = { version = "1.3.5", features = ["std"] }
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/network/bitfield-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
parity-scale-codec = { version = "1.3.5", default-features = false, features = ["derive"] }
polkadot-primitives = { path = "../../../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion node/network/bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
async-trait = "0.1.42"
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
polkadot-primitives = { path = "../../../primitives" }
parity-scale-codec = { version = "1.3.5", default-features = false, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion node/network/collator-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
thiserror = "1.0.22"

Expand Down
2 changes: 1 addition & 1 deletion node/network/pov-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
polkadot-primitives = { path = "../../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
Expand Down
2 changes: 1 addition & 1 deletion node/network/statement-distribution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
futures = "0.3.8"
tracing = "0.1.21"
tracing = "0.1.22"
tracing-futures = "0.2.4"
polkadot-primitives = { path = "../../../primitives" }
node-primitives = { package = "polkadot-node-primitives", path = "../../primitives" }
Expand Down
Loading

0 comments on commit 60aede3

Please sign in to comment.