-
Notifications
You must be signed in to change notification settings - Fork 127
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
Refactor ping pong example #977
base: main
Are you sure you want to change the base?
Conversation
Bencher
🚨 10 ALERTS: Threshold Boundary Limits exceeded!
Click to view all benchmark results
Bencher - Continuous Benchmarking View Public Perf Page Docs | Repo | Chat | Help |
Bencher
🚨 1 ALERT: Threshold Boundary Limit exceeded!
Click to view all benchmark results
Bencher - Continuous Benchmarking View Public Perf Page Docs | Repo | Chat | Help |
Bencher
Click to view all benchmark results
Bencher - Continuous Benchmarking View Public Perf Page Docs | Repo | Chat | Help |
Bencher
🚨 2 ALERTS: Threshold Boundary Limits exceeded!
Click to view all benchmark results
Bencher - Continuous Benchmarking View Public Perf Page Docs | Repo | Chat | Help |
@jbesraa @Shourya742 @pythcoiner since you're all interested in learning more about the low-level crates, how about we do a "PR Review Club"-style call? We could follow this agenda:
We could record it and share on SRI YouTube to spread the knowledge to the community. Also, this could be a good opportunity to brainstorm design decisions on the |
sure! |
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.
tACK
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.
Looks good. Added one small question.
Could you please add a gh workflow to run this example instead of the removed one?
// initialize decoder | ||
let mut decoder = StandardDecoder::<Ping>::new(); | ||
|
||
// right now, the decoder buffer can only read a frame header |
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.
sorry, I am not getting why the first read fails, could you pleas elaborate?
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.
It seems like we're only reading the first 6 bytes of this specific message type and not reaching the total byte length, which causes an error signaling that more bytes are needed to match the payload size. But I'm wondering, why are we taking this approach? Couldn't we just read all the bytes in one go and then decipher from there?
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.
It seems like we're only reading the first 6 bytes of this specific message type and not reaching the total byte length, which causes an error signaling that more bytes are needed to match the payload size.
correct
But I'm wondering, why are we taking this approach? Couldn't we just read all the bytes in one go and then decipher from there?
this is technical debt we need to clean up
#903 is the first step of that journey
|
@plebhash Thanks alot for the call and the thorough explanation about this. |
c5afda3
to
40c54e9
Compare
done |
65b14fd
to
146b9ed
Compare
146b9ed
to
60b722a
Compare
utACK 60b722a |
e480c0a
to
0d962ce
Compare
0d962ce
to
6e3334b
Compare
utACK 6e3334b |
Note: Wait to merge until the following is merged: |
Co-authored-by: pythcoiner <[email protected]>
6e3334b
to
f1aef4d
Compare
This PR is refactoring the
examples/ping-pong-without-noise
example intoexamples/ping-pong
.I wrote it from scratch as an exercise to get familiar with
protocols
crates.The overall idea is quite similar to the previous implementation, but with some simplifications to make the example easier to understand.
ping-pong
is an example of how to encode and decode SV2 binary frames (without any encryption layer) while leveraging the following crates:binary_sv2
codec_sv2
framing_sv2
(which is actually just re-exported bycodec_sv2
)We establish a simple
Ping
-Pong
protocol with a server and a client communicating over a TCP socket.The server expects to receive a
Ping
message encoded as a SV2 binary frame.The
Ping
message contains anonce
, which is au8
generated randomly by the client.The client expects to get a
Pong
message in response, also encoded as a SV2 binary frame, with the samenonce
.The messages are assigned arbitrary values for binary encoding: