[consensus] Unify epoch settlement across paths (cross-path double-credit + schema drift)

Aperta
#6,749 5 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 10 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python, sql

Direzione di ricerca

The settlement writers live in finalize_epoch (node), settle_epoch_rip200 in rewards_implementation_rip200.py, settle_epoch_with_anti_double_mining in anti_double_mining.py, and the divergent epoch_state CREATE in sophia_elya_service.py. Read how each path opens its transaction and writes epoch_state before proposing a shared claim_epoch helper. Done means one schema source and a single claim before settlement, backed by a migration plan agreed in the thread.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug consensus pinned

Spun out of PR #(epoch-settlement-atomic). Tri-brain (3 loops) surfaced that epoch settlement has multiple independent writers with no shared concurrency control:

  • finalize_epoch (node) — writes balances + epoch_state.settled (now atomic vs itself after the PR)
  • settle_epoch_rip200 (rewards_implementation_rip200.py) — writes epoch_rewards + epoch_state.settled (INSERT OR REPLACE)
  • settle_epoch_with_anti_double_mining (anti_double_mining.py) — same pattern
  • sophia_elya_service.py has its own epoch_state CREATE without settled/settled_ts
Risks
  1. Cross-path race: two settlement paths can settle the same epoch concurrently — no shared lock/claim spans them.
  2. INSERT OR REPLACE epoch_state in the rewards/anti-double-mining paths clobbers accepted_blocks/finalized written by block ingest.
  3. Schema drift: divergent epoch_state CREATEs across files → missing-column errors / order-dependent migrations in mixed/standalone deployments.
  4. Two visibility models: reward APIs read epoch_rewards; finalize-path settlements only appear in epoch_state/balances.
Proposed direction
  • One canonical settlement entrypoint (or a shared claim_epoch(con, epoch) helper using BEGIN IMMEDIATE that all paths call first).
  • Single source of truth for epoch_state schema (shared init) + remove the divergent CREATE.
  • Reconcile epoch_rewards vs epoch_state (dual-write or pick one).

CHAOTIC-tier; needs deliberate design + a migration plan. Good bounty candidate.

Lingua principale
Python
Stelle
850
Fork
589
Merge medio
11g 7h
PR unite (30g)
29

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Scottcjn/Rustchain

Tutte le issue di Scottcjn/Rustchain

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.