Skip to content

fix: implement per-validator rate limit in slashing mempool#28

Merged
JamesEjembi merged 9 commits into
VeriNode-Labs:mainfrom
dev-king-001:main
Jun 24, 2026
Merged

fix: implement per-validator rate limit in slashing mempool#28
JamesEjembi merged 9 commits into
VeriNode-Labs:mainfrom
dev-king-001:main

Conversation

@dev-king-001

Copy link
Copy Markdown

Title:

fix: implement per-validator rate limit in slashing mempool

Description

What was done

  • Added a HashMap<ValidatorIndex, u8> rate-limiter to the SlashingMempool.
  • Enforced a hard limit of MAX_EVIDENCE_PER_VALIDATOR_PER_EPOCH = 1.
  • Configured push_evidence() to immediately return an OverflowError and drop any redundant evidence for the same validator.
  • Implemented reset_epoch() to clear the rate-limit map at epoch boundaries.
  • Integrated the slashing module into the Soroban environment securely via #![cfg_attr(target_family = "wasm", no_std)].

Why it was done

  • To prevent a known griefing vector where an attacker floods the mempool with minimal-evidence packages for a single victim validator. Previously, unbounded evidence processing could exhaust the epoch processing gas budget and permanently block legitimate slashing evidence from being evaluated.

How it was verified

  • Validated via cargo test --test griefing_resistance_test.
  • Added a DoS resistance test (test_minimal_evidence_flood_griefing_resistance) that actively pushes 100 duplicate evidence entries for the same validator index, verifying that exactly 1 is successfully accepted while the remaining 99 are immediately rejected with an OverflowError::RateLimitReached.

Closes #25

@JamesEjembi

Copy link
Copy Markdown
Contributor

CI failed

@dev-king-001

Copy link
Copy Markdown
Author

Fixed

@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 73325c9 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.

Slashing Condition Engine Griefing via Minimal-Evidence Flood on Single Validator

3 participants