-
Notifications
You must be signed in to change notification settings - Fork 36
feat: deployment engine #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: deployment engine #1047
Changes from 55 commits
8bafe86
d95101b
00ba92a
9f6c70d
4a51e33
cecd4f3
460c2e0
2aaeb00
4581387
b94ed13
3ba9fad
e455afb
00433e9
945619f
8680dd6
21033d1
5304e6c
9545217
4d36444
a951c30
384aeef
ac1dc8a
1fd5830
dd459c1
11be630
7b16818
8f7d6f7
63c93f9
e38a93c
563f04f
a455a57
e3642d3
b06da1a
05c0dc0
d5affff
265a3a7
8d4cef0
beea923
31509cf
ac59e59
a224fe8
17db1f2
c49467f
65b44c9
25a3ae4
e597f1c
6c5c0b5
70e4501
8f14c51
e7f4ea5
f6787b9
27260d0
8c26cf3
0ad7618
198fc50
5b13830
4358d33
b3cf5e5
92eab04
d851888
5492653
90f133f
b8acf9c
7a82a0b
dfe4808
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,6 @@ lcov* | |
| report/ | ||
|
|
||
| .DS_Store | ||
| .venv/ | ||
| .venv/ | ||
|
|
||
| output/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (c) 2025 Aave Labs | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import 'scripts/deploy/AaveV4DeployBatchBase.s.sol'; | ||
|
|
||
| contract AaveV4DeployBatchScript is AaveV4DeployBatchBaseScript { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think aavev4 prefix is needed on any of these
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agnostic but just a copy of v3 style - @miguelmtzinf thoughts? |
||
| string internal constant INPUT_FILE = 'AaveV4DeployInput.json'; | ||
| string internal constant OUTPUT_FILE = 'AaveV4DeployBatch.json'; | ||
| constructor() AaveV4DeployBatchBaseScript(INPUT_FILE, OUTPUT_FILE) {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (c) 2025 Aave Labs | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {OrchestrationReports} from 'src/deployments/libraries/OrchestrationReports.sol'; | ||
| import {InputUtils} from 'src/deployments/utils/InputUtils.sol'; | ||
| import {MetadataLogger} from 'src/deployments/utils/MetadataLogger.sol'; | ||
| import { | ||
| AaveV4DeployOrchestration | ||
| } from 'src/deployments/orchestration/AaveV4DeployOrchestration.sol'; | ||
|
|
||
| import {Script} from 'forge-std/Script.sol'; | ||
|
|
||
| abstract contract AaveV4DeployBatchBaseScript is Script, InputUtils { | ||
| string internal constant INPUT_PATH = 'scripts/deploy/inputs/'; | ||
| string internal constant OUTPUT_DIR = 'output/reports/deployments/'; | ||
|
|
||
| string internal _inputFileName; | ||
| string internal _outputFileName; | ||
|
|
||
| constructor(string memory inputFileName_, string memory outputFileName_) { | ||
| _inputFileName = inputFileName_; | ||
| _outputFileName = outputFileName_; | ||
| } | ||
|
|
||
| function run() external virtual { | ||
| vm.createDir(OUTPUT_DIR, true); | ||
| MetadataLogger logger = new MetadataLogger(OUTPUT_DIR); | ||
| FullDeployInputs memory inputs = loadFullDeployInputs( | ||
| string.concat(INPUT_PATH, _inputFileName) | ||
| ); | ||
| (, address deployer, ) = vm.readCallers(); | ||
| _loadWarnings(logger, inputs); | ||
| inputs = _sanitizeInputs(inputs, deployer); | ||
|
|
||
| logger.log('...Starting Aave V4 Batch Deployment...'); | ||
| vm.startBroadcast(deployer); | ||
| OrchestrationReports.FullDeploymentReport memory report = AaveV4DeployOrchestration | ||
| .deployAaveV4(logger, deployer, inputs); | ||
| vm.stopBroadcast(); | ||
| logger.writeJsonReportMarket(report); | ||
| logger.log('...Batch Deployment Completed...'); | ||
| logger.log('...Saving Logs...'); | ||
| logger.save({fileName: _outputFileName, withTimestamp: true}); | ||
| } | ||
|
|
||
| function _loadWarnings(MetadataLogger logger, FullDeployInputs memory inputs) internal virtual { | ||
| bool hadWarnings = false; | ||
| string memory warnings = ''; | ||
| if (inputs.grantRoles) { | ||
| warnings = _logAndAppend(logger, warnings, 'WARNING: Roles are being set'); | ||
| hadWarnings = true; | ||
| if (inputs.accessManagerAdmin == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Access Manager Admin is zero address; role will be granted to deployer by default' | ||
Kogaroshi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
| if (inputs.hubConfiguratorOwner == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Hub Configurator Owner is zero address; role will be granted to deployer by default' | ||
| ); | ||
| } | ||
| if (inputs.spokeConfiguratorOwner == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Spoke Configurator Owner is zero address; role will be granted to deployer by default' | ||
| ); | ||
| } | ||
| if (inputs.spokeProxyAdminOwner == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Spoke Proxy Admin Owner is zero address; role will be granted to deployer by default' | ||
| ); | ||
| } | ||
| if (inputs.treasurySpokeOwner == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Treasury Spoke Owner is zero address; role will be granted to deployer by default' | ||
| ); | ||
| } | ||
| if (inputs.spokeAdmin == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Spoke Admin is zero address; spoke admin roles will be granted to deployer by default' | ||
| ); | ||
| } | ||
| } | ||
| if (inputs.hubLabels.length == 0) { | ||
| warnings = _logAndAppend(logger, warnings, 'WARNING: Hub will not be deployed'); | ||
| hadWarnings = true; | ||
| } | ||
| if (inputs.spokeLabels.length == 0) { | ||
| warnings = _logAndAppend(logger, warnings, 'WARNING: Spoke will not be deployed'); | ||
| hadWarnings = true; | ||
| } | ||
| if (inputs.nativeWrapper == address(0)) { | ||
| warnings = _logAndAppend( | ||
| logger, | ||
| warnings, | ||
| 'WARNING: Native wrapper zero address; NativeTokenGateway & SignatureGateway will not be deployed' | ||
| ); | ||
| hadWarnings = true; | ||
| } | ||
| logger.log(''); | ||
|
|
||
| if (hadWarnings) { | ||
| _executeUserPrompt(warnings); | ||
| } | ||
| } | ||
|
|
||
| function _executeUserPrompt(string memory warnings) internal virtual { | ||
| string memory ack = vm.prompt(string.concat(warnings, "\nEnter 'y' to continue")); | ||
| if (keccak256(bytes(ack)) != keccak256(bytes('y'))) { | ||
| revert('User did not acknowledge warnings. Please try again.'); | ||
| } | ||
| } | ||
|
|
||
| function _sanitizeInputs( | ||
| FullDeployInputs memory deployInputs, | ||
| address deployer | ||
| ) internal view virtual returns (FullDeployInputs memory) { | ||
| // if any admin is zero address, default to deployer as admin | ||
| InputUtils.FullDeployInputs memory sanitizedInputs = deployInputs; | ||
| sanitizedInputs.accessManagerAdmin = deployInputs.accessManagerAdmin != address(0) | ||
| ? deployInputs.accessManagerAdmin | ||
| : deployer; | ||
|
||
| sanitizedInputs.hubConfiguratorOwner = deployInputs.hubConfiguratorOwner != address(0) | ||
| ? deployInputs.hubConfiguratorOwner | ||
| : deployer; | ||
| sanitizedInputs.treasurySpokeOwner = deployInputs.treasurySpokeOwner != address(0) | ||
| ? deployInputs.treasurySpokeOwner | ||
| : deployer; | ||
| sanitizedInputs.spokeProxyAdminOwner = deployInputs.spokeProxyAdminOwner != address(0) | ||
| ? deployInputs.spokeProxyAdminOwner | ||
| : deployer; | ||
| sanitizedInputs.spokeConfiguratorOwner = deployInputs.spokeConfiguratorOwner != address(0) | ||
| ? deployInputs.spokeConfiguratorOwner | ||
| : deployer; | ||
| sanitizedInputs.gatewayOwner = deployInputs.gatewayOwner != address(0) | ||
| ? deployInputs.gatewayOwner | ||
| : deployer; | ||
|
|
||
| return sanitizedInputs; | ||
| } | ||
|
|
||
| function _logAndAppend( | ||
| MetadataLogger logger, | ||
| string memory warnings, | ||
| string memory warning | ||
| ) internal virtual returns (string memory) { | ||
| logger.log(warning); | ||
| return string.concat(warnings, warning, '\n'); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "accessManagerAdmin": "0x0000000000000000000000000000000000000001", | ||
| "hubConfiguratorOwner": "0x0000000000000000000000000000000000000002", | ||
| "hubAdmin": "0x0000000000000000000000000000000000000003", | ||
| "treasurySpokeOwner": "0x0000000000000000000000000000000000000003", | ||
| "spokeConfiguratorOwner": "0x0000000000000000000000000000000000000004", | ||
| "spokeAdmin": "0x0000000000000000000000000000000000000005", | ||
| "spokeProxyAdminOwner": "0x0000000000000000000000000000000000000005", | ||
| "gatewayOwner": "0x0000000000000000000000000000000000000005", | ||
| "nativeWrapper": "0x0000000000000000000000000000000000000006", | ||
| "grantRoles": true, | ||
| "hubLabels": ["Hub 1", "Hub 2", "Hub 3"], | ||
| "spokeLabels": ["Spoke 1", "Spoke 2", "Spoke 3"] | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are they changing? foundry version?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no foundry version update. was trying to dig into this but couldnt id exactly why, base set up was just refactored. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||
| // SPDX-License-Identifier: UNLICENSED | ||||||
| // Copyright (c) 2025 Aave Labs | ||||||
| pragma solidity ^0.8.0; | ||||||
|
|
||||||
| import {BatchReports} from 'src/deployments/libraries/BatchReports.sol'; | ||||||
| import { | ||||||
| AaveV4AccessManagerEnumerableDeployProcedure | ||||||
| } from 'src/deployments/procedures/deploy/AaveV4AccessManagerEnumerableDeployProcedure.sol'; | ||||||
|
|
||||||
| contract AaveV4AccessBatch is AaveV4AccessManagerEnumerableDeployProcedure { | ||||||
| BatchReports.AccessBatchReport internal _report; | ||||||
|
|
||||||
| constructor(address admin_) { | ||||||
|
||||||
| assert(admin_ != address(0)); | ||||||
|
||||||
| assert(admin_ != address(0)); | |
| require(admin_ != address(0), InvalidParam()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/aave/aave-v4/pull/1047/files/25a3ae4a6ebe749f43bb0fc49939067b2f8501d6#r2602519757
i think I'd prefer require to get an error msg in there but also, this state is never meant to be reached. Also moved these validations to the procedures instead. cc @avniculae thoughts?
I'll move back to require for now, see latest
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (c) 2025 Aave Labs | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {BatchReports} from 'src/deployments/libraries/BatchReports.sol'; | ||
| import { | ||
| AaveV4HubConfiguratorDeployProcedure | ||
| } from 'src/deployments/procedures/deploy/hub/AaveV4HubConfiguratorDeployProcedure.sol'; | ||
| import { | ||
| AaveV4SpokeConfiguratorDeployProcedure | ||
| } from 'src/deployments/procedures/deploy/spoke/AaveV4SpokeConfiguratorDeployProcedure.sol'; | ||
|
|
||
| contract AaveV4ConfiguratorBatch is | ||
| AaveV4HubConfiguratorDeployProcedure, | ||
| AaveV4SpokeConfiguratorDeployProcedure | ||
| { | ||
| BatchReports.ConfiguratorBatchReport internal _report; | ||
|
|
||
| constructor(address hubConfiguratorOwner_, address spokeConfiguratorOwner_) { | ||
| assert(hubConfiguratorOwner_ != address(0)); | ||
| assert(spokeConfiguratorOwner_ != address(0)); | ||
|
|
||
| address hubConfigurator = _deployHubConfigurator(hubConfiguratorOwner_); | ||
| address spokeConfigurator = _deploySpokeConfigurator(spokeConfiguratorOwner_); | ||
|
|
||
| _report = BatchReports.ConfiguratorBatchReport({ | ||
| hubConfigurator: hubConfigurator, | ||
| spokeConfigurator: spokeConfigurator | ||
| }); | ||
| } | ||
|
|
||
| function getReport() external view returns (BatchReports.ConfiguratorBatchReport memory) { | ||
| return _report; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (c) 2025 Aave Labs | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import {BatchReports} from 'src/deployments/libraries/BatchReports.sol'; | ||
| import { | ||
| AaveV4NativeTokenGatewayDeployProcedure | ||
| } from 'src/deployments/procedures/deploy/position-manager/AaveV4NativeTokenGatewayDeployProcedure.sol'; | ||
| import { | ||
| AaveV4SignatureGatewayDeployProcedure | ||
| } from 'src/deployments/procedures/deploy/position-manager/AaveV4SignatureGatewayDeployProcedure.sol'; | ||
|
|
||
| contract AaveV4GatewayBatch is | ||
| AaveV4NativeTokenGatewayDeployProcedure, | ||
| AaveV4SignatureGatewayDeployProcedure | ||
| { | ||
| BatchReports.GatewaysBatchReport internal _report; | ||
|
|
||
| constructor(address owner_, address nativeWrapper_) { | ||
| assert(owner_ != address(0)); | ||
| assert(nativeWrapper_ != address(0)); | ||
|
|
||
| address nativeGateway = _deployNativeTokenGateway({ | ||
| nativeWrapper: nativeWrapper_, | ||
| owner: owner_ | ||
| }); | ||
| address signatureGateway = _deploySignatureGateway(owner_); | ||
|
|
||
| _report = BatchReports.GatewaysBatchReport({ | ||
| nativeGateway: nativeGateway, | ||
| signatureGateway: signatureGateway | ||
| }); | ||
| } | ||
|
|
||
| function getReport() external view returns (BatchReports.GatewaysBatchReport memory) { | ||
| return _report; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.