-
Notifications
You must be signed in to change notification settings - Fork 107
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
Use a channel in sync timing test #2281
Use a channel in sync timing test #2281
Conversation
Error:
|
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.
I think I found the cause and a fix :D
let (peer_requests_sender, peer_requests_receiver) = watch::channel(peer_requests_counter); | ||
let (state_requests_sender, state_requests_receiver) = watch::channel(state_requests_counter); |
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.
The error seems to be caused by ChainSync
needing to clone the service to create multiple instances of it. To allow that, I think one way would be to simply wrap the senders with Arc
s so that the watch::Sender
is shared between all instances:
let (peer_requests_sender, peer_requests_receiver) = watch::channel(peer_requests_counter); | |
let (state_requests_sender, state_requests_receiver) = watch::channel(state_requests_counter); | |
let (peer_requests_sender, peer_requests_receiver) = watch::channel(peer_requests_counter); | |
let (state_requests_sender, state_requests_receiver) = watch::channel(state_requests_counter); | |
let peer_requests_sender = Arc::new(peer_requests_sender); | |
let state_requests_sender = Arc::new(state_requests_sender); |
I realized that the counter values will actually be copied instead of shared, so they will lead to incorrect counts :/ Replacing the atomics might need another similar abstraction 🤔 |
Looks like this cleanup is blocked by #2200, which will give us the Can you update ticket #2268 with what we've learned here? (This cleanup is a low priority right now, because the tests are passing. So we can just close this PR.) |
The cleanup will be done after #2200 by using something as the following inside the services:
This should avoid any incorrect counts and will allow us to use Closing the PR and leaving the branch up for future reference. |
Motivation
We are trying to get rid of
Atomic
s, including in test cases. #2268Designs
[link to async coding rfc - atomics section]
Solution
Use a
tokio::watch
for this test.Review
By now this is a draft for sharing with @jvff
Reviewer Checklist
Follow Up Work