Skip to content

op-deployer: strip the AST from bundled forge artifacts to cut forge's memory #24000

Closed

Description

@sebastianst

Part of #23300. Follow-up to #23664, related to #23995.

Problem

On contracts-bedrock, each forge run of an op-deployer script peaks at about 1.4–1.5 GB of memory. The cause is not the number of artifacts. contracts-bedrock builds with ast = true (foundry.toml:42), and the AST is about 80% of the artifact bytes. At start, forge parses the artifact of every file in the src/ graph plus the target's imports, AST included.

Measured over op-deployer's live forge scripts in TestEndToEndApply:

Bundle Peak memory per forge run Bundle .tzst
Today 1.41–1.53 GB 18.7 MB
ast stripped from the artifacts after the build 0.35–0.38 GB 13.1 MB
Stripped, plus the lib/ sources that the compile cache doesn't reference dropped 0.35–0.38 GB 2.1 MB

The stripped bundle stays warm: no op-deployer script compiles. The e2e apply, the Go script host and TestApplyGenesisStrategy pass on it, and the deployed bytecode is unchanged. Turning ast off for the whole build isn't an option, because the repo's checks read it: semver-lock, snapshots, interfaces and others.

Proposal

  1. Strip ast from the artifacts in mktar (main.go). Every bundle goes through it: the embedded one, the Docker and melange builds, and publish-artifacts.sh. Keep artifacts/build-info and cache/. If either is missing, forge discards the cached artifacts and compiles.
  2. Drop the lib/ sources that the compile cache doesn't reference. Keep license files. Test that forge verify-contract still works.
  3. Revisit the forge slots (slots.go:42-52): forgeRunMemory, the one-run-per-two-CPUs rule, and the slotPool comment. Bundles that bypass mktar keep the AST: a file:// locator to a local build (download.go:82), as sysgo (deployer.go:268) and op-e2e (init.go:254) use in CI. So the slot sizing has to stay safe for them, or those paths have to use stripped artifacts too.

Done when

🤖 Co-created with Claude Opus 5.5

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions