feat: adding a use_latest_patch option to solc compiler config #1383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
I've noticed that there's an issue with the chainlink contract
0x514910771AF9Ca656af840dff83E8264EcF986CA
wrt. to overloaded events. This contract is bothERC-20
andERC-677
based and so it emits both types of events which have a different signature and can't be matched properly with log filters. AFAIS, overloaded events have been fixed in solidity compiler version0.4.17
, the contract defines0.4.16
in its pragma version. The fact that brownie doesn't compile solidity contracts with version<0.4.22
causes it to use the given abi from the explorer etherscan which is also incomplete in terms of overloaded events. To overcome this issue and generate a more complete abi I've added a solc compiler setting that enables the download of the latest patch version of a given compiler based on the contract's version pragma.How I did it
In this change, I've implemented a solidity compiler config flag called
use_latest_patch
.It can be turned on for all contracts by setting the value
true
:Alternatively, specific contracts can be added as a string list:
In both cases the latest semver patch version of the solc compiler is downloaded and if it's >= 0.4.22 this causes local re-compilation of the contract with the latest compiler instead of the one which is hard-coded in the contract sources.
For the chainlink contract, this fixes the issue that the abi contained only a single Transfer event definition and now includes both event definitions as the re-compilation is done locally.
How to verify it
The contract 0x514910771AF9Ca656af840dff83E8264EcF986CA specifies the compiler version
0.4.16
in its source code.The latest patch semver version for solidity is therefore
0.4.26
If the flag is set to either true or if the contract is contained in the list, the
0.4.26
version will be used, otherwise the0.4.16
will be used.Checklist