From a1c654cdeef3b040cf3f61940c5e7540468a138f Mon Sep 17 00:00:00 2001 From: idatsy Date: Sun, 16 Jun 2024 20:27:12 +0100 Subject: [PATCH 1/2] stash reference to eigenlayer slashing implementation --- src/EigenLayerBridge.sol | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/EigenLayerBridge.sol b/src/EigenLayerBridge.sol index e2d981f..b345693 100644 --- a/src/EigenLayerBridge.sol +++ b/src/EigenLayerBridge.sol @@ -93,6 +93,65 @@ contract BridgeServiceManager is ECDSAServiceManagerBase, Vault { function slashMaliciousAttestor(address operator, uint256 penalty) internal { // TODO: Implement slashing logic pending clarity on Eigen implementations + // @dev the below code is commented out for the upcoming M2 release + // in which there will be no slashing. The slasher is also being redesigned + // so its interface may very well change. + // ========================================== + // // get the list of all operators who were active when the task was initialized + // Operator[][] memory allOperatorInfo = getOperatorState( + // IRegistryCoordinator(address(registryCoordinator)), + // task.quorumNumbers, + // task.taskCreatedBlock + // ); + // // freeze the operators who signed adversarially + // for (uint i = 0; i < allOperatorInfo.length; i++) { + // // first for loop iterate over quorums + + // for (uint j = 0; j < allOperatorInfo[i].length; j++) { + // // second for loop iterate over operators active in the quorum when the task was initialized + + // // get the operator address + // bytes32 operatorID = allOperatorInfo[i][j].operatorId; + // address operatorAddress = BLSPubkeyRegistry( + // address(blsPubkeyRegistry) + // ).pubkeyCompendium().pubkeyHashToOperator(operatorID); + + // // check if the operator has already NOT been frozen + // if ( + // IServiceManager( + // address( + // BLSRegistryCoordinatorWithIndices( + // address(registryCoordinator) + // ).serviceManager() + // ) + // ).slasher().isFrozen(operatorAddress) == false + // ) { + // // check whether the operator was a signer for the task + // bool wasSigningOperator = true; + // for ( + // uint k = 0; + // k < addresssOfNonSigningOperators.length; + // k++ + // ) { + // if ( + // operatorAddress == addresssOfNonSigningOperators[k] + // ) { + // // if the operator was a non-signer, then we set the flag to false + // wasSigningOperator == false; + // break; + // } + // } + + // if (wasSigningOperator == true) { + // BLSRegistryCoordinatorWithIndices( + // address(registryCoordinator) + // ).serviceManager().freezeOperator(operatorAddress); + // } + // } + // } + // } + + // the task response has been challenged successfully } function challengeAttestation( From 0c2ba54d71f55c0a907e32b18130aac6d054534c Mon Sep 17 00:00:00 2001 From: idatsy Date: Sun, 16 Jun 2024 20:38:26 +0100 Subject: [PATCH 2/2] added weight to attestation event for easier querying and indexing --- src/EigenLayerBridge.sol | 5 +++-- src/Events.sol | 3 ++- src/PermissionedBridge.sol | 5 +++-- test/PermissionedBridge.t.sol | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/EigenLayerBridge.sol b/src/EigenLayerBridge.sol index b345693..ef3f498 100644 --- a/src/EigenLayerBridge.sol +++ b/src/EigenLayerBridge.sol @@ -84,11 +84,12 @@ contract BridgeServiceManager is ECDSAServiceManagerBase, Vault { // Increment the total weights attested for this bridge request. // Helpful for determining when enough attestations have been collected to release funds. - bridgeRequestWeights[_bridgeRequestId] += getOperatorWeight(msg.sender); + uint256 operatorWeight = getOperatorWeight(msg.sender); + bridgeRequestWeights[_bridgeRequestId] += operatorWeight; rewardAttestation(msg.sender); - emit AVSAttestation(attestation, _bridgeRequestId); + emit AVSAttestation(attestation, _bridgeRequestId, operatorWeight); } function slashMaliciousAttestor(address operator, uint256 penalty) internal { diff --git a/src/Events.sol b/src/Events.sol index c28f4f5..aba2518 100644 --- a/src/Events.sol +++ b/src/Events.sol @@ -15,7 +15,8 @@ contract Events { event AVSAttestation( bytes indexed attestation, - uint256 indexed bridgeRequestId + uint256 indexed bridgeRequestId, + uint256 indexed operatorWeight ); event FundsReleased( diff --git a/src/PermissionedBridge.sol b/src/PermissionedBridge.sol index a5ba7b7..c7578de 100644 --- a/src/PermissionedBridge.sol +++ b/src/PermissionedBridge.sol @@ -55,9 +55,10 @@ contract PermissionedBridge is Vault { // Increment the total weights attested for this bridge request. // Helpful for determining when enough attestations have been collected to release funds. - bridgeRequestWeights[_bridgeRequestId] += getOperatorWeight(msg.sender); + uint256 operatorWeight = getOperatorWeight(msg.sender); + bridgeRequestWeights[_bridgeRequestId] += operatorWeight; - emit AVSAttestation(attestation, _bridgeRequestId); + emit AVSAttestation(attestation, _bridgeRequestId, operatorWeight); } /// @notice Release funds to the destination address diff --git a/test/PermissionedBridge.t.sol b/test/PermissionedBridge.t.sol index 71d6090..7e8f71d 100644 --- a/test/PermissionedBridge.t.sol +++ b/test/PermissionedBridge.t.sol @@ -107,7 +107,7 @@ contract PermissionedBridgeTest is Test, EIP712("PermissionedBridge", "1") { vm.prank(operator); vm.expectEmit(true, true, true, true); - emit Events.AVSAttestation(attestation, 0); + emit Events.AVSAttestation(attestation, 0, 1000 ether); localVault.publishAttestation(attestation, 0); }