sui icon indicating copy to clipboard operation
sui copied to clipboard

[gql] events (eventConnection) on tx

Open wlmyng opened this issue 1 year ago • 2 comments

Description

Use fetch_events for transaction

Test Plan

transactions/events.move


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • [ ] protocol change
  • [ ] user-visible impact
  • [ ] breaking change for a client SDKs
  • [ ] breaking change for FNs (FN binary must upgrade)
  • [ ] breaking change for validators or node operators (must upgrade binaries)
  • [ ] breaking change for on-chain data layout
  • [ ] necessitate either a data wipe or data migration

Release notes

wlmyng avatar Dec 19 '23 19:12 wlmyng

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

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2024 9:24pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2024 9:24pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2024 9:24pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Jan 4, 2024 9:24pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jan 4, 2024 9:24pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jan 4, 2024 9:24pm

vercel[bot] avatar Dec 19 '23 19:12 vercel[bot]

Note that the StoredTransaction keeps track of a serialized representation of all its events:

https://github.com/MystenLabs/sui/blob/0a4182d17651e5b4d496f8ca2fa4610362bcf9af/crates/sui-indexer/src/models_v2/transactions.rs#L36

So it would be better to implement this referencing that, instead of doing another DB roundtrip, if we can avoid it, but we can treat that as a follow-up.

Hmm.. not sure how I missed this, thanks for calling it out. I think I can update Event representation to have optional StoredEvent and required NativeSuiEvent

wlmyng avatar Dec 21 '23 23:12 wlmyng

I think I can update Event representation to have optional StoredEvent and required NativeSuiEvent

I was just having a look at this -- there are quite a few rows in StoredEvent that are actually derived from the transaction block, so you may want to keep the representation of GraphQL's event the same (a StoredEvent) but provide a way to build one given a GraphQL transaction block and a native event, or just a plain StoredEvent.

amnn avatar Jan 03 '24 15:01 amnn

I think I can update Event representation to have optional StoredEvent and required NativeSuiEvent

I was just having a look at this -- there are quite a few rows in StoredEvent that are actually derived from the transaction block, so you may want to keep the representation of GraphQL's event the same (a StoredEvent) but provide a way to build one given a GraphQL transaction block and a native event, or just a plain StoredEvent.

Astute observation! Yes exactly, StoredTransaction and the native event can recreate a StoredEvent. Verified in the indexer code that values such as timestamp_ms are the same between the Indexed -> Stored Transaction and Event. I will do this to keep things simple

wlmyng avatar Jan 03 '24 16:01 wlmyng

Ready for another review. Figured it'd be easier to just do the "right" thing straight up (use serialized events on StoredTransaction)

wlmyng avatar Jan 04 '24 16:01 wlmyng

Thanks @wlmyng, some small clean-ups for this here: #15577

amnn avatar Jan 05 '24 16:01 amnn