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: snappy framing format #543

Closed
wants to merge 27 commits into from
Closed

Conversation

h3lio5
Copy link
Contributor

@h3lio5 h3lio5 commented Dec 20, 2023

Motivation

Implements the snappy decompression for the framing format.

Closes #224

@h3lio5 h3lio5 changed the title Snappy framing format feat: snappy framing format Dec 20, 2023
Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

Good work!

lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

Left some more comments

lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
@MegaRedHand
Copy link
Collaborator

Also, since CRC-32 checksums seem to be supported by the erlang stdlib, we could add checksum checking in this PR (should be just a call to CRC-32 and a comparison).

lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
Copy link
Collaborator

@Arkenan Arkenan left a comment

Choose a reason for hiding this comment

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

Hello Akash, here are some code quality and bug related comments. They still don't fully fix the problem though. You need to keep debugging. I suggest you do some of the following:

  1. Check if the masking works. Create a simple 32-bit element, like <<1, 0, 2, 0>>. Think how that would work when masked. That is, follow the rotation and then the addition, by hand (e.g. in a piece of paper). Then, check that your mask function does the same.
  2. Check with a different implementation, like lighthouse or lodestar, if their implementation of checksums computes the same checksum given the same payload. If they are different we might need to configure something in our crc32 call.

Don't hesitate on printing intermediate results both here and on the other implementation.

lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
test/unit/snappyex_test.exs Show resolved Hide resolved
mix.exs Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
@h3lio5 h3lio5 marked this pull request as ready for review January 17, 2024 13:06
@h3lio5 h3lio5 requested a review from a team as a code owner January 17, 2024 13:06
Comment on lines +56 to +79
# test "decompress Ping responses" do
# for {msg, expected} <- [
# {"0008FF060000734E61507059010C0000B18525A04300000000000000", "4300000000000000"},
# {"0008FF060000734E61507059010C00000175DE410100000000000000", "0100000000000000"},
# {"0008FF060000734E61507059010C0000EAB2043E0500000000000000", "0500000000000000"},
# {"0008FF060000734E61507059010C0000290398070000000000000000", "0000000000000000"}
# ] do
# "00" <> "08" <> compressed_payload = msg
# expected = Base.decode16!(expected)

# assert_snappy_decompress_frames(compressed_payload, expected)
# end

# # Error response
# msg =
# "011CFF060000734E6150705900220000EF99F84B1C6C4661696C656420746F20756E636F6D7072657373206D657373616765"

# "01" <> "1C" <> compressed_payload = msg

# assert_snappy_decompress_frames(
# compressed_payload,
# "Failed to uncompress message"
# )
# end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these work?

test/unit/snappyex_test.exs Outdated Show resolved Hide resolved
lib/snappy_ex.ex Outdated Show resolved Hide resolved
test/unit/snappyex_test.exs Outdated Show resolved Hide resolved
test/unit/snappyex_test.exs Outdated Show resolved Hide resolved
h3lio5 and others added 5 commits January 18, 2024 17:13
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
@mpaulucci
Copy link
Collaborator

Closing this since Akash is no longer in the bootcamp. Will link this PR to the issue though since there is some good work that has been done.

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.

[Snappy] Implement Snappy framing format in Elixir
4 participants