Skip to content

feat(nano): execute standalone transfer headers#1654

Open
jansegre wants to merge 1 commit into
feat/nano/transfer-headerfrom
feat/nano/transfer-header-execution
Open

feat(nano): execute standalone transfer headers#1654
jansegre wants to merge 1 commit into
feat/nano/transfer-headerfrom
feat/nano/transfer-header-execution

Conversation

@jansegre

@jansegre jansegre commented Apr 16, 2026

Copy link
Copy Markdown
Member

Motivation

This PR is part of the implementation of RFC #108. The prior commits on this branch added the TransferHeader format, validation, and the underlying global address-balance state; this step wires standalone transfer-header transactions into block execution so they actually move funds in the global balance map.

Before this change, only nano-contract transactions were picked up by the block executor. Transactions that carry only a TransferHeader (no nano-contract call) were parsed and validated but had no effect on state. This PR makes them first-class participants in block execution alongside nano-contract calls.

Acceptance Criteria

  • The block executor collects both nano-contract and transfer-header transactions, sorts them together in topological order, and executes them sequentially so each tx sees the state produced by its predecessors.
  • Standalone transfer-header transactions debit and credit the global address-balance map, enforce per-address seqnum progression, and fail with NCInsufficientFunds when an input address lacks balance.
  • Execution results carry the resulting NCBlockStorage explicitly (not only a Runner), letting the consensus layer commit state for transfer-header txs, voided nano txs (seqnum-only updates), and failed nano txs that still need their partial state persisted.
  • The sorter groups transactions by (address, seqnum) from either a nano header or a transfer header, so transfer-header-only txs are ordered correctly relative to nano calls sharing an address.
  • Reorgs correctly discard global-balance state produced on the losing chain and restore balances/seqnums from the winning chain, verified by a new consensus test.
  • A new test also covers the end-to-end path: a nano contract seeds a caller's global balance, a standalone transfer-header tx then moves funds between addresses, and balances reflect the transfer at the confirming block.

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

@jansegre jansegre self-assigned this Apr 16, 2026
@jansegre jansegre requested a review from msbrogli as a code owner April 16, 2026 16:28
@jansegre jansegre moved this from Todo to In Progress (WIP) in Hathor Network Apr 16, 2026
@jansegre jansegre requested a review from glevco April 16, 2026 16:28
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.92593% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.00%. Comparing base (791dd28) to head (f12e584).

Files with missing lines Patch % Lines
hathor/nanocontracts/execution/block_executor.py 79.62% 11 Missing and 11 partials ⚠️
.../nanocontracts/execution/dry_run_block_executor.py 18.18% 6 Missing and 3 partials ⚠️
...anocontracts/execution/consensus_block_executor.py 61.90% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/nano/transfer-header    #1654      +/-   ##
=============================================================
- Coverage                      85.01%   85.00%   -0.02%     
=============================================================
  Files                            480      480              
  Lines                          30162    30283     +121     
  Branches                        4526     4561      +35     
=============================================================
+ Hits                           25643    25741      +98     
- Misses                          3615     3622       +7     
- Partials                         904      920      +16     
Flag Coverage Δ
test-lib 84.98% <75.92%> (-0.02%) ⬇️

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.

@jansegre jansegre force-pushed the feat/nano/transfer-header branch from c50cae0 to 1672ba9 Compare April 20, 2026 20:28
@jansegre jansegre force-pushed the feat/nano/transfer-header branch from 1672ba9 to 791dd28 Compare May 12, 2026 13:41
@jansegre jansegre force-pushed the feat/nano/transfer-header-execution branch from 438188c to f12e584 Compare May 12, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress (WIP)

Development

Successfully merging this pull request may close these issues.

1 participant