Skip to content

Commit

Permalink
refactor: optimize pausable (#854)
Browse files Browse the repository at this point in the history
* refactor: optimize pausable

* chore: forge fmt

* refactor: nits

* chore: make storage-report

* fix: rebase

* refactor: review changes

- check pauser reg is non-zero on construction

* fix: ci

feat: small delegation refactors (#866)

* refactor: small refactor to move duplicate expiry checks into signature utils

* refactor: improve clarity of fully-slashed logic

* refactor: improve readability of operator slashed amount calculation
* todo: off-by-one error in test due to rounding issue

* fix: correct amount of shares slashed

* wip: comment out test so michael gets to it in his pr

slashing: change queue withdrawal input to deposit shares (#869)

* feat: queue withdraw uses deposit shares

* fix: tests and removed old test files

* chore: forge ftm

* test: redelegate shares from rounding

* chore: remove unused import

feat: remove delegate to by signature (#871)

feat: track staker withdrawals (#864)

* feat: track staker withdrawals

* chore: forge fmt

* feat: track staker withdrawals

* chore: forge fmt

* fix: `pendingWithdrawals` arrangement

* fix: ci

Fix: Flaky DM Test (#875)

* fix: test

* fix: remove log

feat: move operator set functionality to alm (#860)

* feat: move operator set functionality to alm

* feat: clarify registration states
* fix: allow operators to deallocate from strategies that are not in operator set

* fix: add enumeration for operator allocations

* feat: remove deallocations on deregistration

* chore: cleanup src/test (#863)

* feat: add configurable avs registrar

* feat: remove bloated getters

* feat: use existing set method to get set values

* test: avsd alm refactor (#867)

* test: ALM compiling + but not passing

* test(wip): avsd alm refactor

* chore: update forge-std

* fix: compile

* test(wip): avsd passing

* nit: cleanup

* test: get alm tests passing

* test: fix delegation tests

* feat: add lib `Random`

* test: add allocation enumeration checks to tests

* test: reg/dereg + use `Random`

* refactor: small refactor to reuse getters

* test: `addStrategiesToOperatorSet`

- also adds missing state mutation checks on previous tests

* test: `removeStrategiesFromOperatorSet`

* test: `createOperatorSets`

* test: `setAVSRegistrar`

---------

Co-authored-by: wadealexc <[email protected]>

* feat: add AVS metadata URI to ALM

* chore: update comments

* chore: address comments

fix: change to sharesToWithdraw (#878)

* fix: change to sharesToWithdraw

* fix: test

feat: add tasks to prepare chain state ready for slashing (#868)

* feat: add tasks to prepare chain state ready for slashing

* feat: add queueWithdrawal and completeWithdrawal tasks

* fix: extract addresses from output after deploy

* fix: upgrade scripts to account for AVS/ALM operatorSet changes

* fix: add additional deposit

* fix: add additional slashing between withdrawal queued and completed

* fix: update slashing on top of alex/avsd-alm-refactor

* chore: correct readme and formatting

* fix: PascalCase contract names and update forge-std

* feat: replace console with emit

* feat: remove additional use of console

---------

Co-authored-by: wadealexc <[email protected]>

test: slashing todos (#880)

* test(wip): todos

* test: remove unused utils

* feat: foundry `sparse_mode=true`

* test(wip): todos

* test(wip): todos

* test(wip): todos

* test(wip): todos

* test(wip): todos

* fix: cherry-pick errors

* fix: forge-std

* test(wip): todos

feat: add getMinimumSlashableStake (#889)

* feat: add getMinimumSlashableStake

* fix: only account for deallocation when calculating minimum slashable

refactor: pull beacon chain slashing out of slashing lib (#876)

* fix: correctly update dsf when increasing delegation

* fix: fix bug where we modify an array while iterating over it

* chore: address review nits

* refactor: minor refactors for codesize

* refactor(nit): function ordering

* fix: only check input lengths when receiving tokens

* refactor: remove callstack indirection when completing a withdrawal

* chore: update comment

test: slashing test todos (#885)

* test(wip): todos

* chore: remove lcov

* test(wip): remaining alm todos

* test: final todos

* test(wip): todos

* chore: remove lcov

feat: burn erc20s on slashing (#881)

* refactor: pull beacon chain slashing out of slashing lib

* feat: initial draft for sync slashing

* fix: existing tests

* fix: cumulative shares and fmt

* fix: missing operator key in mapping

* refactor: cumulative scaled shares

* chore: cleanup

* chore: storage report

* fix: rename and beacon strategy

* fix: rebase

* fix: rounding

* test: happy path test cases for burn erc20s

* fix: address comments

* test: timing regression test and comments

* fix: slashable shares in queue amount

* refactor: burn refactor (#897)

* refactor: remove unused return values from _insert
* also removes safe cast
* refactor: pull unrelated operations out and condense library method usage

* test: additional unit test with multiple withdrawals

---------

Co-authored-by: wadealexc <[email protected]>
Co-authored-by: Alex <[email protected]>

test: DelegationManager unit tests  (#886)

* feat: initial draft for sync slashing

* refactor: cumulative scaled shares

* feat: initial draft for sync slashing

* fix: cumulative shares and fmt

* chore: cleanup src/test

* fix: delegation tests

* test: rebased and refactored tests

fix: rebase tests

test: delegation unit refactoring

fix: rounding tests

fix: continue fixing delegation tests

* test: include fuzz underflow tests

* fix: tests and rebase

* chore: comment nit

* fix: failing ci

test: fix env requirement (#899)

* fix: remove env required

* fix: use envOr

* fix: remove env from CI for being required

fix: compile warnings (#900)

fix: slashing local deploy (#898)

* feat: local deploy

* fix: transfer ownership

* fix: comment

test: slashing integration framework (#894)

* feat: add `AVS` user

* test(wip): slashing integration

* test(wip): slashing integration

* test(wip): slashing integration

* test(wip): slashing integration

* fix: make tracing useful

* test(wip): slashing integration

* fix: toStringWad

* fix: eigenpods

* test(wip): slashing integration

* refactor: revert change

* test(review): changes

* fix: compile

* test(review): changes

* refactor: improve logging

* refactor: review changes

* fix: roll in `modifyAllocations`

* fix: roll in `modifyAllocations`

* refactor: review changes

* refactor: add back pause constants

---------

Co-authored-by: Yash Patil <[email protected]>

refactor: EigenPods and beacon chain slashing (#892)

* refactor: eigenpod and beacon chain slashing
* checkpoints are not deleted on completion, saving gas when creating a new checkpoint

* refactor: pull bcsf out of delegationManager

* chore: formatting

* refactor: rename withdrawableRestakedExecutionLayerGwei
* maintains old interface, only state variable is renamed
* this is to reduce line length when using this variable

* refactor: remove branching and slashing math from eigenpod
* fix: clean up balance update conditions and ensure shares==0 is handled

* refactor: remove input validation and explicitly document assumptions

* fix: tests and roundup (#901)

* chore: address feedback

* chore: address feedback again

* chore: cleanup EPM withdrawSharesAsTokens

---------

Co-authored-by: Michael Sun <[email protected]>

refactor: remove deprecated methods (#903)

* refactor: rename parameter to be more accurate

* refactor: remove deprecated methods from dm

* refactor: remove operator details usage

* chore: nit word

test: `withdrawSharesAsTokens` regression (#904)

* fix: commented out integration

* test: call into EP for withdrawing as tokens

chore: remove unnecessary delegate checks (#908)

* feat: remove checks on approver/operator sender on delegate

* chore: update interface

feat: user access management (#870)

* feat: unified access management

fix: test/compile

chore: use helper func in modifier

chore: remove extra

* test: add UAM to unit tests

* refactor: delegate -> appointee

* refactor: setAdmin -> addAdmin

* fix: prevent 0 admins

* refactor: bitshift encode/decode

* feat: short-circuit _checkCanCall

* test: basic reversability

* feat: admin 2-step

fix: remove external call

* chore: fix compile/test

* feat: use opSet length as avs check

* chore: format

* refactor: getoperatorsetcount

* fix: msg.sender in delegatoinapproverupdated

* chore: format
  • Loading branch information
0xClandestine authored and ypatil12 committed Dec 10, 2024
1 parent 385dc53 commit a9f652e
Show file tree
Hide file tree
Showing 143 changed files with 15,278 additions and 12,219 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testinparallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge build --sizes
forge build
id: build

- name: Run unit tests
Expand Down
14 changes: 2 additions & 12 deletions certora/specs/core/DelegationManager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ in this case, the end state is that:
isOperator(staker) == false,
delegatedTo(staker) != staker && delegatedTo(staker) != 0,
and isDelegated(staker) == true (redundant with above)
-only allowed when calling `delegateTo` or `delegateToBySignature`
-only allowed when calling `delegateTo`
2)
FROM not delegated AND not registered as an operator
Expand Down Expand Up @@ -172,7 +172,7 @@ rule cannotChangeDelegationWithoutUndelegating(address staker) {
}
}

// verifies that an undelegated address can only delegate when calling `delegateTo`, `delegateToBySignature` or `registerAsOperator`
// verifies that an undelegated address can only delegate when calling `delegateTo` or `registerAsOperator`
rule canOnlyDelegateWithSpecificFunctions(address staker) {
requireInvariant operatorsAlwaysDelegatedToSelf(staker);
// assume the staker begins as undelegated
Expand All @@ -192,16 +192,6 @@ rule canOnlyDelegateWithSpecificFunctions(address staker) {
} else {
assert (!isDelegated(staker), "staker delegated to inappropriate address?");
}
} else if (f.selector == sig:delegateToBySignature(address, address, ISignatureUtils.SignatureWithExpiry, ISignatureUtils.SignatureWithExpiry, bytes32).selector) {
address toDelegateFrom;
address operator;
require(operator != 0);
ISignatureUtils.SignatureWithExpiry stakerSignatureAndExpiry;
ISignatureUtils.SignatureWithExpiry approverSignatureAndExpiry;
bytes32 salt;
delegateToBySignature(e, toDelegateFrom, operator, stakerSignatureAndExpiry, approverSignatureAndExpiry, salt);
// TODO: this check could be stricter! need to filter when the block timestamp is appropriate for expiry and signature is valid
assert (!isDelegated(staker) || delegatedTo(staker) == operator, "delegateToBySignature bug?");
} else if (f.selector == sig:registerAsOperator(IDelegationManager.OperatorDetails, string).selector) {
IDelegationManager.OperatorDetails operatorDetails;
string metadataURI;
Expand Down
25 changes: 0 additions & 25 deletions docs/core/DelegationManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ Allows an Operator to emit an `OperatorMetadataURIUpdated` event. No other state
Stakers interact with the following functions to delegate their shares to an Operator:

* [`DelegationManager.delegateTo`](#delegateto)
* [`DelegationManager.delegateToBySignature`](#delegatetobysignature)

#### `delegateTo`

Expand All @@ -138,30 +137,6 @@ Allows the caller (a Staker) to delegate their shares to an Operator. Delegation
* The `operator` MUST already be an Operator
* If the `operator` has a `delegationApprover`, the caller MUST provide a valid `approverSignatureAndExpiry` and `approverSalt`

#### `delegateToBySignature`

```solidity
function delegateToBySignature(
address staker,
address operator,
SignatureWithExpiry memory stakerSignatureAndExpiry,
SignatureWithExpiry memory approverSignatureAndExpiry,
bytes32 approverSalt
)
external
```

Allows a Staker to delegate to an Operator by way of signature. This function can be called by three different parties:
* If the Operator calls this method, they need to submit only the `stakerSignatureAndExpiry`
* If the Operator's `delegationApprover` calls this method, they need to submit only the `stakerSignatureAndExpiry`
* If the anyone else calls this method, they need to submit both the `stakerSignatureAndExpiry` AND `approverSignatureAndExpiry`

*Effects*: See `delegateTo` above.

*Requirements*: See `delegateTo` above. Additionally:
* If caller is either the Operator's `delegationApprover` or the Operator, the `approverSignatureAndExpiry` and `approverSalt` can be empty
* `stakerSignatureAndExpiry` MUST be a valid, unexpired signature over the correct hash and nonce

---

### Undelegating and Withdrawing
Expand Down
11 changes: 1 addition & 10 deletions docs/release/slashing/AllocationManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ The AllocationManager contract manages the allocation and reallocation of operat

```solidity
/**
* @notice Called by the delagation manager to set delay when operators register.
* @notice Called by operators or the delegation manager to set their allocation delay.
* @param operator The operator to set the delay on behalf of.
* @param delay The allocation delay in seconds.
* @dev msg.sender is assumed to be the delegation manager.
*/
function setAllocationDelay(address operator, uint32 delay) external;
/**
* @notice Called by operators to set their allocation delay.
* @param delay the allocation delay in seconds
* @dev msg.sender is assumed to be the operator
*/
function setAllocationDelay(uint32 delay) external;
```

These functions allow operators to set their allocation delay. The first variant is called by the DelegationManager upon operator registration for all new operators created after the slashing release. The second variant is called by operators themselves to update their allocation delay or set it for the first time if they joined before the slashing release.
The allocation delay takes effect in `ALLOCATION_CONFIGURATION_DELAY` seconds.
Expand Down
38 changes: 16 additions & 22 deletions docs/storage-report/AVSDirectory.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
| Name | Type | Slot | Offset | Bytes | Contract |
|-------------------------------|--------------------------------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _initializing | bool | 0 | 1 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _owner | address | 51 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectoryTypes.OperatorAVSRegistrationStatus)) | 152 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 153 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| isOperatorSetAVS | mapping(address => bool) | 154 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| isOperatorSet | mapping(address => mapping(uint32 => bool)) | 155 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _operatorSetsMemberOf | mapping(address => struct EnumerableSet.Bytes32Set) | 156 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _operatorSetMembers | mapping(bytes32 => struct EnumerableSet.AddressSet) | 157 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _operatorSetStrategies | mapping(bytes32 => struct EnumerableSet.AddressSet) | 158 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| operatorSetStatus | mapping(address => mapping(address => mapping(uint32 => struct IAVSDirectoryTypes.OperatorSetRegistrationStatus))) | 159 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[41] | 160 | 0 | 1312 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _status | uint256 | 201 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[49] | 202 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| Name | Type | Slot | Offset | Bytes | Contract |
|-------------------------------|-----------------------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _initializing | bool | 0 | 1 | 1 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _owner | address | 51 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __deprecated_pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 151 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectoryTypes.OperatorAVSRegistrationStatus)) | 152 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 153 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[41] | 154 | 0 | 1312 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| _status | uint256 | 195 | 0 | 32 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
| __gap | uint256[49] | 196 | 0 | 1568 | src/contracts/core/AVSDirectory.sol:AVSDirectory |
18 changes: 6 additions & 12 deletions docs/storage-report/AVSDirectoryStorage.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
| Name | Type | Slot | Offset | Bytes | Contract |
|-------------------------------|--------------------------------------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------|
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectoryTypes.OperatorAVSRegistrationStatus)) | 1 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 2 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| isOperatorSetAVS | mapping(address => bool) | 3 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| isOperatorSet | mapping(address => mapping(uint32 => bool)) | 4 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| _operatorSetsMemberOf | mapping(address => struct EnumerableSet.Bytes32Set) | 5 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| _operatorSetMembers | mapping(bytes32 => struct EnumerableSet.AddressSet) | 6 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| _operatorSetStrategies | mapping(bytes32 => struct EnumerableSet.AddressSet) | 7 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| operatorSetStatus | mapping(address => mapping(address => mapping(uint32 => struct IAVSDirectoryTypes.OperatorSetRegistrationStatus))) | 8 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| __gap | uint256[41] | 9 | 0 | 1312 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| Name | Type | Slot | Offset | Bytes | Contract |
|-------------------------------|-----------------------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------|
| __deprecated_DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| avsOperatorStatus | mapping(address => mapping(address => enum IAVSDirectoryTypes.OperatorAVSRegistrationStatus)) | 1 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| operatorSaltIsSpent | mapping(address => mapping(bytes32 => bool)) | 2 | 0 | 32 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
| __gap | uint256[41] | 3 | 0 | 1312 | src/contracts/core/AVSDirectoryStorage.sol:AVSDirectoryStorage |
Loading

0 comments on commit a9f652e

Please sign in to comment.