-
Notifications
You must be signed in to change notification settings - Fork 38
refactor: wallet on_new_tx #1561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
c66ad17 to
eaef7cd
Compare
eaef7cd to
e0a08c0
Compare
452fd4a to
2199ef8
Compare
e0a08c0 to
38ae478
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
38ae478 to
6fc3b8b
Compare
|
|
||
| self._register_wallet(wallet) | ||
|
|
||
| def _register_wallet(self, wallet: BaseWallet | None) -> None: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
00e1894 to
945a67f
Compare
6fc3b8b to
6bf9bd3
Compare
|
| Branch | refactor/wallet-on-new-tx |
| Testbed | ubuntu-22.04 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark 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%) |
Depends on #1547
Motivation
There's a long-standing TODO on the
VertexHandlerto 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 itson_new_txmethod to be called before all other asynchronous events the consensus emits.Acceptance Criteria
NETWORK_NEW_TX_PROCESSING.walleton theVertexHandlerso it handlesNETWORK_NEW_TX_PROCESSINGevents asynchronously, instead of a synchronous call towallet.on_new_tx().Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged