refactor(scan): make remote simulation flow-aware#112
Open
wantedsystem wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the Blockaid scan “flow-aware” by restricting remote simulation to the dapp sign-transaction confirmation flow, while keeping validation behavior unchanged and still governed by the useSecurityAlerts preference.
Changes:
- Updated the scan refresher to add
TransactionScanOption.Simulationonly whensimulateOnChainActionsis enabled andinterfaceKey === SignTransaction. - Updated/expanded unit tests to cover simulation inclusion/exclusion across relevant confirmation interface keys.
- Updated
snap.manifest.jsonsource.shasumto reflect the new bundle output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/snap/src/handlers/cronjob/refreshConfirmationContext/scanRefresher.ts | Makes scan option selection depend on confirmation flow (simulation only for SignTransaction). |
| packages/snap/src/handlers/cronjob/refreshConfirmationContext/scanRefresher.test.ts | Adds coverage ensuring simulation is skipped for send/change-trust flows and retained for sign-transaction. |
| packages/snap/snap.manifest.json | Updates the snap bundle shasum for the changed build output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Makes the Blockaid security scan flow-aware so that remote simulation is only requested for the dapp sign-transaction flow. The send and change-trust flows no longer request remote simulation, since they already run local on-chain re-validation that covers submittability. Malicious validation is untouched and still runs for every flow per the
useSecurityAlertspreference.Why
Changes
scanRefresher.ts:#getScanOptionsnow reads the full scan context and only addsSimulationwhensimulateOnChainActionsis enabled andinterfaceKey === SignTransaction.Validationis unchanged (all flows, peruseSecurityAlerts). Removed the now-unusedSecurityScanPreferencesalias and updated the 3 call sites.scanFetchStatusstarts asFetching), so the refresher performs the only scan call. No controller/handler changes were needed.Comparison with TRON
This mirrors the spirit of TRON's approach (don't lean on unreliable remote simulation) but applies it per-flow on Stellar: remote simulation is disabled exactly where a local check already exists (send / change-trust), and kept where it's the only option (sign-transaction).
SignAuthEntry/SignMessagedon't run a transaction scan, so they're unaffected.