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

Normalize usage of LIB #918

Merged
merged 6 commits into from
Oct 11, 2024
Merged

Normalize usage of LIB #918

merged 6 commits into from
Oct 11, 2024

Conversation

heifner
Copy link
Member

@heifner heifner commented Oct 9, 2024

Most of the changes involve using froot instead of lib.

Did not change the interface of tester to avoid uses having to update their tests.
get_info was unchanged; it still reports last_irreversible_block_num and last_irreversible_block_id for forkdb_root_block_num and forkdb_root_block_id.

Resolves #806

…[num|id].

Use froot in logs that reference fork_db_root_block_num.
@heifner heifner requested review from greg7mdp and linh2931 October 9, 2024 21:44
@heifner heifner added the OCI Work exclusive to OCI team label Oct 9, 2024
Comment on lines 336 to 340
uint32_t fork_db_root_block_num() const;
// thread-safe, only valid if fork_db_has_root()
block_id_type fork_db_root_block_id() const;
// thread-safe, only valid if fork_db_has_root()
time_point fork_db_root_block_time() const;
Copy link
Contributor

@greg7mdp greg7mdp Oct 9, 2024

Choose a reason for hiding this comment

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

I think a better API would be to return a block_handle here, even if it involves a signed_block_ptr copy.

Copy link
Member Author

Choose a reason for hiding this comment

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

A signed_block does not provide an efficient .id() call.

Copy link
Contributor

Choose a reason for hiding this comment

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

my bad, I misspoke, the block_handle contains the block_state_ptr not signed_block_ptr.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh right. Sure might as well match fork_db_head()

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 423 to 424
block_id_type fork_root_id;
uint32_t fork_root_num = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not froot?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was matching the existing fork_head_ members.

chain_info_t get_chain_info() const;
uint32_t get_chain_lib_num() const;
uint32_t get_fork_root_num() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

froot here to I think for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, we have a get_fork_head_num. Seems better to spell it out.

my_impl->connections.for_each_block_connection( [&highest_lib_num]( const auto& cc ) {
// Closing connection, therefore its view of froot can no longer be considered as we will no longer be connected.
// Determine current froot of remaining peers as our sync_known_froot_num.
uint32_t highest_fork_root_num = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

froot

Copy link
Member Author

Choose a reason for hiding this comment

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

Matches the handshake fork_root_num.

@@ -2049,9 +2049,9 @@ namespace eosio {

auto reset_on_failure = [&]() REQUIRES(sync_mtx) {
sync_source.reset();
sync_known_lib_num = chain_info.lib_num;
sync_known_froot_num = chain_info.fork_root_num;
Copy link
Contributor

Choose a reason for hiding this comment

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

froot here and all other fork_root locations.

Copy link
Member Author

@heifner heifner Oct 10, 2024

Choose a reason for hiding this comment

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

I think I would rather go the other direction. Change froot to fork_root except in logging. I do see it is currently inconsistent. I'm happy to go either way with this. Change froot to fork_root in code (leave as froot in logging). Or use froot and also fhead throughout. @linh2931 thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

whatever we choose let's be consistent throughout in the code.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer fork_root as it spells out what it really is; it is not long. The f in froot can be anything, it can even be be thought of finality.

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed froot to fork_root.

Comment on lines 1289 to 1290
auto fork_root = db.fork_db_root();
auto fork_head = db.fork_db_head();
Copy link
Contributor

Choose a reason for hiding this comment

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

Now this seems inconsistent. Why do we have both fork_root and fork_db_root at different spots in the code?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like fork_root because it sounds like is the the root of a fork, not of fork_db. If we are going to spell it out, I think it should be fork_db_root everywhere, although I did prefer the shorter froot :-).

@linh2931
Copy link
Member

Another thing I noticed we have fork_db and forkdb. Probably we should use only one of them (at least easier for search)

@linh2931
Copy link
Member

Another thing I noticed we have fork_db and forkdb. Probably we should use only one of them (at least easier for search)

Maybe another PR to clean up all of those forkdb, fork_db usages, froot, ...

@greg7mdp
Copy link
Contributor

Maybe another PR to clean up all of those forkdb, fork_db usages, froot, ...

This is the PR to normalize the usage... I think get it right here.

@heifner heifner merged commit 460af47 into main Oct 11, 2024
36 checks passed
@heifner heifner deleted the GH-806-lib branch October 11, 2024 11:32
@ericpassmore
Copy link
Contributor

Note:start
category: Chores
component: Internal
summary: Normalize usage of LIB.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Normalize LIB nomenclature
4 participants