From cce7a738c7264a0eeeaeec5ba56685d69cc3b2ed Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Fri, 22 Mar 2024 12:31:03 +0100 Subject: [PATCH] Fix process_block script --- src/lib.cairo | 20 +++++++++---------- src/stark/tests/test_stark_proof_verify.cairo | 2 +- .../test_table_commitment_decommit.cairo | 2 +- .../test_vector_commitment_decommit.cairo | 6 +++--- utils.py | 8 ++++++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/lib.cairo b/src/lib.cairo index e184ba9ed..d3ac28e7a 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -25,16 +25,16 @@ use cairo_verifier::{ // === DEX END === // === RECURSIVE BEGIN === air::layouts::recursive::public_input::RecursivePublicInputImpl as PublicInputImpl, -// === RECURSIVE END === -// === RECURSIVE_WITH_POSEIDON BEGIN === -// air::layouts::recursive_with_poseidon::public_input::RecursiveWithPoseidonPublicInputImpl as PublicInputImpl, -// === RECURSIVE_WITH_POSEIDON END === -// === SMALL BEGIN === -// air::layouts::small::public_input::SmallPublicInputImpl as PublicInputImpl, -// === SMALL END === -// === STARKNET BEGIN === -// air::layouts::starknet::public_input::StarknetPublicInputImpl as PublicInputImpl, -// === STARKNET END === + // === RECURSIVE END === + // === RECURSIVE_WITH_POSEIDON BEGIN === + // air::layouts::recursive_with_poseidon::public_input::RecursiveWithPoseidonPublicInputImpl as PublicInputImpl, + // === RECURSIVE_WITH_POSEIDON END === + // === SMALL BEGIN === + // air::layouts::small::public_input::SmallPublicInputImpl as PublicInputImpl, + // === SMALL END === + // === STARKNET BEGIN === + // air::layouts::starknet::public_input::StarknetPublicInputImpl as PublicInputImpl, + // === STARKNET END === }; const SECURITY_BITS: felt252 = 50; diff --git a/src/stark/tests/test_stark_proof_verify.cairo b/src/stark/tests/test_stark_proof_verify.cairo index bd286c67f..03b492b63 100644 --- a/src/stark/tests/test_stark_proof_verify.cairo +++ b/src/stark/tests/test_stark_proof_verify.cairo @@ -8,7 +8,7 @@ use cairo_verifier::{ // #[available_gas(99999999999)] // fn test_stark_proof_fibonacci_verify() { // let security_bits: felt252 = 50; -// +// // let stark_proof = StarkProof { // config: stone_proof_fibonacci::stark::config::get(), // public_input: stone_proof_fibonacci::public_input::get(), diff --git a/src/table_commitment/tests/test_table_commitment_decommit.cairo b/src/table_commitment/tests/test_table_commitment_decommit.cairo index 5b845691c..6fecdb096 100644 --- a/src/table_commitment/tests/test_table_commitment_decommit.cairo +++ b/src/table_commitment/tests/test_table_commitment_decommit.cairo @@ -17,7 +17,7 @@ use cairo_verifier::{ // let queries = stone_proof_fibonacci::queries::get().span(); // let decommitment = stone_proof_fibonacci::traces::decommitment::get().original; // let witness = stone_proof_fibonacci::traces::witness::get().original; -// +// // table_decommit(commitment, queries, decommitment, witness); // } // === BLAKE2S END === diff --git a/src/vector_commitment/tests/test_vector_commitment_decommit.cairo b/src/vector_commitment/tests/test_vector_commitment_decommit.cairo index faf7242a5..fd6f96839 100644 --- a/src/vector_commitment/tests/test_vector_commitment_decommit.cairo +++ b/src/vector_commitment/tests/test_vector_commitment_decommit.cairo @@ -13,7 +13,7 @@ use cairo_verifier::vector_commitment::vector_commitment::{ // }, // commitment_hash: 0x1e9b0fa29ebe52b9c9a43a1d44e555ce42da3199370134d758735bfe9f40269 // }; -// +// // let queries = array![ // VectorQuery { // index: 0x73, value: 0x12346ea425a6aebc8c323a401410cc325aabaf99b54e600a7271f146488aa2d @@ -47,7 +47,7 @@ use cairo_verifier::vector_commitment::vector_commitment::{ // }, // ] // .span(); -// +// // // let witness = VectorCommitmentWitness { // authentications: array![ // 0x2e9de49846b184d454c30e3b4854167583093da20c5ddef5e3ba2885524d006, @@ -103,7 +103,7 @@ use cairo_verifier::vector_commitment::vector_commitment::{ // ] // .span(), // }; -// +// // // vector_commitment_decommit(commitment, queries, witness); // } // === BLAKE2S END === diff --git a/utils.py b/utils.py index 898c28c9d..2c7bb0130 100644 --- a/utils.py +++ b/utils.py @@ -21,15 +21,19 @@ def process_block(lines: list[str], types: list[str]): modified_lines.append(line) continue - if in_block and line.strip() != "": + if in_block: if current_block_type in types: + # Remove comment if exists if line.lstrip().startswith("// "): modified_lines.append(indent + line.lstrip()[3:]) else: modified_lines.append(line) else: + # Add comment if does not exist if not line.lstrip().startswith("// "): - modified_lines.append(indent + "// " + line.lstrip()) + line_indent = len(line) - len(line.lstrip()) + subtracted_indent = min(len(indent), line_indent) + modified_lines.append(indent + "// " + line[subtracted_indent:]) else: modified_lines.append(line) else: