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

[3.2] Enhancement: Add capability of not genereating block log by setting option block-log-retain-blocks to 0 #643

Merged
merged 10 commits into from
Jul 22, 2022

Conversation

linh2931
Copy link
Member

Resolve #92.

block-log-retain-blocks option is modified to allow being set to 0, which tells nodeos not to generate blocks.log.

Now block-log-retain-blocks description looks like

  --block-log-retain-blocks arg         If set to greater than 0, periodically
                                        prune the block log to store only
                                        configured number of most recent
                                        blocks.
                                        If set to 0, no blocks are be written
                                        to the block log; block log file is
                                        removed after startup.

New unit tests and basic integration tests are added for this enhancement.

@linh2931 linh2931 requested review from heifner and spoonincode July 11, 2022 14:55
@linh2931 linh2931 self-assigned this Jul 11, 2022
@linh2931 linh2931 requested a review from matthewdarwin July 11, 2022 17:23
libraries/chain/block_log.cpp Show resolved Hide resolved
libraries/chain/block_log.cpp Show resolved Hide resolved
if (my->not_generate_block_log) {
// No blocks exist. Avoid cascading failures if going further.
return b;
}
Copy link
Member

Choose a reason for hiding this comment

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

There are a number of public methods of block_log that should also check this flag. Including: read_block, read_block_header, read_block_by_num, read_block_id_by_num, read_block_by_id, get_block_pos, read_head, flush, etc. These should all be updated to do the correct thing when in not_generate_block_log mode.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally we should have unittests around this new functionality so we can show all these work in the new mode.

libraries/chain/controller.cpp Show resolved Hide resolved

if ( my->chain_config->prune_config->prune_blocks == 0 ) {
// clear out empty blocks.log. otherwise block_log::extract_genesis_state
// will return version 0 which asserts.
Copy link
Member

Choose a reason for hiding this comment

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

How do you get into a state with a blocks.log of 0 size?

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 intentionally tested with blocks.log of 0 size. Probably it is not a valid test. Will revert this code.

return False

def start_and_stop_nodeos(retain_blocks=0, produced_block=10):
cmd=f'programs/nodeos/nodeos -e -p eosio --plugin eosio::producer_api_plugin --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::chain_plugin --data-dir {data_dir} --block-log-retain-blocks {retain_blocks}'
Copy link
Member

Choose a reason for hiding this comment

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

Should specify a --config-dir.
Also would be better to use Node.py or Cluster.py for launching.

Copy link
Member

Choose a reason for hiding this comment

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

Also consider disabling p2p & http endpoints so it can be a parallelizable test. Can Node/Cluster do that for us @heifner ?

Copy link
Member

Choose a reason for hiding this comment

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

You can start a cluster of 1 with extraNodeosArgs set with the --p2p-listen-endpoint. See almost any of the python tests.
One of the items I hope we can start on soon is making all the python integration tests able to run in parallel. By using Cluster.py when that work is done this test would pick put that ability along with it.

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 have rewritten the test using standard Cluster.py. I tried disabling p2p and http endpoints by setting --p2p-listen-endpoint and --http-server-address empty, but nodeos failed to come up due to the way Cluster.py starts nodeos. For now, I keep the test as nonparallel. Once the work of making python integration tests run in parallel is done, this test will pick up that ability without changes.

prune_config.reset();
not_generate_block_log = true;
} else {
EOS_ASSERT(prune_config->prune_blocks, block_log_exception, "block log prune configuration requires at least one 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 assert can be removed now

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I missed that assert.

linh2931 and others added 2 commits July 18, 2022 10:32
…take appropriate actions in block_log public functions when no block log mode is enabled and add corresponding unit tests, use update_head for all occasions
libraries/chain/block_log.cpp Outdated Show resolved Hide resolved
libraries/chain/block_log.cpp Outdated Show resolved Hide resolved
libraries/chain/block_log.cpp Outdated Show resolved Hide resolved
libraries/chain/block_log.cpp Outdated Show resolved Hide resolved
libraries/chain/block_log.cpp Outdated Show resolved Hide resolved
TestHelper.printSystemInfo("BEGIN")
cluster.setWalletMgr(walletMgr)

cluster.setWalletMgr(walletMgr)
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for careful reviewing! I am fixing it.

@linh2931 linh2931 merged commit b5fff95 into main Jul 22, 2022
@linh2931 linh2931 deleted the no-blocks-log branch July 22, 2022 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: allow nodeos to run in "no blocks.log" mode
3 participants