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

Add preconfirmation gossip messages #2726

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

MitchTurner
Copy link
Member

@MitchTurner MitchTurner commented Feb 18, 2025

Linked Issues/PRs

Closes #2738

Description

This is part of the greater tx confirmation work. This will enable the block producer to gossip a batch of signed transactions around the network for the senders of those transactions to receive.

In an attempt to cleanup the P2P code, some of the tests were moved to their own files (this makes reviewing slightly more difficult, so I've marked the new tests with comments in those refactored test suites).

TODO:

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@MitchTurner MitchTurner self-assigned this Feb 19, 2025
}

#[tokio::test]
async fn run__gossip_message_from_p2p_service_is_broadcasted__tx_confirmations() {
Copy link
Member Author

@MitchTurner MitchTurner Feb 19, 2025

Choose a reason for hiding this comment

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

This is the only new test in this file. The rest were just copied over during the refactor.


#[tokio::test]
#[instrument]
async fn gossipsub_broadcast_tx_with_reject__tx_confirmations() {
Copy link
Member Author

Choose a reason for hiding this comment

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

New test.


#[tokio::test]
#[instrument]
async fn gossipsub_broadcast_tx_with_accept__tx_confirmations() {
Copy link
Member Author

Choose a reason for hiding this comment

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

New test.


// TODO: Move me before tests that use this function
/// Reusable helper function for Broadcasting Gossipsub requests
async fn gossipsub_broadcast(
Copy link
Member Author

Choose a reason for hiding this comment

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

This method was updated to accept the new GossipsubBroadcastRequest::Confirmations variant.

Introduced check_message_matches_request as part of that (before it was hardcoded to look for a specific value).

@MitchTurner MitchTurner marked this pull request as ready for review February 20, 2025 22:07
@MitchTurner MitchTurner changed the title Add TxConfirmation gossip messages Add preconfirmation gossip messages Feb 20, 2025
@MitchTurner MitchTurner requested a review from netrome as a code owner February 21, 2025 18:32
@MitchTurner MitchTurner mentioned this pull request Feb 23, 2025
1 task
Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Just a nit and a question, otherwise looks good to me.

#[cfg(test)]
mod tests {
#![allow(non_snake_case)]
#![allow(clippy::cast_possible_truncation)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps unrelated to this PR but why do we need this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, it was already here. In general, I am in favor of allowing panickable arithmetic and dangerous casts in tests, for the same reason I'm okay with unwrap in tests.

I'm not sure specifically what this is enabling in the tests, but I'd encourage this pattern.

Comment on lines +90 to +91
/// Seal
pub signature: Signature,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd suggest renaming the signature field to seal or renaming the type to Signed so the naming is more consistent. There's also a "todo" to do the same renaming in the sibling struct in the blockchain/consensus.rs module.

Suggested change
/// Seal
pub signature: Signature,
/// Seal
pub seal: Signature,

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 prefer Signature. Seal is ambiguous IMO.

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.

Transaction Preconfirmation Gossip Message
2 participants