Erasure encoding availability (#345)

* Erasure encoding availability initial commit

 * Modifications to availability store to keep chunks as well as
   reconstructed blocks and extrinsics.
 * Gossip messages containig signed erasure chunks.
 * Requesting eraure chunks with polkadot-specific messages.
 * Validation of erasure chunk messages.

* Apply suggestions from code review

Co-Authored-By: Luke Schoen <ltfschoen@users.noreply.github.com>

* Fix build after a merge

* Gossip erasure chunk messages under their own topic

* erasure_chunks should use the appropriate topic

* Updates Cargo.lock

* Fixes after merge

* Removes a couple of leftover pieces of code

* Fixes simple stuff from review

* Updates erasure and storage for more flexible logic

* Changes validation and candidate receipt production.

* Adds add_erasure_chunks method

* Fixes most of the nits

* Better validate_collation and validate_receipt functions

* Fixes the tests

* Apply suggestions from code review

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* Removes unwrap() calls

* Removes ErasureChunks primitive

* Removes redundant fields from ErasureChunk struct

* AvailabilityStore should store CandidateReceipt

* Changes the way chunk messages are imported and validated.

 * Availability store now stores a validator_index and n_validators for
 each relay_parent.
 * Availability store now also stores candidate receipts.
 * Removes importing chunks in the table and moves it into network
 gossip validation.
 * Validation of erasure messages id done against receipts that are
 stored in the availability store.

* Correctly compute topics for erasure messages

* Removes an unused parameter

* Refactors availability db querying into a helper

* Adds the apis described in the writeup

* Adds a runtime api to extract erasure roots form raw extrinsics.

* Adds a barebone BlockImport impl for avalability store

* Adds the implementation of the availability worker

* Fix build after the merge with master.

* Make availability store API async

* Bring back the default wasmtime feature

* Lines width

* Bump runtime version

* Formatting and dead code elimination

* some style nits (#1)

* More nits and api cleanup

* Disable wasm CI for availability-store

* Another nit

* Formatting
This commit is contained in:
Fedor Sakharov
2019-12-03 17:49:07 +03:00
committed by Robert Habermeier
parent ec54d5b1e4
commit 99d164b5e7
29 changed files with 2957 additions and 572 deletions
+14 -1
View File
@@ -33,7 +33,7 @@ use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode};
use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas}, ValidityError,
parachain::{self, ActiveParas, CandidateReceipt}, ValidityError,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
@@ -711,6 +711,19 @@ sp_api::impl_runtime_apis! {
{
Parachains::ingress(to, since).map(parachain::StructuredUnroutedIngress)
}
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>) -> Option<Vec<CandidateReceipt>> {
extrinsics
.into_iter()
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
Ok(ex) => match ex.function {
Call::Parachains(ParachainsCall::set_heads(heads)) => {
Some(heads.into_iter().map(|c| c.candidate).collect())
}
_ => None,
}
Err(_) => None,
})
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
+10
View File
@@ -1247,6 +1247,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
}
}
@@ -1269,6 +1270,7 @@ mod tests {
upward_messages: upward_messages.into_iter()
.map(|x| UpwardMessage { origin: x.0, data: x.1 })
.collect(),
erasure_root: [1u8; 32].into(),
}
}
}
@@ -1676,6 +1678,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
},
};
@@ -1707,6 +1710,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1722,6 +1726,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1761,6 +1766,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1798,6 +1804,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1843,6 +1850,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1859,6 +1867,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
@@ -1920,6 +1929,7 @@ mod tests {
fees: 0,
block_data_hash: Default::default(),
upward_messages: vec![],
erasure_root: [1u8; 32].into(),
}
};
make_attestations(&mut candidate_c);
+1
View File
@@ -836,6 +836,7 @@ mod tests {
fees: 0,
block_data_hash,
upward_messages: vec![],
erasure_root: [1; 32].into(),
};
let payload = (Statement::Valid(candidate.hash()), System::parent_hash()).encode();
let roster = Parachains::calculate_duty_roster().0.validator_duty;