0xMiden / 0xMiden/wallet

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

Abierto Apto para principiantes
#770 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
5
Forks
28
Merge medio
9 h 50 min
PR fusionados (30 d)
123

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
testing
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Activo
Claridad
Bien especificado
Aptitud para principiantes
75/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.