Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Jul 29, 2024
1 parent 21cfff3 commit 12001e3
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 231 deletions.
1 change: 1 addition & 0 deletions zero_bin/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pub mod debug_utils;
pub mod fs;
pub mod parsing;
pub mod prover_state;
pub mod version;
16 changes: 16 additions & 0 deletions zero_bin/common/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pub struct Version {
pub evm_arithmetization_pkg_version: String,
pub build_commit_hash: String,
pub build_timestamp: String,
}

impl Version {
pub fn print(&self) {
println!(
"Evm Arithmetization package version: {}",
self.evm_arithmetization_pkg_version
);
println!("Build Commit Hash: {}", self.build_commit_hash);
println!("Build Timestamp: {}", self.build_timestamp);
}
}
2 changes: 1 addition & 1 deletion zero_bin/leader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
build = "build.rs"
build = "../version.rs"

[dependencies]
paladin-core = { workspace = true }
Expand Down
45 changes: 11 additions & 34 deletions zero_bin/leader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use paladin::runtime::Runtime;
use proof_gen::proof_types::GeneratedBlockProof;
use tracing::{info, warn};
use zero_bin_common::block_interval::BlockInterval;
use zero_bin_common::version::Version;

use crate::client::{client_main, ProofParams};

Expand All @@ -20,9 +21,7 @@ mod http;
mod init;
mod stdio;

const EVM_ARITH_VER_KEY: &str = "EVM_ARITHMETIZATION_PKG_VER";
const VERGEN_BUILD_TIMESTAMP: &str = "VERGEN_BUILD_TIMESTAMP";
const VERGEN_RUSTC_COMMIT_HASH: &str = "VERGEN_RUSTC_COMMIT_HASH";
const EVM_ARITHMETIZATION_PKG_VER: &str = "EVM_ARITHMETIZATION_PKG_VER";

fn get_previous_proof(path: Option<PathBuf>) -> Result<Option<GeneratedBlockProof>> {
if path.is_none() {
Expand All @@ -41,36 +40,14 @@ async fn main() -> Result<()> {
load_dotenvy_vars_if_present();
init::tracing();

if env::var_os(EVM_ARITH_VER_KEY).is_none() {
if env::var_os(EVM_ARITHMETIZATION_PKG_VER).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
EVM_ARITH_VER_KEY,
EVM_ARITHMETIZATION_PKG_VER,
// see build.rs
env!("EVM_ARITHMETIZATION_PACKAGE_VERSION"),
);
}
}
if env::var_os(VERGEN_BUILD_TIMESTAMP).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_BUILD_TIMESTAMP,
// see build.rs
env!("VERGEN_BUILD_TIMESTAMP"),
);
}
}
if env::var_os(VERGEN_RUSTC_COMMIT_HASH).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_RUSTC_COMMIT_HASH,
// see build.rs
env!("VERGEN_RUSTC_COMMIT_HASH"),
env!("EVM_ARITHMETIZATION_PKG_VER"),
);
}
}
Expand All @@ -86,12 +63,12 @@ async fn main() -> Result<()> {

match args.command {
Command::Version {} => {
println!(
"Evm Arithmetization package version: {}",
env::var(EVM_ARITH_VER_KEY)?
);
println!("Build Commit Hash: {}", env::var(VERGEN_RUSTC_COMMIT_HASH)?);
println!("Build Timestamp: {}", env::var(VERGEN_BUILD_TIMESTAMP)?);
Version {
evm_arithmetization_pkg_version: env::var(EVM_ARITHMETIZATION_PKG_VER)?,
build_commit_hash: env!("VERGEN_RUSTC_COMMIT_HASH").to_string(),
build_timestamp: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
}
.print();
}
Command::Stdio {
previous_proof,
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
build = "build.rs"
build = "../version.rs"

[dependencies]
__compat_primitive_types = { workspace = true }
Expand Down
30 changes: 0 additions & 30 deletions zero_bin/rpc/build.rs

This file was deleted.

45 changes: 11 additions & 34 deletions zero_bin/rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ use rpc::{retry::build_http_retry_provider, RpcType};
use tracing_subscriber::{prelude::*, EnvFilter};
use url::Url;
use zero_bin_common::block_interval::BlockInterval;
use zero_bin_common::version::Version;

const EVM_ARITH_VER_KEY: &str = "EVM_ARITHMETIZATION_PKG_VER";
const VERGEN_BUILD_TIMESTAMP: &str = "VERGEN_BUILD_TIMESTAMP";
const VERGEN_RUSTC_COMMIT_HASH: &str = "VERGEN_RUSTC_COMMIT_HASH";
const EVM_ARITHMETIZATION_PKG_VER: &str = "EVM_ARITHMETIZATION_PKG_VER";

#[derive(Parser)]
pub enum Cli {
Expand Down Expand Up @@ -48,12 +47,12 @@ impl Cli {
pub async fn execute(self) -> anyhow::Result<()> {
match self {
Self::Version {} => {
println!(
"Evm Arithmetization package version: {}",
env::var(EVM_ARITH_VER_KEY)?
);
println!("Build Commit Hash: {}", env::var(VERGEN_RUSTC_COMMIT_HASH)?);
println!("Build Timestamp: {}", env::var(VERGEN_BUILD_TIMESTAMP)?);
Version {
evm_arithmetization_pkg_version: env::var(EVM_ARITHMETIZATION_PKG_VER)?,
build_commit_hash: env!("VERGEN_RUSTC_COMMIT_HASH").to_string(),
build_timestamp: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
}
.print();
}
Self::Fetch {
start_block,
Expand Down Expand Up @@ -92,36 +91,14 @@ impl Cli {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
if env::var_os(EVM_ARITH_VER_KEY).is_none() {
if env::var_os(EVM_ARITHMETIZATION_PKG_VER).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
EVM_ARITH_VER_KEY,
EVM_ARITHMETIZATION_PKG_VER,
// see build.rs
env!("EVM_ARITHMETIZATION_PACKAGE_VERSION"),
);
}
}
if env::var_os(VERGEN_BUILD_TIMESTAMP).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_BUILD_TIMESTAMP,
// see build.rs
env!("VERGEN_BUILD_TIMESTAMP"),
);
}
}
if env::var_os(VERGEN_RUSTC_COMMIT_HASH).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_RUSTC_COMMIT_HASH,
// see build.rs
env!("VERGEN_RUSTC_COMMIT_HASH"),
env!("EVM_ARITHMETIZATION_PKG_VER"),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "verifier"
authors = ["Polygon Zero <[email protected]>"]
version = "0.1.0"
edition = "2021"
build = "build.rs"
build = "../version.rs"

[dependencies]
clap = { workspace = true }
Expand Down
30 changes: 0 additions & 30 deletions zero_bin/verifier/build.rs

This file was deleted.

45 changes: 11 additions & 34 deletions zero_bin/verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,39 @@ use dotenvy::dotenv;
use proof_gen::proof_types::GeneratedBlockProof;
use serde_json::Deserializer;
use tracing::info;
use zero_bin_common::version::Version;

mod cli;
mod init;

use cli::Command;

const EVM_ARITH_VER_KEY: &str = "EVM_ARITHMETIZATION_PKG_VER";
const VERGEN_BUILD_TIMESTAMP: &str = "VERGEN_BUILD_TIMESTAMP";
const VERGEN_RUSTC_COMMIT_HASH: &str = "VERGEN_RUSTC_COMMIT_HASH";
const EVM_ARITHMETIZATION_PKG_VER: &str = "EVM_ARITHMETIZATION_PKG_VER";

fn main() -> Result<()> {
dotenv().ok();
init::tracing();
let args = cli::Cli::parse();

if env::var_os(EVM_ARITH_VER_KEY).is_none() {
if env::var_os(EVM_ARITHMETIZATION_PKG_VER).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
EVM_ARITH_VER_KEY,
EVM_ARITHMETIZATION_PKG_VER,
// see build.rs
env!("EVM_ARITHMETIZATION_PACKAGE_VERSION"),
);
}
}
if env::var_os(VERGEN_BUILD_TIMESTAMP).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_BUILD_TIMESTAMP,
// see build.rs
env!("VERGEN_BUILD_TIMESTAMP"),
);
}
}
if env::var_os(VERGEN_RUSTC_COMMIT_HASH).is_none() {
// Safety:
// - we're early enough in main that nothing else should race
unsafe {
env::set_var(
VERGEN_RUSTC_COMMIT_HASH,
// see build.rs
env!("VERGEN_RUSTC_COMMIT_HASH"),
env!("EVM_ARITHMETIZATION_PKG_VER"),
);
}
}

if let Some(Command::Version {}) = args.command {
println!(
"Evm Arithmetization package version: {}",
env::var(EVM_ARITH_VER_KEY)?
);
println!("Build Commit Hash: {}", env::var(VERGEN_RUSTC_COMMIT_HASH)?);
println!("Build Timestamp: {}", env::var(VERGEN_BUILD_TIMESTAMP)?);
Version {
evm_arithmetization_pkg_version: env::var(EVM_ARITHMETIZATION_PKG_VER)?,
build_commit_hash: env!("VERGEN_RUSTC_COMMIT_HASH").to_string(),
build_timestamp: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
}
.print();
return Ok(());
}

Expand Down
2 changes: 1 addition & 1 deletion zero_bin/leader/build.rs → zero_bin/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> anyhow::Result<()> {
.context("couldn't find evm_arithmetization package")?
.version;
println!(
"cargo::rustc-env=EVM_ARITHMETIZATION_PACKAGE_VERSION={}.{}.x",
"cargo::rustc-env=EVM_ARITHMETIZATION_PKG_VER={}.{}.x",
// patch version change should not prompt circuits regeneration
version.major,
version.minor
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
build = "build.rs"
build = "../version.rs"

[dependencies]
paladin-core = { workspace = true }
Expand Down
30 changes: 0 additions & 30 deletions zero_bin/worker/build.rs

This file was deleted.

Loading

0 comments on commit 12001e3

Please sign in to comment.