Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
add version information about zkevm-circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkiebell committed Feb 2, 2023
1 parent 96983cd commit fd00efd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
50 changes: 50 additions & 0 deletions prover/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use std::env::var;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::process::Command;

fn get_crate_version(pkg: &str) -> String {
let cmd = Command::new("cargo")
.args([
"tree",
"--package",
pkg,
"--depth",
"0",
"--prefix",
"none",
"--quiet",
"--charset",
"utf8",
])
.output()
.expect("cargo tree output");

String::from_utf8(cmd.stdout).expect("utf8 output")
}

fn main() {
let pkg_version = var("CARGO_PKG_VERSION").expect("CARGO_PKG_VERSION");
let version = format!(
"pub const VERSION: &str = \"{}\n{}\";",
pkg_version,
get_crate_version("zkevm-circuits"),
);

let path = "src/version.rs";
let update = match File::open(path) {
Ok(mut file) => {
let mut buffer = String::new();
file.read_to_string(&mut buffer).expect("read version.rs");
buffer != version
}
Err(_) => true,
};

if update {
let mut file = File::create(path).expect("create version.rs");
file.write_all(version.as_bytes())
.expect("write version.rs");
}
}
3 changes: 2 additions & 1 deletion prover/src/bin/prover_rpcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use env_logger::Env;

use prover::server::serve;
use prover::shared_state::SharedState;
use prover::version::VERSION;

#[derive(Parser, Debug)]
#[clap(version, about)]
#[clap(version = VERSION, about)]
/// This command starts a http/json-rpc server and serves proof oriented methods.
pub(crate) struct ProverdConfig {
#[clap(long, env = "PROVERD_BIND")]
Expand Down
1 change: 1 addition & 0 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ pub mod circuits;
pub mod server;
pub mod shared_state;
pub mod utils;
pub mod version;
3 changes: 3 additions & 0 deletions prover/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub const VERSION: &str = "0.1.0
zkevm-circuits v0.1.0 (https://github.com/pinkiebell/zkevm-circuits.git?branch=zkevm-chain#27141e57)
";

0 comments on commit fd00efd

Please sign in to comment.