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

Recursion PoC #102

Merged
merged 53 commits into from
Jul 24, 2023
Merged

Recursion PoC #102

merged 53 commits into from
Jul 24, 2023

Conversation

Brechtpd
Copy link

@Brechtpd Brechtpd commented May 31, 2023

Currently implements recursion like this for n blocks:

  • n x SuperCircuits -> n x root circuits -> 1 x aggregation circuit (EVM verifiable)

The best version is bench_root_super_circuit_prover_sdk. bench_root_super_circuit_prover is the older version I made without the sdk and should not be used anymore.

TODO:

  • Make a TaikoSuperCircuit (current PR just changes the PSE super circuit, let's make a new circuit and leave the original as is)
  • Let's add our own publlic input circuit as the only sub-circuit to TaikoSuperCircuit for now (can leave the rest commented so easy to enable more circuits in the future).
  • Currently uses a slightly modified snark verifier at https://github.com/brechtpd/snark-verifier. This is just until it's merged into in the PSE snark verifier.
  • I haven't gotten gen_pk to work because of trait issues, can just wait until this gets fixed upstream if hard to fix.
  • Make this usable for the next testnet.

@johntaiko
Copy link

johntaiko commented Jun 5, 2023

changes:

  • pi_circuit2 lookups the block_table instead of assigns it
    • lookup block_table with pi's block_hash field
    • lookup block_table with pi's parent_hash field
  • Taiko witness is merged into Block witness
  • TaikoSuperCircuit uses Challenges instead of mock randomness

@Brechtpd
Copy link
Author

Brechtpd commented Jun 22, 2023

Looks like the last commit or 2 makes the code not compile anymore with some generics errors (so hard to figure out what exactly is wrong).

@johntaiko
Copy link

Looks like the last commit or 2 makes the code not compile anymore with some generics errors (so hard to figure out what exactly is wrong).

Ok, let me get it done

Copy link
Author

@Brechtpd Brechtpd left a comment

Choose a reason for hiding this comment

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

Looks good to me!

circuit-benchmarks/src/super_circuit.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/taiko_super_circuit/test.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/witness/block.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/root_circuit/pcd_aggregation.rs Outdated Show resolved Hide resolved
@smtmfft
Copy link
Collaborator

smtmfft commented Jun 23, 2023

Looks like the last commit or 2 makes the code not compile anymore with some generics errors (so hard to figure out what exactly is wrong).

Let me see if reference brakes.

@johntaiko
Copy link

Looks like a lot of tests are still failing because of the signature problem (half fixed here: #119). If I merge in the master containing that "fix" for the signature problem there's a test failing:

failures:

---- pi_circuit2::pi_circuit_test::test_verify stdout ----
thread 'pi_circuit2::pi_circuit_test::test_verify' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<Err(
<    [
<        Lookup in block table(index: 1) is not satisfied in Region 4 ('region 0') at offset 159,
<        Lookup in block table(index: 1) is not satisfied in Region 4 ('region 0') at offset 191,
<    ],
>Ok(
>    (),
 )

', zkevm-circuits/src/pi_circuit2.rs:799:9

fixed

@johntaiko
Copy link

johntaiko commented Jun 29, 2023

Only some minor feedback for the PR itself. But let's make make test-all work for all tests (except the bytecode test failures, those are from the PSE side)! I temporarily ignored some PSE public input tests in #119 (files), but that was a workaround to get things working on the master again. Please find out why they are broken so we can enable them again (even though we won't use that circuit, we should keep all tests working unless there's a good reason for them to stop working).

According to the test intent, these errors in bytecode-circuit are as expected.

pub fn test_bytecode_circuit_unrolled<F: Field>(
k: u32,
bytecodes: Vec<UnrolledBytecode<F>>,
success: bool,
) {
let circuit = BytecodeCircuit::<F>::new(bytecodes, 2usize.pow(k));
let prover = MockProver::<F>::run(k, &circuit, Vec::new()).unwrap();
let result = prover.verify_par();
if let Err(failures) = &result {
for failure in failures.iter() {
error!("{}", failure);
}
}
let error_msg = if success { "valid" } else { "invalid" };
assert_eq!(result.is_ok(), success, "proof must be {}", error_msg);
}

If success == false, the test will show the ERROR message.

[2023-06-29T02:06:55Z ERROR zkevm_circuits::bytecode_circuit::test] Constraint 0 ('cur.index == 0') in gate 4 ('Header row') is not satisfied in Region 2 ('assign bytecode') at offset 0
    - Column('Advice', 0 - tag)@0 = 0
    - Column('Advice', 1 - index)@0 = 1
    - Column('Fixed', 0 - BYTECODE_q_enable)@0 = 1
    - Column('Fixed', 2 - BYTECODE_q_last)@0 = 0

@johntaiko johntaiko self-assigned this Jun 29, 2023
@johntaiko johntaiko self-requested a review June 29, 2023 03:10
@taikoxyz taikoxyz deleted a comment from dyxushuai Jun 29, 2023
@Brechtpd
Copy link
Author

I re-enabled the PSE PI tests so fixing those isn't forgotten. I also fixed a small issue with the taiko 2tx_2max_tx test because of a wrong max_txs value.

@johntaiko
Copy link

I re-enabled the PSE PI tests so fixing those isn't forgotten. I also fixed a small issue with the taiko 2tx_2max_tx test because of a wrong max_txs value

Yes, finally passed all the tests 🥹

@Brechtpd Brechtpd merged commit 5d785b4 into main Jul 24, 2023
17 of 20 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants