Skip to content

node: newtype hashes and source node ids instead of raw [u8; 32] #1851

Closed

Description

@yigitdot

WarmingAllowance and the warming-credit seam pass both content hashes and source node identities as bare [u8; 32], so the compiler cannot tell them apart.

Concrete places this bites:

  • debit_speculative(source: [u8; 32], hash: [u8; 32], units: u64) — two adjacent same-typed parameters a caller can transpose silently.
  • source_for(hash: [u8; 32]) -> Option<[u8; 32]> takes a hash and returns a source of the same type.
  • The credit channel payload is mpsc::Sender<([u8; 32], u64)> carrying a source, while WarmingCreditSink::credit directly above it carries a hash. Identical tuple shape, nothing marks where the meaning flips.

The node crate has a real Hash type and deliberately degrades at this boundary (handlers/client/mod.rs does *hash.as_bytes()), so this is a conscious style choice rather than an oversight — filing it so the choice is revisitable rather than implicit.

Suggestion: a SourceId newtype and decdn_cache::Hash at this boundary. Pre-existing, surfaced by the #1803 review.

Activity

  1. added
    kind:chore
    area:node
    prio:low
    on Aug 26, 2026
  2. moved this from Backlog to Ready in deCDNon Aug 27, 2026
  3. moved this from Ready to In progress in deCDNon Aug 30, 2026
  4. moved this from In progress to Done in deCDNon Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:nodekind:choreprio:low

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions