[Refactor] Speed-up deployment. #181
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Major refactoring of the deployment framework to improve speed, scalability, and developer experience. This transforms the deployment system from a basic script-based approach to a sophisticated, maintainable framework.
71 files changed | +3,733 lines | -2,687 lines
Motivation
The old deployment process had several limitations that made it difficult to maintain as the number of deployment scripts grew:
1. Manual Script Registration
Every new deployment script required:
DeployManager.solrun()function2. Inefficient JSON Serialization
The old approach read and wrote JSON line-by-line, which was:
vm.serializeUintcall overwrote previous data)3. AddressResolver Recreated Per Script
A new
AddressResolverwas instantiated in every script'srun()function, wasting gas and setup time.4. Address Passing via Constructor
Scripts had to receive addresses as constructor parameters, creating tight coupling:
Key Changes
1. Dynamic Script Discovery
Scripts are now auto-discovered from chain-specific folders (
mainnet/,sonic/). No more manual registration.2. Struct-Based JSON with Arrays
JSON is now parsed once using struct deserialization, and written once at the end:
New JSON format:
{ "contracts": [{"name": "LIDO_ARM", "implementation": "0x..."}], "executions": [{"name": "003_UpgradeLidoARMScript", "timestamp": 123}] }3. Persistent Resolver at Deterministic Address
A single
Resolvercontract is deployed viavm.etchto a deterministic address. All scripts access the same instance:4. Resolver-Based Address Lookups
Scripts now query the Resolver directly - no constructor params needed:
5. Standardized Deployment Lifecycle
New
AbstractDeployScriptprovides a clean lifecycle with override hooks:_execute()- Deploy contracts, register them_buildGovernanceProposal()- Define governance actions_fork()- Post-deployment verification6. Multi-Chain Support
Built-in support for multiple chains via folder-based organization:
script/deploy/mainnet/script/deploy/sonic/Benefits
CI Improvements
The refactoring also improves CI pipeline performance by parallelizing test execution across multiple chains. Fork tests now run concurrently for each supported chain (Mainnet, Sonic), reducing overall CI run time.
New Architecture
How to Write a New Deployment Script
script/deploy/mainnet/NNN_YourScript.s.solNNN_DescriptiveName.s.sol$NNN_DescriptiveName"NNN_DescriptiveName"See
script/deploy/mainnet/000_Example.s.solfor a complete template.