-
Notifications
You must be signed in to change notification settings - Fork 118
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 contract class unmarshall for modern cairo compilers #656
base: main
Are you sure you want to change the base?
Fix contract class unmarshall for modern cairo compilers #656
Conversation
* added contract casm compiled by scarn 2.7.0 compiler * added tests to unmarshall contract class from new casm json format
…compilers * Added bytecode_segment_lengths field to CasmClass, allowing for backward compatibility * Added NestedUInts type to handle deserialisation of CasmClass * Added test to check that ClassHash now respects bytecode_segment_lengths and calculates correct value
… of Declare transation * Simplify nested string
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.
Thanks for your help, @baitcode!
I left some comments, mostly about testing
Added argent 0.4.0 contract. Fixed review comments
@thiagodeev Fixed! Added argent account contract v0.4.0 to hash tests. |
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.
Thanks @baitcode. Some new observations about testing
@thiagodeev Thank you very much for the review. I've fixed all the comments. |
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.
Thanks @baitcode! Nice work.
Just a few requests:
contracts/contracts_test.go
Outdated
|
||
expectedEntryPoint := testCase.ExpectedCasmClass.EntryPointByType | ||
|
||
// External |
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.
We can just use:
assert.Equal(t, casmClass.EntryPointByType.External, expectedEntryPoint.External)
assert.Equal(t, casmClass.EntryPointByType.Constructor, expectedEntryPoint.Constructor)
assert.Equal(t, casmClass.EntryPointByType.L1Handler, expectedEntryPoint.L1Handler)
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.
I can't remember why exactly I decided to compare everything explicitly so will have to fix. Will leave a comment next time.
hash/hash.go
Outdated
return felt.Zero.Add( | ||
zero := &felt.Felt{} | ||
|
||
return zero.Add( |
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.
We don't need a new var, we can just pass new(felt.Felt)
directly
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.
Thanks for catching!
* added test for new sierra hash * simplified EntryPoint comparisons in test
Fixes: #655
Added workaround for abi data that is not string, but json object.
Fix ClassHash calculation for casm compiled classes for modern cairo compilers
Here is the snippet for hash values generation with starknet.py:
https://gist.github.com/baitcode/5adec0f74121d0ae3a09aaf573ff8665