Skip to content

op-batcher: enable graceful shutdown, closing current channel#5105

Merged
sebastianst merged 15 commits intoethereum-optimism:developfrom
BrianBland:brianbland/batch-submitter-graceful-shutdown
Mar 27, 2023
Merged

op-batcher: enable graceful shutdown, closing current channel#5105
sebastianst merged 15 commits intoethereum-optimism:developfrom
BrianBland:brianbland/batch-submitter-graceful-shutdown

Conversation

@BrianBland
Copy link
Contributor

@BrianBland BrianBland commented Mar 10, 2023

Description

This change is intended to enable graceful shutdowns for the BatchSubmitter when the Stop method is called.

In order to shut down safely, this first closes any current pending channel, then publishes any remaining frames on the channel back to the L1. Once the channel has been completely closed and submitted, the submitter loop should exit without loading any new L2 blocks into its local state.

One caveat is that a repeated failure to submit frames back to the L1 may cause this loop to hang even when a shutdown is desired, as this prioritizes channel completion over shutdown speed. This can be worked around by passing a channel into the Stop method with a reasonable deadline, as is now the case in at least one e2e test.

Tests

Added tests for various channel manager Close() behaviors, including "close before first use", "close with no pending channel", "close with pending channel", and "close when all transactions are failed"

Invariants

For changes to critical code paths, please list and describe the invariants or key security properties of your new or changed code.

Additional context

Add any other context about the problem you're solving.

Metadata

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2023

⚠️ No Changeset found

Latest commit: acdd051

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from b47e2f8 to b9d6331 Compare March 10, 2023 17:29
@BrianBland BrianBland marked this pull request as ready for review March 10, 2023 17:30
@BrianBland BrianBland requested a review from a team as a code owner March 10, 2023 17:30
@BrianBland BrianBland requested a review from mslipper March 10, 2023 17:30
@BrianBland BrianBland changed the title Gracefully shut down the BatchSubmitter, closing current channel batcher - enable graceful shutdown, closing current channel Mar 10, 2023
@BrianBland BrianBland changed the title batcher - enable graceful shutdown, closing current channel batcher: enable graceful shutdown, closing current channel Mar 10, 2023
Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this. I'd love to see some tests around this. Unit tests would be ideal, but we also have some frameworks which can handle more complex system setups.

@BrianBland
Copy link
Contributor Author

Thanks for implementing this. I'd love to see some tests around this. Unit tests would be ideal, but we also have some frameworks which can handle more complex system setups.

Agreed about the need for testing. I'll see what I can put together here.

@BrianBland
Copy link
Contributor Author

I believe that this should be technically tested by some of the e2e tests, such as TestMigration:

func TestMigration(t *testing.T) {

This is proving to be fairly difficult to unit test due to the dependency on the L1Client and L2Client *ethclient.Client fields. Is there a preferred framework we can use to simulate these blockchain dependencies?

@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from f62fc02 to 669445a Compare March 14, 2023 02:12
@mergify
Copy link
Contributor

mergify bot commented Mar 14, 2023

Hey @BrianBland! This PR has merge conflicts. Please fix them before continuing review.

@mergify mergify bot added the conflict label Mar 14, 2023
@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from 669445a to add81b5 Compare March 14, 2023 18:37
@BrianBland BrianBland changed the title batcher: enable graceful shutdown, closing current channel op-batcher: enable graceful shutdown, closing current channel Mar 14, 2023
@netlify
Copy link

netlify bot commented Mar 14, 2023

Deploy Preview for opstack-docs canceled.

Name Link
🔨 Latest commit acdd051
🔍 Latest deploy log https://app.netlify.com/sites/opstack-docs/deploys/6421ea489e7b5a00085695e5

@mergify mergify bot removed the conflict label Mar 14, 2023
@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from be11111 to ba5b58c Compare March 14, 2023 22:38
@mergify
Copy link
Contributor

mergify bot commented Mar 15, 2023

Hey @BrianBland! This PR has merge conflicts. Please fix them before continuing review.

@mergify mergify bot added the conflict label Mar 15, 2023
@trianglesphere trianglesphere self-requested a review March 16, 2023 17:49
Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

We should think about a way to not only test the channelManager but also the BatchSubmitter itself, because there's a lot going on now with different contexts, closing done channels etc.

@tynes
Copy link
Contributor

tynes commented Mar 20, 2023

Great work @BrianBland this is a super high leverage fix

@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from ba5b58c to 4ae79f8 Compare March 21, 2023 01:15
@mergify mergify bot removed the conflict label Mar 21, 2023
@BrianBland BrianBland force-pushed the brianbland/batch-submitter-graceful-shutdown branch from 3a6e76f to acdd051 Compare March 27, 2023 19:11
@BrianBland BrianBland requested review from sebastianst and trianglesphere and removed request for sebastianst March 27, 2023 19:16
Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

Looks good now!

It seems one fix got reverted, see comment.

@mergify
Copy link
Contributor

mergify bot commented Mar 27, 2023

This PR has been added to the merge queue, and will be merged soon.

@mergify
Copy link
Contributor

mergify bot commented Mar 27, 2023

Hey @BrianBland, this pull request failed to merge and has been dequeued from the merge train. If you believe your PR failed in the merge train because of a flaky test, requeue it by commenting with @mergifyio requeue.
More details can be found on the Queue: Embarked in merge train check-run.

@mergify mergify bot removed the on-merge-train label Mar 27, 2023
@BrianBland
Copy link
Contributor Author

@Mergifyio requeue

@mergify
Copy link
Contributor

mergify bot commented Mar 27, 2023

requeue

❌ Command disallowed due to command restrictions in the Mergify configuration.

Details
  • sender-permission>=write

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.

5 participants