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

963 Fixes #974

Merged
merged 2 commits into from
Feb 27, 2021
Merged

963 Fixes #974

merged 2 commits into from
Feb 27, 2021

Conversation

iamdefinitelyahuman
Copy link
Member

What I did

Address two issues reported in #963

  • inability to compile certain contracts (e.g. 0xEAA081a9fad4607CdF046fEA7D4BF3DfEf533282)
  • inability to process implementations for certain proxy contracts when in fork mode (e.g. 0x0b8f12b1788BFdE65Aa1ca52E3e9F3Ba401be16D)

Closes #963

How I did it

The compilation issue stems from an incorrect-length sourceMap output from the Solidity compiler. I'm not sure when/why this happens but sometimes the source map extends beyond the length of the actual bytecode. These final instructions appear to always have no related contact (the 3rd value within the source map). As such, to fix I trim all source map data from the right side, so long as it maps to contract id -1 (no contract). It's hacky and probably some edge case will appear, but.. such is the reality when working with Solidity.

The implementation issue is due to a regression in Ganache v6.12.2 where calls to eth_getStorageAt do not return leading zero bytes. To fix it, I do [-20:] instead of [12:] which has the same effect on a 32 byte hex string while correctly handling the 20 byte hex returned in that specific ganache version.

Thanks to @poolpitako for helping me find all this.

How to verify it

Hope and pray nothing else breaks.

this is required to handle a regression in ganache-cli v6.12.2
where storage slots are not left-padded with zero bytes
@iamdefinitelyahuman iamdefinitelyahuman merged commit 3eea03f into master Feb 27, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the fix-trim-sourcemap branch February 27, 2021 15:08
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.

Possible regresssion when fetching contract
2 participants