diff --git a/lib/deploy.ts b/lib/deploy.ts index 24aa589c64..90623ee328 100644 --- a/lib/deploy.ts +++ b/lib/deploy.ts @@ -16,6 +16,7 @@ const PROXY_CONTRACT_NAME = "OssifiableProxy"; type TxParams = { from: string; value?: bigint | string; + gasLimit?: bigint | string; }; function logWithConstructorArgs(message: string, constructorArgs: ConvertibleToString[] = []) { @@ -34,11 +35,16 @@ export async function makeTx( withStateFile = true, ): Promise { log.withArguments(`Call: ${yl(contract.name)}[${cy(contract.address)}].${yl(funcName)}`, args); + txParams["gasLimit"] = 16_000_000n; + const estimatedGas = await contract.getFunction(funcName).estimateGas(...args, txParams); + log(`Gas estimate: ${cy(estimatedGas.toString())}`); const tx = await contract.getFunction(funcName)(...args, txParams); + log(`Transaction sent: ${cy(tx.hash)}`); const receipt = await tx.wait(); const gasUsed = receipt.gasUsed; + log(`Gas used: ${cy(gasUsed.toString())}`); incrementGasUsed(gasUsed, withStateFile); return receipt; @@ -53,8 +59,9 @@ async function getDeployTxParams(deployer: string) { if (GAS_PRIORITY_FEE !== null && GAS_MAX_FEE !== null) { return { type: 2, - maxPriorityFeePerGas: ethers.parseUnits(String(GAS_PRIORITY_FEE), "gwei"), - maxFeePerGas: ethers.parseUnits(String(GAS_MAX_FEE), "gwei"), + maxPriorityFeePerGas: 1000000000n, // ethers.parseUnits(String(GAS_PRIORITY_FEE), "gwei"), + maxFeePerGas: 2000000000n, // ethers.parseUnits(String(GAS_MAX_FEE), "gwei"), + gasLimit: 16_000_000n, }; } else { throw new Error('Must specify gas ENV vars: "GAS_PRIORITY_FEE" and "GAS_MAX_FEE" in gwei (like just "3")'); @@ -70,11 +77,17 @@ async function deployContractType2( ): Promise { const txParams = await getDeployTxParams(deployer); const factory = (await ethers.getContractFactory(artifactName, signerOrOptions)) as ContractFactory; + + const deployTx = await factory.getDeployTransaction(...constructorArgs, txParams); + const estimatedGas = await ethers.provider.estimateGas(deployTx); + log(`Deploy gas estimate: ${cy(estimatedGas.toString())}`); + const contract = await factory.deploy(...constructorArgs, txParams); const tx = contract.deploymentTransaction(); if (!tx) { throw new Error(`Failed to send the deployment transaction for ${artifactName}`); } + log(`Deployment transaction sent: ${cy(tx.hash)}`); const receipt = await tx.wait(); if (!receipt) { @@ -82,6 +95,7 @@ async function deployContractType2( } const gasUsed = receipt.gasUsed; + log(`Deployment gas used: ${cy(gasUsed.toString())}`); incrementGasUsed(gasUsed, withStateFile); (contract as DeployedContract).deploymentGasUsed = gasUsed; (contract as DeployedContract).deploymentTx = tx.hash; @@ -248,7 +262,7 @@ async function getLocatorConfig(locatorAddress: string) { "oracleDaemonConfig", ] as (keyof LidoLocator.ConfigStruct)[]; - const configPromises = addresses.map((name) => locator[name]()); + const configPromises = addresses.map((name) => locator[name]({ gasLimit: 16_000_000 })); const config = await Promise.all(configPromises); diff --git a/lib/ens.ts b/lib/ens.ts index 8a281b4fc1..ab7a7c2c06 100644 --- a/lib/ens.ts +++ b/lib/ens.ts @@ -26,10 +26,10 @@ export async function assignENSName( log(`Label: ${yl(labelName)} (${cy(labelHash)})`); let receipt; - if ((await ens.owner(node)) === owner) { + if ((await ens.owner(node, { gasLimit: 16_000_000 })) === owner) { receipt = await makeTx(ens as unknown as LoadedContract, "setOwner", [node, assigneeAddress], { from: owner }); } else { - if ((await ens.owner(parentNode)) !== owner) { + if ((await ens.owner(parentNode, { gasLimit: 16_000_000 })) !== owner) { throw new Error( `the address ${owner} has no ownership rights over the target ` + `domain '${labelName}.${parentName}' or parent domain '${parentName}'`, @@ -57,6 +57,6 @@ export async function assignENSName( } export async function getENSNodeOwner(ens: ENS, node: string) { - const ownerAddr = await ens.owner(node); + const ownerAddr = await ens.owner(node, { gasLimit: 16_000_000 }); return ownerAddr == ethers.ZeroAddress ? null : ownerAddr; } diff --git a/lib/scratch.ts b/lib/scratch.ts index 4613f9d4ad..bf3de0cdec 100644 --- a/lib/scratch.ts +++ b/lib/scratch.ts @@ -102,7 +102,6 @@ export const resolveMigrationFile = (step: string): string => { export async function applyMigrationScript(migrationFile: string): Promise { const fullPath = path.resolve(migrationFile); const { main } = await import(fullPath); - if (typeof main !== "function") { throw new MigrationMainFunctionError(migrationFile); } diff --git a/scripts/scratch/deployed-testnet-defaults.json b/scripts/scratch/deployed-testnet-defaults.json index c0c0d5ce73..92022fc4f8 100644 --- a/scripts/scratch/deployed-testnet-defaults.json +++ b/scripts/scratch/deployed-testnet-defaults.json @@ -33,8 +33,8 @@ "voting": { "minSupportRequired": "500000000000000000", "minAcceptanceQuorum": "50000000000000000", - "voteDuration": 900, - "objectionPhaseDuration": 300 + "voteDuration": 60, + "objectionPhaseDuration": 5 }, "fee": { "totalPercent": 10, @@ -52,7 +52,9 @@ "0xCD1f9954330AF39a74Fd6e7B25781B4c24ee373f": "820000000000000000000000", "0xaa6bfBCD634EE744CB8FE522b29ADD23124593D3": "60000000000000000000000", "0xBA59A84C6440E8cccfdb5448877E26F1A431Fc8B": "60000000000000000000000", - "lido-aragon-agent-placeholder": "60000000000000000000000" + "lido-aragon-agent-placeholder": "60000000000000000000000", + "0x8943545177806ED17B9F23F0a21ee5948eCaa776": "820000000000000000000000", + "0xE25583099BA105D9ec0A67f5Ae86D90e50036425": "820000000000000000000000" }, "start": 0, "cliff": 0, @@ -73,7 +75,7 @@ "hashConsensusForAccountingOracle": { "deployParameters": { "fastLaneLengthSlots": 10, - "epochsPerFrame": 12 + "epochsPerFrame": 8 } }, "accountingOracle": { @@ -84,7 +86,7 @@ "hashConsensusForValidatorsExitBusOracle": { "deployParameters": { "fastLaneLengthSlots": 10, - "epochsPerFrame": 4 + "epochsPerFrame": 8 } }, "validatorsExitBusOracle": { @@ -121,7 +123,7 @@ "NORMALIZED_CL_REWARD_PER_EPOCH": 64, "NORMALIZED_CL_REWARD_MISTAKE_RATE_BP": 1000, "REBASE_CHECK_NEAREST_EPOCH_DISTANCE": 1, - "REBASE_CHECK_DISTANT_EPOCH_DISTANCE": 23, + "REBASE_CHECK_DISTANT_EPOCH_DISTANCE": 2, "VALIDATOR_DELAYED_TIMEOUT_IN_SLOTS": 7200, "VALIDATOR_DELINQUENT_TIMEOUT_IN_SLOTS": 28800, "NODE_OPERATOR_NETWORK_PENETRATION_THRESHOLD_BP": 100, diff --git a/scripts/scratch/steps/0020-deploy-aragon-env.ts b/scripts/scratch/steps/0020-deploy-aragon-env.ts index 7d3996216a..ec2a009353 100644 --- a/scripts/scratch/steps/0020-deploy-aragon-env.ts +++ b/scripts/scratch/steps/0020-deploy-aragon-env.ts @@ -45,7 +45,7 @@ async function deployAPM( async function deployAragonID(owner: string, ens: LoadedContract) { // Get public resolver const publicNode = ethers.namehash("resolver.eth"); - const publicResolverAddress = await ens.resolver(publicNode); + const publicResolverAddress = await ens.resolver(publicNode, { gasLimit: 16_000_000 }); log(`Using public resolver: ${cy(publicResolverAddress)}`); const nodeName = "aragonid.eth"; diff --git a/scripts/scratch/steps/0040-register-ens-domain.ts b/scripts/scratch/steps/0040-register-ens-domain.ts index d84f6cc454..bb8b097daa 100644 --- a/scripts/scratch/steps/0040-register-ens-domain.ts +++ b/scripts/scratch/steps/0040-register-ens-domain.ts @@ -39,8 +39,8 @@ export async function main() { log.emptyLine(); // Check ownership and perform necessary actions - const nodeOwner = await ens.owner(node); - const tldNodeOwner = await ens.owner(tldNode); + const nodeOwner = await ens.owner(node, { gasLimit: 16_000_000 }); + const tldNodeOwner = await ens.owner(tldNode, { gasLimit: 16_000_000 }); if (nodeOwner !== deployer && tldNodeOwner !== deployer) { throw new Error(`This branch is not implemented. diff --git a/scripts/scratch/steps/0070-deploy-dao.ts b/scripts/scratch/steps/0070-deploy-dao.ts index 77690daabd..4294f1e599 100644 --- a/scripts/scratch/steps/0070-deploy-dao.ts +++ b/scripts/scratch/steps/0070-deploy-dao.ts @@ -102,9 +102,10 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt) ); state = updateObjectInState(Sk.callsScript, { - address: await evmScriptRegistryFactory.baseCallScript(), + address: await evmScriptRegistryFactory.baseCallScript({ gasLimit: 16_000_000 }), contract: await getContractPath("CallsScript"), constructorArgs: [], + gasLimit: 16_000_000, }); // Process installed apps @@ -126,7 +127,7 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt) log.success(idsCheckDesc); const kernel = await loadContract("Kernel", kernelProxyAddress); - const APP_BASES_NAMESPACE = await kernel.APP_BASES_NAMESPACE(); + const APP_BASES_NAMESPACE = await kernel.APP_BASES_NAMESPACE({ gasLimit: 16_000_000 }); // Process each installed app const dataByAppName: { [key: string]: { [key: string]: string } } = {}; @@ -136,9 +137,9 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt) const proxyAddress = ethers.getAddress(evt.args.appProxy); const proxy = await loadContract("ERCProxy", proxyAddress); - const implAddress = await proxy.implementation(); + const implAddress = await proxy.implementation({ gasLimit: 16_000_000 }); - const kernelBaseAddr = await kernel.getApp(APP_BASES_NAMESPACE, appId); + const kernelBaseAddr = await kernel.getApp(APP_BASES_NAMESPACE, appId, { gasLimit: 16_000_000 }); // Verify app base const baseCheckDesc = `${appName}: the installed app base is ${cy(implAddress)}`; @@ -209,7 +210,7 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt) }; if (appName === Sk.aragonEvmScriptRegistry) { state[appName].implementation = { - address: await proxy.getFunction("implementation")(), + address: await proxy.getFunction("implementation")({ gasLimit: 16_000_000 }), contract: await getContractPath("EVMScriptRegistry"), constructorArgs: [], // see DAOFactory.newDAO and EVMScriptRegistryFactory.baseReg }; diff --git a/scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts b/scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts index 5cbe15d039..54e5e2193a 100644 --- a/scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts +++ b/scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts @@ -134,7 +134,7 @@ export async function main() { // Set OracleDaemonConfig parameters const oracleDaemonConfig = await loadContract("OracleDaemonConfig", oracleDaemonConfigAddress); - const CONFIG_MANAGER_ROLE = await oracleDaemonConfig.getFunction("CONFIG_MANAGER_ROLE")(); + const CONFIG_MANAGER_ROLE = await oracleDaemonConfig.getFunction("CONFIG_MANAGER_ROLE")({ gasLimit: 16_000_000 }); await makeTx(oracleDaemonConfig, "grantRole", [CONFIG_MANAGER_ROLE, testnetAdmin], { from: testnetAdmin }); // Set each parameter in the OracleDaemonConfig diff --git a/scripts/scratch/steps/0130-grant-roles.ts b/scripts/scratch/steps/0130-grant-roles.ts index 2ef6f4f5ea..15c8d6c6c7 100644 --- a/scripts/scratch/steps/0130-grant-roles.ts +++ b/scripts/scratch/steps/0130-grant-roles.ts @@ -22,27 +22,36 @@ export async function main() { const accountingOracleAddress = state[Sk.accountingOracle].proxy.address; const validatorsExitBusOracleAddress = state[Sk.validatorsExitBusOracle].proxy.address; const depositSecurityModuleAddress = state[Sk.depositSecurityModule].address; - // StakingRouter const stakingRouter = await loadContract("StakingRouter", stakingRouterAddress); await makeTx( stakingRouter, "grantRole", - [await stakingRouter.STAKING_MODULE_UNVETTING_ROLE(), depositSecurityModuleAddress], + [await stakingRouter.STAKING_MODULE_UNVETTING_ROLE({ gasLimit: 16_000_000 }), depositSecurityModuleAddress], { from: deployer }, ); await makeTx( stakingRouter, "grantRole", - [await stakingRouter.REPORT_EXITED_VALIDATORS_ROLE(), accountingOracleAddress], + [await stakingRouter.REPORT_EXITED_VALIDATORS_ROLE({ gasLimit: 16_000_000 }), accountingOracleAddress], { from: deployer }, ); - await makeTx(stakingRouter, "grantRole", [await stakingRouter.REPORT_REWARDS_MINTED_ROLE(), lidoAddress], { - from: deployer, - }); - await makeTx(stakingRouter, "grantRole", [await stakingRouter.STAKING_MODULE_MANAGE_ROLE(), agentAddress], { - from: deployer, - }); + await makeTx( + stakingRouter, + "grantRole", + [await stakingRouter.REPORT_REWARDS_MINTED_ROLE({ gasLimit: 16_000_000 }), lidoAddress], + { + from: deployer, + }, + ); + await makeTx( + stakingRouter, + "grantRole", + [await stakingRouter.STAKING_MODULE_MANAGE_ROLE({ gasLimit: 16_000_000 }), agentAddress], + { + from: deployer, + }, + ); // ValidatorsExitBusOracle if (gateSealAddress) { @@ -50,9 +59,14 @@ export async function main() { "ValidatorsExitBusOracle", validatorsExitBusOracleAddress, ); - await makeTx(validatorsExitBusOracle, "grantRole", [await validatorsExitBusOracle.PAUSE_ROLE(), gateSealAddress], { - from: deployer, - }); + await makeTx( + validatorsExitBusOracle, + "grantRole", + [await validatorsExitBusOracle.PAUSE_ROLE({ gasLimit: 16_000_000 }), gateSealAddress], + { + from: deployer, + }, + ); } else { log(`GateSeal is not specified or deployed: skipping assigning PAUSE_ROLE of validatorsExitBusOracle`); log.emptyLine(); @@ -61,29 +75,47 @@ export async function main() { // WithdrawalQueue const withdrawalQueue = await loadContract("WithdrawalQueueERC721", withdrawalQueueAddress); if (gateSealAddress) { - await makeTx(withdrawalQueue, "grantRole", [await withdrawalQueue.PAUSE_ROLE(), gateSealAddress], { - from: deployer, - }); + await makeTx( + withdrawalQueue, + "grantRole", + [await withdrawalQueue.PAUSE_ROLE({ gasLimit: 16_000_000 }), gateSealAddress], + { + from: deployer, + }, + ); } else { log(`GateSeal is not specified or deployed: skipping assigning PAUSE_ROLE of withdrawalQueue`); log.emptyLine(); } - - await makeTx(withdrawalQueue, "grantRole", [await withdrawalQueue.FINALIZE_ROLE(), lidoAddress], { - from: deployer, - }); - - await makeTx(withdrawalQueue, "grantRole", [await withdrawalQueue.ORACLE_ROLE(), accountingOracleAddress], { - from: deployer, - }); + await makeTx( + withdrawalQueue, + "grantRole", + [await withdrawalQueue.FINALIZE_ROLE({ gasLimit: 16_000_000 }), lidoAddress], + { + from: deployer, + }, + ); + await makeTx( + withdrawalQueue, + "grantRole", + [await withdrawalQueue.ORACLE_ROLE({ gasLimit: 16_000_000 }), accountingOracleAddress], + { + from: deployer, + }, + ); // Burner const burner = await loadContract("Burner", burnerAddress); // NB: REQUEST_BURN_SHARES_ROLE is already granted to Lido in Burner constructor - await makeTx(burner, "grantRole", [await burner.REQUEST_BURN_SHARES_ROLE(), nodeOperatorsRegistryAddress], { - from: deployer, - }); - await makeTx(burner, "grantRole", [await burner.REQUEST_BURN_SHARES_ROLE(), simpleDvtApp], { + await makeTx( + burner, + "grantRole", + [await burner.REQUEST_BURN_SHARES_ROLE({ gasLimit: 16_000_000 }), nodeOperatorsRegistryAddress], + { + from: deployer, + }, + ); + await makeTx(burner, "grantRole", [await burner.REQUEST_BURN_SHARES_ROLE({ gasLimit: 16_000_000 }), simpleDvtApp], { from: deployer, }); }