@chainlink/evm-gauntlet-vrfv2plus v5.13.0
evm-gauntlet-vrfv2plus
This package implements various commands for deploying and managing VRF V2+ contracts.
See here for supported operations and associated documentation.
Repository dependencies
- Chainlink repository with contracts: chainlink
Required tools
- yarn
- jq
- foundry
- nvm
- node.js
- pnpm@8.6.2
Setup
# cd into gauntlet-evm repo
$ cd gauntlet-evm
$ nvm use
$ yarn # Installs node.js dependenciesRunning Tests
From the root directory of gauntlet-evm run the following to trigger all tests:
yarn test --selectProjects evm-gauntlet-vrfv2plusOr if you want to run a specific test only:
yarn test packages/evm-gauntlet-vrfv2plus/tests/batchblockhashstore.test.tsUpdate Contract ABIs and Bytecode
Using the script
There is a script you can use to help you with generating all the metadata files (you can find it in the scripts folder).
Prior to running the script, make sure that you have the correct foundry.toml and remappings.txt configuration set. If not, follow steps 1-4 in the manual steps guide below. Otherwise, the script will warn you about missing configuration. Also, don't forget to install Foundry prior to using the script!
This is how you can run the script that replaces all the manual steps explained below to generate all the necessary metadata for VRFCoordinatorV2_5.sol contract:
$ ./gen-vrf-contract-metadata.sh \
-m /path/to/chainlink \
-c /path/to/chainlink/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol \
-g /path/to/gauntlet-evm
-v /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm/v2
-p vrfv2plus_coordinatorFlags are as following:
- -m : absolute path to your local chainlink repository copy (root)
- -c : absolute path to the contract file in your local chainlink repository
- -g : absolute path to your local gauntlet-evm repository copy (root)
- -v : version folder where to store all generated files (e.g. v1, v2)
- -p : Foundry profile to use (optional parameter, if not specified default profile will be used, set to
vrfv2plusfor using VRF v2.5 default profile or set tovrfv2plus_coordinatorto use the profile for VRFCoordinatorV2_5 contract) - -o : number of optimizer runs (optional parameter, default value is the one from the Foundry VRF profile in `foundry.toml
file)
Known script issues
Script failures may be possible due to missing modules or lock file already being used. If you experience these issues, this is due to simultaneous use of different dependency managers resulting in collisions. In that case, go to your chainlink local repository run inside contracts folder and run some of the following to clean up:
$ npm run clean # should be sufficient, you could also try yarn clean
$ rm -rf node_modules # in case nothing else worksManual steps
These steps will guide you how to (re)build contracts.
- Go to chainlink core repo setup locally
$ cd chainlink/contracts Update
foundry.tomlfile in contracts directory with following profiles (unless these profiles already exist, then don't update anything!)[profile.vrfv2plus_coordinator] optimizer_runs = 500 src = 'src/v0.8/vrf' solc_version = '0.8.19' [profile.vrfv2plus] optimizer_runs = 1_000_000 src = 'src/v0.8/vrf' solc_version = '0.8.19'Update
remappings.txtfile in contracts directory to have openzeppelin point to a vendor directory rather than node_modules (if needed, adjust OpenZeppelin version to the one used in contracts)@openzeppelin/=src/v0.8/vendor/openzeppelin-solidity/v4.9.3- Download and copy
@openzeppelin/contracts@4.9.3code to local vendor directory$ nvm use $ npm install -g @openzeppelin/contracts@4.9.3 # Update node.js version accordingly in the command below $ cp -r ~/.nvm/versions/node/18.12.0/lib/node_modules/@openzeppelin/contracts/ ./src/v0.8/vendor/openzeppelin-solidity/v4.9.3/contracts/ Install Foundry and run forge build for VRFCoordinatorV2_5, BlockhashStore and VRFV2PlusWrapper (change
FOUNDRY_PROFILEto profile name fromfoundry.tomlfile or omit if you want to use the default profile)$ FOUNDRY_PROFILE=<profile_name> forge build --contracts src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol --force --build-info-path=./build --build-info --skip test --skip scripts $ mv build/1d042417803331c5f14babf40ad6faee.json build/VRFCoordinatorV2_5.build.jsonIn case you are using Apple Clang with you Solidity compiler, make sure to remove "Darwin.appleclang" tag from the
solcLongVersionparameter in the generated build file (otherwise verification might be rejected by EtherScan or some other blockchain explorer, check supported Solidity versions on EtherScan). You can do it like this:sed 's/.Darwin.appleclang//g' build/BatchVRFCoordinatorV2Plus.json > build/BatchVRFCoordinatorV2Plus_fixed.json mv build/BatchVRFCoordinatorV2Plus_fixed.json build/BatchVRFCoordinatorV2Plus.jsonFew more finishing touches:
# now remove all whitespaces and make the build file more compact $ cat ./build/VRFCoordinatorV2_5.build.json | jq -c . > ./build/VRFCoordinatorV2_5_compact.build.json # copy the file to gauntlet-evm inside artifacts folder $ cp /path/to/chainlink/build/VRFCoordinatorV2_5_compact.build.json /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm/VRFCoordinatorV2_5.build.jsonRepeat this process for BlockhashStore and VRFV2PlusWrapper contracts (or any other contracts).
Run hardhat compile to generate metadata (example for
VRFCoordinatorV2_5.sol)# Make sure you are in the contrats folder (chainlink repo) $ cd ./contracts # The following command will use the settings for VRFCoordinatorV2_5 in hardhat.config.js # overrides section and the defaults (1 million optimizations) for wrapper and BHS $ nvm use # If specific node.js version not installed, install it using nvm install v16.16.0 $ npm install -g pnpm@9.0.6 $ pnpm i $ pnpm hardhat compile # After running the above command, you should see the appropriate output in: # artifacts/src/v0.8/vrf/dev/<ContractName>.sol/<ContractName>.json # Example: artifacts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol/VRFCoordinatorV2_5.json # copy the metadata file to a correct location in the gauntlet-evm repo $ cp ./artifacts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol/VRFCoordinatorV2_5.json /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm
Add commands for new contracts
To add a new contract, create a separate subfolder under
commandsfolder and add one file per command plus don't forget to add theindex.tsfile.Add new contract category in
packages/evm-gauntlet-vrfv2plus/src/lib/categories.ts, contract loader inpackages/evm-gauntlet-vrfv2plus/src/lib/contracts.tsand new contract types (if necessary) inpackages/evm-gauntlet-vrfv2plus/src/lib/types.ts.Update commands root index in
packages/evm-gauntlet-vrfv2plus/src/commands/index.tsby extending it with new commands.You should be able to see new commands when you run
yarn gauntlet help.
Package release
Create a PR in
gauntlet-evmrepo.Add a changeset in the same PR
yarn changeset add, edit the changeset file from major to minor and get the PR accepted and merged.Release the new
gauntlet-evmpackage: once changeset is detected ondevelopbranch, CI will automatically create a new PR to release the package, approve this PR and merge it (merge will initiate package creation and then you can find it on the Releases page)If you want this change to be available for the Gauntlet tool, then you have to make sure Gauntlet is updated with the new
gauntlet-evm-vrfv2pluspackage versionCreate a PR on the Gauntlet repository by upgrading the
gauntlet-evm-vrfv2pluspackage version in thepackages/gauntlet-evmby running the following command:yarn add @chainlink/evm-gauntlet-vrfv2plus@X.Y.Z # replace X.Y.Z with the correct versionAdd changeset in the same PR
yarn changeset add, edit the changeset file from major to minor and get the PR accepted and merged.Release the new
gauntletpackage: once changeset is detected ondevelopbranch, CI will automatically create a new PR to release the package, approve this PR and merge it (merge will initiate package creation and then you can find it on the Releases page)
Documentation
When everything is finished, make sure to update the following docs:
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago