• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacks-network / stacks-core / 28582929957-1

02 Jul 2026 10:22AM UTC coverage: 85.69% (-0.02%) from 85.712%
28582929957-1

Pull #7155

github

480cac
web-flow
Merge 8f7d691f7 into e6bed49aa
Pull Request #7155: chore: remove mocknet network mode

421 of 440 new or added lines in 8 files covered. (95.68%)

10192 existing lines in 154 files now uncovered.

194381 of 226843 relevant lines covered (85.69%)

19529078.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.05
/stacks-node/src/run_loop/mod.rs
1
pub mod boot_nakamoto;
2
pub mod helium;
3
pub mod nakamoto;
4
pub mod neon;
5

6
use clarity::vm::costs::ExecutionCost;
7
use clarity::vm::database::BurnStateDB;
8
use stacks::burnchains::{PoxConstants, Txid};
9
use stacks::chainstate::stacks::db::StacksChainState;
10
use stacks::chainstate::stacks::events::StacksTransactionReceipt;
11
use stacks::chainstate::stacks::{
12
    StacksBlock, TransactionAuth, TransactionPayload, TransactionSpendingCondition,
13
};
14
use stacks_common::types::chainstate::StacksBlockId;
15
use stacks_common::util::vrf::VRFPublicKey;
16

17
use crate::stacks::chainstate::coordinator::BlockEventDispatcher;
18
use crate::stacks::chainstate::stacks::index::ClarityMarfTrieId;
19
use crate::{BitcoinRegtestController, BurnchainTip, ChainTip, EventDispatcher, Tenure};
20

21
macro_rules! info_blue {
22
    ($($arg:tt)*) => ({
23
        eprintln!("\x1b[0;96m{}\x1b[0m", format!($($arg)*));
24
    })
25
}
26

27
#[allow(unused_macros)]
28
macro_rules! info_yellow {
29
    ($($arg:tt)*) => ({
30
        eprintln!("\x1b[0;33m{}\x1b[0m", format!($($arg)*));
31
    })
32
}
33

34
macro_rules! info_green {
35
    ($($arg:tt)*) => ({
36
        eprintln!("\x1b[0;32m{}\x1b[0m", format!($($arg)*));
37
    })
38
}
39

40
#[allow(clippy::type_complexity)]
41
pub struct RunLoopCallbacks {
42
    on_burn_chain_initialized: Option<fn(&mut BitcoinRegtestController)>,
43
    on_new_burn_chain_state: Option<fn(u64, &BurnchainTip, &ChainTip)>,
44
    on_new_stacks_chain_state:
45
        Option<fn(u64, &BurnchainTip, &ChainTip, &mut StacksChainState, &dyn BurnStateDB)>,
46
    on_new_tenure: Option<fn(u64, &BurnchainTip, &ChainTip, &mut Tenure)>,
47
}
48

49
impl Default for RunLoopCallbacks {
50
    fn default() -> Self {
×
51
        Self::new()
×
52
    }
×
53
}
54

55
impl RunLoopCallbacks {
56
    pub fn new() -> RunLoopCallbacks {
291✔
57
        RunLoopCallbacks {
291✔
58
            on_burn_chain_initialized: None,
291✔
59
            on_new_burn_chain_state: None,
291✔
60
            on_new_stacks_chain_state: None,
291✔
61
            on_new_tenure: None,
291✔
62
        }
291✔
63
    }
291✔
64

NEW
65
    pub fn on_burn_chain_initialized(&mut self, callback: fn(&mut BitcoinRegtestController)) {
×
66
        self.on_burn_chain_initialized = Some(callback);
×
67
    }
×
68

69
    pub fn on_new_burn_chain_state(&mut self, callback: fn(u64, &BurnchainTip, &ChainTip)) {
×
70
        self.on_new_burn_chain_state = Some(callback);
×
71
    }
×
72

UNCOV
73
    pub fn on_new_stacks_chain_state(
×
UNCOV
74
        &mut self,
×
UNCOV
75
        callback: fn(u64, &BurnchainTip, &ChainTip, &mut StacksChainState, &dyn BurnStateDB),
×
UNCOV
76
    ) {
×
UNCOV
77
        self.on_new_stacks_chain_state = Some(callback);
×
UNCOV
78
    }
×
79

UNCOV
80
    pub fn on_new_tenure(&mut self, callback: fn(u64, &BurnchainTip, &ChainTip, &mut Tenure)) {
×
UNCOV
81
        self.on_new_tenure = Some(callback);
×
UNCOV
82
    }
×
83

NEW
84
    pub fn invoke_burn_chain_initialized(&self, burnchain: &mut BitcoinRegtestController) {
×
UNCOV
85
        if let Some(cb) = self.on_burn_chain_initialized {
×
86
            cb(burnchain);
×
UNCOV
87
        }
×
UNCOV
88
    }
×
89

UNCOV
90
    pub fn invoke_new_burn_chain_state(
×
UNCOV
91
        &self,
×
UNCOV
92
        round: u64,
×
UNCOV
93
        burnchain_tip: &BurnchainTip,
×
UNCOV
94
        chain_tip: &ChainTip,
×
UNCOV
95
    ) {
×
UNCOV
96
        info_blue!(
×
97
            "Burnchain block #{} ({}) was produced with sortition #{}",
98
            burnchain_tip.block_snapshot.block_height,
99
            burnchain_tip.block_snapshot.burn_header_hash,
100
            burnchain_tip.block_snapshot.sortition_hash
101
        );
102

UNCOV
103
        if let Some(cb) = self.on_new_burn_chain_state {
×
104
            cb(round, burnchain_tip, chain_tip);
×
UNCOV
105
        }
×
UNCOV
106
    }
×
107

UNCOV
108
    pub fn invoke_new_stacks_chain_state(
×
UNCOV
109
        &self,
×
UNCOV
110
        round: u64,
×
UNCOV
111
        burnchain_tip: &BurnchainTip,
×
UNCOV
112
        chain_tip: &ChainTip,
×
UNCOV
113
        chain_state: &mut StacksChainState,
×
UNCOV
114
        burn_dbconn: &dyn BurnStateDB,
×
UNCOV
115
    ) {
×
UNCOV
116
        info_green!(
×
117
            "Stacks block #{} ({}) successfully produced, including {} transactions",
118
            chain_tip.metadata.stacks_block_height,
UNCOV
119
            chain_tip.metadata.index_block_hash(),
×
UNCOV
120
            chain_tip.block.txs.len()
×
121
        );
UNCOV
122
        for tx in chain_tip.block.txs.iter() {
×
UNCOV
123
            match &tx.auth {
×
UNCOV
124
                TransactionAuth::Standard(TransactionSpendingCondition::Singlesig(auth)) => {
×
UNCOV
125
                    println!(
×
126
                        "-> Tx issued by {:?} (fee: {}, nonce: {})",
127
                        auth.signer, auth.tx_fee, auth.nonce
128
                    )
129
                }
130
                _ => println!("-> Tx {:?}", tx.auth),
×
131
            }
UNCOV
132
            match &tx.payload {
×
UNCOV
133
                TransactionPayload::Coinbase(..) => println!("   Coinbase"),
×
UNCOV
134
                TransactionPayload::SmartContract(contract, ..) => println!("   Publish smart contract\n**************************\n{:?}\n**************************", contract.code_body),
×
UNCOV
135
                TransactionPayload::TokenTransfer(recipent, amount, _) => println!("   Transfering {amount} µSTX to {recipent}"),
×
UNCOV
136
                _ => println!("   {:?}", tx.payload)
×
137
            }
138
        }
139

UNCOV
140
        if let Some(cb) = self.on_new_stacks_chain_state {
×
UNCOV
141
            cb(round, burnchain_tip, chain_tip, chain_state, burn_dbconn);
×
UNCOV
142
        }
×
UNCOV
143
    }
×
144

UNCOV
145
    pub fn invoke_new_tenure(
×
UNCOV
146
        &self,
×
UNCOV
147
        round: u64,
×
UNCOV
148
        burnchain_tip: &BurnchainTip,
×
UNCOV
149
        chain_tip: &ChainTip,
×
UNCOV
150
        tenure: &mut Tenure,
×
UNCOV
151
    ) {
×
UNCOV
152
        if let Some(cb) = self.on_new_tenure {
×
UNCOV
153
            cb(round, burnchain_tip, chain_tip, tenure);
×
UNCOV
154
        }
×
UNCOV
155
    }
×
156
}
157

158
#[derive(Clone, Debug, Serialize, Deserialize)]
159
pub struct RegisteredKey {
160
    /// burn block height we intended this VRF key register to land in
161
    pub target_block_height: u64,
162
    /// burn block height it actually landed in
163
    pub block_height: u64,
164
    /// offset in the block's tx list where this operation is
165
    pub op_vtxindex: u32,
166
    /// the public key itself
167
    pub vrf_public_key: VRFPublicKey,
168
    /// `memo` field that was used to register key
169
    /// Could be `Hash160(miner_pubkey)`, or empty
170
    pub memo: Vec<u8>,
171
}
172

173
pub fn announce_boot_receipts(
537✔
174
    event_dispatcher: &EventDispatcher,
537✔
175
    chainstate: &StacksChainState,
537✔
176
    pox_constants: &PoxConstants,
537✔
177
    boot_receipts: &[StacksTransactionReceipt],
537✔
178
) {
537✔
179
    let block_header_0 = StacksChainState::get_genesis_header_info(chainstate.db())
537✔
180
        .expect("FATAL: genesis block header not stored");
537✔
181
    let block_0 = StacksBlock {
537✔
182
        header: block_header_0
537✔
183
            .anchored_header
537✔
184
            .as_stacks_epoch2()
537✔
185
            .expect("FATAL: Expected a Stacks 2.0 Genesis block")
537✔
186
            .clone(),
537✔
187
        txs: vec![],
537✔
188
    };
537✔
189

190
    debug!("Push {} boot receipts", &boot_receipts.len());
537✔
191
    event_dispatcher.announce_block(
537✔
192
        &block_0.into(),
537✔
193
        &block_header_0,
537✔
194
        boot_receipts,
537✔
195
        &StacksBlockId::sentinel(),
537✔
196
        &Txid([0x00; 32]),
537✔
197
        &[],
537✔
198
        None,
537✔
199
        &block_header_0.burn_header_hash,
537✔
200
        block_header_0.burn_header_height,
537✔
201
        block_header_0.burn_header_timestamp,
537✔
202
        &ExecutionCost::ZERO,
537✔
203
        &ExecutionCost::ZERO,
537✔
204
        pox_constants,
537✔
205
        &None,
537✔
206
        &None,
537✔
207
        None,
537✔
208
        0,
209
    );
210
}
537✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc