Skip to content

Conversation

@glevco
Copy link
Contributor

@glevco glevco commented Jan 21, 2026

Depends on #1547

Motivation

There's a long-standing TODO on the VertexHandler to make the wallet processing of new txs asynchronous, via PubSub. This PR does this. I had to introduce a new event type to fire before the consensus, because the wallet expected its on_new_tx method to be called before all other asynchronous events the consensus emits.

Acceptance Criteria

  • Add new pubsub event NETWORK_NEW_TX_PROCESSING.
  • Refactor wallet on the VertexHandler so it handles NETWORK_NEW_TX_PROCESSING events asynchronously, instead of a synchronous call to wallet.on_new_tx().
  • Fix tests.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@glevco glevco self-assigned this Jan 21, 2026
@glevco glevco removed the status in Hathor Network Jan 21, 2026
@glevco glevco moved this to Todo in Hathor Network Jan 21, 2026
@glevco glevco force-pushed the refactor/wallet-on-new-tx branch from c66ad17 to eaef7cd Compare January 21, 2026 02:42
@glevco glevco moved this from Todo to In Progress (WIP) in Hathor Network Jan 21, 2026
@glevco glevco force-pushed the refactor/wallet-on-new-tx branch from eaef7cd to e0a08c0 Compare January 21, 2026 03:33
@glevco glevco moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Jan 21, 2026
@glevco glevco force-pushed the feat/critical-indexes branch from 452fd4a to 2199ef8 Compare January 21, 2026 13:34
@glevco glevco moved this from In Progress (Done) to In Progress (WIP) in Hathor Network Jan 21, 2026
@glevco glevco force-pushed the refactor/wallet-on-new-tx branch from e0a08c0 to 38ae478 Compare January 21, 2026 13:39
@glevco glevco moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Jan 21, 2026
@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.28%. Comparing base (11f318d) to head (6bf9bd3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1561      +/-   ##
==========================================
- Coverage   86.29%   86.28%   -0.02%     
==========================================
  Files         437      437              
  Lines       33642    33649       +7     
  Branches     5257     5257              
==========================================
+ Hits        29031    29033       +2     
- Misses       3602     3608       +6     
+ Partials     1009     1008       -1     

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

@glevco glevco force-pushed the refactor/wallet-on-new-tx branch from 38ae478 to 6fc3b8b Compare January 21, 2026 14:19

self._register_wallet(wallet)

def _register_wallet(self, wallet: BaseWallet | None) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this registration be done elsewhere? Maybe at HathorManager or the builder?

Copy link
Member

Choose a reason for hiding this comment

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

This refactor will be very useful to create multiple wallets in tests.

address = manager.wallet.get_unused_address(mark_as_used=False)

blocks = add_new_blocks(manager, settings.REWARD_SPEND_MIN_BLOCKS + 1)
blocks = add_new_blocks(manager, settings.REWARD_SPEND_MIN_BLOCKS + 1, advance_clock=1)
Copy link
Member

Choose a reason for hiding this comment

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

Why not add advance_clock=1 by default in add_new_blocks()?

self._tx_storage.save_transaction(vertex)
with non_critical_code(self._log):
self._tx_storage.indexes.add_to_non_critical_indexes(vertex)
self._pubsub.publish(HathorEvents.NETWORK_NEW_TX_PROCESSING, tx=vertex)
Copy link
Member

Choose a reason for hiding this comment

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

Should we refactor all event publications from the consensus to the vertex handler? This would allow us to publish everything after the consensus has executed.

@github-project-automation github-project-automation bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Jan 21, 2026
@glevco glevco force-pushed the feat/critical-indexes branch 2 times, most recently from 00e1894 to 945a67f Compare January 21, 2026 17:15
Base automatically changed from feat/critical-indexes to master January 21, 2026 20:55
@glevco glevco force-pushed the refactor/wallet-on-new-tx branch from 6fc3b8b to 6bf9bd3 Compare January 22, 2026 13:28
@github-actions
Copy link

🐰 Bencher Report

Branchrefactor/wallet-on-new-tx
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
minutes (m)
(Result Δ%)
Lower Boundary
minutes (m)
(Limit %)
Upper Boundary
minutes (m)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
1.68 m
(-2.29%)Baseline: 1.72 m
1.55 m
(92.11%)
2.06 m
(81.43%)
🐰 View full continuous benchmarking report in Bencher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review (WIP)

Development

Successfully merging this pull request may close these issues.

3 participants