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

miner,eth: latest block as pending block on rollup #93

Merged
merged 2 commits into from
May 26, 2023

Conversation

protolambda
Copy link
Collaborator

@protolambda protolambda commented May 18, 2023

Description

This fixes the pending-block behavior to be more compatible with pre-bedrock assumptions: requests for the "pending" block/header get served the "latest" block. This prevents transactions from the tx-pool from being revealed before they are committed to by the sequencer

Additionally this updates other lesser used API endpoints that utilize the "pending" mining state as well:

  • debug-namespace methods do not serve state or receipts for the pending block, if not available like in the rollup case.
  • the pending-state in graph-QL queries (as hit by StateAndHeaderByNumberOrHash) continues processing as "latest" state when the pending state is not available, like in the rollup case.

And to prevent unnecessary pending-block computations, the worker in the miner package is changed to:

  • Do not update the pending-block snapshot when processing txs
  • Not triggering recommits: the Engine API does its own revising of payload builds with buildPayload, and thus we can disable the pending-block work-triggering parts by draining the events that create those, rather than processing them (in newWorkLoop). Draining is important, as unsubscribing would leave the producing subscription channels filling up, causing the engine API to hang after producing blocks.

The engine API will still be initiating tasks for block-building, but does so by merely using the block-building functionality of the worker, not the whole recommit and snapshot thing that still remains from L1 PoW days / pending-block support.

I also suspect that this improves sequencing performance, or at least reduces block-building lag spikes: rebuilding the pending block continuously on the head block which changes every 2 seconds, and re-applying transactions, is expensive. Previously this was worked-around on the sequencer node by setting the pending-block gas limit to be very low (5000 gas to effectively force the pending-blocks to be empty), but now it doesn't try to build it at all anymore, which means there is less contention around the state of the chain and the tx-pool.

Tests

ethereum-optimism/optimism#5736

Replaces #81

Fix CLI-3793

@protolambda
Copy link
Collaborator Author

do not merge until we figure out test-failures in ethereum-optimism/optimism#5736

@protolambda
Copy link
Collaborator Author

Figured out the issue: the producing-side of the chain-heads subscription started blocking the forkchoice API. There needs to be at least one subscriber, which is the miner apparently. So instead I now implemented it to drain the produced triggers, without creating pending-block computation work, as well as ignoring incoming news txs, rather than unsubscribing to the tx events. Monorepo e2e tests should pass now.

@protolambda
Copy link
Collaborator Author

cleaned up the diff a little bit more. Ready for review now

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

LGTM. Can you back port it to a new branch based off of release/v1.101105?

@ajsutton
Copy link
Contributor

@trianglesphere I've created a branch with this change and #95 back ported onto release/v1.101105: https://github.com/ethereum-optimism/op-geth/compare/aj/backport-pending-block-l1overhead

We probably should have a better name for that branch but I wasn't sure what pattern we used so shoved it under aj/ until someone has a better idea.

I think we should also get both PRs merged into optimism if we're happy with them.

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.

The flag was not included in the list of flags. Failed to start b/c of this.

}, utils.NetworkFlags, utils.DatabasePathFlags)

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.

lgtm

@protolambda protolambda merged commit bdab05c into optimism May 26, 2023
@protolambda protolambda deleted the fix-pending-block branch May 26, 2023 15:46
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