Skip to content

Stream per-address pattern code (lazy Code from templates through writers) #97

Description

@CPerezz

create2_deploys/create_preimage_deploys with code_pattern: unique_jumpdest_pre_amsterdam materialize one unique 24,576-byte runtime per derived contract inside Expand's returned slice, and generator.Config.materializePreAlloc then retains every blob in Config.GenesisCode for the entire run — peak RSS grows ≈24.6 KB per derived contract (measured: 247.8 MB at 10k contracts, GC-bracketed heap probe; linear → ≈3.7 GB at spec-repricing-min.yaml's 150k, ≈37 GB at 1.5M), while Storage already streams via iter.Seq2.

PR #76's interim guard (added during review hardening) only warns above 2 GiB estimated residency and hard-fails above 64 GiB. Actually bounding residency requires:

  • a lazy Code source on templates.PreAllocEntity (e.g. CodeFn func() []byte or a code iterator alongside Storage),
  • teaching generator.Config.materializePreAlloc not to pin the bytes in GenesisCode,
  • updating every client writer (geth, besu, nethermind, reth) to emit code per-entity and release it.

Acceptance: building examples/spec-repricing-min.yaml shows peak RSS independent of salt_count; cross-client genesis roots byte-identical to today's; the 2 GiB specbuild warning removed or demoted.

Related: TODO(template-aware-budget) in internal/specbuild/build.go (per-template ProjectCost) — a sibling blind spot in the same seam, kept separate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions