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

fix: calc degree from the origin l1 transactions #3

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ zkevm_common = { path = "../common" }
itertools = "0.10.3"
clap = { version = "4.0.14", features = ["derive", "env"] }
hex = "0.4.3"
rlp = "0.5.2"

# autogen
mock = { git = "https://github.com/taikoxyz/zkevm-circuits.git", branch = "taiko-pi-test", optional = true }
Expand Down
20 changes: 12 additions & 8 deletions prover/src/circuit_witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use eth_types::H256;
use eth_types::{geth_types, Bytes};
use ethers_providers::Http;
use halo2_proofs::halo2curves::bn256::Fr;
use rlp::Rlp;
use std::str::FromStr;
use zkevm_circuits::evm_circuit;
use zkevm_circuits::pi_circuit::PublicData;
Expand All @@ -23,6 +24,7 @@ pub struct CircuitWitness {
pub block: bus_mapping::circuit_input_builder::Block,
pub code_db: bus_mapping::state_db::CodeDB,
pub txs_rlp: Bytes,
pub l1_txs: Vec<eth_types::Transaction>,
}

impl CircuitWitness {
Expand Down Expand Up @@ -61,6 +63,7 @@ impl CircuitWitness {
block: builder.block,
code_db: builder.code_db,
txs_rlp: Bytes::default(),
l1_txs: vec![],
})
}

Expand All @@ -78,21 +81,21 @@ impl CircuitWitness {
&hex::decode(propose_tx_hash).expect("parse propose tx hash"),
);
let txs_rlp = get_txs_rlp(&l1_geth_client, propose_tx_hash).await?;
let l1_txs = Rlp::new(&txs_rlp).as_list().expect("invalid txs rlp");

let l2_url = Http::from_str(l2_rpc_url)?;
let l2_geth_client = GethClient::new(l2_url);
// TODO: add support for `eth_getHeaderByNumber`
let block = l2_geth_client
.get_block_by_number((*block_num).into())
.await?;
let circuit_config =
crate::match_circuit_params_txs!(block.transactions.len(), CIRCUIT_CONFIG, {
return Err(format!(
"No circuit parameters found for block with gas used={}",
block.gas_used
)
.into());
});
let circuit_config = crate::match_circuit_params_txs!(l1_txs.len(), CIRCUIT_CONFIG, {
return Err(format!(
"No circuit parameters found for block with gas used={}",
block.gas_used
)
.into());
});
let circuit_params = CircuitsParams {
max_txs: circuit_config.max_txs,
max_calldata: circuit_config.max_calldata,
Expand All @@ -109,6 +112,7 @@ impl CircuitWitness {
block: builder.block,
code_db: builder.code_db,
txs_rlp,
l1_txs,
})
}

Expand Down
2 changes: 1 addition & 1 deletion prover/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async fn handle_method(
.map_err(|e| e.to_string())?;

let circuit_config =
crate::match_circuit_params!(witness.gas_used(), CIRCUIT_CONFIG, {
crate::match_circuit_params_txs!(witness.l1_txs.len(), CIRCUIT_CONFIG, {
return Err(format!(
"No circuit parameters found for block with gas={}",
witness.gas_used()
Expand Down
2 changes: 1 addition & 1 deletion prover/src/shared_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl SharedState {
.map_err(|e| e.to_string())?;

let (config, circuit_proof, aggregation_proof) = crate::match_circuit_params_txs!(
witness.txs().len(),
witness.l1_txs.len(),
{
match task_options_copy.circuit.as_str() {
"pi" => {
Expand Down