Skip to content

Commit

Permalink
better poseidon row estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc committed Aug 18, 2023
1 parent 414bdb9 commit e81455a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 67 deletions.
74 changes: 20 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bin"
version = "0.4.0"
version = "0.6.4"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
18 changes: 9 additions & 9 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "prover"
version = "0.4.0"
version = "0.6.4"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_02_02" }

aggregator = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
bus-mapping = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2", default-features = false, features = ["test","scroll","scroll-trace","shanghai"] }
mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
mock = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
aggregator = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }
bus-mapping = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }
eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }
zkevm-circuits = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4", default-features = false, features = ["test","scroll","scroll-trace","shanghai"] }
mpt-zktrie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }
mock = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }

snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", tag = "v0.1.1" }
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", tag = "v0.1.1" }
snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", tag = "v0.1.2" }
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", tag = "v0.1.2" }

anyhow = "1.0"
blake2 = "0.10.3"
Expand Down
5 changes: 5 additions & 0 deletions prover/src/zkevm/capacity_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ impl RowUsage {
row_number: (1_000_000u64 * (x.row_number as u64) / (*limit as u64)) as usize,
})
.collect_vec();
log::debug!(
"normalize row usage, before {:#?}\nafter {:#?}",
self.row_usage_details,
details
);
Self::from_row_usage_details(details)
}
pub fn from_row_usage_details(row_usage_details: Vec<SubCircuitRowUsage>) -> Self {
Expand Down
7 changes: 6 additions & 1 deletion prover/src/zkevm/circuit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ pub fn calculate_row_usage_of_trace(
pub fn calculate_row_usage_of_witness_block(
witness_block: &Block<Fr>,
) -> Result<Vec<zkevm_circuits::super_circuit::SubcircuitRowUsage>> {
let rows = <super::SuperCircuit as TargetCircuit>::Inner::min_num_rows_block_subcircuits(
let mut rows = <super::SuperCircuit as TargetCircuit>::Inner::min_num_rows_block_subcircuits(
witness_block,
);

assert_eq!(SUB_CIRCUIT_NAMES[10], "poseidon");
assert_eq!(SUB_CIRCUIT_NAMES[13], "mpt");
// empirical estimation is each row in mpt cost 1.5 hash (aka 12 rows)
rows[10].row_num_real += rows[13].row_num_real * 12;

log::debug!(
"row usage of block {:?}, tx num {:?}, tx calldata len sum {}, rows needed {:?}",
witness_block
Expand Down
4 changes: 2 additions & 2 deletions types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "types"
version = "0.4.0"
version = "0.6.4"
edition = "2021"

[dependencies]
eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.2" }
eth-types = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.6.4" }
base64 = "0.13.0"
blake2 = "0.10.3"
ethers-core = "0.17.0"
Expand Down

0 comments on commit e81455a

Please sign in to comment.