Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tenure-height in block messages #661

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ pub fn create_stacks_new_block(
events,
matured_miner_rewards: vec![],
block_time: Some(12345),
tenure_height: Some(1122),
signer_bitvec: Some("000800000001ff".to_owned()),
signer_signature: Some(vec!["1234".to_owned(), "2345".to_owned()]),
cycle_number: Some(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -103,6 +104,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -189,6 +191,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -276,6 +279,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -362,6 +366,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -450,6 +455,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -537,6 +543,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -624,6 +631,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -712,6 +720,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -799,6 +808,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -886,6 +896,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -973,6 +984,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -1060,6 +1072,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down Expand Up @@ -1157,6 +1170,7 @@
"pox_cycle_position": 1033,
"stacks_block_hash": "0x",
"block_time": null,
"tenure_height": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
Expand Down
4 changes: 4 additions & 0 deletions components/chainhook-sdk/src/indexer/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct NewBlock {
pub events: Vec<NewEvent>,
pub matured_miner_rewards: Vec<MaturedMinerReward>,

#[serde(skip_serializing_if = "Option::is_none")]
pub tenure_height: Option<u64>,

#[serde(skip_serializing_if = "Option::is_none")]
pub block_time: Option<u64>,

Expand Down Expand Up @@ -464,6 +467,7 @@ pub fn standardize_stacks_block(
stacks_block_hash: block.block_hash.clone(),

block_time: block.block_time,
tenure_height: block.tenure_height,
// TODO: decode `signer_bitvec` into an easy to use bit string representation (e.g. "01010101")
signer_bitvec: block.signer_bitvec.clone(),
signer_signature: block.signer_signature.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn generate_test_stacks_block(
confirm_microblock_identifier,
stacks_block_hash: String::new(),
block_time: Some(12345),
tenure_height: Some(1122),
signer_bitvec: Some("1010101010101".to_owned()),
signer_signature: Some(vec!["1234".to_owned(), "2345".to_owned()]),
cycle_number: Some(1),
Expand Down
1 change: 1 addition & 0 deletions components/chainhook-types-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ export interface StacksBlockMetadata {
pox_cycle_length: number;

block_time?: number | null;
tenure_height?: number | null;
signer_bitvec?: string | null;
signer_signature?: string[] | null;
cycle_number?: number | null;
Expand Down
3 changes: 3 additions & 0 deletions components/chainhook-types-rs/src/rosetta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ pub struct StacksBlockMetadata {
// Available starting in epoch3, only included in blocks where the pox cycle rewards are first calculated
pub cycle_number: Option<u64>,
pub reward_set: Option<StacksBlockMetadataRewardSet>,

// Available in /new_block messages sent from stacks-core v3.0 and newer
pub tenure_height: Option<u64>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
Expand Down
2 changes: 2 additions & 0 deletions components/client/typescript/src/schemas/stacks/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const StacksEventMetadataSchema = Type.Object({
pox_cycle_position: Type.Integer(),
stacks_block_hash: Type.String(),

tenure_height: Nullable(Type.Integer()),

// Fields included in Nakamoto block headers
block_time: Nullable(Type.Integer()),
signer_bitvec: Nullable(Type.String()),
Expand Down
Loading