xJonathanLEI / starknet-rs

Complete Starknet library in Rust™
https://starknet.rs
Apache License 2.0
286 stars 101 forks source link

Legacy contract class corrupted when deserialized through `ContractArtifact` #392

Open xJonathanLEI opened 1 year ago

xJonathanLEI commented 1 year ago

Due to a scientific notation issue, certain legacy (Cairo 0) contract artifacts can be different when deserializing directly and through the ConrtractArtifact enum. This leads to class hash errors, and hence failures on contract declaration.

Details to be updated later. Creating this issue first so that it can be referenced from starkli.

xJonathanLEI commented 1 year ago

Looks like the switch to raw_value in https://github.com/xJonathanLEI/starknet-rs/commit/c5cf1967d44dd61fb68b36cefed710cc8518b1ab has made this worse. Previously only artifacts with values that can be converted to the scientific notation without precision loss are affected; now it looks like most artifacts are affected.

xJonathanLEI commented 3 months ago

Added a test case (that's disabled by default to avoid breaking CI) in #644, test_legacy_artifact_deser_from_contract_artifact, specifically to test this issue. A patch to this issue should be able to also remove the ignore attribute on that test case.