-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zksync_cli): Health checkpoint improvements (#3193)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> Add three new components to node's healthcheck: - General (i.e., version, last migration) - State Keeper - Eth Sender ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --------- Co-authored-by: Danil <[email protected]>
- Loading branch information
1 parent
193c855
commit 440fe8d
Showing
42 changed files
with
756 additions
and
241 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "zksync_bin_metadata" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
|
||
[dependencies] | ||
serde.workspace = true | ||
vise.workspace = true | ||
tracing.workspace = true | ||
|
||
[build-dependencies] | ||
rustc_version.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//! Build script for the external node binary. | ||
use std::{ | ||
env, fs, | ||
io::{self, Write}, | ||
path::Path, | ||
process::Command, | ||
}; | ||
|
||
use rustc_version::{Channel, LlvmVersion}; | ||
|
||
fn print_binary_meta(out: &mut impl Write) -> io::Result<()> { | ||
let rustc_meta = rustc_version::version_meta().expect("Failed obtaining rustc metadata"); | ||
|
||
writeln!( | ||
out, | ||
"pub const RUST_METADATA: RustMetadata = RustMetadata {{ \ | ||
version: {semver:?}, \ | ||
commit_hash: {commit_hash:?}, \ | ||
commit_date: {commit_date:?}, \ | ||
channel: {channel:?}, \ | ||
host: {host:?}, \ | ||
llvm: {llvm:?}, \ | ||
}}; | ||
pub const GIT_METADATA: GitMetadata = GitMetadata {{ \ | ||
branch: {git_branch:?}, \ | ||
revision: {git_revision:?} \ | ||
}};", | ||
semver = rustc_meta.semver.to_string(), | ||
commit_hash = rustc_meta.commit_hash, | ||
commit_date = rustc_meta.commit_date, | ||
channel = match rustc_meta.channel { | ||
Channel::Dev => "dev", | ||
Channel::Beta => "beta", | ||
Channel::Nightly => "nightly", | ||
Channel::Stable => "stable", | ||
}, | ||
host = rustc_meta.host, | ||
llvm = rustc_meta.llvm_version.as_ref().map(LlvmVersion::to_string), | ||
git_branch = git_branch(), | ||
git_revision = git_revision() | ||
) | ||
} | ||
|
||
/// Outputs the current git branch as a string literal. | ||
pub fn git_branch() -> Option<String> { | ||
run_cmd_opt("git", &["rev-parse", "--abbrev-ref", "HEAD"]) | ||
} | ||
|
||
/// Outputs the current git commit hash as a string literal. | ||
pub fn git_revision() -> Option<String> { | ||
run_cmd_opt("git", &["rev-parse", "--short", "HEAD"]) | ||
} | ||
|
||
fn run_cmd_opt(cmd: &str, args: &[&str]) -> Option<String> { | ||
let output = Command::new(cmd).args(args).output().ok()?; | ||
if output.status.success() { | ||
String::from_utf8(output.stdout) | ||
.ok() | ||
.map(|s| s.trim().to_string()) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn main() { | ||
let out_dir = env::var("OUT_DIR").expect("`OUT_DIR` env var not set for build script"); | ||
let metadata_module_path = Path::new(&out_dir).join("metadata_values.rs"); | ||
let metadata_module = | ||
fs::File::create(metadata_module_path).expect("cannot create metadata module"); | ||
let mut metadata_module = io::BufWriter::new(metadata_module); | ||
|
||
print_binary_meta(&mut metadata_module).expect("failed printing binary metadata"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use serde::Serialize; | ||
use vise::{EncodeLabelSet, Info, Metrics}; | ||
|
||
use self::values::{GIT_METADATA, RUST_METADATA}; | ||
|
||
pub mod values { | ||
use super::{GitMetadata, RustMetadata}; | ||
|
||
include!(concat!(env!("OUT_DIR"), "/metadata_values.rs")); | ||
} | ||
|
||
pub const BIN_METADATA: BinMetadata = BinMetadata { | ||
rust: RUST_METADATA, | ||
git: GIT_METADATA, | ||
}; | ||
|
||
/// Metadata of the compiled binary. | ||
#[derive(Debug, Serialize)] | ||
pub struct BinMetadata { | ||
pub rust: RustMetadata, | ||
pub git: GitMetadata, | ||
} | ||
|
||
/// Rust metadata of the compiled binary. | ||
#[derive(Debug, EncodeLabelSet, Serialize)] | ||
pub struct RustMetadata { | ||
pub version: &'static str, | ||
pub commit_hash: Option<&'static str>, | ||
pub commit_date: Option<&'static str>, | ||
pub channel: &'static str, | ||
pub host: &'static str, | ||
pub llvm: Option<&'static str>, | ||
} | ||
|
||
/// Git metadata of the compiled binary. | ||
#[derive(Debug, EncodeLabelSet, Serialize)] | ||
pub struct GitMetadata { | ||
pub branch: Option<&'static str>, | ||
pub revision: Option<&'static str>, | ||
} | ||
|
||
#[derive(Debug, Metrics)] | ||
#[metrics(prefix = "rust")] | ||
pub struct RustMetrics { | ||
/// General information about the compiled binary. | ||
info: Info<RustMetadata>, | ||
} | ||
|
||
impl RustMetrics { | ||
pub fn initialize(&self) { | ||
tracing::info!("Rust metadata for this binary: {RUST_METADATA:?}"); | ||
self.info.set(RUST_METADATA).ok(); | ||
} | ||
} | ||
|
||
#[derive(Debug, Metrics)] | ||
#[metrics(prefix = "git_info")] | ||
pub struct GitMetrics { | ||
/// General information about the compiled binary. | ||
info: Info<GitMetadata>, | ||
} | ||
|
||
impl GitMetrics { | ||
pub fn initialize(&self) { | ||
tracing::info!("Git metadata for this binary: {GIT_METADATA:?}"); | ||
self.info.set(GIT_METADATA).ok(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...lib/dal/.sqlx/query-3566423188a5d6bed7150f327d83613cd34138b59ef3b9271fd0bfdaddd086f8.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.