Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/forge-test-intense.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: v1.3.5
version: v1.5.0

# Build the project and display contract sizes.
- name: Forge Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: v1.3.5
version: v1.5.0

# Run Forge's formatting checker to ensure consistent code style.
- name: Forge Fmt
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: v1.3.5
version: v1.5.0

# Install LCOV for coverage report generation.
- name: Install LCOV
Expand Down
16 changes: 12 additions & 4 deletions script/utils/OperatorSetUpgradeLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
pragma solidity ^0.8.0;
// Deploy L2AVS proxy

import {ITransparentUpgradeableProxy} from
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {
ITransparentUpgradeableProxy
} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

import {Vm} from "forge-std/Vm.sol";
Expand All @@ -30,12 +31,19 @@ library OperatorSetUpgradeLib {
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

function upgrade(address proxy, address implementation, bytes memory data) internal {
function upgrade(
address proxy,
address implementation,
bytes memory data
) internal {
ProxyAdmin admin = ProxyAdmin(getAdmin(proxy));
admin.upgradeAndCall(ITransparentUpgradeableProxy(payable(proxy)), implementation, data);
}

function upgrade(address proxy, address implementation) internal {
function upgrade(
address proxy,
address implementation
) internal {
ProxyAdmin admin = ProxyAdmin(getAdmin(proxy));
admin.upgrade(ITransparentUpgradeableProxy(payable(proxy)), implementation);
}
Expand Down
20 changes: 10 additions & 10 deletions src/BLSSignatureChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage {
}

// Get the quorums the nonsigner was registered for at referenceBlockNumber
nonSigners.quorumBitmaps[j] = registryCoordinator
.getQuorumBitmapAtBlockNumberByIndex({
nonSigners.quorumBitmaps[j] = registryCoordinator.getQuorumBitmapAtBlockNumberByIndex({
operatorId: nonSigners.pubkeyHashes[j],
blockNumber: referenceBlockNumber,
index: params.nonSignerQuorumBitmapIndices[j]
Expand Down Expand Up @@ -144,12 +143,12 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage {
apk = apk.plus(params.quorumApks[i]);

// Get the total and starting signed stake for the quorum at referenceBlockNumber
stakeTotals.totalStakeForQuorum[i] = stakeRegistry
.getTotalStakeAtBlockNumberFromIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
index: params.totalStakeIndices[i]
});
stakeTotals.totalStakeForQuorum[i] =
stakeRegistry.getTotalStakeAtBlockNumberFromIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
index: params.totalStakeIndices[i]
});
stakeTotals.signedStakeForQuorum[i] = stakeTotals.totalStakeForQuorum[i];

// Keep track of the nonSigners index in the quorum
Expand All @@ -160,8 +159,9 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage {
for (uint256 j = 0; j < params.nonSignerPubkeys.length; j++) {
// if the nonSigner is a part of the quorum, subtract their stake from the running total
if (BitmapUtils.isSet(nonSigners.quorumBitmaps[j], uint8(quorumNumbers[i]))) {
stakeTotals.signedStakeForQuorum[i] -= stakeRegistry
.getStakeAtBlockNumberAndIndex({
stakeTotals.signedStakeForQuorum[
i
] -= stakeRegistry.getStakeAtBlockNumberAndIndex({
quorumNumber: uint8(quorumNumbers[i]),
blockNumber: referenceBlockNumber,
operatorId: nonSigners.pubkeyHashes[j],
Expand Down
10 changes: 8 additions & 2 deletions src/EjectionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
}

/// @inheritdoc IEjectionManager
function setEjector(address ejector, bool status) external onlyOwner {
function setEjector(
address ejector,
bool status
) external onlyOwner {
_setEjector(ejector, status);
}

Expand All @@ -116,7 +119,10 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
}

///@dev internal function to set the ejector
function _setEjector(address ejector, bool status) internal {
function _setEjector(
address ejector,
bool status
) internal {
isEjector[ejector] = status;
emit EjectorUpdated(ejector, status);
}
Expand Down
10 changes: 6 additions & 4 deletions src/IndexRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ contract IndexRegistry is IndexRegistryStorage {
// If this is the first time we're using this operatorIndex, push its first update
// This maintains an invariant: existing indices have nonzero history
if (_operatorIndexHistory[quorumNumber][newOperatorCount - 1].length == 0) {
_operatorIndexHistory[quorumNumber][newOperatorCount - 1].push(
_operatorIndexHistory[quorumNumber][newOperatorCount
- 1].push(
OperatorUpdate({
operatorId: OPERATOR_DOES_NOT_EXIST_ID,
fromBlockNumber: uint32(block.number)
operatorId: OPERATOR_DOES_NOT_EXIST_ID, fromBlockNumber: uint32(block.number)
})
);
}
Expand Down Expand Up @@ -149,7 +149,9 @@ contract IndexRegistry is IndexRegistryStorage {
lastUpdate.numOperators = newOperatorCount;
} else {
_operatorCountHistory[quorumNumber].push(
QuorumUpdate({numOperators: newOperatorCount, fromBlockNumber: uint32(block.number)})
QuorumUpdate({
numOperators: newOperatorCount, fromBlockNumber: uint32(block.number)
})
);
}
}
Expand Down
36 changes: 21 additions & 15 deletions src/OperatorStateRetriever.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ contract OperatorStateRetriever {
CheckSignaturesIndices memory checkSignaturesIndices;

// get the indices of the quorumBitmap updates for each of the operators in the nonSignerOperatorIds array
checkSignaturesIndices.nonSignerQuorumBitmapIndices = registryCoordinator
.getQuorumBitmapIndicesAtBlockNumber(referenceBlockNumber, nonSignerOperatorIds);
checkSignaturesIndices.nonSignerQuorumBitmapIndices =
registryCoordinator.getQuorumBitmapIndicesAtBlockNumber(
referenceBlockNumber, nonSignerOperatorIds
);

// get the indices of the totalStake updates for each of the quorums in the quorumNumbers array
checkSignaturesIndices.totalStakeIndices =
Expand All @@ -138,24 +140,28 @@ contract OperatorStateRetriever {

for (uint256 i = 0; i < nonSignerOperatorIds.length; i++) {
// get the quorumBitmap for the operator at the given blocknumber and index
uint192 nonSignerQuorumBitmap = registryCoordinator
.getQuorumBitmapAtBlockNumberByIndex(
nonSignerOperatorIds[i],
referenceBlockNumber,
checkSignaturesIndices.nonSignerQuorumBitmapIndices[i]
);
uint192 nonSignerQuorumBitmap =
registryCoordinator.getQuorumBitmapAtBlockNumberByIndex(
nonSignerOperatorIds[i],
referenceBlockNumber,
checkSignaturesIndices.nonSignerQuorumBitmapIndices[i]
);

require(nonSignerQuorumBitmap != 0, OperatorNotRegistered());

// if the operator was a part of the quorum and the quorum is a part of the provided quorumNumbers
if ((nonSignerQuorumBitmap >> uint8(quorumNumbers[quorumNumberIndex])) & 1 == 1) {
// get the index of the stake update for the operator at the given blocknumber and quorum number
checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex][numNonSignersForQuorum]
= stakeRegistry.getStakeUpdateIndexAtBlockNumber(
nonSignerOperatorIds[i],
uint8(quorumNumbers[quorumNumberIndex]),
referenceBlockNumber
);
checkSignaturesIndices.nonSignerStakeIndices[
quorumNumberIndex
][
numNonSignersForQuorum
] =
stakeRegistry.getStakeUpdateIndexAtBlockNumber(
nonSignerOperatorIds[i],
uint8(quorumNumbers[quorumNumberIndex]),
referenceBlockNumber
);
numNonSignersForQuorum++;
}
}
Expand All @@ -167,7 +173,7 @@ contract OperatorStateRetriever {
checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex][i];
}
checkSignaturesIndices.nonSignerStakeIndices[quorumNumberIndex] =
nonSignerStakeIndicesForQuorum;
nonSignerStakeIndicesForQuorum;
}

IBLSApkRegistry blsApkRegistry = registryCoordinator.blsApkRegistry();
Expand Down
3 changes: 2 additions & 1 deletion src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVe
import {SemVerMixin} from "eigenlayer-contracts/src/contracts/mixins/SemVerMixin.sol";
import {IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol";
import {
IRegistryCoordinator, IRegistryCoordinatorTypes
IRegistryCoordinator,
IRegistryCoordinatorTypes
} from "./interfaces/IRegistryCoordinator.sol";

import {BitmapUtils} from "./libraries/BitmapUtils.sol";
Expand Down
1 change: 0 additions & 1 deletion src/RegistryCoordinatorStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ abstract contract RegistryCoordinatorStorage is IRegistryCoordinator {
* CONSTANTS AND IMMUTABLES
*
*/

/// @notice the ServiceManager for this AVS, which forwards calls onto EigenLayer's core contracts
IServiceManager public immutable serviceManager;

Expand Down
63 changes: 30 additions & 33 deletions src/ServiceManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ pragma solidity ^0.8.27;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ISignatureUtilsMixinTypes} from
"eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol";
import {
ISignatureUtilsMixinTypes
} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol";
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import {IRewardsCoordinator} from
"eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {
IRewardsCoordinator
} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {
IAllocationManager,
IAllocationManagerTypes
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {IPermissionController} from
"eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";
import {
IPermissionController
} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";

import {ServiceManagerBaseStorage} from "./ServiceManagerBaseStorage.sol";
import {IServiceManager} from "./interfaces/IServiceManager.sol";
Expand Down Expand Up @@ -94,12 +97,13 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
}

/// @inheritdoc IServiceManager
function setAppointee(address appointee, address target, bytes4 selector) external onlyOwner {
function setAppointee(
address appointee,
address target,
bytes4 selector
) external onlyOwner {
_permissionController.setAppointee({
account: address(this),
appointee: appointee,
target: target,
selector: selector
account: address(this), appointee: appointee, target: target, selector: selector
});
}

Expand All @@ -110,10 +114,7 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
bytes4 selector
) external onlyOwner {
_permissionController.removeAppointee({
account: address(this),
appointee: appointee,
target: target,
selector: selector
account: address(this), appointee: appointee, target: target, selector: selector
});
}

Expand Down Expand Up @@ -147,12 +148,10 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
for (uint256 i = 0; i < rewardsSubmissions.length; ++i) {
// transfer token to ServiceManager and approve RewardsCoordinator to transfer again
// in createAVSRewardsSubmission() call
rewardsSubmissions[i].token.safeTransferFrom(
msg.sender, address(this), rewardsSubmissions[i].amount
);
rewardsSubmissions[i].token.safeIncreaseAllowance(
address(_rewardsCoordinator), rewardsSubmissions[i].amount
);
rewardsSubmissions[i].token
.safeTransferFrom(msg.sender, address(this), rewardsSubmissions[i].amount);
rewardsSubmissions[i].token
.safeIncreaseAllowance(address(_rewardsCoordinator), rewardsSubmissions[i].amount);
}

_rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions);
Expand All @@ -173,26 +172,26 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
* smaller array of submissions if necessary.
*/
function createOperatorDirectedAVSRewardsSubmission(
IRewardsCoordinator.OperatorDirectedRewardsSubmission[] calldata
operatorDirectedRewardsSubmissions
IRewardsCoordinator
.OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
) public virtual onlyRewardsInitiator {
for (uint256 i = 0; i < operatorDirectedRewardsSubmissions.length; ++i) {
// Calculate total amount of token to transfer
uint256 totalAmount = 0;
for (
uint256 j = 0; j < operatorDirectedRewardsSubmissions[i].operatorRewards.length; ++j
uint256 j = 0;
j < operatorDirectedRewardsSubmissions[i].operatorRewards.length;
++j
) {
totalAmount += operatorDirectedRewardsSubmissions[i].operatorRewards[j].amount;
}

// Transfer token to ServiceManager and approve RewardsCoordinator to transfer again
// in createOperatorDirectedAVSRewardsSubmission() call
operatorDirectedRewardsSubmissions[i].token.safeTransferFrom(
msg.sender, address(this), totalAmount
);
operatorDirectedRewardsSubmissions[i].token.safeIncreaseAllowance(
address(_rewardsCoordinator), totalAmount
);
operatorDirectedRewardsSubmissions[i].token
.safeTransferFrom(msg.sender, address(this), totalAmount);
operatorDirectedRewardsSubmissions[i].token
.safeIncreaseAllowance(address(_rewardsCoordinator), totalAmount);
}

_rewardsCoordinator.createOperatorDirectedAVSRewardsSubmission(
Expand Down Expand Up @@ -238,9 +237,7 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
uint32[] memory operatorSetIds
) public virtual onlyRegistryCoordinator {
IAllocationManager.DeregisterParams memory params = IAllocationManagerTypes.DeregisterParams({
operator: operator,
avs: address(this),
operatorSetIds: operatorSetIds
operator: operator, avs: address(this), operatorSetIds: operatorSetIds
});
_allocationManager.deregisterFromOperatorSets(params);
}
Expand Down
20 changes: 12 additions & 8 deletions src/ServiceManagerBaseStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordi
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";

import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import {IAllocationManager} from
"eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {IRewardsCoordinator} from
"eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {IAllocationManager} from
"eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {IPermissionController} from
"eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";
import {
IAllocationManager
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {
IRewardsCoordinator
} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
import {
IAllocationManager
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
import {
IPermissionController
} from "eigenlayer-contracts/src/contracts/interfaces/IPermissionController.sol";

/**
* @title Storage variables for the `ServiceManagerBase` contract.
Expand Down
Loading
Loading