Stress conservation number is contaminated by foreign faucets: getBalance ignores its token symbol
- 主要语言
- TypeScript
- 星标
- 5
- 派生
- 28
- 平均合并
- 9 小时 50 分钟
- 30 天内合并 PR
- 123
描述
`getBalance(_tokenSymbol?)` in the E2E harness ignores its symbol argument and sums **every** faucet in the wallet, so unrelated dust lands in the stress suite's conservation assertion signed — it can invent a violation, shrink a real one, or invert it.
**Where** — `playwright/e2e/helpers/wallet-page.ts:1464`. The parameter is underscore-prefixed and referenced exactly once, in the signature. Two separate sums are unfiltered: the `freshState.balances` loop (~1491) and the `miden_sync_data.notes` loop (~1502).
**Symptom** — `conservationHeld: false` on a run where the tracked asset is conserved to the unit.
**Repro** — 25-note all-private stress run on testnet today (`e4fadde3`, `seed 942930517`):
```
A = 3004 B = 2996.0304 total = 6000.0304
expectedDeltaA = +4 expectedDeltaB = -4 conservationHeld = FALSE
```
TST is exact: 3004 + 2996 = 6000, matching the driver's expected ±4. The entire reported deviation is 0.0304 of foreign-faucet dust.
**Expected** — the conservation assertion measures only the harness's own faucet.
**Impact** — both directions, and both are load-bearing:
- **False positive** (above): a clean run reports a conservation violation.
- **False negative**: on the 2026-08-17 run the same defect masked **72% of a −70 TST loss**. On 2026-08-24 it was small (≈0.35 against −151) but still signed.
Because the headline number of every stress run passes through this function, a real fund-loss regression can be hidden by dust from an unrelated faucet.
Fix sketch
Filter both loops by the harness faucet id (the one `deploy_and_fund` creates), resolving the symbol argument to a faucet id and skipping non-matching entries. `quickBalanceSnapshot()`/`totalReportable` should get the same treatment so the settle loop and the final assertion agree.
Callers that legitimately want an all-asset total should ask for it explicitly rather than getting it by accident from an ignored parameter.
Status on branches
Unfixed on both `origin/main` and `origin/next` as of 2026-08-25 — the two files are byte-identical at this function.
**Reviewers:** the part worth your time is whether to filter by symbol or by faucet id — `deploy_and_fund` knows the faucet id, but `getBalance` currently takes a symbol, and the swap/earn specs may rely on the current all-asset behaviour.
贡献指南
调研方向
The bug is in `playwright/e2e/helpers/wallet-page.ts` at line 1464 in the `getBalance` function. Examine the two loops around lines 1491 and 1502 that sum balances without filtering by the provided token symbol. The fix involves filtering these sums to only include the specified faucet. Check how `deploy_and_fund` creates the faucet ID and ensure `quickBalanceSnapshot` is also updated for consistency. Run the stress tests to verify the conservation assertion is now accurate.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- testing
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 75/100