Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmp/new l2geth #1359

Closed
wants to merge 18 commits into from
Prev Previous commit
Revert "tmp disable circuit test"
This reverts commit 39f8d5a.
lightsing committed Aug 7, 2024
commit 545ca5be8619cfd53ae406b51e7e36a9e14ecd85
164 changes: 82 additions & 82 deletions testool/src/statetest/executor.rs
Original file line number Diff line number Diff line change
@@ -567,88 +567,88 @@ pub fn run_test(
log::debug!("witness_block created");
//builder.sdb.list_accounts();

// let row_usage = ScrollSuperCircuit::min_num_rows_block_subcircuits(&witness_block);
// let mut overflow = false;
// for (num, limit) in row_usage.iter().zip_eq(
// get_sub_circuit_limit_and_confidence()
// .iter()
// .map(|(limit, _)| limit),
// ) {
// if num.row_num_real > *limit {
// log::warn!(
// "ccc detail: suite.id {}, st.id {}, circuit {}, num {}, limit {}",
// suite.id,
// st.id,
// num.name,
// num.row_num_real,
// limit
// );
// overflow = true;
// }
// }
// let max_row_usage = row_usage.iter().max_by_key(|r| r.row_num_real).unwrap();
// if overflow {
// log::warn!(
// "ccc overflow: st.id {}, detail {} {}",
// st.id,
// max_row_usage.name,
// max_row_usage.row_num_real
// );
// // panic!("{} {}", max_row_usage.name, max_row_usage.row_num_real);
// return Err(StateTestError::CircuitOverflow {
// circuit: max_row_usage.name.to_string(),
// needed: max_row_usage.row_num_real,
// });
// }
// log::info!(
// "ccc ok: st.id {}, detail {} {}",
// st.id,
// max_row_usage.name,
// max_row_usage.row_num_real
// );

// if !circuits_config.super_circuit {
// if (*CIRCUIT).is_empty() {
// CircuitTestBuilder::<1, 1>::new_from_block(witness_block).run();
// } else {
// match (*CIRCUIT).as_str() {
// "modexp" => test_with::<ModExpCircuit<Fr>>(&witness_block),
// "bytecode" => test_with::<BytecodeCircuit<Fr>>(&witness_block),
// "ecc" => test_with::<EccCircuit<Fr, 9>>(&witness_block),
// "sig" => {
// if !witness_block
// .precompile_events
// .get_ecrecover_events()
// .is_empty()
// {
// test_with::<SigCircuit<Fr>>(&witness_block);
// } else {
// log::warn!("no ec recover event {}, skip", st.id);
// }
// }
// _ => unimplemented!(),
// };
// }
// } else {
// log::debug!("test super circuit {}", *CIRCUIT);
//
// // TODO: these codes are too difficult to maintain.
// // The correct way is to dump trace files,
// // and use separate tools to test trace files.
// #[cfg(feature = "inner-prove")]
// {
// eth_types::constants::set_env_coinbase(&st.env.current_coinbase);
// prover::test::inner_prove(&test_id, &witness_block);
// }
// #[cfg(feature = "chunk-prove")]
// {
// eth_types::constants::set_env_coinbase(&st.env.current_coinbase);
// prover::test::chunk_prove(&test_id, prover::ChunkProvingTask::from(vec![scroll_trace]));
// }
//
// #[cfg(not(any(feature = "inner-prove", feature = "chunk-prove")))]
// mock_prove(&test_id, &witness_block);
// };
let row_usage = ScrollSuperCircuit::min_num_rows_block_subcircuits(&witness_block);
let mut overflow = false;
for (num, limit) in row_usage.iter().zip_eq(
get_sub_circuit_limit_and_confidence()
.iter()
.map(|(limit, _)| limit),
) {
if num.row_num_real > *limit {
log::warn!(
"ccc detail: suite.id {}, st.id {}, circuit {}, num {}, limit {}",
suite.id,
st.id,
num.name,
num.row_num_real,
limit
);
overflow = true;
}
}
let max_row_usage = row_usage.iter().max_by_key(|r| r.row_num_real).unwrap();
if overflow {
log::warn!(
"ccc overflow: st.id {}, detail {} {}",
st.id,
max_row_usage.name,
max_row_usage.row_num_real
);
// panic!("{} {}", max_row_usage.name, max_row_usage.row_num_real);
return Err(StateTestError::CircuitOverflow {
circuit: max_row_usage.name.to_string(),
needed: max_row_usage.row_num_real,
});
}
log::info!(
"ccc ok: st.id {}, detail {} {}",
st.id,
max_row_usage.name,
max_row_usage.row_num_real
);

if !circuits_config.super_circuit {
if (*CIRCUIT).is_empty() {
CircuitTestBuilder::<1, 1>::new_from_block(witness_block).run();
} else {
match (*CIRCUIT).as_str() {
"modexp" => test_with::<ModExpCircuit<Fr>>(&witness_block),
"bytecode" => test_with::<BytecodeCircuit<Fr>>(&witness_block),
"ecc" => test_with::<EccCircuit<Fr, 9>>(&witness_block),
"sig" => {
if !witness_block
.precompile_events
.get_ecrecover_events()
.is_empty()
{
test_with::<SigCircuit<Fr>>(&witness_block);
} else {
log::warn!("no ec recover event {}, skip", st.id);
}
}
_ => unimplemented!(),
};
}
} else {
log::debug!("test super circuit {}", *CIRCUIT);

// TODO: these codes are too difficult to maintain.
// The correct way is to dump trace files,
// and use separate tools to test trace files.
#[cfg(feature = "inner-prove")]
{
eth_types::constants::set_env_coinbase(&st.env.current_coinbase);
prover::test::inner_prove(&test_id, &witness_block);
}
#[cfg(feature = "chunk-prove")]
{
eth_types::constants::set_env_coinbase(&st.env.current_coinbase);
prover::test::chunk_prove(&test_id, prover::ChunkProvingTask::from(vec![scroll_trace]));
}

#[cfg(not(any(feature = "inner-prove", feature = "chunk-prove")))]
mock_prove(&test_id, &witness_block);
};
log::debug!("balance_overflow = {balance_overflow}");
log::debug!(
"has_l2_different_evm_behaviour_trace = {}",