Request based availability distribution (#2423)

* WIP

* availability distribution, still very wip.

Work on the requesting side of things.

* Some docs on what I intend to do.

* Checkpoint of session cache implementation

as I will likely replace it with something smarter.

* More work, mostly on cache

and getting things to type check.

* Only derive MallocSizeOf and Debug for std.

* availability-distribution: Cache feature complete.

* Sketch out logic in `FetchTask` for actual fetching.

- Compile fixes.
- Cleanup.

* Format cleanup.

* More format fixes.

* Almost feature complete `fetch_task`.

Missing:

- Check for cancel
- Actual querying of peer ids.

* Finish FetchTask so far.

* Directly use AuthorityDiscoveryId in protocol and cache.

* Resolve `AuthorityDiscoveryId` on sending requests.

* Rework fetch_task

- also make it impossible to check the wrong chunk index.
- Export needed function in validator_discovery.

* From<u32> implementation for `ValidatorIndex`.

* Fixes and more integration work.

* Make session cache proper lru cache.

* Use proper lru cache.

* Requester finished.

* ProtocolState -> Requester

Also make sure to not fetch our own chunk.

* Cleanup + fixes.

* Remove unused functions

- FetchTask::is_finished
- SessionCache::fetch_session_info

* availability-distribution responding side.

* Cleanup + Fixes.

* More fixes.

* More fixes.

adder-collator is running!

* Some docs.

* Docs.

* Fix reporting of bad guys.

* Fix tests

* Make all tests compile.

* Fix test.

* Cleanup + get rid of some warnings.

* state -> requester

* Mostly doc fixes.

* Fix test suite.

* Get rid of now redundant message types.

* WIP

* Rob's review remarks.

* Fix test suite.

* core.relay_parent -> leaf for session request.

* Style fix.

* Decrease request timeout.

* Cleanup obsolete errors.

* Metrics + don't fail on non fatal errors.

* requester.rs -> requester/mod.rs

* Panic on invalid BadValidator report.

* Fix indentation.

* Use typed default timeout constant.

* Make channel size 0, as each sender gets one slot anyways.

* Fix incorrect metrics initialization.

* Fix build after merge.

* More fixes.

* Hopefully valid metrics names.

* Better metrics names.

* Some tests that already work.

* Slightly better docs.

* Some more tests.

* Fix network bridge test.
This commit is contained in:
Robert Klotzner
2021-02-26 18:58:07 +01:00
committed by GitHub
parent 241b1f12a7
commit 48409e5548
45 changed files with 2037 additions and 1523 deletions
+22 -21
View File
@@ -899,7 +899,7 @@ impl CandidateBackingJob {
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
fn check_statement_signature(&self, statement: &SignedFullStatement) -> Result<(), Error> {
let idx = statement.validator_index() as usize;
let idx = statement.validator_index().0 as usize;
if self.table_context.validators.len() > idx {
statement.check_signature(
@@ -1282,7 +1282,8 @@ mod tests {
let validator_public = validator_pubkeys(&validators);
let validator_groups = vec![vec![2, 0, 3, 5], vec![1], vec![4]];
let validator_groups = vec![vec![2, 0, 3, 5], vec![1], vec![4]]
.into_iter().map(|g| g.into_iter().map(ValidatorIndex).collect()).collect();
let group_rotation_info = GroupRotationInfo {
session_start_block: 0,
group_rotation_frequency: 100,
@@ -1599,7 +1600,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate_a.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -1607,7 +1608,7 @@ mod tests {
&test_state.keystore,
Statement::Valid(candidate_a_hash),
&test_state.signing_context,
5,
ValidatorIndex(5),
&public1.into(),
).await.ok().flatten().expect("should be signed");
@@ -1741,7 +1742,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate_a.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -1749,7 +1750,7 @@ mod tests {
&test_state.keystore,
Statement::Valid(candidate_a_hash),
&test_state.signing_context,
5,
ValidatorIndex(5),
&public1.into(),
).await.ok().flatten().expect("should be signed");
@@ -1757,7 +1758,7 @@ mod tests {
&test_state.keystore,
Statement::Valid(candidate_a_hash),
&test_state.signing_context,
3,
ValidatorIndex(3),
&public3.into(),
).await.ok().flatten().expect("should be signed");
@@ -1894,7 +1895,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate_a.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -1902,7 +1903,7 @@ mod tests {
&test_state.keystore,
Statement::Invalid(candidate_a_hash),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -1910,7 +1911,7 @@ mod tests {
&test_state.keystore,
Statement::Invalid(candidate_a_hash),
&test_state.signing_context,
0,
ValidatorIndex(0),
&public0.into(),
).await.ok().flatten().expect("should be signed");
@@ -2002,7 +2003,7 @@ mod tests {
validator_index,
s1,
&test_state.signing_context,
&test_state.validator_public[validator_index as usize],
&test_state.validator_public[validator_index.0 as usize],
).expect("signature must be valid");
SignedFullStatement::new(
@@ -2010,7 +2011,7 @@ mod tests {
validator_index,
s2,
&test_state.signing_context,
&test_state.validator_public[validator_index as usize],
&test_state.validator_public[validator_index.0 as usize],
).expect("signature must be valid");
}
);
@@ -2042,7 +2043,7 @@ mod tests {
validator_index,
s1,
&test_state.signing_context,
&test_state.validator_public[validator_index as usize],
&test_state.validator_public[validator_index.0 as usize],
).expect("signature must be valid");
SignedFullStatement::new(
@@ -2050,7 +2051,7 @@ mod tests {
validator_index,
s2,
&test_state.signing_context,
&test_state.validator_public[validator_index as usize],
&test_state.validator_public[validator_index.0 as usize],
).expect("signature must be valid");
}
);
@@ -2223,7 +2224,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&validator2.into(),
).await.ok().flatten().expect("should be signed");
@@ -2361,7 +2362,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -2503,7 +2504,7 @@ mod tests {
&test_state.keystore,
Statement::Seconded(candidate_a.clone()),
&test_state.signing_context,
2,
ValidatorIndex(2),
&public2.into(),
).await.ok().flatten().expect("should be signed");
@@ -2542,7 +2543,7 @@ mod tests {
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.insert(para_id, vec![0, 1, 2, 3, 4, 5].into_iter().map(ValidatorIndex).collect());
validator_groups
};
@@ -2567,9 +2568,9 @@ mod tests {
let attested = TableAttestedCandidate {
candidate: Default::default(),
validity_votes: vec![
(5, fake_attestation(5)),
(3, fake_attestation(3)),
(1, fake_attestation(1)),
(ValidatorIndex(5), fake_attestation(5)),
(ValidatorIndex(3), fake_attestation(3)),
(ValidatorIndex(1), fake_attestation(1)),
],
group_id: para_id,
};