Skip to content

op-batcher: Rewrite ChannelManager#3859

Merged
mslipper merged 6 commits intodevelopfrom
jg/full_channel_manger
Nov 7, 2022
Merged

op-batcher: Rewrite ChannelManager#3859
mslipper merged 6 commits intodevelopfrom
jg/full_channel_manger

Conversation

@trianglesphere
Copy link
Copy Markdown
Contributor

Description

The channel manager is now responsible for tracking in flight frames and properly handling different error conditions.

A channel is a collection of frames. We have a single frame per L1 transaction.
When frames are submitted to L1 even if all frames are successfully included, their
inclusion may not be timely. The tx confirmation method handles resubmitting frames
if the transaction fails or voiding the entire channel if the channel times out.

It has hook points for how large a range of blocks to select, but does not use them
yet. It simply chooses up to 100 blocks (but it will also not submit channels that
are too large).

Tests

No unit tests yet. op-e2e still passing.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 2, 2022

⚠️ No Changeset found

Latest commit: a3d0466

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

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 2, 2022

This PR changes implementation code, but doesn't include a changeset. Did you forget to add one?

// If the range of blocks serialized to be too large, restore
// blocks that could not be included inside the channel
if len(leftOverBlocks) != 0 {
s.blocks = append(leftOverBlocks, s.blocks...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks right, I think a test case hitting this particular branch would be nice to see

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yea, this code also worried me a bit

@trianglesphere trianglesphere force-pushed the jg/clean_up_load_into_state branch from 67aa6d6 to 4f8d797 Compare November 2, 2022 23:19
if err != nil {
return nil, txID{}, err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps sanity check on the length of frames being less than math.MaxUint16 to prevent an overflow with the typecast, it should never happen but it would be a nice sanity check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gonna leave a TODO comment about this. It's a good idea, but has some trickiness when implementing it.

Copy link
Copy Markdown
Contributor

@tynes tynes left a comment

Choose a reason for hiding this comment

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

Will re-review after comments addressed

Base automatically changed from jg/clean_up_load_into_state to develop November 3, 2022 01:54
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 3, 2022

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

@mergify mergify bot added the conflict label Nov 3, 2022
The channel manager is now responsible for tracking in flight frames
and properly handling different error conditions.
@tynes
Copy link
Copy Markdown
Contributor

tynes commented Nov 3, 2022

Looks like not all comments have been addressed yet

@trianglesphere
Copy link
Copy Markdown
Contributor Author

Looks like not all comments have been addressed yet

Nope. I didn't re-request a review. The force push was a rebase.

Copy link
Copy Markdown
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

Changes look good, but I would prefer to defer the creation of frames until we include them into transactions, so we can better utilize the packing, instead of committing to a specific size of frame before we know the tx we can put them in.

And long-term I would like if we always pack frames from one or two channels per transaction: if a channel leaves data-tx space underutilized, we can start encoding the next channel in the same tx. Maybe it's too deep of a change for this PR, but we can keep the option more open to do so later? Outputting the frames early and using single channel txIDs makes that quite hard.

@trianglesphere
Copy link
Copy Markdown
Contributor Author

Maybe it's too deep of a change for this PR, but we can keep the option more open to do so later? Outputting the frames early and using single channel txIDs makes that quite hard

It is too large a change for this PR. It's tricky enough to handle multiple frames per channel with a single channel (you have to keep track of which block were submitted where).

In terms of the IDs, they're opaque IDs on purpose & when it becomes worth it pack multiple frames into a single L1 transaction we will be able to do that by only updating the channel manager.

@mslipper
Copy link
Copy Markdown
Contributor

mslipper commented Nov 4, 2022

@trianglesphere LGTM - you'll need to fix a misspelling in order to get the go tests to pass. Otherwise once @protolambda has a look I'll merge this while we update + fix hive.

@trianglesphere
Copy link
Copy Markdown
Contributor Author

I fixed the lint

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Nov 4, 2022

    driver.go:284:         ERROR[11-04|22:16:53.453] Failed to send transaction               role=batcher   err="failed to create tx: failed to get suggested gas tip cap: context canceled"

@trianglesphere
Copy link
Copy Markdown
Contributor Author

    driver.go:284:         ERROR[11-04|22:16:53.453] Failed to send transaction               role=batcher   err="failed to create tx: failed to get suggested gas tip cap: context canceled"

gah, I guess the first attempt at fixing this didn't work. I force pushed something that's trying to fix it.

Copy link
Copy Markdown
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

LGTM. Can merge after CI passes (except hive, which I'll work on fixing as soon as the geth rebase lands on develop)

@mslipper mslipper merged commit 4abae61 into develop Nov 7, 2022
@mslipper mslipper deleted the jg/full_channel_manger branch November 7, 2022 07:01
@mslipper mslipper mentioned this pull request Nov 10, 2022
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.

4 participants