Skip to content

Commit

Permalink
GH-646 Add try-catch-log-and-drop on bls_signature creation to avoid …
Browse files Browse the repository at this point in the history
…an exception killing the thread pool
  • Loading branch information
heifner committed Aug 28, 2024
1 parent 446c959 commit 67c9256
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions libraries/chain/finality/finalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ vote_message_ptr finalizer::maybe_vote(const bls_public_key& pub_key,
const digest_type& digest) {
finalizer::vote_decision decision = decide_vote(bsp).decision;
if (decision == vote_decision::strong_vote || decision == vote_decision::weak_vote) {
bls_signature sig;
if (decision == vote_decision::weak_vote) {
// if voting weak, the digest to sign should be a hash of the concatenation of the finalizer_digest
// and the string "WEAK"
sig = priv_key.sign(create_weak_digest(digest));
} else {
sig = priv_key.sign({(uint8_t*)digest.data(), (uint8_t*)digest.data() + digest.data_size()});
}
return std::make_shared<vote_message>(bsp->id(), decision == vote_decision::strong_vote, pub_key, sig);
try {
bls_signature sig;
if (decision == vote_decision::weak_vote) {
// if voting weak, the digest to sign should be a hash of the concatenation of the finalizer_digest
// and the string "WEAK"
sig = priv_key.sign(create_weak_digest(digest));
} else {
sig = priv_key.sign({(uint8_t*)digest.data(), (uint8_t*)digest.data() + digest.data_size()});
}
return std::make_shared<vote_message>(bsp->id(), decision == vote_decision::strong_vote, pub_key, sig);
} FC_LOG_AND_DROP() // bls_signature can throw if invalid signature
}
return {};
}
Expand Down

0 comments on commit 67c9256

Please sign in to comment.