Skip to content

feat(consensus): moderator#992

Merged
Mododo merged 10 commits intomasterfrom
feature/consensus/moderator-1
Apr 3, 2026
Merged

feat(consensus): moderator#992
Mododo merged 10 commits intomasterfrom
feature/consensus/moderator-1

Conversation

@Mododo
Copy link
Copy Markdown
Member

@Mododo Mododo commented Jan 6, 2026

Pull Request Checklist

NODE CONFIGURATION MODEL CHANGES

added ban config and journal storage duration (with defaults)

BLOCKCHAIN CONFIGURATION MODEL CHANGES

None


COMPATIBILITY

Full. Added a new separate db.

SPECIAL DEPLOYMENT ACTIONS

Not Required


PERFORMANCE IMPACT

No impact expected


TESTS

Unit Tests

Added some tests for basic units and a single core cross-call test

Network Tests

No coverage

Manual Tests

transfers-30k, simulator


Notes/Additional Comments:

moderator core sequence diagram
sequenceDiagram
    participant Moderator
    participant Scheduler as Unban<br/>Scheduler
    box Ban Core State
      participant StateLock as Ban Core<br/>state lock
      participant BanCache as Ban Cache
      participant CurrentBans as Peer Events,<br/>Current Bans
    end
    participant PeerSchedule as Peer Schedule
    participant DBWriter as Delayed<br/>DB Writer
    participant DelayQueue as Unban<br/>Delay Queue

    alt start
        Moderator->>StateLock: init task at node start
        activate StateLock
        StateLock->>BanCache: restore
        BanCache->>CurrentBans: upsert
        BanCache->>Scheduler: banned
        BanCache-->>StateLock: new bans
        StateLock->>PeerSchedule: set_banned
        StateLock->>DBWriter: new bans
        deactivate StateLock

    else report
        Moderator->>Scheduler: event
        Scheduler->>Scheduler: dequeue
        Scheduler->>StateLock: event
        activate StateLock
        StateLock->>BanCache: maybe_ban
        opt if banned
            BanCache->>CurrentBans: upsert
            BanCache->>Scheduler: banned
            StateLock->>PeerSchedule: set_banned
        end
        StateLock->>DBWriter: stored items, no callback
        deactivate StateLock

    else manual ban
        Moderator->>StateLock: manual ban
        activate StateLock
        StateLock->>BanCache: manual_ban
        BanCache->>CurrentBans: upsert
        BanCache->>Scheduler: banned
        StateLock->>PeerSchedule: set_banned
        StateLock->>DBWriter: with callback
        deactivate StateLock
        DBWriter->>Moderator: wait callback

    else schedule unban
        Scheduler->>Scheduler: dequeue
        Scheduler->>StateLock: lock
        activate StateLock
        Scheduler->>DelayQueue: add
        deactivate StateLock

    else manual unban
        Moderator->>Scheduler: manual unban
        Scheduler->>Scheduler: dequeue
        Scheduler->>StateLock: manual unban
        activate StateLock
        Scheduler->>DelayQueue: remove
        StateLock->>BanCache: unban
        BanCache->>CurrentBans: remove
        StateLock->>PeerSchedule: remove_bans
        StateLock->>DBWriter: with callback
        deactivate StateLock
        DBWriter->>Moderator: wait callback

    else auto unban
        DelayQueue->>Scheduler: expire
        Scheduler->>StateLock: current ban
        activate StateLock
        StateLock->>BanCache: unban
        BanCache->>CurrentBans: remove
        StateLock->>PeerSchedule: remove_bans
        StateLock->>DBWriter: no callback
        deactivate StateLock

    end
Loading

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 6, 2026

🧪 Network Tests

To run network tests for this PR, use:

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

Available test options:

  • Run all tests: gh workflow run network-tests.yml -f pr_number=992
  • Run specific test: gh workflow run network-tests.yml -f pr_number=992 -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.

@Mododo Mododo requested review from 0xdeafbeef and Rexagon January 6, 2026 13:40
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 39.48413% with 1525 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.80%. Comparing base (a31514e) to head (c1b1da5).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
consensus/src/moderator/impl_.rs 0.94% 313 Missing ⚠️
consensus/src/moderator/ban/core.rs 0.00% 234 Missing ⚠️
cli/src/cmd/node/control.rs 0.00% 131 Missing ⚠️
cli/src/cmd/node/mempool_control.rs 0.00% 93 Missing ⚠️
control/src/server.rs 0.00% 80 Missing ⚠️
consensus/src/moderator/ban/state.rs 0.00% 75 Missing ⚠️
control/src/client.rs 0.00% 73 Missing ⚠️
consensus/src/moderator/ban/cache.rs 74.52% 52 Missing and 15 partials ⚠️
consensus/src/moderator/storage/store.rs 58.33% 52 Missing and 13 partials ⚠️
consensus/src/moderator/journal/event.rs 63.63% 43 Missing and 1 partial ⚠️
... and 31 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #992      +/-   ##
==========================================
- Coverage   57.25%   56.80%   -0.45%     
==========================================
  Files         429      448      +19     
  Lines       71866    74314    +2448     
  Branches    71866    74314    +2448     
==========================================
+ Hits        41147    42217    +1070     
- Misses      28735    30020    +1285     
- Partials     1984     2077      +93     

☔ View full report in Codecov by Sentry.
📢 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.

@Mododo Mododo added this to the 020 Consensus milestone Jan 6, 2026
@Mododo Mododo self-assigned this Jan 6, 2026
@Mododo Mododo force-pushed the feature/consensus/moderator-1 branch from 8b23e2e to debb4f0 Compare March 23, 2026 19:15
@github-actions
Copy link
Copy Markdown

❌ CLI reference check failed in CI.

Please run just update_cli_reference, add the updated docs/cli-reference.md, and push the changes.

@Mododo Mododo force-pushed the feature/consensus/moderator-1 branch from debb4f0 to fedc658 Compare March 23, 2026 20:40
@Mododo Mododo marked this pull request as ready for review March 23, 2026 20:51
@Mododo Mododo changed the title feat(consensus): add moderator feat(consensus): moderator Mar 23, 2026
@Mododo Mododo added the C-consesus Consesus module label Mar 24, 2026
@Mododo Mododo force-pushed the feature/consensus/moderator-1 branch 6 times, most recently from cf37f2f to a35ae28 Compare March 27, 2026 17:16
@Mododo Mododo force-pushed the feature/consensus/moderator-1 branch from a35ae28 to c1b1da5 Compare March 30, 2026 11:19
@Mododo Mododo added this pull request to the merge queue Apr 3, 2026
Merged via the queue into master with commit 06c2d2f Apr 3, 2026
21 of 23 checks passed
@Mododo Mododo deleted the feature/consensus/moderator-1 branch April 3, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-consesus Consesus module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants