Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
While developing snarktor contracts and aggregator service it was found that in order to find the table an endianess transformation was necessary, as seen here:
This test was a clear example of the issue:
Reproducing
Created two contracts that perform exactly same tasks and define same structs one in rust and one in C:
cindextest
: https://gist.github.com/guilledk/40a79e87803a62358a74e9743d978ed8rindextest
: https://gist.github.com/guilledk/139d2021c8b6cbd76d752bf656dc3b02Then created test that auto deploys contracts and calls the actions in three batches:
store
actionsrload
function on both contracts to read and compare stored hashcload
function on both contracts to read and compare stored hashHere is test python version: https://gist.github.com/guilledk/4b561aacaec627c5504754d3bc55f968
Here is test rust version: https://gist.github.com/guilledk/eb0bf73fa2b4788208d8d12f3cde6d62
When run without this branch, the test will succed until step 3, rust contract will fail to find the row in the C contract. Another interesting result is the output of the
dump
function on the rust contract:rindextest::dump
:this prints:
so clearly table data works fine when searching by simple primary index, but is printed with its 16 byte chunks reversed, as well as endianess swap internaly on each 16 byte chunk.
Conclusion
Changes in this PR make the test suite run correctly as well as the zk proof submit test.