Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(relayer): Support dynamic handover in production #1781

Merged
merged 13 commits into from
Sep 11, 2024
Merged

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Aug 24, 2024

The fast relayer can presently have multiple concurrent instances for a short period of time because there is no method of coordinating the "active" relayer. This can cause some collisions when both relayer instances attempt to fill the same transaction(s), and requires that the relayer be stopped via a SIGHUP, which is slightly awkward in the serverless environment.

This change instead uses redis as a coordination mechanism between relayer instances, such that a new relayer will update a specific redis record when it is ready to take over from any previous instance. Likewise, and existing instance will detect when the record is updated and will gracefully exit thereafter.

The fast relayer can presently have multiple concurrent instances
for a short period of time because there is no method of coordinating
the "active" relayer. This can cause some collisions when both relayer
instances attempt to fill the same transaction(s), and requires that the
relayer be stopped via a SIGHUP, which is slightly awkward in the
serverless environment.

This change instead uses redis as a coordination mechanism between
relayer instances, such that a new relayer will update a specific redis
record when it is ready to take over from any previous instance.
Likewise, and existing instance will detect when the record is updated
and will gracefully exit thereafter.
src/relayer/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@james-a-morris james-a-morris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to make this more generic for any/all bots? Or do we just want to implement this now for the fast relayer

@pxrl
Copy link
Contributor Author

pxrl commented Aug 28, 2024

is it possible to make this more generic for any/all bots? Or do we just want to implement this now for the fast relayer

The relayer in looping mode is currently the only bot that's really suited for this, because it has a natural recurring point to check for handover. The other bots don't yet have this so it's not really clear for me how they'd benefit from it...but in a world where they are more event-based (i.e. precomputing executions and waiting for the right block to execute them) then I think this could be pretty beneficial and would definitely be worth generalising.

src/clients/SpokePoolClient.ts Outdated Show resolved Hide resolved
src/relayer/index.ts Outdated Show resolved Hide resolved
@pxrl pxrl merged commit 7508b76 into master Sep 11, 2024
4 checks passed
@pxrl pxrl deleted the pxrl/handover branch September 11, 2024 14:10
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.

3 participants