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

[Indexer] Support query event by event type and sender #2405

Merged
merged 3 commits into from
Aug 10, 2024

Conversation

baichuan3
Copy link
Collaborator

@baichuan3 baichuan3 commented Aug 10, 2024

Summary

  1. Support query event by event type and sender, and the query can use sqlite index
  2. Migrate filter_out from ObjectStateFilterView::ObjectTypeWithOwner to QueryOptions, eliminate the restriction of forcing filter_out to be passed in ObjectStateFilterView::ObjectTypeWithOwner

TODO:
QueryOptions uses camelCase for serialization, and some parameters use snake_case for parameter passing. Should we unify them?

Copy link

vercel bot commented Aug 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 10, 2024 4:51am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Aug 10, 2024 4:51am

Copy link

github-actions bot commented Aug 10, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@baichuan3
Copy link
Collaborator Author

  1. rooch_queryEvents event_type_with_sender
curl --location 'http://localhost:6767' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_queryEvents",
    "params": [
        {"event_type_with_sender":{"event_type":"0x3::coin_store::WithdrawEvent", "sender":"0x9ade46634d15f000fca7bac2f2212119d823c453846f0d5c4e440136aca0f65c"}}, null, "10", {"descending":true}
    ]
}'
{
    "jsonrpc": "2.0",
    "result": {
        "data": [
            {
                "indexer_event_id": {
                    "tx_order": "3",
                    "event_index": "3"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "5"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x01b41f157189602e0d1825d3408a190d3c0b80c4582f667e0c539e71225062193d53303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e6facf50500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0xed1d14dbab6920baa77991291a46be825ca152bfc98b296e61504c6fb4d25ff0",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256800192",
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": "3",
                    "event_index": "0"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "4"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x0193d1eff444dc7787ff9c286a50f2986122c2c41edb5a964bd9bdc277ac05121053303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e00e1f50500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0xed1d14dbab6920baa77991291a46be825ca152bfc98b296e61504c6fb4d25ff0",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256800192",
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": "2",
                    "event_index": "3"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "3"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x01b41f157189602e0d1825d3408a190d3c0b80c4582f667e0c539e71225062193d53303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e6facf50500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0x9d36f14bf8066296d64db9ee3f1c3a258351e4978ca17f551f0c79e8dc1d1ee0",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256790255",
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": "2",
                    "event_index": "0"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "2"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x0193d1eff444dc7787ff9c286a50f2986122c2c41edb5a964bd9bdc277ac05121053303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e00e1f50500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0x9d36f14bf8066296d64db9ee3f1c3a258351e4978ca17f551f0c79e8dc1d1ee0",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256790255",
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": "1",
                    "event_index": "5"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "1"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x01b41f157189602e0d1825d3408a190d3c0b80c4582f667e0c539e71225062193d53303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696ed97de80500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0x0ed7c4ea3a498c8ed5fd3a840efa8e162c88d2ba0ba9930570b098b0fdf18fd4",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256784967",
                "decoded_event_data": null
            },
            {
                "indexer_event_id": {
                    "tx_order": "1",
                    "event_index": "3"
                },
                "event_id": {
                    "event_handle_id": "0x8e3089f2c059cc5377a1b6b7c3dcefba8a586697c35de27c2a4b68f81defb69c",
                    "event_seq": "0"
                },
                "event_type": "0x3::coin_store::WithdrawEvent",
                "event_data": "0x0193d1eff444dc7787ff9c286a50f2986122c2c41edb5a964bd9bdc277ac05121053303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6761735f636f696e3a3a476173436f696e00e1f50500000000000000000000000000000000000000000000000000000000",
                "tx_hash": "0x0ed7c4ea3a498c8ed5fd3a840efa8e162c88d2ba0ba9930570b098b0fdf18fd4",
                "sender": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "created_at": "1723256784967",
                "decoded_event_data": null
            }
        ],
        "next_cursor": {
            "tx_order": "1",
            "event_index": "3"
        },
        "has_next_page": false
    },
    "id": 101
}
  1. rooch_queryObjectStates with filterOut
curl --location 'http://localhost:6767' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_queryObjectStates",
    "params": [
        {"object_type_with_owner":{"object_type":"0x2::module_store::Package","owner":"0x9ade46634d15f000fca7bac2f2212119d823c453846f0d5c4e440136aca0f65c"}}, null, "30", {"descending":true, "filterOut":true}
    ]
}'
{
    "jsonrpc": "2.0",
    "result": {
        "data": [
            {
                "id": "0x9ade46634d15f000fca7bac2f2212119d823c453846f0d5c4e440136aca0f65c",
                "owner": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "owner_bitcoin_address": "bcrt1pauayqlrhqpzqtmlex0k0twtxdvvyh5x8xz6t633djrks44nmsyqq379wxf",
                "flag": 0,
                "state_root": "0x5350415253455f4d45524b4c455f504c414345484f4c4445525f484153480000",
                "size": "0",
                "created_at": "1723256784967",
                "updated_at": "1723256800192",
                "object_type": "0x2::account::Account",
                "value": "0x9ade46634d15f000fca7bac2f2212119d823c453846f0d5c4e440136aca0f65c0300000000000000",
                "decoded_value": null,
                "tx_order": "3",
                "state_index": "2",
                "display_fields": null
            },
            {
                "id": "0x93d1eff444dc7787ff9c286a50f2986122c2c41edb5a964bd9bdc277ac051210",
                "owner": "rooch1nt0yvc6dzhcqpl98htp0ygfpr8vz83zns3hs6hzwgsqndt9q7ewqlrhhz8",
                "owner_bitcoin_address": "bcrt1pauayqlrhqpzqtmlex0k0twtxdvvyh5x8xz6t633djrks44nmsyqq379wxf",
                "flag": 0,
                "state_root": "0x5350415253455f4d45524b4c455f504c414345484f4c4445525f484153480000",
                "size": "0",
                "created_at": "1723256784967",
                "updated_at": "1723256800192",
                "object_type": "0x3::coin_store::CoinStore<0x3::gas_coin::GasCoin>",
                "value": "0xb74397d4e800000000000000000000000000000000000000000000000000000000",
                "decoded_value": null,
                "tx_order": "3",
                "state_index": "1",
                "display_fields": null
            }
        ],
        "next_cursor": {
            "tx_order": "3",
            "state_index": "1"
        },
        "has_next_page": false
    },
    "id": 101
}

Copy link
Contributor

@jolestar jolestar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jojoo-eth @wow-sven @mx819812523, putting the filter_out argument in the Option will break the SDK and PRC call.

@jolestar
Copy link
Contributor

jolestar commented Aug 10, 2024

TODO:
QueryOptions uses camelCase for serialization, and some parameters use snake_case for parameter passing. Should we unify them?

We can unify them, but we need to support camelCase and snake_case both to avoid breaking RPC.

@jolestar jolestar merged commit cb4e29e into main Aug 10, 2024
8 checks passed
@jolestar jolestar deleted the query_event_by_sender_and_event_type branch August 10, 2024 10:59
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.

Enhance rooch_queryEvents RPC to support combined sender and event_type filtering
2 participants