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

fetch past objects #4367

Merged
merged 4 commits into from
Sep 9, 2022
Merged

fetch past objects #4367

merged 4 commits into from
Sep 9, 2022

Conversation

longbowlu
Copy link
Contributor

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.

Copy link
Contributor

@lxfind lxfind left a 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.

@@ -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),
Copy link
Contributor

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.

Copy link
Contributor Author

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

@longbowlu
Copy link
Contributor Author

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.

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 debug daunts people from using it even though it's helpful

@lxfind
Copy link
Contributor

lxfind commented Aug 30, 2022

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.
Is there a scenario you have in mind that applications/clients might want to use it? I am worried that people might think this is a feature they could ever depend on.

@666lcz
Copy link
Contributor

666lcz commented Aug 30, 2022

@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?

@patrickkuo
Copy link
Contributor

patrickkuo commented Aug 30, 2022

@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.

@mystenmark
Copy link
Contributor

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

Wow, do we really need to do this? its going to be a bit tricky

@@ -74,10 +75,14 @@ impl RpcReadApiServer for ReadApi {
.collect())
}

async fn get_object(&self, object_id: ObjectID) -> RpcResult<GetObjectDataResponse> {
async fn get_object(
Copy link
Contributor

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 into NotExists.
  • Rename ExistsButPastNotFound to ObjectVersionPruned

Copy link
Contributor Author

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

@longbowlu
Copy link
Contributor Author

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?

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.

@longbowlu
Copy link
Contributor Author

longbowlu commented Aug 30, 2022

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.

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.

@longbowlu longbowlu force-pushed the fetch_past_object branch 2 times, most recently from c45b03a to 9adcc13 Compare September 2, 2022 22:20
@patrickkuo
Copy link
Contributor

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.

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.

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....

@lxfind
Copy link
Contributor

lxfind commented Sep 3, 2022

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.

Copy link
Contributor

@patrickkuo patrickkuo left a 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

crates/sui-json-rpc/src/api.rs Outdated Show resolved Hide resolved
crates/sui-json-rpc/src/gateway_api.rs Outdated Show resolved Hide resolved
crates/sui-json-rpc-types/src/lib.rs Show resolved Hide resolved
crates/sui-json-rpc-types/src/lib.rs Show resolved Hide resolved
crates/sui-types/src/error.rs Outdated Show resolved Hide resolved
@longbowlu longbowlu merged commit 2bf1304 into main Sep 9, 2022
@longbowlu longbowlu deleted the fetch_past_object branch September 9, 2022 08:12
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.

5 participants