perf(bridge): fetch transaction operations once in processTransaction#1098
Merged
sameh-farouk merged 1 commit intoJun 1, 2026
Merged
Conversation
When a Stellar transaction credited the bridge account more than once, processTransaction called getOperationEffect(tx.Hash) once per matching account_credited effect, refetching identical operation data from Horizon each time and slowing down processing. Fetch the operations lazily at most once per transaction and reuse the result across all matching effects. The fetch still happens only when a matching TFT credit is present (no extra call for unrelated transactions), and per-effect MintEvent emission is unchanged, so behaviour is preserved. Closes #1051 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
processTransaction(pkg/stellar/stellar.go) callsgetOperationEffect(tx.Hash)inside the per-effect loop. When a single Stellar transaction credits the bridge account more than once (multipleaccount_creditedeffects), this refetches the same operation data from Horizon once per matching effect — redundant API calls that slow down processing.This is the remaining ask from #1051. The correctness parts of that issue (per-payment asset/issuer validation; not dropping payments after non-payment ops) were already resolved by #1094; this completes it.
Fix
Hoist the Horizon operations fetch to a lazy, fetch-at-most-once read, reused across all matching effects:
MintEventemission is unchanged, so observable behaviour is preserved — only the redundant refetch is eliminated.Note / possible follow-up
When a transaction has N matching credited effects, the loop still emits N identical
MintEvents (each built from the same operations). These are de-duplicated downstream by the mint idempotency check (IsMintedAlreadyontx.Hash), so this is behaviourally correct but does N passes over the same ops. Collapsing to a singleMintEventper transaction is a safe further cleanup, deliberately left out here to keep this change focused on the redundant API calls the issue calls out.Verification
go build ./...,go vet ./pkg/stellar/,gofmt— clean.processTransactionfetches effects/operations directly from Horizon (no injection seam), so it isn't unit-testable without a mock Horizon server — consistent with the rest of this file. The change is behaviour-preserving and verified by build + review.Closes #1051
🤖 Generated with Claude Code