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

Bor waypoint storage #9793

Merged
merged 36 commits into from
Apr 29, 2024
Merged

Bor waypoint storage #9793

merged 36 commits into from
Apr 29, 2024

Conversation

mh0lt
Copy link
Collaborator

@mh0lt mh0lt commented Mar 22, 2024

Implementation of db and snapshot storage for additional synced hiemdall waypoint types

  • Checkpoint
  • Milestones

This is targeted at the Astrid downloader which uses waypoints to verify headers during syncing and fork choice selection.

Post milestones for heimdall these types are currently downloaded by erigon but not persisted locally. This change adds persistence for these types.

In addition to the pure persistence changes this PR also contains a refactor step which is part of the process of extracting polygon related types from erigon core into a seperate package which may eventually be extracted to a separate module and possibly repo.

The aim is rather than the core turbo\snapshotsync\freezeblocks having to know about types it manages and how to exaract and index their contents this can concern it self with a set of macro shard management actions.

This process is partially completed by this PR, a final step will be to remove BorSnapshots and to simplify the places in the code which has to remeber to deal with them. This requires further testing so has been left out of this PR to avoid delays in delivering the base types.

Status

  • Waypont types and storage are complete and integrated in to the BorHeimdall stage, The code has been tested to check that types are inserted into mdbx, extracted and merged correctly
  • I have verified that when produced from block 0 the new snapshot correctly follow the merging strategy of existing snapshots
  • The functionality is enables by a --bor.waypoints=true this is false by default.

Testing

This has been tested as follows:

  • Run a Mumbai instance to the tip and check current processing for milestones and checkpoints

Post merge steps

  • Produce and release snapshots for mumbai and bor mainnet
  • Check existing node upgrades
  • Remove --bor.waypoints flags

},
indexes: []Index{Indexes.TxnHash, Indexes.TxnHash2BlockNum},
indexBuilder: IndexBuilderFunc(
func(ctx context.Context, sn FileInfo, chainConfig *chain.Config, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer this to be a named function.

defer d.EnableMadvNormal().DisableReadAhead()
defer bodiesSegment.EnableMadvNormal().DisableReadAhead()

RETRY:
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider using a for loop

@@ -117,6 +116,207 @@ func fetchAndWriteHeimdallSpan(
return spanID, nil
}

func fetchRequiredHeimdallCheckpointsIfNeeded(
Copy link
Collaborator

Choose a reason for hiding this comment

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

revise the function name:

  • not clear what is meant by "required"?
  • there's a function fetchAndWrite, so this one is not expected to write, or it should it be fetchAndWrite as well?

alternative names: fetchAndWriteMissingHeimdallCheckpoints, fetchAndWriteHeimdallCheckpointsIfNeeded

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have just followed the existing language used in this file. I guess I can change all of them to make them more consistent.

}),
[]snaptype.Index{snaptype.Indexes.BorTxnHash},
snaptype.IndexBuilderFunc(
func(ctx context.Context, sn snaptype.FileInfo, chainConfig *chain.Config, tmpDir string, p *background.Progress, lvl log.Lvl, logger log.Logger) (err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer this to be a named function.

@@ -72,15 +78,20 @@ func (m *Milestone) MarshalJSON() ([]byte, error) {
}

func (m *Milestone) UnmarshalJSON(b []byte) error {

// TODO - do we want to handle milestone_id ?
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you mean? what benefits doest it have? what if we don't handle it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know - hence the question. There seems to be a long hiemdall id sent on the json message. I don't know what it is, it seems different from the id passed between erigon & heimdall. I assume we can ignore it but am not 100% sure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to replace a TODO comment with a comment like: ignoring an unused milestone_id, which looks like ... to not bother us with thinking about whether or not to do this TODO :) I feel that TODO is like a promise, and I prefer to follow a rule that all TODOs are either fixed, removed or moved to the task tracker within a limited time frame.

Copy link

sonarcloud bot commented Apr 1, 2024

Quality Gate Passed Quality Gate passed

Issues
29 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.9% Duplication on New Code

See analysis details on SonarCloud

@mh0lt mh0lt marked this pull request as ready for review April 9, 2024 17:07
@mh0lt mh0lt changed the title [WIP] Bor waypoint storage Bor waypoint storage Apr 27, 2024
@mh0lt mh0lt merged commit 714c259 into devel Apr 29, 2024
7 checks passed
@mh0lt mh0lt deleted the bor_waypoint_storage branch April 29, 2024 17:31
@ghost ghost mentioned this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants