Skip to content

Commit

Permalink
feat: P-888 add cli to print the worker version
Browse files Browse the repository at this point in the history
  • Loading branch information
higherordertech committed Jan 10, 2025
1 parent f82e400 commit 2139358
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 2 deletions.
72 changes: 70 additions & 2 deletions tee-worker/Cargo.lock

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

1 change: 1 addition & 0 deletions tee-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ yasna = { version = "0.4" }
musig2 = { git = "https://github.com/kziemianek/musig2", branch = "master", features = ["k256"] }
rlp = { version = "0.5", default-features = false }
sha3 = { version = "0.10", default-features = false }
built = { version = "0.6.1", default-features = false }

url = { git = "https://github.com/domenukk/rust-url", rev = "316c868", default-features = false, features = ["alloc", "no_std_net"] }
substrate-api-client = { git = "https://github.com/Kailai-Wang/substrate-api-client", branch = "polkadot-v0.9.42-litentry", default-features = false, features = ["sync-api"] }
Expand Down
20 changes: 20 additions & 0 deletions tee-worker/bitacross/cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

fn main() {
// generate build-time information
built::write_built_file().expect("Failed to acquire build-time information");
}
57 changes: 57 additions & 0 deletions tee-worker/bitacross/cli/src/base_cli/commands/worker_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use crate::{Cli, CliResult, CliResultOk};

mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

// Dispnay the current worker version detail
// usage example:
// ./litentry-cli worker-version
#[derive(Parser)]
pub struct WorkerVersionCommand {}

impl WorkerVersionCommand {
pub(crate) fn run(&self, _: &Cli) -> CliResult {
println!(
r#"
Version Information:
------------------
Package version: {}
Target: {}
Rustc version: {}
Git Information:
--------------
Version: {}
Commit Hash: {}
Build Time:
---------
{}
"#,
built_info::PKG_VERSION,
built_info::TARGET,
built_info::RUSTC_VERSION,
built_info::GIT_VERSION.unwrap_or("unknown"),
built_info::GIT_COMMIT_HASH.unwrap_or("unknown"),
built::util::strptime(built_info::BUILT_TIME_UTC),
);
Ok(CliResultOk::Bytes { bytes: () })
}
}
4 changes: 4 additions & 0 deletions tee-worker/identity/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
array-bytes = { version = "6.0.0" }
base58 = { workspace = true }
built = { workspace = true, features = ["git2", "chrono", "semver"] }
chrono = "*"
clap = { version = "=4.1.0", features = ["derive"] }
codec = { package = "parity-scale-codec", workspace = true, features = ["std"] }
Expand Down Expand Up @@ -51,6 +52,9 @@ litentry-hex-utils = { workspace = true }
litentry-primitives = { workspace = true, features = ["std"] }
scale-value = "0.6.0"

[build-dependencies]
built = { workspace = true, features = ["git2", "chrono", "semver"] }

[features]
default = []
evm = ["ita-stf/evm", "pallet-evm"]
Expand Down
20 changes: 20 additions & 0 deletions tee-worker/identity/cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

fn main() {
// generate build-time information
built::write_built_file().expect("Failed to acquire build-time information");
}
1 change: 1 addition & 0 deletions tee-worker/identity/cli/src/base_cli/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pub mod listen;
pub mod litentry;
pub mod register_tcb_info;
pub mod transfer;
pub mod worker_version;
57 changes: 57 additions & 0 deletions tee-worker/identity/cli/src/base_cli/commands/worker_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use crate::{Cli, CliResult, CliResultOk};

mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

// Dispnay the current worker version detail
// usage example:
// ./litentry-cli worker-version
#[derive(Parser)]
pub struct WorkerVersionCommand {}

impl WorkerVersionCommand {
pub(crate) fn run(&self, cli: &Cli) -> CliResult {
println!(
r#"
Version Information:
------------------
Package version: {}
Target: {}
Rustc version: {}
Git Information:
--------------
Version: {}
Commit Hash: {}
Build Time:
---------
{}
"#,
built_info::PKG_VERSION,
built_info::TARGET,
built_info::RUSTC_VERSION,
built_info::GIT_VERSION.unwrap_or("unknown"),
built_info::GIT_COMMIT_HASH.unwrap_or("unknown"),
built::util::strptime(built_info::BUILT_TIME_UTC),
);
Ok(CliResultOk::Bytes { bytes: () })
}
}
5 changes: 5 additions & 0 deletions tee-worker/identity/cli/src/base_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
base_cli::commands::{
balance::BalanceCommand, faucet::FaucetCommand, listen::ListenCommand, litentry::*,
register_tcb_info::RegisterTcbInfoCommand, transfer::TransferCommand,
worker_version::WorkerVersionCommand,
},
command_utils::*,
Cli, CliResult, CliResultOk, ED25519_KEY_TYPE, SR25519_KEY_TYPE,
Expand Down Expand Up @@ -71,6 +72,9 @@ pub enum BaseCommand {
/// Register TCB info for FMSPC
RegisterTcbInfo(RegisterTcbInfoCommand),

/// Worker version
WorkerVersion(WorkerVersionCommand),

// Litentry's commands below
/// query sgx-runtime metadata and print the raw (hex-encoded) metadata to stdout
/// we could have added a parameter like `--raw` to `PrintSgxMetadata`, but
Expand Down Expand Up @@ -106,6 +110,7 @@ impl BaseCommand {
BaseCommand::ListWorkers => list_workers(cli),
BaseCommand::Listen(cmd) => cmd.run(cli),
BaseCommand::RegisterTcbInfo(cmd) => cmd.run(cli),
BaseCommand::WorkerVersion(cmd) => cmd.run(cli),
// Litentry's commands below
BaseCommand::PrintSgxMetadataRaw => print_sgx_metadata_raw(cli),
BaseCommand::LinkIdentity(cmd) => cmd.run(cli),
Expand Down

0 comments on commit 2139358

Please sign in to comment.