Skip to content

fix: store the summed node reward instead of adding it again in SQL - #523

Open
KSlashh wants to merge 1 commit into
devfrom
audit/31-rpc-consistency
Open

KSlashh wants to merge 1 commit into
devfrom
audit/31-rpc-consistency

Conversation

@KSlashh

@KSlashh KSlashh commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Audit item M23. Open against dev.

add_node_reward reads the node's reward, adds the increment in Rust and passes the new total to update_node_reward_by_peer_id, whose SQL then ran reward = reward + ?. Each reward event therefore added the old total again, so /v1/nodes showed a value that grew much faster than the real reward.

  • update_node_reward_by_peer_id now stores the total it is given (reward = ?); the addition happens only in Rust. sqlx offline cache updated.

Tests: two rewards of 5 on a fresh node give 10 (15 before the fix). Node and store tests, clippy and fmt pass.

Validation results above are recorded in the zkm PR notes. Branch scope and diff formatting were checked locally; builds and tests were not rerun during publication.

This branch has not been deployed

No deployments
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.

2 participants