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

[Bug] Fix bug introduced by changing BigEndian to LittleEndian #36

Merged
merged 2 commits into from
Jan 1, 2024

Conversation

h5law
Copy link
Collaborator

@h5law h5law commented Jan 1, 2024

Summary

Human Summary

  • When BigEndian what changed to LittleEndian it meant that the hashes generated by the trie would be different in the SMST
  • This meant that for the ProveClosest method where hardcoded hashes were used they broke
  • This change reverts this among other minor fixes

AI Summary

Summary generated by Reviewpad on 01 Jan 24 20:51 UTC

This pull request includes the following changes:

  1. The file proof_sizes_test.go has updates related to modifying and proving values in a trie data structure. It includes replacing the usage of binary.LittleEndian.PutUint64 with binary.BigEndian.PutUint64.

  2. The file smst_proofs_test.go has changes in lines 101, 321, 347, 418, and 450, where binary.LittleEndian.PutUint64 is replaced with binary.BigEndian.PutUint64. Additionally, the loop in line 450 has been modified to insert 100 key-value-sum triples instead of 100,000.

  3. The file smst_utils_test.go has changes in the Update and GetValueSum functions. The byte order used for encoding and decoding the sumBz variable has been modified from little endian to big endian. The ProveSumCompact function has been removed.

  4. The file smst.go has changes in the Get, Update, and Sum functions, where the byte ordering of variables weight and sum has been changed from little endian to big endian.

  5. The file smst_test.go has a change in line 462, where binary.LittleEndian.Uint64 is replaced with binary.BigEndian.Uint64 for calculating the variable rootSum.

  6. The file diff includes modifications in functions related to compaction and decompaction in the smt_proofs_test.go file. The error handling has been improved by replacing t.Fatalf() with require.NoErrorf().

  7. The file diff modifies the test case TestSMT_ProveClosest_Proof in smt_proofs_test.go, reducing the number of key-value-sum triples inserted from 100,000 to 100.

  8. The file utils.go has changes in the intToBytes and bytesToInt functions. The byte ordering for converting between int and byte slice has been changed from little endian to big endian.

  9. The file proofs.go has changes in the VerifyProof and VerifyClosestProof functions, where the byte ordering for encoding and decoding a uint64 value has been changed from little endian to big endian.

  10. The file hasher.go has changes in the encodeSumInner function. The byte slices are now converted into unsigned integers and sum using big endian encoding instead of little endian encoding.

  11. The file fuzz_test.go has changes in line 75, replacing binary.LittleEndian.PutUint64 with binary.BigEndian.PutUint64, and lines 96-98, where a default case has been added to handle unknown operations.

  12. The file diff in MerkleSumTrie.md suggests changing the encoding of the sum value from little endian to big endian.

Let me know if you need any further assistance!

Issue

Fixes N/A

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Testing

  • Run all unit tests: make test_all
  • Run all/relevant benchmarks (if optimising): make benchmark_{all | suite name}

Required Checklist

If Applicable Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated any relevant README(s)/documentation and left TODOs throughout the codebase
  • Add or update any relevant or supporting mermaid diagrams

@h5law h5law added the bug Something isn't working label Jan 1, 2024
@h5law h5law self-assigned this Jan 1, 2024
@reviewpad reviewpad bot added small Pull request is small waiting-for-review This PR is currently waiting to be reviewed labels Jan 1, 2024
Copy link

codecov bot commented Jan 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d88ea55) 83.28% compared to head (a48b784) 83.28%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #36   +/-   ##
=======================================
  Coverage   83.28%   83.28%           
=======================================
  Files           8        8           
  Lines        1406     1406           
=======================================
  Hits         1171     1171           
  Misses        178      178           
  Partials       57       57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@h5law h5law merged commit db06038 into main Jan 1, 2024
7 checks passed
@h5law h5law deleted the feat/fix-closest-proof-tests branch January 1, 2024 20:54
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

From the PR comment: by the trie would be different in the SMST

  1. Do you mean from the SMT and SMST?
  2. Is this because the sum is stored in the most significant bit?
  3. Should we only be using BigEndian throughout the library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working small Pull request is small waiting-for-review This PR is currently waiting to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants