mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-24 03:45:38 +08:00
tests and documentation
This commit is contained in:
@@ -67,10 +67,39 @@ Example:
|
||||
"tx_index": 1,
|
||||
"txid": "0x738e4d44636023efa08374033428e44eca490582bd39a6e61f3b6cf749b4214c"
|
||||
}
|
||||
]
|
||||
],
|
||||
"matured_miner_rewards": [
|
||||
{
|
||||
"recipient": "ST31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZZ239N96",
|
||||
"coinbase_amount": "1000",
|
||||
"tx_fees_anchored_shared": "800",
|
||||
"tx_fees_anchored_exclusive": "0",
|
||||
"tx_fees_streamed_confirmed": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `POST /new_burn_block`
|
||||
|
||||
This payload includes information about burn blocks as their sortitions are processed.
|
||||
In the event of PoX forks, a `new_burn_block` event may be triggered for a burn block
|
||||
previously processed.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"burn_block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
|
||||
"reward_recipients": [
|
||||
{
|
||||
"recipient": "1C56LYirKa3PFXFsvhSESgDy2acEHVAEt6",
|
||||
"amount": 5000
|
||||
}
|
||||
],
|
||||
"burn_amount": 12000
|
||||
}
|
||||
```
|
||||
|
||||
### `POST /new_mempool_tx`
|
||||
|
||||
|
||||
@@ -515,6 +515,10 @@ impl<'a, T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProvider>
|
||||
for unprocessed_block in sortitions_to_process.drain(..) {
|
||||
let BurnchainBlockData { header, ops } = unprocessed_block;
|
||||
|
||||
if let Some(dispatcher) = self.dispatcher {
|
||||
dispatcher_announce_burn_ops(dispatcher, &header, &ops);
|
||||
}
|
||||
|
||||
let sortition_tip_snapshot = SortitionDB::get_block_snapshot(
|
||||
self.sortition_db.conn(),
|
||||
&canonical_sortition_tip,
|
||||
|
||||
@@ -21,7 +21,7 @@ use stacks::chainstate::stacks::{
|
||||
db::accounts::MinerReward, StacksAddress, StacksBlockId, StacksTransaction,
|
||||
};
|
||||
use stacks::net::StacksMessageCodec;
|
||||
use stacks::util::hash::{bytes_to_hex, to_hex};
|
||||
use stacks::util::hash::bytes_to_hex;
|
||||
use stacks::vm::analysis::contract_interface_builder::build_contract_interface;
|
||||
use stacks::vm::types::{AssetIdentifier, QualifiedContractIdentifier, Value};
|
||||
|
||||
@@ -131,7 +131,7 @@ impl EventObserver {
|
||||
.collect();
|
||||
|
||||
json!({
|
||||
"burn_block_hash": burn_block.to_string(),
|
||||
"burn_block_hash": format!("0x{}", burn_block),
|
||||
"reward_recipients": serde_json::Value::Array(reward_recipients),
|
||||
"burn_amount": burns
|
||||
})
|
||||
@@ -416,15 +416,17 @@ impl EventDispatcher {
|
||||
}
|
||||
|
||||
if dispatch_matrix.len() > 0 {
|
||||
let mature_rewards_vec = mature_rewards.iter()
|
||||
.map(|reward|
|
||||
json!({
|
||||
"recipient": reward.address.to_string(),
|
||||
"coinbase_amount": format!("0x{}", to_hex(&reward.coinbase.to_be_bytes())),
|
||||
"tx_fees_anchored_shared": format!("0x{}", to_hex(&reward.tx_fees_anchored_shared.to_be_bytes())),
|
||||
"tx_fees_anchored_exclusive": format!("0x{}", to_hex(&reward.tx_fees_anchored_exclusive.to_be_bytes())),
|
||||
"tx_fees_streamed_confirmed": format!("0x{}", to_hex(&reward.tx_fees_streamed_confirmed.to_be_bytes()))
|
||||
}))
|
||||
let mature_rewards_vec = mature_rewards
|
||||
.iter()
|
||||
.map(|reward| {
|
||||
json!({
|
||||
"recipient": reward.address.to_string(),
|
||||
"coinbase_amount": reward.coinbase.to_string(),
|
||||
"tx_fees_anchored_shared": reward.tx_fees_anchored_shared.to_string(),
|
||||
"tx_fees_anchored_exclusive": reward.tx_fees_anchored_exclusive.to_string(),
|
||||
"tx_fees_streamed_confirmed": reward.tx_fees_streamed_confirmed.to_string()
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let mature_rewards = serde_json::Value::Array(mature_rewards_vec);
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@ mod test_observer {
|
||||
NEW_BLOCKS.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
pub fn get_burn_blocks() -> Vec<serde_json::Value> {
|
||||
BURN_BLOCKS.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
async fn serve() {
|
||||
let new_blocks = warp::path!("new_block")
|
||||
.and(warp::post())
|
||||
@@ -488,6 +492,20 @@ fn microblock_integration_test() {
|
||||
);
|
||||
assert_eq!(blocks_observed.len() as u64, tip_info.stacks_tip_height);
|
||||
|
||||
let burn_blocks_observed = test_observer::get_burn_blocks();
|
||||
let burn_blocks_with_burns: Vec<_> = burn_blocks_observed
|
||||
.into_iter()
|
||||
.filter(|block| block.get("burn_amount").unwrap().as_u64().unwrap() > 0)
|
||||
.collect();
|
||||
assert!(
|
||||
burn_blocks_with_burns.len() >= 3,
|
||||
"Burn block sortitions {} should be >= 3",
|
||||
burn_blocks_with_burns.len()
|
||||
);
|
||||
for burn_block in burn_blocks_with_burns {
|
||||
eprintln!("{}", burn_block);
|
||||
}
|
||||
|
||||
let mut prior = None;
|
||||
for block in blocks_observed.iter() {
|
||||
let parent_index_hash = block
|
||||
@@ -508,8 +526,6 @@ fn microblock_integration_test() {
|
||||
|
||||
// make sure we have a burn_block_hash, burn_block_height and miner_txid
|
||||
|
||||
eprintln!("{}", block);
|
||||
|
||||
let _burn_block_hash = block.get("burn_block_hash").unwrap().as_str().unwrap();
|
||||
|
||||
let _burn_block_height = block.get("burn_block_height").unwrap().as_u64().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user