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 codegen crate #5

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
3 changes: 0 additions & 3 deletions crates/codegen-bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,6 +12,3 @@ zksync_solidity_vk_codegen = { path = "../codegen" }
structopt = "0.3"
dialoguer = "0.8"

[[bin]]
name = "generate"
path = "src/main.rs"
35 changes: 23 additions & 12 deletions crates/codegen-bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -4,17 +4,21 @@ use zksync_solidity_vk_codegen::{generate, Encoding};

const DEFAULT_OUTPUT_FILE: &str = "./hardhat/contracts";

const PAIRING_BN_254_FILE_PATH: &str = "./codegen/template/PairingsBn254.sol";
const TRANSCRIPT_LIB_FILE_PATH: &str = "./codegen/template/TranscriptLib.sol";
const UNCHECKED_MATH_FILE_PATH: &str = "./codegen/template/UncheckedMath.sol";
const PLONK_4_VERIFIER_FILE_PATH: &str = "./codegen/template/Plonk4VerifierWithAccessToDNext.sol";
const VEERIFIER_TEMPLATE_FILE_PATH: &str = "./codegen/template/Verifier.sol";
const PAIRING_BN_254_FILE_PATH: &str = "PairingsBn254.sol";
const TRANSCRIPT_LIB_FILE_PATH: &str = "TranscriptLib.sol";
const UNCHECKED_MATH_FILE_PATH: &str = "UncheckedMath.sol";
const PLONK_4_VERIFIER_FILE_PATH: &str = "Plonk4VerifierWithAccessToDNext.sol";
const VEERIFIER_TEMPLATE_FILE_PATH: &str = "Verifier.sol";

#[derive(StructOpt, Debug)]
pub struct Opts {
/// Path to verification key(required)
/// Path to verification key (required)
#[structopt(long, parse(from_os_str))]
verification_key: PathBuf,
/// Path to the folder with templates (required)
/// Should point to the `codegen/template` directory
#[structopt(long, parse(from_os_str))]
templates_dir: PathBuf,
/// Output directory
#[structopt(long, parse(from_os_str), default_value = DEFAULT_OUTPUT_FILE)]
output: PathBuf,
@@ -27,7 +31,12 @@ fn main() {
let opts = Opts::from_args();
println!("{:#?}", opts);

let Opts { verification_key, output, encoding } = opts;
let Opts {
verification_key,
output,
templates_dir,
encoding,
} = opts;

let encoding = match encoding {
Some(encoding) => match encoding.as_str() {
@@ -37,16 +46,18 @@ fn main() {
None => Encoding::Default,
};

let template_path = |file_name: &str| templates_dir.join(file_name).to_string_lossy().into_owned();

generate(
verification_key,
output.clone(),
encoding,
vec![
VEERIFIER_TEMPLATE_FILE_PATH,
PLONK_4_VERIFIER_FILE_PATH,
TRANSCRIPT_LIB_FILE_PATH,
PAIRING_BN_254_FILE_PATH,
UNCHECKED_MATH_FILE_PATH,
template_path(VEERIFIER_TEMPLATE_FILE_PATH).as_ref(),
template_path(PLONK_4_VERIFIER_FILE_PATH).as_ref(),
template_path(TRANSCRIPT_LIB_FILE_PATH).as_ref(),
template_path(PAIRING_BN_254_FILE_PATH).as_ref(),
template_path(UNCHECKED_MATH_FILE_PATH).as_ref(),
],
);

Loading