Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P 888 commit hash api #3227

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
53 changes: 51 additions & 2 deletions tee-worker/Cargo.lock

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

3 changes: 3 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 @@ -133,6 +134,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 Expand Up @@ -219,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
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",
]
40 changes: 40 additions & 0 deletions tee-worker/common/core/system-version/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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 std::process::Command;

fn main() {
// 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
)
}
1 change: 1 addition & 0 deletions tee-worker/identity/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,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 Down
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 @@ -3,4 +3,5 @@ pub mod faucet;
pub mod listen;
pub mod litentry;
pub mod register_tcb_info;
pub mod system_version;
pub mod transfer;
30 changes: 30 additions & 0 deletions tee-worker/identity/cli/src/base_cli/commands/system_version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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};

// Display 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![] })
}
}
7 changes: 6 additions & 1 deletion tee-worker/identity/cli/src/base_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use crate::{
base_cli::commands::{
balance::BalanceCommand, faucet::FaucetCommand, listen::ListenCommand, litentry::*,
register_tcb_info::RegisterTcbInfoCommand, transfer::TransferCommand,
register_tcb_info::RegisterTcbInfoCommand, system_version::SystemVersionCommand,
transfer::TransferCommand,
},
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),

/// System version
SystemVersion(SystemVersionCommand),

// 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::SystemVersion(cmd) => cmd.run(cli),
// Litentry's commands below
BaseCommand::PrintSgxMetadataRaw => print_sgx_metadata_raw(cli),
BaseCommand::LinkIdentity(cmd) => cmd.run(cli),
Expand Down
Loading
Loading