From 152cb114fe6d5881958e72839832ec3e9f50fb81 Mon Sep 17 00:00:00 2001 From: Francisco Moura Date: Tue, 22 Aug 2023 16:29:54 -0300 Subject: [PATCH] feat: Add version log --- .dockerignore | 1 - offchain/Cargo.lock | 85 +++++++++++++++++++ offchain/Cargo.toml | 6 ++ offchain/advance-runner/Cargo.toml | 5 ++ offchain/advance-runner/src/main.rs | 12 +++ offchain/authority-claimer/Cargo.toml | 7 ++ offchain/authority-claimer/src/built/build.rs | 5 ++ offchain/authority-claimer/src/main.rs | 11 +++ offchain/build-info/Cargo.toml | 10 +++ offchain/build-info/src/build.rs | 6 ++ offchain/build-info/src/lib.rs | 19 +++++ offchain/dispatcher/Cargo.toml | 6 ++ offchain/dispatcher/src/built/build.rs | 5 ++ offchain/dispatcher/src/main.rs | 12 +++ offchain/graphql-server/Cargo.toml | 6 ++ offchain/graphql-server/src/main.rs | 12 +++ offchain/host-runner/Cargo.toml | 5 ++ offchain/host-runner/src/main.rs | 11 +++ offchain/indexer/Cargo.toml | 6 ++ offchain/indexer/src/main.rs | 12 +++ offchain/inspect-server/Cargo.toml | 3 + offchain/inspect-server/build.rs | 3 + offchain/inspect-server/src/main.rs | 11 +++ offchain/state-server/Cargo.toml | 6 ++ offchain/state-server/src/main.rs | 11 +++ 25 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 offchain/authority-claimer/src/built/build.rs create mode 100644 offchain/build-info/Cargo.toml create mode 100644 offchain/build-info/src/build.rs create mode 100644 offchain/build-info/src/lib.rs create mode 100644 offchain/dispatcher/src/built/build.rs diff --git a/.dockerignore b/.dockerignore index cf579a49c..f4ceea785 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1 @@ -.git **/target/ diff --git a/offchain/Cargo.lock b/offchain/Cargo.lock index 2632d121d..3e25a1e29 100644 --- a/offchain/Cargo.lock +++ b/offchain/Cargo.lock @@ -246,6 +246,8 @@ version = "1.1.0" dependencies = [ "async-trait", "backoff", + "build-info", + "built", "clap", "contracts", "env_logger", @@ -485,6 +487,8 @@ name = "authority-claimer" version = "1.1.0" dependencies = [ "async-trait", + "build-info", + "built", "clap", "eth-tx-manager", "ethers", @@ -864,6 +868,26 @@ dependencies = [ "uuid 0.8.2", ] +[[package]] +name = "build-info" +version = "1.1.0" +dependencies = [ + "built", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "built" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99c4cdc7b2c2364182331055623bdf45254fcb679fea565c40c3c11c101889a" +dependencies = [ + "cargo-lock", + "chrono", + "git2", +] + [[package]] name = "bumpalo" version = "3.13.0" @@ -936,6 +960,18 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-lock" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e11c675378efb449ed3ce8de78d75d0d80542fc98487c26aba28eb3b82feac72" +dependencies = [ + "semver", + "serde", + "toml 0.7.6", + "url", +] + [[package]] name = "cargo-platform" version = "0.1.3" @@ -1512,6 +1548,8 @@ dependencies = [ "async-trait", "axum", "backoff", + "build-info", + "built", "clap", "contracts", "eth-state-client-lib", @@ -2404,6 +2442,19 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "git2" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044" +dependencies = [ + "bitflags 1.3.2", + "libc", + "libgit2-sys", + "log 0.4.20", + "url", +] + [[package]] name = "glob" version = "0.3.1" @@ -2427,6 +2478,8 @@ dependencies = [ "actix-cors", "actix-web", "awc", + "build-info", + "built", "clap", "hex", "http-health-check", @@ -2556,6 +2609,8 @@ version = "1.1.0" dependencies = [ "actix-web", "async-trait", + "build-info", + "built", "byteorder", "clap", "ethabi", @@ -2807,6 +2862,8 @@ name = "indexer" version = "1.1.0" dependencies = [ "backoff", + "build-info", + "built", "clap", "env_logger", "http-health-check", @@ -2860,6 +2917,8 @@ version = "1.1.0" dependencies = [ "actix-cors", "actix-web", + "build-info", + "built", "clap", "futures", "hex", @@ -3053,6 +3112,30 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libgit2-sys" +version = "0.15.2+1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -4894,6 +4977,8 @@ dependencies = [ name = "state-server" version = "1.1.0" dependencies = [ + "build-info", + "built", "clap", "eth-block-history", "eth-state-fold", diff --git a/offchain/Cargo.toml b/offchain/Cargo.toml index 64b92891c..eb22b5d69 100644 --- a/offchain/Cargo.toml +++ b/offchain/Cargo.toml @@ -2,6 +2,7 @@ members = [ "advance-runner", "authority-claimer", + "build-info", "contracts", "data", "dispatcher", @@ -36,6 +37,7 @@ awc = "3.1" axum = "0.6" backoff = "0.4" base64 = "0.21" +built = "0.6" byteorder = "1.4" clap = "4.3" diesel = "2.1" @@ -90,3 +92,7 @@ url = "2" urlencoding = "2.1" users = "0.11" uuid = "1.4" + +[workspace.build-dependencies] +built = "0.6" + diff --git a/offchain/advance-runner/Cargo.toml b/offchain/advance-runner/Cargo.toml index f1c7d7d28..36bcaf52c 100644 --- a/offchain/advance-runner/Cargo.toml +++ b/offchain/advance-runner/Cargo.toml @@ -3,12 +3,14 @@ name = "advance-runner" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-advance-runner" path = "src/main.rs" [dependencies] +build-info = { path = "../build-info" } contracts = { path = "../contracts" } grpc-interfaces = { path = "../grpc-interfaces" } http-health-check = { path = "../http-health-check" } @@ -37,3 +39,6 @@ rand.workspace = true tempfile.workspace = true test-log = { workspace = true, features = ["trace"] } testcontainers.workspace = true + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/advance-runner/src/main.rs b/offchain/advance-runner/src/main.rs index 062a5a295..cff6299a1 100644 --- a/offchain/advance-runner/src/main.rs +++ b/offchain/advance-runner/src/main.rs @@ -4,6 +4,10 @@ use advance_runner::config::AdvanceRunnerConfig; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[tokio::main] async fn main() -> Result<(), Box> { let config = AdvanceRunnerConfig::parse()?; @@ -11,5 +15,13 @@ async fn main() -> Result<(), Box> { log::configure(&config.log_config); info!(?config, "Starting Advance Runner"); + + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + advance_runner::run(config).await.map_err(|e| e.into()) } diff --git a/offchain/authority-claimer/Cargo.toml b/offchain/authority-claimer/Cargo.toml index 873fb224d..20defa16c 100644 --- a/offchain/authority-claimer/Cargo.toml +++ b/offchain/authority-claimer/Cargo.toml @@ -3,6 +3,8 @@ name = "authority-claimer" edition.workspace = true license.workspace = true version.workspace = true +build = "src/built/build.rs" + [[bin]] name = "cartesi-rollups-authority-claimer" @@ -10,6 +12,7 @@ path = "src/main.rs" test = false [dependencies] +build-info = { path = "../build-info" } http-server = { path = "../http-server" } log = { path = "../log" } rollups-events = { path = "../rollups-events" } @@ -25,3 +28,7 @@ snafu.workspace = true tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tracing-subscriber = { workspace = true, features = ["env-filter"] } tracing.workspace = true + + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/authority-claimer/src/built/build.rs b/offchain/authority-claimer/src/built/build.rs new file mode 100644 index 000000000..c8a3a44b7 --- /dev/null +++ b/offchain/authority-claimer/src/built/build.rs @@ -0,0 +1,5 @@ +use built; + +pub(crate) fn main() { + built::write_built_file().expect("Failed to acquire build-time information"); +} \ No newline at end of file diff --git a/offchain/authority-claimer/src/main.rs b/offchain/authority-claimer/src/main.rs index f08f7cd75..9752d6a19 100644 --- a/offchain/authority-claimer/src/main.rs +++ b/offchain/authority-claimer/src/main.rs @@ -5,6 +5,10 @@ use authority_claimer::config::Config; use std::error::Error; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[tokio::main] async fn main() -> Result<(), Box> { // Getting the configuration. @@ -15,5 +19,12 @@ async fn main() -> Result<(), Box> { info!(?config, "Starting Authority Claimer"); + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + authority_claimer::run(config).await } diff --git a/offchain/build-info/Cargo.toml b/offchain/build-info/Cargo.toml new file mode 100644 index 000000000..0d0340016 --- /dev/null +++ b/offchain/build-info/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "build-info" +edition.workspace = true +license.workspace = true +version.workspace = true + +[dependencies] +built = {workspace = true, features = ["chrono","git2"]} +tracing.workspace = true +tracing-subscriber = { workspace = true, features = ["env-filter"] } \ No newline at end of file diff --git a/offchain/build-info/src/build.rs b/offchain/build-info/src/build.rs new file mode 100644 index 000000000..df2e39096 --- /dev/null +++ b/offchain/build-info/src/build.rs @@ -0,0 +1,6 @@ +use built; + +pub(crate) fn main() { + built::write_built_file() + .expect("Failed to acquire build-time information"); +} diff --git a/offchain/build-info/src/lib.rs b/offchain/build-info/src/lib.rs new file mode 100644 index 000000000..dd3e916d9 --- /dev/null +++ b/offchain/build-info/src/lib.rs @@ -0,0 +1,19 @@ +use tracing::info; + +pub fn log_build_info( + version: &str, + build_time: &str, + git_head_ref: Option<&str>, + git_commit_hash: Option<&str>, +) { + info!("Version: {}", version); + info!("Build time: {}", build_time); + match git_head_ref { + Some(v) => info!("Git ref: {}", v), + None => (), + } + match git_commit_hash { + Some(v) => info!("Git hash: {}", v), + None => (), + } +} diff --git a/offchain/dispatcher/Cargo.toml b/offchain/dispatcher/Cargo.toml index 0145a57c5..18dc445e3 100644 --- a/offchain/dispatcher/Cargo.toml +++ b/offchain/dispatcher/Cargo.toml @@ -3,12 +3,14 @@ name = "dispatcher" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-dispatcher" path = "src/main.rs" [dependencies] +build-info = { path = "../build-info" } contracts = { path = "../contracts" } http-server = { path = "../http-server" } log = { path = "../log" } @@ -18,6 +20,7 @@ types = { path = "../types" } async-trait.workspace = true axum.workspace = true backoff = { workspace = true, features = ["tokio"] } +built = { workspace = true, features = ["chrono","git2"] } clap = { workspace = true, features = ["derive", "env"] } eth-state-client-lib.workspace = true eth-state-fold-types = { workspace = true, features = ["ethers"] } @@ -47,3 +50,6 @@ redis.workspace = true serial_test.workspace = true testcontainers.workspace = true tracing-test = { workspace = true, features = ["no-env-filter"] } + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/dispatcher/src/built/build.rs b/offchain/dispatcher/src/built/build.rs new file mode 100644 index 000000000..c8a3a44b7 --- /dev/null +++ b/offchain/dispatcher/src/built/build.rs @@ -0,0 +1,5 @@ +use built; + +pub(crate) fn main() { + built::write_built_file().expect("Failed to acquire build-time information"); +} \ No newline at end of file diff --git a/offchain/dispatcher/src/main.rs b/offchain/dispatcher/src/main.rs index dae55bf57..0da23eafb 100644 --- a/offchain/dispatcher/src/main.rs +++ b/offchain/dispatcher/src/main.rs @@ -4,6 +4,10 @@ use log; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + // NOTE: doesn't support History upgradability. // NOTE: doesn't support changing epoch_duration in the middle of things. #[tokio::main] @@ -13,5 +17,13 @@ async fn main() -> Result<(), Box> { log::configure(&config.dispatcher_config.log_config); info!(?config, "Starting Dispatcher"); + + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + dispatcher::run(config).await.map_err(|e| e.into()) } diff --git a/offchain/graphql-server/Cargo.toml b/offchain/graphql-server/Cargo.toml index ef6e3d3d3..ecfe103d4 100644 --- a/offchain/graphql-server/Cargo.toml +++ b/offchain/graphql-server/Cargo.toml @@ -3,6 +3,7 @@ name = "graphql-server" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-graphql-server" @@ -13,12 +14,14 @@ name = "generate-schema" path = "src/schema/generate_schema.rs" [dependencies] +build-info = { path = "../build-info" } http-health-check = { path = "../http-health-check" } log = { path = "../log" } rollups-data = { path = "../data" } actix-cors.workspace = true actix-web.workspace = true +built = { workspace = true, features = ["chrono","git2"] } clap = { workspace = true, features = ["derive", "env"] } hex.workspace = true juniper.workspace = true @@ -35,3 +38,6 @@ test-fixtures = { path = "../test-fixtures" } awc.workspace = true serial_test.workspace = true testcontainers.workspace = true + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/graphql-server/src/main.rs b/offchain/graphql-server/src/main.rs index ff7df3c6e..8b13aea4b 100644 --- a/offchain/graphql-server/src/main.rs +++ b/offchain/graphql-server/src/main.rs @@ -7,6 +7,10 @@ use graphql_server::{CLIConfig, GraphQLConfig}; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[actix_web::main] async fn main() -> Result<(), Box> { let config: GraphQLConfig = CLIConfig::parse().into(); @@ -14,5 +18,13 @@ async fn main() -> Result<(), Box> { log::configure(&config.log_config); info!(?config, "Starting GraphQL Server"); + + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + graphql_server::run(config).await.map_err(|e| e.into()) } diff --git a/offchain/host-runner/Cargo.toml b/offchain/host-runner/Cargo.toml index 2f712b578..bb4ab7ce1 100644 --- a/offchain/host-runner/Cargo.toml +++ b/offchain/host-runner/Cargo.toml @@ -3,12 +3,14 @@ name = "host-runner" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-host-runner" path = "src/main.rs" [dependencies] +build-info = { path = "../build-info" } grpc-interfaces = { path = "../grpc-interfaces" } http-health-check = { path = "../http-health-check" } log = { path = "../log" } @@ -37,3 +39,6 @@ mockall.workspace = true rand.workspace = true serial_test.workspace = true tracing-test.workspace = true + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/host-runner/src/main.rs b/offchain/host-runner/src/main.rs index 60d009dd1..362bac778 100644 --- a/offchain/host-runner/src/main.rs +++ b/offchain/host-runner/src/main.rs @@ -22,6 +22,10 @@ use clap::Parser; use config::{CLIConfig, Config}; use controller::Controller; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + fn log_result(name: &str, result: Result) { let prefix = format!("http {} terminated ", name); match result { @@ -38,6 +42,13 @@ async fn main() { info!(?config, "Starting Host Runner"); + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + let controller = Controller::new(Duration::from_millis(config.finish_timeout)); let http_service_running = Arc::new(AtomicBool::new(true)); diff --git a/offchain/indexer/Cargo.toml b/offchain/indexer/Cargo.toml index 24e5c7ec3..581fce127 100644 --- a/offchain/indexer/Cargo.toml +++ b/offchain/indexer/Cargo.toml @@ -3,6 +3,7 @@ name = "indexer" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-indexer" @@ -10,11 +11,13 @@ path = "src/main.rs" test = false [dependencies] +build-info = { path = "../build-info" } http-health-check = { path = "../http-health-check" } log = { path = "../log" } rollups-data = { path = "../data" } rollups-events = { path = "../rollups-events" } +built = { workspace = true, features = ["chrono","git2"] } clap = { workspace = true, features = ["derive", "env"] } snafu.workspace = true tokio = { workspace = true, features = ["macros", "time", "rt-multi-thread"] } @@ -30,3 +33,6 @@ rand.workspace = true serial_test.workspace = true test-log = { workspace = true, features = ["trace"] } testcontainers.workspace = true + +[build-dependencies] +built = { workspace = true, features = ["chrono","git2"] } diff --git a/offchain/indexer/src/main.rs b/offchain/indexer/src/main.rs index 5ff76a735..5f26bdaa4 100644 --- a/offchain/indexer/src/main.rs +++ b/offchain/indexer/src/main.rs @@ -7,6 +7,10 @@ use indexer::{CLIConfig, IndexerConfig}; use log; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[tokio::main] async fn main() -> Result<(), Box> { let config: IndexerConfig = CLIConfig::parse().into(); @@ -14,5 +18,13 @@ async fn main() -> Result<(), Box> { log::configure(&config.log_config); info!(?config, "Starting Indexer"); + + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + indexer::run(config).await.map_err(|e| e.into()) } diff --git a/offchain/inspect-server/Cargo.toml b/offchain/inspect-server/Cargo.toml index f7ad7e74f..f6f7edabd 100644 --- a/offchain/inspect-server/Cargo.toml +++ b/offchain/inspect-server/Cargo.toml @@ -9,11 +9,13 @@ name = "cartesi-rollups-inspect-server" path = "src/main.rs" [dependencies] +build-info = { path = "../build-info" } http-health-check = { path = "../http-health-check" } log = { path = "../log" } actix-cors.workspace = true actix-web.workspace = true +built = { workspace = true, features = ["chrono","git2"] } clap = { workspace = true, features = ["derive", "env"] } hex.workspace = true prost.workspace = true @@ -33,6 +35,7 @@ reqwest = { workspace = true, features = ["json"] } serial_test.workspace = true [build-dependencies] +built = { workspace = true, features = ["chrono","git2"] } tonic-build.workspace = true [package.metadata.cargo-machete] diff --git a/offchain/inspect-server/build.rs b/offchain/inspect-server/build.rs index d814ddab2..a3d1b3e3d 100644 --- a/offchain/inspect-server/build.rs +++ b/offchain/inspect-server/build.rs @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 (see LICENSE) fn main() -> Result<(), Box> { + built::write_built_file() + .expect("Failed to acquire build-time information"); + tonic_build::configure() .protoc_arg("--experimental_allow_proto3_optional") .compile( diff --git a/offchain/inspect-server/src/main.rs b/offchain/inspect-server/src/main.rs index 65fadbf81..1e57f460a 100644 --- a/offchain/inspect-server/src/main.rs +++ b/offchain/inspect-server/src/main.rs @@ -6,6 +6,10 @@ use clap::Parser; use inspect_server::{config::CLIConfig, InspectServerConfig}; use tracing::info; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[tokio::main] async fn main() -> Result<(), Box> { let config: InspectServerConfig = CLIConfig::parse().into(); @@ -14,5 +18,12 @@ async fn main() -> Result<(), Box> { info!(?config, "Starting Inspect Server"); + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + inspect_server::run(config).await.map_err(|e| e.into()) } diff --git a/offchain/state-server/Cargo.toml b/offchain/state-server/Cargo.toml index 47b373b96..529324e90 100644 --- a/offchain/state-server/Cargo.toml +++ b/offchain/state-server/Cargo.toml @@ -3,15 +3,18 @@ name = "state-server" edition.workspace = true license.workspace = true version.workspace = true +build = "../build-info/src/build.rs" [[bin]] name = "cartesi-rollups-state-server" path = "src/main.rs" [dependencies] +build-info = { path = "../build-info" } log = { path = "../log" } types = { path = "../types" } +built = {workspace = true, features = ["chrono","git2"]} clap = { workspace = true, features = ["derive", "env"] } eth-block-history.workspace = true eth-state-fold-types.workspace = true @@ -24,3 +27,6 @@ tonic.workspace = true tracing-subscriber = { workspace = true, features = ["env-filter"] } tracing.workspace = true url.workspace = true + +[build-dependencies] +built = {workspace = true, features = ["chrono","git2"]} diff --git a/offchain/state-server/src/main.rs b/offchain/state-server/src/main.rs index 3f13118a8..95dca9d33 100644 --- a/offchain/state-server/src/main.rs +++ b/offchain/state-server/src/main.rs @@ -4,6 +4,10 @@ mod config; use config::Config; use types::foldables::authority::rollups::RollupsState; +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + #[tokio::main] async fn main() -> Result<(), Box> { let config: Config = Config::initialize_from_args()?; @@ -12,6 +16,13 @@ async fn main() -> Result<(), Box> { tracing::info!(?config, "Starting State Server"); + build_info::log_build_info( + built_info::PKG_VERSION, + built_info::BUILT_TIME_UTC, + built_info::GIT_HEAD_REF, + built_info::GIT_COMMIT_HASH, + ); + state_server::run_server::(config.state_server_config) .await .map_err(|e| e.into())