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

Improve fork database logging #163

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,9 @@ struct controller_impl {

auto pending_head = forkdb.pending_head();
if( pending_head && blog_head && start_block_num <= blog_head->block_num() ) {
ilog( "fork database head ${h}, root ${r}", ("h", pending_head->block_num())( "r", forkdb.root()->block_num() ) );
ilog("fork database head ${hn}:${h}, root ${rn}:${r}",
("hn", pending_head->block_num())("h", pending_head->id())
("rn", forkdb.root()->block_num())("r", forkdb.root()->id()));
if( pending_head->block_num() < chain_head.block_num() || chain_head.block_num() < forkdb.root()->block_num() ) {
ilog( "resetting fork database with new last irreversible block as the new root: ${id}", ("id", chain_head.id()) );
fork_db_reset_root_to_chain_head();
Expand Down
7 changes: 5 additions & 2 deletions libraries/chain/fork_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ namespace eosio::chain {
void fork_database_impl<BSP>::close_impl(std::ofstream& out) {
assert(!!head && !!root); // if head or root are null, we don't save and shouldn't get here

ilog("Writing fork_database with root ${rn}:${r} and head ${hn}:${h}",
("rn", root->block_num())("r", root->id())("hn", head->block_num())("h", head->id()));

fc::raw::pack( out, *root );

uint32_t num_blocks_in_fork_db = index.size();
Expand Down Expand Up @@ -719,8 +722,7 @@ namespace eosio::chain {
auto in_use_value = in_use.load();
// check that fork_dbs are in a consistent state
if (!legacy_valid && !savanna_valid) {
wlog( "fork_database is in a bad state when closing; not writing out '${filename}', legacy_valid=${l}, savanna_valid=${s}",
("filename", fork_db_file)("l", legacy_valid)("s", savanna_valid) );
ilog("No fork_database to persist");
return;
} else if (legacy_valid && savanna_valid && in_use_value == in_use_t::savanna) {
legacy_valid = false; // don't write legacy if not needed, we delay 'clear' of legacy until close
Expand All @@ -729,6 +731,7 @@ namespace eosio::chain {
(savanna_valid && (in_use_value == in_use_t::savanna)) ||
(legacy_valid && savanna_valid && (in_use_value == in_use_t::both)) );

ilog("Persisting to fork_database file: ${f}", ("f", fork_db_file));
std::ofstream out( fork_db_file.generic_string().c_str(), std::ios::out | std::ios::binary | std::ofstream::trunc );

fc::raw::pack( out, magic_number );
Expand Down
Loading