-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
fetch past objects #4367
fetch past objects #4367
Conversation
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 recommend naming all the seq_num
in rpc interfaces to something like seq_num_debug
and document that this is for short-term debugging only, so that people don't end up depending on historic objects to be always available.
crates/sui-types/src/object.rs
Outdated
@@ -640,6 +640,14 @@ pub enum ObjectRead { | |||
NotExists(ObjectID), | |||
Exists(ObjectRef, Object, Option<MoveStructLayout>), | |||
Deleted(ObjectRef), | |||
/// The object exists but not found in this node (could be pruned) | |||
ExistsButPastNotFound(ObjectID, SequenceNumber), |
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 ExistsButVersionNotFound
is probably a better name.
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.
indeed, thanks for the suggestion
Even in archival/partial node, we can't assume every object can be found in a node. I think we should educate callers about the potential unavailability in general by having better documents/comments. The term |
hmm do you actually want people to use this API? I was under the impression that only we developers would ever use it for debugging purposes. |
@lxfind @sblackshear mentioned in #3992 (comment) this might be something required by exchanges. It could also power some interesting features on the Explorer side to show object history. If we have consistent pruning policy(e.g., only store up to 5 most recent versions) and make it clear to the users, does it resolve your concern? |
This is great and definitely useful for the exchanges! But I think we will need a bit more than this to satisfy exchanges requirement.... what the exchange need (at lease for Rosetta) is a view of accounts at a particular slice of time/ block height/ checkpoint. Our seq numbers are local to the object, to get a global view at a certain block height/ checkpoint we will need to work out the seq number for all object at that time, which we don't store at the moment (can we store this information with checkpoint?) and it's hard to compute. |
Wow, do we really need to do this? its going to be a bit tricky |
crates/sui-json-rpc/src/read_api.rs
Outdated
@@ -74,10 +75,14 @@ impl RpcReadApiServer for ReadApi { | |||
.collect()) | |||
} | |||
|
|||
async fn get_object(&self, object_id: ObjectID) -> RpcResult<GetObjectDataResponse> { | |||
async fn get_object( |
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 might make a lot more sense to leave this API as is, and add a new API called get_archived_object_version
or something similar. This would:
- Keep this API simpler - it can continue returning the exists/not-exists/deleted enum.
- Simplify the implementation of
get_object_read
which is now very confusing. - Make it clearer to the user that they are trying to access an archive, not live state, which may be pruned.
- Simplify the error return values.
However, If you choose to continue with the current approach, may I then suggest the following:
- Merge
SequenceNumberTooHigh
intoNotExists
. - Rename
ExistsButPastNotFound
toObjectVersionPruned
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.
@mystenmark Split into two functions. ExistsButPastNotFound
renamed to VersionNotFound
. I kept VersionTooHigh
as it's trivial to tell and may be helpful to callers
IMO the node should have the flexibility to configure their pruning policy to fit their own business needs. What matters here is the caller of these apis should NOT be surprised to see a past object does not reside in this node. If they are, then they should talk to the node operators. |
How much coarseness can Resetta tolerate? Seq num is not the right identifier here. Checkpoint is much more suitable but it's a big interval. |
c45b03a
to
9adcc13
Compare
The issue is not the coarseness, in Sui we are object based, we can easily work out the history of an object, however Rosetta is interested in account/ ownership of object at a past checkpoint, which we don't currently store.... |
I think what we will eventually end up will be a specialized implementation of indexer/fullnode to support Rosetta API. For instance, we can maintain an account address balance history table, and update it at checkpoint boundaries. |
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.
2 minor comments, otherwise LGTM
9adcc13
to
50e6f1f
Compare
50e6f1f
to
a7fb2f0
Compare
a7fb2f0
to
3e3f339
Compare
as title. Add for debugging purposes but should be useful for explorer and other use cases too.
meat is in
authority.rs
.ExistsButPastNotFound
is awkward, so plz suggest a better name if you have one.