-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
core: generic test suite for AncientStore #23707
Conversation
I'd like to get #23566 merged before this one. |
core/rawdb/freezer.go
Outdated
@@ -190,15 +182,15 @@ func (f *freezer) HasAncient(kind string, number uint64) (bool, error) { | |||
if table := f.tables[kind]; table != nil { | |||
return table.has(number), nil | |||
} | |||
return false, nil | |||
return false, ethdb.ErrAncientUnknownKind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please notice this change. It looked like a mistake to me so I fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looks like this method can be deleted from the codebase now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it in ba1cee60f69bb2e3b6788f5ef4ffb0de923b5731
I am, but I don't expect a stable interface. I'm just trying to smooth things from a development perspective:
|
Speaking of One thing I noticed is that it does pretty much force the implementation to have a separate storage for each That said, I don't have enough insight at the moment to say if that approach would be valuable so that might be entirely irrelevant. |
I'm not sure that's a valid assumption. When someone is syncing from you, they might first get header in ranges from you, then spread out the body download among a set of peers, and you'll serve bodies here and there which may or may not line up with what you delivered earlier. The PR I linked above, however, with the batched reads, is more in line with your proposed schema, however. It gives the reader a consistent interface, meaning that when doing a batched read, the individual fields are guaranteed to be in lock-step with one-another (but not forcing the fields to all be loaded from disk when one is read) |
97db15f
to
0665d4f
Compare
Following on this idea, I made two small changes for the
|
The #23566 PR is now merged, I guess this will need to be updated? |
0665d4f
to
ded6810
Compare
@holiman I rebased and removed |
Note: it would make sense to extend |
ba1cee6
to
1e30457
Compare
I completed the test suite to cover those. I'm really done this time! (maybe?) |
@holiman would it be time to merge this? |
We discussed this yesteday on our PR triage, and there remains some hesitancy about this, again. Same as I wrote earlier:
Merging this change makes it harder for us to change the API, and we're not sure that we've arrived at the Perfect API yet. Things may (and do) still change, and having to worry about the third-part impact another public API is cumbersome. |
I promise I really don't expect this API to be stable. As a maintainer myself I know it's uncomfortable to expose internals but that's not what I'm trying to do here. I'm merely trying to make this API easier to use, maintain and build on. This PR document some existing behavior, allow to distinguish some failure mode (not found vs actual error) and generalize/clean the test suite. I believe those changes are useful, regardless if I'm using the API as a third party or not. |
If that helps, those interfaces could be marked as internal/unstable. |
Hi @holiman. What would it take to get this PR accepted? Michael is on the Infura team and as he mentioned, we're working on an alternative ancient store experiment that we'd like to share if the experiment works out after load testing. We are fully content to accept that we are building on an internal API which will change in the future and we don't expect this to be maintained as a public API. If there are additional changes you'd like us to make to this PR before it can be merged please let us know. |
@egalano we'll discuss it internally again next triage |
Triage discussion: we'll do another round of review on this PR |
We've discussed to get this PR in, but we need to finish and merge a prerequisite first (#23954) as that also changes the code and interfaces a bit. |
We're tentatively agreeing that this PR could be an ok addition, but as said earlier: the freezer API is still not stable. So this PR has bitrotted a bit and needs a rebase, and further, we have more changes in the pipeline, such as #23954 |
d18d329
to
6323523
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments.
@@ -129,9 +154,11 @@ type AncientWriter interface { | |||
// AncientWriteOp is given to the function argument of ModifyAncients. | |||
type AncientWriteOp interface { | |||
// Append adds an RLP-encoded item. | |||
// Returns ErrAncientOutOrderInsertion if attempting to insert items out of order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this kind should also be checked and return the ErrAncientUnknownKind
if necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. freezerBatch
currently panic if an unknown kind is used. While that would make sense to return ErrAncientUnknownKind
, it also would be a programming error to provide an unknown kind rather than a runtime problem, so a panic seems more appropriate.
Which one do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to panic
, if that's what we already do. Writing wrong kind is definitely a huge programming error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ready to merge then.
btw, I just want you know that we may change the database interface again which introduces the ancient store routing. #24481 My PR is not reviewed right now, but it's kind of necessary. |
Refactor the freezer test suite into one that can be used for other AncientStore implementation. To achieve that, a subset of previously private errors have been promoted as part of the AncientStore interface. Untangle some code in the process: I believe freezer can now be extracted from rawdb if that's deemed beneficial.
This allow to distinguish between not found and an actual read error. Also allow for fancy layering on top of a KeyValueStore. Also, document KeyValueWriter.Delete as idempotent.
6323523
to
a9ac20d
Compare
I think it's good to go now. I can still adjust #23707 (comment) if I get an answer.
That's completely fine. Again, I'm not expecting to have a stable interface, I'm just trying to make things easier to work with for all of us: well defined interfaces and reusable test suite. |
A similar test suite was finally added by #29135, in package core/rawdb/ancienttest |
Thanks for letting me know, but also, quite some wasted effort and time ... |
I don't necessarily see it that way. We sometimes leave PRs open to be reminded that there is demand for a feature. At the time this was originally proposed, we weren't sure where we'd be going with the ancients interface. Now we now better, and have refactored the interface to be usable for more things than just storing historical blocks. At the same time, I can understand it's frustrating to see us coming to our senses way late :) |
Refactor the freezer test suite into one that can be used for other AncientStore implementation. Ultimately that simplify greatly having an alternative implementation.
To achieve that, a subset of previously private errors have been promoted as part of the AncientStore interface.
Untangle some code in the process: I believe freezer can now be extracted from rawdb if that's
deemed beneficial.
CC @holiman, I believe you are the one to bug about that.