Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

prover/compute_proof: track duration of proving time #619

Merged

Conversation

pinkiebell
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the crate-prover Issues related to the prover workspace member label Jul 14, 2022
Copy link
Member

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM!

A part from reporting the total proving time, maybe it's also useful to report the proving time for each individual proof?

@pinkiebell
Copy link
Contributor Author

LGTM!

A part from reporting the total proving time, maybe it's also useful to report the proving time for each individual proof?

CC @AronisAt79 - What do you think?

@AronisAt79
Copy link
Contributor

LGTM!
A part from reporting the total proving time, maybe it's also useful to report the proving time for each individual proof?

CC @AronisAt79 - What do you think?

hi @pinkiebell , i somewhow missed previous comment from Edu; For sure, that would help in terms of more accurately benchmarking proof generation times. Is ti easy to add duration fields per proof, in the results struct? And a question: proofs get calculated in parallel or in sequence?

@pinkiebell
Copy link
Contributor Author

The proofs are processed in sequence. We can of course add more timing information here. Furthermore, the prover will support multiple instances of itself so that we can compute proofs in parallel - for each block.

@ed255 What happens when the supercircuit lands? Does it include all sub-circuits or do we still have dedicated components?

@AronisAt79
Copy link
Contributor

The proofs are processed in sequence. We can of course add more timing information here. Furthermore, the prover will support multiple instances of itself so that we can compute proofs in parallel - for each block.

@pinkiebell, are there any dependencies regarding different parts of a single block proof? For example, evm must be computed first and so on?

p.s. please let us know if you proceed with additional duration fields so we can adapt the test code :)

@ed255
Copy link
Member

ed255 commented Jul 19, 2022

@ed255 What happens when the supercircuit lands? Does it include all sub-circuits or do we still have dedicated components?

The SuperCircuit will include all sub-circuits, which will be proved all at once. In the PR that I'm preparing now the included circuits will be: EVM Circuit, Tx Circuit and Bytecode Circuit. In a following iteration I'll be adding more circuits (starting with the State Circuit).

@pinkiebell
Copy link
Contributor Author

The proofs are processed in sequence. We can of course add more timing information here. Furthermore, the prover will support multiple instances of itself so that we can compute proofs in parallel - for each block.

@pinkiebell, are there any dependencies regarding different parts of a single block proof? For example, evm must be computed first and so on?

p.s. please let us know if you proceed with additional duration fields so we can adapt the test code :)

There are no dependencies (yet). Given the fact that the SuperCircuit will include all sub circuits, I'm wondering if it makes sense to include more timing information at the moment that will be obsolete in the future. On another note, I think it makes more sense to focus on scaling the block production (for all proofs) per block in the proverd thus, scaling the number of machines. Any sub-circuit parallel improvements can be focused on the other crates - especially because the circuit_benchmarks keeps track of individual performance for each circuit.

In practice, we have to limit the production to a 'sane' value. For example, assuming a block proof completes in 1h and we like to limit the number of not finalized blocks to 256 (on l1). We could produce a new block each ~14 seconds and have up to 256 prover instances active to process backlogs. This is already a bit heavy but needs to taken into account :)

@ed255
Copy link
Member

ed255 commented Jul 19, 2022

I'm wondering if it makes sense to include more timing information at the moment that will be obsolete in the future.

You're completely right. In the near future we'll have the super circuit for which we will compute a proof, and then the aggregation circuit for which we will compute a proof (this one will depend on the super circuit proof). In a more distant future we may go back to having individual circuits for which we can compute their proofs in parallel, and then one or more aggregation circuits that verify all the individual circuits proofs.

The reason why I was asking for the sub-circuit timing information was because I think it's very useful to figure out which circuits take more time, so that we know where to focus on optimizations; but I agree that this would soon be obsolete in the tesnet! We can still get those numbers by running benchmarks outside of the testnet.

On another note, I think it makes more sense to focus on scaling the block production (for all proofs) per block in the proverd thus, scaling the number of machines. Any sub-circuit parallel improvements can be focused on the other crates - especially because the circuit_benchmarks keeps track of individual performance for each circuit.

Sounds good! Computing several block proofs in parallel doesn't require any support from halo2 nor circuits side. Distributing the computation of a single proof requires some work. So it makes sense to focus on the first option.

In practice, we have to limit the production to a 'sane' value. For example, assuming a block proof completes in 1h and we like to limit the number of not finalized blocks to 256 (on l1). We could produce a new block each ~14 seconds and have up to 256 prover instances active to process backlogs. This is already a bit heavy but needs to taken into account :)

This sounds great! And I think it's the simplest way to increase the throughput we have :)

About this PR, having said that I agree on not adding sub-circuit timings: from my side this can be merged any time now :)

@AronisAt79
Copy link
Contributor

I'm wondering if it makes sense to include more timing information at the moment that will be obsolete in the future.

You're completely right. In the near future we'll have the super circuit for which we will compute a proof, and then the aggregation circuit for which we will compute a proof (this one will depend on the super circuit proof). In a more distant future we may go back to having individual circuits for which we can compute their proofs in parallel, and then one or more aggregation circuits that verify all the individual circuits proofs.

The reason why I was asking for the sub-circuit timing information was because I think it's very useful to figure out which circuits take more time, so that we know where to focus on optimizations; but I agree that this would soon be obsolete in the tesnet! We can still get those numbers by running benchmarks outside of the testnet.

On another note, I think it makes more sense to focus on scaling the block production (for all proofs) per block in the proverd thus, scaling the number of machines. Any sub-circuit parallel improvements can be focused on the other crates - especially because the circuit_benchmarks keeps track of individual performance for each circuit.

Sounds good! Computing several block proofs in parallel doesn't require any support from halo2 nor circuits side. Distributing the computation of a single proof requires some work. So it makes sense to focus on the first option.

In practice, we have to limit the production to a 'sane' value. For example, assuming a block proof completes in 1h and we like to limit the number of not finalized blocks to 256 (on l1). We could produce a new block each ~14 seconds and have up to 256 prover instances active to process backlogs. This is already a bit heavy but needs to taken into account :)

This sounds great! And I think it's the simplest way to increase the throughput we have :)

About this PR, having said that I agree on not adding sub-circuit timings: from my side this can be merged any time now :)

to the extent that i understand the concept of supercircuit/aggregation circuit and so on.... i also agree. On the testing front, we could start parallelizing proof computations for different blocks among individual prover instances, if this is already supported/implemented

@pinkiebell
Copy link
Contributor Author

we could start parallelizing proof computations for different blocks among individual prover instances, if this is already supported/implemented

I will implement this soon 👍

@pinkiebell pinkiebell merged commit 322004c into privacy-scaling-explorations:main Jul 20, 2022
@pinkiebell pinkiebell deleted the prover/duration branch July 20, 2022 10:46
lispc added a commit that referenced this pull request Aug 28, 2023
…S auditors (#572)

* fix finding 3 (#575)

* Fix zellic finding 4 (#576)

* fix finding 3 (#575)

* fix finding 4

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* add range check on diffs (#586)

* Fix finding 10 (#578)

* fix finding 3 (#575)

* fix finding 10

* Fix finding 13 (#579)

* fix finding 3 (#575)

* fix finding 13

* Fix zellic finding 14 (#580)

* fix finding 3 (#575)

* fix finding 14

* Fix zellic finding 5 (#584)

* fix finding 3 (#575)

* fix finding 5

* refine comments

* fmt

* Fix finding 17 (#602)

* add q_last

* fix

* add more diff range check

* fix finding 7 (#625)

* tx_id = 1 when sm starts

* Fix finding 11 : use length for rlc in rlp table (#719)

* fix: use tag_bytes_rlc and tag_length to copy tag's bytes around

* fix lookup input for Len & RLC & GasCost fields in tx circuit

* refactor

* fix

* refactor

* fix col phase issue

* refactor bytes_rlc type

* Fix the bugs in Tx & PI circuits reported by Zellic & KALOS auditors (#612)

* lookup chain_id to RLP table

* fix finding 22 (#614)

* fix finding 21 (#613)

* fix finding 23 (#618)

* fix finding 26 (#622)

* fix finding 28 (#624)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix finding 29 (#623)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* enforce is_final is true at the last row and fix RLC related vul (#735)

* Fix finding 30  (#733)

* enforce all txs in a block are included in the tx table

* clippy

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* Fix Zellic / Kalos finding25 (#619)

* fix finding 25

* add comment

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix conflicts

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>

* use q_first instead

* fmt

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>
lispc added a commit that referenced this pull request Aug 28, 2023
* add row counting interface for keccak

* add class level capacity calculator for keccak

* remove f capacity from core

* remove capacity calculator in aggregator util

* remove unnecessary imports

* replace max keccak round in core

* replace reference for max keccak

* remove unnecessary keccak imports and constants

* remove max keccak constant

* remove constants in hash cell parsing

* remove constant column sanity check

* add state column usage log

* adjust input bytes column

* add long column padding

* correct fmt

* fix fmt

* minor fixes

* fix

* Fix: allow skipping of L1Msg tx part 2 (calculate num_all_txs in tx circuit) (#778)

* calculate num_l1_msgs and num_l2_txs in tx circuit

* fix

* fmt and clippy

* fix: non-last tx requires next is calldata

* add NumAllTxs in block table and copy it from pi to block table

* add lookup for NumAllTxs in tx circuit

* clippy

* add block num diff check to avoid two real block have same num

* clippy

* address comments

* Fix the bugs in RLP/Tx/PI circuit which are reported by Zellic & KALOS auditors (#572)

* fix finding 3 (#575)

* Fix zellic finding 4 (#576)

* fix finding 3 (#575)

* fix finding 4

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* add range check on diffs (#586)

* Fix finding 10 (#578)

* fix finding 3 (#575)

* fix finding 10

* Fix finding 13 (#579)

* fix finding 3 (#575)

* fix finding 13

* Fix zellic finding 14 (#580)

* fix finding 3 (#575)

* fix finding 14

* Fix zellic finding 5 (#584)

* fix finding 3 (#575)

* fix finding 5

* refine comments

* fmt

* Fix finding 17 (#602)

* add q_last

* fix

* add more diff range check

* fix finding 7 (#625)

* tx_id = 1 when sm starts

* Fix finding 11 : use length for rlc in rlp table (#719)

* fix: use tag_bytes_rlc and tag_length to copy tag's bytes around

* fix lookup input for Len & RLC & GasCost fields in tx circuit

* refactor

* fix

* refactor

* fix col phase issue

* refactor bytes_rlc type

* Fix the bugs in Tx & PI circuits reported by Zellic & KALOS auditors (#612)

* lookup chain_id to RLP table

* fix finding 22 (#614)

* fix finding 21 (#613)

* fix finding 23 (#618)

* fix finding 26 (#622)

* fix finding 28 (#624)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix finding 29 (#623)

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* enforce is_final is true at the last row and fix RLC related vul (#735)

* Fix finding 30  (#733)

* enforce all txs in a block are included in the tx table

* clippy

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* Fix Zellic / Kalos finding25 (#619)

* fix finding 25

* add comment

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>

* fix conflicts

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>

* use q_first instead

* fmt

---------

Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>

* add pi comments

* rename preimage col idx

* add keccak rows check

* rename input bytes col finder fn

* modify keccak row env constaint

* modify keccak row env constaint

* add named constant setup vars

* modify keccak row check

* clippy advised

* add comments on chunk hash

* fmt

* avoid constant lookup table

* avoid repetitive computation of input_bytes_col_idx

---------

Co-authored-by: Zhuo Zhang <mycinbrin@gmail.com>
Co-authored-by: xkx <xiakunxian130@gmail.com>
Co-authored-by: Rohit Narurkar <rohit.narurkar@protonmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-prover Issues related to the prover workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants