Skip to content

Commit

Permalink
feat: improve m2 upgrade test and add eigenpod migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc committed Apr 3, 2024
1 parent 753f16f commit daaac5f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
31 changes: 30 additions & 1 deletion src/test/inspector/Inspector.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Inspector is ExistingDeploymentParser, PrintUtils, ITargetDeployer {

Vm cheats = Vm(HEVM_ADDRESS);

bool isUpgraded = false;
bool public isUpgraded = false;

uint targetNonce;

Expand Down Expand Up @@ -64,6 +64,28 @@ contract Inspector is ExistingDeploymentParser, PrintUtils, ITargetDeployer {
inspect(t);
}

function test_MigrateEigenPod() public {
// Some dude from etherscan hehe
Target t = _target(0xf151FeC20505fAf3E6a7E6AA1654e53e23b42CEE);
inspect(t);

// Deploy a pod for the user
if (!t.hasEigenPod()) {
t.deployEigenPod();
inspect(t);
}

// Send a little ETH to the pod
_fundPod(t.pod());
inspect(t);

// Upgrade to m2
_upgradeMainnet();

t.activateRestaking();
inspect(t);
}

/// Base inspect methods

function inspect(address a) internal returns (Target) {
Expand Down Expand Up @@ -202,6 +224,13 @@ contract Inspector is ExistingDeploymentParser, PrintUtils, ITargetDeployer {
_log("");
}

function _fundPod(IEigenPod pod) internal {
address _pod = address(pod);
_log("Minting 1 eth to pod", _pod);
cheats.deal(_pod, 1 ether);
_log("");
}

function _isEOA(address a) internal view returns (bool b) {
assembly { b := iszero(extcodesize(a)) }
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/inspector/PrintUtils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ contract PrintUtils is Test {
));
}

function _logSection(string memory name, address a) internal {
emit log(string.concat(
SECTION_DELIMITER,
name.cyan(),
": ",
a.yellow().dim(),
SECTION_DELIMITER
));
}

function _logAction(string memory name, string memory action) internal {
emit log_named_string(
name.cyan(),
Expand Down
36 changes: 29 additions & 7 deletions src/test/inspector/Target.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import "src/test/inspector/PrintUtils.t.sol";

interface ITargetDeployer {
function whitelistedStrategies() external view returns (StrategyBase[] memory);
function isUpgraded() external view returns (bool);
}

struct HeldAsset {
Expand Down Expand Up @@ -81,6 +82,18 @@ contract Target is Test, PrintUtils {
}
}

function deployEigenPod() public action("deployEigenPod") {
// M2 expects an address return value, M1 does not
// So we call the method directly and don't parse the return
bytes4 selector = eigenPodManager.createPod.selector;

address(eigenPodManager).call(abi.encodeWithSelector(selector, ""));
}

function activateRestaking() public action("activateRestaking") {
pod.activateRestaking();
}

function queueWithdrawals_M1() public action("queueWithdrawals_M1") {
for (uint i = 0; i < assets.length; i++) {
HeldAsset memory asset = assets[i];
Expand Down Expand Up @@ -159,14 +172,16 @@ contract Target is Test, PrintUtils {
function logBasicInfo() public {
_logHeader(name, address(this));

address _pod = address(pod);

_logEth("ETH balance", address(this).balance);

// Basic info - EigenPod
// EigenPod info
address _pod = address(pod);

_log("Has EigenPod", _pod != address(0));
if (_pod != address(0)) {
_log("- pod", _pod);
_logSection("EigenPod", _pod);
_logEth("Pod ETH balance", _pod.balance);
_log("Has Restaked", pod.hasRestaked());
}

// LST strategy shares and underlying tokens
Expand Down Expand Up @@ -195,7 +210,7 @@ contract Target is Test, PrintUtils {
IStrategyManager.DeprecatedStruct_QueuedWithdrawal memory qw = queuedWithdrawals_M1[i];

bytes32 withdrawalRoot = strategyManager.calculateWithdrawalRoot(qw);
_log("- withdrawalRoot", withdrawalRoot);
_log("withdrawalRoot", withdrawalRoot);
_log("- pending", strategyManager.withdrawalRootPending(withdrawalRoot));
_log("- strategy", _stratName(qw.strategies[0]));
_log("- shares", qw.shares[0]);
Expand All @@ -212,7 +227,7 @@ contract Target is Test, PrintUtils {
IDelegationManager.Withdrawal memory qw = queuedWithdrawals[i];

bytes32 withdrawalRoot = delegationManager.calculateWithdrawalRoot(qw);
_log("- withdrawalRoot", withdrawalRoot);
_log("withdrawalRoot", withdrawalRoot);
_log("- pending", delegationManager.pendingWithdrawals(withdrawalRoot));
_log("- strategy", _stratName(qw.strategies[0]));
_log("- shares", qw.shares[0]);
Expand All @@ -225,9 +240,16 @@ contract Target is Test, PrintUtils {
}
}

function hasEigenPod() public view returns (bool) {
return address(pod) != address(0);
}

function _updateAssets() internal {
delete assets;
if (eigenPodManager.hasPod(address(this))) {
pod = eigenPodManager.getPod(address(this));
}

delete assets;
for (uint i = 0; i < whitelistedStrategies.length; i++) {
StrategyBase strat = whitelistedStrategies[i];
IERC20 underlying = strat.underlyingToken();
Expand Down

0 comments on commit daaac5f

Please sign in to comment.