[build-only, do not merge] op-service: make the RPC pre-flight check proxy-aware - #2
Open
philippecamacho wants to merge 1 commit into
Open
[build-only, do not merge] op-service: make the RPC pre-flight check proxy-aware#2philippecamacho wants to merge 1 commit into
philippecamacho wants to merge 1 commit into
Conversation
IsURLAvailable probes an endpoint with a raw net.Dial before rpc.DialOptions is attempted. That dial ignores HTTP_PROXY/HTTPS_PROXY, so it tests a route the RPC client itself never takes. Inside an AWS Nitro enclave there is no direct route at all — every packet leaves through a local proxy — so the probe fails for every address and CheckAndDial gives up before reaching rpc.DialOptions, which would have succeeded. The TEE batcher dies during setup: failed to setup: failed to dial L1 RPC: operation failed permanently after 30 attempts: address unavailable (http://erpc...:4000/...) Probe whatever the client will actually dial: when a proxy is configured for the URL, check the proxy's address instead of the target's. With no proxy, behaviour is unchanged. Port defaulting moves into a hostPort helper so it applies to the proxy URL too, keeping the existing fail-open for schemes with no well-known port. The environment lookup is indirected through a package var because net/http reads proxy env once per process, which a test cannot undo. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not merge
This PR exists to build a test image. The fix belongs in
celo-org/optimismonespresso/batcher—op-service/client/rpc.gois byte-identical in both repos (blob63694ced…), and this fork's branch is celo-org's head plus the enclave-packaging commit, so anything else landed here is erased by the next sync. Opening it as a PR (rather than pushing to the branch) publishesop-batcher-enclave-app:pr-N/op-batcher-tee:pr-Nwithout touchingespresso/batcher, and closes cleanly afterwards.The bug
IsURLAvailableprobes an endpoint with a rawnet.Dialbeforerpc.DialOptionsis attempted:That dial ignores
HTTP_PROXY/HTTPS_PROXY, so it tests a route the RPC client itself never takes — the client dials the proxy.Inside an AWS Nitro enclave there is no direct route at all; every packet leaves through a local proxy on
127.0.0.1:10000. So the probe fails for every address, andCheckAndDialgives up before reachingrpc.DialOptions, which would have succeeded. The TEE batcher dies during setup, 30 attempts then exit 1:Not specific to that endpoint — the same check would reject every URL the batcher uses. L1 is simply dialled first.
The fix
Probe whatever the client will actually dial: when a proxy is configured for the URL, check the proxy's address instead of the target's. With no proxy, behaviour is unchanged.
Port defaulting moves into a
hostPorthelper so it applies to the proxy URL too, preserving the existing fail-open for schemes with no well-known port.The environment lookup is indirected through a package var because
net/httpreads proxy env once per process, which a test cannot undo. No new dependency —go.mod/go.sumare untouched.Verification
New tests cover: reachable/unreachable target with no proxy; target unreachable but proxy reachable (the enclave case, which fails without this change); proxy unreachable; unknown scheme fails open; and
hostPortdefaulting. The two pre-existing tests,TestIsURLAvailableLocalandTestIsURLAvailableNonLocal, still pass.That is unit-level only. The point of this PR is the image, so the real check is a TEE batcher on the Chaos testnet reaching erpc from inside the enclave. Results will be posted here before the celo-org PR is opened.
Framing for upstream
A pre-flight check that tests a path the client never uses is arguably an upstream bug rather than an Espresso quirk —
CheckAndDialand the timeout removal both came fromethereum-optimism(ethereum-optimism#13146, ethereum-optimism#16864). Worth proposing there once it has run in production.🤖 Generated with Claude Code