-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
Remaining token approvals is currently inferred from Approval events only. This is lossy:
- transfers/
transferFromcan change allowance without emitting a newApprovalevent (common token behavior) - event-only inference can over-report stale approvals
- users can see movement events that suggest spend happened while UI still warns allowance remains
Goal
Compute post-state token allowances and balance changes from simulation/replay state, and attach RPC proofs so the desktop verifier can validate those post-state claims offline.
Scope
- Infer all touched token balances and allowance slots from simulation trace/replay context.
- For each touched account/token slot, fetch post-state values at pinned block context and include proofs.
- Extend evidence package with a
postStateEffectsartifact (or equivalent) containing:- native balances changed
- ERC-20 balances changed
- ERC-20 allowances changed (owner, spender, token, before, after)
- proof material for each claimed slot/account
- Verify these proofs in desktop/CLI against the same anchored state root.
- Render approvals as actual post-state deltas (not event heuristic), and keep event-based display as fallback only.
Design constraints
- Keep chain anchor consistency: simulation/witness/proof must reference same block+state root.
- Preserve witness-only flow semantics.
- Do not rely on token event emission behavior for approval correctness.
Acceptance criteria
- For a tx where allowance is consumed without an
Approvalevent, UI shows correct post-state allowance. - For a tx where approval is revoked to zero, UI does not show it as remaining.
- Post-state effects fail closed when proofs are missing/invalid.
- Desktop and generator display the same approval/balance conclusions for the same package.
- Add regression tests covering:
- no-approval-event allowance decrease
- explicit revoke-to-zero
- unchanged allowance
- partial proof/missing proof failure paths
Related
- Current heuristic implementation:
packages/core/src/lib/simulation/summary.ts(computeRemainingApprovals) - Event decoder basis:
packages/core/src/lib/simulation/event-decoder.ts
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels