feat: add bridgeservicefinder package#1692
Conversation
Resolves and serves the bridge service URL for every network attached to
a rollup manager, from three sources in strict priority: config, on-chain
aggchainMetadata ("BRIDGE_SERVICE_URL"), and trustedSequencerURL + port
5577. Enumerates networks via agglayermanager and keeps the cache updated
via a lightweight FilterLogs polling loop with health-gated updates, wired
into cmd/run.go behind a config flag.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude finished @arnaubennassar's task in 2m 25s —— View job Code Review Complete ✅Reviewing PR #1692: feat: add bridgeservicefinder package 🚀 What's NewThis PR introduces a new 🐛 Bug FixesNone. 📋 Config Updates[BridgeServiceFinder]
Enabled = false # Disabled by default
RollupManagerAddr = "{{L1NetworkConfig.RollupManagerAddr}}"
# Optional static networkID -> URL overrides (only way to configure network 0/L1)
# URLs = { 0 = "http://localhost:5577" }
BlockFinality = "FinalizedBlock" # Options: PendingBlock, LatestBlock, SafeBlock, FinalizedBlock, EarliestBlock
PollInterval = "30s"
BlockChunkSize = 10000
HealthCheckPath = "/health"
HealthCheckTimeout = "5s"
RequireAllHealthyOnStart = false # false = continue with unhealthy services
|
The package isn't consumed by anything yet — it will be wired up by a future component instead of being started directly from cmd/run.go, so drop the unused config plumbing and Start() call along with it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|



🔄 Changes Summary
bridgeservicefinderpackage that resolves and serves the bridge service URL for every network attached to a rollup manager, exposingNew(...),Start(ctx), andGetURL(networkID). Not yet wired intocmd/run.goor the app config — it's intended to be consumed by other components in the future.aggchainMetadatakey"BRIDGE_SERVICE_URL"on the aggchain contract, (3)trustedSequencerURL()with the port substituted to the hardcoded bridge REST port5577.RollupCount/RollupIDToRollupData) rather than a static list;networkID == rollupIDfor L2s, with network 0 (L1) only servable via config.FilterLogsover a configurable block-finality window) watchesSetTrustedSequencerURLandAggchainMetadataSetevents and updates the cache live, respecting source priority (config is never overridden) and a health-gating rule (only replace a cached URL with a new one if it's reachable, unless the previous URL was itself unreachable).test/contracts/rollupmanagermock,test/contracts/aggchainrollupmock) + generated bindings, verified against the realagglayermanager/aggchainbase/polygonrollupbaseetrogbindings via a smoke test.📋 Config Updates
✅ Testing
bridgeservicefinder/*_test.go) covering each source in isolation, all priority combinations, config-immunity to on-chain updates, metadata-over-sequencer precedence, multi-network initial-cache builds, unreachable-service handling atStart, live updates via both event types, and health-gating edge cases. A smoke test (test/contracts/bridgeservicefinder_mocks_test.go) confirms the mock contracts are selector/event-compatible with the real bindings.make build,make lint(0 issues),make test-unit, andmake generate-mocks(no diff) all verified clean.🐞 Issues
🔗 Related PRs
📝 Notes
aggchainMetadata/trustedSequencerURLcalls are treated as "source not available" (graceful fallthrough) on any contract-call error, since go-ethereum bindings don't reliably distinguish "method absent/reverted" from other RPC errors — this favors graceful degradation over strict error classification.Start()time (no historical backfill), since the initial cache build already covers the current state.cmd/run.go/config/*in this PR — a future component will construct and start the finder itself.