Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions deployment.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ vezkc-impl = "0xd40ffc5910aa6e520c9fca68424a17404040af06"
vezkc-impl-prev = ""
vezkc-deployer = "0xb13573c6ceb505a7bdd4fa3ad7b473c5c5d36b19"
staking-rewards = "0x459d87d54808fac136ddcf439fcc1d8a238311c7"
staking-rewards-impl = "0x8e65304a2379ca08689c5046c00ff9d53cf73320"
staking-rewards-impl-prev = "0x2d57bc44e3c1fe4ceec8f2bf9ea0ac954b527e43"
staking-rewards-impl = "0x6bfe251c37f17c53d1c02db6c9bbc28bf8c50c11"
staking-rewards-impl-prev = "0x8e65304a2379ca08689c5046c00ff9d53cf73320"
staking-rewards-deployer = "0xb13573c6ceb505a7bdd4fa3ad7b473c5c5d36b19"
povw-minter = "0xbfce7c2d5e7eddeab71b3eeed770713c8b755397"
staking-minter = "0x459d87d54808fac136ddcf439fcc1d8a238311c7"
Expand All @@ -31,7 +31,7 @@ circulating-zkc-admin = "0xb13573c6ceb505a7bdd4fa3ad7b473c5c5d36b19"
circulating-zkc-commit = "9d0b6a9b541d3b6980893b3385d33d12b173f232"
zkc-commit = "5b8310b"
vezkc-commit = "caa29df"
staking-rewards-commit = "24e6b5a"
staking-rewards-commit = "bac0f29"

[deployment.ethereum-sepolia]
name = "Ethereum Sepolia"
Expand All @@ -51,14 +51,14 @@ vezkc-impl = "0x9990fa62cd1abda69e21f94f325640bdd61c6ef3"
vezkc-impl-prev = "0x31c72d15741a9b6e1c0531248a3610a11c943264"
vezkc-deployer = "0xb13573c6ceb505a7bdd4fa3ad7b473c5c5d36b19"
staking-rewards = "0x226439b7750bc0770fbeeedc619e6cb258aa656a"
staking-rewards-impl = "0xf5584355d8259e4272413df05c0e7c8e822e0dd7"
staking-rewards-impl-prev = "0x1ff6f81ea7f5e6feafaafb0fc5983576096ded1d"
staking-rewards-impl = "0xb0bfe179450972f5cd6e8821d6f98bdf8b91f127"
staking-rewards-impl-prev = "0xf5584355d8259e4272413df05c0e7c8e822e0dd7"
staking-rewards-deployer = "0xb13573c6ceb505a7bdd4fa3ad7b473c5c5d36b19"
povw-minter = "0xc98218aafe225035a34795bf4f6777b7d541e326"
staking-minter = "0x226439b7750bc0770fbeeedc619e6cb258aa656a"
zkc-commit = "99f8f78"
vezkc-commit = "99f8f78"
staking-rewards-commit = "a38381d"
staking-rewards-commit = "bac0f29"

#################################################################################
# STAGING #
Expand All @@ -77,18 +77,17 @@ zkc = "0x99a52662b576f4b2d4ffbc4504331a624a7b2846"
zkc-impl = "0xbd1f65405e7cd9972fd7ae81635532a6000d018f"
zkc-deployer = "0x210173ceff92264c565229e0c9ce02df4c1ba5ad"
vezkc = "0xb7c63161da06ec56840465308e24c70df65abc56"
vezkc-impl = "0xd2ba61a24ef93c97db0117899d27a91829406dac"
vezkc-impl = "0x0fb7eb63e1c1De4e6B4c30E07eCe3595f74DBFfe"
vezkc-deployer = "0x210173ceff92264c565229e0c9ce02df4c1ba5ad"
staking-rewards = "0x881fe38501d869bdb8d747a3506562c73413cabe"
staking-rewards-impl = "0x6d3e2c923b65e5da16b4b8f89f573bb111e618c2"
staking-rewards-impl = "0x80595f523e17045fd3ceee28174a5b8677150204"
staking-rewards-deployer = "0x210173ceff92264c565229e0c9ce02df4c1ba5ad"
zkc-commit = "99f8f78"
vezkc-commit = "f79a4bb"
staking-rewards-commit = "f79a4bb"
staking-rewards-commit = "bac0f29"
povw-minter = "0x8c2a4a28116ed8b8fe559bc53e30b6a056c5d3c9"
staking-minter = "0x881fe38501d869bdb8d747a3506562c73413cabe"
vezkc-impl-prev = "0x0fb7eb63e1c1de4e6b4c30e07ece3595f74dbffe"
staking-rewards-impl-prev = "0xc4ad34bd30ce917d94d89c18a800dc45a9774e79"
staking-rewards-impl-prev = "0x6d3e2c923b65e5da16b4b8f89f573bb111e618c2"
zkc-impl-prev = "0xa7e703df0575ea226f01a5d1494a97c4cfafbb34"

#################################################################################
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fs_permissions = [

# Invariant testing configuration
[invariant]
runs = 50 # Faster execution while maintaining good coverage
runs = 50 # Faster execution while maintaining good coverage
depth = 50 # Sufficient depth for complex state evolution
fail_on_revert = false # Don't fail on individual reverts
call_override = false # Use default call behavior
Expand Down
34 changes: 34 additions & 0 deletions script/BaseDeployment.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,38 @@ abstract contract BaseDeployment is Script {
size := extcodesize(addr)
}
}

/// @notice Print Gnosis Safe transaction information for manual upgrades
/// @param proxyAddress The proxy contract address (target for Gnosis Safe)
/// @param newImpl The new implementation address
/// @param initializerData The initializer call data (if any)
function _printGnosisSafeInfo(address proxyAddress, address newImpl, bytes memory initializerData) internal pure {
console2.log("================================");
console2.log("================================");
console2.log("=== GNOSIS SAFE UPGRADE INFO ===");
console2.log("Target Address (To): ", proxyAddress);

bytes memory callData = abi.encodeWithSignature("upgradeToAndCall(address,bytes)", newImpl, initializerData);
console2.log("Function: upgradeToAndCall(address,bytes)");
console2.log("New Implementation: ", newImpl);

if (initializerData.length > 0) {
console2.log("Initializer Data:");
console2.logBytes(initializerData);
} else {
console2.log("Initializer Data: 0x (empty - no function call)");
}

console2.log("Calldata:");
console2.logBytes(callData);
console2.log("");
console2.log("Expected Events on Successful Execution:");
console2.log("1. Upgraded(address indexed implementation)");
console2.log(" - implementation: ", newImpl);

if (initializerData.length > 0) {
console2.log("2. Initialized(uint8 version)");
console2.log(" - version: depends on initializer function");
}
}
}
2 changes: 1 addition & 1 deletion script/Ops.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract Dev_InitialMintToSelf is BaseDeployment {
function run() public {
vm.startBroadcast();

(DeploymentConfig memory config, string memory deploymentKey) = ConfigLoader.loadDeploymentConfig(vm);
(DeploymentConfig memory config,) = ConfigLoader.loadDeploymentConfig(vm);
require(config.zkc != address(0), "ZKC address not set in deployment.toml");

uint256 mintAmount = vm.envUint("MINT_AMOUNT");
Expand Down
5 changes: 1 addition & 4 deletions script/Update.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ contract UpdateCirculatingUnlocked is BaseDeployment {
function setUp() public {}

function run() public {
(DeploymentConfig memory config, string memory deploymentKey) = ConfigLoader.loadDeploymentConfig(vm);
(DeploymentConfig memory config,) = ConfigLoader.loadDeploymentConfig(vm);
require(config.circulatingZKC != address(0), "CirculatingZKC address not set in deployment.toml");

// Get new unlocked value from environment
Expand Down Expand Up @@ -1121,7 +1121,6 @@ contract RemoveAdminAll is BaseDeployment {
console2.log("");

// ZKC
ZKC zkcContract = ZKC(config.zkc);
bytes32 zkcAdminRole = zkcContract.ADMIN_ROLE();
bytes memory zkcRevokeRoleCallData =
abi.encodeWithSignature("revokeRole(bytes32,address)", zkcAdminRole, adminToRemove);
Expand All @@ -1137,7 +1136,6 @@ contract RemoveAdminAll is BaseDeployment {
console2.log("");

// veZKC
veZKC veZKCContract = veZKC(config.veZKC);
bytes32 veZKCAdminRole = veZKCContract.ADMIN_ROLE();
bytes memory veZKCRevokeRoleCallData =
abi.encodeWithSignature("revokeRole(bytes32,address)", veZKCAdminRole, adminToRemove);
Expand All @@ -1153,7 +1151,6 @@ contract RemoveAdminAll is BaseDeployment {
console2.log("");

// StakingRewards
StakingRewards stakingRewardsContract = StakingRewards(config.stakingRewards);
bytes32 stakingAdminRole = stakingRewardsContract.ADMIN_ROLE();
bytes memory stakingRevokeRoleCallData =
abi.encodeWithSignature("revokeRole(bytes32,address)", stakingAdminRole, adminToRemove);
Expand Down
119 changes: 55 additions & 64 deletions script/Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,44 +100,6 @@ abstract contract BaseZKCUpgrade is BaseDeployment {

return newImpl;
}

/// @notice Print Gnosis Safe transaction information for manual upgrades
/// @param proxyAddress The proxy contract address (target for Gnosis Safe)
/// @param newImpl The new implementation address
/// @param initializerData The initializer call data (if any)
function _printGnosisSafeInfo(address proxyAddress, address newImpl, bytes memory initializerData) internal pure {
console2.log("================================");
console2.log("================================");
console2.log("=== GNOSIS SAFE UPGRADE INFO ===");
console2.log("Target Address (To): ", proxyAddress);

if (initializerData.length > 0) {
// For upgradeToAndCall
bytes memory callData = abi.encodeWithSignature("upgradeToAndCall(address,bytes)", newImpl, initializerData);
console2.log("Function: upgradeToAndCall(address,bytes)");
console2.log("New Implementation: ", newImpl);
console2.log("Calldata:");
console2.logBytes(callData);
console2.log("");
console2.log("Expected Events on Successful Execution:");
console2.log("1. Upgraded(address indexed implementation)");
console2.log(" - implementation: ", newImpl);
console2.log("2. Initialized(uint8 version)");
console2.log(" - version: depends on initializer function");
} else {
// For upgradeTo
bytes memory callData = abi.encodeWithSignature("upgradeTo(address)", newImpl);
console2.log("Function: upgradeTo(address)");
console2.log("New Implementation: ", newImpl);
console2.log("Calldata:");
console2.logBytes(callData);
console2.log("");
console2.log("Expected Events on Successful Execution:");
console2.log("1. Upgraded(address indexed implementation)");
console2.log(" - implementation: ", newImpl);
}
console2.log("================================");
}
}

contract UpgradeZKC is BaseZKCUpgrade {
Expand Down Expand Up @@ -427,9 +389,8 @@ contract UpgradeStakingRewards is BaseDeployment {
(DeploymentConfig memory config, string memory deploymentKey) = ConfigLoader.loadDeploymentConfig(vm);
require(config.stakingRewards != address(0), "StakingRewards not deployed");

vm.startBroadcast();

// Check for skip safety checks flag
// Check for deployment mode flags
bool gnosisExecute = vm.envOr("GNOSIS_EXECUTE", false);
bool skipSafetyChecks = vm.envOr("SKIP_SAFETY_CHECKS", false);

// Prepare upgrade options with reference contract
Expand All @@ -449,38 +410,68 @@ contract UpgradeStakingRewards is BaseDeployment {
console2.log("Using reference build directory: ", referenceBuildDir);
}

console2.log("Upgrading StakingRewards at: ", config.stakingRewards);
address currentImpl = _getImplementationAddress(config.stakingRewards);
console2.log("Current implementation: ", currentImpl);
address newImpl;

// Perform safe upgrade
Upgrades.upgradeProxy(
config.stakingRewards,
"StakingRewards.sol:StakingRewards",
"", // No reinitializer
opts
);
if (gnosisExecute) {
console2.log("GNOSIS_EXECUTE=true: Deploying new implementation for Safe upgrade");
console2.log("Target proxy address: ", config.stakingRewards);
console2.log("Current implementation: ", currentImpl);

address newImpl = Upgrades.getImplementationAddress(config.stakingRewards);
console2.log("Upgraded StakingRewards implementation to: ", newImpl);
vm.startBroadcast();

vm.stopBroadcast();
// Use prepareUpgrade for validation + deployment
newImpl = Upgrades.prepareUpgrade("StakingRewards.sol:StakingRewards", opts);
console2.log("New implementation deployed: ", newImpl);

vm.stopBroadcast();

// Print Gnosis Safe transaction info
_printGnosisSafeInfo(config.stakingRewards, newImpl, "");
} else {
console2.log("Upgrading StakingRewards at: ", config.stakingRewards);
console2.log("Current implementation: ", currentImpl);

vm.startBroadcast();

// Perform safe upgrade
Upgrades.upgradeProxy(
config.stakingRewards,
"StakingRewards.sol:StakingRewards",
"", // No reinitializer
opts
);

newImpl = Upgrades.getImplementationAddress(config.stakingRewards);
console2.log("Upgraded StakingRewards implementation to: ", newImpl);

vm.stopBroadcast();
}

// Update deployment.toml with new implementation and store previous
_updateDeploymentConfig(deploymentKey, "staking-rewards-impl-prev", currentImpl);
_updateDeploymentConfig(deploymentKey, "staking-rewards-impl", newImpl);
_updateStakingRewardsCommit(deploymentKey);

// Verify upgrade
StakingRewards stakingRewardsContract = StakingRewards(config.stakingRewards);
console2.log("Proxy still points to StakingRewards: ", address(stakingRewardsContract) == config.stakingRewards);
console2.log("Implementation updated: ", newImpl != config.stakingRewardsImpl);
console2.log("ZKC configured: ", address(stakingRewardsContract.zkc()));
console2.log("veZKC configured: ", address(stakingRewardsContract.veZKC()));
console2.log("ZKC token still configured: ", address(stakingRewardsContract.zkc()) == config.zkc);
console2.log("veZKC still configured: ", address(stakingRewardsContract.veZKC()) == config.veZKC);
console2.log("================================================");
console2.log("StakingRewards Upgrade Complete");
console2.log("New Implementation: ", newImpl);
// Verify results
if (gnosisExecute) {
console2.log("================================================");
console2.log("StakingRewards Implementation Deployment Complete");
console2.log("New Implementation: ", newImpl);
console2.log("Proxy NOT upgraded - use Gnosis Safe to complete upgrade");
} else {
StakingRewards stakingRewardsContract = StakingRewards(config.stakingRewards);
console2.log(
"Proxy still points to StakingRewards: ", address(stakingRewardsContract) == config.stakingRewards
);
console2.log("Implementation updated: ", newImpl != config.stakingRewardsImpl);
console2.log("ZKC configured: ", address(stakingRewardsContract.zkc()));
console2.log("veZKC configured: ", address(stakingRewardsContract.veZKC()));
console2.log("ZKC token still configured: ", address(stakingRewardsContract.zkc()) == config.zkc);
console2.log("veZKC still configured: ", address(stakingRewardsContract.veZKC()) == config.veZKC);
console2.log("================================================");
console2.log("StakingRewards Upgrade Complete");
console2.log("New Implementation: ", newImpl);
}
}
}
Loading
Loading