Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []) {
Expand All @@ -34,11 +35,16 @@ export async function makeTx(
withStateFile = true,
): Promise<ContractTransactionReceipt> {
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;
Expand All @@ -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")');
Expand All @@ -70,18 +77,25 @@ async function deployContractType2(
): Promise<DeployedContract> {
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) {
throw new Error(`Failed to wait till the transaction ${tx.hash} execution!`);
}

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;
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions lib/ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`,
Expand Down Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion lib/scratch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const resolveMigrationFile = (step: string): string => {
export async function applyMigrationScript(migrationFile: string): Promise<void> {
const fullPath = path.resolve(migrationFile);
const { main } = await import(fullPath);

if (typeof main !== "function") {
throw new MigrationMainFunctionError(migrationFile);
}
Expand Down
14 changes: 8 additions & 6 deletions scripts/scratch/deployed-testnet-defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"voting": {
"minSupportRequired": "500000000000000000",
"minAcceptanceQuorum": "50000000000000000",
"voteDuration": 900,
"objectionPhaseDuration": 300
"voteDuration": 60,
"objectionPhaseDuration": 5
},
"fee": {
"totalPercent": 10,
Expand All @@ -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,
Expand All @@ -73,7 +75,7 @@
"hashConsensusForAccountingOracle": {
"deployParameters": {
"fastLaneLengthSlots": 10,
"epochsPerFrame": 12
"epochsPerFrame": 8
}
},
"accountingOracle": {
Expand All @@ -84,7 +86,7 @@
"hashConsensusForValidatorsExitBusOracle": {
"deployParameters": {
"fastLaneLengthSlots": 10,
"epochsPerFrame": 4
"epochsPerFrame": 8
}
},
"validatorsExitBusOracle": {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/scratch/steps/0020-deploy-aragon-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function deployAPM(
async function deployAragonID(owner: string, ens: LoadedContract<ENS>) {
// 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";
Expand Down
4 changes: 2 additions & 2 deletions scripts/scratch/steps/0040-register-ens-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions scripts/scratch/steps/0070-deploy-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -126,7 +127,7 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt)
log.success(idsCheckDesc);

const kernel = await loadContract<Kernel>("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 } } = {};
Expand All @@ -136,9 +137,9 @@ async function saveStateFromNewDAOTx(newDAOReceipt: ContractTransactionReceipt)
const proxyAddress = ethers.getAddress(evt.args.appProxy);

const proxy = await loadContract<ERCProxy>("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)}`;
Expand Down Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 59 additions & 27 deletions scripts/scratch/steps/0130-grant-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,51 @@ 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>("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) {
const validatorsExitBusOracle = await loadContract<ValidatorsExitBusOracle>(
"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();
Expand All @@ -61,29 +75,47 @@ export async function main() {
// WithdrawalQueue
const withdrawalQueue = await loadContract<WithdrawalQueueERC721>("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>("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,
});
}
Loading