Skip to content

Commit 1637273

Browse files
authored
Merge branch 'develop' into fix/5193-stackerdb-decoherence
2 parents 9391403 + 4dc2902 commit 1637273

File tree

8 files changed

+28
-0
lines changed

8 files changed

+28
-0
lines changed

stackslib/src/chainstate/coordinator/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub trait BlockEventDispatcher {
179179
pox_constants: &PoxConstants,
180180
reward_set_data: &Option<RewardSetData>,
181181
signer_bitvec: &Option<BitVec<4000>>,
182+
block_timestamp: Option<u64>,
182183
);
183184

184185
/// called whenever a burn block is about to be

stackslib/src/chainstate/coordinator/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ impl BlockEventDispatcher for NullEventDispatcher {
430430
_pox_constants: &PoxConstants,
431431
_reward_set_data: &Option<RewardSetData>,
432432
_signer_bitvec: &Option<BitVec<4000>>,
433+
_block_timestamp: Option<u64>,
433434
) {
434435
assert!(
435436
false,

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,8 @@ impl NakamotoChainState {
20482048

20492049
let signer_bitvec = (&next_ready_block).header.pox_treatment.clone();
20502050

2051+
let block_timestamp = next_ready_block.header.timestamp;
2052+
20512053
// set stacks block accepted
20522054
let mut sort_tx = sort_db.tx_handle_begin(canonical_sortition_tip)?;
20532055
sort_tx.set_stacks_block_accepted(
@@ -2093,6 +2095,7 @@ impl NakamotoChainState {
20932095
&pox_constants,
20942096
&reward_set_data,
20952097
&Some(signer_bitvec),
2098+
Some(block_timestamp),
20962099
);
20972100
}
20982101

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl BlockEventDispatcher for DummyEventDispatcher {
190190
_pox_constants: &PoxConstants,
191191
_reward_set_data: &Option<RewardSetData>,
192192
_signer_bitvec: &Option<BitVec<4000>>,
193+
_block_timestamp: Option<u64>,
193194
) {
194195
assert!(
195196
false,
@@ -6409,6 +6410,7 @@ impl StacksChainState {
64096410
&pox_constants,
64106411
&reward_set_data,
64116412
&None,
6413+
None,
64126414
);
64136415
}
64146416

stackslib/src/net/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,7 @@ pub mod test {
20342034
pox_constants: &PoxConstants,
20352035
reward_set_data: &Option<RewardSetData>,
20362036
_signer_bitvec: &Option<BitVec<4000>>,
2037+
_block_timestamp: Option<u64>,
20372038
) {
20382039
self.blocks.lock().unwrap().push(TestEventObserverBlock {
20392040
block: block.clone(),

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ impl EventObserver {
594594
pox_constants: &PoxConstants,
595595
reward_set_data: &Option<RewardSetData>,
596596
signer_bitvec_opt: &Option<BitVec<4000>>,
597+
block_timestamp: Option<u64>,
597598
) -> serde_json::Value {
598599
// Serialize events to JSON
599600
let serialized_events: Vec<serde_json::Value> = filtered_events
@@ -631,6 +632,7 @@ impl EventObserver {
631632
let mut payload = json!({
632633
"block_hash": format!("0x{}", block.block_hash),
633634
"block_height": metadata.stacks_block_height,
635+
"block_time": block_timestamp,
634636
"burn_block_hash": format!("0x{}", metadata.burn_header_hash),
635637
"burn_block_height": metadata.burn_header_height,
636638
"miner_txid": format!("0x{}", winner_txid),
@@ -852,6 +854,7 @@ impl BlockEventDispatcher for EventDispatcher {
852854
pox_constants: &PoxConstants,
853855
reward_set_data: &Option<RewardSetData>,
854856
signer_bitvec: &Option<BitVec<4000>>,
857+
block_timestamp: Option<u64>,
855858
) {
856859
self.process_chain_tip(
857860
block,
@@ -869,6 +872,7 @@ impl BlockEventDispatcher for EventDispatcher {
869872
pox_constants,
870873
reward_set_data,
871874
signer_bitvec,
875+
block_timestamp,
872876
);
873877
}
874878

@@ -1051,6 +1055,7 @@ impl EventDispatcher {
10511055
pox_constants: &PoxConstants,
10521056
reward_set_data: &Option<RewardSetData>,
10531057
signer_bitvec: &Option<BitVec<4000>>,
1058+
block_timestamp: Option<u64>,
10541059
) {
10551060
let all_receipts = receipts.to_owned();
10561061
let (dispatch_matrix, events) = self.create_dispatch_matrix_and_event_vector(&all_receipts);
@@ -1102,6 +1107,7 @@ impl EventDispatcher {
11021107
pox_constants,
11031108
reward_set_data,
11041109
signer_bitvec,
1110+
block_timestamp,
11051111
);
11061112

11071113
// Send payload
@@ -1508,6 +1514,7 @@ mod test {
15081514
let mblock_confirmed_consumed = ExecutionCost::zero();
15091515
let pox_constants = PoxConstants::testnet_default();
15101516
let signer_bitvec = BitVec::zeros(2).expect("Failed to create BitVec with length 2");
1517+
let block_timestamp = Some(123456);
15111518

15121519
let payload = observer.make_new_block_processed_payload(
15131520
filtered_events,
@@ -1525,6 +1532,7 @@ mod test {
15251532
&pox_constants,
15261533
&None,
15271534
&Some(signer_bitvec.clone()),
1535+
block_timestamp,
15281536
);
15291537
assert_eq!(
15301538
payload
@@ -1576,6 +1584,7 @@ mod test {
15761584
let mblock_confirmed_consumed = ExecutionCost::zero();
15771585
let pox_constants = PoxConstants::testnet_default();
15781586
let signer_bitvec = BitVec::zeros(2).expect("Failed to create BitVec with length 2");
1587+
let block_timestamp = Some(123456);
15791588

15801589
let payload = observer.make_new_block_processed_payload(
15811590
filtered_events,
@@ -1593,6 +1602,7 @@ mod test {
15931602
&pox_constants,
15941603
&None,
15951604
&Some(signer_bitvec.clone()),
1605+
block_timestamp,
15961606
);
15971607

15981608
let event_signer_signature = payload

testnet/stacks-node/src/run_loop/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,6 @@ pub fn announce_boot_receipts(
197197
pox_constants,
198198
&None,
199199
&None,
200+
None,
200201
);
201202
}

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,9 +2272,18 @@ fn correct_burn_outs() {
22722272
"Blocks should be sorted by cycle number already"
22732273
);
22742274

2275+
let mut last_block_time = None;
22752276
for block in new_blocks_with_reward_set.iter() {
22762277
let cycle_number = block["cycle_number"].as_u64().unwrap();
22772278
let reward_set = block["reward_set"].as_object().unwrap();
2279+
if let Some(block_time) = block["block_time"].as_u64() {
2280+
if let Some(last) = last_block_time {
2281+
assert!(block_time > last, "Block times should be increasing");
2282+
}
2283+
last_block_time = Some(block_time);
2284+
}
2285+
let cycle_number = block["cycle_number"].as_u64().unwrap();
2286+
let reward_set = block["reward_set"].as_object().unwrap();
22782287

22792288
if cycle_number < first_epoch_3_cycle {
22802289
assert!(

0 commit comments

Comments
 (0)