espresso: deduplicate the generated contract bindings - #513
espresso: deduplicate the generated contract bindings#513philippecamacho wants to merge 2 commits into
Conversation
espresso/bindings shipped two large generated bindings that duplicated code already available elsewhere in the build. The package is now gone entirely. batch_authenticator.go (2277 lines) duplicated the binding already exported by the imported espresso-streamers module, and the two ABIs had diverged: the vendored copy predates the BatcherChangedThisBlock custom error, so it was a contract revision behind. Comparing both against packages/contracts-bedrock/snapshots/abi/BatchAuthenticator.json, the module's copy matches the current contract exactly and the vendored one is missing precisely that error. Nothing decodes custom errors from revert data today (geth's bind v1 BoundContract.Call does not unpack them, and neither op-batcher nor op-service/txmgr does so explicitly), so the staleness was latent rather than an active decoding bug -- but a second copy of a binding is a copy that drifts, and this one already had. Point op-batcher at github.com/EspressoSystems/espresso-streamers/op/bindings, imported as streamerBindings, as the canonical binding. system_config.go (2640 lines) existed for a single call, batcherHash(), used once to resolve the fallback batcher address -- and duplicated a binding the repo already generates. op-e2e/bindings/systemconfig.go is produced by `just gen-binding SystemConfig` (op-e2e/scripts/gen-binding.sh, abigen over the forge artifact) and already exports SystemConfigCaller.BatcherHash, so use it instead of vendoring or hand-rolling a third copy. op-e2e/bindings is a leaf package with no dependencies beyond go-ethereum, and shipped binaries already import it (op-chain-ops/cmd/check-fjord, op-chain-ops/cmd/check-jovian, op-devstack/dsl). Net: -4917 lines of generated code, no new code, and one canonical source for each binding. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ff41577 to
acef413
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acef413273
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
op-batcher now imports op-e2e/bindings for the generated SystemConfig binding, but Dockerfile.dockerignore excludes everything by default and re-included only /op-e2e/e2eutils, so `just op-batcher` inside the image failed on a missing package even though a full-checkout `go build ./...` succeeded. Nothing had exercised this before: the other non-e2e importers of that package (op-chain-ops/cmd/check-fjord, op-chain-ops/cmd/check-jovian, op-devstack/dsl) are not built by this Dockerfile, and /op-devstack is not in the context at all. op-batcher is the first binary in a production image to depend on it. Verified by building a probe image against this dockerignore: before the change /app/op-e2e contains only e2eutils; after it, bindings/systemconfig.go is present. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@philippecamacho Nice reduction in code. Just a general question: How are the streamer bindings generated? I'd say this repo's contract should be the source of truth for bindings, so we need to make sure they match. |
|
Hi @philippecamacho. I'm in agreement with @palango, it's strange to house the contract in this repo, but have generated bindings in another repo that this repo then uses. Instead I would suggest, writing a small interface in the espresso streamer that contains just the methods required by the streamer (currently just one) and then passing an instance of BatchAuthenticatorCaller to the streamer at construction. Then both the contract and bindings could live in this repo. |
|
Here's another comment from Claude:
|
Stacked on #459 (
espresso/batcher). Closes #504.Deletes
espresso/bindingsentirely: net −4,916 lines, no new logic.batch_authenticator.go(2,277 lines) duplicated the binding already exported by the importedespresso-streamersmodule — and had drifted from it. e.system_config.go(2,640 lines) existed for a single call,batcherHash(). The repo already generates that binding —op-e2e/bindings/systemconfig.go, viajust gen-binding SystemConfig— so op-batcher uses it rather than keeping a third copy.That import needs one line in
ops/docker/op-stack-go/Dockerfile.dockerignore. The file excludes everything by default and re-includes an allowlist, and op-batcher is the first binary in a production image to depend onop-e2e/bindings— the other non-e2e importers aren't built by that Dockerfile. Without the line the image fails on a missing package even though a full-checkoutgo build ./...succeeds. Longer term that package belongs outside the e2e tree, which is too broad for this PR (35 importers).Verified:
go build ./...,go vet,gofmt,go test ./op-batcher/..., anddocker build --target op-batcher-builder -f ops/docker/op-stack-go/Dockerfile .— all passing.🤖 Generated with Claude Code