-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
fix(sui-indexer): Fix StructTag conversion for suix_queryEvents Indexer-RPC method #20467
fix(sui-indexer): Fix StructTag conversion for suix_queryEvents Indexer-RPC method #20467
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent PR, thanks @samuel-rufi! Love the detailed description, and the fact that you've added a test. I've made a suggestion for a small improvement in the fix, but everything else looks good here.
let formatted_struct_tag = struct_tag.to_canonical_string(true); | ||
format!("event_type = '{formatted_struct_tag}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small tweak here -- we can use to_canonical_display
to avoid materializing to an intermediate string.
let formatted_struct_tag = struct_tag.to_canonical_string(true); | |
format!("event_type = '{formatted_struct_tag}'") | |
format!( | |
"event_type = '{}'", | |
struct_tag.to_canonical_display(/* with_prefix */ true), | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @amnn thanks very much for your response and suggestion, will keep this in mind! 🙏
Co-authored-by: Ashok Menon <amenon94@gmail.com>
Description
Currently, there is a bug in the
suix_queryEvents
implementation when processingEventFilter::MoveEventType(struct_tag)
. Even if the user provides astruct_tag
in its full canonical hex representation (including the necessary prefix), it is not converted correctly to the format expected by the database. Instead, the struct_tag is transformed into a simplified representation that does not align with the structure stored in the indexer database.This mismatch causes the SQL query to fail in finding the relevant records, effectively preventing the retrieval of the desired event data, despite the user supplying the correct input.
While
suix_queryEvents
makes use of following string:sui/crates/sui-indexer/src/indexer_reader.rs
Lines 1032 to 1034 in 8bd5399
The indexed event is stored makes use of the full canonical string (including the prefix):
sui/crates/sui-indexer/src/types.rs
Line 134 in 8bd5399
You can reproduce the issue by calling the
suix_queryEvents
RPC endpoint on a indexer instance as follows:Inspired from this PR: iotaledger/iota#4289
Test plan
Please see the provided test.
Release notes
StructTag
conversion forsuix_queryEvents
Indexer-RPC method