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

Feat/prover: add prover command line utilities #326

Merged
merged 8 commits into from
Feb 18, 2022

Conversation

pinkiebell
Copy link
Contributor

@pinkiebell pinkiebell commented Feb 9, 2022

The first version includes two commands:

gen_params

For generating circuit commitment parameters

prover_cmd

that generates circuit proofs and prints them as json to stdout.

Another rpc daemon is needed for a later stage so that it becomes possible to defer generating/requesting proofs over http.

@github-actions github-actions bot added the crate-zkevm-circuits Issues related to the zkevm-circuits workspace member label Feb 9, 2022
let block = block_convert(Fr::rand(), bytecode, &builder.block);
let circuit = TestCircuit::<Fr>::new(block, FixedTableTag::iterator().collect());

// TODO: can this be pre-generated to a file?
Copy link
Collaborator

Choose a reason for hiding this comment

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

{
// generate evm_circuit proof
//
// TODO: why blocks.txs()[0]?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This should be addressed in https://github.com/appliedzkp/zkevm-circuits/pull/292/files#diff-09bf944a4f9216c1053a271fea0ff2f7a985380789b990f8e4ac530159214df2R964-R967
Which updates block_convert to be:

pub fn block_convert(
    block: &circuit_input_builder::Block,
    code_db: &bus_mapping::state_db::CodeDB,
) -> Block<Fp> {

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! Good work :)

I have two comments though:

  1. I saw a few unwrap(), maybe you could replace them with expect() for a more friendly message in case of panic.
  2. I noticed that gen_params uses arguments while prover_cmd uses env variables. Why is that?

For the future I suggest taking a look at https://github.com/clap-rs/clap for argument parsing (it also supports setting arguments from env vars), so that we get help messages and nice errors on invalid arguments for free. I think this will be useful once we have binaries that require more options.

{
// generate evm_circuit proof
//
// TODO: why blocks.txs()[0]?
Copy link
Member

Choose a reason for hiding this comment

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

This should be addressed in https://github.com/appliedzkp/zkevm-circuits/pull/292/files#diff-09bf944a4f9216c1053a271fea0ff2f7a985380789b990f8e4ac530159214df2R964-R967
Which updates block_convert to be:

pub fn block_convert(
    block: &circuit_input_builder::Block,
    code_db: &bus_mapping::state_db::CodeDB,
) -> Block<Fp> {

@@ -98,8 +98,8 @@ impl<F: FieldExt> EvmCircuit<F> {
}
}

#[cfg(test)]
pub(crate) mod test {
#[cfg(feature = "test")]
Copy link
Member

Choose a reason for hiding this comment

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

😃

@pinkiebell
Copy link
Contributor Author

LGTM! Good work :)

I have two comments though:

  1. I saw a few unwrap(), maybe you could replace them with expect() for a more friendly message in case of panic.

Will do :)

  1. I noticed that gen_params uses arguments while prover_cmd uses env variables. Why is that?

gen_params has limited utility and thus will be used rarely on the cmdline - that's why its reading arguments.
the prover_cmd is used in test environments and all the configuration lives as env variables. This fits naturally in the prod & developer sandbox setups without having to pass any arguments.

For the future I suggest taking a look at https://github.com/clap-rs/clap for argument parsing (it also supports setting arguments from env vars), so that we get help messages and nice errors on invalid arguments for free. I think this will be useful once we have binaries that require more options.

Sounds good.

@github-actions github-actions bot added the crate-bus-mapping Issues related to the bus-mapping workspace member label Feb 17, 2022
@pinkiebell
Copy link
Contributor Author

@ed255 Rebased :)

@ed255
Copy link
Member

ed255 commented Feb 17, 2022

@pinkiebell there seems to be a small formatting code issue: https://github.com/appliedzkp/zkevm-circuits/runs/5234903891?check_suite_focus=true

@pinkiebell
Copy link
Contributor Author

@pinkiebell there seems to be a small formatting code issue: https://github.com/appliedzkp/zkevm-circuits/runs/5234903891?check_suite_focus=true

sry, should run rustfmt in the root folder next time 😅

@pinkiebell pinkiebell merged commit 0acc51b into privacy-scaling-explorations:main Feb 18, 2022
@pinkiebell pinkiebell deleted the feat/prover branch March 26, 2022 07:40
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
…ing-explorations#326)

* test/keccak-normalize-table: unittest for normalize functions

* test/keccak-normalize-table: test for the Chi table

* test/keccak-normalize-table: move test to the new table module

---------

Co-authored-by: Aurélien Nicolas <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants