Skip to content

Commit

Permalink
feat: P-888 added ws api to return the worker version
Browse files Browse the repository at this point in the history
  • Loading branch information
higherordertech committed Jan 10, 2025
1 parent 2139358 commit 24973e2
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 166 deletions.
6 changes: 3 additions & 3 deletions parachain/ts-tests/common/utils/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const input = {
'*': ['*'],
},
},
evmVersion: "london",
evmVersion: 'london',
optimizer: {
enabled: true,
runs: 200
}
runs: 200,
},
},
};
const result = JSON.parse(solcWrapper.compile(JSON.stringify(input)));
Expand Down
37 changes: 9 additions & 28 deletions tee-worker/Cargo.lock

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

2 changes: 2 additions & 0 deletions tee-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"common/core/parentchain/test",
"common/core/rest-client",
"common/core/rpc-client",
"common/core/system-version",
"common/core/tls-websocket-server",

# identity-worker
Expand Down Expand Up @@ -220,6 +221,7 @@ itc-parentchain-test = { path = "common/core/parentchain/test", default-features
itc-rest-client = { path = "common/core/rest-client", default-features = false }
itc-rpc-client = { path = "common/core/rpc-client" }
itc-tls-websocket-server = { path = "common/core/tls-websocket-server", default-features = false }
itc-system-version = { path = "common/core/system-version", default-features = false }

itp-attestation-handler = { path = "common/core-primitives/attestation-handler", default-features = false }
itp-import-queue = { path = "common/core-primitives/import-queue", default-features = false }
Expand Down
57 changes: 0 additions & 57 deletions tee-worker/bitacross/cli/src/base_cli/commands/worker_version.rs

This file was deleted.

20 changes: 20 additions & 0 deletions tee-worker/common/core/system-version/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "itc-system-version"
version = "0.1.0"
authors = ['Trust Computing GmbH <[email protected]>', 'Integritee AG <[email protected]>']
build = 'build.rs'
edition = "2021"

[dependencies]
# sgx dependencies
sgx_tstd = { workspace = true, optional = true }

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

[features]
default = ["std"]
std = []
sgx = [
"sgx_tstd",
]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,27 @@
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use std::process::Command;

fn main() {
// generate build-time information
// Generate build-time information
built::write_built_file().expect("Failed to acquire build-time information");

// Example value: ce3abe05a53fcdf103af58b46b3974cb24309543
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
if output.status.success() {
if let Ok(hash) = String::from_utf8(output.stdout) {
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", hash.trim());
}
}
}

// Example value: v0.9.20-07-51-gce3abe05
if let Ok(output) = Command::new("git").args(["describe", "--tags", "--long"]).output() {
if output.status.success() {
if let Ok(version) = String::from_utf8(output.stdout) {
println!("cargo:rustc-env=GIT_VERSION={}", version.trim());
}
}
}
}
65 changes: 65 additions & 0 deletions tee-worker/common/core/system-version/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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/>.

#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(all(feature = "std", feature = "sgx"))]
compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time");

#[cfg(all(not(feature = "std"), feature = "sgx"))]
extern crate sgx_tstd as std;

use std::{format, println, string::String};

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

const DEFAULT_VALUE: &str = "unknown";

pub fn print_system_version() {
println!(
r#"Version Information:
------------------
Target: {}
Rustc version: {}
Git Information:
--------------
Version: {}
Commit Hash: {}
Build Time:
---------
{}"#,
built_info::TARGET,
built_info::RUSTC_VERSION,
option_env!("GIT_VERSION").unwrap_or(DEFAULT_VALUE),
option_env!("GIT_COMMIT_HASH").unwrap_or(DEFAULT_VALUE),
built_info::BUILT_TIME_UTC,
)
}

pub fn get_system_version() -> String {
format!(
r#"{{"target":"{}","rustc_version":"{}","git_version":"{}","git_commit_hash":"{}","build_time":"{}"}}"#,
built_info::TARGET,
built_info::RUSTC_VERSION,
option_env!("GIT_VERSION").unwrap_or(DEFAULT_VALUE),
option_env!("GIT_COMMIT_HASH").unwrap_or(DEFAULT_VALUE),
built_info::BUILT_TIME_UTC
)
}
5 changes: 1 addition & 4 deletions tee-worker/identity/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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 @@ -40,6 +39,7 @@ ita-parentchain-interface = { package = "id-ita-parentchain-interface", path = "
ita-sgx-runtime = { package = "id-ita-sgx-runtime", path = "../app-libs/sgx-runtime" }
ita-stf = { package = "id-ita-stf", path = "../app-libs/stf" }
itc-rpc-client = { workspace = true }
itc-system-version = { workspace = true, features = ["std"] }
itp-node-api = { workspace = true, features = ["std"] }
itp-rpc = { workspace = true, features = ["std"] }
itp-sgx-crypto = { workspace = true, features = ["std"] }
Expand All @@ -52,9 +52,6 @@ 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
2 changes: 1 addition & 1 deletion tee-worker/identity/cli/src/base_cli/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pub mod faucet;
pub mod listen;
pub mod litentry;
pub mod register_tcb_info;
pub mod system_version;
pub mod transfer;
pub mod worker_version;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
// 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");
use crate::{Cli, CliResult, CliResultOk};

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

impl SystemVersionCommand {
pub(crate) fn run(&self, _cli: &Cli) -> CliResult {
itc_system_version::print_system_version();
Ok(CliResultOk::Bytes { bytes: vec![] })
}
}
Loading

0 comments on commit 24973e2

Please sign in to comment.