Skip to content

Commit

Permalink
add operator weigths to attestation event emission (#5)
Browse files Browse the repository at this point in the history
* stash reference to eigenlayer slashing implementation

* added weight to attestation event for easier querying and indexing
  • Loading branch information
idatsy authored Jun 16, 2024
1 parent 0528cb1 commit c580a26
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
64 changes: 62 additions & 2 deletions src/EigenLayerBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,75 @@ 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 {
// 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(
Expand Down
3 changes: 2 additions & 1 deletion src/Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ contract Events {

event AVSAttestation(
bytes indexed attestation,
uint256 indexed bridgeRequestId
uint256 indexed bridgeRequestId,
uint256 indexed operatorWeight
);

event FundsReleased(
Expand Down
5 changes: 3 additions & 2 deletions src/PermissionedBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/PermissionedBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c580a26

Please sign in to comment.