Skip to content

Create command line arguments to set genesis staking keys, VRF keys, and pool Id #1092

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

Merged
merged 26 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9091f81
Allow test framework to not exit on success
alfiedotwtf Jul 28, 2023
b869720
Add Genesis staking settings parsing
alfiedotwtf Jul 28, 2023
2d56a2f
Add tets for genesis staking settings
alfiedotwtf Jul 28, 2023
67e4dbe
Remove regex for command-line parsing
alfiedotwtf Jul 31, 2023
1cff1dd
Add a type for genesis staking settings to be used by Clap
alfiedotwtf Jul 31, 2023
fd3a688
Adding further explaination for the two main() calls
alfiedotwtf Jul 31, 2023
a1bfb3f
Fix do_checks
alfiedotwtf Jul 31, 2023
c7b51c9
Moved RegTest-specific code into its own file
alfiedotwtf Aug 1, 2023
1d0e413
Lifted more handling of genesis settings to the type
alfiedotwtf Aug 1, 2023
5c992dc
Better Genesis staking settings error handling
alfiedotwtf Aug 2, 2023
4dd0e6b
Make default values idiomatic
alfiedotwtf Aug 2, 2023
068452c
Fix broken round tripping of default clap custom variables
alfiedotwtf Aug 2, 2023
9af4cd4
Remove "genesis_" prefix and more default() fixes
alfiedotwtf Aug 2, 2023
f83b607
Moving into constants
alfiedotwtf Aug 2, 2023
84175e0
Fix typo
alfiedotwtf Aug 2, 2023
2ca3b32
Adding unit tests for GenesisStakingSettings
alfiedotwtf Aug 2, 2023
076562f
Fix panicking decoding errors
alfiedotwtf Aug 2, 2023
f7f7cc6
Fix for rebase
alfiedotwtf Aug 2, 2023
12b089b
Make large coin values readable
alfiedotwtf Aug 3, 2023
72c85ff
Don't return a clone
alfiedotwtf Aug 3, 2023
d24809e
Error when staking settings are missing a value
alfiedotwtf Aug 3, 2023
7597247
Error when settings are not unique
alfiedotwtf Aug 3, 2023
4e74444
Removing regex dependency
alfiedotwtf Aug 3, 2023
65bfe3a
Gate regtest configuration options to only the regtest network
alfiedotwtf Aug 3, 2023
5e548d8
Factor out reusable names
alfiedotwtf Aug 4, 2023
ea952eb
Fix keyboard mash
alfiedotwtf Aug 4, 2023
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
30 changes: 15 additions & 15 deletions Cargo.lock

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

71 changes: 2 additions & 69 deletions common/src/chain/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
mod builder;
mod checkpoints;
pub mod emission_schedule;
pub mod regtest;
pub use builder::Builder;
use crypto::key::PublicKey;
use crypto::vrf::VRFPublicKey;
Expand All @@ -28,14 +29,13 @@ use crate::chain::block::timestamp::BlockTimestamp;
use crate::chain::transaction::Destination;
use crate::chain::upgrades::NetUpgrades;
use crate::chain::TxOutput;
use crate::chain::{GenBlock, Genesis, PoolId};
use crate::chain::{GenBlock, Genesis};
use crate::chain::{PoWChainConfig, UpgradeVersion};
use crate::primitives::id::{Id, Idable, WithId};
use crate::primitives::per_thousand::PerThousand;
use crate::primitives::semver::SemVer;
use crate::primitives::{Amount, BlockDistance, BlockHeight, H256};
use crypto::key::hdkd::{child_number::ChildNumber, u31::U31};
use crypto::{key::PrivateKey, vrf::VRFPrivateKey};
use std::num::NonZeroU64;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -597,73 +597,6 @@ fn create_testnet_genesis() -> Genesis {
)
}

pub fn regtest_genesis_values() -> (
PoolId,
Box<StakePoolData>,
PrivateKey,
PublicKey,
VRFPrivateKey,
VRFPublicKey,
) {
let genesis_pool_id =
decode_hex::<PoolId>("123c4c600097c513e088b9be62069f0c74c7671c523c8e3469a1c3f14b7ea2c4");

let genesis_stake_private_key = decode_hex::<PrivateKey>(
"008717e6946febd3a33ccdc3f3a27629ec80c33461c33a0fc56b4836fcedd26638",
);

let genesis_stake_public_key = decode_hex::<PublicKey>(
"0003c53526caf73cd990148e127cb57249a5e266d78df23968642c976a532197fdaa",
);

let genesis_vrf_private_key = decode_hex::<VRFPrivateKey>("003fcf7b813bec2a293f574b842988895278b396dd72471de2583b242097a59f06e9f3cd7b78d45750afd17292031373fddb5e7a8090db51221038f5e05f29998e");

let genesis_vrf_public_key = decode_hex::<VRFPublicKey>(
"00fa2f59dc7a7e176058e4f2d155cfa03ee007340e0285447892158823d332f744",
);

let genesis_pool_stake_data = Box::new(StakePoolData::new(
MIN_STAKE_POOL_PLEDGE,
Destination::PublicKey(genesis_stake_public_key.clone()),
genesis_vrf_public_key.clone(),
Destination::PublicKey(genesis_stake_public_key.clone()),
PerThousand::new(1000).expect("Valid per thousand"),
Amount::ZERO,
));

(
genesis_pool_id,
genesis_pool_stake_data,
genesis_stake_private_key,
genesis_stake_public_key,
genesis_vrf_private_key,
genesis_vrf_public_key,
)
}

pub fn create_regtest_pos_genesis(premine_destination: Destination) -> Genesis {
let (
genesis_pool_id,
genesis_stake_pool_data,
_genesis_stake_private_key,
_genesis_stake_public_key,
_genesis_vrf_private_key,
_genesis_vrf_public_key,
) = regtest_genesis_values();

let create_genesis_pool_txoutput =
TxOutput::CreateStakePool(genesis_pool_id, genesis_stake_pool_data);

let premine_output =
TxOutput::Transfer(OutputValue::Coin(DEFAULT_INITIAL_MINT), premine_destination);

Genesis::new(
String::new(),
BlockTimestamp::from_int_seconds(1639975460),
vec![premine_output, create_genesis_pool_txoutput],
)
}

fn create_unit_test_genesis(premine_destination: Destination) -> Genesis {
let genesis_message = String::new();

Expand Down
Loading