Skip to content

Fix contract class unmarshall for modern cairo compilers#656

Merged
thiagodeev merged 27 commits intoNethermindEth:mainfrom
baitcode:fix-contract-class-unmarshall-for-modern-cairo-compilers
Feb 24, 2025
Merged

Fix contract class unmarshall for modern cairo compilers#656
thiagodeev merged 27 commits intoNethermindEth:mainfrom
baitcode:fix-contract-class-unmarshall-for-modern-cairo-compilers

Conversation

@baitcode
Copy link
Copy Markdown
Contributor

@baitcode baitcode commented Jan 17, 2025

Fixes: #655

Added workaround for abi data that is not string, but json object.

  • added contract casm compiled by scarn 2.7.0 compiler
  • added tests to unmarshall contract class from new casm json format

Fix ClassHash calculation for casm compiled classes for modern cairo 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

Here is the snippet for hash values generation with starknet.py:

https://gist.github.com/baitcode/5adec0f74121d0ae3a09aaf573ff8665

* 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
Copy link
Copy Markdown
Collaborator

@thiagodeev thiagodeev left a 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

@baitcode
Copy link
Copy Markdown
Contributor Author

baitcode commented Feb 3, 2025

@thiagodeev Fixed!

Added argent account contract v0.4.0 to hash tests.

@baitcode baitcode requested a review from thiagodeev February 3, 2025 16:54
Copy link
Copy Markdown
Collaborator

@thiagodeev thiagodeev left a 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

@baitcode
Copy link
Copy Markdown
Contributor Author

baitcode commented Feb 7, 2025

@thiagodeev Thank you very much for the review. I've fixed all the comments.

Copy link
Copy Markdown
Collaborator

@thiagodeev thiagodeev left a 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:

@baitcode baitcode requested a review from thiagodeev February 12, 2025 12:51
@thiagodeev thiagodeev force-pushed the fix-contract-class-unmarshall-for-modern-cairo-compilers branch from 35d5fe5 to 98dda3f Compare February 21, 2025 16:26
Copy link
Copy Markdown
Collaborator

@thiagodeev thiagodeev left a comment

Choose a reason for hiding this comment

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

Thank you again @baitcode!

I made a new test for the ClassHash and CompiledClassHash. The code is failing in the ClassHash, I gave more details in the comment.
CompiledClassHash is working fine, congrats!

Could you please handle this?

@baitcode baitcode requested a review from thiagodeev February 21, 2025 19:43
@thiagodeev
Copy link
Copy Markdown
Collaborator

Thank you again @baitcode for your contribution!
It was a great help

@thiagodeev thiagodeev merged commit 41bde07 into NethermindEth:main Feb 24, 2025
6 checks passed
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.

Support for modern CASM format

2 participants