mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
backing: Remove redundant erasure encoding (#7469)
* Remove redundant erasure encoding Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix comments Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -155,6 +155,7 @@ On `StoreChunk` message:
|
||||
|
||||
On `StoreAvailableData` message:
|
||||
|
||||
- Compute the erasure root of the available data and compare it with `expected_erasure_root`. Return `StoreAvailableDataError::InvalidErasureRoot` on mismatch.
|
||||
- If there is no `CandidateMeta` under the candidate hash, create it with `State::Unavailable(now)`. Load the `CandidateMeta` otherwise.
|
||||
- Store `data` under `("available", candidate_hash)` and set `data_available` to true.
|
||||
- Store each chunk under `("chunk", candidate_hash, index)` and set every bit in `chunks_stored` to `1`.
|
||||
|
||||
@@ -254,22 +254,66 @@ enum AvailabilityRecoveryMessage {
|
||||
Messages to and from the availability store.
|
||||
|
||||
```rust
|
||||
enum AvailabilityStoreMessage {
|
||||
/// Query the `AvailableData` of a candidate by hash.
|
||||
QueryAvailableData(CandidateHash, ResponseChannel<Option<AvailableData>>),
|
||||
/// Query whether an `AvailableData` exists within the AV Store.
|
||||
QueryDataAvailability(CandidateHash, ResponseChannel<bool>),
|
||||
/// Query a specific availability chunk of the candidate's erasure-coding by validator index.
|
||||
/// Returns the chunk and its inclusion proof against the candidate's erasure-root.
|
||||
QueryChunk(CandidateHash, ValidatorIndex, ResponseChannel<Option<ErasureChunk>>),
|
||||
/// Query all chunks that we have locally for the given candidate hash.
|
||||
QueryAllChunks(CandidateHash, ResponseChannel<Vec<ErasureChunk>>),
|
||||
/// Store a specific chunk of the candidate's erasure-coding by validator index, with an
|
||||
/// accompanying proof.
|
||||
StoreChunk(CandidateHash, ErasureChunk, ResponseChannel<Result<()>>),
|
||||
/// Store `AvailableData`. If `ValidatorIndex` is provided, also store this validator's
|
||||
/// `ErasureChunk`.
|
||||
StoreAvailableData(CandidateHash, Option<ValidatorIndex>, u32, AvailableData, ResponseChannel<Result<()>>),
|
||||
pub enum AvailabilityStoreMessage {
|
||||
/// Query a `AvailableData` from the AV store.
|
||||
QueryAvailableData(CandidateHash, oneshot::Sender<Option<AvailableData>>),
|
||||
|
||||
/// Query whether a `AvailableData` exists within the AV Store.
|
||||
///
|
||||
/// This is useful in cases when existence
|
||||
/// matters, but we don't want to necessarily pass around multiple
|
||||
/// megabytes of data to get a single bit of information.
|
||||
QueryDataAvailability(CandidateHash, oneshot::Sender<bool>),
|
||||
|
||||
/// Query an `ErasureChunk` from the AV store by the candidate hash and validator index.
|
||||
QueryChunk(CandidateHash, ValidatorIndex, oneshot::Sender<Option<ErasureChunk>>),
|
||||
|
||||
/// Get the size of an `ErasureChunk` from the AV store by the candidate hash.
|
||||
QueryChunkSize(CandidateHash, oneshot::Sender<Option<usize>>),
|
||||
|
||||
/// Query all chunks that we have for the given candidate hash.
|
||||
QueryAllChunks(CandidateHash, oneshot::Sender<Vec<ErasureChunk>>),
|
||||
|
||||
/// Query whether an `ErasureChunk` exists within the AV Store.
|
||||
///
|
||||
/// This is useful in cases like bitfield signing, when existence
|
||||
/// matters, but we don't want to necessarily pass around large
|
||||
/// quantities of data to get a single bit of information.
|
||||
QueryChunkAvailability(CandidateHash, ValidatorIndex, oneshot::Sender<bool>),
|
||||
|
||||
/// Store an `ErasureChunk` in the AV store.
|
||||
///
|
||||
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
|
||||
StoreChunk {
|
||||
/// A hash of the candidate this chunk belongs to.
|
||||
candidate_hash: CandidateHash,
|
||||
/// The chunk itself.
|
||||
chunk: ErasureChunk,
|
||||
/// Sending side of the channel to send result to.
|
||||
tx: oneshot::Sender<Result<(), ()>>,
|
||||
},
|
||||
|
||||
/// Computes and checks the erasure root of `AvailableData` before storing all of its chunks in
|
||||
/// the AV store.
|
||||
///
|
||||
/// Return `Ok(())` if the store operation succeeded, `Err(StoreAvailableData)` if it failed.
|
||||
StoreAvailableData {
|
||||
/// A hash of the candidate this `available_data` belongs to.
|
||||
candidate_hash: CandidateHash,
|
||||
/// The number of validators in the session.
|
||||
n_validators: u32,
|
||||
/// The `AvailableData` itself.
|
||||
available_data: AvailableData,
|
||||
/// Erasure root we expect to get after chunking.
|
||||
expected_erasure_root: Hash,
|
||||
/// Sending side of the channel to send result to.
|
||||
tx: oneshot::Sender<Result<(), StoreAvailableDataError>>,
|
||||
},
|
||||
}
|
||||
|
||||
/// The error result type of a [`AvailabilityStoreMessage::StoreAvailableData`] request.
|
||||
pub enum StoreAvailableDataError {
|
||||
InvalidErasureRoot,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user