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

fix(ssz): adjust the initial offset of variables-length fields #1492

Merged
merged 7 commits into from
Jun 18, 2024

Conversation

TropicalDog17
Copy link
Contributor

@TropicalDog17 TropicalDog17 commented Jun 15, 2024

Description

Fix offset calculation and update the parity test.

Closes #1131
Related to #1064

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the order of operations in the offset calculation to ensure accurate results.
  • Tests

    • Improved test assertions to ensure equality and length checks for values, enhancing test reliability.

Copy link
Contributor

coderabbitai bot commented Jun 15, 2024

Warning

Rate limit exceeded

@TropicalDog17 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 7 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 2c429af and 576ee4a.

Walkthrough

The changes correct the order of operations in the InterleaveOffsets function within the SSZ serialization library to ensure correct calculation of offsets for variable-size elements. This adjustment fixes issues where serialized byte buffers differed from expected results, enhancing the accuracy of SSZ serialization.

Changes

File Change Summary
mod/primitives/pkg/ssz/v2/lib/.../helpers.go Modified the InterleaveOffsets function to reorder the assignment of variableOffsets[i] before updating offsetSum.
mod/primitives/pkg/ssz/v2/lib/spec_test.go Replaced commented-out debug code with assertions for equality and length checks on o2 and res.

Sequence Diagram(s)

The changes are too simple and specific to merit a sequence diagram.

Assessment against linked issues

Objective Addressed Explanation
Ensure correctness of serialization offsets for variable-size elements (#1131)
Verify deserialization with our implementation and fix issues if any (#1131) The change corrects serialization, but deserialization specifics or checks aren't detailed.
Update tests to compare objects and lengths for parity tests (#1131)

Poem

In a world of bits and bytes,
Offsets danced through sleepless nights.
With shifts and sums, they found their place,
Now calculations move with grace.
Code now sings a joyful tune,
Serialization fixed, a grand monsoon!
🌟🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jun 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.45%. Comparing base (70c8129) to head (35cff6c).

Current head 35cff6c differs from pull request most recent head 576ee4a

Please upload reports for the commit 576ee4a to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1492       +/-   ##
===========================================
+ Coverage   24.08%   70.45%   +46.36%     
===========================================
  Files         248        8      -240     
  Lines       11177       88    -11089     
  Branches       18       18               
===========================================
- Hits         2692       62     -2630     
+ Misses       8319       22     -8297     
+ Partials      166        4      -162     

see 240 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between c39920a and 35cff6c.

Files selected for processing (2)
  • mod/primitives/pkg/ssz/v2/lib/helpers.go (1 hunks)
  • mod/primitives/pkg/ssz/v2/lib/spec_test.go (1 hunks)

mod/primitives/pkg/ssz/v2/lib/helpers.go Outdated Show resolved Hide resolved
mod/primitives/pkg/ssz/v2/lib/spec_test.go Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 35cff6c and 2c429af.

Files selected for processing (1)
  • mod/primitives/pkg/ssz/v2/lib/helpers.go (1 hunks)

mod/primitives/pkg/ssz/v2/lib/helpers.go Outdated Show resolved Hide resolved
@TropicalDog17 TropicalDog17 changed the title fix: adjust the initial offset of variables-length fields fix(ssz): adjust the initial offset of variables-length fields Jun 16, 2024
@TropicalDog17
Copy link
Contributor Author

Hi @itsdevbear could you take a look at this PR, would be nice to get this bug fix merged so I could continue working on improving perf.

@itsdevbear
Copy link
Member

lgtm. @TropicalDog17 we are likely going a different direction with our v2 ssz library, so i wouldn't spend too much time here rn. It needs some more broader design, so it may end up being thrown away, will merge this though bc I agree it's correct.

@itsdevbear itsdevbear added this pull request to the merge queue Jun 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 18, 2024
@itsdevbear itsdevbear merged commit bd5b557 into berachain:main Jun 18, 2024
14 checks passed
@TropicalDog17
Copy link
Contributor Author

lgtm. @TropicalDog17 we are likely going a different direction with our v2 ssz library, so i wouldn't spend too much time here rn. It needs some more broader design, so it may end up being thrown away, will merge this though bc I agree it's correct.

Thanks for your information!

@TropicalDog17 TropicalDog17 deleted the tuan/fix-serializer-offset branch June 18, 2024 16:35
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.

fix(ssz/serialization): Offsets dont match
2 participants