fix(ttx): remove context.Context field from Transaction struct - #2180
Merged
Conversation
adecaro
force-pushed
the
containedctx
branch
2 times, most recently
from
August 11, 2026 05:18
71907d4 to
6d43348
Compare
Transaction stored a context.Context captured once at construction, so methods reached for t.Context instead of taking a context from their caller. A transaction rebuilt via NewTransactionFromBytes in a different view kept the originating view's context, and htlc.Transaction.Lock already accepted ctx but silently used t.Context instead, dropping the caller's deadline/cancellation/tracing context. Bytes, Issue, Transfer, Redeem, Upgrade, Outputs, and Inputs now take ctx explicitly, threaded through every call site in token/ and integration/. Also enables the containedctx linter and suppresses the pattern's remaining, reviewed occurrences (long-lived service/worker lifecycles, a per-event struct, session-wrapper convenience defaults, and a test fake) with a justification comment each. Fixes #2178 Fixes #2179 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
atharrva01
added a commit
to atharrva01/panurus
that referenced
this pull request
Aug 16, 2026
LFDT-Panurus#2180 enabled containedctx and fixed the ttx occurrence. The evm module is a separate Go module and was not linted in that pass, so make lint has been failing on it since. Neither field can be dropped. Ledger.ctx exists because driver.GetStateFnc passes no context to GetState, and fakeContext.ctx exists because it implements view.Context, whose Context() method has to return one. Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
atharrva01
added a commit
to atharrva01/panurus
that referenced
this pull request
Aug 16, 2026
LFDT-Panurus#2180 enabled containedctx and fixed the ttx occurrence. The evm module is a separate Go module and was not linted in that pass, so make lint has been failing on it since. Neither field can be dropped. Ledger.ctx exists because driver.GetStateFnc passes no context to GetState, and fakeContext.ctx exists because it implements view.Context, whose Context() method has to return one. Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
atharrva01
added a commit
to atharrva01/panurus
that referenced
this pull request
Aug 16, 2026
LFDT-Panurus#2180 enabled containedctx and fixed the ttx occurrence. The evm module is a separate Go module and was not linted in that pass, so make lint has been failing on it since. Neither field can be dropped. Ledger.ctx exists because driver.GetStateFnc passes no context to GetState, and fakeContext.ctx exists because it implements view.Context, whose Context() method has to return one. Signed-off-by: atharrva01 <atharvaborade568@gmail.com>
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.
Summary
Context context.Contextfield fromttx.Transaction;Bytes,Issue,Transfer,Redeem,Upgrade,Outputs, andInputsnow takectx context.Contextexplicitly from the caller instead of reading a value captured once at construction time.htlc.Transaction.Lock, which already acceptedctxbut silently used the struct field instead — the caller's deadline/cancellation/tracing context was being dropped.ctxthrough every same-package caller (marshaller.go,auditor.go,collectactions.go,collectendorsements.go), the wrapper transaction types (htlc,nfttx,boolpolicy,multisig), ~45 integration view call sites, and doc code samples.containedctxlinter and resolves every resulting finding repo-wide (root +integration+cmd/*modules) — either by threadingctxthrough as above, or with a//nolint:containedctxplus justification for the reviewed, accepted patterns (long-lived worker/service lifecycles, a per-event struct, session-wrapper convenience defaults, and one test fake).Test plan
go build ./...(root andintegrationmodule) cleango vet ./...(root andintegrationmodule) cleanmake unit-testspassingmake unit-tests-racepassing, no new racesmake checksclean across all modulesmake lint-auto-fixclean across all modules (0containedctxissues)Fixes #2178
Fixes #2179
🤖 Generated with Claude Code