Skip to content

feat(consensus): moderator#992

Open
Mododo wants to merge 7 commits intomasterfrom
feature/consensus/moderator-1
Open

feat(consensus): moderator#992
Mododo wants to merge 7 commits intomasterfrom
feature/consensus/moderator-1

Conversation

@Mododo
Copy link
Member

@Mododo Mododo commented Jan 6, 2026

Pull Request Checklist

NODE CONFIGURATION MODEL CHANGES

Yes: added ban config and journal storage duration (with defaults)

BLOCKCHAIN CONFIGURATION MODEL CHANGES

None


COMPATIBILITY

Full. Added new column families in mempool 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
    participant StateLock as Ban Core<br/>state lock
    participant BanCache as Ban Cache
    participant CurrentBans as Peer Events,<br/>Current Bans
    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
        BanCache->>CurrentBans: upsert
        BanCache->>Scheduler: banned
        StateLock->>PeerSchedule: set_banned
        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

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

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 39.12338% with 1500 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.80%. Comparing base (577e65b) to head (76b160a).

Files with missing lines Patch % Lines
consensus/src/moderator/impl_.rs 0.96% 309 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/storage/journal_store.rs 55.84% 56 Missing and 12 partials ⚠️
consensus/src/moderator/ban/cache.rs 74.52% 52 Missing and 15 partials ⚠️
consensus/src/moderator/journal/event.rs 63.63% 43 Missing and 1 partial ⚠️
... and 27 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #992      +/-   ##
==========================================
- Coverage   57.23%   56.80%   -0.44%     
==========================================
  Files         429      445      +16     
  Lines       71848    74246    +2398     
  Branches    71848    74246    +2398     
==========================================
+ Hits        41125    42174    +1049     
- Misses      28733    29999    +1266     
- Partials     1990     2073      +83     

☔ 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

❌ 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 2 times, most recently from 76087ed to 2c32c3f Compare March 25, 2026 18:58
@Mododo Mododo force-pushed the feature/consensus/moderator-1 branch from 2c32c3f to 76b160a Compare March 26, 2026 03:03
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.

1 participant