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

overlay-tree: allow resumable runs #233

Closed
wants to merge 1 commit into from

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Jul 1, 2023

This PR attempts to collect all needed changes to allow to resume a run of an overlay tree chain importing:

  • It saves started and ended markers.
  • It saves the translation roots.

The goal is to allow:

  • To stop and resume a run in the middle of the transaction to continue; that's convenient for us.
  • To stop and resume after a full conversion to allow to iterate more rapidly on the context of a fully converted tree reg performance improvements.

There's a reasonable chance that something else might be missing or needs to be fixed in this branch, since I've confirmed that as is it doesn't fully work reading the right snapshot on the second run.

Note that this PR is targeting reenable-snapshots as expected.

@jsign jsign requested review from holiman and gballet and removed request for holiman July 1, 2023 23:03
var (
dbKeyOverlayTransitionStarted = []byte("overlay-transition-started")
dbKeyOverlayTransitionEnded = []byte("overlay-transition-ended")
translatedRootPrefix = []byte("translated-")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the db key prefix for saving the root translation table.

Comment on lines -316 to +338
fdb.translatedRoots[fdb.translationIndex] = trans
fdb.origRoots[fdb.translationIndex] = orig
fdb.translationIndex = (fdb.translationIndex + 1) % len(fdb.translatedRoots)
fdb.diskdb.Put(append(translatedRootPrefix, orig.Bytes()...), trans.Bytes())
log.Info("Saved translation", "originRoot", orig.Bytes(), "translatedRoot", trans.Bytes())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Instead of writing to the map, we save into the database.
I left an extra log-info since it can help a bit after when something doesn't work.

Comment on lines +345 to 347
if err != nil {
return common.Hash{}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically speaking, this is equivalent to before. If Get returns err=leveldb.NotFound it returns common.Hash{} as before.

There's an extra border-case here if the err is related to a disk error. Very low chance for now to care about, but that needs bubbling some error in the chain. Not sure if this code will stay for long, but we can properly handle and clean up after.

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign
Copy link
Collaborator Author

jsign commented May 10, 2024

See #440

@jsign jsign closed this May 10, 2024
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.

1 participant