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

Add support for generating multiple block proofs at once #296

Closed
BGluth opened this issue Apr 17, 2024 · 8 comments
Closed

Add support for generating multiple block proofs at once #296

BGluth opened this issue Apr 17, 2024 · 8 comments
Assignees

Comments

@BGluth
Copy link
Member

BGluth commented Apr 17, 2024

It has come up during benchmarking that it would be useful to test what it is like to generate multiple block proofs simultaneously.

The motivation for this comes from the fact that the amount of parallelizable work diminishes as generation progresses for a block proof. The reason for this is due to the trie structure from aggregating txn proofs together into a final block proof, the amount of work units available quickly decreases as we move up the proof aggregation trie. This quickly leads to a situation where CPU utilization drops off after a good portion of the proof tree becomes completed.

Because it's useful to benchmark a more realistic scenario where we have multiple blocks being proved at once, we probably should add a new mode that support generating a range of blocks. This should be pretty straight forward to implement I think.

@vladimir-trifonov
Copy link
Contributor

@BGluth this issue is a duplicate of #10, right?

@BGluth
Copy link
Member Author

BGluth commented Apr 22, 2024

@vladimir-trifonov Yeah you're right. Like I guess that PR focuses more on caching block hashes, but this one is more about explicit multi-blocks.

@BGluth
Copy link
Member Author

BGluth commented May 3, 2024

Ok... So just want to note that while #297 does add support to generate multiple blocks at once, it does not generate multiple blocks in parallel, so this is still something that we should do (as a separate PR probably).

@vladimir-trifonov
Copy link
Contributor

When we prove a range, let's say blocks 10..13= for processing block 10 we use checkpoint-block-number set to 9, but for processing block 11 we use the block proof of block 10 as a parent, i.e. every next proof relies on the previous one, i.e. that's why proving a range happens synchronously. We can skip that, we have in the readme:

- Because incorporating the previous block proof requires a chain of proofs back to the last checkpoint height, you can also disable this requirement by passing `true` for `<IGNORE_PREVIOUS_PROOFS>` (which internally just sets the current checkpoint height to the previous block height).

and then the proving blocks could be made to run in parallel... @Nashtare

@Nashtare
Copy link
Collaborator

I'm not sure how much work this would be with the current zero-bin (cc @cpubot) as it is currently built around proving one block at a time, but we need to be able to process blocks concurrently and to connect them if required, by passing the previous block proof when proving the next one. 99.99% of the proving time (all txn + aggregation proofs) remains fully independent of the previous block, so we could still have the leader push a next block to the queue, to be processed ASAP by available workers.
We'd just need the final block_proof producer for block N to:

  • wait for proof N-1 to be available if checkpoint-block-number is smaller than N-1
  • ignore previous proofs and just process the current block if checkpoint-block-number == N-1.

@vladimir-trifonov
Copy link
Contributor

That sounds fine to me, should we make some plan, it sounds like a pretty big change to me if I'm not mistaken...

@BGluth
Copy link
Member Author

BGluth commented May 21, 2024

I remember I did take a decent look at what an implementation might look like a while back, and IIRC it looked pretty doable with how Paladin was setup. I would take a look at prove in prover/src/lib.rs. You can probably adjust this so it takes in a block range and creates the same task dependencies for multiple blocks. You might also need to make one more task type to merge two block proofs together. @cpubot might have more to add.

@Nashtare Nashtare transferred this issue from 0xPolygonZero/zero-bin Jun 18, 2024
@Nashtare
Copy link
Collaborator

Done in 0xPolygonZero/zero-bin#90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants