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 21, 2023
1 parent c7959f1 commit af6473e
Show file tree
Hide file tree
Showing 25 changed files with 223 additions and 3 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.git
**/target/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support to `POST` *inspect state* requests
- Added snapshot validation. The node will now check whether the snapshot's template hash matches the one stored in the blockchain
- Added `cartesi/rollups-node` docker image with all node binaries
- Added versioning logs to all services

### Changed

Expand Down
1 change: 1 addition & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN cargo chef cook --release --recipe-path recipe.json

# Build application
COPY ./offchain/ .
COPY ./.git ../
RUN cargo build --release

#
Expand Down
69 changes: 69 additions & 0 deletions offchain/Cargo.lock

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

3 changes: 1 addition & 2 deletions offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 @@ -91,5 +92,3 @@ urlencoding = "2.1"
users = "0.11"
uuid = "1.4"

[profile.release]
strip = true # Automatically strip symbols from the binary.
4 changes: 4 additions & 0 deletions offchain/advance-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "advance-runner"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "../log/src/build.rs"

[[bin]]
name = "cartesi-rollups-advance-runner"
Expand Down Expand Up @@ -37,3 +38,6 @@ tempfile.workspace = true
test-log = { workspace = true, features = ["trace"] }
testcontainers.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[build-dependencies]
built = { workspace = true, features = ["git2"] }
11 changes: 11 additions & 0 deletions offchain/advance-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
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");

log::log_build_info(
built_info::PKG_VERSION,
built_info::GIT_HEAD_REF,
built_info::GIT_COMMIT_HASH,
);

advance_runner::run(config).await.map_err(|e| e.into())
}
6 changes: 6 additions & 0 deletions offchain/authority-claimer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name = "authority-claimer"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "../log/src/build.rs"


[[bin]]
name = "cartesi-rollups-authority-claimer"
Expand All @@ -23,3 +25,7 @@ serde_json.workspace = true
snafu.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing.workspace = true


[build-dependencies]
built = { workspace = true, features = ["git2"] }
10 changes: 10 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,11 @@ async fn main() -> Result<(), Box<dyn Error>> {

info!(?config, "Starting Authority Claimer");

log::log_build_info(
built_info::PKG_VERSION,
built_info::GIT_HEAD_REF,
built_info::GIT_COMMIT_HASH,
);

authority_claimer::run(config).await
}
4 changes: 4 additions & 0 deletions offchain/dispatcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "dispatcher"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "../log/src/build.rs"

[[bin]]
name = "cartesi-rollups-dispatcher"
Expand Down Expand Up @@ -46,3 +47,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 = ["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");
}
11 changes: 11 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,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::configure(&config.dispatcher_config.log_config);

info!(?config, "Starting Dispatcher");

log::log_build_info(
built_info::PKG_VERSION,
built_info::GIT_HEAD_REF,
built_info::GIT_COMMIT_HASH,
);

dispatcher::run(config).await.map_err(|e| e.into())
}
4 changes: 4 additions & 0 deletions offchain/graphql-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "graphql-server"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "../log/src/build.rs"

[[bin]]
name = "cartesi-rollups-graphql-server"
Expand Down Expand Up @@ -34,3 +35,6 @@ test-fixtures = { path = "../test-fixtures" }
awc.workspace = true
serial_test.workspace = true
testcontainers.workspace = true

[build-dependencies]
built = { workspace = true, features = ["git2"] }
11 changes: 11 additions & 0 deletions offchain/graphql-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ 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<dyn std::error::Error>> {
let config: GraphQLConfig = CLIConfig::parse().into();

log::configure(&config.log_config);

info!(?config, "Starting GraphQL Server");

log::log_build_info(
built_info::PKG_VERSION,
built_info::GIT_HEAD_REF,
built_info::GIT_COMMIT_HASH,
);

graphql_server::run(config).await.map_err(|e| e.into())
}
4 changes: 4 additions & 0 deletions offchain/host-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "host-runner"
edition.workspace = true
license.workspace = true
version.workspace = true
build = "../log/src/build.rs"

[[bin]]
name = "cartesi-rollups-host-runner"
Expand Down Expand Up @@ -36,3 +37,6 @@ mockall.workspace = true
rand.workspace = true
serial_test.workspace = true
tracing-test.workspace = true

[build-dependencies]
built = { workspace = true, features = ["git2"] }
10 changes: 10 additions & 0 deletions offchain/host-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, E: std::error::Error>(name: &str, result: Result<T, E>) {
let prefix = format!("http {} terminated ", name);
match result {
Expand All @@ -38,6 +42,12 @@ async fn main() {

info!(?config, "Starting Host Runner");

log::log_build_info(
built_info::PKG_VERSION,
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));
Expand Down
Loading

0 comments on commit af6473e

Please sign in to comment.