Skip to content

fix!: remove truncating VariableList conversions and migrate consumers#70

Merged
storopoli merged 4 commits intomainfrom
STR-2856-fix-silent-truncation
Apr 7, 2026
Merged

fix!: remove truncating VariableList conversions and migrate consumers#70
storopoli merged 4 commits intomainfrom
STR-2856-fix-silent-truncation

Conversation

@storopoli
Copy link
Copy Markdown
Member

Description

  • remove From<Vec<T>> for VariableList<T, N> because it silently truncated oversized inputs
  • add TryFrom<Vec<T>> for VariableList<T, N> backed by VariableList::new(...)
  • update ssz_types decode/docs/tests to use checked construction
  • migrate repo-local consumers, benches, and generated code to checked VariableList construction
  • refresh ssz_codegen expected outputs to match the new generated code
  • preserve infallible view/codegen-owned conversion APIs where length is already validated, using checked construction internally with expect("valid view")

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency update
  • Security fix

Notes to Reviewers

This is breaking, that's why the last commit bumps the version to 0.15.0

  • The main behavioral change is that oversized Vec<T> values can no longer be converted into VariableList<T, N> by truncation.
  • Repo-local consumers were migrated to VariableList::try_from(...) or VariableList::new(...).expect("valid view") depending on whether the path is externally fallible or already protected by SSZ/view invariants.
  • ssz_codegen generated output changed in many snapshot files because list-to-owned conversion now uses checked construction.
  • This is split into two commits:
    • fix(ssz_types): remove truncating VariableList conversion
    • fix(codegen): migrate VariableList consumers to checked constructors

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

STR-2856 and subtasks from it: STR-2857 and STR-2858

@storopoli storopoli requested a review from delbonis April 7, 2026 16:57
@storopoli storopoli self-assigned this Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@delbonis delbonis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now I would kinda expect that new wouldn't take any arguments and would always construct an empty list, since now it's behaviorally duplicating try_from.

@storopoli storopoli added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit 6e4b99e Apr 7, 2026
10 checks passed
@storopoli storopoli deleted the STR-2856-fix-silent-truncation branch April 7, 2026 18:54
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.

2 participants