Skip to content

Commit

Permalink
feat: use default keys for genesis, or override
Browse files Browse the repository at this point in the history
Warning if we're using defaults
  • Loading branch information
joshuef authored and RolandSherwin committed May 21, 2024
1 parent 3f89f68 commit f2e0372
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/benchmark-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/generate-benchmark-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly_wan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/nightly_wan_churn.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
19 changes: 16 additions & 3 deletions sn_transfers/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
}
};
}

Expand Down

0 comments on commit f2e0372

Please sign in to comment.