Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions relayer/chainreader/indexer/transactions_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,14 @@ func (tIndexer *TransactionsIndexer) syncTransmitterTransactions(ctx context.Con
executionStateChanged := map[string]any{
"source_chain_selector": fmt.Sprintf("%d", sourceChainSelector),
"sequence_number": fmt.Sprintf("%d", execReport.Message.Header.SequenceNumber),
"message_id": execReport.Message.Header.MessageID,
"message_hash": messageHash[:],
"state": uint8(3), // 3 = FAILURE
// The conversion to []any is needed to avoid the default Go DB SDK behaviour of converting the byte slice to encoded base64 string.
"message_id": codec.BytesToAnySlice(execReport.Message.Header.MessageID),
"message_hash": codec.BytesToAnySlice(messageHash[:]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we decode these values first?

base64.StdEncoding.DecodeString(messageId)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They are already []byte or [32]byte not strings. The issue here is that when inserting them as those types, the DB SDK auto-converts it to base64, all we're doing here is going from []byte to []any to match the JSON-friendly types that are inserted with regular events (comes from parsedJson).

This conversion effectively tells the DB SDK, we want to insert this slice as-is.

"state": uint8(3), // 3 = FAILURE
}

tIndexer.logger.Debugw("About to insert synthetic ExecutionStateChanged event", "executionStateChanged", executionStateChanged)

// normalize keys
executionStateChanged = common.ConvertMapKeysToCamelCase(executionStateChanged).(map[string]any)

Expand Down
8 changes: 8 additions & 0 deletions relayer/codec/type_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,11 @@ func UnifiedTypeConverterHook(from, to reflect.Type, data any) (any, error) {
// Use the global converter
return getDefaultTypeConverter().Convert(from, to, data)
}

func BytesToAnySlice(b []byte) []any {
result := make([]any, len(b))
for i, v := range b {
result[i] = v
}
return result
}
Loading