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

Use absolute path to disambiguate contract names #219

Merged
merged 41 commits into from
Dec 21, 2023

Conversation

nwatson22
Copy link
Member

@nwatson22 nwatson22 commented Nov 30, 2023

Closes #178
Replaces references to contracts done by name with a name qualified by the full path of the contract, e.g. contract Initializable in openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol would get the name openzeppelin-contracts-upgradeable%contracts%proxy%utils%Initializable. % is used as a separator because the names of the contracts become directory names when the proofs are saved to disk. In generated K files the K escaping would convert this to S2KopennzeppelinZSubcontractsZSubupgradeableZModcontractsZModproxyZModutilsZModInitializable-CONTRACT.

When there is a duplicate name, solc will disambiguate the files in the out directory by adding their paths as subdirectories. Our foundry.contracts function previously would just not import these. This changes is to recursively import .jsons directly under a .sol directory.

Because of this issue of the duplicates not being imported because they're in subdirectories, I don't know how to reproduce the runtime error Project contains duplicated contract names that may clash in K definitions: {contract_name} in master. However, I've added contracts with duplicate names under src/tests/integration/test-data/foundry/src/ to demonstrate that duplicate test names can be imported with the new system.

@anvacaru
Copy link
Contributor

anvacaru commented Dec 4, 2023

The quality-checks stage is currently failing on CI. You can run make format; make in the repo's root to format the Python files automatically and run the unit tests.

@anvacaru anvacaru added the bug Something isn't working label Dec 5, 2023
src/kontrol/foundry.py Outdated Show resolved Hide resolved
@nwatson22 nwatson22 marked this pull request as ready for review December 7, 2023 20:18
src/kontrol/foundry.py Outdated Show resolved Hide resolved
src/kontrol/foundry.py Outdated Show resolved Hide resolved
Co-authored-by: Andrei Văcaru <16517508+anvacaru@users.noreply.github.com>
src/kontrol/foundry.py Outdated Show resolved Hide resolved
@rv-jenkins rv-jenkins merged commit c00d4dd into master Dec 21, 2023
11 checks passed
@rv-jenkins rv-jenkins deleted the noah/contract-name-fix branch December 21, 2023 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge bug Something isn't working engagement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contract name clashes when the same contract name is used in multiple libraries.
4 participants