Skip to content

Conversation

@benjamin-stacks
Copy link
Contributor

@benjamin-stacks benjamin-stacks commented Dec 17, 2025

I started doing this as part of #6762, but since this refactoring is a self-contained change, I figured I'd split it into its own PR.

Two primary changes:

  • split the 3000-line event_dispatcher.rs into multiple files to make it easier to work with, and
  • turn EventObserver into a "dumb" struct that contains nothing more than the actual subscriber information and has no functionality of its own, with the EventDispatcher being the one doing the real work.

I would strongly suggest reviewing commit-by-commit.

The individual commits are structured so that the largely mechanical changes (like moving code from one file to another) can be more quickly verified by diffing the code that was removed from one file with the corresponding code that was added to another. Also take note of the individual commit messages.

brice-stacks and others added 7 commits November 10, 2025 09:58
…3.0.0.1

Merge release/3.3.0.0.1 to master
…3.0.0.2

Merge Release/3.3.0.0.2 to master
The observer is now a pure data struct without any methods. All
functionality lives in the dispatcher; the observer just contains the
info where to send the data.

This is a largely mechanical change: cut & paste; delete now duplicate
`delete_payload` method; fix references.
No functional changes, only moving things around
Since the code in new files is just cut & paste from
`event_dispatcher.rs`, I kept the same header from there, but bumped
the year to 2025.
This is the final step to making `EventObserver` a "dumb" data object
that simply reflects the configuration of the registered observer.

Most of this change is straightforward. There is one thing that's worth
a mention, and that's the `ProposalCallbackHandler`, a concept that was
added in stacks-network#4228.
Because block proposal validation happens on a dedicated thread, those
validation events are handled a little specially.

Since `send_payload` now needs a dispatcher instance as the source of
the `db_path`, the list of observers alone is no longer enough.

For now I've elected to simply add the DB path to the
ProposalCallbackHandler and keep a non-method version of `send_payload`
around that gets the DB path passed in. Eventually I may have to clone
the dispatcher, but for now this approach had the smallest blast radius.

There wasn't any test coverage for this special behavior (at least not
on the event dispatcher side -- there are [some tests](https://github.com/stacks-network/stacks-core/blob/45381558f5e79554fc6e7930b0c4091e739e4992/stackslib/src/net/api/tests/postblock_proposal.rs#L234)
on the API side of things), so I added that as well.
Copy link
Contributor

@brice-stacks brice-stacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@jacinta-stacks jacinta-stacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up 👍

@benjamin-stacks benjamin-stacks added this pull request to the merge queue Jan 5, 2026
Merged via the queue into stacks-network:develop with commit ef4a697 Jan 5, 2026
618 of 622 checks passed
@benjamin-stacks benjamin-stacks deleted the refactor/event-dispatcher branch January 5, 2026 11:54
@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 73.96293% with 295 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.99%. Comparing base (0b60401) to head (3b166a4).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
stacks-node/src/event_dispatcher/tests.rs 70.07% 190 Missing ⚠️
stacks-node/src/event_dispatcher/db.rs 62.89% 82 Missing ⚠️
stacks-node/src/event_dispatcher/payloads.rs 91.51% 19 Missing ⚠️
stacks-node/src/event_dispatcher/stacker_db.rs 92.45% 4 Missing ⚠️

❌ Your project status has failed because the head coverage (67.99%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6765      +/-   ##
===========================================
- Coverage    68.95%   67.99%   -0.96%     
===========================================
  Files          582      586       +4     
  Lines       361570   361650      +80     
===========================================
- Hits        249312   245911    -3401     
- Misses      112258   115739    +3481     
Files with missing lines Coverage Δ
stacks-node/src/event_dispatcher.rs 72.27% <ø> (-3.97%) ⬇️
stacks-node/src/event_dispatcher/stacker_db.rs 92.45% <92.45%> (ø)
stacks-node/src/event_dispatcher/payloads.rs 91.51% <91.51%> (ø)
stacks-node/src/event_dispatcher/db.rs 62.89% <62.89%> (ø)
stacks-node/src/event_dispatcher/tests.rs 70.07% <70.07%> (ø)

... and 392 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b60401...3b166a4. Read the comment docs.

🚀 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.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants