Skip to content

Commit

Permalink
fix: default devnet stacker (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard authored Oct 30, 2024
1 parent 0bdb379 commit af78d2d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
11 changes: 7 additions & 4 deletions components/clarinet-cli/src/generate/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use clarinet_files::{
DEFAULT_BITCOIN_EXPLORER_IMAGE, DEFAULT_BITCOIN_NODE_IMAGE, DEFAULT_DERIVATION_PATH,
DEFAULT_EPOCH_2_0, DEFAULT_EPOCH_2_05, DEFAULT_EPOCH_2_1, DEFAULT_EPOCH_2_2, DEFAULT_EPOCH_2_3,
DEFAULT_EPOCH_2_4, DEFAULT_EPOCH_2_5, DEFAULT_EPOCH_3_0, DEFAULT_FAUCET_MNEMONIC,
DEFAULT_POSTGRES_IMAGE, DEFAULT_STACKS_API_IMAGE, DEFAULT_STACKS_EXPLORER_IMAGE,
DEFAULT_STACKS_MINER_MNEMONIC, DEFAULT_STACKS_NODE_IMAGE, DEFAULT_STACKS_SIGNER_IMAGE,
DEFAULT_SUBNET_API_IMAGE, DEFAULT_SUBNET_CONTRACT_ID, DEFAULT_SUBNET_MNEMONIC,
DEFAULT_SUBNET_NODE_IMAGE,
DEFAULT_POSTGRES_IMAGE, DEFAULT_STACKER_MNEMONIC, DEFAULT_STACKS_API_IMAGE,
DEFAULT_STACKS_EXPLORER_IMAGE, DEFAULT_STACKS_MINER_MNEMONIC, DEFAULT_STACKS_NODE_IMAGE,
DEFAULT_STACKS_SIGNER_IMAGE, DEFAULT_SUBNET_API_IMAGE, DEFAULT_SUBNET_CONTRACT_ID,
DEFAULT_SUBNET_MNEMONIC, DEFAULT_SUBNET_NODE_IMAGE,
};

use super::changes::{Changes, DirectoryCreation, FileCreation};
Expand Down Expand Up @@ -308,6 +308,8 @@ disable_stacks_api = false
# miner_derivation_path = "{default_derivation_path}"
# faucet_mnemonic = "{default_stacks_faucet_mnemonic}"
# faucet_derivation_path = "{default_derivation_path}"
# stacker_mnemonic = "{default_stacks_stacker_mnemonic}"
# stacker_derivation_path = "{default_derivation_path}"
# orchestrator_port = 20445
# bitcoin_node_p2p_port = 18444
# bitcoin_node_rpc_port = 18443
Expand Down Expand Up @@ -392,6 +394,7 @@ btc_address = "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7"
default_subnet_api_image = DEFAULT_SUBNET_API_IMAGE,
default_stacks_miner_mnemonic = DEFAULT_STACKS_MINER_MNEMONIC,
default_stacks_faucet_mnemonic = DEFAULT_FAUCET_MNEMONIC,
default_stacks_stacker_mnemonic = DEFAULT_STACKER_MNEMONIC,
);
let name = "settings/Devnet.toml".into();
self.changes
Expand Down
8 changes: 4 additions & 4 deletions components/clarinet-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ pub use network_manifest::{
DEFAULT_BITCOIN_NODE_IMAGE, DEFAULT_DERIVATION_PATH, DEFAULT_DOCKER_PLATFORM,
DEFAULT_EPOCH_2_0, DEFAULT_EPOCH_2_05, DEFAULT_EPOCH_2_1, DEFAULT_EPOCH_2_2, DEFAULT_EPOCH_2_3,
DEFAULT_EPOCH_2_4, DEFAULT_EPOCH_2_5, DEFAULT_EPOCH_3_0, DEFAULT_FAUCET_MNEMONIC,
DEFAULT_FIRST_BURN_HEADER_HEIGHT, DEFAULT_POSTGRES_IMAGE, DEFAULT_STACKS_API_IMAGE,
DEFAULT_STACKS_EXPLORER_IMAGE, DEFAULT_STACKS_MINER_MNEMONIC, DEFAULT_STACKS_NODE_IMAGE,
DEFAULT_STACKS_SIGNER_IMAGE, DEFAULT_SUBNET_API_IMAGE, DEFAULT_SUBNET_CONTRACT_ID,
DEFAULT_SUBNET_MNEMONIC, DEFAULT_SUBNET_NODE_IMAGE,
DEFAULT_FIRST_BURN_HEADER_HEIGHT, DEFAULT_POSTGRES_IMAGE, DEFAULT_STACKER_MNEMONIC,
DEFAULT_STACKS_API_IMAGE, DEFAULT_STACKS_EXPLORER_IMAGE, DEFAULT_STACKS_MINER_MNEMONIC,
DEFAULT_STACKS_NODE_IMAGE, DEFAULT_STACKS_SIGNER_IMAGE, DEFAULT_SUBNET_API_IMAGE,
DEFAULT_SUBNET_CONTRACT_ID, DEFAULT_SUBNET_MNEMONIC, DEFAULT_SUBNET_NODE_IMAGE,
};
pub use project_manifest::{
ProjectManifest, ProjectManifestFile, RequirementConfig, INVALID_CLARITY_VERSION,
Expand Down
41 changes: 36 additions & 5 deletions components/clarinet-files/src/network_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub const DEFAULT_SUBNET_CONTRACT_ID: &str =
"ST173JK7NZBA4BS05ZRATQH1K89YJMTGEH1Z5J52E.subnet-v3-0-1";
pub const DEFAULT_STACKS_MINER_MNEMONIC: &str = "fragile loan twenty basic net assault jazz absorb diet talk art shock innocent float punch travel gadget embrace caught blossom hockey surround initial reduce";
pub const DEFAULT_FAUCET_MNEMONIC: &str = "shadow private easily thought say logic fault paddle word top book during ignore notable orange flight clock image wealth health outside kitten belt reform";
pub const DEFAULT_STACKER_MNEMONIC: &str = "empty lens any direct brother then drop fury rule pole win claim scissors list rescue horn rent inform relief jump sword weekend half legend";
pub const DEFAULT_SUBNET_MNEMONIC: &str = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw";
#[cfg(unix)]
pub const DEFAULT_DOCKER_SOCKET: &str = "unix:///var/run/docker.sock";
Expand Down Expand Up @@ -139,6 +140,8 @@ pub struct DevnetConfigFile {
pub miner_wallet_name: Option<String>,
pub faucet_mnemonic: Option<String>,
pub faucet_derivation_path: Option<String>,
pub stacker_mnemonic: Option<String>,
pub stacker_derivation_path: Option<String>,
pub bitcoin_controller_block_time: Option<u32>,
pub bitcoin_controller_automining_disabled: Option<bool>,
pub pre_nakamoto_mock_signing: Option<bool>,
Expand Down Expand Up @@ -305,6 +308,8 @@ pub struct DevnetConfig {
pub faucet_btc_address: String,
pub faucet_mnemonic: String,
pub faucet_derivation_path: String,
pub stacker_mnemonic: String,
pub stacker_derivation_path: String,
pub pre_nakamoto_mock_signing: bool,
pub working_dir: String,
pub postgres_port: u16,
Expand Down Expand Up @@ -840,15 +845,39 @@ impl NetworkManifest {
));
}

let stacker_mnemonic = devnet_config
.stacker_mnemonic
.take()
.unwrap_or(DEFAULT_STACKER_MNEMONIC.to_string());
let stacker_derivation_path = devnet_config
.stacker_derivation_path
.take()
.unwrap_or(DEFAULT_DERIVATION_PATH.to_string());
let (stx_address, btc_address, _) =
compute_addresses(&stacker_mnemonic, &stacker_derivation_path, networks);

accounts.insert(
"stacker".to_string(),
AccountConfig {
label: "stacker".to_string(),
mnemonic: stacker_mnemonic.clone(),
derivation: stacker_derivation_path.clone(),
balance: 100_000_000_000_000,
stx_address,
btc_address,
is_mainnet: false,
},
);

let mut stacking_orders = vec![];
let mut add_default_stacking_order = true;
// for stacking orders, we validate that wallet names match one of the provided accounts
if let Some(mut val) = devnet_config.pox_stacking_orders {
for (i, stacking_order) in val.iter().enumerate() {
let wallet_name = &stacking_order.wallet;

// if the project already set a stacking order for the deployer, do not override it
if wallet_name == "deployer" {
// if the project already set a stacking order for the stacker, do not override it
if wallet_name == "stacker" {
add_default_stacking_order = false;
}

Expand All @@ -868,14 +897,14 @@ impl NetworkManifest {
if add_default_stacking_order {
if let Some((_, account_config)) = accounts
.iter()
.find(|(account_name, _)| *account_name == "deployer")
.find(|(account_name, _)| *account_name == "stacker")
{
stacking_orders.push(PoxStackingOrder {
auto_extend: Some(true),
duration: 10,
start_at_cycle: 1,
wallet: "deployer".into(),
slots: 6,
wallet: "stacker".into(),
slots: 10,
btc_address: account_config.btc_address.clone(),
})
}
Expand Down Expand Up @@ -935,6 +964,8 @@ impl NetworkManifest {
faucet_mnemonic,
faucet_secret_key_hex,
faucet_derivation_path,
stacker_mnemonic,
stacker_derivation_path,
working_dir: devnet_config
.working_dir
.take()
Expand Down

0 comments on commit af78d2d

Please sign in to comment.