Skip to content

fix: wind down the signing domain refresh on shutdown - #679

Merged
MoonBoi9001 merged 10 commits into
mainfrom
mb9/stop-domain-refresh-cleanly-on-shutdown
Jul 20, 2026
Merged

fix: wind down the signing domain refresh on shutdown#679
MoonBoi9001 merged 10 commits into
mainfrom
mb9/stop-domain-refresh-cleanly-on-shutdown

Conversation

@MoonBoi9001

@MoonBoi9001 MoonBoi9001 commented Jul 20, 2026

Copy link
Copy Markdown
Member

This PR makes the background refresh of the agreement signing domain wind down as part of graceful shutdown, and drops a refresh still in flight when the stop signal arrives. That refresh keeps a running dipper in step with an in-place upgrade of the contract it signs against: it re-reads the contract's EIP-712 domain on a timer and keeps the current domain if a read fails.

Until now the refresh ran as a detached background task that ignored the shutdown signal entirely, so the process could tear down around a task still doing work. It now lives in its own module with the same stop handle every other long-running service has. Because the read goes out to an RPC provider, one that accepts the request and then goes quiet would otherwise hold the process open until it gave up, which can outlast a deployment's grace period. The stop signal wins over the read instead, at the cost of one read-only round trip.

The periodic refresh of the RCA EIP-712 signing domain, which lets a running dipper
follow an in-place contract upgrade, ran as a detached task that ignored shutdown. It
now joins the service task tree with a stop handle, so it winds down with everything else.
The refresh was only signalled to stop and left running while shutdown moved on, so it
could still be mid-refresh at exit. It now waits for the loop to drop its receiver, the
same way every sibling service stops. Also drops a stray em-dash from a nearby comment.
@MoonBoi9001 MoonBoi9001 changed the title refactor: shut down the RCA domain refresh cleanly refactor(service): shut down the RCA domain refresh cleanly Jul 20, 2026
The loop that periodically re-reads the signing domain from the contract lived in the
chain client module root, away from the function it drives and from the other supervised
background loops. It now sits beside them in network/service, with its types imported.
…lings

Shutting the refresh down meant sending on a raw channel and then waiting on it by hand,
inline in main, while every neighbouring service is stopped through a small handle type.
The refresh now offers the same handle, so the shutdown sequence reads the same throughout.
…e refresh

Startup already refuses to run unless the chain client is configured and enabled, yet the
domain refresh re-tested both and carried the resulting optional value through three call
sites whose fallback branches could never run. It now reads the validated config directly.
Waiting for an in-flight domain refresh to finish had no upper limit, so a provider that
stopped responding could hold up the whole shutdown sequence behind a single best-effort
RPC call. The wait now gives up after 15 seconds and warns instead of blocking.
Nothing checked that a tick reaches the refresh call, so the loop could stop following
contract upgrades without a single test noticing. The new case runs it on a virtual clock
and waits for three refreshes; tokio's test-util is enabled for the fake clock.
The loop logs a failed refresh and carries on, which is what keeps a temporary RPC outage
from silently ending the service. That behaviour had no test, so the new case fails every
attempt and checks the loop is still running and still trying.
The dipper re-reads the RecurringCollector signing domain on a timer, but a stop could not
interrupt that read, so a provider going quiet mid-request held the process open for minutes.
The read now loses to the stop signal and is dropped, costing one read-only round trip.
@MoonBoi9001 MoonBoi9001 changed the title refactor(service): shut down the RCA domain refresh cleanly fix: wind down the signing domain refresh on shutdown Jul 20, 2026
@MoonBoi9001
MoonBoi9001 merged commit 81f0d12 into main Jul 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant