@@ -12,6 +12,12 @@ import {IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol";
12
12
import {QuorumBitmapHistoryLib} from "../../src/libraries/QuorumBitmapHistoryLib.sol " ;
13
13
import {BitmapUtils} from "../../src/libraries/BitmapUtils.sol " ;
14
14
import {console} from "forge-std/console.sol " ;
15
+ import {
16
+ OperatorWalletLib,
17
+ SigningKeyOperationsLib,
18
+ OperatorKeyOperationsLib,
19
+ Operator
20
+ } from "../utils/OperatorWalletLib.sol " ;
15
21
16
22
contract RegistryCoordinatorUnitTests is MockAVSDeployer {
17
23
using BN254 for BN254.G1Point;
@@ -2418,52 +2424,68 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT
2418
2424
assertTrue (registryCoordinator.operatorSetsEnabled ());
2419
2425
}
2420
2426
2427
+ ///
2421
2428
function test_M2_Deregister () public {
2422
- vm.skip (true );
2423
- /// Create 2 M2 quorums
2424
2429
_deployMockEigenLayerAndAVS (2 );
2425
2430
2426
- address operatorToRegister = address ( 420 );
2431
+ Operator memory operatorToRegister = OperatorWalletLib. createOperator ( " 4 " );
2427
2432
2428
- ISignatureUtils.SignatureWithSaltAndExpiry memory emptySignature = ISignatureUtils
2429
- .SignatureWithSaltAndExpiry ({signature: new bytes (0 ), salt: bytes32 (0 ), expiry: 0 });
2433
+ /// NOTE: resolves stack too deep
2434
+ {
2435
+ // Set operator shares for quorum 0
2436
+ (IStrategy strategy ,) = stakeRegistry.strategyParams (0 , 0 );
2437
+ delegationMock.setOperatorShares (operatorToRegister.key.addr, strategy, 1 ether);
2438
+ }
2439
+ bytes32 salt = bytes32 (uint256 (1 ));
2440
+ uint256 expiry = block .timestamp + 1 days ;
2441
+ bytes32 digestHash = avsDirectory.calculateOperatorAVSRegistrationDigestHash (
2442
+ operatorToRegister.key.addr, address (registryCoordinator), salt, expiry
2443
+ );
2444
+ bytes memory signature = OperatorKeyOperationsLib.sign (operatorToRegister.key, digestHash);
2445
+ ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature = ISignatureUtils
2446
+ .SignatureWithSaltAndExpiry ({signature: signature, salt: salt, expiry: expiry});
2430
2447
2448
+ bytes32 messageHash =
2449
+ registryCoordinator.calculatePubkeyRegistrationMessageHash (operatorToRegister.key.addr);
2431
2450
IBLSApkRegistryTypes.PubkeyRegistrationParams memory operatorRegisterApkParams =
2432
2451
IBLSApkRegistryTypes.PubkeyRegistrationParams ({
2433
- pubkeyRegistrationSignature: BN254.G1Point ({X: 0 , Y: 0 }),
2434
- pubkeyG1: BN254.G1Point ({X: 0 , Y: 0 }),
2435
- pubkeyG2: BN254.G2Point ({X: [uint256 (0 ), uint256 (0 )], Y: [uint256 (0 ), uint256 (0 )]})
2452
+ pubkeyRegistrationSignature: SigningKeyOperationsLib.sign (
2453
+ operatorToRegister.signingKey, messageHash
2454
+ ),
2455
+ pubkeyG1: operatorToRegister.signingKey.publicKeyG1,
2456
+ pubkeyG2: operatorToRegister.signingKey.publicKeyG2
2436
2457
});
2437
2458
2438
2459
string memory socket = "socket " ;
2439
2460
2440
2461
// register for quorum 0
2441
- vm.prank (operatorToRegister);
2462
+ vm.prank (operatorToRegister.key.addr );
2442
2463
registryCoordinator.registerOperator (
2443
2464
new bytes (1 ), // Convert 0 to bytes1 first
2444
2465
socket,
2445
2466
operatorRegisterApkParams,
2446
- emptySignature
2467
+ operatorSignature
2447
2468
);
2448
2469
2449
2470
/// migrate to operator sets
2471
+ vm.prank (registryCoordinatorOwner);
2450
2472
registryCoordinator.enableOperatorSets ();
2451
2473
2452
2474
/// Deregistration for m2 should for the first two operator sets
2453
- vm.prank (defaultOperator );
2475
+ vm.prank (operatorToRegister.key.addr );
2454
2476
registryCoordinator.deregisterOperator (new bytes (1 ));
2455
2477
2456
2478
// Verify operator was deregistered by checking their bitmap is empty
2457
- bytes32 operatorId = registryCoordinator.getOperatorId (operatorToRegister);
2479
+ bytes32 operatorId = registryCoordinator.getOperatorId (operatorToRegister.key.addr );
2458
2480
uint192 bitmap = registryCoordinator.getCurrentQuorumBitmap (operatorId);
2459
2481
assertEq (bitmap, 0 , "Operator bitmap should be empty after deregistration " );
2460
2482
2461
2483
// Verify operator status is NEVER_REGISTERED
2462
2484
ISlashingRegistryCoordinatorTypes.OperatorStatus status =
2463
- registryCoordinator.getOperatorStatus (operatorToRegister);
2485
+ registryCoordinator.getOperatorStatus (operatorToRegister.key.addr );
2464
2486
assertEq (
2465
2487
uint8 (status),
2466
- uint8 (ISlashingRegistryCoordinatorTypes.OperatorStatus.NEVER_REGISTERED ),
2488
+ uint8 (ISlashingRegistryCoordinatorTypes.OperatorStatus.DEREGISTERED ),
2467
2489
"Operator status should be NEVER_REGISTERED "
2468
2490
);
2469
2491
}
0 commit comments