4 ms·
For those not familiar with Solidity, there is a peculiarity in the "ABI" that makes it painful to interop between languages. In solidity, there are types call
by mgraczyk 5y ago
For those not familiar with Solidity, there is a peculiarity in the "ABI" that makes it painful to interop between languages.
In solidity, there are types called "contracts" which are like classes in other languages. When you call a function in a different contract, the dispatch is routed using the first few bytes of the has of the signature [1].
For example, to transfer ERC-20 tokens you dispatch using `hash(transfer(address, uint256))[:4]`, meaning that you put those first four bytes at the beginning of the data that you pass to the receiving contract.
Just like the native world, this causes a problem when you try to interface between different languages. In Fe, the types have different names so this hashing scheme can't work without a translation layer. From some of the issues it looks like interoperability may be a problem [2]. That's ok if you write all the contracts that your dApp interacts with, but as time goes on dApps interact and call into one another more and more often.
There are probably also lots of opportunities here for exploiting confusion at these boundaries, so if you're inclined and know how to use tornado you may be able to make quite a bit of money off contracts that use Fe.
[1] https://docs.soliditylang.org/en/v0.8.10/abi-spec.html#function-selector https://docs.soliditylang.org/en/v0.8.10/abi-spec.html#funct...
[2] https://github.com/ethereum/fe/issues/592 https://github.com/ethereum/fe/issues/592
- deleted 5y ago[deleted]
- davesque 5y agoFe currently doesn't support the offending type and I'm pretty sure the rest of the types support the same names internally. Smart contact development isn't like native systems programming where the details of the ABI are not considered in the majority of work. I think any smart contact engineer worth their salt will immediately ask what hash will be generated by a given type and confirm that it's compatible with standard contract interfaces.
- mgraczyk 5y agoYeah looking at elements.rs, it appears that they have the translation layer I alluded to: https://github.com/ethereum/fe/blob/bfeffe82b4f8623330c1ebb1950ca981449c9e86/crates/abi/src/elements.rs#L95 https://github.com/ethereum/fe/blob/bfeffe82b4f8623330c1ebb1... It's not obvious to me though and I couldn't find documentation for ABI compatibility. For example, does delegatecall to solidity work? That requires that Fe also use the same "binary" layout for storage in which slot index is used to generate the storage hash: https://docs.soliditylang.org/en/v0.8.10/internals/layout_in_storage.html https://docs.soliditylang.org/en/v0.8.10/internals/layout_in...