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

Commit

Permalink
fix merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaZ030 committed Nov 1, 2023
1 parent dfd3d4a commit 75af7b8
Showing 1 changed file with 66 additions and 26 deletions.
92 changes: 66 additions & 26 deletions integration-tests/src/integration_public_data_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
mod public_data_test {
use crate::get_client;
use bus_mapping::{
circuit_input_builder::{
protocol_instance::BlockEvidence, BlockMetadata, BuilderClient, CircuitsParams,
ProtocolInstance,
circuit_input_builder::{BuilderClient, CircuitsParams, ProtocolInstance,
protocol_instance::{BlockEvidence, BlockMetadata}
},
rpc::BlockNumber,
};
use eth_types::{Address, Block as EthBlock, Hash, Transaction};
use ethers::abi::{Function, Param, ParamType, StateMutability};
use halo2_proofs::{arithmetic::Field, dev::{MockProver, CellValue}, halo2curves::bn256::Fr};
use ethers::{
abi::{Function, Param, ParamType, StateMutability},
utils::hex,
};
use halo2_proofs::{
arithmetic::Field,
dev::{CellValue, MockProver},
halo2curves::bn256::Fr,
};
use log::error;
use std::str::FromStr;
use testool::{parse_address, parse_hash};
Expand All @@ -38,8 +44,7 @@ mod public_data_test {
.map(|to| {
to == protocol_address
&& tx.input.len() > 4
&& &tx.input[0..4]
== parse_hash(PROPOSAL_TX_METHOD_SIGNATURE).unwrap().as_bytes()
&& tx.input[0..4] == hex::decode(PROPOSAL_TX_METHOD_SIGNATURE).unwrap()
})
.unwrap_or(false)
})
Expand Down Expand Up @@ -156,7 +161,7 @@ mod public_data_test {

let txlist_bytes = get_txlist_bytes(&proposal_txs[2]);

let expected_txlist_bytes = parse_hash(
let expected_txlist_bytes = hex::decode(
concat!("f95973b90c3a02f90c3683028c5d8268e884600d0e6a84600d0e6c830748229421561e1c1c64e18ab02654f365f3b0f7509d948180b90bc4fee99b22000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000",
"0000000000000697c00000000000000000000000010007777000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000028c5e0000000000000000000000000000000000000000000000000000000000028c5d00000000000000000000000029c5dc4a469f868df9b799ef3c282a5883b06c9b000000000000000000000000d90d8e85d0472ebc61267ecbba544252b719745200000000",
"000000000000000029c5dc4a469f868df9b799ef3c282a5883b06c9b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064c2f256035a000000000000000000000000000000000000000000000000000000000002fe9a0000000000000000000000000000000000",
Expand Down Expand Up @@ -291,7 +296,7 @@ mod public_data_test {
"0909e64d9966b0d80b844095ea7b300000000000000000000000010007777000000000000000000000000000000020000000000000000000000000000000000000000000000135541deabf44f6902c001a068108a0e7faeb0a2b420b980f9d6303d8004f6fbdfed61acf31340ada1acd60ba01c238069bbab8d81718624715691406a6946d63a2dcc9a614a850b5c9dceb998b8b502f8b283028c5d1d8459682f008459682f0182b4b8947b1a",
"3117b2b9be3a3c31e5a097c7f890199666ac80b844095ea7b3000000000000000000000000501f63210ae6d7eeb50dae74da5ae407515ee24600000000000000000000000000000000000000000000000000000000000b4801c080a07c21aae4318c817c8853f35560302ca83a6166bd1f92111f0b86b256aa213d13a04db98b7d01383ff2fb3435905b545c01182045c80e68380e66eaf47773c5d27e")
).unwrap();
assert_eq!(&txlist_bytes, expected_txlist_bytes.as_bytes());
assert_eq!(txlist_bytes, expected_txlist_bytes);
}

fn run_super_circuit_mock_prover(block: &Block<Fr>) {
Expand Down Expand Up @@ -330,22 +335,7 @@ mod public_data_test {
println!("anchor_info: {:?}", anchor_info);
}

#[tokio::test]
async fn test_pure_anchor_block() {
let block_num = 10;
let cli = get_client();

let circuits_params = CircuitsParams {
max_txs: 80,
max_calldata: 69750,
max_bytecode: 139500,
max_rws: 524288,
max_copy_rows: 524288,
max_exp_steps: 27900,
max_evm_rows: 0,
max_keccak_rows: 0,
};

fn gen_requests() -> Vec<ProtocolInstance> {
let metadata = BlockMetadata {
l1Hash: parse_hash("6e3b781b2d9a04e21ecba49e67dc3fb0a8242408cc07fa6fed5d8bd0eca2c985")
.unwrap()
Expand Down Expand Up @@ -394,6 +384,15 @@ mod public_data_test {
block_evidence,
..Default::default()
};
vec![protocol_instance]
}

async fn gen_block(
circuits_params: CircuitsParams,
protocol_instance: ProtocolInstance,
) -> Block<Fr> {
let block_num = protocol_instance.block_evidence.blockMetadata.id;
let cli = get_client();

let cli = BuilderClient::new(cli, circuits_params, Some(protocol_instance.clone()))
.await
Expand All @@ -406,9 +405,25 @@ mod public_data_test {
block.randomness = Fr::ONE;
block.protocol_instance = Some(protocol_instance);

// block
block
}

#[tokio::test]
async fn test_pure_anchor_block() {
let circuits_params = CircuitsParams {
max_txs: 80,
max_calldata: 69750,
max_bytecode: 139500,
max_rws: 524288,
max_copy_rows: 524288,
max_exp_steps: 27900,
max_evm_rows: 80000,
max_keccak_rows: 0,
};
let protocol_instance = gen_requests()[0].clone();
let block = gen_block(circuits_params, protocol_instance).await;
run_super_circuit_mock_prover(&block);
}

#[tokio::test]
async fn test_block_statistics() {
Expand All @@ -435,4 +450,29 @@ mod public_data_test {
cli.gen_inputs(i).await.unwrap();
}
}

#[tokio::test]
async fn test_fixed_stablity() {
let circuits_params = CircuitsParams {
max_txs: 80,
max_calldata: 69750,
max_bytecode: 139500,
max_rws: 72428,
max_copy_rows: 72428,
max_exp_steps: 27900,
max_evm_rows: 80000,
max_keccak_rows: 20000,
};

let requests = gen_requests();
let protocol_instances: std::iter::Take<std::slice::Iter<'_, ProtocolInstance>> =
requests.iter().take(2);
assert!(protocol_instances.len() == 2);
let mut fixed_wits = vec![];
for protocol_instance in protocol_instances {
let block = gen_block(circuits_params, protocol_instance.clone()).await;
fixed_wits.push(get_fixed_columns(&block));
}
assert!(fixed_wits[0] == fixed_wits[1])
}
}

0 comments on commit 75af7b8

Please sign in to comment.