mempool: align output policy with Handshake
Merged
WO
4mo ago+425+425+012345678901234567890123456789-135-135-012345678901234567890123456789
Summary
- align native Handshake output standardness with hsd v8
- classify null-data, unknown, and unspendable addresses and covenants centrally
- use exact hsd dust sizing, exemptions, fee rounding, and null-data ordering
- apply the shared classifications to checkpoint validation, UTXO handling, and GCS construction
- restore and extend policy tests for reserved addresses, unknown covenants, dust boundaries, fee scaling, and overflow
Reference parity
Compared against pinned hsd commit 9f013c1cb7f92edf94db69fbd69daf34adf655fb:
- https://github.com/handshake-org/hsd/blob/9f013c1cb7f92edf94db69fbd69daf34adf655fb/lib/primitives/address.js
- https://github.com/handshake-org/hsd/blob/9f013c1cb7f92edf94db69fbd69daf34adf655fb/lib/primitives/covenant.js
- https://github.com/handshake-org/hsd/blob/9f013c1cb7f92edf94db69fbd69daf34adf655fb/lib/primitives/output.js
- https://github.com/handshake-org/hsd/blob/9f013c1cb7f92edf94db69fbd69daf34adf655fb/lib/primitives/tx.js
- https://github.com/handshake-org/hsd/blob/9f013c1cb7f92edf94db69fbd69daf34adf655fb/lib/mempool/policy.js
Validation
- make build
- make unit-cover
- make unit-race
- make integration
- make hsd-interop
- make lint workers=2
- go vet ./... in the root, hnsutil, and hnsutil/psbt modules
- focused mempool, wire, blockchain, and GCS builder tests repeated 10 times
- git diff --check origin/main...HEAD
Summary by cubic
Aligns mempool output standardness and dust policy with Handshake hsd v8 for parity. Centralizes address and covenant classification across mempool, blockchain, and gcs to ensure consistent behavior.
- Refactors
- Standardness: treat unknown native address versions as nonstandard; reject unknown covenants unless the output is native nulldata (version 31); keep single-nulldata limit.
- Dust: match
hsdsizing and fee rounding; exempt native nulldata and state-carrying name covenants; add overflow-safe fee calculation. - Centralization: add
wire.Addresshelpers (IsNulldata,IsUnknown,IsUnspendable) andwire.Covenanthelpers (IsDustworthy,IsUnspendable); use them in checkpoint validation, UTXO unspendable checks, and basic filter (gcs) construction. - Tests: restore and extend policy tests for reserved address versions, unknown covenants, dust boundaries with custom fees, fee scaling, and overflow; add checkpoint and covenant/address classification tests.
Summary by CodeRabbit
- New Features
- Added clearer classification for addresses and covenants, including unknown, nulldata, dustworthy, and unspendable outputs.
- Improved transaction policy handling for standardness, dust thresholds, relay fees, and covenant validation.
- Bug Fixes
- Improved checkpoint and transaction checks for unusual addresses and covenant types.
- Corrected handling of unspendable outputs in transaction filtering and UTXO processing.
- Added safeguards for zero values and fee calculations that could overflow.
- Tests
- Expanded coverage for address, covenant, dust, fee, and transaction-standardness edge cases.