CityOfZion / neo-boa

Python compiler for the Neo2 Virtual Machine, see neo3-boa for NEO3
MIT License
69 stars 55 forks source link

Fix generating incorrect hash for ABI file #133

Closed meevee98 closed 4 years ago

meevee98 commented 4 years ago

What current issue(s) from Github does this address? Fix #132

What problem does this PR solve? Fixes the incorrect hash in abi generation

How did you solve this problem? Changed the algorithm used to hash the file.

How did you make sure your solution works? Compared with the hash output from neo-cli when deploying the contracts and included unit tests.

Are there any special changes in the code that we should be aware of? The hexdigest() function from hashlib was generating a reversed hash string. That's why we need to reverse the bytes before getting the string representation

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.1%) to 89.953% when pulling f9ea864c0b54705af937b1657682d676f71cac98 on simplitech:fix-abi-hash into 33e8483d1b458318d7a93a7e23d00a2050b36cef on CityOfZion:master.

ixje commented 4 years ago

The hexdigest() function from hashlib was generating a reversed hash string

I'm going to guess this has todo with C# calling ToScriptHash() which returns a UInt160. The problem is that they reverse the actual bytes before turning it into a string here

        public override string ToString()
        {
            return "0x" + this.ToArray().ToHexString(reverse: true);
        }

I've historically tried to convince them to remove it because it makes no sense to change a byte array order when printing, but no luck. I gave up