Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete redundant chunk removal from storage
Browse files Browse the repository at this point in the history
kamilsa committed Jan 29, 2025

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech
1 parent 352e38f commit 54e4151
Showing 2 changed files with 20 additions and 20 deletions.
11 changes: 6 additions & 5 deletions core/parachain/availability/recovery/recovery_impl.cpp
Original file line number Diff line number Diff line change
@@ -196,20 +196,21 @@ namespace kagome::parachain {
if (auto indexed_key_pair_opt =
session_keys_->getParaKeyPair(session->validators);
indexed_key_pair_opt.has_value()) {
auto out_validator_index = indexed_key_pair_opt->second;
auto index_of_our_chunk = val2chunk(out_validator_index);
auto our_validator_index = indexed_key_pair_opt->second;
auto index_of_our_chunk = val2chunk(our_validator_index);
auto min_chunks = _min.value();

auto our_chunk = av_store_->getChunk(candidate_hash, index_of_our_chunk);

if (not our_chunk.has_value()) {
SL_WARN(logger_,
"Our node does not have a chunk which it must be have");
"Our chunk {}:{} not found",
candidate_hash,
index_of_our_chunk);
} else {
available_data_size = our_chunk->chunk.size() * min_chunks;
}
} else {
SL_WARN(logger_, "Cannot retrieve out validator index");
SL_WARN(logger_, "Cannot retrieve our validator index");
}

// Do recovery from backers strategy iff available
29 changes: 14 additions & 15 deletions core/parachain/availability/store/store_impl.cpp
Original file line number Diff line number Diff line change
@@ -259,6 +259,8 @@ namespace kagome::parachain {
std::vector<ErasureChunk> &&chunks,
const ParachainBlock &pov,
const PersistedValidationData &data) {
SL_TRACE(logger, "Attempt to store all chunks of {}", candidate_hash);

state_.exclusiveAccess([&](auto &state) {
prune_candidates_no_lock(state);
state.candidates_[relay_parent].insert(candidate_hash);
@@ -287,6 +289,11 @@ namespace kagome::parachain {
candidate_hash,
chunk_index,
res.error());
} else {
SL_TRACE(logger,
"Chunk {}:{} is saved by storeData()",
candidate_hash,
chunk.index);
}
}
candidate_data.pov = pov;
@@ -299,6 +306,8 @@ namespace kagome::parachain {
void AvailabilityStoreImpl::putChunk(const network::RelayHash &relay_parent,
const CandidateHash &candidate_hash,
ErasureChunk &&chunk) {
SL_TRACE(logger, "Attempt to put chunk {}:{}", candidate_hash, chunk.index);

auto encoded_chunk = scale::encode(chunk);
const auto chunk_index = chunk.index;
state_.exclusiveAccess([&](auto &state) {
@@ -331,28 +340,18 @@ namespace kagome::parachain {
chunk_index,
res.error());
}

SL_TRACE(logger,
"Chunk {}:{} is saved by putChunk()",
candidate_hash,
chunk.index);
}

void AvailabilityStoreImpl::remove_no_lock(
State &state, const network::RelayHash &relay_parent) {
if (auto it = state.candidates_.find(relay_parent);
it != state.candidates_.end()) {
for (const auto &l : it->second) {
auto space = storage_->getSpace(storage::Space::kAvaliabilityStorage);
if (space) {
for (const auto &chunk : state.per_candidate_[l].chunks) {
if (not space->remove(
CandidateChunkKey::encode(l, chunk.second.index))) {
SL_ERROR(logger,
"Failed to remove chunk candidate {} index {}",
l,
chunk.second.index);
}
}
} else {
SL_CRITICAL(logger,
"Failed to get AvaliabilityStorage space in remove");
}
state.per_candidate_.erase(l);
}
state.candidates_.erase(it);

0 comments on commit 54e4151

Please sign in to comment.