Skip to content

Commit

Permalink
feat(scratch): make deploy of DepositSecurityModule optional
Browse files Browse the repository at this point in the history
  • Loading branch information
arwer13 committed Jan 23, 2024
1 parent da5bc51 commit eb93149
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 23 deletions.
3 changes: 2 additions & 1 deletion deployed-testnet-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"deployParameters": {
"maxDepositsPerBlock": 150,
"minDepositBlockDistance": 5,
"pauseIntentValidityPeriodBlocks": 6646
"pauseIntentValidityPeriodBlocks": 6646,
"usePredefinedAddressInstead": null
}
},
"oracleReportSanityChecker": {
Expand Down
9 changes: 5 additions & 4 deletions docs/scratch-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
## General info

The repo contains bash scripts for deployment of the DAO under multiple environments:
- local node (ganache, anvil, hardhat network) `dao-local-deploy.sh`
- holesky testnet - `dao-holesky-deploy.sh`
- local node (ganache, anvil, hardhat network) `scripts/scratch/dao-local-deploy.sh`
- holesky testnet - `scripts/scratch/dao-holesky-deploy.sh`

The protocol has a bunch of parameters to configure for the scratch deployment. The default configuration is stored in files `deployed-<deploy env>-defaults.json`, where `<deploy env>` is the target environment. Currently, there is a single default configuration, `deployed-testnet-defaults.json`, suitable for testnet deployments. Compared to the mainnet configuration, it has lower vote durations, more frequent oracle report cycles, etc. Part of the parameters require further specification -- they are marked with `null` values.
During the deployment, the "default" configuration is copied to `deployed-<network name>.json`, where `<network name>` is the name of a network configuration defined in `hardhat.config.js`. The file `deployed-<network name>.json` gets populated with the contract addresses and transaction hashes during the deployment process.
Expand Down Expand Up @@ -91,8 +91,9 @@ To do Holešky deployment, the following parameters must be set up via env varia
- `RPC_URL`. Address of of the Ethereum RPC node to use. E.g. for Infura it is `https://holesky.infura.io/v3/<yourProjectId>`
- `GAS_PRIORITY_FEE`. Gas priority fee. By default set to `2`
- `GAS_MAX_FEE`. Gas max fee. By default set to `100`
- `GATE_SEAL_FACTORY`. Address of the [GateSeal Factory](https://github.com/lidofinance/gate-seals) contract. Must be deployed in advance. Can be set to any `0x0000000000000000000000000000000000000000` to debug deployment.
- `WITHDRAWAL_QUEUE_BASE_URI`. BaseURI for WithdrawalQueueERC712. By default not set (left an empty string).
- `GATE_SEAL_FACTORY`. Address of the [GateSeal Factory](https://github.com/lidofinance/gate-seals) contract. Must be deployed in advance. Can be set to any `0x0000000000000000000000000000000000000000` to debug deployment
- `WITHDRAWAL_QUEUE_BASE_URI`. BaseURI for WithdrawalQueueERC712. By default not set (left an empty string)
- `DSM_PREDEFINED_ADDRESS`. Address to use instead of deploying `DepositSecurityModule` or `null` otherwise. If used, the deposits can be made by calling `Lido.deposit` from the address.

Also you need to specify `DEPLOYER` private key in `accounts.json` under `/eth/holesky` like `"holesky": ["<key>"]`. See `accounts.sample.json` for an example.

Expand Down
10 changes: 9 additions & 1 deletion scripts/scratch/00-populate-deploy-artifact-from-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const GATE_SEAL_FACTORY = process.env.GATE_SEAL_FACTORY
const GENESIS_TIME = parseInt(process.env.GENESIS_TIME)
const DEPOSIT_CONTRACT = process.env.DEPOSIT_CONTRACT
const WITHDRAWAL_QUEUE_BASE_URI = process.env.WITHDRAWAL_QUEUE_BASE_URI
const DSM_PREDEFINED_ADDRESS = process.env.DSM_PREDEFINED_ADDRESS

async function saveDeployParameters({ web3, artifacts }) {
async function saveDeployParameters({ web3 }) {
const netId = await web3.eth.net.getId()

console.log('Using env values:')
Expand Down Expand Up @@ -45,6 +46,13 @@ async function saveDeployParameters({ web3, artifacts }) {
baseUri: WITHDRAWAL_QUEUE_BASE_URI,
}
}
if (DSM_PREDEFINED_ADDRESS !== undefined) {
state.depositSecurityModule.deployParameters = {
...state.depositSecurityModule.deployParameters,
usePredefinedAddressInstead: DSM_PREDEFINED_ADDRESS,
}
state.depositSecurityModule.address = DSM_PREDEFINED_ADDRESS
}
persistNetworkState(network.name, netId, state)
}

Expand Down
27 changes: 16 additions & 11 deletions scripts/scratch/13-deploy-non-aragon-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,22 @@ async function deployNewContracts({ web3, artifacts }) {
//
// === DepositSecurityModule ===
//
const {maxDepositsPerBlock, minDepositBlockDistance, pauseIntentValidityPeriodBlocks} = depositSecurityModuleParams
const depositSecurityModuleArgs = [
lidoAddress,
depositContract,
stakingRouterAddress,
maxDepositsPerBlock,
minDepositBlockDistance,
pauseIntentValidityPeriodBlocks,
]
const depositSecurityModuleAddress = await deployWithoutProxy(
"depositSecurityModule", "DepositSecurityModule", deployer, depositSecurityModuleArgs)
let depositSecurityModuleAddress = depositSecurityModuleParams.usePredefinedAddressInstead
if (depositSecurityModuleAddress === null) {
const {maxDepositsPerBlock, minDepositBlockDistance, pauseIntentValidityPeriodBlocks} = depositSecurityModuleParams
const depositSecurityModuleArgs = [
lidoAddress,
depositContract,
stakingRouterAddress,
maxDepositsPerBlock,
minDepositBlockDistance,
pauseIntentValidityPeriodBlocks,
]
depositSecurityModuleAddress = await deployWithoutProxy(
"depositSecurityModule", "DepositSecurityModule", deployer, depositSecurityModuleArgs)
} else {
console.log(`NB: skipping deployment of DepositSecurityModule - using the predefined address ${depositSecurityModuleAddress} instead`)
}
logWideSplitter()

//
Expand Down
4 changes: 3 additions & 1 deletion scripts/scratch/19-transfer-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ async function deployNewContracts({ web3, artifacts }) {
await changeOssifiableProxyAdmin(state.validatorsExitBusOracle.proxy.address, deployer, agent)
await changeOssifiableProxyAdmin(state.withdrawalQueueERC721.proxy.address, deployer, agent)

await changeDepositSecurityModuleAdmin(state.depositSecurityModule.address, deployer, agent)
if (state.depositSecurityModule.deployParameters.usePredefinedAddressInstead === null) {
await changeDepositSecurityModuleAdmin(state.depositSecurityModule.address, deployer, agent)
}

await TotalGasCounter.incrementTotalGasUsedInStateFile()
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/scratch/20-check-dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ async function checkDAO({ web3, artifacts }) {
log.splitter()

const permissionsConfig = JSON.parse(fs.readFileSync('./scripts/scratch/checks/scratch-deploy-permissions.json'))
if (state.depositSecurityModule.deployParameters.usePredefinedAddressInstead !== null) {
delete permissionsConfig['depositSecurityModule']
}
await assertNonAragonPermissions(state, permissionsConfig)

log.splitter()
Expand Down
10 changes: 5 additions & 5 deletions scripts/scratch/checks/scratch-acceptance-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function loadDeployedProtocol(state) {
voting: await artifacts.require('Voting').at(state['app:aragon-voting'].proxy.address),
agent: await artifacts.require('Agent').at(state['app:aragon-agent'].proxy.address),
nodeOperatorsRegistry: await artifacts.require('NodeOperatorsRegistry').at(state['app:node-operators-registry'].proxy.address),
depositSecurityModule: await artifacts.require('DepositSecurityModule').at(state.depositSecurityModule.address),
depositSecurityModuleAddress: state.depositSecurityModule.address, // Deploying DepositSecurityModule might be omitted and e.g. EOA is used
accountingOracle: await artifacts.require('AccountingOracle').at(state.accountingOracle.proxy.address),
hashConsensusForAO: await artifacts.require('HashConsensus').at(state.hashConsensusForAccountingOracle.address),
elRewardsVault: await artifacts.require('LidoExecutionLayerRewardsVault').at(state.executionLayerRewardsVault.address),
Expand All @@ -68,13 +68,13 @@ async function prepareProtocolForSubmitDepositReportWithdrawalFlow(protocol, sta
voting,
agent,
nodeOperatorsRegistry,
depositSecurityModule,
depositSecurityModuleAddress,
hashConsensusForAO,
withdrawalQueue,
} = protocol

await ethers.provider.send('hardhat_impersonateAccount', [voting.address])
await ethers.provider.send('hardhat_impersonateAccount', [depositSecurityModule.address])
await ethers.provider.send('hardhat_impersonateAccount', [depositSecurityModuleAddress])
await ethers.provider.send('hardhat_impersonateAccount', [agent.address])

await lido.resume({ from: voting.address })
Expand Down Expand Up @@ -111,7 +111,7 @@ async function checkSubmitDepositReportWithdrawal(protocol, state, user1, user2)
const {
lido,
agent,
depositSecurityModule,
depositSecurityModuleAddress,
accountingOracle,
hashConsensusForAO,
elRewardsVault,
Expand All @@ -130,7 +130,7 @@ async function checkSubmitDepositReportWithdrawal(protocol, state, user1, user2)
assert.equals(await lido.getTotalPooledEther(), initialLidoBalance + BigInt(ETH(34)))
assert.equals(await lido.getBufferedEther(), initialLidoBalance + BigInt(ETH(34)))

await lido.deposit(MAX_DEPOSITS, CURATED_MODULE_ID, CALLDATA, { from: depositSecurityModule.address })
await lido.deposit(MAX_DEPOSITS, CURATED_MODULE_ID, CALLDATA, { from: depositSecurityModuleAddress })
log.success('Ether deposited')


Expand Down
1 change: 1 addition & 0 deletions scripts/scratch/dao-local-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export RPC_URL=${RPC_URL:="http://127.0.0.1:8555"} # if defined use the value s
export GATE_SEAL_FACTORY=0x0000000000000000000000000000000000000000
export GENESIS_TIME=1639659600 # just some time
# export WITHDRAWAL_QUEUE_BASE_URI="<< SET IF REQUIED >>"
# export DSM_PREDEFINED_ADDRESS="<< SET IF REQUIED >>"
#
export DEPLOYER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
export GAS_PRIORITY_FEE=1
Expand Down

0 comments on commit eb93149

Please sign in to comment.