-
Notifications
You must be signed in to change notification settings - Fork 35
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 all 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,15 @@ | ||
| { | ||
| "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"], | ||
| "salt": "salt" | ||
| } | ||
| 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,150 @@ | ||
| // 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 { | ||
| struct Warnings { | ||
| string[] s; | ||
| } | ||
|
|
||
| string internal constant INPUT_PATH = 'config/'; | ||
| string internal constant OUTPUT_DIR = 'output/reports/deployments/'; | ||
| string internal _inputFileName; | ||
| string internal _outputFileName; | ||
| Warnings internal _warnings; | ||
|
|
||
| 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(); | ||
| inputs = _loadWarningsAndSanitizeInputs(logger, inputs, deployer); | ||
|
|
||
| logger.log('CHAIN ID', block.chainid); | ||
| 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 _loadWarningsAndSanitizeInputs( | ||
| MetadataLogger logger, | ||
| FullDeployInputs memory inputs, | ||
| address deployer | ||
| ) internal virtual returns (FullDeployInputs memory) { | ||
| string memory message = ' is zero address'; | ||
| string memory outcome = '; defaulting to deployer'; | ||
|
|
||
| FullDeployInputs memory sanitizedInputs = inputs; | ||
| bool hadWarnings = false; | ||
| if (inputs.grantRoles) { | ||
| _logAndAppend(logger, string.concat('Roles are being set')); | ||
| hadWarnings = true; | ||
| if (inputs.accessManagerAdmin == address(0)) { | ||
| _logAndAppend(logger, string.concat('Access Manager Admin', message, outcome)); | ||
| sanitizedInputs.accessManagerAdmin = deployer; | ||
| } | ||
| if (inputs.hubConfiguratorOwner == address(0)) { | ||
| _logAndAppend(logger, string.concat('Hub Configurator Owner', message, outcome)); | ||
| sanitizedInputs.hubConfiguratorOwner = deployer; | ||
| } | ||
| if (inputs.spokeConfiguratorOwner == address(0)) { | ||
| _logAndAppend(logger, string.concat('Spoke Configurator Owner', message, outcome)); | ||
| sanitizedInputs.spokeConfiguratorOwner = deployer; | ||
| } | ||
| if (inputs.spokeProxyAdminOwner == address(0)) { | ||
| _logAndAppend(logger, string.concat('Spoke Proxy Admin Owner', message, outcome)); | ||
| sanitizedInputs.spokeProxyAdminOwner = deployer; | ||
| } | ||
| if (inputs.treasurySpokeOwner == address(0)) { | ||
| _logAndAppend(logger, string.concat('Treasury Spoke Owner', message, outcome)); | ||
| sanitizedInputs.treasurySpokeOwner = deployer; | ||
| } | ||
| if (inputs.spokeAdmin == address(0)) { | ||
| _logAndAppend(logger, string.concat('Spoke Admin', message, outcome)); | ||
| sanitizedInputs.spokeAdmin = deployer; | ||
| } | ||
| if (inputs.hubAdmin == address(0)) { | ||
| _logAndAppend(logger, string.concat('Hub Admin', message, outcome)); | ||
| sanitizedInputs.hubAdmin = deployer; | ||
| } | ||
| } | ||
| if (inputs.hubLabels.length == 0) { | ||
| _logAndAppend(logger, string.concat('Hub will not be deployed')); | ||
| hadWarnings = true; | ||
| sanitizedInputs.hubLabels = new string[](0); | ||
| } | ||
| if (inputs.spokeLabels.length == 0) { | ||
| _logAndAppend(logger, string.concat('Spoke will not be deployed')); | ||
| hadWarnings = true; | ||
| sanitizedInputs.spokeLabels = new string[](0); | ||
| } | ||
| if (inputs.nativeWrapper == address(0)) { | ||
| _logAndAppend( | ||
| logger, | ||
| string.concat( | ||
| 'Native wrapper', | ||
| message, | ||
| "; NativeTokenGateway & SignatureGateway will not be deployed'" | ||
| ) | ||
| ); | ||
| hadWarnings = true; | ||
| sanitizedInputs.nativeWrapper = address(0); | ||
| } | ||
| if (inputs.gatewayOwner == address(0)) { | ||
| _logAndAppend(logger, string.concat('Gateway owner', message, outcome)); | ||
| hadWarnings = true; | ||
| sanitizedInputs.gatewayOwner = deployer; | ||
| } | ||
| if (hadWarnings) { | ||
| _executeUserPrompt(); | ||
| } | ||
| return sanitizedInputs; | ||
| } | ||
|
|
||
| function _executeUserPrompt() internal virtual { | ||
| string memory ack = vm.prompt( | ||
| string.concat(_joinWarnings(_warnings), "\nEnter 'y' to continue") | ||
| ); | ||
| if (keccak256(bytes(ack)) != keccak256(bytes('y'))) { | ||
| revert('User did not acknowledge warnings. Please try again.'); | ||
| } | ||
| } | ||
|
|
||
| function _logAndAppend(MetadataLogger logger, string memory warning) internal virtual { | ||
| warning = string.concat('WARNING: ', warning); | ||
| logger.log(warning); | ||
| _warnings.s.push(warning); | ||
| } | ||
|
|
||
| function _joinWarnings(Warnings storage warnings) internal view virtual returns (string memory) { | ||
| uint256 n = warnings.s.length; | ||
| if (n == 0) return ''; | ||
| string memory out = warnings.s[0]; | ||
| for (uint256 i = 1; i < n; i++) { | ||
| out = string.concat(out, '\n', warnings.s[i]); | ||
| } | ||
| return string.concat(out, '\n'); | ||
| } | ||
| } |
|
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,24 @@ | ||
| // 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_, bytes32 salt_) { | ||
| address accessManager = _deployAccessManagerEnumerable( | ||
| admin_, | ||
| keccak256(abi.encodePacked(SALT, salt_, 'accessManager')) | ||
| ); | ||
| _report = BatchReports.AccessBatchReport({accessManager: accessManager}); | ||
| } | ||
|
|
||
| function getReport() external view returns (BatchReports.AccessBatchReport 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 { | ||
| 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_, bytes32 salt_) { | ||
| address hubConfigurator = _deployHubConfigurator( | ||
| hubConfiguratorOwner_, | ||
| keccak256(abi.encodePacked(SALT, salt_, 'hubConfigurator')) | ||
| ); | ||
| address spokeConfigurator = _deploySpokeConfigurator( | ||
| spokeConfiguratorOwner_, | ||
| keccak256(abi.encodePacked(SALT, salt_, 'spokeConfigurator')) | ||
| ); | ||
|
|
||
| _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,39 @@ | ||
| // 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_, bytes32 salt_) { | ||
| address nativeGateway = _deployNativeTokenGateway({ | ||
| nativeWrapper: nativeWrapper_, | ||
| owner: owner_, | ||
| salt: keccak256(abi.encodePacked(SALT, salt_, 'nativeGateway')) | ||
| }); | ||
| address signatureGateway = _deploySignatureGateway( | ||
| owner_, | ||
| keccak256(abi.encodePacked(SALT, salt_, 'signatureGateway')) | ||
| ); | ||
|
|
||
| _report = BatchReports.GatewaysBatchReport({ | ||
| nativeGateway: nativeGateway, | ||
| signatureGateway: signatureGateway | ||
| }); | ||
| } | ||
|
|
||
| function getReport() external view returns (BatchReports.GatewaysBatchReport memory) { | ||
| return _report; | ||
| } | ||
| } |
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.
Copying thread from #1053
avniculae
Contributor
Author
what use case is there for setRoles = false?
yan-man replied
yan-man
Contributor
i think perhaps deploying an instance via aave labs and not setting roles till an AIP to hand off to DAO, cc @Kogaroshi
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.
Yes, since some Spoke/Hubs might not be controlled by the deploying entity, this would allow to deploy them with "empty" configs until ready to be configured by the entity managing it.
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.
i did the setRoles by default (for the defined targetFunctionSelectors, but grantRole i made into a boolean, see latest