Repository navigation
This is a hardening release. The reflection engine, the code generator, the hasher and treeproof went through many rounds of differential fuzzing, external audits and conformance testing. Both engines now produce the same bytes, roots, trees and errors for the same schema, bad input returns an error instead of panicking or allocating without bound, and the code generator is no longer in beta.
Breaking Changes
CompatibleUnionselectors now follow EIP-8016. Selectors are 1-based (1..127), so the first untagged variant is written as0x01instead of0x00. Schemas and values that use 0-based selectors need to be migrated.- The hash tree root of
ssz-type:"optional"fields changed (extended types only). Presence is now mixed in as a length, so an absent value and a present zero value no longer have the same root. The root is now the same as foroptional-list. Serialization is unchanged. Generated code keeps the old root until it is regenerated. - Validation is stricter. Some malformed input and schemas that older versions accepted are now rejected with an error. This includes list counts that do not fit the region, non-zero padding bits in bitvectors, trailing or missing bytes, hash tree roots of lists without a limit, conflicting size or type tags, zero-field containers with their own SSZ methods (use
ssz-type:"custom"for these) and spec-only bounds in code generated without dynamic expressions.
Added
- Classic SSZ
Union[T]with 0-based selectors anddynssz.None, next to the EIP-8016CompatibleUnion[T]. - Async hashing. Optional background hashing of large subtrees, enabled with
WithAsyncHashing(workers)orhasher.EnableAsyncHashing. - Recursive types, as long as every cycle goes through a variable-length field. Nesting depth is limited (default 1024) and can be set with
WithMaxNestingDepth,codegen.WithRecursionDepthordynssz-gen -recursion-depth. - Batched tree finalization.
GetTreenow builds a finalized read-only tree through the hashtree backend. NewNode.Finalize,treeproof.WithHashFnandtreeproof.NewWrapperWithHashFn. - Unknown-size stream decoding.
UnmarshalSSZReaderwith a negative size reads until EOF and only allocates for bytes that actually arrived. Generated code needs to be regenerated for this. - Limits for untrusted input:
WithMaxStreamSize, the per-callWithStreamSizeLimitandWithMaxNestingDepth. ssz-type:"-"to skip a struct field, andWithNoDelegationto ignore the generated methods of a type.dynssz-genoptions: custom header templates, per-typeskip-*settings in the config file,-recursion-depthand-remove.- New error values (
ErrStreamTooLarge,ErrSszSizeExceeded,ErrMaxDepthExceededand more),HashErr()onHasherandtreeproof.Wrapper, andReseton all encoders and decoders. - Big-endian (s390x) and 32-bit support, tested in CI. New examples (
chain-specs,streaming,merkle-proofs,fork-views,htr-caching) and a docs page about method delegation.
Changed
- Performance: generated code resolves the spec expressions of a type once per
DynSszinstance instead of on every call (regenerate to get this). Encoders and decoders are pooled per instance. The reflection engine sizes byte lists by their length, decodes byte slices without boxing and handlesuint64and byte-array elements as one block. - All size, offset and limit math is done in unsigned 64-bit with explicit range checks, so both engines are safe on 32-bit targets.
- Spec expressions are evaluated as exact rationals and rounded up once. The
govaluatedependency is gone. Aname:Nfallback syntax was added. - Both engines use the same rules for when the fastssz,
*Dynor view methods of a type are called. Promoted methods from embedded fields are no longer used, and fastssz is only used when no resolved spec value differs from the static tags.sszutils.Annotatenow works across packages and on views, type wrappers and union variants. - Conformance tests: the consensus-spec vectors (including Gloas) also run as a 32-bit build, and a new test runs every vector of the official
ethereum/ssz-specssuite on both engines. The differential fuzzer got an independent reference SSZ implementation and extra checks for trees, proofs, native hashing, sizes and streaming. - The code generator is now considered production ready.
hashtree-bindingsbumped to 0.2.6.
Fixed
- Panics and unbounded allocations on bad input (oversized declared lists, huge
bitsizevalues, stream over-reads, offset overflows, recursive payloads). - Cases where reflection and generated code framed, sized or hashed the same schema differently: views of view-serving types, custom types with spec-driven widths, overridden type hints, cross-package
Annotate, packed large uints, union variants with spec-only widths and code generated without dynamic expressions. - Hash tree roots of packed scopes with delegated elements,
Index-opened scopes, progressive lists under async hashing, partial chunks, shortuint128anduint256values, optionals and lists of type wrappers.HashTreeRootandGetTreenow agree and return backend errors. - Streaming: the streaming encoder of a static build wrote correct data behind wrong offsets for children with spec values. Unions, optionals, custom types and views are now framed the same way on buffer and reader paths.
treeproof: empty leaves fromProveMulti, caller memory being aliased, zero-padding gindices that could not be proven, 32-bit leaf overflow and an unbounded multiproof cache.- Zero-padding no longer writes into caller memory,
float32NaN bits are kept as is,NewDynSszcopies its spec map andRemoveTyperemoves both the value and the pointer form of a type.
Full changelog
Full changelog
- 36555b0 fix: remove both value and pointer forms in RemoveType (#259)
- 3d377da perf: handle uint64 and byte-array elements as one block in reflection (#258)
- 90de3df perf: decode reflection byte slices without boxing them (#257)
- f2782e3 Check the size against the platform int before SizeSSZ converts it (#256)
- 1697d38 Pre-release performance refinement: cheaper per-call lookups, byte-list sizing, pooled encoders and decoders (#255)
- 0af489a Run the official SSZ vectors from upstream main on generated types (#254)
- f48642c Size a spec-carrying child inline in a static build's streaming encoder (#253)
- c97b5f8 Add official SSZ conformance gate and independent fuzz oracles (#224)
- 6aadf51 Walk a generated type's static surface by reflection under WithNoDelegation (#251)
- 8da8c6c fix: bound the multiproof required-indices cache (#252)
- b72f006 Fix union variant framing, Index scopes, packed large-uint roots and field type hints (#249)
- 5fa342a ci: drop the block and state perftests from the benchmark workflow (#250)
- d98e54a ci: bump the all-actions group with 4 updates (#247)
- 5b640af fix: merge Annotate into TypeWrapper and union field tags (#245)
- cfdf656 Resolve the spec expressions of a generated type once per DynSsz instance (#244)
- 9689895 Frame a view of a view-serving type by its own ssz-static declaration, and bound lists of delegated elements by their guaranteed fixed section (#243)
- 102eda6 Honor Annotate on types from other packages and on view fields (#241)
- 19ade7b Keep a Collapse hint from reshaping an undeclared scope, and declare the four-bit justification bits as a bitvector (#240)
- a9b1d43 Fix async deferral of an undeclared scope, the reflect-API list bound, and expression-only custom widths (#239)
- 468eaae Generator refusals and parity for overridden, custom and static-build bounds; async hashing of undeclared scopes (#238)
- d110740 ci: bump the all-actions group with 5 updates (#236)
- 296dcc8 Gate fastssz delegation on any resolved spec value, resolve only what differs (#237)
- 990798f v1.4.0-pre3: follow-up fixes (#235)
- fc3de77 v1.4.0: follow-up correctness fixes from rounds seven to sixteen (#234)
- f36887b ci: bump the all-actions group with 7 updates (#233)
- 87cee6d v1.4.0-pre.3: pre-release correctness fixes, rounds three to eleven (#232)
- 0220b28 v1.4.0-pre.3: pre-release correctness fixes (#227)
- 5d3da8b ci: render unit and spec test output with a multiplexing log formatter (#230)
- 4498001 ci: bump the all-actions group with 4 updates (#226)
- 1d2fcbb spectests: move to the ethpandaops go-eth2-client fork and run the suite as a 32-bit build (#228)
- 7ba566b ci: bump the all-actions group with 5 updates (#225)
- 9152f45 Batched tree finalization (#222)
- 6457b59 fix: panic on HashTreeRoot/UnmarshalSSZ when bitsize spec value is very large (#220)
- df31af6 ci: bump actions/attest-build-provenance in the all-actions group (#219)
- ef56856 Fix latent codegen and reflection residuals (#218)
- c709b2c Harden integer conversions in generated SSZ code (#217)
- 3fa3402 HTR caching example: wrapper-based root caching with codegen support (#216)
- 8f48bfc Async hashing: opt-in background subtree reduction (#213)
- 69436f4 ci: bump the all-actions group with 5 updates (#215)
- 5bafc1d bump internal version to
1.4.0-pre.1(#214) - 5ed22f2 Differential fuzzing hardening: hash tree root semantics, validation, decoding, and a unified nesting bound (#212)
- 21784f1 ci: bump docker/login-action in the all-actions group (#211)
- b89780a Harden unknown-size stream errors and allocations (#210)
- e6c334c Fuzzing fixes: unknown-size stream over-read + codegen without-dynamic-expressions delegation (#209)
- fd0f745 Merge pull request #207 from pk910/pk910/unknown-size-stream-decoder
- 5914b11 Merge pull request #208 from pk910/pk910/fuzz4-test-coverage
- df837b9 Merge pull request #206 from pk910/pk910/fuzzer-findings4
- 23de289 Merge pull request #205 from pk910/pk910/extended-examples
- 75d9cc4 Merge pull request #204 from pk910/pk910/union-validation
- 1ea1900 Merge pull request #203 from pk910/pk910/fuzzer-findings3
- cf95792 Merge pull request #200 from pk910/dependabot/go_modules/examples/basic/all-go-deps-c75918bef0
- fc03680 Merge pull request #201 from pk910/dependabot/github_actions/all-actions-1bad4a276f
- 2051354 Merge pull request #202 from pk910/pk910/fuzzer-findings2
- 47a7543 Merge pull request #198 from pk910/dependabot/go_modules/all-go-deps-af9d9fbd46
- b1f6980 Merge pull request #199 from pk910/dependabot/github_actions/all-actions-b70452c881
- efc2fdf Merge pull request #197 from pk910/pk910/big-endian-arch
- c20adcf Merge pull request #196 from pk910/pk910/custom-codegen-header
- 4244159 Merge pull request #195 from pk910/pk910/format-expressions
- e681e39 Merge pull request #194 from pk910/dependabot/github_actions/all-actions-8e9cfb314e
- 231cfdb Merge pull request #193 from pk910/dependabot/github_actions/all-actions-b0629671b9
- 58c7287 Merge pull request #192 from pk910/pk910/fix-treeroot
- cbb5dca Merge pull request #190 from pk910/dependabot/github_actions/all-actions-ec6f05e430