cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
17 stars 37 forks source link

Use `abi.encode` for fixed-size values #215

Closed guidanoli closed 6 months ago

guidanoli commented 6 months ago

📚 Context

There are places in our code base that use abi.encodePacked for fixed-size values. This is not necessary, as abi.encode works just like abi.encodePacked for those values. Plus, abi.encode is shorter.

✔️ Solution

Replace abi.encodePacked with abi.encode in those cases.

ZzzzHui commented 6 months ago

To be exact, by "fixed size" you mean the fixed 32-byte size. Otherwise, for example, uint64 is fixed size. But abi.encode packs it to 32 bytes while abi.encodePacked doesn't

guidanoli commented 6 months ago

To be exact, by "fixed size" you mean the fixed 32-byte size. Otherwise, for example, uint64 is fixed size. But abi.encode packs it to 32 bytes while abi.encodePacked doesn't

Ouch, you're right!