Skip to content

Conversation

panoel
Copy link
Contributor

@panoel panoel commented Sep 24, 2025

No description provided.

@panoel panoel requested a review from evan-gray as a code owner September 24, 2025 02:53
Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

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

overall seems reasonable, though I'm not sure if tilt will pass. mostly nits. I could go either way about reobserving direcly by version or keeping it by event sequence. I think the obvious advantage of using the version is that reobservation would not require the indexer and that would probably be a good thing.

@panoel panoel force-pushed the aptos-watcher-uses-graphql-indexer branch from 3439ae9 to b16e7d0 Compare September 24, 2025 18:02
@panoel panoel force-pushed the aptos-watcher-uses-graphql-indexer branch from cd7e7f7 to a246b22 Compare September 24, 2025 18:23
Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

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

had limited time to take a look but this seems broadly correct. the main thing I am unsure of and would want confirmed is the security of the new fields we are checking in the transactions/by_version response - type being the most critical one to enforce that we're only picking up legitimate Wormhole messages.

// Only aptosIndexerRPC is required for indexer mode, token is optional
useIndexerMode := *aptosIndexerRPC != ""

// Log which mode will be used
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this will be critical to debugging. do you think this is worth a (really short) feature flag in the heartbeat as well?

}

// processTransactionVersion fetches a transaction by version and extracts WormholeMessage events
func (e *Watcher) processTransactionVersion(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function's logged errors should include a unique field that we can do lookups on in order to debug. Maybe hash listed here? I'm not sure if there's a better field though:
https://aptos.dev/rest-api/operations/get_transaction_by_version

Otherwise, we just get the error strings but we can't tell where they came from.

txResult := gjson.ParseBytes(txData)

// Look for WormholeMessage in the events array
whEventType := fmt.Sprintf("%s::state::WormholeMessage", e.aptosAccount)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This could be defined when the watcher is configured instead of inside of this function


// Check for GraphQL errors in the response
// The indexer may return errors with a 200 status code
if gjson.Valid(string(body)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We always expect valid JSON from this query, right? So I think if this check fails, the function should return nil, err. Right now it will fallthrough to body, nil

if gjson.Valid(string(body)) {
response := gjson.ParseBytes(body)
errors := response.Get("errors")
if errors.Exists() && errors.IsArray() && len(errors.Array()) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly the bounds check on errors is worth a loud comment as it will cause a panic if removed

continue
}

if blockHeight.Exists() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It seems like this check should happen before the Uint() check above. It also seems like if the block height doesn't exist for whatever reason then we would never see a health check. Probably if this field does not exist or is 0 after Uint(), an error should be logged.

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.

3 participants