From cda85b5350fa22eaab17b14a01fa005cdf3664cb Mon Sep 17 00:00:00 2001 From: Rohit Narurkar Date: Mon, 25 Mar 2024 20:34:55 +0000 Subject: [PATCH] hash selector should only exist for digest rlc section | minor refactor --- aggregator/src/aggregation/blob_data.rs | 20 +++++++++++--------- aggregator/src/tests/blob.rs | 5 ++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/aggregator/src/aggregation/blob_data.rs b/aggregator/src/aggregation/blob_data.rs index 80ce5155f6..de9dc2ebd2 100644 --- a/aggregator/src/aggregation/blob_data.rs +++ b/aggregator/src/aggregation/blob_data.rs @@ -315,7 +315,9 @@ impl BlobDataConfig { } // enable hash selector - for offset in N_ROWS_METADATA + N_ROWS_DATA..N_ROWS_BLOB_DATA_CONFIG { + for offset in + N_ROWS_METADATA + N_ROWS_DATA..N_ROWS_METADATA + N_ROWS_DATA + N_ROWS_DIGEST_RLC + { self.hash_selector.enable(&mut region, offset)?; } @@ -651,8 +653,8 @@ impl BlobDataConfig { region.constrain_equal(i_val.cell(), row.chunk_idx.cell())?; } - let blob_preimage_rlc_specified = &rows.last().unwrap().preimage_rlc; - let blob_digest_rlc_specified = &rows.last().unwrap().digest_rlc; + let challenge_digest_preimage_rlc_specified = &rows.last().unwrap().preimage_rlc; + let challenge_digest_rlc_specified = &rows.last().unwrap().digest_rlc; // ensure that on the last row of this section the is_boundary is turned on // which would enable the keccak table lookup for challenge_digest @@ -722,7 +724,7 @@ impl BlobDataConfig { ///////////////////////////////// DIGEST BYTES ///////////////////////////////// //////////////////////////////////////////////////////////////////////////////// - let mut blob_preimage_keccak_rlc = zero.clone(); + let mut challenge_digest_preimage_keccak_rlc = zero.clone(); let rows = assigned_rows .iter() .skip(N_ROWS_METADATA + N_ROWS_DATA + N_ROWS_DIGEST_RLC) @@ -730,7 +732,7 @@ impl BlobDataConfig { .collect::>(); for (i, digest_rlc_specified) in std::iter::once(metadata_digest_rlc_specified) .chain(chunk_digest_evm_rlcs) - .chain(std::iter::once(blob_digest_rlc_specified)) + .chain(std::iter::once(challenge_digest_rlc_specified)) .enumerate() { let digest_rows = rows @@ -760,9 +762,9 @@ impl BlobDataConfig { &r_keccak, &mut rlc_config_offset, )?; - blob_preimage_keccak_rlc = rlc_config.mul_add( + challenge_digest_preimage_keccak_rlc = rlc_config.mul_add( &mut region, - &blob_preimage_keccak_rlc, + &challenge_digest_preimage_keccak_rlc, &r32, &digest_keccak_rlc, &mut rlc_config_offset, @@ -770,8 +772,8 @@ impl BlobDataConfig { } } region.constrain_equal( - blob_preimage_keccak_rlc.cell(), - blob_preimage_rlc_specified.cell(), + challenge_digest_preimage_keccak_rlc.cell(), + challenge_digest_preimage_rlc_specified.cell(), )?; //////////////////////////////////////////////////////////////////////////////// diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index 808f7ec8c3..1b1ca02e1c 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -2,7 +2,7 @@ use crate::{ aggregation::{ AssignedBarycentricEvaluationConfig, BarycentricEvaluationConfig, BlobDataConfig, RlcConfig, }, - blob::{BlobAssignments, BlobData}, + blob::{BlobAssignments, BlobData, N_ROWS_DATA}, param::ConfigParams, MAX_AGG_SNARKS, }; @@ -167,6 +167,8 @@ fn check_circuit(data: BlobData) -> Result<(), Vec> { #[test] fn blob_circuit_completeness() { + // single chunk in batch, but the chunk has a size of N_ROWS_DATA + let full_blob = vec![vec![123; N_ROWS_DATA]]; let all_empty_chunks: Vec> = vec![vec![]; MAX_AGG_SNARKS]; let one_chunk = vec![vec![2, 3, 4, 100, 1]]; let two_chunks = vec![vec![100; 1000], vec![2, 3, 4, 100, 1]]; @@ -188,6 +190,7 @@ fn blob_circuit_completeness() { .collect::>(); for blob in [ + full_blob, one_chunk, two_chunks, max_chunks,