ApeWorX / ApeWorX/eth-abi

encodePacked appears to have different behavior from solidity for complex types

Đang mở
#149 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Needs Review p3
Ngôn ngữ chính
Python
Star
256
Fork
117
Merge trung bình
4 phút
Pull request đã merge (30 ngày)
1

Mô tả

For arrays, encodePacked appears to fall back to standard encoding.

https://github.com/ethereum/eth-abi/blob/decaadcdf7a33020846aafd9ba36859c1ab82909/eth_abi/encoding.py#L666
->
https://github.com/ethereum/eth-abi/blob/decaadcdf7a33020846aafd9ba36859c1ab82909/eth_abi/encoding.py#L615-L631

However, solidity skips the length and pads dynamic array elements with zeros:
https://docs.soliditylang.org/en/v0.8.6/abi-spec.html#non-standard-packed-mode
> The encoding of an array is the concatenation of the encoding of its elements **with** padding.

cf. https://github.com/ethereum/solidity/issues/8441 for an example of the current padding scheme.

Additionally, and please correct me if I'm wrong here, eth-abi appears to encode bytestrings in tuples without padding as in the tests here

https://github.com/ethereum/eth-abi/blob/decaadcdf7a33020846aafd9ba36859c1ab82909/tests/common/unit.py#L166-L171

However my cursory reading of solc output says that they are in fact padded. (solidity disallows structs in abi.encodePacked, but it uses the packed encoding code path to calculate event indexes).
[event.ir.txt](https://github.com/ethereum/eth-abi/files/6912947/event.ir.txt)
[event.sol.txt](https://github.com/ethereum/eth-abi/files/6912948/event.sol.txt)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.