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: add various new nakamoto block fields to /new_block ingestion and StacksPayload #659

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

zone117x
Copy link
Member

@zone117x zone117x commented Oct 22, 2024

Related to #651 -- we need these new fields to make the StackerDB chunk messages useful.

Comment on lines +39 to +52
#[serde(skip_serializing_if = "Option::is_none")]
pub block_time: Option<u64>,

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

#[serde(skip_serializing_if = "Option::is_none")]
pub signer_signature: Option<Vec<String>>,

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

#[serde(skip_serializing_if = "Option::is_none")]
pub reward_set: Option<RewardSet>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stacks-core isn't very consistent with some of these fields being optional (undefined) vs nullable. So goal here is to just support either case during deserialization.

Comment on lines +117 to +139

// Fields included in Nakamoto block headers
pub block_time: Option<u64>,
pub signer_bitvec: Option<String>,
pub signer_signature: Option<Vec<String>>,

// 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>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct StacksBlockMetadataRewardSet {
pub pox_ustx_threshold: String,
pub rewarded_addresses: Vec<String>,
pub signers: Option<Vec<StacksBlockMetadataRewardSetSigner>>,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct StacksBlockMetadataRewardSetSigner {
pub signing_key: String,
pub weight: u32,
pub stacked_amt: String,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm simply re-using the same structure as the /new_block event for this payload so for now it looks like code duplication, however, it gives us room to restructure/rename/re-type these as needed.

Comment on lines +467 to +468
// TODO: decode `signer_bitvec` into an easy to use bit string representation (e.g. "01010101")
signer_bitvec: block.signer_bitvec.clone(),
Copy link
Member Author

@zone117x zone117x Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelcr we get these from /new_block in consesus-serialize format, e.g. 0x000800000001ff. Is there existing code I can call to decode this? We should deliver it in the payloads in a more typical (and easier to use) bitfield format (a string of 1 and/or 0).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so, it's probably included in the update we did to the stacks-codec here hirosystems/clarinet#1524

Copy link
Collaborator

@rafaelcr rafaelcr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks @zone117x

@zone117x zone117x marked this pull request as ready for review October 22, 2024 14:47
@zone117x zone117x merged commit f48cda5 into develop Oct 22, 2024
9 checks passed
@zone117x zone117x deleted the feat/update-new-block branch October 22, 2024 15:22
github-actions bot pushed a commit that referenced this pull request Oct 25, 2024
## [1.9.0-stacks-signers.1](v1.8.0...v1.9.0-stacks-signers.1) (2024-10-25)

### Features

* add various new nakamoto block fields to `/new_block` ingestion and `StacksPayload` ([#659](#659)) ([f48cda5](f48cda5))
* include recovered signer pubkeys in new block payload ([#662](#662)) ([b5ad4ba](b5ad4ba))
* include signer messages in Stacks predicate payloads ([#656](#656)) ([aee14bc](aee14bc))
* parse `/stackerdb_chunks` Stacks node event ([#653](#653)) ([e44d84a](e44d84a))
* store signer messages in local sqlite database ([#664](#664)) ([d12acd9](d12acd9))
* support tenure-height in block messages ([#661](#661)) ([99e5a61](99e5a61))
* **ts-client:** add persisted predicates and periodic health check ([#658](#658)) ([535226a](535226a))
* **ts-client:** add signer messages to stacks payloads ([#657](#657)) ([ff66bb2](ff66bb2))

### Bug Fixes

* add a configurable max timeout for outgoing predicate payload requests ([#642](#642)) ([6c1dfa9](6c1dfa9)), closes [#643](#643)
* increase stacks event server body size limit to 500MB ([#660](#660)) ([21234c9](21234c9))
* return 500 status code to Stacks node when event ingestion fails ([#648](#648)) ([63c753c](63c753c)), closes [#646](#646)
* signer pubkey calculation ([#665](#665)) ([cc93873](cc93873))
* update SignerMessage deserializing ([#663](#663)) ([71364c1](71364c1))
* validate ts client predicates before registering ([#639](#639)) ([2d08f72](2d08f72))
Copy link

🎉 This PR is included in version 1.9.0-stacks-signers.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants