Skip to content

Conversation

@elopez
Copy link
Member

@elopez elopez commented Jun 9, 2023

This adds support for solc remaps and EVM version found in the Etherscan JSON.

Fixes #150, #151, #386, #415

This adds support for solc remaps found in the Etherscan JSON.

Fixes: #415
@elopez elopez force-pushed the fix-etherscan-remappings branch from e739787 to 4aa13a1 Compare June 9, 2023 13:41
@elopez elopez force-pushed the fix-etherscan-remappings branch from aa7af41 to 7da2761 Compare June 9, 2023 15:59
@0xalpharush
Copy link
Contributor

Will this address #151 and #150

@elopez
Copy link
Member Author

elopez commented Jun 9, 2023

This also seems to fix the case in #386.

The case in #151 requires passing the EVM target, which this PR doesn't, but it could be added as a follow up.

#150:

  • 0x640022f8a9f00992fa63ee6bae25c2829deadd2d works both with and without this PR
  • 0x2a311e451491091d2a1d3c43f4f5744bdb4e773a has broken remappings (with absolute paths). This PR rejects them currently
WARNING:CryticCompile:Remapping @0x/contracts-erc20=/home/cluracan/code/0x-protocol/contracts/zero-ex/node_modules/@0x/contracts-erc20 is potentially unsafe, skipping

we could override any absolute paths and make them relative though, that would work in this case from what I can see.

  • 0xcE4a49d7ed99C7c8746B713EE2f0C9aA631688d8 works both with and without this PR

@elopez elopez force-pushed the fix-etherscan-remappings branch from f61ef40 to fa4cd58 Compare June 9, 2023 22:47
@elopez elopez changed the title platform: etherscan: add support for solc remaps platform: etherscan: add support for solc remaps, evm version Jun 9, 2023
@elopez elopez force-pushed the fix-etherscan-remappings branch 2 times, most recently from 1aa03fc to 21b1f59 Compare June 9, 2023 23:19
@elopez
Copy link
Member Author

elopez commented Jun 9, 2023

I added some more code to handle those two cases 👍

elopez added 2 commits June 9, 2023 20:25
is_absolute() will return False on Windows if a Path does not contain
a drive letter (e.g. if you are using a POSIX path string)

solc on Windows does not seem to like case #5 though, so mark it as
expected to fail.
@elopez elopez force-pushed the fix-etherscan-remappings branch from 21b1f59 to fec9713 Compare June 9, 2023 23:25
@elopez elopez marked this pull request as ready for review June 9, 2023 23:29
Comment on lines +479 to +481
if os.path.commonpath((allowed_path, os.path.abspath(dest_disk))) != allowed_path:
LOGGER.warning("Remapping %s=%s is potentially unsafe, skipping", origin, dest)
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking but we should extract this into utils so we can have a common API to validate absolute path resolution (ref 8a7c037)

@0xalpharush 0xalpharush added this to the 0.3.2 milestone Jun 20, 2023
@montyly montyly added this pull request to the merge queue Jun 21, 2023
Merged via the queue into dev with commit 6c77b09 Jun 21, 2023
@0xalpharush 0xalpharush deleted the fix-etherscan-remappings branch January 22, 2024 18:38
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.

Problems with etherscan multi-file node_modules contract Etherscan fails on foundry project Etherscan: compile with correct settings

4 participants