Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFunction selector collision is not detected with the "0" selector #1603
Comments
|
We should definitely check for collisions between function selectors and reject programs with collisions at compile time! |
|
It seems Vyper does this -- the only edge case I've found is the "0" selector. Note, though, that Solidity does allow a function with a "0" selector along with a fallback function. It differentiates between the two by checking whether |
Thanks - I think we will just reject programs with name that maps to the "0" selector |
|
As an aside, this provides us a clean and gas-efficient way to perform memory zeroing without loops. We can just use |
|
@wadeAlexC I think this should fix it: #1606 |
|
Looks good to me! |

Version Information
vyper --version): 0.1.0-beta.12What's your issue about?
Vyper has an edge case in function selector collision detection. If a function with selector
0x00000000exists, the__default__function is overwritten in the resulting contract. Here's an example:Calls made to the above contract with no calldata trigger
blockHashAskewLimitary(uint), rather than the default function. It seems thatvis also successfully decoded, even without calldata.How can it be fixed?
Solidity uses
CALLDATASIZEto differentiate between functions with the "0" selector, and the fallback function. As for the variable unpacking from empty calldata, a check should be in place that each function has some minimumCALLDATASIZE.