Skip to content

Commit

Permalink
GH-376 Renamed in_progress_qc_sig_t to aggregating_qc_sig_t and in_pr…
Browse files Browse the repository at this point in the history
…ogress_qc_t to aggregating_qc_t.
  • Loading branch information
heifner committed Jul 24, 2024
1 parent eccecad commit 492a79a
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 127 deletions.
16 changes: 8 additions & 8 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ block_state::block_state(const block_header_state& prev, signed_block_ptr b, con
, block(std::move(b))
, strong_digest(compute_finality_digest())
, weak_digest(create_weak_digest(strong_digest))
, in_progress_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{})
, aggregating_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{})
{
// ASSUMPTION FROM controller_impl::apply_block = all untrusted blocks will have their signatures pre-validated here
if( !skip_validate_signee ) {
Expand All @@ -37,7 +37,7 @@ block_state::block_state(const block_header_state& bhs,
, block(std::make_shared<signed_block>(signed_block_header{bhs.header}))
, strong_digest(compute_finality_digest())
, weak_digest(create_weak_digest(strong_digest))
, in_progress_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{})
, aggregating_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{})
, valid(valid)
, pub_keys_recovered(true) // called by produce_block so signature recovery of trxs must have been done
, cached_trxs(std::move(trx_metas))
Expand Down Expand Up @@ -93,8 +93,8 @@ block_state_ptr block_state::create_if_genesis_block(const block_state_legacy& b
result.strong_digest = result.compute_finality_digest(); // all block_header_state data populated in result at this point
result.weak_digest = create_weak_digest(result.strong_digest);

// in_progress_qc will not be used in the genesis block as finalizers will not vote on it, but still create it for consistency.
result.in_progress_qc = in_progress_qc_t{result.active_finalizer_policy, finalizer_policy_ptr{}};
// aggregating_qc will not be used in the genesis block as finalizers will not vote on it, but still create it for consistency.
result.aggregating_qc = aggregating_qc_t{result.active_finalizer_policy, finalizer_policy_ptr{}};

// build leaf_node and validation_tree
valid_t::finality_leaf_node_t leaf_node {
Expand Down Expand Up @@ -156,7 +156,7 @@ block_state::block_state(snapshot_detail::snapshot_block_state_v7&& sbs)
}
, strong_digest(compute_finality_digest())
, weak_digest(create_weak_digest(strong_digest))
, in_progress_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{}) // just in case we receive votes
, aggregating_qc(active_finalizer_policy, pending_finalizer_policy ? pending_finalizer_policy->second : finalizer_policy_ptr{}) // just in case we receive votes
, valid(std::move(sbs.valid))
{
header_exts = header.validate_and_extract_header_extensions();
Expand All @@ -177,17 +177,17 @@ void block_state::set_trxs_metas( deque<transaction_metadata_ptr>&& trxs_metas,
// Called from vote threads
vote_result_t block_state::aggregate_vote(uint32_t connection_id, const vote_message& vote) {
auto finalizer_digest = vote.strong ? strong_digest.to_uint8_span() : std::span<const uint8_t>(weak_digest);
return in_progress_qc.aggregate_vote(connection_id, vote, block_num(), finalizer_digest);
return aggregating_qc.aggregate_vote(connection_id, vote, block_num(), finalizer_digest);
}

// Only used for testing
vote_status_t block_state::has_voted(const bls_public_key& key) const {
return in_progress_qc.has_voted(key);
return aggregating_qc.has_voted(key);
}

// Called from net threads
void block_state::verify_qc(const qc_t& qc) const {
in_progress_qc.verify_qc(qc, strong_digest, weak_digest);
aggregating_qc.verify_qc(qc, strong_digest, weak_digest);
}

qc_claim_t block_state::extract_qc_claim() const {
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3718,15 +3718,15 @@ struct controller_impl {
block_state_ptr bsp = fork_db_fetch_bsp_on_branch_by_num(id, qc.block_num);
if (!bsp)
return {};
return bsp->in_progress_qc.vote_metrics(qc);
return bsp->aggregating_qc.vote_metrics(qc);
}


qc_vote_metrics_t::fin_auth_set_t missing_votes(const block_id_type& id, const qc_t& qc) const {
block_state_ptr bsp = fork_db_fetch_bsp_on_branch_by_num(id, qc.block_num);
if (!bsp)
return {};
return bsp->in_progress_qc.missing_votes(qc);
return bsp->aggregating_qc.missing_votes(qc);
}

// thread safe
Expand All @@ -3739,7 +3739,7 @@ struct controller_impl {
// net plugin subscribed to this signal. it will broadcast the vote message on receiving the signal
emit(voted_block, std::tuple{uint32_t{0}, vote_result_t::success, std::cref(vote)}, __FILE__, __LINE__);

// also aggregate our own vote into the in_progress_qc for this block, 0 connection_id indicates our own vote
// also aggregate our own vote into the aggregating_qc for this block, 0 connection_id indicates our own vote
process_vote_message(0, vote);
});
}
Expand Down
Loading

0 comments on commit 492a79a

Please sign in to comment.