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

Does adding a check in removeFunctions make the function more robust? #345

Open
defirobot opened this issue Mar 10, 2023 · 0 comments
Open

Comments

@defirobot
Copy link

As following, removeFunctions in ParaProxyLib.
It seems the program could check the equality of the oldImplementationAddress and the _implementationAddress, which prevents from removing functions by accidents.

function removeFunctions(
        address _implementationAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        require(
            _functionSelectors.length > 0,
            "ParaProxy: No selectors in implementation to cut"
        );
        ProxyStorage storage ds = diamondStorage();
        // if function does not exist then do nothing and return
        require(
            _implementationAddress == address(0),
            "ParaProxy: Remove implementation address must be address(0)"
        );
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldImplementationAddress = ds
                .selectorToImplAndPosition[selector]
                .implAddress;
            removeFunction(ds, oldImplementationAddress, selector);
        }
    }
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

No branches or pull requests

1 participant