Skip to content

Refactor NoteTag account targets to contain up to 32 bits #2309

@PhilippGackstatter

Description

@PhilippGackstatter

After #2285 is done, AccountStorageMode::Network should have been removed, and once that happens, we can simplify the NoteTag::with_account_target API further and use the full 32 bits of a note tag instead of at most 30 bits.

One difficulty is that RoutingParameters relies on NoteTag::MAX_ACCOUNT_TARGET_TAG_LENGTH to be 30 since its 5-bit format can only encode 2^5 = 32 values, and 31 is reserved to signal the absence of a note tag.

The potential solutions are:

  • Allow up to 32 bits in RoutingParameters::note_tag_len and:
    • Reduce address interface from 11 to 10 bits and increase note tag from 5 to 6 bits.
      • This would waste quite a bit of available space for the note tag.
    • Move note tag length encoding to a separate byte, making more room. This means two bytes in total for address interface and note tag, instead of one as now.
      • This wastes even more space.
  • Continue enforcing that at most 30 bits can be encoded in RoutingParameters::note_tag_len even though the NoteTag itself can support up to 32.

My preference is the latter option:

  • 30 bits in a note tag already sufficiently reduce the set of potential target accounts.
  • Network notes targeted at accounts are no longer identified by the note tag, so the requirement for having it be as precise as possible is no longer relevant.
  • Leaves the address as small as it is.

So the tasks would be:

  • Refactor NoteTag account targets to allow for up to 32 bits.
  • Introduce a RoutingParameters::MAX_NOTE_TAG_LENGTH = 30 and use it to enforce max note tag len, instead of relying on NoteTag::MAX_ACCOUNT_TARGET_TAG_LENGTH which would be 32 at that point.

Context: #2219 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedSomething prevents working on thisgood first issueGood for newcomersrustIssues that affect or pull requests that update Rust code

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions