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 gossipsub message validation #694

Merged
merged 26 commits into from
Oct 19, 2022

Conversation

leviathanbeak
Copy link
Contributor

Closes #679

In this PR we introduce message validation for our gossipsub messages.

The flow goes like this:

  • on new GossipsubMessage received
  • check if the format is correct
  • if the format is correct, the message is propagated to the modules interested in it
  • there it's checked if is valid
  • once checked for validity, the module responds with the message validity
  • and that is reported to the Gossipsub protocol

In this PR I have also removed unnecessary loop from p2p service's next_event.

@leviathanbeak leviathanbeak self-assigned this Oct 12, 2022
@leviathanbeak leviathanbeak requested a review from a team October 12, 2022 18:11
fuel-p2p/src/service.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@freesig freesig left a comment

Choose a reason for hiding this comment

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

Overall looks good. I wonder about the NetworkData trait though. Also should there be a test of this new behavior?

Comment on lines +107 to +109
pub trait NetworkData<T>: Debug + Send {
fn take_data(&mut self) -> Option<T>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub trait NetworkData<T>: Debug + Send {
fn take_data(&mut self) -> Option<T>;
}
pub trait NetworkData<T>: Debug + Send {
type Metadata;
fn take_data(self) -> (Self::Metadata, T);
}

I'm thinking it would be better to actually split the type so that we don't have to handle the option?

Copy link
Member

Choose a reason for hiding this comment

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

hmm maybe we can defer this to a followup task? Ideally in a way that wouldn't require users of this trait to know or care about the concrete type for metadata.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did raise this concern in the architecture PR but was told it was an implementation detail. Happy to do a follow up though

Copy link
Member

Choose a reason for hiding this comment

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

yeah I think it's just a matter of having a fully fleshed out proposal of this actually working

fuel-txpool/src/service.rs Show resolved Hide resolved
Voxelot
Voxelot previously approved these changes Oct 18, 2022
@freesig freesig self-requested a review October 19, 2022 04:32
@freesig freesig dismissed their stale review October 19, 2022 04:32

no need to block for network trait

@leviathanbeak leviathanbeak merged commit e1f43d1 into master Oct 19, 2022
@leviathanbeak leviathanbeak deleted the leviathanbeak/gossipsub_validate_msg branch October 19, 2022 18:17
MujkicA pushed a commit that referenced this pull request Oct 25, 2022
* remove loop from next_event

* initial work

* more work

* trying to use an alternative approach to message id cache

* quick break

* fix sized issue

* finalize gossipsub validation

* remove unused

* update fast_gossip_message_id

* check MessageId calculation

* cleanup network orchestrator

* move types to p2p for reuse

* add consensus gossip data instead

* add serde only feature

* update with suggestions

* remove unused

* use gossipsub_config

* hash complete messages

* use gossipsub config and its builder

* import serde only as feature

* use test-helpers from fuel-core-interfaces

* to the right place in toml

Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
MujkicA pushed a commit that referenced this pull request Oct 26, 2022
* remove loop from next_event

* initial work

* more work

* trying to use an alternative approach to message id cache

* quick break

* fix sized issue

* finalize gossipsub validation

* remove unused

* update fast_gossip_message_id

* check MessageId calculation

* cleanup network orchestrator

* move types to p2p for reuse

* add consensus gossip data instead

* add serde only feature

* update with suggestions

* remove unused

* use gossipsub_config

* hash complete messages

* use gossipsub config and its builder

* import serde only as feature

* use test-helpers from fuel-core-interfaces

* to the right place in toml

Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
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.

enable message validation on gossipsub
3 participants