Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IF: Unification: Changes in controller to complete unification - Part 2 #2077

Merged
merged 25 commits into from
Jan 16, 2024

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented Jan 11, 2024

Resolves #2034.
Resolves #2047.

@greg7mdp greg7mdp changed the base branch from main to hotstuff_integration January 11, 2024 21:56
@greg7mdp greg7mdp marked this pull request as draft January 11, 2024 21:56
@@ -930,7 +939,7 @@ struct controller_impl {
cfg.state_size, false, cfg.db_map_mode ),
blog( cfg.blocks_dir, cfg.blog ),
block_data(block_data_t::block_data_variant{
std::in_place_type<block_data_legacy_t>, // [greg todo] create correct type depending on whether IF activated
std::in_place_type<block_data_legacy_t>, // initial state is always dpos
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that will be true after IF is enabled on startup, but fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I thought I asked and we said we would always go through the transition, but I was thinking it might not be true when we start from a snapshot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will always go through the transition when starting a new chain. We have no immediate plans to add the feature of enabling protocol feature activation in genesis.
Startup of nodeos after transition will start with state (either from chainbase or snapshot) that is in IF mode.

@@ -2917,7 +2931,8 @@ struct controller_impl {
}

auto do_push = [&](auto& fork_db, auto& head) {
fork_db.add( bsp );
if constexpr (std::is_same_v<BSP, typename std::decay_t<decltype(head)>>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is really ugly, would be nice to find a way not to have these if constexpr.

}

void controller::push_block( controller::block_report& br,
const block_state_ptr& bsp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we will want to public push_block like this. Users of controller shouldn't need to know which one to call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I agree and ideally the block_state struct should not be visible outside libraries/chain. But I thought that if create_block_state and create_block_state_future were needed maybe push_block as well? We can certainly remove these if not needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worse case we have some type that controller provides via something like create_block_start_state() that controller::push_block breaks apart and calls the appropriate controller_impl::push_block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now until we get the create_block_state() and create_block_state_future() fixed.

@greg7mdp greg7mdp marked this pull request as ready for review January 12, 2024 14:18
@greg7mdp greg7mdp requested a review from linh2931 January 12, 2024 14:18
}

#warning Add last_proposed_finalizer_policy_generation to snapshot_block_header_state_v3, see header file TODO

block_header_state_core block_header_state_core::next(const uint32_t last_qc_block_num, bool is_last_qc_strong) const {
block_header_state_core block_header_state_core::next(qc_info_t incoming) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not const &?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing by reference (indirection with a pointer) would actually be slower since the whole struct is 8 bytes.

libraries/chain/controller.cpp Outdated Show resolved Hide resolved
libraries/chain/controller.cpp Show resolved Hide resolved
@@ -201,6 +207,29 @@ struct block_data_t {
return std::visit([](const auto& bd) -> const signed_block_ptr& { return bd.head->block; }, v);
}

void replace_producer_keys( const public_key_type& key ) {
ilog("Replace producer keys with ${k}", ("k", key));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to log it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @heifner added this, but I don't see the harm in logging it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is public keys so no harm. Useful to see it working.

if( s != controller::block_status::irreversible ) {
fork_db.add( bsp, true );
}
if (s != controller::block_status::irreversible) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change those existing styles. Lots of places using this if( .

@@ -21,11 +21,13 @@ namespace eosio::chain {
*
* An internal mutex is used to provide thread-safety.
*/
template<class bsp, class bhsp> // either [block_state_legacy_ptr, block_state_ptr], same with block_header_state_ptr
template<class bsp> // either block_state_legacy_ptr or block_state_ptr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conventionally template type should be capitalized as BSP.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change.

@greg7mdp greg7mdp merged commit 70b9797 into hotstuff_integration Jan 16, 2024
26 checks passed
@greg7mdp greg7mdp deleted the gh_2034_part2 branch January 16, 2024 02:44
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: INTERNALS
summary: Finish data structures to allow assembling of blocks under new Faster Finality.
Note: end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants