Unverified Commit 8f882afd authored by Fedor Sakharov's avatar Fedor Sakharov Committed by GitHub
Browse files

Availability store pruning (#1820)



* Initial commit

* Move tests to separate module

* Move timestamps to the newtype

* Change idx name

* Use Duration for consts and update chunk records

* Ordering::Equal

* Update node/core/av-store/src/lib.rs

Co-authored-by: default avatarPeter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* put_ methods do the array sorting

* Fix get_block_number

* Change StoreChunk message type and relay parent method

* Add chunk tests

* Fix block number computation for StoreChunk

* Duration instead of u64 everywhere

* Add a clarifying comment

Co-authored-by: default avatarPeter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
parent 573152f2
Pipeline #111672 passed with stages
in 23 minutes and 56 seconds
......@@ -4932,7 +4932,9 @@ version = "0.1.0"
dependencies = [
"assert_matches",
"derive_more 0.99.11",
"env_logger",
"futures 0.3.5",
"futures-timer 3.0.2",
"kvdb",
"kvdb-memorydb",
"kvdb-rocksdb",
......@@ -4944,6 +4946,7 @@ dependencies = [
"polkadot-node-subsystem-util",
"polkadot-overseer",
"polkadot-primitives",
"smallvec 1.4.2",
"sp-core",
]
......
......@@ -7,21 +7,24 @@ edition = "2018"
[dependencies]
derive_more = "0.99.9"
futures = "0.3.5"
log = "0.4.8"
futures-timer = "3.0.2"
kvdb = "0.7.0"
kvdb-rocksdb = "0.9.1"
codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
log = "0.4.8"
codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
erasure = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
[dev-dependencies]
env_logger = "0.7.1"
assert_matches = "1.3.0"
smallvec = "1.4.2"
kvdb-memorydb = "0.7.0"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
futures = { version = "0.3.5", features = ["thread-pool"] }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
kvdb-memorydb = "0.7.0"
assert_matches = "1.3.0"
This diff is collapsed.
This diff is collapsed.
......@@ -661,6 +661,7 @@ where
if let Err(_e) = store_chunk(
ctx,
message.candidate_hash.clone(),
live_candidate.descriptor.relay_parent.clone(),
message.erasure_chunk.index,
message.erasure_chunk.clone(),
).await? {
......@@ -949,6 +950,7 @@ where
async fn store_chunk<Context>(
ctx: &mut Context,
candidate_hash: Hash,
relay_parent: Hash,
validator_index: ValidatorIndex,
erasure_chunk: ErasureChunk,
) -> Result<std::result::Result<(), ()>>
......@@ -957,7 +959,13 @@ where
{
let (tx, rx) = oneshot::channel();
ctx.send_message(AllMessages::AvailabilityStore(
AvailabilityStoreMessage::StoreChunk(candidate_hash, validator_index, erasure_chunk, tx),
AvailabilityStoreMessage::StoreChunk {
candidate_hash,
relay_parent,
validator_index,
chunk: erasure_chunk,
tx,
}
)).await?;
rx.await.map_err::<Error, _>(Into::into)
}
......
......@@ -305,7 +305,18 @@ pub enum AvailabilityStoreMessage {
/// Store an `ErasureChunk` in the AV store.
///
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
StoreChunk(Hash, ValidatorIndex, ErasureChunk, oneshot::Sender<Result<(), ()>>),
StoreChunk {
/// A hash of the candidate this chunk belongs to.
candidate_hash: Hash,
/// A relevant relay parent.
relay_parent: Hash,
/// The index of the validator this chunk belongs to.
validator_index: ValidatorIndex,
/// The chunk itself.
chunk: ErasureChunk,
/// Sending side of the channel to send result to.
tx: oneshot::Sender<Result<(), ()>>,
},
/// Store a `AvailableData` in the AV store.
/// If `ValidatorIndex` is present store corresponding chunk also.
......@@ -315,15 +326,10 @@ pub enum AvailabilityStoreMessage {
}
impl AvailabilityStoreMessage {
/// If the current variant contains the relay parent hash, return it.
/// In fact, none of the AvailabilityStore messages assume a particular relay parent.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::QueryAvailableData(hash, _) => Some(*hash),
Self::QueryDataAvailability(hash, _) => Some(*hash),
Self::QueryChunk(hash, _, _) => Some(*hash),
Self::QueryChunkAvailability(hash, _, _) => Some(*hash),
Self::StoreChunk(hash, _, _, _) => Some(*hash),
Self::StoreAvailableData(hash, _, _, _, _) => Some(*hash),
_ => None,
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment