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] Implements Field indexer #3282

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

[Indexer] Implements Field indexer #3282

wants to merge 6 commits into from

Conversation

baichuan3
Copy link
Collaborator

Summary

Supports on-chain configuration of table handles, automatically indexes specified table elements, and sorts by fixed fields. Provides RPC API to query field index data.

At the same time, in the rooch db tool, the revert and rollback operations on the field indexer are supported.

The rooch_queryFields RPC API supports a new paging method, page+limit paging, which is different from the previous cursor+limit paging and can meet the needs of the grow voting list.

TODO

  1. Sqlite native bigint only supports u64 at most, and does not support u128 and u256 for the time being. This will limit the use of coin holder lists. It is necessary to consider wrapping u128 and u256 to meet the sorting requirements of large numbers.
  2. Use EventBus to trigger field indexer update, to reduce queries for FieldIndexerTable configuration

Copy link

vercel bot commented Feb 9, 2025

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

Name Status Preview Comments Updated (UTC)
onchain-ai-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 17, 2025 10:04am
rooch-portal-v2.1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 17, 2025 10:04am
test-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 17, 2025 10:04am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 10:04am

Copy link

github-actions bot commented Feb 9, 2025

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@jolestar
Copy link
Contributor

@popcnt1 help review

@baichuan3
Copy link
Collaborator Author

curl --location 'http://localhost:6767' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_queryFields",
    "params": [
        {"object_id":"0x1e73dc3b85365ef877e22c0dd3ea3450db57ba6d5de8af98d5c3883b9a98d18b"}, null, "21", {"descending":true}
    ]
}'
{"jsonrpc":"2.0","result":{"data":[{"id":"0x1e73dc3b85365ef877e22c0dd3ea3450db57ba6d5de8af98d5c3883b9a98d18b","field_key":"0x819bb79fed56c6f79738ac1ec37110cbecda769eb0987c6c13162c8355a2e829","name":"0x0000000000000000000000000000000000000000000000000000000000000002","value":"333"},{"id":"0x1e73dc3b85365ef877e22c0dd3ea3450db57ba6d5de8af98d5c3883b9a98d18b","field_key":"0x07d29b5cffb95d39f98baed1a973e676891bc9d379022aba6f4a2e4912a5e552","name":"0x0000000000000000000000000000000000000000000000000000000000000001","value":"10"}],"next_cursor":"1","has_next_page":false},"id":101}

@baichuan3
Copy link
Collaborator Author

Construct transactions through multi-signatures, submit new field indexer configurations, and field indexes will automatically take effect on the chain.

rooch tx build --function 0x3::indexer::add_field_indexer_entry --args  object:0x1e73dc3b85365ef877e22c0dd3ea3450db57ba6d5de8af98d5c3883b9a98d18b --args string:test1 --args string:ext1  --sender-account 0x575c1acf874bae08134257d5e27865898314ac5868a8278606ea7be04111f2ec

Comment on lines -2368 to +2370
let clonded_fileds = struct_def.field_defs;
let clonded_fields = struct_def.field_defs;

for field_def in clonded_fileds {
for field_def in clonded_fields {
Copy link
Contributor

Choose a reason for hiding this comment

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

third_party 下的代码最好不要修改。

pub id: ObjectIDView,
pub field_key: String,
pub name: String,
pub value: StrView<u64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是应该把原始的 Object 从 state 中取出来? 这样 queryField 和 listField 返回结果就是一致的,然后把 u64 value 作为 sort_key 输出。如果后面增加了按 struct 中的某个字段来排序,也不用变这个结构。

另外后面可以默认用时间来排序,这样大多数场景也能满足需求。

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.

[Indexer] Support Table index
2 participants