Skip to content

Added async utx cleaning#1735

Merged
alexeykiselev merged 60 commits into
masterfrom
async-utx
Sep 5, 2025
Merged

Added async utx cleaning#1735
alexeykiselev merged 60 commits into
masterfrom
async-utx

Conversation

@esuwu

@esuwu esuwu commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and refactorings to transaction handling, logging, and microblock mining in the codebase. The main themes are better logging (including transaction IDs), improved error handling and reporting in the miner, and refactoring of the UTX pool and related APIs for clarity and robustness.

MicroMiner improvements and logging:

  • Enhanced logging in MicroMiner to include transaction IDs and more detailed debug/error messages, using a custom logger and new helpers in logging.go. This includes logging dropped, inapplicable, and successfully applied transactions, and improved error reporting when returning transactions to the UTX pool. [1] [2] [3] [4] [5]
  • Added a new error ErrBlockIsFull to distinguish block fullness due to size or complexity limits.

UTX pool and transaction API refactoring:

  • Refactored UTX pool heap implementation to use a new heapItem type, improving heap safety and index tracking. This change also updates transaction selection logic for microblocks.
  • Updated UTX pool and transaction API methods for consistency and clarity (Count() to Len(), changes to validator construction, and transaction addition methods to include state validation where appropriate). [1] [2] [3] [4] [5]

Cleaner and validation changes:

  • Refactored the UTX pool cleaner to require scheme and use context for validation, improving testability and future extensibility. [1] [2] [3]
  • Removed unused methods from the stateWrapper interface and its mocks, simplifying the interface and related tests.

General codebase improvements:

  • Added new dependencies for logging and base58 encoding, and removed unused imports. [1] [2]
  • Minor code and comment cleanups for clarity and maintainability across several files.

These changes collectively improve the reliability, observability, and maintainability of transaction processing and microblock mining.

@esuwu esuwu requested review from alexeykiselev and nickeskov June 30, 2025 13:48
@esuwu esuwu removed the request for review from nickeskov July 1, 2025 09:24
alexeykiselev
alexeykiselev previously approved these changes Jul 1, 2025

@nickeskov nickeskov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still can panic with already modifying state because TxValidation method can be called in parallel with other state methods.

esuwu and others added 6 commits July 10, 2025 14:46
* Added logs for functions and locks

* Removed state locks from utx validator

* Added logs for utx locking

* removed logs

* Added a state map around add tx to utx because there no state lock inside anymore

* Changed workflow file to build with -race

* fixed the workflow file

* Fixed the workfile file

* Fixed the workflow file

* Changed the version back

* Fixed platforms

* Added args for amd64 only

* Refactor 'UtxPool' and 'Validator'.

* Added cancel context

* removed a binary

* removed a log

* Replaced dockerfile
'

* Removed cas when bulk validating

* Removed cas from reset list

* Fixed a go sum entry

* Returned the old version of bip39 hash

* Replaced channel to context cancellation

* Hash sum fixed

* Returned github actions and dockerfile code back

---------

Co-authored-by: Nikolay Eskov <mr.eskov1@yandex.ru>
Comment thread pkg/node/fsm/fsm.go Fixed
@esuwu esuwu requested a review from nickeskov August 14, 2025 22:20
Comment thread pkg/logging/logging.go
Comment thread pkg/miner/micro_miner.go
Comment thread pkg/miner/micro_miner.go
Comment thread pkg/miner/utxpool/transaction_bulk_validator.go Outdated
Comment thread pkg/miner/utxpool/transaction_bulk_validator.go Outdated
@nickeskov nickeskov added the enhancement New feature or request label Sep 4, 2025
alexeykiselev
alexeykiselev previously approved these changes Sep 4, 2025
@nickeskov nickeskov dismissed stale reviews from alexeykiselev and themself September 4, 2025 12:39

@alexeykiselev already reviewed this changes.

@nickeskov nickeskov added the wip This is a WIP, should not be merged right away label Sep 4, 2025
)

* UTX clean-up reimplemented with in-place transactions validation.

Pool item type heapItem added to store index of item in the heap.
Item index management implemented in heap.Interface implementation.
AllTransactions function now return slice of proto.Transaction.
Function Clean added to UtxPool interface and implemented.
Interface function Count renamed to Len, duplicated method removed from implementation.

* Review issues fixed.

Various pool implementation improvements.
Errors documentation comments updated.

* Check on space left in the block and fast path to abort micro-block mining added.
@nickeskov nickeskov removed the wip This is a WIP, should not be merged right away label Sep 5, 2025
@alexeykiselev alexeykiselev merged commit 2d3853f into master Sep 5, 2025
21 checks passed
@alexeykiselev alexeykiselev deleted the async-utx branch September 5, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants