Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit df40b50

Browse files
committed
[fix] chain id len for tests
1 parent 990a2d1 commit df40b50

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

aggregator/src/tests/aggregator_e2e.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn test_e2e() {
5353
// Proof for test circuit
5454
let circuits = chunks
5555
.iter()
56-
.map(|&chunk| MockChunkCircuit { chunk })
56+
.map(|&chunk| MockChunkCircuit { chain_id: 0, chunk })
5757
.collect_vec();
5858
let layer_0_snarks = circuits
5959
.iter()

aggregator/src/tests/mock_chunk.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod config;
1616
/// - data hash
1717
/// - public input hash
1818
pub struct MockChunkCircuit {
19+
pub(crate) chain_id: u64,
1920
pub(crate) chunk: ChunkHash,
2021
}
2122

aggregator/src/tests/mock_chunk/circuit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use super::{
1616
impl MockChunkCircuit {
1717
pub(crate) fn random<R: rand::RngCore>(r: &mut R) -> Self {
1818
Self {
19+
chain_id: 0,
1920
chunk: ChunkHash::mock_chunk_hash(r),
2021
}
2122
}

aggregator/src/tests/mock_chunk/circuit_ext.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ impl CircuitExt<Fr> for MockChunkCircuit {
1313

1414
/// return vec![data hash | public input hash]
1515
fn instances(&self) -> Vec<Vec<Fr>> {
16-
vec![
17-
self.chain_id.to_le_bytes().iter().zip(
18-
19-
self
20-
.chunk
21-
.data_hash
22-
.as_bytes()
16+
vec![self
17+
.chain_id
18+
.to_le_bytes()
2319
.iter()
24-
.chain(self.chunk.public_input_hash().as_bytes().iter()))
20+
.chain(
21+
self.chunk
22+
.data_hash
23+
.as_bytes()
24+
.iter()
25+
.chain(self.chunk.public_input_hash().as_bytes().iter()),
26+
)
2527
.map(|&x| Fr::from(x as u64))
2628
.collect()]
2729
}

aggregator/src/tests/mock_chunk/config.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use zkevm_circuits::{
1414

1515
use crate::{
1616
util::{capacity, get_indices},
17-
LOG_DEGREE,
17+
CHAIN_ID_LEN, LOG_DEGREE,
1818
};
1919

2020
/// Config for MockChunkCircuit
@@ -152,9 +152,9 @@ impl MockChunkCircuitConfig {
152152
// chunk's data hash
153153
for i in 0..32 {
154154
layouter.constrain_instance(
155-
hash_input_cells[i + 100].cell(),
155+
hash_input_cells[i + 96 + CHAIN_ID_LEN].cell(),
156156
self.hash_digest_column,
157-
i,
157+
i + CHAIN_ID_LEN,
158158
)?;
159159
}
160160
// chunk's public_input_hash
@@ -164,10 +164,15 @@ impl MockChunkCircuitConfig {
164164
layouter.constrain_instance(
165165
hash_output_cells[(3 - i) * 8 + j].cell(),
166166
self.hash_digest_column,
167-
i * 8 + j + 32,
167+
i * 8 + j + 32 + CHAIN_ID_LEN,
168168
)?;
169169
}
170170
}
171+
// chain id
172+
for i in 0..CHAIN_ID_LEN {
173+
layouter.constrain_instance(hash_input_cells[i].cell(), self.hash_digest_column, i)?;
174+
}
175+
171176
Ok(hash_output_cells)
172177
}
173178
}

aggregator/src/tests/proof_aggregation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn test_aggregation_circuit() {
4343
// Proof for test circuit
4444
let circuits = chunks
4545
.iter()
46-
.map(|&chunk| MockChunkCircuit { chunk })
46+
.map(|&chunk| MockChunkCircuit { chain_id: 0, chunk })
4747
.collect_vec();
4848
let layer_0_snarks = circuits
4949
.iter()

aggregator/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_moc
44

55

66
# the following 3 tests takes super long time
7-
# RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_mock_chunk_prover -- --nocapture 2>&1 | tee mock_chunk.log
7+
# RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_proof_compression -- --nocapture 2>&1 | tee mock_chunk.log
88
# RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_two_layer_proof_compression -- --ignored --nocapture 2>&1 | tee compression2.log
99
# RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_aggregation_circuit -- --ignored --nocapture 2>&1 | tee aggregation.log
1010
# RUST_LOG=trace MODE=greeter cargo test --release --features=print-trace test_e2e -- --ignored --nocapture 2>&1 | tee aggregation.log

0 commit comments

Comments
 (0)