Skip to content

Commit

Permalink
Merge pull request #172 from yieldnest/deploy-initv2-holesky/danoctav…
Browse files Browse the repository at this point in the history
…ian/sc-1162/implement-generalized-withdrawal-queue-manager

update with deployed addresses
  • Loading branch information
danoctavian authored Sep 30, 2024
2 parents f6c2fed + e4aee06 commit f7b1310
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 107 deletions.
10 changes: 8 additions & 2 deletions script/ContractAddresses.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ contract ContractAddresses {
address REWARDS_DISTRIBUTOR_ADDRESS;
address EXECUTION_LAYER_RECEIVER_ADDRESS;
address CONSENSUS_LAYER_RECEIVER_ADDRESS;
address YNETH_REDEMPTION_ASSETS_VAULT_ADDRESS;
address WITHDRAWAL_QUEUE_MANAGER_ADDRESS;
}

struct EigenlayerAddresses {
Expand Down Expand Up @@ -119,7 +121,9 @@ contract ContractAddresses {
STAKING_NODES_MANAGER_ADDRESS: 0x8C33A1d6d062dB7b51f79702355771d44359cD7d,
REWARDS_DISTRIBUTOR_ADDRESS: 0x40d5FF3E218f54f4982661a0464a298Cf6652351,
EXECUTION_LAYER_RECEIVER_ADDRESS: 0x1D6b2a11FFEa5F9a8Ed85A02581910b3d695C12b,
CONSENSUS_LAYER_RECEIVER_ADDRESS: 0xE439fe4563F7666FCd7405BEC24aE7B0d226536e
CONSENSUS_LAYER_RECEIVER_ADDRESS: 0xE439fe4563F7666FCd7405BEC24aE7B0d226536e,
YNETH_REDEMPTION_ASSETS_VAULT_ADDRESS: address(0),
WITHDRAWAL_QUEUE_MANAGER_ADDRESS: address(0)
}),
ynEigen: YnEigenAddresses({
YNEIGEN_ADDRESS: 0x35Ec69A77B79c255e5d47D5A3BdbEFEfE342630c,
Expand Down Expand Up @@ -174,7 +178,9 @@ contract ContractAddresses {
STAKING_NODES_MANAGER_ADDRESS: 0xc2387EBb4Ea66627E3543a771e260Bd84218d6a1,
REWARDS_DISTRIBUTOR_ADDRESS: 0x82915efF62af9FCC0d0735b8681959e069E3f2D8,
EXECUTION_LAYER_RECEIVER_ADDRESS: 0xA5E9E1ceb4cC1854d0e186a9B3E67158b84AD072,
CONSENSUS_LAYER_RECEIVER_ADDRESS: 0x706EED02702fFE9CBefD6A65E63f3C2b59B7eF2d
CONSENSUS_LAYER_RECEIVER_ADDRESS: 0x706EED02702fFE9CBefD6A65E63f3C2b59B7eF2d,
YNETH_REDEMPTION_ASSETS_VAULT_ADDRESS: 0x3a2DD2f0f5A20768110a52fC4f091AB9d8631b58,
WITHDRAWAL_QUEUE_MANAGER_ADDRESS: 0x141aAb320857145fB42240C979b800f48CE5B678
}),
ynEigen: YnEigenAddresses({
YNEIGEN_ADDRESS: 0x071bdC8eDcdD66730f45a3D3A6F794FAA37C75ED,
Expand Down
34 changes: 21 additions & 13 deletions script/DeployYnETHWithdrawals.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ contract DeployYnETHWithdrawals is BaseYnETHScript {

function run() external {

// ynETH.sol ROLES
actors = getActors();

ContractAddresses contractAddresses = new ContractAddresses();

if (false) {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

address publicKey = vm.addr(deployerPrivateKey);
console.log("Deployer Public Key:", publicKey);
deployer = publicKey;

// ynETH.sol ROLES
actors = getActors();

ContractAddresses contractAddresses = new ContractAddresses();
IynETH yneth = IynETH(payable(contractAddresses.getChainAddresses(block.chainid).yn.YNETH_ADDRESS));

// // Apply preprod overrides for DEFAULT_SIGNER
Expand Down Expand Up @@ -171,18 +173,24 @@ contract DeployYnETHWithdrawals is BaseYnETHScript {
saveDeployment(deployment);

console.log("Deployment information saved successfully.");
}

ynETHRedemptionAssetsVaultInstance = ynETHRedemptionAssetsVault(payable(0x3a2DD2f0f5A20768110a52fC4f091AB9d8631b58));
// initialize stakingNodesManager withdrawal contracts
// {
// StakingNodesManager.Init2 memory initParams = StakingNodesManager.Init2({
// redemptionAssetsVault: ynETHRedemptionAssetsVaultInstance,
// withdrawalManager: actors.ops.WITHDRAWAL_MANAGER,
// stakingNodesWithdrawer: actors.ops.STAKING_NODES_WITHDRAWER
// });
{
StakingNodesManager.Init2 memory initParams = StakingNodesManager.Init2({
redemptionAssetsVault: ynETHRedemptionAssetsVaultInstance,
withdrawalManager: actors.ops.WITHDRAWAL_MANAGER,
stakingNodesWithdrawer: actors.ops.STAKING_NODES_WITHDRAWER
});

console.log("actors.ops.WITHDRAWAL_MANAGER:", actors.ops.WITHDRAWAL_MANAGER);
console.log("actors.ops.STAKING_NODES_WITHDRAWER:", actors.ops.STAKING_NODES_WITHDRAWER);

// vm.prank(actors.admin.ADMIN);
// stakingNodesManager.initializeV2(initParams);
// }
bytes memory txData = abi.encodeWithSelector(StakingNodesManager.initializeV2.selector, initParams);
console.log("Transaction data for stakingNodesManager.initializeV2:");
console.logBytes(txData);
}

vm.stopBroadcast();
}
Expand Down
96 changes: 4 additions & 92 deletions test/integration/M3/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ contract Base is Test, Utils {
rewardsDistributor = RewardsDistributor(payable(chainAddresses.yn.REWARDS_DISTRIBUTOR_ADDRESS));
executionLayerReceiver = RewardsReceiver(payable(chainAddresses.yn.EXECUTION_LAYER_RECEIVER_ADDRESS));
consensusLayerReceiver = RewardsReceiver(payable(chainAddresses.yn.CONSENSUS_LAYER_RECEIVER_ADDRESS));
ynETHWithdrawalQueueManager = WithdrawalQueueManager(payable(chainAddresses.yn.WITHDRAWAL_QUEUE_MANAGER_ADDRESS));
ynETHRedemptionAssetsVaultInstance = ynETHRedemptionAssetsVault(payable(chainAddresses.yn.YNETH_REDEMPTION_ASSETS_VAULT_ADDRESS));
}

// assign Ethereum addresses
Expand All @@ -113,8 +115,8 @@ contract Base is Test, Utils {
}

function upgradeYnToM3() internal {
if (block.chainid == 17000) {
upgradeYnToM3OnHolesky();
if (block.chainid != 1) {
// Nothing to do, only mainnet left to upgrade
return;
}

Expand Down Expand Up @@ -287,96 +289,6 @@ contract Base is Test, Utils {
runUpgradeIntegrityInvariants(preUpgradeState);
}

function upgradeYnToM3OnHolesky() internal {


uint256 totalAssets = yneth.totalAssets();
uint256 totalSupply = yneth.totalSupply();

// Capture the upgrade state before making any changes
UpgradeState memory preUpgradeState = captureUpgradeState();

preUpgradeState.stakingNodesManagerTotalDeposited = 0;
for (uint256 i = 0; i < preUpgradeState.stakingNodeBalances.length; i++) {
preUpgradeState.stakingNodesManagerTotalDeposited += preUpgradeState.stakingNodeBalances[i];
}

{
address stakinNodesManagerImplementation = 0xC9cf6740282617f3B392f900De0449E687Ce05e3;

vm.startPrank(actors.admin.PROXY_ADMIN_OWNER);
ProxyAdmin(
getTransparentUpgradeableProxyAdminAddress(address(stakingNodesManager))
).upgradeAndCall(
ITransparentUpgradeableProxy(address(stakingNodesManager)),
address(stakinNodesManagerImplementation),
""
);
vm.stopPrank();
}

runUpgradeIntegrityInvariants(preUpgradeState);

// upgrade ynETH
{
vm.startPrank(actors.admin.PROXY_ADMIN_OWNER);
ProxyAdmin(
getTransparentUpgradeableProxyAdminAddress(address(yneth))
).upgradeAndCall(
ITransparentUpgradeableProxy(address(yneth)),
address(0x090D67d3C97712f6C17a037515CbB8502561EE57),
""
);
vm.stopPrank();
}

runUpgradeIntegrityInvariants(preUpgradeState);

// upgrade StakingNodeImplementation
{
stakingNodeImplementation = new StakingNode();
vm.prank(actors.admin.STAKING_ADMIN);
stakingNodesManager.upgradeStakingNodeImplementation(0xf07861349Ed0cB4603590B47D2269768Ed6E2821);
}

{
runUpgradeIntegrityInvariants(preUpgradeState);
// Assert that the redemptionAssetsVault is initially set to the zero address in the StakingNodesManager
assertEq(address(stakingNodesManager.redemptionAssetsVault()), address(0), "redemptionAssetsVault should initially be set to the zero address in StakingNodesManager");
// Assert that previewRedeem returns a non-zero value
uint256 previewRedeemAmount = yneth.previewRedeem(1 ether);
assertGt(previewRedeemAmount, 0, "previewRedeem should return a non-zero value");
}

ynETHWithdrawalQueueManager = WithdrawalQueueManager(0x141aAb320857145fB42240C979b800f48CE5B678);
ynETHRedemptionAssetsVaultInstance = ynETHRedemptionAssetsVault(payable(0x3a2DD2f0f5A20768110a52fC4f091AB9d8631b58));

// ---------------------------------------------------------------
// STAGE 3 - Initialize StakingNodesManager with Init2 and add BURNER_ROLE for WithdrawalQueueManager
// ---------------------------------------------------------------
{
StakingNodesManager.Init2 memory initParams = StakingNodesManager.Init2({
redemptionAssetsVault: ynETHRedemptionAssetsVaultInstance,
withdrawalManager: actors.ops.WITHDRAWAL_MANAGER,
stakingNodesWithdrawer: actors.ops.STAKING_NODES_WITHDRAWER
});

vm.prank(actors.admin.ADMIN);
stakingNodesManager.initializeV2(initParams);
}

runUpgradeIntegrityInvariants(preUpgradeState);

// grant burner role
{
vm.startPrank(actors.admin.STAKING_ADMIN);
yneth.grantRole(yneth.BURNER_ROLE(), address(ynETHWithdrawalQueueManager));
vm.stopPrank();
}

runUpgradeIntegrityInvariants(preUpgradeState);
}

function createValidators(uint256[] memory nodeIds, uint256 count) public returns (uint40[] memory) {
uint40[] memory validatorIndices = new uint40[](count * nodeIds.length);
uint256 index = 0;
Expand Down

0 comments on commit f7b1310

Please sign in to comment.