Skip to content

fix: eliminate reputation update race via append-only event log (#3)#44

Merged
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:fix/reputation-update-race
Jun 24, 2026
Merged

fix: eliminate reputation update race via append-only event log (#3)#44
JamesEjembi merged 1 commit into
VeriNode-Labs:mainfrom
real-venus:fix/reputation-update-race

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Fix #3 — Node Reputation Score Update Race in Concurrent Attestation Processing

Closes #3

Changes

File Purpose
src/reputation/score.rs ReputationLedger (set_initial_score, update_reputation, try_slash, score, slash_count, event_count), ReputationSource, ReputationEvent, range/adjustment constants
src/reputation/mod.rs Registers pub mod score
tests/reputation/score_tests.rs (+ tests/reputation.rs) Race + invariant tests

…Node-Labs#3)

Reputation was a single scalar updated read-compute-write, so a
successful attestation (+10) and a slashing event (-500) processed
together raced: the last writer won and a +10 could clobber the slash
(final 760 instead of 260), dropping the authoritative slash.

Fix stores reputation as a per-event log (blueprint step 3): each
adjustment is appended as a ReputationEvent and the score is the clamped
sum, so two updates each record their event and the result is
independent of write order. A monotonic slash_count + try_slash
(step 4) make slashing idempotent against duplicate replays.

- reputation/score.rs: ReputationLedger (set_initial_score,
  update_reputation, try_slash, score, slash_count), ReputationSource,
  ReputationEvent, range/adjustment constants
- tests/score_tests.rs: concurrent attestation+slash -> 260 (never
  760/250), slash-always-(-500), duplicate-slash skip, clamp,
  order-independence property test

@JamesEjembi JamesEjembi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JamesEjembi JamesEjembi merged commit 86baba2 into VeriNode-Labs:main Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node Reputation Score Update Race in Concurrent Attestation Processing

2 participants