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 versioned and backwards-compatible server version to block proposal #5803

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

hstove
Copy link
Contributor

@hstove hstove commented Feb 4, 2025

This PR introduces a pattern that we introduced previously to BlockResponse, which allows us to add new fields to the BlockProposal struct without worrying about backwards/forwards issues with serialization.

Critically, this PR only works because there is no place where we deserialize a Vec<BlockProposal> (just like we didn't/don't deserialize Vec<BlockResponse>). The only time we do anything like that is when deserializing StackerDB chunks, but the fact that StackerDbChunk "wraps" these structs is what makes this OK.

The reason we need to add this pattern is because Vec-based deserialization will run into issues, because "old" versions of the code won't fully consume each item's bytes.

This new pattern does consume all of the item's bytes, even if the item was serialized using future code.

@hstove hstove requested review from a team as code owners February 4, 2025 23:02
@hstove hstove linked an issue Feb 4, 2025 that may be closed by this pull request
@hstove hstove requested review from kantai and jferrant February 4, 2025 23:02
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

Looks good, just two minor comments.

/// Serialize the "inner" block response data. Used to determine the bytes length of the serialized block response data
fn inner_consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), CodecError> {
write_next(fd, &self.server_version.as_bytes().to_vec())?;
// write_next(fd, &self.unknown_bytes)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this comment be deleted?

old_block_proposal.reward_cycle,
new_block_proposal.reward_cycle
);
// assert_eq!();
Copy link
Contributor

Choose a reason for hiding this comment

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

extraneous comment

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

Successfully merging this pull request may close these issues.

Add server version string to block proposal metadata
3 participants