ethereum-optimism / ethereum-optimism/optimism
Unused internal/private function check script
- Dominant language
- Go
- Stars
- 6.5k
- Forks
- 4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 145
Description
Discussed: https://github.com/ethereum-optimism/optimism/pull/16470#discussion_r2159077432
The idea for this is:
This script would for each contract (e.g ContractA) in the contract-bedrock folder with internal/private functions (e.g functionA and functionB)
- Go through all artifacts
- For each artifact, check if ContractA is imported, if it is not, check the next artifact
- If it is imported, loop through each of that artifacts functions and check if functionA or functionB is invoked, if none of them are invoked after looping, go to the next artifact
- if e.g functionA is invoked, mark it as true so that it does not need to be checked for again and only check for functionB for other artifacts.
- once all its internal/private functions are found to be invoked, go to the next contract e.g contractB
A similar system as the one used for the [opcm upgrade checks](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/scripts/checks/opcm-upgrade-checks/main.go) can be used for checking through all possible nodes of a function.
This is nuanced however because there are edge cases like, what if we do not call the internal/private function but we use it's function type as an arg somewhere or for something else, etc
Contributor guide
Research direction
Start by reading packages/contracts-bedrock/scripts/checks/opcm-upgrade-checks/main.go and the contract-bedrock artifacts referenced in the issue. Trace how artifacts and function call paths could be inspected, then resolve the listed function-type and indirect-call edge cases; done means the script reliably identifies unused internal/private functions across the contracts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- blockchain, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100