diff --git a/examples/counter/settings/Devnet.toml b/examples/counter/settings/Devnet.toml index 9b9325d42..33d49de37 100644 --- a/examples/counter/settings/Devnet.toml +++ b/examples/counter/settings/Devnet.toml @@ -2,41 +2,100 @@ name = "devnet" [accounts.deployer] -mnemonic = "fetch outside black test wash cover just actual execute nice door want airport betray quantum stamp fish act pen trust portion fatigue scissors vague" -balance = 1_000_000 +mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw" +balance = 1_000_000_000 +# secret_key: 753b7cc01a1a2e86221266a154af739463fce51219d97e4f856cd7200c3bd2a601 +# stx_address: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM +# btc_address: mqVnk6NPRdhntvfm4hh9vvjiRkFDUuSYsH [accounts.wallet_1] -mnemonic = "spoil sock coyote include verify comic jacket gain beauty tank flush victory illness edge reveal shallow plug hobby usual juice harsh pact wreck eight" -balance = 1_000_000 +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" +balance = 1_000_000_000 +# secret_key: 7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801 +# stx_address: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5 +# btc_address: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC [accounts.wallet_2] -mnemonic = "arrange scale orient half ugly kid bike twin magnet joke hurt fiber ethics super receive version wreck media fluid much abstract reward street alter" -balance = 1_000_000 +mnemonic = "hold excess usual excess ring elephant install account glad dry fragile donkey gaze humble truck breeze nation gasp vacuum limb head keep delay hospital" +balance = 1_000_000_000 +# secret_key: 530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101 +# stx_address: ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG +# btc_address: muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG [accounts.wallet_3] -mnemonic = "glide clown kitchen picnic basket hidden asset beyond kid plug carbon talent drama wet pet rhythm hero nest purity baby bicycle ghost sponsor dragon" -balance = 1_000_000 +mnemonic = "cycle puppy glare enroll cost improve round trend wrist mushroom scorpion tower claim oppose clever elephant dinosaur eight problem before frozen dune wagon high" +balance = 1_000_000_000 +# secret_key: d655b2523bcd65e34889725c73064feb17ceb796831c0e111ba1a552b0f31b3901 +# stx_address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC +# btc_address: mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7 [accounts.wallet_4] -mnemonic = "pulp when detect fun unaware reduce promote tank success lecture cool cheese object amazing hunt plug wing month hello tunnel detect connect floor brush" -balance = 1_000_000 +mnemonic = "board list obtain sugar hour worth raven scout denial thunder horse logic fury scorpion fold genuine phrase wealth news aim below celery when cabin" +balance = 1_000_000_000 +# secret_key: f9d7206a47f14d2870c163ebab4bf3e70d18f5d14ce1031f3902fbbc894fe4c701 +# stx_address: ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND +# btc_address: mg1C76bNTutiCDV3t9nWhZs3Dc8LzUufj8 [accounts.wallet_5] -mnemonic = "replace swing shove congress smoke banana tired term blanket nominee leave club myself swing egg virus answer bulk useful start decrease family energy february" -balance = 1_000_000 +mnemonic = "hurry aunt blame peanut heavy update captain human rice crime juice adult scale device promote vast project quiz unit note reform update climb purchase" +balance = 1_000_000_000 +# secret_key: 3eccc5dac8056590432db6a35d52b9896876a3d5cbdea53b72400bc9c2099fe801 +# stx_address: ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB +# btc_address: mweN5WVqadScHdA81aATSdcVr4B6dNokqx [accounts.wallet_6] -mnemonic = "apology together shy taxi glare struggle hip camp engage lion possible during squeeze hen exotic marriage misery kiwi once quiz enough exhibit immense tooth" -balance = 1_000_000 +mnemonic = "area desk dutch sign gold cricket dawn toward giggle vibrant indoor bench warfare wagon number tiny universe sand talk dilemma pottery bone trap buddy" +balance = 1_000_000_000 +# secret_key: 7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01 +# stx_address: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0 +# btc_address: mzxXgV6e4BZSsz8zVHm3TmqbECt7mbuErt [accounts.wallet_7] -mnemonic = "antenna bitter find rely gadget father exact excuse cross easy elbow alcohol injury loud silk bird crime cabbage winter fit wide screen update october" -balance = 1_000_000 +mnemonic = "prevent gallery kind limb income control noise together echo rival record wedding sense uncover school version force bleak nuclear include danger skirt enact arrow" +balance = 1_000_000_000 +# secret_key: b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401 +# stx_address: ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ +# btc_address: n37mwmru2oaVosgfuvzBwgV2ysCQRrLko7 [accounts.wallet_8] -mnemonic = "east load echo merit ignore hip tag obvious truly adjust smart panther deer aisle north hotel process frown lock property catch bless notice topple" -balance = 1_000_000 +mnemonic = "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune" +balance = 1_000_000_000 +# secret_key: 6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01 +# stx_address: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP +# btc_address: n2v875jbJ4RjBnTjgbfikDfnwsDV5iUByw [accounts.wallet_9] -mnemonic = "market ocean tortoise venue vivid coach machine category conduct enable insect jump fog file test core book chaos crucial burst version curious prosper fever" -balance = 1_000_000 +mnemonic = "shadow private easily thought say logic fault paddle word top book during ignore notable orange flight clock image wealth health outside kitten belt reform" +balance = 1_000_000_000 +# secret_key: de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801 +# stx_address: STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6 +# btc_address: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d + +# [devnet] +# pox_stacking_orders = [] +# orchestrator_port = 20445 +# bitcoind_p2p_port = 18444 +# bitcoind_rpc_port = 18443 +# bitcoind_username = "devnet" +# bitcoind_password = "devnet" +# bitcoin_controller_port = 18442 +# bitcoin_controller_block_time = 30_000 +# stacks_node_rpc_port = 20443 +# stacks_node_p2p_port = 20444 +# stacks_node_events_observers = ["localhot:8002"] +# stacks_api_port = 20080 +# stacks_api_events_port = 3700 +# bitcoin_explorer_port = 8001 +# stacks_explorer_port = 8000 +# miner_mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw" +# miner_derivation_path = "m/44'/5757'/0'/0/0" +# working_dir = "tmp/devnet" +# postgres_port = 5432 +# postgres_username = "postgres" +# postgres_password = "postgres" +# postgres_database = "postgres" +# bitcoind_image_url = "quay.io/hirosystems/bitcoind:devnet" +# stacks_node_image_url = "quay.io/hirosystems/stacks-node:devnet" +# stacks_api_image_url = "blockstack/stacks-blockchain-api:latest" +# stacks_explorer_image_url = "blockstack/explorer:latest" +# postgres_image_url = "postgres:alpine" diff --git a/src/generate/project.rs b/src/generate/project.rs index c38430ebf..a67f6b5b9 100644 --- a/src/generate/project.rs +++ b/src/generate/project.rs @@ -193,44 +193,74 @@ mnemonic = "" name = "devnet" [accounts.deployer] -mnemonic = "fetch outside black test wash cover just actual execute nice door want airport betray quantum stamp fish act pen trust portion fatigue scissors vague" -balance = 1_000_000 +mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw" +balance = 1_000_000_000 +# secret_key: 753b7cc01a1a2e86221266a154af739463fce51219d97e4f856cd7200c3bd2a601 +# stx_address: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM +# btc_address: mqVnk6NPRdhntvfm4hh9vvjiRkFDUuSYsH [accounts.wallet_1] -mnemonic = "spoil sock coyote include verify comic jacket gain beauty tank flush victory illness edge reveal shallow plug hobby usual juice harsh pact wreck eight" -balance = 1_000_000 +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" +balance = 1_000_000_000 +# secret_key: 7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801 +# stx_address: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5 +# btc_address: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC [accounts.wallet_2] -mnemonic = "arrange scale orient half ugly kid bike twin magnet joke hurt fiber ethics super receive version wreck media fluid much abstract reward street alter" -balance = 1_000_000 +mnemonic = "hold excess usual excess ring elephant install account glad dry fragile donkey gaze humble truck breeze nation gasp vacuum limb head keep delay hospital" +balance = 1_000_000_000 +# secret_key: 530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101 +# stx_address: ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG +# btc_address: muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG [accounts.wallet_3] -mnemonic = "glide clown kitchen picnic basket hidden asset beyond kid plug carbon talent drama wet pet rhythm hero nest purity baby bicycle ghost sponsor dragon" -balance = 1_000_000 +mnemonic = "cycle puppy glare enroll cost improve round trend wrist mushroom scorpion tower claim oppose clever elephant dinosaur eight problem before frozen dune wagon high" +balance = 1_000_000_000 +# secret_key: d655b2523bcd65e34889725c73064feb17ceb796831c0e111ba1a552b0f31b3901 +# stx_address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC +# btc_address: mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7 [accounts.wallet_4] -mnemonic = "pulp when detect fun unaware reduce promote tank success lecture cool cheese object amazing hunt plug wing month hello tunnel detect connect floor brush" -balance = 1_000_000 +mnemonic = "board list obtain sugar hour worth raven scout denial thunder horse logic fury scorpion fold genuine phrase wealth news aim below celery when cabin" +balance = 1_000_000_000 +# secret_key: f9d7206a47f14d2870c163ebab4bf3e70d18f5d14ce1031f3902fbbc894fe4c701 +# stx_address: ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND +# btc_address: mg1C76bNTutiCDV3t9nWhZs3Dc8LzUufj8 [accounts.wallet_5] -mnemonic = "replace swing shove congress smoke banana tired term blanket nominee leave club myself swing egg virus answer bulk useful start decrease family energy february" -balance = 1_000_000 +mnemonic = "hurry aunt blame peanut heavy update captain human rice crime juice adult scale device promote vast project quiz unit note reform update climb purchase" +balance = 1_000_000_000 +# secret_key: 3eccc5dac8056590432db6a35d52b9896876a3d5cbdea53b72400bc9c2099fe801 +# stx_address: ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB +# btc_address: mweN5WVqadScHdA81aATSdcVr4B6dNokqx [accounts.wallet_6] -mnemonic = "apology together shy taxi glare struggle hip camp engage lion possible during squeeze hen exotic marriage misery kiwi once quiz enough exhibit immense tooth" -balance = 1_000_000 +mnemonic = "area desk dutch sign gold cricket dawn toward giggle vibrant indoor bench warfare wagon number tiny universe sand talk dilemma pottery bone trap buddy" +balance = 1_000_000_000 +# secret_key: 7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01 +# stx_address: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0 +# btc_address: mzxXgV6e4BZSsz8zVHm3TmqbECt7mbuErt [accounts.wallet_7] -mnemonic = "antenna bitter find rely gadget father exact excuse cross easy elbow alcohol injury loud silk bird crime cabbage winter fit wide screen update october" -balance = 1_000_000 +mnemonic = "prevent gallery kind limb income control noise together echo rival record wedding sense uncover school version force bleak nuclear include danger skirt enact arrow" +balance = 1_000_000_000 +# secret_key: b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401 +# stx_address: ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ +# btc_address: n37mwmru2oaVosgfuvzBwgV2ysCQRrLko7 [accounts.wallet_8] -mnemonic = "east load echo merit ignore hip tag obvious truly adjust smart panther deer aisle north hotel process frown lock property catch bless notice topple" -balance = 1_000_000 +mnemonic = "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune" +balance = 1_000_000_000 +# secret_key: 6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01 +# stx_address: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP +# btc_address: n2v875jbJ4RjBnTjgbfikDfnwsDV5iUByw [accounts.wallet_9] -mnemonic = "market ocean tortoise venue vivid coach machine category conduct enable insect jump fog file test core book chaos crucial burst version curious prosper fever" -balance = 1_000_000 +mnemonic = "shadow private easily thought say logic fault paddle word top book during ignore notable orange flight clock image wealth health outside kitten belt reform" +balance = 1_000_000_000 +# secret_key: de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801 +# stx_address: STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6 +# btc_address: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d "# ); let name = format!("Devnet.toml"); diff --git a/src/integrate/events_observer.rs b/src/integrate/events_observer.rs index aefd03486..0c4ba6762 100644 --- a/src/integrate/events_observer.rs +++ b/src/integrate/events_observer.rs @@ -6,7 +6,7 @@ use rocket_contrib::json::Json; use rocket::State; use std::str; use std::sync::mpsc::{Receiver, Sender}; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, RwLock}; use crate::integrate::{BlockData, LogData, MempoolAdmissionData, ServiceStatusData, Status, Transaction}; use crate::types::{ChainConfig, DevnetConfig}; use crate::publish::{publish_contracts, Network}; @@ -44,6 +44,16 @@ pub struct NewTransaction { pub struct EventObserverConfig { pub devnet_config: DevnetConfig, pub manifest_path: PathBuf, + pub pox_info: PoxInfo, +} + +#[derive(Deserialize, Debug, Clone, Default)] +pub struct PoxInfo { + pox_activation_threshold_ustx: u64, + first_burnchain_block_height: u32, + prepare_phase_block_length: u32, + reward_phase_block_length: u32, + reward_slots: u32, } pub async fn start_events_observer(events_config: EventObserverConfig, devnet_event_tx: Sender, terminator_rx: Receiver) -> Result<(), Box> { @@ -57,7 +67,7 @@ pub async fn start_events_observer(events_config: EventObserverConfig, devnet_ev .finalize()?; rocket::custom(config) - .manage(Arc::new(Mutex::new(events_config))) + .manage(RwLock::new(events_config)) .manage(Arc::new(Mutex::new(devnet_event_tx.clone()))) .mount("/", routes![handle_new_burn_block, handle_new_block, handle_new_mempool_tx, handle_drop_mempool_tx]) .launch(); @@ -73,7 +83,7 @@ pub async fn start_events_observer(events_config: EventObserverConfig, devnet_ev } #[post("/new_burn_block", format = "application/json", data = "")] -pub fn handle_new_burn_block(config: State>>, devnet_events_tx: State>>>, new_burn_block: Json) -> Json { +pub fn handle_new_burn_block(config: State>, devnet_events_tx: State>>>, new_burn_block: Json) -> Json { let devnet_events_tx = devnet_events_tx.inner(); match devnet_events_tx.lock() { @@ -96,8 +106,9 @@ pub fn handle_new_burn_block(config: State>>, dev } #[post("/new_block", format = "application/json", data = "")] -pub fn handle_new_block(config: State>>, devnet_events_tx: State>>>, new_block: Json) -> Json { +pub fn handle_new_block(config: State>, devnet_events_tx: State>>>, new_block: Json) -> Json { let devnet_events_tx = devnet_events_tx.inner(); + let config = config.inner(); if let Ok(tx) = devnet_events_tx.lock() { let _ = tx.send(DevnetEvent::ServiceStatus(ServiceStatusData { @@ -111,33 +122,66 @@ pub fn handle_new_block(config: State>>, devnet_e new_block.burn_block_height, new_block.transactions.len(), ))); - let _ = tx.send(DevnetEvent::Block(BlockData { - block_height: new_block.block_height, - block_hash: new_block.block_hash.clone(), - bitcoin_block_height: new_block.burn_block_height, - bitcoin_block_hash: new_block.burn_block_hash.clone(), - transactions: new_block.transactions.iter().map(|t| { - Transaction { - txid: t.txid.clone(), - success: t.status == "success", - result: t.raw_result.clone(), - events: vec![], - } - }).collect(), - })); if new_block.block_height == 1 { - let config = config.inner(); - if let Ok(config) = config.lock() { - let _ = tx.send(DevnetEvent::info(format!("Checking and publishing contracts..."))); - let logs = match publish_contracts(config.manifest_path.clone(), Network::Devnet) { + // We just received the Stacks Genesis block. + // With that, we will be: + // - Fetching the pox constants + // - Publishing the contracts + let updated_config = if let Ok(config_reader) = config.read() { + let mut updated_config = config_reader.clone(); + let url = format!("http://0.0.0.0:{}/v2/pox", updated_config.devnet_config.stacks_node_rpc_port); + updated_config.pox_info = match reqwest::blocking::get(url) { + Ok(reponse) => { + let _ = tx.send(DevnetEvent::debug(format!("{:?}", reponse))); + let pox_info: PoxInfo = reponse.json().unwrap(); + let _ = tx.send(DevnetEvent::debug(format!("{:?}", pox_info))); + pox_info + }, + Err(_) => PoxInfo::default() + }; + Some(updated_config) + } else { + None + }; + + if let Some(updated_config) = updated_config { + let _ = tx.send(DevnetEvent::debug(format!("Updated config: {:?} ", updated_config.pox_info))); + + let logs = match publish_contracts(updated_config.manifest_path.clone(), Network::Devnet) { Ok(res) => res.iter().map(|l| DevnetEvent::success(l.into())).collect(), Err(e) => vec![DevnetEvent::error(e.into())] }; for log in logs.into_iter() { let _ = tx.send(log); } - }; + + if let Ok(mut config_writer) = config.write() { + *config_writer = updated_config; + } + } + } + + if let Ok(config_reader) = config.read() { + let pox_cycle_length = config_reader.pox_info.prepare_phase_block_length + config_reader.pox_info.reward_phase_block_length; + let pox_cycle_id = (new_block.burn_block_height - config_reader.pox_info.first_burnchain_block_height) / pox_cycle_length; + let _ = tx.send(DevnetEvent::Block(BlockData { + block_height: new_block.block_height, + block_hash: new_block.block_hash.clone(), + bitcoin_block_height: new_block.burn_block_height, + bitcoin_block_hash: new_block.burn_block_hash.clone(), + first_burnchain_block_height: config_reader.pox_info.first_burnchain_block_height, + pox_cycle_length, + pox_cycle_id, + transactions: new_block.transactions.iter().map(|t| { + Transaction { + txid: t.txid.clone(), + success: t.status == "success", + result: t.raw_result.clone(), + events: vec![], + } + }).collect(), + })); } }; @@ -156,7 +200,7 @@ pub fn handle_new_microblocks(devnet_events_tx: State>>, devnet_events_tx: State>>>, raw_txs: Json>) -> Json { +pub fn handle_new_mempool_tx(config: State>, devnet_events_tx: State>>>, raw_txs: Json>) -> Json { if let Ok(tx) = devnet_events_tx.lock() { for raw_tx in raw_txs.iter() { diff --git a/src/integrate/mod.rs b/src/integrate/mod.rs index 673b35976..610f84fbc 100644 --- a/src/integrate/mod.rs +++ b/src/integrate/mod.rs @@ -10,7 +10,7 @@ use crate::utils; pub use orchestrator::DevnetOrchestrator; use events_observer::start_events_observer; -use self::events_observer::EventObserverConfig; +use self::events_observer::{EventObserverConfig, PoxInfo}; pub fn run_devnet(devnet: DevnetOrchestrator) { match block_on(do_run_devnet(devnet)) { @@ -49,6 +49,7 @@ pub async fn do_run_devnet( let config = EventObserverConfig { devnet_config, manifest_path: devnet.manifest_path.clone(), + pox_info: PoxInfo::default(), }; let events_observer_tx = devnet_events_tx.clone(); let (events_observer_terminator_tx, terminator_rx) = channel(); @@ -192,6 +193,9 @@ pub struct BlockData { pub block_hash: String, pub bitcoin_block_height: u32, pub bitcoin_block_hash: String, + pub first_burnchain_block_height: u32, + pub pox_cycle_length: u32, + pub pox_cycle_id: u32, pub transactions: Vec } diff --git a/src/integrate/orchestrator.rs b/src/integrate/orchestrator.rs index dc09f9b73..615a19c9a 100644 --- a/src/integrate/orchestrator.rs +++ b/src/integrate/orchestrator.rs @@ -335,6 +335,11 @@ whitelisted_rpc_calls = [ "getrawmempool", "getblockhash", ] + +[[blocks]] +count = 1 +block_time = 30000 +ignore_txs = false "#, devnet_config.bitcoin_controller_port, devnet_config.bitcoin_controller_block_time, diff --git a/src/integrate/ui/app.rs b/src/integrate/ui/app.rs index 92470eb8a..1586483ba 100644 --- a/src/integrate/ui/app.rs +++ b/src/integrate/ui/app.rs @@ -76,10 +76,11 @@ impl<'a> App<'a> { } pub fn display_block(&mut self, block: BlockData) { - let cycle_len = 10; - let (start, end) = if block.block_height % cycle_len == (cycle_len - 1) { + let cycle_len = block.pox_cycle_length; + let abs_pos = (block.bitcoin_block_height - block.first_burnchain_block_height); + let (start, end) = if abs_pos % cycle_len == (cycle_len - 1) { ("", "<") - } else if block.block_height % cycle_len == 0 { + } else if abs_pos % cycle_len == 0 { (">", "") } else { ("", "") diff --git a/src/integrate/ui/ui.rs b/src/integrate/ui/ui.rs index fa3bf9f42..0e3132e40 100644 --- a/src/integrate/ui/ui.rs +++ b/src/integrate/ui/ui.rs @@ -194,6 +194,8 @@ where Constraint::Length(2), Constraint::Length(1), Constraint::Length(2), + Constraint::Length(1), + Constraint::Length(2), ].as_ref()) .split(area); @@ -245,6 +247,19 @@ where .block(Block::default().borders(Borders::NONE)); f.render_widget(paragraph, labels[8]); + let label = "Pox Cycle:".to_string(); + let paragraph = Paragraph::new(label) + .style(Style::default().bg(Color::Black).fg(Color::White)) + .block(Block::default().borders(Borders::NONE)); + f.render_widget(paragraph, labels[9]); + + let value = format!("{}", block.pox_cycle_id); + let paragraph = Paragraph::new(value) + .style(Style::default().bg(Color::Black).fg(Color::White)) + .block(Block::default().borders(Borders::NONE)); + f.render_widget(paragraph, labels[10]); + + // TODO(ludo): PoX informations // TODO(ludo): Mining informations (miner, VRF) } diff --git a/src/types/chain_config.rs b/src/types/chain_config.rs index 3f8cc824c..d4f9369b3 100644 --- a/src/types/chain_config.rs +++ b/src/types/chain_config.rs @@ -132,10 +132,10 @@ pub struct DevnetConfig { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PoxStackingOrder { pub start_at_cycle: u32, - pub end_at_cycle: u32, - pub amount_locked: u32, - pub wallet_label: String, - pub bitcoin_address: String, + pub duration: u32, + pub wallet: String, + pub slots: u32, + pub btc_address: String, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -268,7 +268,6 @@ impl ChainConfig { postgres_username: devnet_config.postgres_username.take().unwrap_or("postgres".to_string()), postgres_password: devnet_config.postgres_password.take().unwrap_or("postgres".to_string()), postgres_database: devnet_config.postgres_database.take().unwrap_or("postgres".to_string()), - pox_stacking_orders: devnet_config.pox_stacking_orders.take().unwrap_or(vec![]), preflight_scripts: devnet_config.preflight_scripts.take().unwrap_or(vec![]), postflight_scripts: devnet_config.postflight_scripts.take().unwrap_or(vec![]), bitcoind_image_url: devnet_config.bitcoind_image_url.take().unwrap_or(DEFAULT_BITCOIND_IMAGE.to_string()), @@ -276,6 +275,36 @@ impl ChainConfig { stacks_api_image_url: devnet_config.stacks_api_image_url.take().unwrap_or(DEFAULT_STACKS_API_IMAGE.to_string()), postgres_image_url: devnet_config.postgres_image_url.take().unwrap_or(DEFAULT_POSTGRES_IMAGE.to_string()), stacks_explorer_image_url: devnet_config.stacks_explorer_image_url.take().unwrap_or(DEFAULT_STACKS_EXPLORER_IMAGE.to_string()), + pox_stacking_orders: devnet_config.pox_stacking_orders.take().unwrap_or(vec![ + PoxStackingOrder { + start_at_cycle: 0, + duration: 12, + wallet: "wallet_1".into(), + slots: 2, + btc_address: "mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC".into(), + }, + PoxStackingOrder { + start_at_cycle: 0, + duration: 12, + wallet: "wallet_2".into(), + slots: 2, + btc_address: "muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG".into(), + }, + PoxStackingOrder { + start_at_cycle: 0, + duration: 12, + wallet: "wallet_3".into(), + slots: 2, + btc_address: "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7".into(), + }, + PoxStackingOrder { + start_at_cycle: 0, + duration: 12, + wallet: "wallet_4".into(), + slots: 2, + btc_address: "mg1C76bNTutiCDV3t9nWhZs3Dc8LzUufj8".into(), + }, + ]), }; Some(config) } else {