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

[rooch-rpc-api] SyncStateFilter of the syncStates method supports filtering by application #2838

Open
yubing744 opened this issue Oct 31, 2024 · 2 comments
Assignees
Labels
proposal New external API or other notable changes skill::rust Need the rust language skill to complete the issue
Milestone

Comments

@yubing744
Copy link
Collaborator

yubing744 commented Oct 31, 2024

Proposal Details

Background:
When developing a game, in order to quickly synchronize the game status, the general strategy of the client is to
synchronize the latest status of the game in full, and then synchronize subsequent status changes incrementally.
Currently, Rooch supports incremental synchronization of the Object status through tx_order. However,
it does not support synchronization of the entire game status. In order to support synchronization of the entire game status,
there are two solutions: 1: synchronization through the address of the game contract; 2: synchronization through the game Root object ID.

Expected functions:

  1. Add ParentObjectID filter to SyncStateFilterView of syncStates

Code

pub enum SyncStateFilterView {
    /// Sync by object id.
    ObjectID(ObjectIDView),
    ParentObjectID(ObjectIDView),
    /// Sync all.
    All,
}

Filter logic:
Traverse the queried StateChangeSetWithTxOrder, if the recursive Parent Object of ObjectChange matches ParentObjectID, keep it

  1. Add StructTag filter to SyncStateFilterView of syncStates

Code

pub enum SyncStateFilterView {
    /// Sync by object id.
    ObjectID(ObjectIDView),
    StructTagPattern(StrView),
    /// Sync all.
    All,
}

StructTagPattern example: 0x1::::, 0x1::gas_coin::*, 0x1::gas_coin::RGas

Filtering logic:
Traverse the queried StateChangeSetWithTxOrder, and keep the embedded StructTag of ObjectChange if it matches StructTagPattern

Parent Issue:
#768

@yubing744 yubing744 added the proposal New external API or other notable changes label Oct 31, 2024
@jolestar jolestar added this to the Rooch v0.8 milestone Nov 9, 2024
@jolestar jolestar added the skill::rust Need the rust language skill to complete the issue label Nov 9, 2024
@wfnuser
Copy link
Contributor

wfnuser commented Nov 10, 2024

May I have a try on this one?

@wfnuser
Copy link
Contributor

wfnuser commented Nov 23, 2024

@jolestar I'm still on a vocation. I think I can start on this next weekend (11/30). If it is in a hurry, maybe just assign to some one else. Sorry for that. If it's not, I will try to finish it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New external API or other notable changes skill::rust Need the rust language skill to complete the issue
Projects
Status: No status
Development

No branches or pull requests

3 participants