Skip to content

Slasher (part 1)#1098

Merged
Rexagon merged 31 commits into
masterfrom
feature/slasher
Jun 26, 2026
Merged

Slasher (part 1)#1098
Rexagon merged 31 commits into
masterfrom
feature/slasher

Conversation

@Rexagon

@Rexagon Rexagon commented Jun 8, 2026

Copy link
Copy Markdown
Member

This PR adds an initial slasher impl. It observes and analyzes blocks validation (a signature collection step after collation). It gives a rough idea of how well each node works. When vset changes each node analyzes each others reports and emits some metrics (stake punishment will be implemented in later PR's).

How does it work

Each validator collects BlocksBatches that contain a matrix of received signatures from other validator per each block.
image

These block batches are then sent to the Slasher Contract (message_ttl / message_retry_interval) and at the same time each validator parses all transactions from that contract. So each participant knows all block batches from everyone.

When vset changes an analyzer is triggered and all batches are reduced into a list of validator ids to accuse. For now, accusations are only visible on metric tycho_slasher_accusations_total{pubkey}.

Analyzer steps:

NOTE: It is executed independently by each participant with their local configs.

  • It first checks that the validator set covers enough blocks and has enough validators (vset_len_threshold).
  • Then it scans stored block batches and, for each observer, counts only blocks that reached the 2/3+1 weight threshold of valid signatures. Those blocks become the observer’s usable samples.
  • For each observer, it measures how often every other validator produced valid signatures on those usable samples. It uses the median valid-signature rate as a baseline, scales it by slow_node_factor, and flags validators whose statistically adjusted upper-bound rate is still below that slow threshold. Accusation weights from observers are accumulated per each validator.
  • A validator is considered as "indeed accused" if 2/3+1 observers (by weight) accused it, or if it produced too much malformed batches (malformed_samples_threshold).

Breaking Changes

Validators subset computation now uses a vset_switch_round from consensus_info.

Config Changes

A new section has been added:

{
  "slasher": {
    // TTL of messages to the slasher contract.
    "message_ttl": "30s",
    // Interval between message delivery attempts.
    "message_retry_interval": "1s",
    // Additional time to wait for the previous batch delivery.
    "prev_delivery_timeout": "5s",
    // Validator set round must contain at least this amount of blocks to run analyzer.
    "vset_len_threshold": 1000,
    // At least this number of block samples must be collected to accuse someone.
    "block_samples_threshold": 100,
    // At least this number of malformed batches must be collected to accuse someone.
    "malformed_samples_threshold": 5,
    // We treat the node as slow if its block rate is this times the median rate.
    "slow_node_factor": 0.5
  }
}

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🧪 Network Tests

To run network tests for this PR, use:

gh workflow run network-tests.yml -f pr_number=1098

Available test options:

  • Run all tests: gh workflow run network-tests.yml -f pr_number=1098
  • Run specific test: gh workflow run network-tests.yml -f pr_number=1098 -f test_selection=ping-pong

Test types: destroyable, ping-pong, one-to-many-internal-messages, fq-deploy, nft-index, persistent-sync

Results will be posted as workflow runs in the Actions tab.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.06891% with 1350 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.67%. Comparing base (d41cb45) to head (70e67a7).

Files with missing lines Patch % Lines
slasher/src/lib.rs 0.00% 345 Missing ⚠️
slasher/src/collector/validator_events.rs 0.00% 202 Missing ⚠️
slasher/src/storage/mod.rs 0.00% 181 Missing ⚠️
slasher/src/analyzer.rs 0.00% 141 Missing ⚠️
slasher/src/bc/contract.rs 33.53% 108 Missing and 3 partials ⚠️
slasher/src/storage/models.rs 0.00% 93 Missing ⚠️
slasher/src/bc/mod.rs 30.69% 70 Missing ⚠️
slasher-traits/src/validator.rs 68.96% 53 Missing and 1 partial ⚠️
slasher/src/util.rs 79.90% 36 Missing and 6 partials ⚠️
slasher/src/storage/db.rs 0.00% 23 Missing ⚠️
... and 13 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1098      +/-   ##
==========================================
- Coverage   60.31%   59.67%   -0.65%     
==========================================
  Files         473      484      +11     
  Lines       80685    82583    +1898     
  Branches    80685    82583    +1898     
==========================================
+ Hits        48668    49279     +611     
- Misses      29692    30954    +1262     
- Partials     2325     2350      +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Rexagon Rexagon requested review from Mododo and SmaGMan June 8, 2026 12:02
@Rexagon Rexagon changed the title Slasher Slasher (part 1) Jun 8, 2026
Comment thread collator/src/types.rs
@Rexagon Rexagon enabled auto-merge June 26, 2026 13:36
@Rexagon Rexagon mentioned this pull request Jun 26, 2026
@Rexagon Rexagon added this pull request to the merge queue Jun 26, 2026
Merged via the queue into master with commit 43a3979 Jun 26, 2026
21 of 23 checks passed
@Rexagon Rexagon deleted the feature/slasher branch June 26, 2026 13:50
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.

5 participants