Skip to content

Commit

Permalink
feat: upgrade ratatui and add pox informations in devnet ui
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jan 16, 2024
1 parent 3e48eb1 commit bd8f749
Show file tree
Hide file tree
Showing 11 changed files with 11,591 additions and 257 deletions.
105 changes: 98 additions & 7 deletions Cargo.lock

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

17 changes: 5 additions & 12 deletions components/clarinet-files/src/network_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ use toml::value::Value;

pub const DEFAULT_DERIVATION_PATH: &str = "m/44'/5757'/0'/0/0";

pub const DEFAULT_BITCOIN_NODE_IMAGE: &str = "quay.io/hirosystems/bitcoind:devnet-v3";
pub const DEFAULT_STACKS_NODE_IMAGE: &str = "quay.io/hirosystems/stacks-node:devnet-2.4.0.0.0";
pub const DEFAULT_STACKS_API_IMAGE: &str = "hirosystems/stacks-blockchain-api:latest";

// Nakamoto images overrides
pub const DEFAULT_BITCOIN_NODE_IMAGE_NAKA: &str = "quay.io/hirosystems/bitcoind:25.0";
pub const DEFAULT_STACKS_NODE_IMAGE_NAKA: &str = "blockstack/stacks-blockchain:next-devnet";
pub const DEFAULT_STACKS_API_IMAGE_NAKA: &str = "hirosystems/stacks-blockchain-api:nakamoto";

pub const DEFAULT_BITCOIN_NODE_IMAGE: &str = "quay.io/hirosystems/bitcoind:25.0";
pub const DEFAULT_BITCOIN_EXPLORER_IMAGE: &str = "quay.io/hirosystems/bitcoin-explorer:devnet";
pub const DEFAULT_STACKS_EXPLORER_IMAGE: &str = "hirosystems/explorer:latest";
pub const DEFAULT_POSTGRES_IMAGE: &str = "postgres:14";
Expand Down Expand Up @@ -852,15 +850,10 @@ impl NetworkManifest {
.take()
.unwrap_or("subnet_api".to_string()),
execute_script: devnet_config.execute_script.take().unwrap_or(vec![]),
bitcoin_node_image_url: devnet_config.bitcoin_node_image_url.take().unwrap_or_else(
|| {
if devnet_config.use_nakamoto.unwrap_or(false) {
DEFAULT_BITCOIN_NODE_IMAGE_NAKA.to_string()
} else {
DEFAULT_BITCOIN_NODE_IMAGE.to_string()
}
},
),
bitcoin_node_image_url: devnet_config
.bitcoin_node_image_url
.take()
.unwrap_or(DEFAULT_BITCOIN_NODE_IMAGE.to_string()),
stacks_node_image_url: devnet_config.stacks_node_image_url.take().unwrap_or_else(
|| {
if devnet_config.use_nakamoto.unwrap_or(false) {
Expand Down
7 changes: 2 additions & 5 deletions components/stacks-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ atty = "0.2.14"
ansi_term = "0.12.1"
bollard = "0.11.0"
bytes = "1.4.0"
crossterm = { version = "0.22.1", optional = true }
bitcoin = "0.29.2"
bitcoincore-rpc = "0.16.0"
serde = { version = "1.0.136", features = ["derive"] }
Expand All @@ -25,8 +24,9 @@ reqwest = { version = "0.11", default-features = false, features = [
"json",
"rustls-tls",
] }
tui = { version = "0.18.0", default-features = false, features = ["crossterm"] }
crossbeam-channel = "0.5.6"
crossterm = { version = "0.27.0" }
ratatui = { version = "0.25.0", default-features = false, features = ["crossterm"] }

chrono = "0.4.31"
futures = "0.3.12"
Expand Down Expand Up @@ -55,6 +55,3 @@ crate-type = ["cdylib", "rlib"]
[[bin]]
name = "stacks-network"
path = "src/main.rs"

[features]
default = ["crossterm"]
115 changes: 68 additions & 47 deletions components/stacks-network/src/chains_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ pub fn relay_devnet_protocol_deployment(
pub async fn publish_stacking_orders(
pox_info: PoxInfo,
devnet_config: &DevnetConfig,
_devnet_event_tx: &Sender<DevnetEvent>,
devnet_event_tx: &Sender<DevnetEvent>,
accounts: &[AccountConfig],
services_map_hosts: &ServicesMapHosts,
fee_rate: u64,
Expand Down Expand Up @@ -579,52 +579,73 @@ pub async fn publish_stacking_orders(
let node_url = stacks_node_rpc_url.clone();
let pox_contract_id = pox_info.contract_id.clone();

let _ = hiro_system_kit::thread_named("Stacking orders handler").spawn(move || {
let default_fee = fee_rate * 1000;
let stacks_rpc = StacksRpc::new(&node_url);
let nonce = stacks_rpc
.get_nonce(&account.stx_address)
.expect("Unable to retrieve nonce");

let (_, _, account_secret_key) = clarinet_files::compute_addresses(
&account.mnemonic,
&account.derivation,
&StacksNetwork::Devnet.get_networks(),
);

let addr_bytes = Hash160::from_bytes(&addr_bytes[1..21]).unwrap();
let addr_version = AddressHashMode::SerializeP2PKH;
let stack_stx_tx = codec::build_contrat_call_transaction(
pox_contract_id,
"stack-stx".into(),
vec![
ClarityValue::UInt(stx_amount.into()),
ClarityValue::Tuple(
TupleData::from_data(vec![
(
ClarityName::try_from("version".to_owned()).unwrap(),
ClarityValue::buff_from_byte(addr_version as u8),
),
(
ClarityName::try_from("hashbytes".to_owned()).unwrap(),
ClarityValue::Sequence(SequenceData::Buffer(BuffData {
data: addr_bytes.as_bytes().to_vec(),
})),
),
])
.unwrap(),
),
ClarityValue::UInt((bitcoin_block_height - 1).into()),
ClarityValue::UInt(duration),
],
nonce,
default_fee,
&hex_bytes(&account_secret_key).unwrap(),
);
let _ = stacks_rpc
.post_transaction(&stack_stx_tx)
.expect("Unable to broadcast transaction");
});
let stacking_result =
hiro_system_kit::thread_named("Stacking orders handler").spawn(move || {
let default_fee = fee_rate * 1000;
let stacks_rpc = StacksRpc::new(&node_url);
let nonce = stacks_rpc.get_nonce(&account.stx_address)?;

let (_, _, account_secret_key) = clarinet_files::compute_addresses(
&account.mnemonic,
&account.derivation,
&StacksNetwork::Devnet.get_networks(),
);

let addr_bytes = Hash160::from_bytes(&addr_bytes[1..21]).unwrap();
let addr_version = AddressHashMode::SerializeP2PKH;
let stack_stx_tx = codec::build_contrat_call_transaction(
pox_contract_id,
"stack-stx".into(),
vec![
ClarityValue::UInt(stx_amount.into()),
ClarityValue::Tuple(
TupleData::from_data(vec![
(
ClarityName::try_from("version".to_owned()).unwrap(),
ClarityValue::buff_from_byte(addr_version as u8),
),
(
ClarityName::try_from("hashbytes".to_owned()).unwrap(),
ClarityValue::Sequence(SequenceData::Buffer(BuffData {
data: addr_bytes.as_bytes().to_vec(),
})),
),
])
.unwrap(),
),
ClarityValue::UInt((bitcoin_block_height - 1).into()),
ClarityValue::UInt(duration),
// ClarityValue::buff_from(vec![0; 33]).unwrap(),
],
nonce,
default_fee,
&hex_bytes(&account_secret_key).unwrap(),
);
stacks_rpc.post_transaction(&stack_stx_tx)
});

// match stacking_result {
// Ok(result) => {
// if let Ok(result) = result.join() {
// match result {
// Ok(_) => {
// let _ = devnet_event_tx.send(DevnetEvent::success(format!(
// "stacking order for {} STX submitted",
// stx_amount
// )));
// }
// Err(e) => {
// let _ = devnet_event_tx
// .send(DevnetEvent::error(format!("unable to stack: {}", e)));
// }
// }
// };
// }
// Err(e) => {
// let _ =
// devnet_event_tx.send(DevnetEvent::error(format!("unable to stack: {}", e)));
// }
// }
}
}
if transactions > 0 {
Expand Down
Loading

0 comments on commit bd8f749

Please sign in to comment.