Skip to content

Commit

Permalink
Duplicated approval fixup! (#1540)
Browse files Browse the repository at this point in the history
* duplicated approval fixup!

Signed-off-by: iceseer <iceseer@gmail.com>

---------

Signed-off-by: iceseer <iceseer@gmail.com>
  • Loading branch information
iceseer authored Mar 25, 2023
1 parent df4e400 commit 80eca0e
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions core/parachain/approval/approval_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,31 @@ namespace kagome::parachain {
validator_index);

auto &entry = opt_entry->get();
if (candidate_index >= entry.candidates.size()) {
logger_->warn(
"Unexpected candidate entry in import approval. (candidate index={}, "
"block hash={}, validator index={})",
candidate_index,
block_hash,
validator_index);
return;
}

auto &candidate_entry = entry.candidates[candidate_index];
if (auto it = candidate_entry.messages.find(validator_index);
it != candidate_entry.messages.end()) {
if (auto state{boost::get<DistribApprovalStateApproved>(
&it->second.approval_state)}) {
logger_->warn(
"Duplicate message. (candidate index={}, "
"block hash={}, validator index={})",
candidate_index,
block_hash,
validator_index);
return;
}
}

if (source) {
/// TODO(iceseer): vector-clock for knowledge
switch (check_and_import_approval(vote)) {
Expand All @@ -1493,17 +1518,6 @@ namespace kagome::parachain {
/// TODO(iceseer): vector-clock for knowledge
}

if (candidate_index >= entry.candidates.size()) {
logger_->warn(
"Unexpected candidate entry in import approval. (candidate index={}, "
"block hash={}, validator index={})",
candidate_index,
block_hash,
validator_index);
return;
}

auto &candidate_entry = entry.candidates[candidate_index];
if (auto it = candidate_entry.messages.find(validator_index);
it != candidate_entry.messages.end()) {
auto cert{
Expand Down

0 comments on commit 80eca0e

Please sign in to comment.