Skip to content
Merged
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
62 changes: 1 addition & 61 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,36 +186,6 @@ abstract contract IntegrationBase is IntegrationDeployer {

return result;
}

/// @dev Choose a random subset of validators (selects AT LEAST ONE but NOT ALL)
function _chooseSubset(uint40[] memory validators) internal returns (uint40[] memory) {
require(validators.length >= 2, "Need at least 2 validators to choose subset");

uint40[] memory result = new uint40[](validators.length);
uint newLen;

uint rand = _randUint({ min: 1, max: validators.length ** 2 });
for (uint i = 0; i < validators.length; i++) {
if (rand >> i & 1 == 1) {
result[newLen] = validators[i];
newLen++;
}
}

// If we picked all, remove one random validator
if (newLen == validators.length) {
uint indexToRemove = _randUint({ min: 0, max: validators.length - 1 });
for (uint i = indexToRemove; i < newLen - 1; i++) {
result[i] = result[i + 1];
}
newLen--;
}

// Update array length
assembly { mstore(result, newLen) }

return result;
}

function _getTokenName(IERC20 token) internal view returns (string memory) {
if (token == NATIVE_ETH) {
Expand Down Expand Up @@ -591,11 +561,8 @@ abstract contract IntegrationBase is IntegrationDeployer {
uint wadToSlash = slashingParams.wadsToSlash[slashingParams.strategies.indexOf(strat)];
slashedShares = prevShares[i].mulWadRoundUp(allocateParams.newMagnitudes[i].mulWadRoundUp(wadToSlash));
}
console.log(prevShares[i]);
console.log(slashedShares);
console.log(curShares[i]);

assertApproxEqAbs(prevShares[i] - slashedShares, curShares[i], 1000, err);
assertApproxEqAbs(prevShares[i] - slashedShares, curShares[i], 1, err);
}
}

Expand Down Expand Up @@ -1166,21 +1133,6 @@ abstract contract IntegrationBase is IntegrationDeployer {

return (strategies.sort(), wadsToSlash);
}

function _strategiesAndWadsForFullSlash(
OperatorSet memory operatorSet
) internal view returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
// Get list of all strategies in an operator set.
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);

wadsToSlash = new uint[](strategies.length);

for (uint i; i < strategies.length; ++i) {
wadsToSlash[i] = 1 ether;
}

return (strategies.sort(), wadsToSlash);
}

function _randMagnitudes(uint64 sum, uint256 len) internal returns (uint64[] memory magnitudes) {
magnitudes = new uint64[](len);
Expand All @@ -1199,18 +1151,6 @@ abstract contract IntegrationBase is IntegrationDeployer {
}
}

function _maxMagnitudes(OperatorSet memory operatorSet, User operator) internal view returns (uint64[] memory magnitudes) {
IStrategy[] memory strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
uint256 len = strategies.length;
magnitudes = new uint64[](len);

if (len == 0) return magnitudes;

for (uint256 i; i < len; ++i) {
magnitudes[i] = allocationManager.getMaxMagnitude(address(operator), strategies[i]);
}
}

function _randWithdrawal(
IStrategy[] memory strategies,
uint[] memory shares
Expand Down
50 changes: 0 additions & 50 deletions src/test/integration/IntegrationChecks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -390,56 +390,6 @@ contract IntegrationCheckUtils is IntegrationBase {
}
}

function check_Withdrawal_AsTokens_State_AfterBeaconSlash(
User staker,
User operator,
IDelegationManagerTypes.Withdrawal memory withdrawal,
IAllocationManagerTypes.AllocateParams memory allocateParams,
IAllocationManagerTypes.SlashingParams memory slashingParams,
uint[] memory expectedTokens
) internal {
IERC20[] memory tokens = new IERC20[](withdrawal.strategies.length);

for (uint i; i < withdrawal.strategies.length; i++) {
IStrategy strat = withdrawal.strategies[i];

bool isBeaconChainETHStrategy = strat == beaconChainETHStrategy;

tokens[i] = isBeaconChainETHStrategy ? NATIVE_ETH : withdrawal.strategies[i].underlyingToken();

if (slashingParams.strategies.contains(strat)) {
uint wadToSlash = slashingParams.wadsToSlash[slashingParams.strategies.indexOf(strat)];

expectedTokens[i] -= expectedTokens[i]
.mulWadRoundUp(allocateParams.newMagnitudes[i].mulWadRoundUp(wadToSlash));

uint256 max = allocationManager.getMaxMagnitude(address(operator), strat);

withdrawal.scaledShares[i] -= withdrawal.scaledShares[i].calcSlashedAmount(WAD, max);

// Round down to the nearest gwei for beaconchain ETH strategy.
if (isBeaconChainETHStrategy) {
expectedTokens[i] -= expectedTokens[i] % 1 gwei;
}
}
}

// Common checks
assert_WithdrawalNotPending(delegationManager.calculateWithdrawalRoot(withdrawal), "staker withdrawal should no longer be pending");

// assert_Snap_Added_TokenBalances(staker, tokens, expectedTokens, "staker should have received expected tokens");
assert_Snap_Unchanged_StakerDepositShares(staker, "staker shares should not have changed");
assert_Snap_Removed_StrategyShares(withdrawal.strategies, withdrawal.scaledShares, "strategies should have total shares decremented");

// Checks specific to an operator that the Staker has delegated to
if (operator != User(payable(0))) {
if (operator != staker) {
assert_Snap_Unchanged_TokenBalances(operator, "operator token balances should not have changed");
}
assert_Snap_Unchanged_OperatorShares(operator, "operator shares should not have changed");
}
}

function check_Withdrawal_AsShares_State_AfterSlash(
User staker,
User operator,
Expand Down

This file was deleted.

Loading
Loading