@@ -194,6 +194,7 @@ use stacks::net::stackerdb::{StackerDBConfig, StackerDBSync, StackerDBs, MINER_S
194
194
use stacks:: net:: {
195
195
Error as NetError , NetworkResult , PeerNetworkComms , RPCHandlerArgs , ServiceFlags ,
196
196
} ;
197
+ use stacks:: types:: StacksEpoch ;
197
198
use stacks:: util_lib:: strings:: { UrlString , VecDisplay } ;
198
199
use stacks:: { monitoring, version_string} ;
199
200
use stacks_common:: codec:: StacksMessageCodec ;
@@ -2273,12 +2274,20 @@ impl BlockMinerThread {
2273
2274
let burn_db_path = self . config . get_burn_db_file_path ( ) ;
2274
2275
let burn_db = SortitionDB :: open ( & burn_db_path, false , self . burnchain . pox_constants . clone ( ) )
2275
2276
. expect ( "FATAL: could not open sortition DB" ) ;
2276
- let p2p_net = StacksNode :: setup_peer_network (
2277
- & self . config ,
2278
- & self . config . atlas ,
2279
- self . burnchain . clone ( ) ,
2280
- ) ;
2281
- let epoch_id = p2p_net. get_current_epoch ( ) . epoch_id ;
2277
+ let epochs = SortitionDB :: get_stacks_epochs ( burn_db. conn ( ) )
2278
+ . expect ( "Error while loading stacks epochs" ) ;
2279
+ let epoch_index = StacksEpoch :: find_epoch ( & epochs, self . burn_block . block_height )
2280
+ . unwrap_or_else ( || {
2281
+ panic ! (
2282
+ "BUG: block {} is not in a known epoch" ,
2283
+ self . burn_block. block_height
2284
+ )
2285
+ } ) ;
2286
+ let epoch_id = epochs
2287
+ . get ( epoch_index)
2288
+ . expect ( "BUG: no epoch at found index" )
2289
+ . epoch_id ;
2290
+
2282
2291
if epoch_id != StacksEpochId :: Epoch25 {
2283
2292
debug ! ( "Mock miner messaging is disabled for non-epoch 2.5 blocks." ;
2284
2293
"epoch_id" => epoch_id. to_string( )
@@ -2300,7 +2309,7 @@ impl BlockMinerThread {
2300
2309
else {
2301
2310
continue ;
2302
2311
} ;
2303
- if miner_message. tenure_burn_block_height == self . burn_block . block_height {
2312
+ if miner_message. peer_info . burn_block_height == self . burn_block . block_height {
2304
2313
debug ! (
2305
2314
"Already sent mock miner message for tenure burn block height {:?}" ,
2306
2315
self . burn_block. block_height
@@ -2350,11 +2359,11 @@ impl BlockMinerThread {
2350
2359
. or ( option_env ! ( "CARGO_PKG_VERSION" ) )
2351
2360
. unwrap_or ( "0.0.0.0" ) ,
2352
2361
) ;
2353
- let stacks_tip_height = p2p_net . stacks_tip . height ;
2354
- let stacks_tip = p2p_net . stacks_tip . block_hash . clone ( ) ;
2355
- let stacks_tip_consensus_hash = p2p_net . stacks_tip . consensus_hash . clone ( ) ;
2356
- let pox_consensus = p2p_net . burnchain_tip . consensus_hash . clone ( ) ;
2357
- let burn_block_height = p2p_net . chain_view . burn_block_height ;
2362
+ let stacks_tip_height = self . burn_block . canonical_stacks_tip_height ;
2363
+ let stacks_tip = self . burn_block . canonical_stacks_tip_hash ;
2364
+ let stacks_tip_consensus_hash = self . burn_block . canonical_stacks_tip_consensus_hash ;
2365
+ let pox_consensus = self . burn_block . consensus_hash ;
2366
+ let burn_block_height = self . burn_block . block_height ;
2358
2367
2359
2368
let peer_info = PeerInfo {
2360
2369
burn_block_height,
@@ -2369,10 +2378,9 @@ impl BlockMinerThread {
2369
2378
peer_info,
2370
2379
chain_id : self . config . burnchain . chain_id ,
2371
2380
mock_signatures,
2372
- tenure_burn_block_height : self . burn_block . block_height ,
2373
2381
} ;
2374
2382
2375
- info ! ( "Sending mock miner message in response to mock signatures for burn block {:?}" , message. tenure_burn_block_height ;
2383
+ info ! ( "Sending mock miner message in response to mock signatures for burn block {:?}" , message. peer_info . burn_block_height ;
2376
2384
"stacks_tip_consensus_hash" => ?message. peer_info. stacks_tip_consensus_hash. clone( ) ,
2377
2385
"stacks_tip" => ?message. peer_info. stacks_tip. clone( ) ,
2378
2386
"peer_burn_block_height" => message. peer_info. burn_block_height,
0 commit comments