Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function clash for non-storage arguments #34

Merged
merged 12 commits into from
Mar 28, 2024

Conversation

Amxx
Copy link
Collaborator

@Amxx Amxx commented Mar 28, 2024

This is caused by getFunctionId not resolving the UDVT.

Given the following solidity code:

library UdvtConflict {
    type myFirstType is bytes32;
    type mySecondType is bytes32;

    function unwrap(myFirstType t) internal pure returns (bytes32) {
        return myFirstType.unwrap(t);
    }

    function unwrap(mySecondType t) internal pure returns (bytes32) {
        return mySecondType.unwrap(t);
    }
}

getFunctionId will return

  • unwrapUdvtConflict.myFirstType
  • unwrapUdvtConflict.mySecondType

The system doesn't see them as colliding, when in fact they do collide.

@frangio frangio changed the title Fix function clash when using different UDVT with similar underlying type. Fix function clash for non-storage arguments Mar 28, 2024
@frangio
Copy link
Owner

frangio commented Mar 28, 2024

The issue was more general as only storage arguments were previously handled, which are converted to uint256 indices and thus are particularly likely to cause conflicts. Other types like contract types can also cause conflicts and were not handled correctly.

I've generalized the fix so that we get the "ABI type" of every argument, which in the case of UDVT is the underlying, and use types that have different ABI and source-level types to disambiguate.

src/core.ts Outdated Show resolved Hide resolved
src/core.ts Show resolved Hide resolved
src/core.ts Outdated Show resolved Hide resolved
frangio and others added 2 commits March 28, 2024 16:22
Co-authored-by: Hadrien Croubois <[email protected]>
Co-authored-by: Hadrien Croubois <[email protected]>
@frangio frangio merged commit f535d7f into frangio:master Mar 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants