Skip to content

refactor(memo): fold encode_request and encode_name_note policy - #2

Open
craftsoldier wants to merge 1 commit into
masterfrom
refactor/memo-fold-encoders
Open

refactor(memo): fold encode_request and encode_name_note policy#2
craftsoldier wants to merge 1 commit into
masterfrom
refactor/memo-fold-encoders

Conversation

@craftsoldier

Copy link
Copy Markdown
Contributor

What

Extract memo::classify_action(action, ua) so encode_request and encode_name_note share one copy of the per-action ua policy check (Release must have empty ua; Claim and Update must have non-empty ua).

Why

Both encoders previously had a byte-identical 6-arm match action { Release if !ua.is_empty() => FieldCount, Claim | Update if ua.is_empty() => EmptyArg, ... } block. A future edit to one but not the other is a silent strictness divergence in the memo grammar. One call site, one audit, no drift. This is the audit observation D2 (encoder drift) in docs/code_review.md.

Verification

$ cargo test -p zns-verify
test result: ok. 9 passed  (memo_tests)
test result: ok. 5 passed  (vectors)         <- sacred, unchanged
test result: ok. 5 passed  (verify_tests)
test result: ok. 5 passed  (commitment_tests)
test result: ok. 1 passed  (doc-tests)

No new clippy or doc warnings introduced by this change (pre-existing type_complexity warnings on the public parse_*_memo signatures are unchanged).

What this does NOT do

  • Does not touch any memo bytes, field ordering, grammar strictness, parser behavior, commitment code, or any cross-language test vector.
  • Does not introduce or remove any public API entry point.
  • The companion commitment-side refactor (inlining tagged_zns_hash's absorb steps) is tracked in a separate PR, since they target independent audit observations and can land or revert independently.

extract classify_action(action, ua) so encode_request and
encode_name_note share one copy of the Release-must-have-empty-ua /
Claim-and-Update-must-have-non-empty-ua policy. The two encoders can
no longer drift apart on the strictness check; one call site, one
audit.

No change to any emitted or accepted memo bytes. The sacred
cross-language vectors in tests/vectors.rs are unchanged and still
pass, as do all memo round-trip and reject tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant