mirror of
https://github.com/zkemail/halo2-zk-email.git
synced 2026-01-09 05:47:57 -05:00
Add custom gas limit to setup_eth_backend.
This commit is contained in:
@@ -280,7 +280,7 @@ export async function initMultiThread() {
|
||||
console.log(multiThread);
|
||||
await multiThread.default();
|
||||
console.log(`hardware: ${navigator.hardwareConcurrency}`);
|
||||
await multiThread.initThreadPool(4);
|
||||
await multiThread.initThreadPool(navigator.hardwareConcurrency);
|
||||
return multiThread;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,8 @@ enum Commands {
|
||||
/// public input file
|
||||
#[arg(long, default_value = "./build/public_input.json")]
|
||||
public_input_path: String,
|
||||
#[arg(short, long)]
|
||||
gas_limit: Option<u64>,
|
||||
},
|
||||
GenRegexFiles {
|
||||
#[arg(short, long, default_value = "./configs/decomposed_regex_config.json")]
|
||||
@@ -247,8 +249,9 @@ async fn main() {
|
||||
sols_dir,
|
||||
proof_path,
|
||||
public_input_path,
|
||||
gas_limit,
|
||||
} => {
|
||||
evm_verify(&circuit_config_path, &sols_dir, &proof_path, &public_input_path).await.unwrap();
|
||||
evm_verify(&circuit_config_path, &sols_dir, &proof_path, &public_input_path, gas_limit).await.unwrap();
|
||||
}
|
||||
Commands::GenRegexFiles {
|
||||
decomposed_regex_config_path,
|
||||
|
||||
@@ -65,9 +65,9 @@ pub struct DeployParamsJson {
|
||||
pub type EthersClient = Arc<SignerMiddleware<Provider<Http>, Wallet<SigningKey>>>;
|
||||
|
||||
// original: https://github.com/zkonduit/ezkl/blob/main/src/eth.rs#L58-L86
|
||||
pub async fn setup_eth_backend() -> AnvilInstance {
|
||||
pub async fn setup_eth_backend(gas_limit: u64) -> AnvilInstance {
|
||||
// Launch anvil
|
||||
let anvil = Anvil::new().arg("--gas-limit").arg("100000000").spawn();
|
||||
let anvil = Anvil::new().arg("--gas-limit").arg(gas_limit.to_string()).spawn();
|
||||
anvil
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ pub async fn setup_eth_client(anvil: &AnvilInstance) -> EthersClient {
|
||||
client
|
||||
}
|
||||
|
||||
pub async fn deploy_and_call_verifiers(sols_dir: &PathBuf, runs: Option<usize>, proof: &[u8], instance: &DefaultEmailVerifyPublicInput) {
|
||||
let anvil = setup_eth_backend().await;
|
||||
pub async fn deploy_and_call_verifiers(sols_dir: &PathBuf, runs: Option<usize>, proof: &[u8], instance: &DefaultEmailVerifyPublicInput, gas_limit: u64) {
|
||||
let anvil = setup_eth_backend(gas_limit).await;
|
||||
let client = setup_eth_client(&anvil).await;
|
||||
let runs = runs.unwrap_or(1);
|
||||
let config_params = default_config_params();
|
||||
|
||||
@@ -503,7 +503,7 @@ pub fn gen_evm_verifier<C: CircuitExt<Fr>>(
|
||||
/// # Note
|
||||
/// The contract size limitation is disabled in this function.
|
||||
/// Therefore, your verifier contract may violate that limitation even if it passes the verification here.
|
||||
pub async fn evm_verify(circuit_config_path: &str, sols_dir: &str, proof_path: &str, public_input_path: &str) -> Result<(), Error> {
|
||||
pub async fn evm_verify(circuit_config_path: &str, sols_dir: &str, proof_path: &str, public_input_path: &str, gas_limit: Option<u64>) -> Result<(), Error> {
|
||||
set_var(EMAIL_VERIFY_CONFIG_ENV, circuit_config_path);
|
||||
let proof = {
|
||||
let mut f = File::open(&proof_path).unwrap();
|
||||
@@ -514,7 +514,8 @@ pub async fn evm_verify(circuit_config_path: &str, sols_dir: &str, proof_path: &
|
||||
println!("proof {}", hex::encode(&proof));
|
||||
let public_input = serde_json::from_reader(File::open(public_input_path).unwrap()).unwrap();
|
||||
println!("public_input {:?}", public_input);
|
||||
deploy_and_call_verifiers(&PathBuf::new().join(sols_dir), None, &proof, &public_input).await;
|
||||
let gas_limit = gas_limit.unwrap_or(100000000);
|
||||
deploy_and_call_verifiers(&PathBuf::new().join(sols_dir), None, &proof, &public_input, gas_limit).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -640,7 +641,7 @@ mod test {
|
||||
evm_prove(params_path, circuit_config_path, pk_path, evm_proof_path, circuit.clone()).unwrap();
|
||||
gen_evm_verifier::<DefaultEmailVerifyCircuit<Fr>>(params_path, circuit_config_path, vk_path, sols_dir, None).unwrap();
|
||||
});
|
||||
evm_verify(circuit_config_path, sols_dir, evm_proof_path, public_input_path).await.unwrap();
|
||||
evm_verify(circuit_config_path, sols_dir, evm_proof_path, public_input_path, None).await.unwrap();
|
||||
}
|
||||
|
||||
// #[ignore]
|
||||
|
||||
Reference in New Issue
Block a user