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: mpsc channel #125

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Feat: mpsc channel #125

wants to merge 17 commits into from

Conversation

driemworks
Copy link
Contributor

@driemworks driemworks commented Mar 4, 2025

This replaces the SharedState struct with an mpsc channel, where it uses a TracingUnboundedSender to write well-formatted pulses from the gossipsub topic. Pulses can be read with a corresponding TracingUnboundedReceiver

@driemworks driemworks added this to the Trustless Drand Bridge milestone Mar 4, 2025
@driemworks driemworks self-assigned this Mar 4, 2025
let data_lock = state.lock().unwrap();
let pulses = &data_lock.pulses;
assert!(pulses.len() == 0);
sleep(Duration::from_millis(7000)).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite a lot of waiting, why is that? and why did you need to increase it?

Copy link
Contributor Author

@driemworks driemworks Mar 5, 2025

Choose a reason for hiding this comment

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

This test actually connects to drand's gossipsub. Waiting 7 seconds ensure we get enough pulses. It's probably not necessary to wait that long but it provides a strong guarantee that we would have consumed at least two messages from the topic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that we could do with a mock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be mocked, but I still think it's good to have an e2e test that consumes from the real drand.

Copy link

@carloskiron carloskiron left a comment

Choose a reason for hiding this comment

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

@driemworks looks good overall imo. Nice tests, my only comment would be to differentiate those tests with actual dependency to the drand network to be more like integration or e2e tests

Copy link
Contributor

@colemanirby colemanirby 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 to me. The tarpaulin stuff has been removed in the most recent PR.

@driemworks
Copy link
Contributor Author

driemworks commented Mar 7, 2025

@colemanirby Gotcha, I removed the changes to the tarpaulin config.

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

Successfully merging this pull request may close these issues.

Gossipsub: use mpsc channel to write pulses
4 participants