Skip to content

refactor(ssz): lift shared coerce/shape logic out of vector and list#971

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-06-lift-ssz-coerce-shaping
Jun 12, 2026
Merged

refactor(ssz): lift shared coerce/shape logic out of vector and list#971
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:audit/arch-06-lift-ssz-coerce-shaping

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

Summary

The before-validators on the fixed-length vector and the variable-length list each repeated the same input-shaping block: reject strings and bytes (which would silently iterate into characters or ints), reject non-iterables, and materialize any other iterable into a length-checkable sequence.

This lifts that shaping into one shared classmethod on the sequence scaffolding base. Each subclass now keeps only the two things that genuinely differ:

  • its misconfiguration message (LENGTH vs LIMIT wording), and
  • its own element-count rule (exact count vs maximum).

Behavior

Behavior-preserving. Every exception message is reproduced byte-for-byte:

  • <Type>: Expected iterable of <Element>, got <type>
  • <Type>: Expected iterable, got <type>
  • the distinct misconfiguration and count-check messages stay in their respective subclasses.

Verified against the full-equality message assertions in tests/spec/ssz/test_collections.py (98 passed). just check is clean.

🤖 Generated with Claude Code

The vector and list before-validators duplicated the input-shaping
block that rejects strings and non-iterables and materializes other
iterables into a length-checkable sequence.

Lift that shaping into one shared base-class method on the sequence
scaffolding. Each subclass keeps only its distinct misconfiguration
message and its own element-count rule. All exception messages are
preserved exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit ffe0f10 into leanEthereum:main Jun 12, 2026
14 checks passed
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