Skip to content

Commit 9c44080

Browse files
committed
feat: add parent_burn_block_hash to /new_burn_block payload
1 parent 5b70d4f commit 9c44080

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1010
### Changed
1111

1212
- Reduce the default `block_rejection_timeout_steps` configuration so that miners will retry faster when blocks fail to reach 70% approved or 30% rejected.
13+
- Added a new field, `parent_burn_block_hash`, to the payload that is included in the `/new_burn_block` event observer payload.
1314

1415
## [3.1.0.0.8]
1516

@@ -25,7 +26,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2526

2627
- When a miner times out waiting for signatures, it will re-propose the same block instead of building a new block ([#5877](https://github.com/stacks-network/stacks-core/pull/5877))
2728
- Improve tenure downloader trace verbosity applying proper logging level depending on the tenure state ("debug" if unconfirmed, "info" otherwise) ([#5871](https://github.com/stacks-network/stacks-core/issues/5871))
28-
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
29+
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
2930
- Deprecated the `wait_on_interim_blocks` option in the miner config file. This option is no longer needed, as the miner will always wait for interim blocks to be processed before mining a new block. To wait extra time in between blocks, use the `min_time_between_blocks_ms` option instead. ([#5979](https://github.com/stacks-network/stacks-core/pull/5979))
3031
- Added `empty_mempool_sleep_ms` to the miner config file to control the time to wait in between mining attempts when the mempool is empty. If not set, the default sleep time is 2.5s. ([#5997](https://github.com/stacks-network/stacks-core/pull/5997))
3132

stackslib/src/chainstate/coordinator/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub trait BlockEventDispatcher {
195195
burns: u64,
196196
reward_recipients: Vec<PoxAddress>,
197197
consensus_hash: &ConsensusHash,
198+
parent_burn_block_hash: &BurnchainHeaderHash,
198199
);
199200
}
200201

@@ -964,6 +965,7 @@ pub fn dispatcher_announce_burn_ops<T: BlockEventDispatcher>(
964965
paid_rewards.burns,
965966
recipients,
966967
consensus_hash,
968+
&burn_header.parent_block_hash,
967969
);
968970
}
969971

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl BlockEventDispatcher for DummyEventDispatcher {
205205
_burns: u64,
206206
_slot_holders: Vec<PoxAddress>,
207207
_consensus_hash: &ConsensusHash,
208+
_parent_burn_block_hash: &BurnchainHeaderHash,
208209
) {
209210
error!("We should never try to announce to the dummy dispatcher");
210211
panic!();

stackslib/src/net/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,6 +2576,7 @@ pub mod test {
25762576
_burns: u64,
25772577
_reward_recipients: Vec<PoxAddress>,
25782578
_consensus_hash: &ConsensusHash,
2579+
_parent_burn_block_hash: &BurnchainHeaderHash,
25792580
) {
25802581
// pass
25812582
}

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ impl EventObserver {
547547
burns: u64,
548548
slot_holders: Vec<PoxAddress>,
549549
consensus_hash: &ConsensusHash,
550+
parent_burn_block_hash: &BurnchainHeaderHash,
550551
) -> serde_json::Value {
551552
let reward_recipients = rewards
552553
.into_iter()
@@ -570,6 +571,7 @@ impl EventObserver {
570571
"reward_slot_holders": serde_json::Value::Array(reward_slot_holders),
571572
"burn_amount": burns,
572573
"consensus_hash": format!("0x{consensus_hash}"),
574+
"parent_burn_block_hash": format!("0x{parent_burn_block_hash}"),
573575
})
574576
}
575577

@@ -1062,6 +1064,7 @@ impl BlockEventDispatcher for EventDispatcher {
10621064
burns: u64,
10631065
recipient_info: Vec<PoxAddress>,
10641066
consensus_hash: &ConsensusHash,
1067+
parent_burn_block_hash: &BurnchainHeaderHash,
10651068
) {
10661069
self.process_burn_block(
10671070
burn_block,
@@ -1070,6 +1073,7 @@ impl BlockEventDispatcher for EventDispatcher {
10701073
burns,
10711074
recipient_info,
10721075
consensus_hash,
1076+
parent_burn_block_hash,
10731077
)
10741078
}
10751079
}
@@ -1114,6 +1118,7 @@ impl EventDispatcher {
11141118
burns: u64,
11151119
recipient_info: Vec<PoxAddress>,
11161120
consensus_hash: &ConsensusHash,
1121+
parent_burn_block_hash: &BurnchainHeaderHash,
11171122
) {
11181123
// lazily assemble payload only if we have observers
11191124
let interested_observers = self.filter_observers(&self.burn_block_observers_lookup, true);
@@ -1128,6 +1133,7 @@ impl EventDispatcher {
11281133
burns,
11291134
recipient_info,
11301135
consensus_hash,
1136+
parent_burn_block_hash,
11311137
);
11321138

11331139
for observer in interested_observers.iter() {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10625,12 +10625,28 @@ fn consensus_hash_event_dispatcher() {
1062510625
let expected_consensus_hash = format!("0x{}", tip.consensus_hash);
1062610626

1062710627
let burn_blocks = test_observer::get_burn_blocks();
10628+
let parent_burn_block = burn_blocks.get(burn_blocks.len() - 2).unwrap();
1062810629
let burn_block = burn_blocks.last().unwrap();
1062910630
assert_eq!(
1063010631
burn_block.get("consensus_hash").unwrap().as_str().unwrap(),
1063110632
expected_consensus_hash
1063210633
);
1063310634

10635+
let parent_burn_block_hash = parent_burn_block
10636+
.get("burn_block_hash")
10637+
.unwrap()
10638+
.as_str()
10639+
.unwrap();
10640+
10641+
assert_eq!(
10642+
burn_block
10643+
.get("parent_burn_block_hash")
10644+
.unwrap()
10645+
.as_str()
10646+
.unwrap(),
10647+
parent_burn_block_hash
10648+
);
10649+
1063410650
let stacks_blocks = test_observer::get_blocks();
1063510651
for block in stacks_blocks.iter() {
1063610652
if block.get("block_height").unwrap().as_u64().unwrap() == tip.stacks_block_height {

0 commit comments

Comments
 (0)