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

A6 public input circuit #161

Merged
merged 27 commits into from
Nov 1, 2023
Merged

A6 public input circuit #161

merged 27 commits into from
Nov 1, 2023

Conversation

CeciliaZ030
Copy link

Description

Migrated from #149

@CeciliaZ030 CeciliaZ030 marked this pull request as ready for review October 10, 2023 12:09
Copy link

@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.

Haven't rechecked the circuit in detail again, but generally looks okay, just some questions.

There's also still some clippy errors I think.

zkevm-circuits/src/table/block_table.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/taiko_super_circuit.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/taiko_pi_circuit.rs Outdated Show resolved Hide resolved
zkevm-circuits/src/taiko_pi_circuit.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@smtmfft smtmfft left a comment

Choose a reason for hiding this comment

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

PI circuit part seems ok as the most of logic is moved from a5, however, maybe separating this one to 2 PRs(1 for circuit_tool & 1 for pi change) is better for reviewing & commitment organization.

FixedBytes(self.graffiti, 32),
];
match evidence_type {
EvidenceType::Sgx { prover, new_pubkey } => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need sgx type here?

Choose a reason for hiding this comment

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

Copied from Raiko? Otherwise indeed not necessary here.

Copy link
Author

Choose a reason for hiding this comment

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

Yea it's copied.

result.extend_from_slice(self.block_evidence.blockMetadata.l1Hash.as_slice());
result.extend_from_slice(self.block_evidence.signalRoot.as_slice());
result.extend_from_slice(self.block_evidence.blockMetadata.l1Hash.as_slice());
result.extend_from_slice(&[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why 0?

Copy link
Author

Choose a reason for hiding this comment

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

This is parent_gas_used which got removed from this version. I'll change it to a param.

});

///
pub static TREASURY: Lazy<Address> = Lazy::new(|| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in case of l1 change, hardcode is inflexible, I think client already gives all of them from API, why you need hardcode here?

Copy link
Author

@CeciliaZ030 CeciliaZ030 Nov 1, 2023

Choose a reason for hiding this comment

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

I think these constants should be taken from Raiko-host? Maybe we should align the API. For now the only place of getting taiko specific params are through ProtocolInstance, if anything is removed from BlockEvidence in our contract, I'll have to scrape it from somewhere else or hardcode.


/// PublicData contains all the values that the PiCircuit receives as input
const S1: PiCellType = PiCellType::StoragePhase1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

SP1 or SPhase1 makes more sense.

@@ -173,6 +203,7 @@ impl_expr!(bool);
impl_expr!(u8);
impl_expr!(u64);
impl_expr!(usize);
impl_expr!(isize);
Copy link
Collaborator

Choose a reason for hiding this comment

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

which data is in isize type?

Choose a reason for hiding this comment

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

Default type of negative numbers, was added for the MPT circuit.

@@ -540,11 +454,11 @@ impl<F: Field> SubCircuit<F> for TaikoPiCircuit<F> {
fn unusable_rows() -> usize {
// No column queried at more than 3 distinct rotations, so returns 6 as
// minimum unusable rows.
6
CM_HEIGHT + 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

is CM_HEIGHT enough? as you don't have cross CM rotation I think.

Choose a reason for hiding this comment

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

Seems okay to me because 3 is the base number of unusable rows. Or what do you mean with cross CM rotation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking that the max rotation is CM_HEIGHT because there is no rotation to the other cm region, not a real problem with +3.

Choose a reason for hiding this comment

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

I think the 3 comes from the random values that are required to make the prover zero knowledge that need to be stored in the last 3 rows. Not sure though, and I also don't know why it's 3 to make that happen (I would think 1 random value would be good enough, but seems like not).

Copy link
Author

@CeciliaZ030 CeciliaZ030 Nov 1, 2023

Choose a reason for hiding this comment

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

Total cells needed for 7 FieldGadget are 7 * 32 = 224. CM height is 15 and has 15 columns available = 225 which fits nicely :)

Copy link

@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.

Would indeed have been a bit easier to have separate PRs so it's more clear what needs to be reviewed more closely. Now I just went over everything pretty quickly. :)

@@ -34,7 +34,6 @@ impl<F: Field> ExecutionGadget<F> for JumpGadget<F> {

// Pop the value from the stack
cb.stack_pop(destination.expr());

Choose a reason for hiding this comment

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

Random new line removed diff?

@@ -540,11 +454,11 @@ impl<F: Field> SubCircuit<F> for TaikoPiCircuit<F> {
fn unusable_rows() -> usize {
// No column queried at more than 3 distinct rotations, so returns 6 as
// minimum unusable rows.
6
CM_HEIGHT + 3

Choose a reason for hiding this comment

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

Seems okay to me because 3 is the base number of unusable rows. Or what do you mean with cross CM rotation?

@@ -173,6 +203,7 @@ impl_expr!(bool);
impl_expr!(u8);
impl_expr!(u64);
impl_expr!(usize);
impl_expr!(isize);

Choose a reason for hiding this comment

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

Default type of negative numbers, was added for the MPT circuit.

FixedBytes(self.graffiti, 32),
];
match evidence_type {
EvidenceType::Sgx { prover, new_pubkey } => {

Choose a reason for hiding this comment

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

Copied from Raiko? Otherwise indeed not necessary here.

@CeciliaZ030 CeciliaZ030 merged commit 49ac689 into feat/for-a6-release Nov 1, 2023
15 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