diff --git a/components/chainhook-cli/src/service/tests/helpers/mock_stacks_node.rs b/components/chainhook-cli/src/service/tests/helpers/mock_stacks_node.rs index 7cc7ff22f..883853689 100644 --- a/components/chainhook-cli/src/service/tests/helpers/mock_stacks_node.rs +++ b/components/chainhook-cli/src/service/tests/helpers/mock_stacks_node.rs @@ -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), diff --git a/components/chainhook-sdk/src/chainhooks/tests/fixtures/stacks/testnet/occurrence.json b/components/chainhook-sdk/src/chainhooks/tests/fixtures/stacks/testnet/occurrence.json index 9fb468e6a..0651df08c 100644 --- a/components/chainhook-sdk/src/chainhooks/tests/fixtures/stacks/testnet/occurrence.json +++ b/components/chainhook-sdk/src/chainhooks/tests/fixtures/stacks/testnet/occurrence.json @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/components/chainhook-sdk/src/indexer/stacks/mod.rs b/components/chainhook-sdk/src/indexer/stacks/mod.rs index 005cd10c0..2e54a7992 100644 --- a/components/chainhook-sdk/src/indexer/stacks/mod.rs +++ b/components/chainhook-sdk/src/indexer/stacks/mod.rs @@ -36,6 +36,9 @@ pub struct NewBlock { pub events: Vec, pub matured_miner_rewards: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub tenure_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub block_time: Option, @@ -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(), diff --git a/components/chainhook-sdk/src/indexer/tests/helpers/stacks_blocks.rs b/components/chainhook-sdk/src/indexer/tests/helpers/stacks_blocks.rs index d41d9cb47..71123b9fe 100644 --- a/components/chainhook-sdk/src/indexer/tests/helpers/stacks_blocks.rs +++ b/components/chainhook-sdk/src/indexer/tests/helpers/stacks_blocks.rs @@ -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), diff --git a/components/chainhook-types-js/src/index.ts b/components/chainhook-types-js/src/index.ts index dc4473582..8f6251d32 100644 --- a/components/chainhook-types-js/src/index.ts +++ b/components/chainhook-types-js/src/index.ts @@ -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; diff --git a/components/chainhook-types-rs/src/rosetta.rs b/components/chainhook-types-rs/src/rosetta.rs index 6e3d6750c..369eaa424 100644 --- a/components/chainhook-types-rs/src/rosetta.rs +++ b/components/chainhook-types-rs/src/rosetta.rs @@ -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, pub reward_set: Option, + + // Available in /new_block messages sent from stacks-core v3.0 and newer + pub tenure_height: Option, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] diff --git a/components/client/typescript/src/schemas/stacks/payload.ts b/components/client/typescript/src/schemas/stacks/payload.ts index cc1653e1e..4b2d5f6b8 100644 --- a/components/client/typescript/src/schemas/stacks/payload.ts +++ b/components/client/typescript/src/schemas/stacks/payload.ts @@ -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()),