Skip to content

Commit

Permalink
feat: Add version log
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Sep 14, 2023
1 parent 5e077a9 commit 152cb11
Show file tree
Hide file tree
Showing 25 changed files with 275 additions and 1 deletion.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.git
**/target/
85 changes: 85 additions & 0 deletions offchain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"advance-runner",
"authority-claimer",
"build-info",
"contracts",
"data",
"dispatcher",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -90,3 +92,7 @@ url = "2"
urlencoding = "2.1"
users = "0.11"
uuid = "1.4"

[workspace.build-dependencies]
built = "0.6"

5 changes: 5 additions & 0 deletions offchain/advance-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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"]}
12 changes: 12 additions & 0 deletions offchain/advance-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
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<dyn std::error::Error>> {
let config = AdvanceRunnerConfig::parse()?;

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())
}
7 changes: 7 additions & 0 deletions offchain/authority-claimer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ name = "authority-claimer"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "src/built/build.rs"


[[bin]]
name = "cartesi-rollups-authority-claimer"
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" }
Expand All @@ -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"]}
5 changes: 5 additions & 0 deletions offchain/authority-claimer/src/built/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use built;

pub(crate) fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
11 changes: 11 additions & 0 deletions offchain/authority-claimer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
// Getting the configuration.
Expand All @@ -15,5 +19,12 @@ async fn main() -> Result<(), Box<dyn Error>> {

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
}
10 changes: 10 additions & 0 deletions offchain/build-info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
6 changes: 6 additions & 0 deletions offchain/build-info/src/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use built;

pub(crate) fn main() {
built::write_built_file()
.expect("Failed to acquire build-time information");
}
19 changes: 19 additions & 0 deletions offchain/build-info/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 => (),
}
}
6 changes: 6 additions & 0 deletions offchain/dispatcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"] }
Expand Down Expand Up @@ -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"]}
5 changes: 5 additions & 0 deletions offchain/dispatcher/src/built/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use built;

pub(crate) fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
12 changes: 12 additions & 0 deletions offchain/dispatcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -13,5 +17,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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())
}
Loading

0 comments on commit 152cb11

Please sign in to comment.