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

Challenge in EVM circuit WIP#990

Closed
adria0 wants to merge 7 commits into
mainfrom
tmp/challenge-evm-circuit
Closed

Challenge in EVM circuit WIP#990
adria0 wants to merge 7 commits into
mainfrom
tmp/challenge-evm-circuit

Conversation

@adria0

@adria0 adria0 commented Dec 15, 2022

Copy link
Copy Markdown
Contributor

Uploaded the version I'm working now of evm circuit with challenge api

Uses
https://github.com/privacy-scaling-explorations/halo2/tree/tmp/challenge-evm-circuit

Current status, and stuff I'll be working on

Anyway, if anybody wants to take a look (not asking for a detailed review now, only for general comments), will be nice because I'm blocking other issues.

@github-actions github-actions Bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-eth-types Issues related to the eth-types workspace member crate-gadgets Issues related to the gadgets workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements labels Dec 15, 2022
@adria0 adria0 changed the title Challange in EVM circuit WIP Challenge in EVM circuit WIP Dec 15, 2022
@han0110

han0110 commented Dec 15, 2022

Copy link
Copy Markdown
Contributor

Had a review on the major changes and every opcode today, here are some my thoughts:

  • Since we have 3 phases, the witness assignment is called 3 times, so the slow down seems to make sense. In future PR we will need to address this issue by not doing unnecessary computation when the phase is not matching.
  • The lookup RLC challenge is still using the same challenge evm_word, I think we need to use another challenge lookup_input usable after second phase, then we'd need more third phase columns in ColumnType::Lookup (or need more phase2 columns if we manage to remove phase3, see next bullet).
  • I think we could remove third phase by witnessing the is_zero of RLC value in first phase, since as far as I see there is only is_zero(word_rlc1 - word_rlc2) requiring the third phase
    Edit: I think we still need columns in ColumnType::Lookup to be in third phase, since no matter what those tables just contain the RLC value :(

@adria0

adria0 commented Dec 15, 2022

Copy link
Copy Markdown
Contributor Author

Had a review on the major changes and every opcode today, here are some my thoughts:

Thanks! :)

  • Since we have 3 phases, the witness assignment is called 3 times, so the slow down seems to make sense. In future PR we will need to address this issue by not doing unnecessary computation when the phase is not matching.

But is this happening with MockProver? I added a dbg! of the challange values in the EvmCircuit::synthesize and I'm only getting one print, with the values set. Should I expect here at least two rounds, one with Value::unknown and the other with Value::known ?

running 1 test
[zkevm-circuits/src/evm_circuit.rs:344] challenges = Challenges {
    evm_word: Value {
        inner: Some(
            0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519,
        ),
    },
    keccak_input: Value {
        inner: Some(
            0x1f00d576567535824a93454a0f4679c99b1052a5728d21c5e03b4877c99f12f1,
        ),
    },
}
test evm_circuit::execution::gas::test::gas_gadget_simple ... ok

@han0110

han0110 commented Dec 15, 2022

Copy link
Copy Markdown
Contributor

But is this happening with MockProver? I added a dbg! of the challange values in the EvmCircuit::synthesize and I'm only getting one print, with the values set. Should I expect here at least two rounds, one with Value::unknown and the other with Value::known ?

Ahhh sorry, you are completely right, it should just be one synthesize called in MockProver, only when real prover we will do multiple times synthesize. Sorry for confusing.

@adria0 adria0 force-pushed the tmp/challenge-evm-circuit branch from 6eabfe2 to 8120bd4 Compare December 16, 2022 12:15
@andyguzmaneth andyguzmaneth linked an issue Dec 22, 2022 that may be closed by this pull request
@adria0

adria0 commented Jan 2, 2023

Copy link
Copy Markdown
Contributor Author

@han0110, for thelookup_input challenge, you you think that's enough with 8120bd4 ?

@adria0 adria0 closed this Jan 2, 2023
@adria0 adria0 deleted the tmp/challenge-evm-circuit branch January 2, 2023 16:52

@han0110 han0110 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for thelookup_input challenge, you you think that's enough with 8120bd4 ?

It looks good to me! Just left 2 more thoughts.

rlc::expr(&lookup.input_exprs(), self.lookup_powers_of_randomness),
MAX_DEGREE - IMPLICIT_DEGREE,
);
self.store_expression(name, compressed_expr, CellType::Lookup(lookup.table()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems need to be stored in LookupPhase3 since it contains challenge after phase 2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, sure! I miss this!

Comment on lines +419 to +420
let lookup_powers_of_randomness: [Expression<F>; 31] =
challenges.lookup_input_powers_of_randomness();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems we only need 12 here at most for CopyTable.

noel2004 pushed a commit to noel2004/zkevm-circuits that referenced this pull request Nov 29, 2023
* create: refactor lifetime

* fmt

* add more tests
noel2004 pushed a commit to noel2004/zkevm-circuits that referenced this pull request Nov 29, 2023
* create_op: fix memory size (privacy-ethereum#990)

* create: refactor lifetime

* fmt

* add more tests

* update access list in create

* refactor create

* build

* fix

* try

* ci
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-circuit-benchmarks Issues related to the circuit-benchmarks workspace member crate-eth-types Issues related to the eth-types workspace member crate-gadgets Issues related to the gadgets workspace member crate-integration-tests Issues related to the integration-tests workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member T-bench Type: benchmark improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants