Skip to content

Commit

Permalink
feat: add sepolia testnet support
Browse files Browse the repository at this point in the history
  • Loading branch information
loga4 committed Apr 25, 2024
1 parent c2b14c7 commit 739a661
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 28 deletions.
2 changes: 0 additions & 2 deletions contracts/0.8.9/TriggerableExitMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
/* See contracts/COMPILERS.md */
pragma solidity 0.8.9;

import "hardhat/console.sol";

contract TriggerableExitMock {
address constant WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS = 0x00A3ca265EBcb825B45F985A16CEFB49958cE017;

Expand Down
15 changes: 15 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ const config: HardhatUserConfig = {
},
forking: HARDHAT_FORKING_URL ? { url: HARDHAT_FORKING_URL } : undefined,
},
sepolia: {
url: RPC_URL,
chainId: 11155111,
timeout: 60000 * 15,
accounts: [""],
urls: {
apiURL: "https://api-sepolia.etherscan.io/api",
browserURL: "https://sepolia.etherscan.io/",
},
},
},
etherscan: {
apiKey: {
sepolia: "",
},
},
solidity: {
compilers: [
Expand Down
2 changes: 2 additions & 0 deletions lib/state-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum Sk {
lidoLocator = "lidoLocator",
chainSpec = "chainSpec",
scratchDeployGasUsed = "scratchDeployGasUsed",
triggerableExitMock = "triggerableExitMock",
}

export function getAddress(contractKey: Sk, state: DeploymentState): string {
Expand Down Expand Up @@ -123,6 +124,7 @@ export function getAddress(contractKey: Sk, state: DeploymentState): string {
case Sk.oracleReportSanityChecker:
case Sk.wstETH:
case Sk.depositContract:
case Sk.triggerableExitMock:
return state[contractKey].address;
default:
throw new Error(`Unsupported contract entry key ${contractKey}`);
Expand Down
20 changes: 20 additions & 0 deletions scripts/scratch/dao-sepolia-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e +u
set -o pipefail

#
export NETWORK=sepolia
export RPC_URL=https://sepolia.drpc.org

export GENESIS_TIME=1639659600 # just some time
# export WITHDRAWAL_QUEUE_BASE_URI="<< SET IF REQUIED >>"
# export DSM_PREDEFINED_ADDRESS="<< SET IF REQUIED >>"
#
export DEPLOYER= # first acc of default mnemonic "test test ..."
export GAS_PRIORITY_FEE=2
export GAS_MAX_FEE=100
#
export NETWORK_STATE_FILE="deployed-${NETWORK}.json"
export NETWORK_STATE_DEFAULTS_FILE="scripts/scratch/deployed-testnet-defaults.json"

bash scripts/scratch/dao-deploy.sh
58 changes: 33 additions & 25 deletions scripts/scratch/steps/09-deploy-non-aragon-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,31 +125,6 @@ async function main() {
);
logWideSplitter();

//
// === WithdrawalVault ===
//
const withdrawalVaultImpl = await deployImplementation(Sk.withdrawalVault, "WithdrawalVault", deployer, [
lidoAddress,
treasuryAddress,
]);
state = readNetworkState();
const withdrawalsManagerProxyConstructorArgs = [votingAddress, withdrawalVaultImpl.address];
const withdrawalsManagerProxy = await deployContract(
"WithdrawalsManagerProxy",
withdrawalsManagerProxyConstructorArgs,
deployer,
);
const withdrawalVaultAddress = withdrawalsManagerProxy.address;
updateObjectInState(Sk.withdrawalVault, {
proxy: {
contract: await getContractPath("WithdrawalsManagerProxy"),
address: withdrawalsManagerProxy.address,
constructorArgs: withdrawalsManagerProxyConstructorArgs,
},
address: withdrawalsManagerProxy.address,
});
logWideSplitter();

//
// === LidoExecutionLayerRewardsVault ===
//
Expand Down Expand Up @@ -269,6 +244,39 @@ async function main() {
);
logWideSplitter();

//
// === TriggerableExitMock ===
//
const triggerableExitMock = await deployWithoutProxy(Sk.triggerableExitMock, "TriggerableExitMock", deployer);
logWideSplitter();

//
// === WithdrawalVault ===
//
const withdrawalVaultImpl = await deployImplementation(Sk.withdrawalVault, "WithdrawalVault", deployer, [
lidoAddress,
treasuryAddress,
validatorsExitBusOracle.address,
triggerableExitMock.address,
]);
state = readNetworkState();
const withdrawalsManagerProxyConstructorArgs = [votingAddress, withdrawalVaultImpl.address];
const withdrawalsManagerProxy = await deployContract(
"WithdrawalsManagerProxy",
withdrawalsManagerProxyConstructorArgs,
deployer,
);
const withdrawalVaultAddress = withdrawalsManagerProxy.address;
updateObjectInState(Sk.withdrawalVault, {
proxy: {
contract: await getContractPath("WithdrawalsManagerProxy"),
address: withdrawalsManagerProxy.address,
constructorArgs: withdrawalsManagerProxyConstructorArgs,
},
address: withdrawalsManagerProxy.address,
});
logWideSplitter();

//
// === Burner ===
//
Expand Down
9 changes: 8 additions & 1 deletion scripts/scratch/steps/13-grant-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function main() {
const deployer = (await ethers.provider.getSigner()).address;
const state = readNetworkState({ deployer });

const agent = state[Sk.appAgent].proxy.address;
const lidoAddress = state[Sk.appLido].proxy.address;
const nodeOperatorsRegistryAddress = state[Sk.appNodeOperatorsRegistry].proxy.address;
const gateSealAddress = state.gateSeal.address;
Expand Down Expand Up @@ -54,8 +55,8 @@ async function main() {
//
// === ValidatorsExitBusOracle
//
const validatorsExitBusOracle = await getContractAt("ValidatorsExitBusOracle", validatorsExitBusOracleAddress);
if (gateSealAddress) {
const validatorsExitBusOracle = await getContractAt("ValidatorsExitBusOracle", validatorsExitBusOracleAddress);
await makeTx(
validatorsExitBusOracle,
"grantRole",
Expand All @@ -66,6 +67,12 @@ async function main() {
} else {
log(`GateSeal is not specified or deployed: skipping assigning PAUSE_ROLE of validatorsExitBusOracle`);
}
await makeTx(
validatorsExitBusOracle,
"grantRole",
[await validatorsExitBusOracle.getFunction("SUBMIT_PRIORITY_DATA_ROLE")(), agent],
{ from: deployer },
);

//
// === WithdrawalQueue
Expand Down
92 changes: 92 additions & 0 deletions scripts/scratch/verify-contracts-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

#!/bin/bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

export NETWORK=sepolia
export RPC_URL=https://sepolia.drpc.org

if [[ -z "$NETWORK" ]]; then
echo "Must set NETWORK env variable" 1>&2
exit 1
fi

NETWORK_STATE_FILE="deployed-${NETWORK}.json"
if [ ! -f $NETWORK_STATE_FILE ]; then
echo "Cannot find network state file ${NETWORK_STATE_FILE}"
exit 1
fi
echo "Using network state file ${NETWORK_STATE_FILE}"

function jsonGet {
node -e "const fs = require('fs'); const obj = JSON.parse(fs.readFileSync('${NETWORK_STATE_FILE}', 'utf8')); const path='$1'; let res = path.split('.').reduce(function(o, k) {return o && o[k] }, obj); console.log(res)"
}

function verify {
contractPath="$(jsonGet ${1}.contract)"
contractName="${contractPath##*/}"
contractName="${contractName%.*}"
argsJson=$(jsonGet ${1}.constructorArgs)
echo "module.exports = $argsJson" > contract-args.js
npx hardhat --network $NETWORK verify --contract "$contractPath:$contractName" --constructor-args contract-args.js $(jsonGet ${1}.address)
}

# NB: Although most of the contracts listed below would be verified by running
# this bash script as it is, some might require some manual tweaking.
# Sometimes first attempt to verify fails without observable reason.
# Part of the contract require a workaround see SCRATCH_DEPLOY.md section
# "Issues with verification of part of the contracts deployed from factories".

verify dummyEmptyContract
verify burner
verify hashConsensusForAccountingOracle
verify hashConsensusForValidatorsExitBusOracle
verify accountingOracle.implementation
verify accountingOracle.proxy
verify validatorsExitBusOracle.implementation
verify validatorsExitBusOracle.proxy
verify triggerableExitMock
verify stakingRouter.implementation
verify stakingRouter.proxy
verify withdrawalQueueERC721.proxy
verify wstETH
verify executionLayerRewardsVault
verify eip712StETH
verify lidoTemplate
verify withdrawalVault.proxy
verify withdrawalVault.implementation
verify lidoLocator.proxy
verify lidoLocator.implementation
verify app:lido.implementation
verify app:oracle.implementation
verify app:node-operators-registry.implementation
verify app:aragon-voting.implementation
verify app:aragon-token-manager.implementation
verify app:aragon-finance.implementation
verify app:aragon-agent.implementation
verify oracleDaemonConfig
verify oracleReportSanityChecker
verify app:lido.proxy
verify depositSecurityModule
verify withdrawalQueueERC721.implementation
verify aragon-kernel.implementation
verify aragon-acl.implementation
verify aragon-kernel.proxy
verify ldo
verify callsScript
verify aragon-evm-script-registry.proxy
verify aragon-apm-registry.implementation
verify aragon-apm-registry.factory
verify aragon-app-repo-lido.implementation
verify aragon-app-repo-node-operators-registry.implementation
# NB: App Repos of lido, oracle, node-operators-registry, finance, agent, token-manager, voting
# share same implementation of Repo contract
verify aragon-evm-script-registry.proxy
verify aragon-evm-script-registry.implementation
verify app:simple-dvt.proxy
verify app:aragon-token-manager.proxy
verify app:oracle.proxy
verify app:node-operators-registry.proxy
verify app:aragon-voting.proxy
verify app:aragon-finance.proxy
verify app:aragon-agent.proxy

0 comments on commit 739a661

Please sign in to comment.