refactor(incentive-council): improve deploy scripts#1718
refactor(incentive-council): improve deploy scripts#17180xClandestine merged 12 commits intorelease-dev/incentive-councilfrom
Conversation
- instead of fixing one env at a time, you can run them all see all errors and fix at once.
|
@claude review this PR |
|
Claude finished @elhajin's task in 1m 49s —— View job Code Review Complete ✅I've completed a thorough review of this PR. Overall, the changes are well-structured and address the stated objectives. Below are my findings organized by severity. SummaryThis PR refactors deployment scripts for the incentive council upgrade (v1.12.0), adding special handling for preprod environments and removing old v1.9.0 deployment scripts. The main changes focus on:
Critical Issues1. Missing Default Distributions ImplementationLocation: Issue: The PR description states "Added missing check to skip environments that core isn't deployed" and mentions adding "default distributions in order to maintain the current emissions schedule as the TokenHopper initially." However, I don't see any code that actually creates default distributions to the RewardsCoordinator. Expected: After upgrading EmissionsController and granting it minting rights, there should be calls to create initial distribution configurations to maintain the current emissions schedule. Impact: Without default distributions, the emissions schedule may not match the legacy TokenHopper behavior, potentially disrupting expected reward flows. Recommendation: Add code to create default distributions, similar to: // 6. Create default distributions to maintain emissions schedule
IRewardsCoordinator.RewardsSubmission[] memory defaultDistributions = _getDefaultDistributions();
for (uint256 i = 0; i < defaultDistributions.length; i++) {
executorCalls.append({
to: address(Env.proxy.rewardsCoordinator()),
data: abi.encodeCall(IRewardsCoordinator.createRewardsSubmission, (defaultDistributions[i]))
});
}High Priority Issues2. Unsafe Storage Slot Reading for Initialization CheckLocation: RewardsCoordinator rc = Env.proxy.rewardsCoordinator();
bytes32 slot0 = vm.load(address(rc), bytes32(uint256(0)));
uint8 initializedVersion = uint8(uint256(slot0) & 0xFF);Issue: This directly reads storage slot 0 to determine if the contract has been reinitialized. While this works for the current OpenZeppelin Initializable pattern, it's fragile and could break if:
Impact: The script might incorrectly determine initialization status, leading to failed upgrades or double-initialization attempts. Recommendation: Consider adding a public view function to RewardsCoordinator to expose the initialization version, or use try-catch with the reinitialize call: // Option 1: Try to reinitialize, catch if already initialized
try rewardsCoordinator.reinitialize(...) {
// Successfully reinitialized
} catch {
// Already initialized, just upgrade
executorCalls.upgradeRewardsCoordinator();
}Or add a helper function that's more explicit about what it's checking. Medium Priority Issues3. Inconsistent Environment Version Check PatternLocation: Multiple locations in Issue: The preprod special-casing uses string comparison with
Issues:
Recommendation: // At the top of the contract
bool constant IS_PREPROD_UPGRADE = Env._strEq(Env.envVersion(), "1.12.0");
// Then use consistently
if (!IS_PREPROD_UPGRADE) {
deployEmissionsControllerProxy();
}Or better yet, add a helper function: function isPreprodEnvironment() internal view returns (bool) {
// Preprod already has EmissionsController deployed at v1.12.0
return Env._strEq(Env.envVersion(), "1.12.0");
}4. Missing Validation for Preprod-Specific LogicLocation: Issue: The validation skips checking if EmissionsController already has minting rights on preprod: if (!Env._strEq(Env.envVersion(), "1.12.0")) {
require(
!beigen.isMinter(address(Env.proxy.emissionsController())),
"EmissionsController should NOT have minting rights before upgrade"
);
}Problem: On preprod, if EmissionsController somehow doesn't have minting rights, the script will still proceed and try to grant them again (which should be idempotent but worth validating). Recommendation: Add a positive check for preprod: if (Env._strEq(Env.envVersion(), "1.12.0")) {
// On preprod, verify EmissionsController already has minting rights
require(
beigen.isMinter(address(Env.proxy.emissionsController())),
"Preprod: EmissionsController should already have minting rights"
);
} else {
require(
!beigen.isMinter(address(Env.proxy.emissionsController())),
"EmissionsController should NOT have minting rights before upgrade"
);
}Low Priority Issues5. Unused Helper Function Added to Env.solLocation: function _deployedProxyOr(
string memory name,
address defaultValue
) private view returns (address) {
string memory envvar = string.concat("ZEUS_DEPLOYED_", name, "_Proxy");
return vm.envOr(envvar, defaultValue);
}Issue: This function is added but never used in the codebase. The comment in Recommendation: Either:
6. Upgrade Version Constraint ChangeLocation: Change: Issue: This restricts the upgrade path, meaning environments at v1.9.0 or v1.10.0 cannot directly upgrade to v1.12.0. While this may be intentional, it's not documented in the PR description. Questions:
7. TestUtils Label Addition Lacks ConsistencyLocation: Issue: Labels are added to some validation functions but not all. For example:
Recommendation: Either add labels consistently to all validation functions or document why some are excluded. Positive Observations
Recommendations SummaryMust Fix:
Should Fix:
Consider:
Final VerdictThe refactoring is well-structured, but the most critical concern is the missing default distributions implementation mentioned in the PR description. Before merging, please:
|
1a25c27
into
release-dev/incentive-council
Motivation:
Some environments are failing due to missing Zeus env parameters, and we also want to add default distributions in order to maintain the current emissions schedule as the TokenHopper initially.
Modifications:
Result:
CI is passing, and default distributions are added.