Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

implement splitting/extracting block log for eosio_blocklog #10037

Merged
merged 4 commits into from
Feb 16, 2021

Conversation

huangminghuang
Copy link
Contributor

Change Description

implement splitting/extracting block log for eosio_blocklog

Change Type

Select ONE:

  • Documentation
  • Stability bug fix
  • Other
  • Other - special case

Testing Changes

Select ANY that apply:

  • New Tests
  • Existing Tests
  • Test Framework
  • CI System
  • Other

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • [x ] Documentation Additions
    eosio_blocklog added two new options
    • split-blocklog: split the block log file based on the stride and store the result in the specified 'output-dir'
    • extract-blocklog: extract blocks from blocks.log and blocks.index and keep the original .

@matthewdarwin
Copy link

Documentation related comments:

  1. Can you use this tool to change take existing strides and make them smaller?
  2. Can you use this tool to change take existing strides and make them bigger?
  3. What happens when the input is part of the block log (eg existing blocks split in strides is missing one of the strides)?

Or does this tool strictly work only with the full block.log file?

@huangminghuang
Copy link
Contributor Author

Documentation related comments:

  1. Can you use this tool to change take existing strides and make them smaller?
  2. Can you use this tool to change take existing strides and make them bigger?
  3. What happens when the input is part of the block log (eg existing blocks split in strides is missing one of the strides)?

Or does this tool strictly work only with the full block.log file?

So far, it only works with full block.log file. For more complex stride adjusting, it should be implemented as script instead of in the eosio_blocklog tool.

EOS_ASSERT(start_block_num >= log_bundle.log_data.first_block_num(), block_log_exception,
"The first available block is block ${first_block}.", ("first_block", log_bundle.log_data.first_block_num()));

EOS_ASSERT(start_block_num + num_blocks -1 <= log_bundle.log_data.last_block_num(), block_log_exception,
Copy link
Contributor

Choose a reason for hiding this comment

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

"-1" => "- 1"

for (uint32_t i = first_block_num / stride;
i < last_block_num / stride + 1; ++i) {
uint32_t start_block_num = std::max(i * stride + 1, first_block_num);
uint32_t num_blocks = std::min(stride, last_block_num - start_block_num + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to start this loop with a little more complexity, if stride=1000, first_block_num=999, and last_block_num=2000 we will have
i=0 => start_block_num=999, num_blocks=1000
i=1 => start_block_num=1001, num_blocks=1000
i=2 => start_block_num=2001, num_blocks=0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You were looking at outdated code

@huangminghuang huangminghuang merged commit ed588bf into develop Feb 16, 2021
@brianjohnson5972 brianjohnson5972 deleted the huangminghuang/split-blocklog branch February 16, 2021 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants