From f2e03720bfd70ebafc6fe5a8f9048ee6630378c9 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Mon, 20 May 2024 09:20:51 +0900 Subject: [PATCH] feat: use default keys for genesis, or override Warning if we're using defaults --- .github/workflows/benchmark-prs.yml | 1 - .../workflows/generate-benchmark-charts.yml | 1 - .github/workflows/memcheck.yml | 3 ++- .github/workflows/merge.yml | 3 ++- .github/workflows/nightly.yml | 1 - .github/workflows/nightly_wan.yml | 4 ++-- .github/workflows/nightly_wan_churn.yml | 4 +--- sn_transfers/src/genesis.rs | 19 ++++++++++++++++--- 8 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/benchmark-prs.yml b/.github/workflows/benchmark-prs.yml index 084b603b73..a031ac89ba 100644 --- a/.github/workflows/benchmark-prs.yml +++ b/.github/workflows/benchmark-prs.yml @@ -7,7 +7,6 @@ env: RUST_BACKTRACE: 1 CLIENT_DATA_PATH: /home/runner/.local/share/safe/client NODE_DATA_PATH: /home/runner/.local/share/safe/node - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee jobs: benchmark-cli: diff --git a/.github/workflows/generate-benchmark-charts.yml b/.github/workflows/generate-benchmark-charts.yml index 3364e900c2..cd61f0e165 100644 --- a/.github/workflows/generate-benchmark-charts.yml +++ b/.github/workflows/generate-benchmark-charts.yml @@ -17,7 +17,6 @@ env: RUST_BACKTRACE: 1 CLIENT_DATA_PATH: /home/runner/.local/share/safe/client NODE_DATA_PATH: /home/runner/.local/share/safe/node - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee jobs: benchmark-cli: diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 4fa626316a..3cf7841bbe 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -16,7 +16,8 @@ env: BOOTSTRAP_NODE_DATA_PATH: /home/runner/.local/share/safe/bootstrap_node RESTART_TEST_NODE_DATA_PATH: /home/runner/.local/share/safe/restart_node FAUCET_LOG_PATH: /home/runner/.local/share/safe/test_faucet/logs - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee + GENESIS_PK: aa07e487122eb31021301b95f4fb2b01363653cad582a6eb8ba0cfce937e51604350d7fb8a718596411f35d399cbdf28 + GENESIS_SK: ${{ secrets.CI_TESTING_GENESIS_SK }} jobs: memory-check: diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index e400cade4d..9a5d15d9ea 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -12,7 +12,8 @@ on: env: CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI. WINSW_URL: https://github.com/winsw/winsw/releases/download/v3.0.0-alpha.11/WinSW-x64.exe - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee + GENESIS_PK: aa07e487122eb31021301b95f4fb2b01363653cad582a6eb8ba0cfce937e51604350d7fb8a718596411f35d399cbdf28 + GENESIS_SK: ${{ secrets.CI_TESTING_GENESIS_SK }} jobs: cargo-udeps: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1c09fe7f78..2e6a4976c6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,7 +8,6 @@ on: env: CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI. WORKFLOW_URL: https://github.com/maidsafe/stableset_net/actions/runs - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee jobs: e2e: diff --git a/.github/workflows/nightly_wan.yml b/.github/workflows/nightly_wan.yml index 359b996138..5c53da4cd7 100644 --- a/.github/workflows/nightly_wan.yml +++ b/.github/workflows/nightly_wan.yml @@ -8,8 +8,8 @@ on: env: CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI. WORKFLOW_URL: https://github.com/maidsafe/stableset_net/actions/runs - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee - + GENESIS_PK: aa07e487122eb31021301b95f4fb2b01363653cad582a6eb8ba0cfce937e51604350d7fb8a718596411f35d399cbdf28 + GENESIS_SK: ${{ secrets.CI_TESTING_GENESIS_SK }} jobs: e2e: name: E2E tests diff --git a/.github/workflows/nightly_wan_churn.yml b/.github/workflows/nightly_wan_churn.yml index ec33923184..185bcfb939 100644 --- a/.github/workflows/nightly_wan_churn.yml +++ b/.github/workflows/nightly_wan_churn.yml @@ -1,15 +1,13 @@ -name: Nightly -- Perform long running network churn +name: Nightly -- Perform long running network churn on: schedule: - cron: "0 */12 * * *" workflow_dispatch: - env: CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI. WORKFLOW_URL: https://github.com/maidsafe/stableset_net/actions/runs - GENESIS_PK: 9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee jobs: e2e: diff --git a/sn_transfers/src/genesis.rs b/sn_transfers/src/genesis.rs index cdeedffa78..9ced4cb88e 100644 --- a/sn_transfers/src/genesis.rs +++ b/sn_transfers/src/genesis.rs @@ -30,8 +30,9 @@ const GENESIS_DERIVATION_INDEX: DerivationIndex = DerivationIndex([0u8; 32]); /// Default genesis SK for testing purpose. Be sure to pass the correct `GENESIS_PK` value via env. const TESTING_GENESIS_SK: &str = "23746be7fa5df26c3065eb7aa26860981e435c1853cafafe472417bc94f340e9"; // DevSkim: ignore DS173237 + /// Genesis PK for live network. Be sure to pass the correct `GENESIS_SK` value via env when to use. -const LIVE_GENESIS_PK: &str = "b814bc39a357e6f6000f4946da52dcfc72e19efe91e31d4e94e9cb408d765a4a6cf3bf2df14806f8fa524bd7ebb9bb4e"; // DevSkim: ignore DS173237 +const DEFAULT_LIVE_GENESIS_PK: &str = "9934c21469a68415e6b06a435709e16bff6e92bf302aeb0ea9199d2d06a55f1b1a21e155853d3f94ae31f8f313f886ee"; // DevSkim: ignore DS173237 /// Based on the given store cost, it calculates what's the expected amount to be paid as network royalties. /// Network royalties fee is expected to be 15% of the payment amount, i.e. 85% of store cost + 15% royalties fees. @@ -66,7 +67,13 @@ lazy_static! { /// The hard coded value is for production release, allows all nodes to validate it. /// The env set value is only used for testing purpose. pub static ref GENESIS_PK: MainPubkey = { - let pk_str = std::env::var("GENESIS_PK").unwrap_or(LIVE_GENESIS_PK.to_string()); + let pk_str = if let Ok(pk_str) = std::env::var("GENESIS_PK") { + pk_str + } + else { + warn!("USING DEFAULT GENESIS PK FOR TESTING PURPOSES!"); + DEFAULT_LIVE_GENESIS_PK.to_string() + }; match MainPubkey::from_hex(pk_str) { Ok(pk) => pk, @@ -99,7 +106,13 @@ lazy_static! { /// Unlike the `GENESIS_PK`, the hard coded secret_key is for testing purpose. /// The one for live network shall be passed in via env set. static ref GENESIS_SK_STR: String = { - std::env::var("GENESIS_SK").unwrap_or(TESTING_GENESIS_SK.to_string()) + if let Ok(sk) = std::env::var("GENESIS_SK") { + sk + } + else { + warn!("USING DEFAULT GENESIS SK FOR TESTING PURPOSES!"); + TESTING_GENESIS_SK.to_string() + } }; }