Skip to content

Commit acd9a83

Browse files
eigenmikemMichael
authored andcommitted
test: non-beacon-chain slashing integration tests (#1010)
* Slashing integration tests (#1003) * Validate that users who are slashed fully can redeposit once undelegated * removing arraylib use * test for updating eigenpod state -> slash/undelegate * removing unnecessary logging function * fixing strategy set * beacon chain tests in progress --------- Co-authored-by: Michael <michael@Michaels-MacBook-Pro.local> * Revert "Slashing integration tests (#1003)" (#1007) This reverts commit e945d8d. * integration tests for full eigenlayer slashes * comment re: beacon chain eth partial deposits * fix: fixing 0 withdrawal issues (#1019) * fix: fixing 0 withdrawal issues * style: white space * docs: changing description for test --------- Co-authored-by: Michael <michael@Michaels-MacBook-Pro.local> * test: withdraw as shares for random subset of strategies fully slashed * style: removing debugging stubs and updating comment --------- Co-authored-by: Michael <michael@Michaels-MacBook-Pro.local>
1 parent 275b618 commit acd9a83

File tree

2 files changed

+392
-0
lines changed

2 files changed

+392
-0
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,45 @@ abstract contract IntegrationBase is IntegrationDeployer {
11331133

11341134
return (strategies.sort(), wadsToSlash);
11351135
}
1136+
1137+
function _strategiesAndWadsForFullSlash(
1138+
OperatorSet memory operatorSet
1139+
) internal view returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
1140+
// Get list of all strategies in an operator set.
1141+
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1142+
1143+
wadsToSlash = new uint[](strategies.length);
1144+
1145+
for (uint i; i < strategies.length; ++i) {
1146+
wadsToSlash[i] = 1 ether;
1147+
}
1148+
1149+
return(strategies.sort(), wadsToSlash);
1150+
}
1151+
1152+
function _strategiesAndWadsForRandFullSlash(
1153+
OperatorSet memory operatorSet
1154+
) internal returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
1155+
// Get list of all strategies in an operator set.
1156+
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1157+
1158+
// Randomly select a subset of strategies to slash.
1159+
uint len = _randUint({ min: 1, max: strategies.length-1 });
1160+
1161+
// Update length of strategies array.
1162+
assembly {
1163+
mstore(strategies, len)
1164+
}
1165+
1166+
wadsToSlash = new uint[](len);
1167+
1168+
// Fully slash each selected strategy
1169+
for (uint i; i < len; ++i) {
1170+
wadsToSlash[i] = 1 ether;
1171+
}
1172+
1173+
return (strategies.sort(), wadsToSlash);
1174+
}
11361175

11371176
function _randMagnitudes(uint64 sum, uint256 len) internal returns (uint64[] memory magnitudes) {
11381177
magnitudes = new uint64[](len);
@@ -1151,6 +1190,18 @@ abstract contract IntegrationBase is IntegrationDeployer {
11511190
}
11521191
}
11531192

1193+
function _maxMagnitudes(OperatorSet memory operatorSet, User operator) internal view returns (uint64[] memory magnitudes) {
1194+
IStrategy[] memory strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1195+
uint256 len = strategies.length;
1196+
magnitudes = new uint64[](len);
1197+
1198+
if (len == 0) return magnitudes;
1199+
1200+
for (uint256 i; i < len; ++i) {
1201+
magnitudes[i] = allocationManager.getMaxMagnitude(address(operator), strategies[i]);
1202+
}
1203+
}
1204+
11541205
function _randWithdrawal(
11551206
IStrategy[] memory strategies,
11561207
uint[] memory shares

0 commit comments

Comments
 (0)