Skip to content

Commit

Permalink
refactor: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Mar 22, 2024
1 parent 63eebfe commit ca46dda
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 65 deletions.
9 changes: 4 additions & 5 deletions components/clarinet-cli/src/generate/project.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,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_SUBNET_API_IMAGE,
DEFAULT_SUBNET_CONTRACT_ID, DEFAULT_SUBNET_MNEMONIC, DEFAULT_SUBNET_NODE_IMAGE,
DEFAULT_EPOCH_2_4, DEFAULT_EPOCH_2_5, DEFAULT_FAUCET_MNEMONIC, DEFAULT_POSTGRES_IMAGE,
DEFAULT_STACKS_API_IMAGE, DEFAULT_STACKS_EXPLORER_IMAGE, DEFAULT_STACKS_MINER_MNEMONIC,
DEFAULT_STACKS_NODE_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 @@ -410,7 +410,6 @@ disable_stacks_api = false
# epoch_2_3 = {DEFAULT_EPOCH_2_3}
# epoch_2_4 = {DEFAULT_EPOCH_2_4}
# epoch_2_5 = {DEFAULT_EPOCH_2_5}
# epoch_3_0 = {DEFAULT_EPOCH_3_0}
# Send some stacking orders
Expand Down
5 changes: 3 additions & 2 deletions components/clarinet-files/src/network_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ pub const DEFAULT_EPOCH_2_1: u64 = 101;
pub const DEFAULT_EPOCH_2_2: u64 = 102;
pub const DEFAULT_EPOCH_2_3: u64 = 103;
pub const DEFAULT_EPOCH_2_4: u64 = 104;
pub const DEFAULT_EPOCH_2_5: u64 = 105;
pub const DEFAULT_EPOCH_3_0: u64 = 121;
pub const DEFAULT_EPOCH_2_5: u64 = 108;
// Epoch 3.0 isn't stable for now, let's focus on running 2.5
pub const DEFAULT_EPOCH_3_0: u64 = 100001;

// Currently, the pox-4 contract has these values hardcoded:
// https://github.com/stacks-network/stacks-core/blob/e09ab931e2f15ff70f3bb5c2f4d7afb[…]42bd7bec6/stackslib/src/chainstate/stacks/boot/pox-testnet.clar
Expand Down
53 changes: 2 additions & 51 deletions components/stacks-network/src/chains_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ pub async fn publish_stacking_orders(
.and_then(|version| version.parse::<u32>().ok())
.unwrap();

let signer_private_keys = [
let default_signing_keys = [
StacksPrivateKey::from_hex(
"7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801",
)
Expand Down Expand Up @@ -770,7 +770,7 @@ pub async fn publish_stacking_orders(
pox_version,
bitcoin_block_height,
current_cycle.into(),
&signer_private_keys[i],
&default_signing_keys[i % 2],
extend_stacking,
&btc_address_moved,
stx_amount,
Expand Down Expand Up @@ -1087,52 +1087,3 @@ fn make_signer_key_signature(

signature.to_rsv()
}

#[cfg(test)]
mod key_tests {
use super::*;
use clarinet_files::DEFAULT_DERIVATION_PATH;
use stackslib::{net::stackerdb::db, util::hash::bytes_to_hex};
#[test]
fn test_make_signer_key_signature() {
let label = "wallet_1".to_string();
let mnemonic = "sell invite acquire kitten bamboo drastic jelly vivid peace spawn twice guilt pave pen trash pretty park cube fragile unaware remain midnight betray rebuild".to_string();

let account = AccountConfig {
label,
mnemonic,
derivation: DEFAULT_DERIVATION_PATH.into(),
balance: 100000,
stx_address: "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5".into(),
btc_address: "mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC".into(),
is_mainnet: false,
};

let addr_bytes = account
.btc_address
.from_base58()
.expect("Unable to get bytes from btc address");

let pox_addr_tuple = ClarityValue::Tuple(
TupleData::from_data(vec![
(
ClarityName::try_from("version".to_owned()).unwrap(),
ClarityValue::buff_from_byte(AddressHashMode::SerializeP2PKH as u8),
),
(
ClarityName::try_from("hashbytes".to_owned()).unwrap(),
ClarityValue::Sequence(SequenceData::Buffer(BuffData {
data: Hash160::from_bytes(&addr_bytes[1..21])
.unwrap()
.as_bytes()
.to_vec(),
})),
),
])
.unwrap(),
);

let pox_addr = PoxAddress::try_from_pox_tuple(false, &pox_addr_tuple).unwrap();
dbg!(pox_addr);
}
}
39 changes: 32 additions & 7 deletions components/stacks-network/src/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,19 @@ impl DevnetOrchestrator {
enable_subnet_node,
"stacks-signer-1",
Status::Green,
"Waiting for messages",
"running",
);

// Start stacks-signer-2
let _ = event_tx.send(DevnetEvent::info("Starting stacks-signer-2".to_string()));
send_status_update(
&event_tx,
use_nakamoto,
enable_subnet_node,
"stacks-signer-2",
Status::Yellow,
"updating image",
);
match self
.prepare_stacks_signer_container(boot_index, ctx, 2)
.await
Expand All @@ -656,6 +664,14 @@ impl DevnetOrchestrator {
return Err(message);
}
};
send_status_update(
&event_tx,
use_nakamoto,
enable_subnet_node,
"stacks-signer-2",
Status::Yellow,
"booting",
);
match self.boot_stacks_signer_container(2).await {
Ok(_) => {}
Err(message) => {
Expand All @@ -664,6 +680,14 @@ impl DevnetOrchestrator {
return Err(message);
}
};
send_status_update(
&event_tx,
use_nakamoto,
enable_subnet_node,
"stacks-signer-2",
Status::Green,
"running",
);

// Start stacks-explorer
if !disable_stacks_explorer {
Expand Down Expand Up @@ -1412,15 +1436,16 @@ start_height = {epoch_3_0}
boot_index: u32,
signer_id: u32,
) -> Result<Config<String>, String> {
let (_, devnet_config) = match &self.network_config {
let devnet_config = match &self.network_config {
Some(ref network_config) => match network_config.devnet {
Some(ref devnet_config) => (network_config, devnet_config),
_ => return Err("unable to get devnet configuration".into()),
Some(ref devnet_config) => devnet_config,
_ => return Err("unable to initialize bitcoin node".to_string()),
},
_ => return Err("unable to get Docker client".into()),
_ => return Err("unable to initialize bitcoin node".to_string()),
};

let signer_private_keys = [
// the default wallet_1 and wallet_2 are the default signers
let default_signing_keys = [
"7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801",
"530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101",
];
Expand All @@ -1435,7 +1460,7 @@ network = "testnet"
auth_password = "12345"
db_path = "stacks-signer-{signer_id}.sqlite"
"#,
signer_private_key = signer_private_keys[(signer_id - 1) as usize],
signer_private_key = default_signing_keys[(signer_id - 1) as usize],
// signer_private_key = devnet_config.signer_private_key,
network_name = self.network_name,
stacks_node_rpc_port = devnet_config.stacks_node_rpc_port
Expand Down

0 comments on commit ca46dda

Please sign in to comment.