Conversation
Signed-off-by: Ruslan Velkov <ruslan.velkov@limechain.tech>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
joshmarinacci
left a comment
There was a problem hiding this comment.
Will this have any performance impact?
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #26862 +/- ##
============================================
+ Coverage 71.25% 71.26% +0.01%
- Complexity 11906 11907 +1
============================================
Files 2596 2596
Lines 109552 109558 +6
Branches 12364 12368 +4
============================================
+ Hits 78061 78081 +20
+ Misses 27447 27440 -7
+ Partials 4044 4037 -7
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
No meaningful impact — these are |
…e order Signed-off-by: Ruslan Velkov <ruslan.velkov@limechain.tech>
|
Follow-up now that this switched to defensive copies per review: it's no longer O(1) — it's O(n) in the number of signing keys / hollow accounts. But n is single-digit per transaction, and the same pre-handle path already runs |
🚨 All tests passed but jobs failed 🚨Failed Jobs without Test Failures❌ 600: [FLOW] PR Checks / MATS / Snyk Scan / Snyk Checks 🏷️ Commit: 8ec9a69 Learn more about TestLens at testlens.app/docs. |
What
Wrap the collections exposed by
PreHandleResult—requiredKeys,optionalKeys,hollowAccounts,verificationResults— as unmodifiable views in the record's compact constructor, so a consumer cannot mutate them after construction.innerResultsis intentionally left mutable: atomic-batch pre-handle appends inner results to it after thePreHandleResultis constructed (PreHandleWorkflow#preHandleTransaction).Why
SpotBugs reports
EI_EXPOSE_REP/EI_EXPOSE_REP2on these fields — the record stored and returned the references directly. In practice the key/account sets already arrive unmodifiable (built viaPreHandleContextImpl), butverificationResultsis a plainHashMapreturned bySignatureVerifierImpl.verify, sogetVerificationResults()handed out a mutable map. Wrapping the fields makes the exposure defensively safe regardless of how the result is constructed.Testing
PreHandleResultTest.getVerificationResultsRejectsMutation— new; fails before the change (theHashMapaccepts a mutation), passes after.PreHandleContextImplTest.exposedKeyAndAccountSetsAreUnmodifiable— asserts the exposed key/account sets reject mutation../gradlew :app:testforPreHandleResultTest,PreHandleContextImplTest,PreHandleWorkflowImplTest(atomic-batch + reuse),DefaultKeyVerifierTest,DispatchValidatorTest— all green.