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

Flashblocks BlockBuildingAlgorithm #254

Open
liamaharon opened this issue Nov 27, 2024 · 1 comment
Open

Flashblocks BlockBuildingAlgorithm #254

liamaharon opened this issue Nov 27, 2024 · 1 comment

Comments

@liamaharon
Copy link
Contributor

liamaharon commented Nov 27, 2024

A new BlockBuildingAlgorithm implementation is required for Flashblocks.

The idea is a timing config can be specified with the millis since last block it should "checkpoint". Checkpointing means to cache the orders at that point in time, and always use those orders as the head of the block when suggesting future blocks.

e.g. timings set to [250, 500, 750, 950] should result in:

  • While building block N
    • Between 0 - 250ms since block N-1, build_blocks produces and returns empty blocks
    • The first build_blocks call 250 - 500ms since block N-1 produces, caches, and returns f1 (Flashblock 1) using the existing simple gas price ordering algorithm.
    • Subsequent build_blocks calls 250 - 500ms since block N-1 returns f1.
    • The first build_blocks call 500 - 750ms since block N-1 produces, caches, and returns f2 (Flashblock 2) using the existing simple gas price ordering algorithm.
    • Subsequent build_blocks calls 500 - 750ms since block N-1 returns f2.
    • The first build_blocks call 750 - 900ms since block N-1 produces, caches, and returns f3 (Flashblock 3) using the existing simple gas price ordering algorithm.
    • Subsequent build_blocks calls 750 - 950ms since block N-1 returns f3.
    • The first build_blocks call 900 - ∞ms since block N-1 produces, caches, and returns f4 (Flashblock 4) using the existing simple gas price ordering algorithm.
    • Subsequent build_blocks calls 950 - ∞ms since block N-1 returns f4.

Notes

  • It should probably be a wrapper around an existing BlockBuildingAlgorithm implementation, like one that simply orders by gas price.
  • Flexible Flashblock counts and intervals per block
@minnoise
Copy link

minnoise commented Dec 5, 2024

Hi had some questions about these steps, wanted to give some scenarios and clarify my undestanding.

Between 0 - 250ms since block N-1, build_blocks produces and returns empty blocks

So the very first time build_blocks is called will fall into this bucket?

Also does returns empty blocks refer to build_block, which returns Result<Box<dyn BlockBuildingHelper>>, instead of build_blocks, which has no return value? Is the intention to eventually call input.sink.new_block?

The first build_blocks call 250 - 500ms since block N-1 produces, caches, and returns f1 (Flashblock 1) using the existing simple gas price ordering algorithm.

Say another call to build_blocks happens at 251 ms, so it falls into this bucket. We can call OrderingBuildingAlgorithm::build_blocks, which will end up calling input.sink.new_block? We cache f1 by caching the BlockBuildingHelperFromProvider that was created.

Subsequent build_blocks calls 250 - 500ms since block N-1 returns f1.

Another call to build_blocks happens at 252 ms, so it falls into this bucket. It saves these SimulatedOrders for later. Not sure how to return f1 as noted earlier.

The first build_blocks call 500 - 750ms since block N-1 produces, caches, and returns f2 (Flashblock 2) using the existing simple gas price ordering algorithm.

Another call to build_blocks happens at 501 ms, so it falls into this bucket. We add SimulatedOrders from the prior build_blocks call at 252ms to this current call's SimulatedOrders, and call OrderingBuildingAlgorithm::build_blocks.

Subsequent build_blocks calls 500 - 750ms since block N-1 returns f2.

Another call to build_blocks happens at 502 ms, so it falls into this bucket. It saves these SimulatedOrders for later. What happens if this is the last call to build_blocks, are these SimulatedOrders never submitted? Or are we guanteed a final build_blocks call post 950ms?

Thanks!

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

No branches or pull requests

2 participants