evm-gauntlet-vrfv2plus
这个软件包执行各种部署和管理VRF V2+合同的命令.
见 这里 用于支助业务和相关文件.
仓库依赖性
- 有合同的链路链接存储器 : 链路
所需工具
- 线条
- 强克
- 铸造
- 数字
- 节点.js
- [email protected] (韩语)
设置
# cd into gauntlet-evm repo
$ cd gauntlet-evm
$ nvm use
$ yarn # Installs node.js dependencies
运行测试
从根目录 gauntlet-evm 运行以下操作以触发所有测试 :
yarn test --selectProjects evm-gauntlet-vrfv2plus
或者,如果你想运行一个特定的测试:
yarn test packages/evm-gauntlet-vrfv2plus/tests/batchblockhashstore.test.ts
更新合同 ABIs 和字节代码
使用脚本
有一个脚本可以帮助您生成所有元数据文件( 您可以在 scripts 文件夹).
在运行脚本之前, 请确定您是否正确 foundry.toml 财务报告和审定财务报表 remappings.txt 配置设置 。 如果没有,则遵循以下手册步骤指南中的步骤1-4。 否则,剧本会警告您缺少配置. 还有 别忘了在使用脚本之前安装铸币局!
这样就可以运行取代下面所解释的所有手动步骤的脚本,生成所有必要的元数据 VRFCoordinatorV2_5.sol 合同:
$ ./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_coordinator
旗帜如下:
- -m: 本地链路链接寄存器复制的绝对路径( root)
- -c: 本地链路库中合同文件的绝对路径
- -g : 本地 grandlet- evm 寄存器的绝对路径( root)
- -v: 保存所有生成文件的版本文件夹( 如 v1, v2)
- -p: 要使用的创建配置文件( 如果未指定默认配置文件, 可使用可选参数, 设置为
vrfv2plus用于使用 VRF v2.5 默认配置文件或设置为vrfv2plus_coordinator以使用 VRF 协调员V2 5 合同的简介) - -o: 优化器运行的次数( 可选参数, 默认值是 Foundry.toml " 文件 " Foundry.toml " 中来自 Frantry VRF 配置文件的一个)
已知的脚本问题
由于模块或锁文件已经被使用,脚本可能失败. 如果遇到这些问题,这是因为同时使用不同的依赖管理器导致相撞. 那样的话,去你的 chainlink 本地仓库在内部运行 contracts 文件夹并运行以下一些来清理 :
$ npm run clean # should be sufficient, you could also try yarn clean
$ rm -rf node_modules # in case nothing else works
手工步骤
这些步骤将指导你如何(重建)建立合同.
-
转到本地链路链链芯回波设置
$ cd chainlink/contracts -
更新
foundry.toml在合同目录中包含以下配置文件(除非这些配置文件已经存在,否则不要更新任何东西!)[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' -
更新
remappings.txt合同目录中的文件,将 Openzeppelin 指向一个供应商目录而不是节点(如果需要,将 OpenZeppelin 版本调整为合同中使用的版本)@openzeppelin/=src/v0.8/vendor/openzeppelin-solidity/v4.9.3 -
下载和复制
@openzeppelin/[email protected]本地供应商目录的代码$ nvm use $ npm install -g @openzeppelin/[email protected] # 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/ -
安装创建并运行伪造构建 VRF协调员V2 5, BlockhashStore和VRFV2PlusWrapper (变动)
FOUNDRY_PROFILE将配置名称从foundry.toml如果您想要使用默认配置文件, 文件或省略)$ 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.json以防您使用 Apple Clang 與您相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相
solcLongVersion生成的构建文件中的参数( EtherScan 或其他一些区块链浏览器可能拒绝进行其他校验, 请检查 在 EtherScan 上支持的团结版本) (中文(简体) ). 你可以这样做:sed 's/.Darwin.appleclang//g' build/BatchVRFCoordinatorV2Plus.json > build/BatchVRFCoordinatorV2Plus_fixed.json mv build/BatchVRFCoordinatorV2Plus_fixed.json build/BatchVRFCoordinatorV2Plus.json很少有最后的触摸:
# 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.json重复BlockhashStore和VRFV2PlusWrapper合同(或任何其他合同)的这一过程.
-
运行 hardhat 编译生成元数据( 例如
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 [email protected] $ 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
为新合同添加命令
-
要添加新合同, 请在
commands文件夹和每个命令添加一个文件+ 不要忘记添加index.ts文档. -
增加新的合同类别
packages/evm-gauntlet-vrfv2plus/src/lib/categories.ts,合同装入器packages/evm-gauntlet-vrfv2plus/src/lib/contracts.ts新的合同类型(如有必要)packages/evm-gauntlet-vrfv2plus/src/lib/types.ts。 。 。 . -
更新命令根索引
packages/evm-gauntlet-vrfv2plus/src/commands/index.ts以新的命令扩展它. -
运行时您应该可以看到新的命令
yarn gauntlet help。 。 。 .
软件包发布
-
在
gauntlet-evm复发. -
在同一 PR 中添加更改列表
yarn changeset add,编辑从主要到次要的更改器文件,并获得 PR 的接受并合并. -
释放新的
gauntlet-evm软件包: 一旦检测到更改器develop分支, CI 将自动创建一个新的 PR 以发布软件包, 批准此 PR并合并它( 合并将启动软件包的创建, 然后您可以在软件包的页面上找到) -
如果您希望此更改可用于 勇士工具,然后,你必须确保 Gauntlet 更新 新的
gauntlet-evm-vrfv2plus软件包版本 -
在 Gauntlet 仓库 通过升级
gauntlet-evm-vrfv2plus软件包版本packages/gauntlet-evm运行以下命令:yarn add @chainlink/[email protected] # replace X.Y.Z with the correct version -
在同一 PR 中添加更改列表
yarn changeset add,编辑从主要到次要的更改器文件,并获得 PR 的接受并合并. -
释放新的
gauntlet软件包: 一旦检测到更改器develop分支, CI 将自动创建一个新的 PR 以发布软件包, 批准此 PR并合并它( 合并将启动软件包的创建, 然后您可以在软件包的页面上找到)
文档
完成所有工作时,请确保更新以下文件: