A header only had to meet the target it declared for itself, so a fabricated one with `bits = 0x207fffff` passed half the time, a jump of several blocks was accepted without being linked to the tip (a fake header at a huge height locked `tip_height` and froze every draw), and an ordinary one-block reorganisation closed the session on every server. - draw.py: MAINNET_POW_LIMIT (00000000ffff...ffff); header_meets_its_own_target also refuses a claimed target easier than POW_LIMIT. - ElectrumListener._apply_header is async and takes the active client. A single block must chain by prev_hash; a jump downloads the headers in between (blockchain.block.headers, at most 2016 per request, ElectrumClient.get_block_headers) and each must carry valid work and chain, otherwise HeaderValidationError ends the session. - The listener keeps the last 10 headers (`_window`), built from the process's first header and its 9 predecessors (which must chain into it). A header that does not join the tip is walked back to its fork point inside the window and the server's branch is followed instead of ending the session; a fork older than the window, or a branch that does not end at the announced header, still ends it. The audit row and the pause for deep reorgs are B-85; a competing header at the tip's own height is still ignored until then. - _header_at also serves older heights from the window. Tests changed because the spec changed: the mainnet powLimit cannot be mined in a test, so tests/unit/conftest.py swaps in a regtest limit at import time (the new tests put the real one back); the _apply_header tests are async; the two _run_once tests serve the first header's 9 predecessors; test_apply_header_skips_linkage_check_across_a_height_gap is replaced by the jump tests, since that behaviour is exactly what the finding removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Documentazione di PLM Lottery
Questa cartella è la fonte di verità del progetto: si lavora docs-first (prima si scrive o si modifica la documentazione, poi il codice) e ogni informazione ha un solo proprietario (SSOT). Questo file è l'indice: da qui si raggiunge tutto il resto.
I tre principi
- Docs-first. Nessuna modifica di comportamento parte dal codice. Si modifica il requisito (o si scrive l'ADR, se è una scelta nuova), poi si implementa, poi si testa. Spec, codice e test entrano nello stesso commit.
- SSOT — un solo proprietario per ogni informazione. Il perché di una
scelta sta in un ADR; il cosa verificabile in un requisito
(
PREFISSO-NN) del documento di dominio; il come nel codice; la cronologia dei difetti instorico-bug.md. Gli altri documenti rimandano all'ID, non ripetono il testo. Se due documenti dicono cose diverse, vince la specifica e si corregge l'altro. - Un ADR per ogni funzionalità. Ogni funzionalità nuova inizia con un ADR in adr/ (modello: adr/TEMPLATE.md) che registra contesto, decisione, alternative scartate e conseguenze, e ne elenca i requisiti.
Dove si trova cosa
| Domanda | Dove |
|---|---|
| Perché è fatto così? Quali alternative sono state scartate? | adr/ — indice per area e tabella funzionalità → ADR |
| Cosa deve fare esattamente il software? | I documenti di dominio qui sotto (requisiti con ID stabile) |
| Quali limiti abbiamo accettato? | limiti-noti.md (LIM-nn) |
| Che bug sono stati trovati/corretti? Quali restano aperti? | storico-bug.md; i soli aperti in ../BUGS.md |
| In che ordine si implementano le correzioni aperte? | piano-correzioni.md |
| Come si modifica la documentazione/il codice? | processo-di-modifica.md |
| Come si installa, si avvia, si usa? | Guide operative qui sotto |
Specifica (documenti di dominio)
Punto d'ingresso narrativo: come-funziona.md.
| Documento | Prefisso | Contenuto |
|---|---|---|
| registrazione-e-depositi.md | REG, DEP |
Account, indirizzi, depositi, saldo |
| scommesse-e-prelievi.md | BET, WDR |
Scommesse e prelievi |
| ciclo-di-vita-del-round.md | RND |
Apertura, chiusura, estrazione, pagamento |
| transazioni-e-riconciliazione.md | TX |
Ciclo di vita delle transazioni, RBF, riconciliazione |
| connessione-electrum.md | ELC |
Accesso alla rete PLM e difese |
| architettura.md | ARC |
Struttura del codice, processi, frontend, test |
| modello-dati.md | DAT |
Tabelle, campi, stati, vincoli |
| api.md | API |
Endpoint, risposte, codici di errore |
| sicurezza.md | SEC |
Fiducia, chiavi, autenticazione, limiti sui tentativi |
| audit-log.md | AUD |
Catalogo degli eventi di audit |
| operativita.md | OPS |
Backup, riavvii, incidenti |
Decisioni, limiti, storia
| Documento | Prefisso | Contenuto |
|---|---|---|
| adr/ | ADR |
Una decisione di progetto per file (53 al momento) |
| limiti-noti.md | LIM |
Limiti accettati consapevolmente |
| storico-bug.md | B-nn |
Tutti i bug trovati e corretti |
| piano-correzioni.md | — | Ordine di implementazione delle correzioni aperte |
Guide operative (senza requisiti)
setup.md · running-the-server.md · guida-utente.md · guida-admin.md. Si aggiornano quando la specifica cambia qualcosa di visibile.
Lingua
La documentazione di docs/ è in italiano, per scelta esplicita; tutto il
resto del repository (codice, commenti, commit, CLAUDE.md, BUGS.md) è in
inglese.