Conversation
WalkthroughThis pull request introduces two sets of changes. A new deployment script ( Changes
Sequence Diagram(s)sequenceDiagram
participant Script as LidoDeployScript
participant Env as Environment Vars
participant Ethers as ethers.utils
participant HF as Hardhat
participant Log as Console Log
Script->>Env: Fetch WstETH addresses
Script->>Ethers: Validate addresses
alt Invalid Address
Ethers-->>Script: Invalid result
Script->>Log: Log "token address is invalid"
Script->>Script: Exit with error
else Valid Addresses
Script->>HF: Retrieve contract factories
Script->>HF: Deploy L1LidoGateway & L2LidoGateway
HF-->>Script: Return contract instances
Script->>Log: Log deployed contract addresses
Script->>Script: End process
end
sequenceDiagram
participant Task as ProxyUpgradeTask
participant Ethers as hre.ethers.utils
participant Contract as Contract Instance
participant Log as Console Log
Task->>Ethers: Validate proxyadminaddr, proxyaddr, newimpladdr
alt Any Invalid Address
Ethers-->>Task: Return invalid result
Task->>Log: Log "token address invalid"
Task->>Task: Exit with error
else Valid Addresses
Task->>Task: Instantiate ProxyAdmin via correct contract interface
Task->>Task: Instantiate Proxy using ITransparentUpgradeableProxy
Task->>Contract: Call static implementation with proxyadminaddr context
Contract-->>Task: Return implementation address
Task->>Log: Log proxy upgrade details
end
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
contracts/scripts/lido_impl_deploy.ts (3)
1-6: Consider using TypeScript imports consistently.The code mixes CommonJS (
require) and ES6 (import) module systems. Consider using ES6 imports consistently.-const hre = require("hardhat"); +import { ethers } from "hardhat"; import 'dotenv/config'; -const { ethers } = hre;
9-11: Improve error message specificity.The current error message "token address invalid" doesn't specify which address is invalid.
- throw new Error("token address invalid"); + throw new Error( + `Invalid addresses detected:\n${ + !ethers.utils.isAddress(L1WstETHAddr) ? `- L1WstETH: ${L1WstETHAddr}\n` : '' + }${ + !ethers.utils.isAddress(L2WstETHAddr) ? `- L2WstETH: ${L2WstETHAddr}` : '' + }` + );
16-20: Add deployment verification and event logging.The deployment process could benefit from additional verification steps and more detailed logging.
const l1LidoGatewayImpl = await L1LidoGatewayFactory.deploy(L1WstETHAddr, L2WstETHAddr) const l2LidoGatewayImpl = await L2LidoGatewayFactory.deploy(L1WstETHAddr, L2WstETHAddr) + console.log('Waiting for deployments to complete...') await l1LidoGatewayImpl.deployed() await l2LidoGatewayImpl.deployed() - console.log(`impl deployed l1LidoGatewayImpl ${l1LidoGatewayImpl.address}, l2LidoGatewayImpl ${l2LidoGatewayImpl.address}`) + console.log('Deployments completed successfully:') + console.log(`- L1LidoGateway Implementation: ${l1LidoGatewayImpl.address}`) + console.log(`- L2LidoGateway Implementation: ${l2LidoGatewayImpl.address}`) + + // Verify contract code is deployed + const l1Code = await ethers.provider.getCode(l1LidoGatewayImpl.address) + const l2Code = await ethers.provider.getCode(l2LidoGatewayImpl.address) + if (l1Code === '0x' || l2Code === '0x') { + throw new Error('Contract deployment verification failed') + }contracts/tasks/proxy_upgrade.ts (2)
12-15: Improve error message specificity.Similar to the deployment script, the error message should specify which address is invalid.
- throw new Error("token address invalid"); + throw new Error( + `Invalid addresses detected:\n${ + !hre.ethers.utils.isAddress(taskArgs.proxyadminaddr) ? `- ProxyAdmin: ${taskArgs.proxyadminaddr}\n` : '' + }${ + !hre.ethers.utils.isAddress(taskArgs.proxyaddr) ? `- Proxy: ${taskArgs.proxyaddr}\n` : '' + }${ + !hre.ethers.utils.isAddress(taskArgs.newimpladdr) ? `- New Implementation: ${taskArgs.newimpladdr}` : '' + }` + );
24-29: Add upgrade verification and event logging.The upgrade process should include additional verification steps and more detailed logging.
const res = await proxyAdmin.upgrade(taskArgs.proxyaddr, taskArgs.newimpladdr) const receipt = await res.wait() - console.log(`receipt status : ${receipt.status}`) + console.log(`Upgrade transaction status: ${receipt.status ? 'Success' : 'Failed'}`) + console.log(`Transaction hash: ${receipt.transactionHash}`) + + // Verify the implementation was updated const newImpl = await proxy.connect(hre.waffle.provider).callStatic.implementation({ from: taskArgs.proxyadminaddr, })) + if (newImpl.toLowerCase() !== taskArgs.newimpladdr.toLowerCase()) { + throw new Error( + `Implementation address mismatch.\nExpected: ${taskArgs.newimpladdr}\nActual: ${newImpl}` + ) + } + console.log('Implementation address updated successfully')
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
contracts/scripts/lido_impl_deploy.ts(1 hunks)contracts/tasks/proxy_upgrade.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
Summary by CodeRabbit
New Features
Bug Fixes