primitives%feat: implement {Addr,Service,NetInfo}{V1,V2}, define surrounding traits (Net{Addr,Info}), define Checkable, add synthetic vectors, correct impl. errors#12
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (17)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (14)
📝 WalkthroughWalkthroughReplaces the struct-based ChangesNetwork Address Types Overhaul
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning This pull request may have conflicts, please coordinate with the authors of these pull requests. Potential conflicts |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Motivation
Due to a hard dependency on
stdinrust-bitcoinfor its Addr types, we've had to implement our own equivalent types, which proved to be more involved as unlike Bitcoin, Dash embeds addresses (and services, which is an address paired with a port) in its transaction data, making it no longer just a P2P concern but consensus-critical for on-chain data.This pull request implements the semantics to more closely match what is expected by validation routines in Dash Core, alongside synthetic test vectors to validate extended addresses in preparation for a V24 fork.
Additional Information
utf8serde codec to process domain names, preserve unknown values, drop legacy macro #11DisplayandFromStrform a lossless round-trip for all address and service types across both versions.FromStrfor V1 types explicitly rejects.onionand.b32.i2pwithNetAddrError::AddrTooNew.From<{Addr,Service}V1> for {Addr,Service}V2(infallible upgrade) andTryFrom<{Addr,Service}V2> for {Addr,Service}V1. Atype_cvrt!macro indash-typesgenerates both the owned and borrowedFrom/TryFromimpls from a single closure.Checkableimpls (ProRegTx,ProUpServTx) now delegate to the type-levelcheck()calls andNITraitqueries instead of reimplementing validation inline.ProTxInvalid::NetInfoInvalidnow includes the underlyingNIError.Breaking Changes
ExtendedNetInfohas been renamed toNetInfoV2.NetInfoEntryhas been renamed toNIEntry.NetInfoPurposehas been renamed toNIPurpose.I2Pvariant onAddrV2has been renamed toI2p.AddrV2has changed to a fixed-size enum. Field access via.networkand.addrmust use.network()and.bytes()methods.NIEntryCodereplaces the bare0x01/0x02literals in codec paths with a typed enum (Service,Domain,Unknown(u8)).NIEntry::Invalidhas been removed. Unknown entry types now fail at decode time.Corrections
MAX_ENTRIEScorrected from 8 to 4.NIEntry::Servicecorrected toServiceV2fromServiceV1.How Has This Been Tested?
Checklist