You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
op-deployer: strip the AST from bundled forge artifacts to cut forge's memory #24000
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
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.
Drop the lib/ sources that the compile cache doesn't reference. Keep license files. Test that forge verify-contract still works.
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
Bundles built through mktar contain no AST, and op-deployer's forge runs on them compile nothing.
Activity