Skip to content

Commit 388e9f9

Browse files
authored
feat: track total slashable stake and total delegated stake per quorum (#317)
* feat: remove both option * feat: total delegated stake and total slashable stake per quorum config * test: resolve some breaking changes to tests * chore: move stake type to file level definition * chore: refactor loop * test: add unit test for slashble stake quorum init * test: assert on state and event * test: delegated stake quorum and assertions
1 parent fa04f06 commit 388e9f9

13 files changed

+380
-216
lines changed

foundry.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ ffi = true
99
no-match-contract = "FFI"
1010

1111
# Enables or disables the optimizer
12-
optimizer = true
13-
# The number of optimizer runs
14-
optimizer_runs = 200
12+
optimizer = false
1513
# Whether or not to use the Yul intermediate representation compilation pipeline
1614
via_ir = false
1715
# Override the Solidity version (this overrides `auto_detect_solc`)

src/RegistryCoordinator.sol

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISi
66
import {IAVSDirectory, OperatorSet} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
77
import {ISocketUpdater} from "./interfaces/ISocketUpdater.sol";
88
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
9-
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
9+
import {IStakeRegistry, StakeType} from "./interfaces/IStakeRegistry.sol";
1010
import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol";
1111
import {IServiceManager} from "./interfaces/IServiceManager.sol";
1212
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
@@ -87,11 +87,15 @@ contract RegistryCoordinator is
8787
uint256 _initialPausedStatus,
8888
OperatorSetParam[] memory _operatorSetParams,
8989
uint96[] memory _minimumStakes,
90-
IStakeRegistry.StrategyParams[][] memory _strategyParams
90+
IStakeRegistry.StrategyParams[][] memory _strategyParams,
91+
StakeType[] memory _stakeTypes,
92+
uint32[] memory _lookAheadPeriods
9193
) external initializer {
9294
require(
9395
_operatorSetParams.length == _minimumStakes.length
94-
&& _minimumStakes.length == _strategyParams.length,
96+
&& _minimumStakes.length == _strategyParams.length
97+
&& _strategyParams.length == _stakeTypes.length
98+
&& _stakeTypes.length == _lookAheadPeriods.length,
9599
"RegistryCoordinator.initialize: input length mismatch"
96100
);
97101

@@ -108,7 +112,7 @@ contract RegistryCoordinator is
108112

109113
// Create quorums
110114
for (uint256 i = 0; i < _operatorSetParams.length; i++) {
111-
_createQuorum(_operatorSetParams[i], _minimumStakes[i], _strategyParams[i]);
115+
_createQuorum(_operatorSetParams[i], _minimumStakes[i], _strategyParams[i], _stakeTypes[i], _lookAheadPeriods[i]);
112116
}
113117
}
114118

@@ -404,12 +408,21 @@ contract RegistryCoordinator is
404408
* @param strategyParams a list of strategies and multipliers used by the StakeRegistry to
405409
* calculate an operator's stake weight for the quorum
406410
*/
407-
function createQuorum(
411+
function createTotalDelegatedStakeQuorum(
408412
OperatorSetParam memory operatorSetParams,
409413
uint96 minimumStake,
410414
IStakeRegistry.StrategyParams[] memory strategyParams
411415
) external virtual onlyOwner {
412-
_createQuorum(operatorSetParams, minimumStake, strategyParams);
416+
_createQuorum(operatorSetParams, minimumStake, strategyParams, StakeType.TOTAL_DELEGATED, 0);
417+
}
418+
419+
function createSlashableStakeQuorum(
420+
OperatorSetParam memory operatorSetParams,
421+
uint96 minimumStake,
422+
IStakeRegistry.StrategyParams[] memory strategyParams,
423+
uint32 lookAheadPeriod
424+
) external virtual onlyOwner {
425+
_createQuorum(operatorSetParams, minimumStake, strategyParams, StakeType.TOTAL_SLASHABLE, lookAheadPeriod);
413426
}
414427

415428
/**
@@ -809,7 +822,9 @@ contract RegistryCoordinator is
809822
function _createQuorum(
810823
OperatorSetParam memory operatorSetParams,
811824
uint96 minimumStake,
812-
IStakeRegistry.StrategyParams[] memory strategyParams
825+
IStakeRegistry.StrategyParams[] memory strategyParams,
826+
StakeType stakeType,
827+
uint32 lookAheadPeriod
813828
) internal {
814829
// Increment the total quorum count. Fails if we're already at the max
815830
uint8 prevQuorumCount = quorumCount;
@@ -824,7 +839,14 @@ contract RegistryCoordinator is
824839

825840
// Initialize the quorum here and in each registry
826841
_setOperatorSetParams(quorumNumber, operatorSetParams);
827-
stakeRegistry.initializeQuorum(quorumNumber, minimumStake, strategyParams);
842+
843+
// Initialize stake registry based on stake type
844+
if (stakeType == StakeType.TOTAL_DELEGATED) {
845+
stakeRegistry.initializeDelegatedStakeQuorum(quorumNumber, minimumStake, strategyParams);
846+
} else if (stakeType == StakeType.TOTAL_SLASHABLE) {
847+
stakeRegistry.initializeSlashableStakeQuorum(quorumNumber, minimumStake, lookAheadPeriod, strategyParams);
848+
}
849+
828850
indexRegistry.initializeQuorum(quorumNumber);
829851
blsApkRegistry.initializeQuorum(quorumNumber);
830852
// Check if the AVS has migrated to operator sets

0 commit comments

Comments
 (0)