feat(nano): add transfer header format and validation#1653
Open
jansegre wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/nano/global-address-balance-state #1653 +/- ##
===========================================================================
- Coverage 100.00% 85.01% -14.99%
===========================================================================
Files 1 480 +479
Lines 25 30162 +30137
Branches 0 4526 +4526
===========================================================================
+ Hits 25 25643 +25618
- Misses 0 3615 +3615
- Partials 0 904 +904
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a0cf66d to
81878a5
Compare
c50cae0 to
1672ba9
Compare
81878a5 to
cc941ca
Compare
2 tasks
cc941ca to
58d1ae0
Compare
1672ba9 to
791dd28
Compare
58d1ae0 to
ee7e6ff
Compare
ee7e6ff to
2022c13
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Part of RFC#108 that introduces the
TransferHeaderwire format, its parser, and its stateless/stateful validation — the bridge primitive between UTXOs and the global address-balance map described in the RFC. Consensus-time execution (actually debiting/crediting the global map, nano-contract caller-funded flows, seqnum commits) is intentionally left for a follow-up; this PR only lands the header so it can be serialized, parsed, and rejected when invalid.Acceptance Criteria
TransferHeadercan be attached to a transaction, carryingaddresses(authorization entries withaddress,seqnum,script),inputs(address_index,amount,token_index), andoutputs(address,amount,token_index), serialized under header id0x12.TRANSFER_HEADERfeature-activation flag and a matchingENABLE_TRANSFER_HEADERsetting gate the header at verification time; the consensus reorg rule invalidates any tx that still carries a transfer header after the feature deactivates.TransferHeaderVerifierenforces the RFC's structural rules: size limits on addresses/inputs/outputs, positive amounts, valid address/token indexes, regular-address-only credits, no duplicate(address, token)on either side, no same-pair on both sides, and every authorized address must be referenced by at least one input. EachInputAddress.scriptis evaluated against the address under opcodes V2 with sigop-count limits.MAX_SEQNUM_DIFF_MEMPOOL).Transaction.to_json/to_json_extendedsurface the transfer header (addresses, inputs, outputs, resolved token uids) andget_related_addressesincludes both debited and credited addresses so indexers and wallets can track them.nc_transfer_input/nc_transfer_outputattributes so tests can construct transactions with transfer headers, auto-assigning seqnums (shared with nano seqnums) and signing the header against the transaction sighash.Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged