Skip to content

Commit

Permalink
feat: validate tx count from trace before creating proof
Browse files Browse the repository at this point in the history
  • Loading branch information
lightscale-luke committed Aug 22, 2023
1 parent 68becdd commit 0b06ba1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bin/src/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::io::Write;
use std::path::PathBuf;
use utils::Measurer;
use zkevm::{
circuit::{EvmCircuit, StateCircuit, AGG_DEGREE, DEGREE},
circuit::{EvmCircuit, StateCircuit, AGG_DEGREE, DEGREE, MAX_TXS},
io::write_file,
prover::Prover,
utils::{get_block_trace_from_file, load_or_create_params, load_or_create_seed},
Expand Down Expand Up @@ -78,6 +78,16 @@ fn main() {
// Generating proofs for each trace
let mut outer_timer = Measurer::new();
for (trace_name, trace) in traces {
let tx_count = trace.transactions.len();
if tx_count > MAX_TXS {
panic!(
"{}",
format!(
"Too many transactions. MAX_TXS:{}, given transactions:{}",
MAX_TXS, tx_count
)
);
}
let mut out_dir = PathBuf::from(&trace_name);
fs::create_dir_all(&out_dir).unwrap();

Expand Down
10 changes: 10 additions & 0 deletions prover-server/src/server_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use jsonrpc_http_server::jsonrpc_core::{ErrorCode, Result};
use jsonrpc_http_server::ServerBuilder;
use spec::ZkSpec;
use types::eth::BlockTrace;
use zkevm::circuit::MAX_TXS;

const KROMA_CHAIN_ID: u32 = 901;

Expand Down Expand Up @@ -58,6 +59,15 @@ impl Rpc for RpcImpl {
return Err(err);
}
};
let tx_count = block_trace.transactions.len();
if tx_count > MAX_TXS {
kroma_err(format!(
"Too many transactions. MAX_TXS:{}, given transactions:{}",
MAX_TXS, tx_count
));
let err = jsonrpc_core::Error::new(ErrorCode::InvalidRequest);
return Err(err);
}

// initiate ProofType
let proof_type = ProofType::from_value(proof_type);
Expand Down

0 comments on commit 0b06ba1

Please sign in to comment.