Skip to content

Commit 02658c6

Browse files
committed
test: passing redistribution upgrade test
1 parent 4a887cb commit 02658c6

File tree

6 files changed

+95
-112
lines changed

6 files changed

+95
-112
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import "src/test/integration/TypeImporter.t.sol";
1313
import "src/test/integration/IntegrationDeployer.t.sol";
1414
import "src/test/integration/TimeMachine.t.sol";
1515
import "src/test/integration/users/User.t.sol";
16-
import "src/test/integration/users/User_M1.t.sol";
1716

1817
abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
1918
using StdStyle for *;

src/test/integration/IntegrationChecks.t.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity ^0.8.27;
33

44
import "src/test/integration/IntegrationBase.t.sol";
55
import "src/test/integration/users/User.t.sol";
6-
import "src/test/integration/users/User_M1.t.sol";
76

87
/// @notice Contract that provides utility functions to reuse common test blocks & checks
98
contract IntegrationCheckUtils is IntegrationBase {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import "src/contracts/interfaces/IStrategy.sol";
5+
6+
/**
7+
* @notice Interface of the allocationManager prior to redistribution.
8+
* @dev The interface remains the exact same, except `SlashOperator` does not return the slashID or shares
9+
* @dev This interface is the minimal possibl interface needed for the redistribution upgrade test
10+
*/
11+
interface IAllocationManager_PreRedistribution {
12+
13+
/**
14+
* @notice Struct containing parameters to slashing
15+
* @param operator the address to slash
16+
* @param operatorSetId the ID of the operatorSet the operator is being slashed on behalf of
17+
* @param strategies the set of strategies to slash
18+
* @param wadsToSlash the parts in 1e18 to slash, this will be proportional to the operator's
19+
* slashable stake allocation for the operatorSet
20+
* @param description the description of the slashing provided by the AVS for legibility
21+
*/
22+
struct SlashingParams {
23+
address operator;
24+
uint32 operatorSetId;
25+
IStrategy[] strategies;
26+
uint256[] wadsToSlash;
27+
string description;
28+
}
29+
30+
/**
31+
* @notice Called by an AVS to slash an operator in a given operator set. The operator must be registered
32+
* and have slashable stake allocated to the operator set.
33+
*
34+
* @param avs The AVS address initiating the slash.
35+
* @param params The slashing parameters, containing:
36+
* - operator: The operator to slash.
37+
* - operatorSetId: The ID of the operator set the operator is being slashed from.
38+
* - strategies: Array of strategies to slash allocations from (must be in ascending order).
39+
* - wadsToSlash: Array of proportions to slash from each strategy (must be between 0 and 1e18).
40+
* - description: Description of why the operator was slashed.
41+
*
42+
* @dev For each strategy:
43+
* 1. Reduces the operator's current allocation magnitude by wadToSlash proportion.
44+
* 2. Reduces the strategy's max and encumbered magnitudes proportionally.
45+
* 3. If there is a pending deallocation, reduces it proportionally.
46+
* 4. Updates the operator's shares in the DelegationManager.
47+
*
48+
* @dev Small slashing amounts may not result in actual token burns due to
49+
* rounding, which will result in small amounts of tokens locked in the contract
50+
* rather than fully burning through the burn mechanism.
51+
*/
52+
function slashOperator(address avs, SlashingParams calldata params) external;
53+
}

src/test/integration/tests/upgrade/Redistribution.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ contract Integration_Upgrade_Redistribution_Base is UpgradeTest {
5252

5353
// 6. Operator is randomly slashed by the operatorSet
5454
slashParams = _genSlashing_Rand(operator, operatorSet);
55-
avs.slashOperator(slashParams);
55+
avs.slashOperator_PreRedistribution(slashParams);
5656
}
5757
}
5858

src/test/integration/users/AVS.t.sol

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "src/test/utils/Logger.t.sol";
1414

1515
import "src/test/utils/ArrayLib.sol";
1616
import "src/contracts/interfaces/IAVSRegistrar.sol";
17+
import "src/test/integration/deprecatedInterfaces/mainnet/AllocationManager.sol";
1718

1819
interface IAVSDeployer {
1920
function delegationManager() external view returns (DelegationManager);
@@ -134,10 +135,50 @@ contract AVS is Logger, IAllocationManagerTypes, IAVSRegistrar {
134135
}
135136

136137
_tryPrankAppointee_AllocationManager(IAllocationManager.slashOperator.selector);
138+
137139
allocationManager.slashOperator(address(this), params);
138140
print.gasUsed();
139141
}
140142

143+
/// @notice Slash operator prior to redistribution.
144+
/// @dev This is ONLY used by the redistribution upgrade test.
145+
function slashOperator_PreRedistribution(SlashingParams memory params) public createSnapshot {
146+
147+
IAllocationManager_PreRedistribution.SlashingParams memory slashParams = IAllocationManager_PreRedistribution.SlashingParams({
148+
operator: params.operator,
149+
operatorSetId: params.operatorSetId,
150+
strategies: params.strategies,
151+
wadsToSlash: params.wadsToSlash,
152+
description: params.description
153+
});
154+
155+
for (uint i; i < params.strategies.length; ++i) {
156+
string memory strategyName = params.strategies[i] == beaconChainETHStrategy
157+
? "Native ETH"
158+
: IERC20Metadata(address(params.strategies[i].underlyingToken())).name();
159+
160+
print.method(
161+
"slashOperator",
162+
string.concat(
163+
"{operator: ",
164+
User(payable(params.operator)).NAME_COLORED(),
165+
", operatorSetId: ",
166+
cheats.toString(params.operatorSetId),
167+
", strategy: ",
168+
strategyName,
169+
", wadToSlash: ",
170+
params.wadsToSlash[i].asWad(),
171+
"}"
172+
)
173+
);
174+
}
175+
176+
_tryPrankAppointee_AllocationManager(IAllocationManager.slashOperator.selector);
177+
178+
IAllocationManager_PreRedistribution(address(allocationManager)).slashOperator(address(this), slashParams);
179+
print.gasUsed();
180+
}
181+
141182
function slashOperator(User operator, uint32 operatorSetId, IStrategy[] memory strategies, uint[] memory wadsToSlash)
142183
public
143184
createSnapshot

src/test/integration/users/User_M1.t.sol

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)