From f737489d4d52a4f582965fbfa3fccad8be278384 Mon Sep 17 00:00:00 2001 From: -f Date: Thu, 25 Apr 2024 10:29:52 +0530 Subject: [PATCH] remove challengers --- .../contracts/avs/HyperlaneServiceManager.sol | 17 +++++++++++++++++ .../contracts/libs/EnumerableMapEnrollment.sol | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/solidity/contracts/avs/HyperlaneServiceManager.sol b/solidity/contracts/avs/HyperlaneServiceManager.sol index b9ecdf8879..e205f7c6b4 100644 --- a/solidity/contracts/avs/HyperlaneServiceManager.sol +++ b/solidity/contracts/avs/HyperlaneServiceManager.sol @@ -46,6 +46,23 @@ contract HyperlaneServiceManager is ECDSAServiceManagerBase { function deregisterOperatorFromAVS( address operator ) public virtual override onlyStakeRegistry { + address[] memory challengers = enrolledChallengers[operator].keys(); + for (uint256 i = 0; i < challengers.length; i++) { + IRemoteChallenger challenger = IRemoteChallenger(challengers[i]); + Enrollment memory enrollment = enrolledChallengers[operator].get( + challengers[i] + ); + require( + enrollment.status != EnrollmentStatus.ENROLLED, + string( + abi.encodePacked( + "HyperlaneServiceManager: Operator still enrolled in challenger", + challengers[i] + ) + ) + ); + enrolledChallengers[operator].remove(challengers[i]); + } elAvsDirectory.deregisterOperatorFromAVS(operator); } diff --git a/solidity/contracts/libs/EnumerableMapEnrollment.sol b/solidity/contracts/libs/EnumerableMapEnrollment.sol index 99cb4396e6..f87c27b5ed 100644 --- a/solidity/contracts/libs/EnumerableMapEnrollment.sol +++ b/solidity/contracts/libs/EnumerableMapEnrollment.sol @@ -9,8 +9,7 @@ import {TypeCasts} from "./TypeCasts.sol"; enum EnrollmentStatus { ENROLLED, - PENDING_UNENROLLMENT, - UNENROLLED + PENDING_UNENROLLMENT } struct Enrollment {