rooch icon indicating copy to clipboard operation
rooch copied to clipboard

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

Open yubing744 opened this issue 1 year ago • 2 comments

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: https://github.com/rooch-network/rooch/issues/768

yubing744 avatar Oct 31 '24 23:10 yubing744

May I have a try on this one?

wfnuser avatar Nov 10 '24 16:11 wfnuser

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

wfnuser avatar Nov 23 '24 16:11 wfnuser