Skip to content

Commit

Permalink
GH-2045 Rename finalize_block to finish_block to avoid confusion with…
Browse files Browse the repository at this point in the history
… finalizing a block in instant finality
  • Loading branch information
heifner committed Jan 12, 2024
1 parent 8e3dca2 commit 3b15160
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/block_production/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ flowchart TD
direction TB
start -- "stage = Ø" --> sb
sb("start_block()"):::fun -- "stage = building_block" --> et
et["execute transactions" ] -- "stage = building_block" --> fb("finalize_block()"):::fun
et["execute transactions" ] -- "stage = building_block" --> fb("finish_block()"):::fun
fb -- "stage = assembled block" --> cb["add transaction metadata and create completed block"]
cb -- "stage = completed block" --> commit("commit_block() (where we [maybe] add to fork_db and mark valid)"):::fun
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2608,7 +2608,7 @@ struct controller_impl {
guard_pending.cancel();
} /// start_block

void finalize_block()
void finish_block()
{
EOS_ASSERT( pending, block_validate_exception, "it is not valid to finalize when there is no pending block");
EOS_ASSERT( std::holds_alternative<building_block>(pending->_block_stage), block_validate_exception, "already called finalize_block");
Expand Down Expand Up @@ -2888,7 +2888,7 @@ struct controller_impl {
("lhs", r)("rhs", static_cast<const transaction_receipt_header&>(receipt)) );
}

finalize_block();
finish_block();

auto& ab = std::get<assembled_block>(pending->_block_stage);

Expand Down Expand Up @@ -3749,10 +3749,10 @@ void controller::start_block( block_timestamp_type when,
bs, std::optional<block_id_type>(), deadline );
}

void controller::finalize_block( block_report& br, const signer_callback_type& signer_callback ) {
void controller::finish_block( block_report& br, const signer_callback_type& signer_callback ) {
validate_db_available_size();

my->finalize_block();
my->finish_block();

auto& ab = std::get<assembled_block>(my->pending->_block_stage);
my->pending->_block_stage = ab.make_completed_block(
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/hotstuff/chain_pacemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace eosio::chain {
if (_active_finalizer_policy.generation == 0) {
ilog("Switching to instant finality at block ${b}", ("b", block->block_num()));
// switching from dpos to hotstuff, all nodes will switch at same block height
// block header extension is set in finalize_block to value set by host function set_finalizers
// block header extension is set in finish_block to value set by host function set_finalizers
_chain->set_hs_irreversible_block_num(block->block_num()); // can be any value <= dpos lib
}
auto if_extension = std::get<instant_finality_extension>(*ext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct pending_block_header_state_legacy : public detail::block_header_state_leg
* start_block -> (global_property_object.proposed_schedule_block_num == dpos_lib)
* building_block._new_pending_producer_schedule = producers
*
* finalize_block ->
* finish_block ->
* block_header.extensions.wtmsig_block_signatures = producers
* block_header.new_producers = producers
*
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace eosio::chain {
fc::microseconds total_time{};
};

void finalize_block( block_report& br, const signer_callback_type& signer_callback );
void finish_block( block_report& br, const signer_callback_type& signer_callback );
void sign_block( const signer_callback_type& signer_callback );
void commit_block();

Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/resource_limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void resource_limits_manager::set_block_parameters(const elastic_limit_parameter
c.cpu_limit_parameters = cpu_limit_parameters;
c.net_limit_parameters = net_limit_parameters;

// set_block_parameters is called by controller::finalize_block,
// set_block_parameters is called by controller::finish_block,
// where transaction specific logging is not possible
if (auto dm_logger = _get_deep_mind_logger(false)) {
dm_logger->on_update_resource_limits_config(c);
Expand Down Expand Up @@ -359,7 +359,7 @@ void resource_limits_manager::process_account_limit_updates() {
multi_index.remove(*itr);
}

// process_account_limit_updates is called by controller::finalize_block,
// process_account_limit_updates is called by controller::finish_block,
// where transaction specific logging is not possible
if (auto dm_logger = _get_deep_mind_logger(false)) {
dm_logger->on_update_resource_limits_state(state);
Expand All @@ -381,7 +381,7 @@ void resource_limits_manager::process_block_usage(uint32_t block_num) {
state.update_virtual_net_limit(config);
state.pending_net_usage = 0;

// process_block_usage is called by controller::finalize_block,
// process_block_usage is called by controller::finish,
// where transaction specific logging is not possible
if (auto dm_logger = _get_deep_mind_logger(false)) {
dm_logger->on_update_resource_limits_state(state);
Expand Down
2 changes: 1 addition & 1 deletion libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ namespace eosio { namespace testing {
});

controller::block_report br;
control->finalize_block( br, [&]( digest_type d ) {
control->finish_block( br, [&]( digest_type d ) {
std::vector<signature_type> result;
result.reserve(signing_keys.size());
for (const auto& k: signing_keys)
Expand Down
2 changes: 1 addition & 1 deletion plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,7 @@ void producer_plugin_impl::produce_block() {

// idump( (fc::time_point::now() - chain.pending_block_time()) );
controller::block_report br;
chain.finalize_block(br, [&](const digest_type& d) {
chain.finish_block(br, [&](const digest_type& d) {
auto debug_logger = maybe_make_debug_time_logger();
vector<signature_type> sigs;
sigs.reserve(relevant_providers.size());
Expand Down

0 comments on commit 3b15160

Please sign in to comment.