0xMiden / 0xMiden/wallet

Stress conservation number is contaminated by foreign faucets: getBalance ignores its token symbol

未關閉 適合新手
#770 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
5
分支
28
平均合併
16 小時 40 分鐘
30 天內合併 PR
99

描述

`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.

貢獻指南

開啟貢獻指南

研究方向

該錯誤位於 `playwright/e2e/helpers/wallet-page.ts` 第 1464 行的 `getBalance` 函數中。檢查第 1491 行和第 1502 行附近的兩個迴圈,它們在匯總餘額時沒有按提供的代幣符號進行過濾。修復涉及將這些匯總過濾為僅包含指定的 faucet。檢查 `deploy_and_fund` 如何建立 faucet ID,並確保同時更新 `quickBalanceSnapshot` 以保持一致性。執行壓力測試以驗證守恆斷言現在是否準確。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
typescript
領域
testing
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
75/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。