Skip to content

Commit d16bd3a

Browse files
authored
Merge pull request #6037 from hstove/feat/parent-burn-block-hash-payload
feat: add parent_burn_block_hash to /new_burn_block payload
2 parents 58cab7d + d317474 commit d16bd3a

File tree

8 files changed

+60
-30
lines changed

8 files changed

+60
-30
lines changed

CHANGELOG.md

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

1616
- Reduce the default `block_rejection_timeout_steps` configuration so that miners will retry faster when blocks fail to reach 70% approved or 30% rejected.
1717
- Added index for `next_ready_nakamoto_block()` which improves block processing performance.
18+
- Added a new field, `parent_burn_block_hash`, to the payload that is included in the `/new_burn_block` event observer payload.
1819

1920
## [3.1.0.0.8]
2021

@@ -30,7 +31,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
3031

3132
- 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))
3233
- 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))
33-
- 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))
34+
- 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))
3435
- 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))
3536
- 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))
3637

docs/event-dispatcher.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ These events are sent to the configured endpoint at two URLs:
2727
This payload includes data related to a newly processed block,
2828
and any events emitted from Stacks transactions during the block.
2929

30-
If the transaction originally comes from the parent microblock stream
30+
If the transaction originally comes from the parent microblock stream
3131
preceding this block, the microblock related fields will be filled in.
3232

3333
If the `raw_tx` field for a particular transaction is "0x00", that indicates
34-
that it is a burnchain operation. A burnchain operation is a transaction that
34+
that it is a burnchain operation. A burnchain operation is a transaction that
3535
is executed on the Stacks network, but was sent through the Bitcoin network.
36-
The Stacks network supports a few specific burnchain operations. You can read
36+
The Stacks network supports a few specific burnchain operations. You can read
3737
more about them [here](https://github.com/stacksgov/sips/blob/main/sips/sip-007/sip-007-stacking-consensus.md#stx-operations-on-bitcoin).
3838
The section below has example json encodings for each of the burnchain operations.
3939

@@ -152,8 +152,8 @@ Example:
152152
}
153153
```
154154

155-
#### Example json values for burnchain operations
156-
- TransferStx
155+
#### Example json values for burnchain operations
156+
- TransferStx
157157
```json
158158
{
159159
"transfer_stx": {
@@ -233,6 +233,8 @@ Example:
233233
```json
234234
{
235235
"burn_block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
236+
"consensus_hash": "0x53c166a709a9abd64a92a57f928a8b26aad08992",
237+
"parent_burn_block_hash": "0x6eaebcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
236238
"burn_block_height": 331,
237239
"reward_recipients": [
238240
{
@@ -258,8 +260,8 @@ Example:
258260

259261
### `POST /new_microblocks`
260262

261-
This payload includes data related to one or more microblocks that are either emmitted by the
262-
node itself, or received through the network.
263+
This payload includes data related to one or more microblocks that are either emmitted by the
264+
node itself, or received through the network.
263265

264266
Example:
265267

@@ -311,9 +313,9 @@ Example:
311313
}
312314
```
313315

314-
* `burn_block_{}` are the stats related to the burn block that is associated with the stacks
316+
* `burn_block_{}` are the stats related to the burn block that is associated with the stacks
315317
block that precedes this microblock stream.
316-
* Each transaction json object includes information about the microblock the transaction was packaged into.
318+
* Each transaction json object includes information about the microblock the transaction was packaged into.
317319

318320
### `POST /new_mempool_tx`
319321

@@ -384,23 +386,23 @@ Example:
384386
"tx_events": [
385387
{
386388
"Success": {
387-
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
388-
"fee": 0,
389-
"execution_cost": {
390-
"write_length": 0,
391-
"write_count": 0,
392-
"read_length": 0,
393-
"read_count": 0,
389+
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
390+
"fee": 0,
391+
"execution_cost": {
392+
"write_length": 0,
393+
"write_count": 0,
394+
"read_length": 0,
395+
"read_count": 0,
394396
"runtime": 0
395-
},
397+
},
396398
"result": {
397-
"ResponseData":
399+
"ResponseData":
398400
{
399401
"committed": true,
400402
"data": true
401403
}
402404
}
403-
}},
405+
}},
404406
{
405407
"ProcessingError": {
406408
"txid": "eef9f46b20fb637bd07ec92ad3ec175a5a4bdf3e8799259fc5b16a272090d4de",
@@ -432,23 +434,23 @@ Example:
432434
"tx_events": [
433435
{
434436
"Success": {
435-
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
436-
"fee": 0,
437-
"execution_cost": {
438-
"write_length": 10,
439-
"write_count": 10,
440-
"read_length": 20,
441-
"read_count": 10,
437+
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
438+
"fee": 0,
439+
"execution_cost": {
440+
"write_length": 10,
441+
"write_count": 10,
442+
"read_length": 20,
443+
"read_count": 10,
442444
"runtime": 1290
443-
},
445+
},
444446
"result": {
445-
"ResponseData":
447+
"ResponseData":
446448
{
447449
"committed": true,
448450
"data": true
449451
}
450452
}
451-
}},
453+
}},
452454
{
453455
"Skipped": {
454456
"txid": "eef9f46b20fb637bd07ec92ad3ec175a5a4bdf3e8799259fc5b16a272090d4de",

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/coordinator/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ impl BlockEventDispatcher for NullEventDispatcher {
446446
_burns: u64,
447447
_slot_holders: Vec<PoxAddress>,
448448
_consensus_hash: &ConsensusHash,
449+
_parent_burn_block_hash: &BurnchainHeaderHash,
449450
) {
450451
}
451452
}

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)