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
imp(contracts): Improve make command to compile smart contracts #2487
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…racts into testdata subfolder
Signed-off-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
GAtom22
reviewed
Apr 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @MalteHerrmann!!
Left a few questions
…ta folders to clean up the production code
0xstepit
approved these changes
Apr 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @MalteHerrmann! 👏 left some nits
ramacarlucho
approved these changes
Apr 23, 2024
Co-authored-by: Ramiro Carlucho <ramirocarlucho@gmail.com> Co-authored-by: stepit <48993133+0xstepit@users.noreply.github.com> Signed-off-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
…d usage in test contracts
# Conflicts: # CHANGELOG.md # contracts/erc20.go # contracts/erc20DirectBalanceManipulation.go # contracts/erc20burnable.go # contracts/erc20maliciousdelayed.go # contracts/flash_loan.go # precompiles/bank/testdata/bank.go # precompiles/distribution/integration_test.go # precompiles/erc20/testdata/erc20_allowance_caller.go # precompiles/erc20/testdata/erc20_no_metadata.go # precompiles/erc20/testdata/erc20minter_openzeppelinv5.go # precompiles/ics20/integration_test.go # precompiles/staking/integration_test.go # precompiles/staking/testdata/staking_caller.go # precompiles/testutil/contracts/distribution_caller.go # precompiles/testutil/contracts/interchain_sender.go # precompiles/vesting/integration_test.go # precompiles/vesting/testdata/vesting_caller.go # precompiles/werc20/testdata/wevmos.go # x/erc20/keeper/utils_test.go # x/evm/statedb/integration_test.go
MalteHerrmann
commented
Apr 24, 2024
Signed-off-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Signed-off-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR is tackling something that has bugged me for a long time, which is that the compilation of the JSON data for smart contracts was not as easily done as I would have liked it to be. E.g. for the files in the testdata in the precompiles, one would have to add those into Remix along with all other related contracts, then compile them, stringify the ABI and copy the bytecode into the corresponding JSON file.
To make this easier, I've turned the
contracts
subdirectory into a Hardhat project and built thecompile_smart_contracts.py
script. This is scanning the repository for available Solidity smart contracts with a corresponding JSON file, copies all available.sol
files, compiles them, and then overwrites the available JSON files with the updated version.To compile the available smart contracts, run:
To clean the
contracts
directory from build artifacts and downloaded dependencies, run:In order to add a new contract, for which a corresponding JSON file should be generated, run:
In order to support the structure of JSON files generated by Hardhat, it was necessary to add a new type
evmtypes.HardhatCompiledContract
, which contains a method to convert those into the expectedevmtypes.CompiledContract
which is the prior format.In addition to the changes above, @GAtom22 pointed out that the instantiation of the smart contracts in
init()
functions is very noisy as test-related data is set up every time that a production node is started. This is cleaned up in this PR as well by introducing dedicated functions to load the contracts in the tests.Closes: ENG-1777