Skip to content

Commit

Permalink
Add signature to block in edge case
Browse files Browse the repository at this point in the history
If we receive a signature that we have in memory but it is not in the
header yet we need to still add it.
  • Loading branch information
hewison-chris committed Mar 14, 2022
1 parent e50aaa2 commit f13fa34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/agora/consensus/protocol/Nominator.d
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,11 @@ extern(D):

Block block = pendingBlockSig ? this.pending_block : this.ledger.getBlocksFrom(Height(block_sig.height)).front;

if (this.collectBlockSignature(block_sig, block.hashFull()))
// Only update if it is valid and we are missing signatures and this is one of them
if (this.collectBlockSignature(block_sig, block.hashFull())
&& block.header.validators.setCount < block.header.preimages.map!(p => p != Hash.init).count()
&& !block.header.validators[this.enroll_man.validator_set
.getValidators(block.header.height).map!(v => v.utxo()).countUntil(block_sig.utxo)])
{
log.dbg("{}: Signature is for {} block #{}",
__FUNCTION__, pendingBlockSig ? "pending" : "ledger", block.header.height);
Expand All @@ -872,6 +876,8 @@ extern(D):
else
{
this.updateMultiSignature(block.header);
log.dbg("{}: mask now {} for block #{}",
__FUNCTION__, block.header.validators, block.header.height);
this.ledger.updateBlockMultiSig(block.header);
return block.header;
}
Expand Down Expand Up @@ -1059,7 +1065,7 @@ extern(D):
if (sigs && block_sig.utxo in (*sigs))
{
log.trace("Signature already collected for this node at height {}", block_sig.height);
return false;
return true;
}

// Using `assumeSorted` and `getValidator` being a random access range
Expand Down

0 comments on commit f13fa34

Please sign in to comment.