-
Notifications
You must be signed in to change notification settings - Fork 16
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!: use gossipsub for consensus broadcasts #1156
base: development
Are you sure you want to change the base?
Conversation
Test Results (CI)549 tests - 18 549 ✅ - 18 1h 23m 20s ⏱️ - 19m 25s Results for commit 622718a. ± Comparison against base commit 49c82f7. This pull request removes 18 tests.
♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM will test when we are out of draft.
For performance and potential issues with incorrect decoding I think we need to use the topic to determine which message type we have
.gossip_message_codec | ||
// the incoming gossip message is a transaction | ||
if let Ok((length, msg)) = self | ||
.transaction_gossip_message_codec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should inspect the topic prefix rather than trying to decode and failing - as this might be slow or even potentially erroneously succeed for the wrong message type (because protobuf works on optional fields and ignores unknown fields).
We could "register" channels for each topic or topic prefix.
e.g.
networking.gossipsub_subscribe("consensus-0-31", codec).await?;
or maybe register a channel for sending/receiving messages on the topic
let channel = message_channel::channel::<HotstuffMessage>::(100);
networking.gossipsub_subscribe("consensus-0-31", channel).await?;
Channel could be something like this
pub fn channel<T>(capacity: usize) -> (MessageChannel<T>, MessageChannel<T>) {
let (ltr_tx, ltr_rx) = mpsc::channel(capacity);
let (rtl_tx, rtl_rx) = mpsc::channel(capacity);
(
MessageChannel {
sender: ltr_tx,
receiver: rtl_rx,
},
MessageChannel {
sender: rtl_tx,
receiver: ltr_rx,
},
)
}
#[derive(Debug)]
pub struct MessageChannel<T> {
sender: mpsc::Sender<T>,
receiver: mpsc::Receiver<T>,
}
impl<T> MessageChannel<T> {
pub async fn recv(&mut self) -> Option<T> {
self.receiver.recv().await
}
pub fn try_recv(&mut self) -> Result<T, TryRecvError> {
self.receiver.try_recv()
}
pub async fn send(&self, value: T) -> Result<(), SendError<T>> {
self.sender.send(value).await
}
pub fn try_send(&self, value: T) -> Result<(), TrySendError<T>> {
self.sender.try_send(value)
}
pub fn split(self) -> (mpsc::Receiver<T>, mpsc::Sender<T>) {
(self.receiver, self.sender)
}
}
Description
Motivation and Context
Hotstuff and cerberus are message based protocols. Currently we implement a message protocol that requires nodes to connect to every other node in the local shard. For cross shard messaging, we implement a strategy that limits the number of messages sent but relies on multiple connections per peer across shards.
We want to leverage libp2p's gossipsub for all consensus broadcasts to local/foreign shards.
consensus-{start}-{end}
(start
andend
are the start/end shards in theShardGroup
type, similar to the mempool service)How Has This Been Tested?
TBD
What process can a PR reviewer use to test or verify this change?
TBD
Breaking Changes