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

Avoid validation error when function parameter has internal function pointer #1038

Merged
merged 11 commits into from
Jun 18, 2024

Conversation

ericglau
Copy link
Member

Problem:
The following function
https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/e49c574f71d402bbd5905175ec2205af02e87dda/contracts/governance/utils/VotesUpgradeable.sol#L259-L262 causes the Upgrades plugin to give a validation error: Variable op is an internal function

This appears to be a false positive, since the internal function pointer comes from the same implementation code and is not kept in storage.

Background:
In #1032, we added validation errors for internal function pointers in storage variables.

This was done by using solidity-ast's findAll to look for all transitive nodes of type VariableDeclaration within a ContractDefinition.

The goal was to check all direct variables of a contract, or all variables within structs. But the contract's functions' parameters can also have VariableDeclaration type (which may be function pointers), and these are also transitive children of the contract -- these should be ignored.

Fix:
Instead of checking all transitive VariableDeclaration nodes from a contract, only check those from its direct variables or from its structs.

Fixes #1037

@ericglau ericglau requested a review from a team June 18, 2024 19:37
packages/core/src/validate/run.ts Outdated Show resolved Hide resolved
packages/core/src/validate/run.ts Outdated Show resolved Hide resolved
packages/core/src/validate/run.ts Outdated Show resolved Hide resolved
@ericglau ericglau requested a review from frangio June 18, 2024 21:14
@ericglau ericglau merged commit 32a2274 into OpenZeppelin:master Jun 18, 2024
11 checks passed
@ericglau ericglau deleted the fnpointerinfn branch June 18, 2024 22:07
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.

Contract in @openzeppelin/contracts-upgradeable raises an internal-function-storage error
2 participants