From 6009296a13468baf7c337b6d32e66aa4349296c8 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 22 Sep 2022 14:23:50 +0200 Subject: [PATCH 1/3] Improved sortition-pools dependency to the most recent version The most recent version has the chaosnet support. --- solidity/random-beacon/package.json | 2 +- solidity/random-beacon/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/solidity/random-beacon/package.json b/solidity/random-beacon/package.json index 3873787c9e..95c7fc94ac 100644 --- a/solidity/random-beacon/package.json +++ b/solidity/random-beacon/package.json @@ -34,7 +34,7 @@ }, "dependencies": { "@keep-network/hardhat-helpers": "^0.6.0-pre.15", - "@keep-network/sortition-pools": "^2.0.0-pre.13", + "@keep-network/sortition-pools": "^2.0.0-pre.15", "@openzeppelin/contracts": "^4.6.0", "@thesis/solidity-contracts": "github:thesis/solidity-contracts#4985bcf", "@threshold-network/solidity-contracts": "development" diff --git a/solidity/random-beacon/yarn.lock b/solidity/random-beacon/yarn.lock index 611ad69d4d..aa36abb3cb 100644 --- a/solidity/random-beacon/yarn.lock +++ b/solidity/random-beacon/yarn.lock @@ -978,10 +978,10 @@ "@openzeppelin/upgrades" "^2.7.2" openzeppelin-solidity "2.4.0" -"@keep-network/sortition-pools@^2.0.0-pre.13": - version "2.0.0-pre.13" - resolved "https://registry.yarnpkg.com/@keep-network/sortition-pools/-/sortition-pools-2.0.0-pre.13.tgz#80dbe8066ce378ae4242c3aef6864224477a9e41" - integrity sha512-+6VXCJyYT3+HApDExeySHjOgezg+umvdpm5lZXIUlhSx7xmbXSK/YwLXkdeWkGyVdyfwRO4ZXo1CbscbC0XGnA== +"@keep-network/sortition-pools@^2.0.0-pre.15": + version "2.0.0-pre.15" + resolved "https://registry.yarnpkg.com/@keep-network/sortition-pools/-/sortition-pools-2.0.0-pre.15.tgz#3a289f7cd502e5d6c629f2fb625d390b77c02950" + integrity sha512-FuEk6uvIL5n82LnxyP6piV8Y7eRae3Vp7n1yQcSK2M9+gaZqzT1eaxX6FtZrXMzAOz3M+aQ8X3DVEyTScQOO2Q== dependencies: "@openzeppelin/contracts" "^4.3.2" "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" From 2b11100458870ac5d01b0dce2432a5638353beb0 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 22 Sep 2022 14:29:22 +0200 Subject: [PATCH 2/3] Transfer chaosnet owner role when deploying beacon sortition pool --- .../deploy/02_deploy_beacon_sortition_pool.ts | 10 +++++++++- solidity/random-beacon/hardhat.config.ts | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/solidity/random-beacon/deploy/02_deploy_beacon_sortition_pool.ts b/solidity/random-beacon/deploy/02_deploy_beacon_sortition_pool.ts index c4e70cffe0..ba85297faa 100644 --- a/solidity/random-beacon/deploy/02_deploy_beacon_sortition_pool.ts +++ b/solidity/random-beacon/deploy/02_deploy_beacon_sortition_pool.ts @@ -3,7 +3,8 @@ import type { DeployFunction } from "hardhat-deploy/types" const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const { getNamedAccounts, deployments, helpers } = hre - const { deployer } = await getNamedAccounts() + const { deployer, chaosnetOwner } = await getNamedAccounts() + const { execute } = deployments const { to1e18 } = helpers.number const POOL_WEIGHT_DIVISOR = to1e18(1) // TODO: Update value @@ -18,6 +19,13 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { waitConfirmations: 1, }) + await execute( + "BeaconSortitionPool", + { from: deployer }, + "transferChaosnetOwnerRole", + chaosnetOwner + ) + if (hre.network.tags.etherscan) { await helpers.etherscan.verify(BeaconSortitionPool) } diff --git a/solidity/random-beacon/hardhat.config.ts b/solidity/random-beacon/hardhat.config.ts index 85c9211a57..683bb6ed86 100644 --- a/solidity/random-beacon/hardhat.config.ts +++ b/solidity/random-beacon/hardhat.config.ts @@ -120,6 +120,11 @@ const config: HardhatUserConfig = { goerli: 0, // mainnet: "" }, + chaosnetOwner: { + default: 3, + goerli: 0, + // mainnet: "" + }, }, external: { contracts: From a56ed7114b197b694e69a3daac76413246d0eae2 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Thu, 22 Sep 2022 14:30:24 +0200 Subject: [PATCH 3/3] Deactivate chaosnet for random beacon contract unit tests --- solidity/random-beacon/test/BeaconDkgValidator.test.ts | 2 ++ solidity/random-beacon/test/fixtures/index.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/solidity/random-beacon/test/BeaconDkgValidator.test.ts b/solidity/random-beacon/test/BeaconDkgValidator.test.ts index fc21175cb2..8a33b32cc8 100644 --- a/solidity/random-beacon/test/BeaconDkgValidator.test.ts +++ b/solidity/random-beacon/test/BeaconDkgValidator.test.ts @@ -42,6 +42,8 @@ const fixture = async () => { constants.poolWeightDivisor )) as SortitionPool + await sortitionPool.deactivateChaosnet() + const DKGValidator = await ethers.getContractFactory("BeaconDkgValidator") const dkgValidator = (await DKGValidator.deploy( sortitionPool.address diff --git a/solidity/random-beacon/test/fixtures/index.ts b/solidity/random-beacon/test/fixtures/index.ts index 3016eaa2de..c35518a990 100644 --- a/solidity/random-beacon/test/fixtures/index.ts +++ b/solidity/random-beacon/test/fixtures/index.ts @@ -80,7 +80,7 @@ export async function randomBeaconDeployment(): Promise { const staking: TokenStaking = await helpers.contracts.getContract("TokenStaking") - const { deployer } = await helpers.signers.getNamedSigners() + const { deployer, chaosnetOwner } = await helpers.signers.getNamedSigners() const sortitionPool: SortitionPool = await helpers.contracts.getContract( "BeaconSortitionPool" @@ -103,6 +103,8 @@ export async function randomBeaconDeployment(): Promise { await updateTokenStakingParams(t, staking, deployer) await setFixtureParameters(randomBeacon) + await sortitionPool.connect(chaosnetOwner).deactivateChaosnet() + const contracts: DeployedContracts = { sortitionPool, staking,