Skip to content

Commit

Permalink
test: non-beacon-chain slashing integration tests (#1010)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
eigenmikem and Michael authored Jan 14, 2025
1 parent e8db8d3 commit 3802dec
Show file tree
Hide file tree
Showing 2 changed files with 392 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,45 @@ 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 _strategiesAndWadsForRandFullSlash(
OperatorSet memory operatorSet
) internal returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
// Get list of all strategies in an operator set.
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);

// Randomly select a subset of strategies to slash.
uint len = _randUint({ min: 1, max: strategies.length-1 });

// Update length of strategies array.
assembly {
mstore(strategies, len)
}

wadsToSlash = new uint[](len);

// Fully slash each selected strategy
for (uint i; i < len; ++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 @@ -1147,6 +1186,18 @@ 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
Loading

0 comments on commit 3802dec

Please sign in to comment.