Skip to content

Commit

Permalink
chore: rename back to checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
8sunyuan committed Aug 12, 2024
1 parent c4a4ed0 commit d795e1c
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 77 deletions.
30 changes: 25 additions & 5 deletions src/contracts/core/AVSDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract AVSDirectory is
ReentrancyGuardUpgradeable
{
using EnumerableSet for EnumerableSet.Bytes32Set;
using MagnitudeCheckpoints for MagnitudeCheckpoints.History;
using Checkpoints for Checkpoints.History;

/// @dev Index for flag that pauses operator register/deregister to avs when set.
uint8 internal constant PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS = 0;
Expand Down Expand Up @@ -364,7 +364,7 @@ contract AVSDirectory is
slashedMagnitude = uint64(uint256(bipsToSlash) * uint256(currentMagnitude) / BIPS_FACTOR);

_magnitudeUpdate[operator][strategies[i]][msg.sender][operatorSetId].decrementAtAndFutureCheckpoints({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
decrementValue: slashedMagnitude
});
}
Expand Down Expand Up @@ -392,7 +392,7 @@ contract AVSDirectory is

// 3. update totalMagnitude, get total magnitude and subtract slashedMagnitude and slashedFromDeallocation
_totalMagnitudeUpdate[operator][strategies[i]].push({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
value: _totalMagnitudeUpdate[operator][strategies[i]].latest() - slashedMagnitude - slashedFromDeallocation
});
}
Expand Down Expand Up @@ -522,7 +522,7 @@ contract AVSDirectory is

// 3. allocate magnitude which will take effect in the future 21 days from now
_magnitudeUpdate[operator][strategy][operatorSets[i].avs][operatorSets[i].operatorSetId].push({
timestamp: effectTimestamp,
key: effectTimestamp,
value: value + uint224(allocation.magnitudeDiffs[i])
});
// 4. keep track of available freeMagnitude to update later
Expand Down Expand Up @@ -566,7 +566,7 @@ contract AVSDirectory is
// 2. update and decrement current and future queued amounts in case any pending allocations exist
_magnitudeUpdate[operator][strategy][operatorSets[i].avs][operatorSets[i].operatorSetId]
.decrementAtAndFutureCheckpoints({
timestamp: uint32(block.timestamp),
key: uint32(block.timestamp),
decrementValue: deallocation.magnitudeDiffs[i]
});

Expand Down Expand Up @@ -685,6 +685,26 @@ contract AVSDirectory is
|| registrationStatus.lastDeregisteredTimestamp + ALLOCATION_DELAY >= block.timestamp;
}

// /**
// * @notice fetches the minimum slashable shares for a certain operator and operatorSet for a list of strategies
// * from the current timestamp until the given timestamp
// *
// * @param operator the operator to get the minimum slashable shares for
// * @param operatorSet the operatorSet to get the minimum slashable shares for
// * @param strategies the strategies to get the minimum slashable shares for
// * @param timestamp the timestamp to the minimum slashable shares before
// *
// * @dev used to get the slashable stakes of operators to weigh over a given slashability window
// *
// * @return the list of share amounts for each strategy
// */
// function getMinimumSlashableSharesBefore(
// address operator,
// OperatorSet calldata operatorSet,
// IStrategy[] calldata strategies,
// uint32 timestamp
// ) external view returns (uint256[] calldata) {}

/**
* @notice Calculates the digest hash to be signed by an operator to register with an AVS.
*
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/core/AVSDirectoryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.12;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

import "../interfaces/IAVSDirectory.sol";
import {MagnitudeCheckpoints} from "../libraries/MagnitudeCheckpoints.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";

abstract contract AVSDirectoryStorage is IAVSDirectory {
using EnumerableSet for EnumerableSet.Bytes32Set;
Expand Down Expand Up @@ -59,14 +59,14 @@ abstract contract AVSDirectoryStorage is IAVSDirectory {

/// @notice Mapping: operator => strategy => checkpointed totalMagnitude
/// Note that totalMagnitude is monotonically decreasing and only gets updated upon slashing
mapping(address => mapping(IStrategy => MagnitudeCheckpoints.History)) internal _totalMagnitudeUpdate;
mapping(address => mapping(IStrategy => Checkpoints.History)) internal _totalMagnitudeUpdate;

/// @notice Mapping: operator => strategy => free available magnitude that can be allocated to operatorSets
/// Decrements whenever allocations take place and increments when deallocations are completed
mapping(address => mapping(IStrategy => uint64)) public freeMagnitude;

/// @notice Mapping: operator => strategy => avs => operatorSetId => checkpointed magnitude
mapping(address => mapping(IStrategy => mapping(address => mapping(uint32 => MagnitudeCheckpoints.History))))
mapping(address => mapping(IStrategy => mapping(address => mapping(uint32 => Checkpoints.History))))
internal _magnitudeUpdate;

/// @notice Mapping: operator => strategy => avs => operatorSetId => queuedDeallocations
Expand Down
Loading

0 comments on commit d795e1c

Please sign in to comment.