Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add operator weigths to attestation event emission #5

Merged
merged 2 commits into from
Jun 16, 2024
Merged
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
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