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

snapshots: SnapshotPath.step_range #2419

Merged
merged 16 commits into from
Oct 15, 2024
Merged

snapshots: SnapshotPath.step_range #2419

merged 16 commits into from
Oct 15, 2024

Conversation

battlmonstr
Copy link
Contributor

No description provided.

@battlmonstr battlmonstr added the snapshots Framework for BitTorrent-based snapshots label Oct 12, 2024
@battlmonstr battlmonstr force-pushed the pr/step branch 2 times, most recently from 8208f2e to 16e6864 Compare October 12, 2024 16:53
@battlmonstr battlmonstr force-pushed the pr/step branch 3 times, most recently from 9d585f6 to 3fca7c4 Compare October 14, 2024 10:03
we need to always proceed to download code,
because it will only download if needed,
and because it will seed them at the same time
@battlmonstr battlmonstr force-pushed the pr/step branch 3 times, most recently from 39e3453 to d75dd11 Compare October 14, 2024 13:34
@battlmonstr battlmonstr requested a review from canepat October 14, 2024 20:14
@battlmonstr battlmonstr marked this pull request as ready for review October 14, 2024 20:14
@battlmonstr battlmonstr enabled auto-merge October 15, 2024 08:35
@canepat canepat mentioned this pull request Oct 15, 2024
41 tasks
StepRange step_range() const { return step_range_; }
SnapshotType type() const { return type_; }
std::string type_string() const;
bool exists() const { return std::filesystem::exists(path_); }
Copy link
Member

Choose a reason for hiding this comment

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

Why adding this helper method and removing similar ones for last_write_time and index_file_for_type or snapshot_path_for_type?
I'm fine with this exists helper, but I suggest to keep the existing ones as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing path_for_type is not related to steps indeed, but as I wanted to keep SnapshotPath as clean as possible, somehow I couldn't resist doing it in this PR :) I agree that the path_for_type is nice, and I will introduce it later in a different schema-related class and replace direct related_path calls to a higher level API.

The idea is that in the future SnapshotPath will be just a container for meta-data encoded in the filename + the full path. In order to get SnapshotType (and things like index_file_for_type) the code will need to consult "schema" - a new decoupled object. So instead of deducing a schema element from path, we'll normally do the other way around: deduce path(s) from schema. The few cases where we need to go from path to schema will be a new method like schema.type_of_path(path). Removing path_for_type is a preparation for this change.

snapshots::Index idx_txn_hash{transactions_segment_path->index_file_for_type(snapshots::SnapshotType::transactions), make_region(ts.tx_hash_index)};
snapshots::Index idx_txn_hash_2_block{transactions_segment_path->index_file_for_type(snapshots::SnapshotType::transactions_to_block), make_region(ts.tx_hash_2_block_index)};
snapshots::Index idx_txn_hash{transactions_segment_path->related_path(snapshots::SnapshotType::transactions, snapshots::kIdxExtension), make_region(ts.tx_hash_index)};
snapshots::Index idx_txn_hash_2_block{transactions_segment_path->related_path(snapshots::SnapshotType::transactions_to_block, snapshots::kIdxExtension), make_region(ts.tx_hash_2_block_index)};
Copy link
Member

Choose a reason for hiding this comment

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

IMO code is less readable than before


auto header_index_builder = snapshots::HeaderIndex::make(header_snapshot_path);
header_index_builder.set_base_data_id(header_snapshot_file.block_num_range().start);
Copy link
Member

Choose a reason for hiding this comment

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

Adding the public method IndexBuilder::set_base_data_id to handle custom start point only for tests is not ideal, but it's necessary to support our sample snapshots used in tests.
A better overall solution would be:

  • introduce some subcommand in snapshots command-line utility to generate (short) sample snapshots
  • use some other command-line utility (maybe new embed_binary?) to generate C++ code for sample snapshots
  • regenerate sample snapshots without custom start point (i.e. add initial empty blocks)
  • remove IndexBuilder::set_base_data_id as it becomes unnecessary

I'll open a dedicated issue on this.

@battlmonstr battlmonstr merged commit 06c901c into master Oct 15, 2024
8 checks passed
@battlmonstr battlmonstr deleted the pr/step branch October 15, 2024 14:21
@canepat canepat added the erigon3 Erigon3 feature label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erigon3 Erigon3 feature snapshots Framework for BitTorrent-based snapshots
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants