Skip to content

refactor(vertex-parser): Move serialization and deserialization to vertex parser module#1597

Merged
msbrogli merged 1 commit intomasterfrom
refactor/vertex-parser-package
Mar 4, 2026
Merged

refactor(vertex-parser): Move serialization and deserialization to vertex parser module#1597
msbrogli merged 1 commit intomasterfrom
refactor/vertex-parser-package

Conversation

@msbrogli
Copy link
Member

@msbrogli msbrogli commented Feb 12, 2026

Motivation

This refactor extracts all binary serialization and deserialization into a dedicated hathor/transaction/vertex_parser/ package, turning vertex classes into pure data containers that delegate to the parser module.

Acceptance Criteria

  • All binary serialization/deserialization for vertices (blocks, transactions, token creation, on-chain blueprints, PoA blocks) is handled by dedicated modules under
    hathor/transaction/vertex_parser/, organized by vertex type (_block.py, _transaction.py, _token_creation.py, _on_chain_blueprint.py, _common.py)
  • Header serialization/deserialization (NanoHeader, FeeHeader) is extracted into _nano_header.py, _fee_header.py, and _headers.py within the vertex parser package
  • A unified public API module (vertex_serializer.py) exposes top-level functions (serialize, serialize_funds, serialize_graph, serialize_sighash, get_sighash_data, etc.) that
    route to the appropriate type-specific serializer based on TxVersion
  • Model classes (Block, Transaction, TokenCreationTransaction, etc.) retain their get_funds_struct(), get_graph_struct(), create_from_struct(), and get_sighash_all() methods
    but delegate to the vertex parser functions rather than implementing serialization inline
  • TxInput and TxOutput serialization (bytes, get_sighash_bytes, create_from_bytes) delegates to the vertex parser
  • The former hathor/transaction/vertex_parser.py file is renamed to _vertex_parser.py inside the new package, preserving the VertexParser class and its import path via
    init.py

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

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

🐰 Bencher Report

Branchrefactor/vertex-parser-package
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.59 m
(-7.15%)Baseline: 1.71 m
1.54 m
(96.93%)
2.05 m
(77.37%)
🐰 View full continuous benchmarking report in Bencher

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 87.13318% with 114 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@9d036e3). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...hor/transaction/vertex_parser/vertex_serializer.py 77.32% 31 Missing and 8 partials ⚠️
hathor/transaction/vertex_parser/_nano_header.py 74.71% 11 Missing and 11 partials ⚠️
...r/transaction/vertex_parser/_on_chain_blueprint.py 62.50% 9 Missing and 9 partials ⚠️
hathor/transaction/base_transaction.py 56.52% 10 Missing ⚠️
hathor/transaction/vertex_parser/_block.py 85.71% 4 Missing and 4 partials ⚠️
hathor/transaction/vertex_parser/_headers.py 87.93% 4 Missing and 3 partials ⚠️
hathor/transaction/merge_mined_block.py 84.21% 3 Missing ⚠️
hathor/nanocontracts/on_chain_blueprint.py 93.33% 1 Missing and 1 partial ⚠️
...athor/transaction/vertex_parser/_token_creation.py 97.43% 2 Missing ⚠️
hathor/transaction/vertex_parser/_transaction.py 96.22% 1 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1597   +/-   ##
=========================================
  Coverage          ?   85.58%           
=========================================
  Files             ?      449           
  Lines             ?    33946           
  Branches          ?     5309           
=========================================
  Hits              ?    29051           
  Misses            ?     3872           
  Partials          ?     1023           
Flag Coverage Δ
test-lib 85.58% <87.13%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch from 072a033 to e449c5f Compare February 12, 2026 20:34
@msbrogli msbrogli force-pushed the master branch 2 times, most recently from eb416fa to 21d7909 Compare February 12, 2026 23:12
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch 6 times, most recently from 439bf16 to cb60176 Compare February 13, 2026 05:26
@msbrogli msbrogli moved this from Todo to In Progress (Done) in Hathor Network Feb 13, 2026
@msbrogli msbrogli moved this from In Progress (Done) to In Review (WIP) in Hathor Network Feb 18, 2026
jansegre
jansegre previously approved these changes Feb 23, 2026
@jansegre jansegre moved this from In Review (WIP) to In Review (Done) in Hathor Network Feb 23, 2026
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch 3 times, most recently from 1ec4873 to 57b1099 Compare February 23, 2026 20:36
jansegre
jansegre previously approved these changes Feb 23, 2026
r4mmer
r4mmer previously approved these changes Feb 24, 2026
@github-project-automation github-project-automation bot moved this from In Review (Done) to In Review (WIP) in Hathor Network Feb 24, 2026
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch from 57b1099 to b4c807b Compare February 24, 2026 15:50
@jansegre jansegre moved this from In Review (WIP) to In Review (Done) in Hathor Network Feb 24, 2026
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch from b4c807b to 056d53e Compare March 3, 2026 22:00
@msbrogli msbrogli moved this from In Review (Done) to In Progress (Done) in Hathor Network Mar 3, 2026
@msbrogli msbrogli dismissed stale reviews from r4mmer and jansegre via 0e965cf March 4, 2026 19:23
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch from 056d53e to 0e965cf Compare March 4, 2026 19:23
@msbrogli msbrogli moved this from In Progress (Done) to In Review (WIP) in Hathor Network Mar 4, 2026
@msbrogli msbrogli force-pushed the refactor/vertex-parser-package branch from 0e965cf to ac98edd Compare March 4, 2026 20:17
@msbrogli msbrogli merged commit ac98edd into master Mar 4, 2026
30 of 31 checks passed
@msbrogli msbrogli deleted the refactor/vertex-parser-package branch March 4, 2026 20:17
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Mar 4, 2026
@jansegre jansegre mentioned this pull request Mar 5, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting to be deployed

Development

Successfully merging this pull request may close these issues.

3 participants