diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 953c2e95..e6976e54 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,7 @@ on: branches: - master - m2-mainnet + - m2-mainnet-fixes pull_request: env: diff --git a/.gitmodules b/.gitmodules index 63102e3d..437f5ba9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ [submodule "lib/eigenlayer-contracts"] path = lib/eigenlayer-contracts url = https://github.com/Layr-labs/eigenlayer-contracts - branch = m2-mainnet + branch = m2-mainnet-fixes [submodule "lib/ds-test"] path = lib/ds-test url = https://github.com/dapphub/ds-test diff --git a/.husky/commit-msg b/.husky/commit-msg old mode 100644 new mode 100755 diff --git a/README.md b/README.md index 6324fa06..354027d7 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,12 @@ EigenLayer is a set of smart contracts deployed on Ethereum that enable restaking of assets to secure new services called AVSs (actively validated services). The core contracts that enable these features can be found in the [`eigenlayer-contracts` repo][core-repo]. -This repo contains smart contracts used to create an AVS that interacts with the EigenLayer core contracts. +This repo contains smart contracts used to create an AVS that interacts with the EigenLayer core contracts. Because these contracts are meant to be used by any AVS, there is no single deployment. However, you can see EigenDA's deployment info on our [docs site](https://docs.eigenlayer.xyz/eigenda/deployed-contracts). ## Getting Started * [Documentation](#documentation) * [Building and Running Tests](#building-and-running-tests) -* [Deployments](#deployments) ## Documentation @@ -39,28 +38,4 @@ foundryup forge build forge test -``` - -## Deployments - -The contracts in this repo are meant to be deployed by each AVS that wants to use them. The addresses listed below refer to EigenDA's deployment, and are included as an example. - -### Current Mainnet Deployment - -No contracts have been deployed to mainnet yet. - -### Current Testnet Deployment - -The current testnet deployment is from our M2 beta release, which is a slightly older version of this repo. You can view the deployed contract addresses below, or check out the [`v0.1.0`](https://github.com/Layr-Labs/eigenlayer-middleware/tree/v0.1.0-m2-goerli) branch in "Releases". - - -| Name | Solidity | Proxy | Implementation | Notes | -| -------- | -------- | -------- | -------- | -------- | -| RegistryCoordinator | [`BLSRegistryCoordinatorWithIndices.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/BLSRegistryCoordinatorWithIndices.sol) | [`0x0b30...4C0B`](https://goerli.etherscan.io/address/0x0b30a3427765f136754368a4500bAca8d2a54C0B) | [`0x9A70...a0e4`](https://goerli.etherscan.io/address/0x9A70ED111FaFEC41856202536AFAA38841a9a0e4) | Proxy: [OpenZeppelin TUP@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) | -| StakeRegistry | [`StakeRegistry.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/StakeRegistry.sol) | [`0x5a83...A206`](https://goerli.etherscan.io/address/0x5a834d58D22742503D8f92dd2f28c866C166A206) | [`0x8741...5B98`](https://goerli.etherscan.io/address/0x8741e3a24d9517Aa19E63122A34680a9A85F5B98) | Proxy: [OpenZeppelin TUP@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) | -| IndexRegistry | [`IndexRegistry.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/IndexRegistry.sol) | [`0xa8A1...BDF7`](https://goerli.etherscan.io/address/0xa8A14B97d556cEc3f4384C186fB99d72F015BDF7) | [`0x8cd4...8117`](https://goerli.etherscan.io/address/0x8cd4c39B713B026319e35f20B7f19baE28648117) | Proxy: [OpenZeppelin TUP@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) | -| BLSApkRegistry | [`BLSPubkeyRegistry.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/BLSPubkeyRegistry.sol) | [`0xD8fC...BEcA`](https://goerli.etherscan.io/address/0xD8fCD5c9103962DE37E375EF9dB62cCf39D5BEcA) | [`0x4C9D...aFb8`](https://goerli.etherscan.io/address/0x4C9D23fd901d3d98e75BdcC6a8AC9bA81d8DaFb8) | Proxy: [OpenZeppelin TUP@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) | -| BLSPubkeyCompendium
(deprecated) | [`BLSPublicKeyCompendium.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/BLSPublicKeyCompendium.sol) | - | [`0xc81d...1b19`](https://goerli.etherscan.io/address/0xc81d3963087fe09316cd1e032457989c7ac91b19) | | -| OperatorStateRetriever | [`BLSOperatorStateRetriever.sol`](https://github.com/Layr-Labs/eigenlayer-middleware/blob/v0.1.0-m2-goerli/src/BLSOperatorStateRetriever.sol) | - | [`0x737d...a3a3`](https://goerli.etherscan.io/address/0x737dd62816a9392e84fa21c531af77c00816a3a3) | | -| ProxyAdmin | [OpenZeppelin ProxyAdmin@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/ProxyAdmin.sol) | - | [`0xbe85...aF3e`](https://goerli.etherscan.io/address/0xbe85B38b6086A45350947DD6dA6d78cc2E4BaF3e) | | -| EigenDAServiceManager | [`eigenda/EigenDAServiceManager.sol`](https://github.com/Layr-Labs/eigenda/blob/f599513723a17ad7bd5693287f75325007deec19/contracts/EigenDAServiceManager.sol#L4831) | [`0x9FcE...0010`](https://goerli.etherscan.io/address/0x9FcE30E01a740660189bD8CbEaA48Abd36040010) | [`0x1261...9606`](https://goerli.etherscan.io/address/0x12612f42bc1f09680c3d0c8dae72d5cd534c9606) | Proxy: [OpenZeppelin TUP@4.7.1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.1/contracts/proxy/transparent/TransparentUpgradeableProxy.sol) | \ No newline at end of file +``` \ No newline at end of file diff --git a/docs/BLSSignatureChecker.md b/docs/BLSSignatureChecker.md index 31e8d09e..afffedbc 100644 --- a/docs/BLSSignatureChecker.md +++ b/docs/BLSSignatureChecker.md @@ -62,6 +62,7 @@ struct QuorumStakeTotals { The goal of this method is to allow an AVS to validate a BLS signature formed from the aggregate pubkey ("apk") of Operators registered in one or more quorums at some `referenceBlockNumber`. Some notes on method parameters: +* `msgHash` is the hash being signed by the apk. Note that the caller is responsible for ensuring `msgHash` is a hash! If someone can provide arbitrary input, it may be possible to tamper with signature verification. * `referenceBlockNumber` is the reason each registry contract keeps historical states: so that lookups can be performed on each registry's info at a particular block. This is important because Operators may sign some data on behalf of an AVS, then deregister from one or more of the AVS's quorums. Historical states allow signature validation to be performed against a "fixed point" in AVS/quorum history. * `quorumNumbers` is used to perform signature validation across one *or more* quorums. Also, Operators may be registered for more than one quorum - and for each quorum an Operator is registered for, that Operator's pubkey is included in that quorum's apk within the `BLSApkRegistry`. This means that, when calculating an apk across multiple `quorumNumbers`, Operators registered for more than one of these quorums will have their pubkey included more than once in the total apk. * `params` contains both a signature from all signing Operators, as well as several fields that identify registered, non-signing Operators. While non-signing Operators haven't contributed to the signature, but need to be accounted for because, as Operators registered for one or more signing quorums, their public keys are included in that quorum's apk. Essentially, in order to validate the signature, nonsigners' public keys need to be subtracted out from the total apk to derive the apk that actually signed the message. @@ -87,11 +88,11 @@ This method performs the following steps. Note that each step involves lookups o * Input validation: * Quorum-related fields MUST have equal lengths: `quorumNumbers`, `params.quorumApks`, `params.quorumApkIndices`, `params.totalStakeIndices`, `params.nonSignerStakeIndices` * Nonsigner-related fields MUST have equal lengths: `params.nonSignerPubkeys`, `params.nonSignerQuorumBitmapIndices` - * `referenceBlockNumber` MUST NOT be greater than `block.number` + * `referenceBlockNumber` MUST be less than `block.number` * `quorumNumbers` MUST be an ordered list of valid, initialized quorums * `params.nonSignerPubkeys` MUST ONLY contain unique pubkeys, in ascending order of their pubkey hash * For each quorum: - * If stale stakes are forbidden (see [`BLSSignatureChecker.setStaleStakesForbidden`](#blssignaturecheckersetstalestakesforbidden)), check the last `quorumUpdateBlockNumber` is within `DelegationManager.withdrawalDelayBlocks` of `referenceBlockNumber`. This references a value in the EigenLayer core contracts - see [EigenLayer core docs][core-docs-m2] for more info. + * If stale stakes are forbidden (see [`BLSSignatureChecker.setStaleStakesForbidden`](#blssignaturecheckersetstalestakesforbidden)), check the last `quorumUpdateBlockNumber` is within `DelegationManager.minWithdrawalDelayBlocks` of `referenceBlockNumber`. This references a value in the EigenLayer core contracts - see [EigenLayer core docs][core-docs-m2] for more info. * Validate that each `params.quorumApks` corresponds to the quorum's apk at the `referenceBlockNumber` * For each historical state lookup, the `referenceBlockNumber` and provided index MUST point to a valid historical entry: * `referenceBlockNumber` MUST come after the entry's `updateBlockNumber` diff --git a/docs/README.md b/docs/README.md index 919e1dcf..297147d7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -97,8 +97,8 @@ These histories are used by offchain code to query state at particular blocks, a ##### Hooking Into EigenLayer Core The main thing that links an AVS to the EigenLayer core contracts is that when EigenLayer Operators register/deregister with an AVS, the AVS calls these functions in EigenLayer core: -* [`DelegationManager.registerOperatorToAVS`][core-registerToAVS] -* [`DelegationManager.deregisterOperatorFromAVS`][core-deregisterFromAVS] +* [`AVSDirectory.registerOperatorToAVS`][core-registerToAVS] +* [`AVSDirectory.deregisterOperatorFromAVS`][core-deregisterFromAVS] These methods ensure that the Operator registering with the AVS is also registered as an Operator in EigenLayer core. In this repo, these methods are called by the `ServiceManagerBase`. diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index aa8b38fc..75115593 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit aa8b38fce32534dfa9feb485d17b1f832de22bd3 +Subproject commit 751155931cfb6b5ebcb77ef3cb12dff041329cbc diff --git a/src/BLSApkRegistry.sol b/src/BLSApkRegistry.sol index d6c892e8..9d145ddd 100644 --- a/src/BLSApkRegistry.sol +++ b/src/BLSApkRegistry.sol @@ -205,19 +205,19 @@ contract BLSApkRegistry is BLSApkRegistryStorage { uint256 blockNumber ) external view returns (uint32[] memory) { uint32[] memory indices = new uint32[](quorumNumbers.length); - for (uint i = 0; i < quorumNumbers.length; i++) { + + for (uint256 i = 0; i < quorumNumbers.length; i++) { uint8 quorumNumber = uint8(quorumNumbers[i]); - uint32 quorumApkUpdatesLength = uint32(apkHistory[quorumNumber].length); - + + uint256 quorumApkUpdatesLength = apkHistory[quorumNumber].length; if (quorumApkUpdatesLength == 0 || blockNumber < apkHistory[quorumNumber][0].updateBlockNumber) { - revert( - "BLSApkRegistry.getApkIndicesAtBlockNumber: blockNumber is before the first update" - ); + revert("BLSApkRegistry.getApkIndicesAtBlockNumber: blockNumber is before the first update"); } - for (uint32 j = 0; j < quorumApkUpdatesLength; j++) { - if (apkHistory[quorumNumber][quorumApkUpdatesLength - j - 1].updateBlockNumber <= blockNumber) { - indices[i] = quorumApkUpdatesLength - j - 1; + // Loop backward through apkHistory until we find an entry that preceeds `blockNumber` + for (uint256 j = quorumApkUpdatesLength; j > 0; j--) { + if (apkHistory[quorumNumber][j - 1].updateBlockNumber <= blockNumber) { + indices[i] = uint32(j - 1); break; } } diff --git a/src/BLSSignatureChecker.sol b/src/BLSSignatureChecker.sol index 0f287825..39391e15 100644 --- a/src/BLSSignatureChecker.sol +++ b/src/BLSSignatureChecker.sol @@ -46,7 +46,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker { /** * RegistryCoordinator owner can either enforce or not that operator stakes are staler - * than the delegation.withdrawalDelayBlocks() window. + * than the delegation.minWithdrawalDelayBlocks() window. * @param value to toggle staleStakesForbidden */ function setStaleStakesForbidden(bool value) external onlyCoordinatorOwner { @@ -75,6 +75,9 @@ contract BLSSignatureChecker is IBLSSignatureChecker { * is correct, i.e., ensure that the stake returned from the specified block number is recent enough and that the stake is either the most recent update * for the total stake (of the operator) or latest before the referenceBlockNumber. * @param msgHash is the hash being signed + * @dev NOTE: Be careful to ensure `msgHash` is collision-resistant! This method does not hash + * `msgHash` in any way, so if an attacker is able to pass in an arbitrary value, they may be able + * to tamper with signature verification. * @param quorumNumbers is the bytes array of quorum numbers that are being signed for * @param referenceBlockNumber is the block number at which the stake information is being verified * @param params is the struct containing information on nonsigners, stakes, quorum apks, and the aggregate signature @@ -109,7 +112,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker { "BLSSignatureChecker.checkSignatures: input nonsigner length mismatch" ); - require(referenceBlockNumber <= uint32(block.number), "BLSSignatureChecker.checkSignatures: invalid reference block"); + require(referenceBlockNumber < uint32(block.number), "BLSSignatureChecker.checkSignatures: invalid reference block"); // This method needs to calculate the aggregate pubkey for all signing operators across // all signing quorums. To do that, we can query the aggregate pubkey for each quorum @@ -179,8 +182,8 @@ contract BLSSignatureChecker is IBLSSignatureChecker { * - subtract the stake for each nonsigner to calculate the stake belonging to signers */ { - uint256 withdrawalDelayBlocks = delegation.withdrawalDelayBlocks(); bool _staleStakesForbidden = staleStakesForbidden; + uint256 withdrawalDelayBlocks = _staleStakesForbidden ? delegation.minWithdrawalDelayBlocks() : 0; for (uint256 i = 0; i < quorumNumbers.length; i++) { // If we're disallowing stale stake updates, check that each quorum's last update block @@ -280,4 +283,8 @@ contract BLSSignatureChecker is IBLSSignatureChecker { PAIRING_EQUALITY_CHECK_GAS ); } + + // storage gap for upgradeability + // slither-disable-next-line shadowing-state + uint256[49] private __GAP; } diff --git a/src/IndexRegistry.sol b/src/IndexRegistry.sol index 5f71d6ab..66df5181 100644 --- a/src/IndexRegistry.sol +++ b/src/IndexRegistry.sol @@ -253,13 +253,11 @@ contract IndexRegistry is IndexRegistryStorage { uint32 blockNumber ) internal view returns (uint32){ uint256 historyLength = _operatorCountHistory[quorumNumber].length; - require(historyLength != 0, "IndexRegistry._operatorCountAtBlockNumber: quorum does not exist"); - // Loop backwards through the total operator history - for (uint256 i = 0; i < historyLength; i++) { - uint256 listIndex = (historyLength - 1) - i; - QuorumUpdate memory quorumUpdate = _operatorCountHistory[quorumNumber][listIndex]; - // Look for the first update that began before or at `blockNumber` + // Loop backwards through _operatorCountHistory until we find an entry that preceeds `blockNumber` + for (uint256 i = historyLength; i > 0; i--) { + QuorumUpdate memory quorumUpdate = _operatorCountHistory[quorumNumber][i - 1]; + if (quorumUpdate.fromBlockNumber <= blockNumber) { return quorumUpdate.numOperators; } @@ -278,18 +276,18 @@ contract IndexRegistry is IndexRegistryStorage { uint32 blockNumber ) internal view returns(bytes32) { uint256 historyLength = _operatorIndexHistory[quorumNumber][operatorIndex].length; - // Loop backward through operatorIndex history - for (uint256 i = 0; i < historyLength; i++) { - uint256 listIndex = (historyLength - 1) - i; - OperatorUpdate memory operatorIndexUpdate = _operatorIndexHistory[quorumNumber][operatorIndex][listIndex]; - // Look for the first update that began before or at `blockNumber` + + // Loop backward through _operatorIndexHistory until we find an entry that preceeds `blockNumber` + for (uint256 i = historyLength; i > 0; i--) { + OperatorUpdate memory operatorIndexUpdate = _operatorIndexHistory[quorumNumber][operatorIndex][i - 1]; + if (operatorIndexUpdate.fromBlockNumber <= blockNumber) { // Special case: this will be OPERATOR_DOES_NOT_EXIST_ID if this operatorIndex was not used at the block number return operatorIndexUpdate.operatorId; } } - // we should only it this if the operatorIndex was never used before blockNumber + // we should only hit this if the operatorIndex was never used before blockNumber return OPERATOR_DOES_NOT_EXIST_ID; } diff --git a/src/RegistryCoordinator.sol b/src/RegistryCoordinator.sol index 37fd7539..1d0031ea 100644 --- a/src/RegistryCoordinator.sol +++ b/src/RegistryCoordinator.sol @@ -195,6 +195,7 @@ contract RegistryCoordinator is // Verify the churn approver's signature for the registering operator and kick params _verifyChurnApproverSignature({ + registeringOperator: msg.sender, registeringOperatorId: operatorId, operatorKickParams: operatorKickParams, churnApproverSignature: churnApproverSignature @@ -285,14 +286,10 @@ contract RegistryCoordinator is bytes calldata quorumNumbers ) external onlyWhenNotPaused(PAUSED_UPDATE_OPERATOR) { // Input validation - // - all quorums should exist + // - all quorums should exist (checked against `quorumCount` in orderedBytesArrayToBitmap) // - there should be no duplicates in `quorumNumbers` // - there should be one list of operators per quorum uint192 quorumBitmap = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount)); - require( - _quorumsAllExist(quorumBitmap), - "RegistryCoordinator.updateOperatorsForQuorum: some quorums do not exist" - ); require( operatorsPerQuorum.length == quorumNumbers.length, "RegistryCoordinator.updateOperatorsForQuorum: input length mismatch" @@ -450,13 +447,13 @@ contract RegistryCoordinator is /** * Get bitmap of quorums to register for and operator's current bitmap. Validate that: * - we're trying to register for at least 1 quorum + * - the quorums we're registering for exist (checked against `quorumCount` in orderedBytesArrayToBitmap) * - the operator is not currently registered for any quorums we're registering for * Then, calculate the operator's new bitmap after registration */ uint192 quorumsToAdd = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount)); uint192 currentBitmap = _currentOperatorBitmap(operatorId); require(!quorumsToAdd.isEmpty(), "RegistryCoordinator._registerOperator: bitmap cannot be 0"); - require(_quorumsAllExist(quorumsToAdd), "RegistryCoordinator._registerOperator: some quorums do not exist"); require(quorumsToAdd.noBitsInCommon(currentBitmap), "RegistryCoordinator._registerOperator: operator already registered for some quorums being registered for"); uint192 newBitmap = uint192(currentBitmap.plus(quorumsToAdd)); @@ -573,13 +570,13 @@ contract RegistryCoordinator is /** * Get bitmap of quorums to deregister from and operator's current bitmap. Validate that: * - we're trying to deregister from at least 1 quorum + * - the quorums we're deregistering from exist (checked against `quorumCount` in orderedBytesArrayToBitmap) * - the operator is currently registered for any quorums we're trying to deregister from * Then, calculate the operator's new bitmap after deregistration */ uint192 quorumsToRemove = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount)); uint192 currentBitmap = _currentOperatorBitmap(operatorId); require(!quorumsToRemove.isEmpty(), "RegistryCoordinator._deregisterOperator: bitmap cannot be 0"); - require(_quorumsAllExist(quorumsToRemove), "RegistryCoordinator._deregisterOperator: some quorums do not exist"); require(quorumsToRemove.isSubsetOf(currentBitmap), "RegistryCoordinator._deregisterOperator: operator is not registered for specified quorums"); uint192 newBitmap = uint192(currentBitmap.minus(quorumsToRemove)); @@ -646,6 +643,7 @@ contract RegistryCoordinator is /// @notice verifies churnApprover's signature on operator churn approval and increments the churnApprover nonce function _verifyChurnApproverSignature( + address registeringOperator, bytes32 registeringOperatorId, OperatorKickParam[] memory operatorKickParams, SignatureWithSaltAndExpiry memory churnApproverSignature @@ -660,7 +658,7 @@ contract RegistryCoordinator is // check the churnApprover's signature EIP1271SignatureUtils.checkSignature_EIP1271( churnApprover, - calculateOperatorChurnApprovalDigestHash(registeringOperatorId, operatorKickParams, churnApproverSignature.salt, churnApproverSignature.expiry), + calculateOperatorChurnApprovalDigestHash(registeringOperator, registeringOperatorId, operatorKickParams, churnApproverSignature.salt, churnApproverSignature.expiry), churnApproverSignature.signature ); } @@ -729,14 +727,6 @@ contract RegistryCoordinator is } } - /** - * @notice Returns true iff all of the bits in `quorumBitmap` belong to initialized quorums - */ - function _quorumsAllExist(uint192 quorumBitmap) internal view returns (bool) { - uint192 initializedQuorumBitmap = uint192((1 << quorumCount) - 1); - return quorumBitmap.isSubsetOf(initializedQuorumBitmap); - } - /// @notice Get the most recent bitmap for the operator, returning an empty bitmap if /// the operator is not registered. function _currentOperatorBitmap(bytes32 operatorId) internal view returns (uint192) { @@ -889,19 +879,20 @@ contract RegistryCoordinator is /** * @notice Public function for the the churnApprover signature hash calculation when operators are being kicked from quorums - * @param registeringOperatorId The is of the registering operator + * @param registeringOperatorId The id of the registering operator * @param operatorKickParams The parameters needed to kick the operator from the quorums that have reached their caps * @param salt The salt to use for the churnApprover's signature * @param expiry The desired expiry time of the churnApprover's signature */ function calculateOperatorChurnApprovalDigestHash( + address registeringOperator, bytes32 registeringOperatorId, OperatorKickParam[] memory operatorKickParams, bytes32 salt, uint256 expiry ) public view returns (bytes32) { // calculate the digest hash - return _hashTypedDataV4(keccak256(abi.encode(OPERATOR_CHURN_APPROVAL_TYPEHASH, registeringOperatorId, operatorKickParams, salt, expiry))); + return _hashTypedDataV4(keccak256(abi.encode(OPERATOR_CHURN_APPROVAL_TYPEHASH, registeringOperator, registeringOperatorId, operatorKickParams, salt, expiry))); } /** diff --git a/src/RegistryCoordinatorStorage.sol b/src/RegistryCoordinatorStorage.sol index 7e276dc2..3d75c24c 100644 --- a/src/RegistryCoordinatorStorage.sol +++ b/src/RegistryCoordinatorStorage.sol @@ -15,7 +15,7 @@ abstract contract RegistryCoordinatorStorage is IRegistryCoordinator { /// @notice The EIP-712 typehash for the `DelegationApproval` struct used by the contract bytes32 public constant OPERATOR_CHURN_APPROVAL_TYPEHASH = - keccak256("OperatorChurnApproval(bytes32 registeringOperatorId,OperatorKickParam[] operatorKickParams)OperatorKickParam(address operator,bytes32[] operatorIdsToSwap)"); + keccak256("OperatorChurnApproval(address registeringOperator,bytes32 registeringOperatorId,OperatorKickParam[] operatorKickParams,bytes32 salt,uint256 expiry)OperatorKickParam(uint8 quorumNumber,address operator)"); /// @notice The EIP-712 typehash used for registering BLS public keys bytes32 public constant PUBKEY_REGISTRATION_TYPEHASH = keccak256("BN254PubkeyRegistration(address operator)"); /// @notice The maximum value of a quorum bitmap diff --git a/src/ServiceManagerBase.sol b/src/ServiceManagerBase.sol index 815decaf..1aa95db7 100644 --- a/src/ServiceManagerBase.sol +++ b/src/ServiceManagerBase.sol @@ -5,7 +5,7 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl import {BitmapUtils} from "./libraries/BitmapUtils.sol"; import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; -import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import {IServiceManager} from "./interfaces/IServiceManager.sol"; import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; @@ -13,15 +13,15 @@ import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; /** * @title Minimal implementation of a ServiceManager-type contract. - * This contract can inherited from or simply used as a point-of-reference. + * This contract can be inherited from or simply used as a point-of-reference. * @author Layr Labs, Inc. */ -contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { +abstract contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { using BitmapUtils for *; IRegistryCoordinator internal immutable _registryCoordinator; - IDelegationManager internal immutable _delegationManager; IStakeRegistry internal immutable _stakeRegistry; + IAVSDirectory internal immutable _avsDirectory; /// @notice when applied to a function, only allows the RegistryCoordinator to call it modifier onlyRegistryCoordinator() { @@ -34,17 +34,17 @@ contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { /// @notice Sets the (immutable) `_registryCoordinator` address constructor( - IDelegationManager __delegationManager, + IAVSDirectory __avsDirectory, IRegistryCoordinator __registryCoordinator, IStakeRegistry __stakeRegistry ) { - _delegationManager = __delegationManager; + _avsDirectory = __avsDirectory; _registryCoordinator = __registryCoordinator; _stakeRegistry = __stakeRegistry; _disableInitializers(); } - function initialize(address initialOwner) public virtual initializer { + function __ServiceManagerBase_init(address initialOwner) internal virtual onlyInitializing { _transferOwnership(initialOwner); } @@ -54,11 +54,11 @@ contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { * @dev only callable by the owner */ function setMetadataURI(string memory _metadataURI) public virtual onlyOwner { - _delegationManager.updateAVSMetadataURI(_metadataURI); + _avsDirectory.updateAVSMetadataURI(_metadataURI); } /** - * @notice Forwards a call to EigenLayer's DelegationManager contract to confirm operator registration with the AVS + * @notice Forwards a call to EigenLayer's AVSDirectory contract to confirm operator registration with the AVS * @param operator The address of the operator to register. * @param operatorSignature The signature, salt, and expiry of the operator's signature. */ @@ -66,15 +66,15 @@ contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature ) public virtual onlyRegistryCoordinator { - _delegationManager.registerOperatorToAVS(operator, operatorSignature); + _avsDirectory.registerOperatorToAVS(operator, operatorSignature); } /** - * @notice Forwards a call to EigenLayer's DelegationManager contract to confirm operator deregistration from the AVS + * @notice Forwards a call to EigenLayer's AVSDirectory contract to confirm operator deregistration from the AVS * @param operator The address of the operator to deregister. */ function deregisterOperatorFromAVS(address operator) public virtual onlyRegistryCoordinator { - _delegationManager.deregisterOperatorFromAVS(operator); + _avsDirectory.deregisterOperatorFromAVS(operator); } /** @@ -142,4 +142,13 @@ contract ServiceManagerBase is IServiceManager, OwnableUpgradeable { } return restakedStrategies; } + + /// @notice Returns the EigenLayer AVSDirectory contract. + function avsDirectory() external view override returns (address) { + return address(_avsDirectory); + } + + // storage gap for upgradeability + // slither-disable-next-line shadowing-state + uint256[50] private __GAP; } diff --git a/src/StakeRegistry.sol b/src/StakeRegistry.sol index b807194e..bc9df974 100644 --- a/src/StakeRegistry.sol +++ b/src/StakeRegistry.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.12; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {StakeRegistryStorage} from "./StakeRegistryStorage.sol"; +import {StakeRegistryStorage, IStrategy} from "./StakeRegistryStorage.sol"; import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; @@ -238,6 +238,7 @@ contract StakeRegistry is StakeRegistryStorage { require(toRemoveLength > 0, "StakeRegistry.removeStrategies: no indices to remove provided"); StrategyParams[] storage _strategyParams = strategyParams[quorumNumber]; + IStrategy[] storage _strategiesPerQuorum = strategiesPerQuorum[quorumNumber]; for (uint256 i = 0; i < toRemoveLength; i++) { emit StrategyRemovedFromQuorum(quorumNumber, _strategyParams[indicesToRemove[i]].strategy); @@ -246,11 +247,13 @@ contract StakeRegistry is StakeRegistryStorage { // Replace index to remove with the last item in the list, then pop the last item _strategyParams[indicesToRemove[i]] = _strategyParams[_strategyParams.length - 1]; _strategyParams.pop(); + _strategiesPerQuorum[indicesToRemove[i]] = _strategiesPerQuorum[_strategiesPerQuorum.length - 1]; + _strategiesPerQuorum.pop(); } } /** - * @notice Modifys the weights of existing strategies for a specific quorum + * @notice Modifies the weights of existing strategies for a specific quorum * @param quorumNumber is the quorum number to which the strategies belong * @param strategyIndices are the indices of the strategies to change * @param newMultipliers are the new multipliers for the strategies @@ -283,17 +286,15 @@ contract StakeRegistry is StakeRegistryStorage { uint32 blockNumber ) internal view returns (uint32) { uint256 length = operatorStakeHistory[operatorId][quorumNumber].length; - for (uint256 i = 0; i < length; i++) { - if (operatorStakeHistory[operatorId][quorumNumber][length - i - 1].updateBlockNumber <= blockNumber) { - uint32 nextUpdateBlockNumber = - operatorStakeHistory[operatorId][quorumNumber][length - i - 1].nextUpdateBlockNumber; - require( - nextUpdateBlockNumber == 0 || nextUpdateBlockNumber > blockNumber, - "StakeRegistry._getStakeUpdateIndexForOperatorAtBlockNumber: operatorId has no stake update at blockNumber" - ); - return uint32(length - i - 1); + + // Iterate backwards through operatorStakeHistory until we find an update that preceeds blockNumber + for (uint256 i = length; i > 0; i--) { + if (operatorStakeHistory[operatorId][quorumNumber][i - 1].updateBlockNumber <= blockNumber) { + return uint32(i - 1); } } + + // If we hit this point, no stake update exists at blockNumber revert( "StakeRegistry._getStakeUpdateIndexForOperatorAtBlockNumber: no stake update found for operatorId and quorumNumber at block number" ); @@ -391,7 +392,7 @@ contract StakeRegistry is StakeRegistryStorage { /** * @notice Adds `strategyParams` to the `quorumNumber`-th quorum. * @dev Checks to make sure that the *same* strategy cannot be added multiple times (checks against both against existing and new strategies). - * @dev This function has no check to make sure that the strategies for a single quorum have the same underlying asset. This is a concious choice, + * @dev This function has no check to make sure that the strategies for a single quorum have the same underlying asset. This is a conscious choice, * since a middleware may want, e.g., a stablecoin quorum that accepts USDC, USDT, DAI, etc. as underlying assets and trades them as "equivalent". */ function _addStrategyParams( @@ -418,6 +419,7 @@ contract StakeRegistry is StakeRegistryStorage { "StakeRegistry._addStrategyParams: cannot add strategy with zero weight" ); strategyParams[quorumNumber].push(_strategyParams[i]); + strategiesPerQuorum[quorumNumber].push(_strategyParams[i].strategy); emit StrategyAddedToQuorum(quorumNumber, _strategyParams[i].strategy); emit StrategyMultiplierUpdated( quorumNumber, @@ -441,23 +443,23 @@ contract StakeRegistry is StakeRegistryStorage { } } - /// @notice Validates that the `operatorStake` was accurate at the given `blockNumber` - function _validateOperatorStakeUpdateAtBlockNumber( - StakeUpdate memory operatorStakeUpdate, + /// @notice Checks that the `stakeUpdate` was valid at the given `blockNumber` + function _validateStakeUpdateAtBlockNumber( + StakeUpdate memory stakeUpdate, uint32 blockNumber ) internal pure { /** - * Validate that the update is valid for the given blockNumber: + * Check that the update is valid for the given blockNumber: * - blockNumber should be >= the update block number * - the next update block number should be either 0 or strictly greater than blockNumber */ require( - blockNumber >= operatorStakeUpdate.updateBlockNumber, - "StakeRegistry._validateOperatorStakeAtBlockNumber: operatorStakeUpdate is from after blockNumber" + blockNumber >= stakeUpdate.updateBlockNumber, + "StakeRegistry._validateStakeUpdateAtBlockNumber: stakeUpdate is from after blockNumber" ); require( - operatorStakeUpdate.nextUpdateBlockNumber == 0 || blockNumber < operatorStakeUpdate.nextUpdateBlockNumber, - "StakeRegistry._validateOperatorStakeAtBlockNumber: there is a newer operatorStakeUpdate available before blockNumber" + stakeUpdate.nextUpdateBlockNumber == 0 || blockNumber < stakeUpdate.nextUpdateBlockNumber, + "StakeRegistry._validateStakeUpdateAtBlockNumber: there is a newer stakeUpdate available before blockNumber" ); } @@ -472,16 +474,14 @@ contract StakeRegistry is StakeRegistryStorage { uint256 stratsLength = strategyParamsLength(quorumNumber); StrategyParams memory strategyAndMultiplier; + uint256[] memory strategyShares = delegation.getOperatorShares(operator, strategiesPerQuorum[quorumNumber]); for (uint256 i = 0; i < stratsLength; i++) { // accessing i^th StrategyParams struct for the quorumNumber strategyAndMultiplier = strategyParams[quorumNumber][i]; - // shares of the operator in the strategy - uint256 sharesAmount = delegation.operatorShares(operator, strategyAndMultiplier.strategy); - // add the weight from the shares for this strategy to the total weight - if (sharesAmount > 0) { - weight += uint96(sharesAmount * strategyAndMultiplier.multiplier / WEIGHTING_DIVISOR); + if (strategyShares[i] > 0) { + weight += uint96(strategyShares[i] * strategyAndMultiplier.multiplier / WEIGHTING_DIVISOR); } } @@ -631,7 +631,7 @@ contract StakeRegistry is StakeRegistryStorage { uint256 index ) external view returns (uint96) { StakeUpdate memory operatorStakeUpdate = operatorStakeHistory[operatorId][quorumNumber][index]; - _validateOperatorStakeUpdateAtBlockNumber(operatorStakeUpdate, blockNumber); + _validateStakeUpdateAtBlockNumber(operatorStakeUpdate, blockNumber); return operatorStakeUpdate.stake; } @@ -680,7 +680,7 @@ contract StakeRegistry is StakeRegistryStorage { uint256 index ) external view returns (uint96) { StakeUpdate memory totalStakeUpdate = _totalStakeHistory[quorumNumber][index]; - _validateOperatorStakeUpdateAtBlockNumber(totalStakeUpdate, blockNumber); + _validateStakeUpdateAtBlockNumber(totalStakeUpdate, blockNumber); return totalStakeUpdate.stake; } diff --git a/src/StakeRegistryStorage.sol b/src/StakeRegistryStorage.sol index 9209242b..9532d724 100644 --- a/src/StakeRegistryStorage.sol +++ b/src/StakeRegistryStorage.sol @@ -2,7 +2,7 @@ pragma solidity =0.8.12; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; +import {IStrategyManager, IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol"; import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; @@ -16,7 +16,7 @@ abstract contract StakeRegistryStorage is IStakeRegistry { /// @notice Constant used as a divisor in calculating weights. uint256 public constant WEIGHTING_DIVISOR = 1e18; - /// @notice Maximum length of dynamic arrays in the `strategiesConsideredAndMultipliers` mapping. + /// @notice Maximum length of dynamic arrays in the `strategyParams` mapping. uint8 public constant MAX_WEIGHING_FUNCTION_LENGTH = 32; /// @notice Constant used as a divisor in dealing with BIPS amounts. uint256 internal constant MAX_BIPS = 10000; @@ -42,6 +42,8 @@ abstract contract StakeRegistryStorage is IStakeRegistry { * corresponding multipliers for that specific quorum */ mapping(uint8 => StrategyParams[]) public strategyParams; + mapping(uint8 => IStrategy[]) public strategiesPerQuorum; + constructor( IRegistryCoordinator _registryCoordinator, @@ -53,5 +55,5 @@ abstract contract StakeRegistryStorage is IStakeRegistry { // storage gap for upgradeability // slither-disable-next-line shadowing-state - uint256[46] private __GAP; + uint256[45] private __GAP; } diff --git a/src/interfaces/IBLSApkRegistry.sol b/src/interfaces/IBLSApkRegistry.sol index bec2ac7f..f46ab4f2 100644 --- a/src/interfaces/IBLSApkRegistry.sol +++ b/src/interfaces/IBLSApkRegistry.sol @@ -6,7 +6,7 @@ import {IRegistry} from "./IRegistry.sol"; import {BN254} from "../libraries/BN254.sol"; /** - * @title Minimal interface for a registry that keeps track of aggregate operator public keys for among many quorums. + * @title Minimal interface for a registry that keeps track of aggregate operator public keys across many quorums. * @author Layr Labs, Inc. */ interface IBLSApkRegistry is IRegistry { diff --git a/src/interfaces/IBLSSignatureChecker.sol b/src/interfaces/IBLSSignatureChecker.sol index 18f3626e..3159ab2e 100644 --- a/src/interfaces/IBLSSignatureChecker.sol +++ b/src/interfaces/IBLSSignatureChecker.sol @@ -20,7 +20,7 @@ interface IBLSSignatureChecker { uint32[] nonSignerQuorumBitmapIndices; // is the indices of all nonsigner quorum bitmaps BN254.G1Point[] nonSignerPubkeys; // is the G1 pubkeys of all nonsigners BN254.G1Point[] quorumApks; // is the aggregate G1 pubkey of each quorum - BN254.G2Point apkG2; // is the aggregate G2 pubkey of all signers and non signers + BN254.G2Point apkG2; // is the aggregate G2 pubkey of all signers BN254.G1Point sigma; // is the aggregate G1 signature of all signers uint32[] quorumApkIndices; // is the indices of each quorum aggregate pubkey uint32[] totalStakeIndices; // is the indices of each quorums total stake diff --git a/src/interfaces/IServiceManager.sol b/src/interfaces/IServiceManager.sol index ca22de58..6f31cb2d 100644 --- a/src/interfaces/IServiceManager.sol +++ b/src/interfaces/IServiceManager.sol @@ -47,4 +47,7 @@ interface IServiceManager { * The off-chain service should do that validation separately */ function getRestakeableStrategies() external view returns (address[] memory); + + /// @notice Returns the EigenLayer AVSDirectory contract. + function avsDirectory() external view returns (address); } diff --git a/src/libraries/BN254.sol b/src/libraries/BN254.sol index 9a378ebd..e86c40bf 100644 --- a/src/libraries/BN254.sol +++ b/src/libraries/BN254.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: BUSL-1.1 AND MIT +// SPDX-License-Identifier: MIT // several functions are taken or adapted from https://github.com/HarryR/solcrypto/blob/master/contracts/altbn128.sol (MIT license): // Copyright 2017 Christian Reitwiessner // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -17,7 +17,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -// The remainder of the code is written by LayrLabs Inc. and is under the BUSL-1.1 license +// The remainder of the code in this library is written by LayrLabs Inc. and is also under an MIT license pragma solidity =0.8.12; diff --git a/src/libraries/BitmapUtils.sol b/src/libraries/BitmapUtils.sol index c8e3d7c2..debe6e66 100644 --- a/src/libraries/BitmapUtils.sol +++ b/src/libraries/BitmapUtils.sol @@ -62,12 +62,9 @@ library BitmapUtils { function orderedBytesArrayToBitmap(bytes memory orderedBytesArray, uint8 bitUpperBound) internal pure returns (uint256) { uint256 bitmap = orderedBytesArrayToBitmap(orderedBytesArray); - if (bitmap != 0) { - require( - uint8(orderedBytesArray[orderedBytesArray.length - 1]) < bitUpperBound, - "BitmapUtils.orderedBytesArrayToBitmap: bitmap exceeds max value" - ); - } + require((1 << bitUpperBound) > bitmap, + "BitmapUtils.orderedBytesArrayToBitmap: bitmap exceeds max value" + ); return bitmap; } @@ -80,32 +77,29 @@ library BitmapUtils { * It also returns 'false' early for arrays with length in excess of MAX_BYTE_ARRAY_LENGTH (i.e. so long that they cannot be strictly ordered) */ function isArrayStrictlyAscendingOrdered(bytes calldata bytesArray) internal pure returns (bool) { - // return 'false' early for too-long (i.e. unorderable) arrays + // Return early if the array is too long, or has a length of 0 if (bytesArray.length > MAX_BYTE_ARRAY_LENGTH) { return false; } - // return 'true' early if length of array is 0 if (bytesArray.length == 0) { return true; } - // initialize an empty byte object, to be re-used inside the loop - bytes1 singleByte; - - // perform the 0-th loop iteration with the ordering check *omitted* (otherwise it will break with an out-of-bounds error) - // pull the 0th byte out of the array - singleByte = bytesArray[0]; + // Perform the 0-th loop iteration by pulling the 0th byte out of the array + bytes1 singleByte = bytesArray[0]; - // loop through each byte in the array to construct the bitmap + // For each byte, validate that each entry is *strictly greater than* the previous + // If it isn't, return false as the array is not ordered for (uint256 i = 1; i < bytesArray.length; ++i) { - // check if the entry is *less than or equal to* the previous entry. if it is, then the array isn't strictly ordered! if (uint256(uint8(bytesArray[i])) <= uint256(uint8(singleByte))) { return false; } - // pull the next byte out of the array + + // Pull the next byte out of the array singleByte = bytesArray[i]; } + return true; } diff --git a/test/ffi/UpdateOperators.t.sol b/test/ffi/UpdateOperators.t.sol new file mode 100644 index 00000000..bb75e530 --- /dev/null +++ b/test/ffi/UpdateOperators.t.sol @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity =0.8.12; + +import "test/integration/User.t.sol"; + +import "test/integration/IntegrationChecks.t.sol"; + +contract Integration_AVS_Sync_GasCosts_FFI is IntegrationChecks { + using BN254 for *; + using BitmapUtils for *; + + // Private keys sorted by operatorIds. + uint256[] public privateKeys = [853, 690, 815, 398, 987, 432, 946, 717, 760, 840, 719, 714, 11, 554, 528, 368, 160, 22, 562, 266, 827, 488, 335, 566, 365, 54, 6, 733, 835, 656, 496, 472, 126, 50, 643, 632, 421, 797, 610, 737, 154, 918, 819, 694, 556, 608, 203, 521, 188, 908, 400, 349, 290, 463, 680, 973, 204, 439, 822, 799, 795, 251, 482, 326, 411, 839, 851, 652, 458, 108, 92, 278, 8, 773, 302, 699, 936, 427, 321, 700, 683, 36, 828, 732, 963, 664, 776, 161, 460, 426, 878, 96, 572, 678, 898, 372, 764, 579, 215, 507, 533, 965, 72, 708, 706, 334, 722, 665, 446, 397, 151, 802, 224, 753, 206, 190, 569, 253, 735, 578, 859, 711, 135, 944, 344, 655, 202, 743, 292, 176, 262, 961, 270, 117, 502, 546, 247, 31, 663, 515, 850, 509, 728, 424, 197, 239, 905, 545, 121, 438, 513, 881, 233, 221, 593, 831, 491, 282, 979, 410, 873, 316, 210, 371, 40, 255, 329, 483, 975, 742, 214, 813, 691, 467, 830, 808, 951, 924, 147, 705, 772, 30, 486, 576, 469, 331, 27, 313, 849, 805, 499, 404, 178, 10, 399, 485, 627, 60, 709, 570, 97, 894, 88, 264, 245, 129, 818, 218, 395, 387, 110, 455, 695, 199, 648, 444, 435, 230, 84, 489, 649, 385, 274, 95, 442, 899, 999, 651, 310, 227, 823, 538, 345, 229, 551, 24, 686, 877, 707, 671, 585, 530, 952, 28, 692, 336, 673, 777, 789, 366, 781, 872, 386, 64, 342, 244, 445, 816, 332, 436, 596, 148, 425, 863, 967, 611, 153, 749, 940, 150, 280, 634, 631, 954, 891, 666, 319, 93, 807, 82, 79, 91, 146, 291, 78, 923, 910, 320, 529, 857, 945, 205, 602, 974, 41, 503, 868, 783, 303, 536, 523, 357, 409, 832, 474, 862, 516, 140, 617, 543, 356, 77, 328, 976, 46, 834, 750, 99, 633, 949, 568, 636, 766, 363, 174, 138, 112, 574, 541, 703, 81, 412, 98, 477, 452, 755, 598, 464, 880, 884, 418, 829, 645, 607, 279, 820, 66, 416, 517, 384, 29, 192, 59, 15, 573, 94, 383, 981, 889, 914, 172, 322, 248, 845, 775, 1000, 854, 817, 668, 724, 786, 575, 710, 825, 407, 592, 890, 911, 641, 544, 989, 347, 196, 125, 370, 459, 803, 454, 564, 939, 658, 624, 996, 142, 514, 758, 848, 980, 955, 855, 298, 119, 391, 341, 130, 577, 798, 323, 986, 58, 171, 14, 959, 234, 838, 811, 958, 715, 902, 846, 571, 456, 268, 882, 257, 591, 497, 630, 20, 136, 672, 621, 744, 791, 314, 252, 367, 833, 23, 693, 726, 595, 276, 620, 167, 325, 401, 481, 63, 730, 771, 613, 614, 943, 526, 604, 104, 932, 856, 263, 650, 590, 232, 462, 931, 236, 915, 402, 644, 315, 213, 249, 869, 179, 312, 718, 675, 493, 903, 542, 287, 752, 285, 487, 661, 616, 182, 888, 929, 842, 364, 720, 935, 396, 763, 235, 226, 879, 346, 916, 615, 800, 972, 906, 547, 997, 198, 500, 39, 193, 864, 837, 301, 484, 362, 836, 293, 913, 324, 269, 520, 25, 169, 745, 960, 883, 61, 741, 382, 115, 220, 953, 612, 970, 207, 796, 901, 865, 53, 275, 408, 639, 875, 265, 756, 887, 133, 586, 296, 450, 433, 200, 49, 662, 2, 4, 183, 697, 222, 479, 429, 747, 143, 713, 784, 982, 539, 380, 75, 667, 601, 992, 457, 70, 103, 587, 785, 107, 186, 679, 804, 821, 567, 201, 928, 461, 413, 120, 67, 164, 441, 89, 962, 738, 801, 242, 740, 373, 759, 68, 490, 43, 358, 677, 937, 778, 589, 947, 565, 414, 861, 712, 299, 83, 904, 978, 886, 969, 701, 453, 933, 757, 76, 721, 286, 311, 968, 156, 184, 998, 994, 921, 159, 790, 934, 12, 128, 519, 307, 809, 687, 228, 393, 52, 912, 217, 113, 736, 195, 858, 925, 21, 170, 305, 892, 977, 360, 139, 810, 71, 727, 669, 622, 919, 32, 173, 208, 34, 535, 957, 782, 792, 874, 48, 132, 177, 57, 13, 475, 243, 647, 352, 5, 494, 277, 681, 580, 338, 158, 920, 350, 300, 284, 626, 297, 369, 806, 470, 895, 603, 420, 768, 761, 33, 191, 449, 359, 375, 844, 561, 86, 355, 606, 676, 734, 271, 381, 716, 767, 337, 688, 938, 746, 540, 942, 209, 451, 267, 907, 731, 674, 180, 619, 166, 893, 100, 704, 993, 294, 583, 770, 739, 256, 508, 495, 440, 289, 145, 237, 557, 109, 187, 102, 80, 843, 273, 37, 38, 354, 584, 794, 134, 194, 927, 922, 885, 118, 65, 684, 45, 431, 419, 281, 582, 531, 504, 471, 900, 51, 896, 124, 216, 466, 26, 378, 9, 137, 116, 588, 988, 423, 729, 157, 600, 152, 698, 106, 774, 448, 950, 56, 876, 379, 956, 163, 702, 511, 69, 3, 473, 990, 181, 555, 563, 165, 549, 447, 560, 510, 552, 304, 629, 930, 518, 826, 991, 17, 16, 35, 505, 723, 480, 478, 841, 254, 640, 405, 867, 522, 175, 468, 926, 852, 241, 860, 74, 443, 501, 769, 394, 246, 225, 966, 388, 111, 272, 259, 376, 985, 765, 984, 231, 597, 548, 374, 295, 870, 917, 897, 725, 642, 780, 422, 283, 971, 415, 240, 787, 238, 340, 149, 527, 550, 377, 964, 558, 144, 553, 788, 618, 351, 330, 525, 685, 625, 85, 42, 465, 941, 762, 47, 476, 751, 871, 189, 212, 754, 824, 223, 748, 7, 532, 670, 162, 403, 1, 659, 306, 657, 317, 623, 318, 605, 537, 131, 689, 308, 430, 168, 309, 599, 682, 654, 866, 90, 327, 581, 909, 635, 114, 559, 123, 127, 660, 646, 288, 19, 389, 793, 406, 638, 812, 343, 62, 498, 437, 44, 260, 122, 101, 628, 779, 417, 847, 696, 492, 211, 434, 339, 594, 333, 219, 348, 18, 250, 105, 512, 185, 524, 506, 155, 948, 141, 55, 428, 637, 392, 609, 995, 361, 983, 261, 653, 258, 87, 353, 390, 73, 534, 814]; + bytes32[] public operatorIds; + address[] public operatorAddresses; + + constructor() { + // Emit generated BLS keys for storing to config file + // Should already be done and added to test/ffi/configs/operatorBLSKeys.json + // for 200 operators + // _generateOperatorKeys(); + + // read from test/ffi/configs/operatorBLSKeys.json + string memory keysConfigPath = string(bytes("test/ffi/configs/operatorBLSKeys.json")); + + // READ JSON CONFIG DATA + string memory config_data = vm.readFile(keysConfigPath); + for (uint256 i = 0; i < MAX_OPERATOR_COUNT; i++) { + IBLSApkRegistry.PubkeyRegistrationParams memory pubkey; + uint256 privateKey = privateKeys[i]; + // G1 + pubkey.pubkeyG1.X = stdJson.readUint( + config_data, + string.concat(".G1x[", vm.toString(i), "]") + ); + pubkey.pubkeyG1.Y = stdJson.readUint( + config_data, + string.concat(".G1y[", vm.toString(i), "]") + ); + // G2 + pubkey.pubkeyG2.X[1] = stdJson.readUint( + config_data, + string.concat(".G2x1[", vm.toString(i), "]") + ); + pubkey.pubkeyG2.Y[1] = stdJson.readUint( + config_data, + string.concat(".G2y1[", vm.toString(i), "]") + ); + pubkey.pubkeyG2.X[0] = stdJson.readUint( + config_data, + string.concat(".G2x0[", vm.toString(i), "]") + ); + pubkey.pubkeyG2.Y[0] = stdJson.readUint( + config_data, + string.concat(".G2y0[", vm.toString(i), "]") + ); + privKeys.push(privateKey); + pubkeys.push(pubkey); + } + } + + function _generateOperatorKeys() internal { + for (uint256 i = 0; i < 200; i++) { + IBLSApkRegistry.PubkeyRegistrationParams memory pubkey; + uint256 privateKey = privateKeys[i]; + pubkey.pubkeyG1 = BN254.generatorG1().scalar_mul(privateKey); + pubkey.pubkeyG2 = G2Operations.mul(privateKey); + + emit log_uint(pubkey.pubkeyG1.X); + emit log_uint(pubkey.pubkeyG1.Y); + + emit log_uint(pubkey.pubkeyG2.X[1]); + emit log_uint(pubkey.pubkeyG2.Y[1]); + emit log_uint(pubkey.pubkeyG2.X[0]); + emit log_uint(pubkey.pubkeyG2.Y[0]); + + privKeys.push(privateKey); + pubkeys.push(pubkey); + } + } + + /// forge-config: default.fuzz.runs = 1 + function test_gasCosts_25Strats() public { + _configRand({ + _randomSeed: 1, + _userTypes: DEFAULT, + _quorumConfig: QuorumConfig({ + numQuorums: ONE, + numStrategies: TWENTYFIVE, + minimumStake: NO_MINIMUM, + fillTypes: FULL + }) + }); + _updateOperators_SingleQuorum(); + } + + // Configure quorum with several strategies and log gas costs + /// forge-config: default.fuzz.runs = 1 + function test_gasCosts_20Strats() public { + _configRand({ + _randomSeed: 1, + _userTypes: DEFAULT, + _quorumConfig: QuorumConfig({ + numQuorums: ONE, + numStrategies: TWENTY, + minimumStake: NO_MINIMUM, + fillTypes: FULL + }) + }); + + _updateOperators_SingleQuorum(); + } + + /// forge-config: default.fuzz.runs = 1 + function test_gasCosts_15Strats() public { + _configRand({ + _randomSeed: 1, + _userTypes: DEFAULT, + _quorumConfig: QuorumConfig({ + numQuorums: ONE, + numStrategies: FIFTEEN, + minimumStake: NO_MINIMUM, + fillTypes: FULL + }) + }); + _updateOperators_SingleQuorum(); + } + + function _updateOperators_SingleQuorum() internal { + // Sort operator addresses + address[] memory operators = operatorsForQuorum[0]; + operators = _sortArray(operators); + + // Call params + address[][] memory operatorsPerQuorum = new address[][](1); + operatorsPerQuorum[0] = operators; + bytes memory quorumNumbers = quorumArray; + + // Update Operators for quorum 0 + uint256 gasBefore = gasleft(); + registryCoordinator.updateOperatorsForQuorum(operatorsPerQuorum, quorumNumbers); + uint256 gasAfter = gasleft(); + // emit log_uint(gasBefore - gasAfter); + console.log(gasBefore - gasAfter); + console.log("Num operators updated: ", operators.length); + console.log("Gas used for updateOperatorsForQuorum: ", gasBefore - gasAfter); + } + + function _sortArray(address[] memory arr) internal pure returns (address[] memory) { + uint256 l = arr.length; + for(uint i = 0; i < l; i++) { + for(uint j = i+1; j < l ;j++) { + if(arr[i] > arr[j]) { + address temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + return arr; + } +} \ No newline at end of file diff --git a/test/ffi/configs/operatorBLSKeys.json b/test/ffi/configs/operatorBLSKeys.json new file mode 100644 index 00000000..0ddd308e --- /dev/null +++ b/test/ffi/configs/operatorBLSKeys.json @@ -0,0 +1,1215 @@ +{ + "privateKeys": [853, 690, 815, 398, 987, 432, 946, 717, 760, 840, 719, 714, 11, 554, 528, 368, 160, 22, 562, 266, 827, 488, 335, 566, 365, 54, 6, 733, 835, 656, 496, 472, 126, 50, 643, 632, 421, 797, 610, 737, 154, 918, 819, 694, 556, 608, 203, 521, 188, 908, 400, 349, 290, 463, 680, 973, 204, 439, 822, 799, 795, 251, 482, 326, 411, 839, 851, 652, 458, 108, 92, 278, 8, 773, 302, 699, 936, 427, 321, 700, 683, 36, 828, 732, 963, 664, 776, 161, 460, 426, 878, 96, 572, 678, 898, 372, 764, 579, 215, 507, 533, 965, 72, 708, 706, 334, 722, 665, 446, 397, 151, 802, 224, 753, 206, 190, 569, 253, 735, 578, 859, 711, 135, 944, 344, 655, 202, 743, 292, 176, 262, 961, 270, 117, 502, 546, 247, 31, 663, 515, 850, 509, 728, 424, 197, 239, 905, 545, 121, 438, 513, 881, 233, 221, 593, 831, 491, 282, 979, 410, 873, 316, 210, 371, 40, 255, 329, 483, 975, 742, 214, 813, 691, 467, 830, 808, 951, 924, 147, 705, 772, 30, 486, 576, 469, 331, 27, 313, 849, 805, 499, 404, 178, 10, 399, 485, 627, 60, 709, 570], + "G1x": [ + 21008703310028844141620162130587521182514488709533704622337026710714836074802, + 2218442071909829476988912623652898328245595472449015640683744728759449649815, + 929152667422599970695899650575094479073771380886799880202469230558386204959, + 3575600246906522524036900976337584446142230737756821779105473917170228123609, + 9061916543864956308970512584250995307668644798601498213984066190813376416958, + 10091502645872257093335205037789654400762772223541421522725432993893632198887, + 20619357027302710171780176937665761598656831341681942829653583342169816142182, + 9099941130641238025385470195583256714200958269945073680214036592216475100033, + 10351196325998191107817125911342471147729141907385406945588844912042944521862, + 15866823055351122078559837406709798344525908146961222093235442230315196349165, + 1348501067026339436270112815749514437467210112392125778316784869073475785646, + 8789530020798369726097878531765454566144275451021150601593941656700225075605, + 19033251874843656108471242320417533909414939332036131356573128480367742634479, + 3979223167501809085480227428065007238209835041723401970501905330407616327528, + 19593059431856802862885853819325102430325644405932288046957014870750193823389, + 8390929267417827336452791043493435936575597898092316919152263072751612058472, + 15100489339697781661527780825898331635882149064108087483216353420833040353916, + 15727213640762128376977790067421582934261473041285176203873887513123693207669, + 18605490393111649731839728366472255644714765200850761728492247072995883152290, + 15336846090704755964528625034690982622997714784382430122711265863173400877387, + 17764948085669298106837271332499151598355415181749044454895405564592499218570, + 12555940061631733298690525448454973663057499890044551816692777922256682590634, + 6606290837202043023235019645971670069753598702002503677374055439723377249805, + 3068197466165959014627752174875642087685547139765847651906759454304963629552, + 4248100166102451680125175905464283399211172892602854532188800080340855446586, + 3927092674152154001037919440146790233361956899612023537741659305499385084031, + 4503322228978077916651710446042370109107355802721800704639343137502100212473, + 1501518903477102043696548360246450543747408924808796629113987784267258891467, + 7873600825056850253486986052968873442352160030772319054875894006095602520782, + 1064422405773428018325110673651235092911768670241865858489810188959673119888, + 1843729298586955840187119816428460106895285901283767371419354059688694085701, + 11422571921256594021064683012282162165595702625021725916052329194154497260283, + 1101057312509651559477244419067253238519767220066365896656567539863927245336, + 10293440467746533258730273868963994264411932774380931409364395879420497572327, + 9849780059844548922343537247108471546568254701727577044313208629101755829952, + 9316231241758435338139509856980912682738999765909107175009362482909424598107, + 21672197238155727964578211946705879096539059517844778016381153888425067231273, + 9844331402755189974955941430851340772869135705168289277813293216948822709757, + 6224721970779364001559111610561597292098045432669553464472100789020894403028, + 3330513229021989056183013898923655936789291712128422934081176087724264796877, + 19694690089203240083329349305529930602027790861312192774074187265499963779341, + 17651857611046956936624752935254652187334578539337442356276537229271452012535, + 12483339460998695384054986468572168713626905916650721872738558526080359371028, + 11805674057158997041651224556038836067953201792248223454186186616717481802103, + 21081834205002741124517733106494289565706586320059028245998909954956031354806, + 4678697332242275396807364313947559165868246091038041132022875344166710311604, + 8640972532221144572012647286664327158426783081668307380579195364355389597682, + 5195038478038025356781918669589915223766176107684139161558193426543221852054, + 17521872790060822918634962327884933922781087739767474353231679230972865206285, + 4492216400784908532645031702197347371112298590851716541802413022671784216830, + 16262199471205794413544947826745938654132104752637586692048329713311590397011, + 12608821237053524911196024432226913018932945199219830120142659066355316678673, + 15028837980481091296831016947530099065956331426063068351608016888381685748291, + 10992764003214384343636167020119026309842947069152604642870988201254434187042, + 14116755263380396269483551805305733883586447067295283615385991104540593662727, + 214698931296579904209766103445198663430436911619536860246583502353931929807, + 17059684171747837145045589753984378801016256455435710153665747710965581597867, + 21849301689878875516024379109435909123714002233583559061831885140106581246763, + 2773351566238813713579612540158377479222737521880275118382397944158519463820, + 6270628957929218474816956229027144551943030204792281956992328217430784273040, + 6572392894612729040652198729551870968516876450392088636793158243306502059801, + 18210469759043018041731677353547663735773188983069171644950019235473848871912, + 19542735766023134034323920539927124148767613883585197640875168599002733387338, + 14349536662151790349658442656977516482980007766388372688422202350228081066041, + 13395751663544151867535099602772352186442545613094869036198296900934243253455, + 10430337431543531393739030921523975878786167360509206005214432082635925276396, + 4172648201341257083350113746245117087043341536101305305618512352960066746090, + 10802925614466615856436402407178439514478011778295543971305724087402097649469, + 4199691724961635209631947307634140148191731163252904347659751036043258418251, + 20407726371048974191762955633160316365190600731048304879201372777187449338770, + 6558317214542555533296341022309235115560511773767859148287126223754983008502, + 12862788731182491047325812839111576132845498384442969100108866529227476469153, + 3932705576657793550893430333273221375907985235130430286685735064194643946083, + 3100464165353520904129396771506202468154342212182794886005257607263704874996, + 14956327795998947663303926487908649704934531731136935425987504932760335924078, + 9888418677474031601147360331459313682385868364967933395358397996608801759368, + 3849418887053435766279766678703867089360109341221376988875839145109920919694, + 17689515103276919398270606514839753281230149269960053505238909481409832524951, + 14905968979339299630791282004007054053411808275902623924589926774324208484198, + 11091099369704420792635714246988239447489639108858134116226486111509292913726, + 7526539425141344687993564467112769213444879158952562170544571180282865176976, + 12109125168208163605857260910923713983580584394895257282529162242928595286368, + 13284478285240244776611402620420852051651674084901975628818927430365808875047, + 1908244807061006741523579196091656777099590918885183519850220483853508078962, + 5765800095311608027671565037489386722411637951416404004585216181089971594877, + 4354573874570380613916252403615008624567926951834735632582280797898789917739, + 10684419352953605007538135646199059246402791527193568285282512272175051473659, + 12766313562177464321430887930136737579503625190210321101900942340880867727231, + 15718683116261348511420508870130263071397119843219890413061444240235675399573, + 11928739438168890503090240460418098171835745227276352431641611027499011291739, + 18343024553513600692434999273179578554412993601258478016692316038787907790699, + 18671841561121186512404299858044607005439720124998758352195376573445009373523, + 12644841667541395848021330255597969638317910225029694406259079279352634550597, + 6354240084794040337609893414308587143361101213810303474455216341840532393533, + 10281398796872911616422904801608609528580497695401335908790595106709947986174, + 715498345872591031817709267534482283032239999977951589998302164736567873247, + 13367058640769559175419826013664925622553041032055637541293685072102028189015, + 20774290526009749049976554151803865249144877726090017675655423783641014808922, + 17528252418450938367435016580653253778504417334318041831978092773368819909223, + 4797531885795792906805913810015129383385268386221744319311227041429775259487, + 3795135095120156329872131797670655800360890086902170284883282163227117634074, + 13667080888773610558467507027924964334533247754530827317188269749964642297578, + 8945922429522785634425188875615982015958045256235789654870089749543667289614, + 1469531279492091903170776673087021936621411696124086885689806519892960878789, + 10675669183704244844683906074219413543174928506492436651156209647832480557563, + 7859676170876933727135276512661626466585301728755363976476275860609241458120, + 16787296659502232397412585383635515317043939521932622556869606943899102427585, + 19156959192624324306296015639711715090624083826224255376840815610003836689034, + 9693009038377845480932832496357015961413703787970048736816558260649871664976, + 11151661203500249083418412671588958873381140493773132621701903655043841172042, + 5686314515957984192645313994356390322903584260339359679134679542156743954834, + 10756373192210956725195200749376879254612141985753768692993731903685373087338, + 16025512136919809940653451651824370246331248196308030860133746984370575183808, + 20531521242500711049369668305375880757590785197762790307428777418419539427036, + 6663269009386774704046531320614103480920047396052609045141544809471211236102, + 17331276848282948955561604980654167115462539362629239055587728817370932708699, + 1651320176654504746648666404064778767382806367529679211773463448949676325271, + 6580745172126597165243614772757059470727493913049141541850969282672243994143, + 19766243767653757959937724832536945413672456565251184909511442044990037902346, + 2014511853889694007465945268059308364684832788002610520550093984012118887397, + 12474057516979268850695377668051977568318050104264824952150669310845044082001, + 5022685756728220955827045942699306964992425940710754637009518130328563678079, + 8515825154068624510977216991578449360215518920161113008640164765171948076453, + 11046303236627519575582651660618980283059685836047102311471676171671798787527, + 4279696094047847131400438199172893463415636955479778275811267923525302880584, + 9424467304309542109140998916676104359278524971990760318275336488052797649388, + 17824683701631220404790167295863547058164197332047694173140186357298477189027, + 15699948478441865767203349823814716499050953310059397515288729237095142720858, + 17808406456525951806822935775129507660662661717541365357563049471977318096517, + 13759698281541362948100552505387368848018484641321223091947306654885243690704, + 9266058920964714896918891528586305682144112304735475913480805854247483068921, + 3668133038378611112531066403637666090464145943363020590114377616140256084877, + 7225982673285909553386501158842748728760186244046778715170744703049569502133, + 21786368759878672976027795513010934058278635123475048700738707729376287825826, + 11164477424856302536619820695611865191161754912958246938861388289761193174014, + 12114498131099389210946401521343849781717449927764469603535580316316758547778, + 18195536337584912162661528316375503471720006776237893642884872443851550749103, + 9366015879375004571250438303432407971238053874512316318402267084951246439740, + 5858219945549501094971087365821449813581780089701668504036979433691389258608, + 16192904060183370978086946916739082341256653912581897734726914939223158290989, + 11676844569607219841011919082709005856726244003485697871389305382744373317590, + 8888016064627700724511212072918256065140875926231849959938597769750792550882, + 15946182865867607910338475951975017091408773094967505237345020744799519231111, + 18442650727864341248117840001802335127307636140452060952131428260037716329349, + 10818684402671679803938670581857848618353996155451424730955142002352363125657, + 2759095667186266942919681905446205531786064808113529181706120395186168617457, + 15990648862660267582208155098385009914696698149966093048125750731699716491494, + 12114878709057082795677831461229505871095782913457519087508702309063561557709, + 14936030977763811550590557453850119029256509382936742155977651917141130273080, + 20596006265481121724486573065068098792862319386508704835424948422387598922703, + 5090292228091227810407354987644262907796086470880015563248273882425077988100, + 15787304016560239155837597316814640057633870394677010651462440187827105806237, + 15243829183890074144109702640859121820511722036389166476804077272375605334184, + 1676471362991543525100060261075347273116101036710387184708574187873633080053, + 13141537302211456498408017567326482037462991321818936375588563090902771347277, + 15451355608085403428816425439169527306598313342357947223007690646614170051117, + 9759511109764457907441246335707284637631418077699497009315527324160565124910, + 15435830618287982986761381377777327789970072622146288262729619715344636740550, + 6832713688294529883829586618525749619127423758538383909613355597506907659662, + 16730207337420605929324648964014724681404456670159142584448755745150071717572, + 6357128550680790906521619402149153875045931318823830790163415953012261964821, + 7554570959301443074261201511779962693566808301692643775482777606713904355412, + 11657337508491416152605970047208789148750112107274457635023450562255198822922, + 11770633327747290800386332646674159126375322173586449627392880321209974595276, + 20003165157599505724822627051277038367118176092311529681748895592930988869629, + 12623042442131138433218131872348034718530098703302257680506121880219970513239, + 20375060113429434357055627441349161894662173567998716459943090966123041894289, + 11163182194745310795576539482698127987404565865187742028601477953642080030141, + 15605284770274530737653975006807637783554369673351144245078223953773493779001, + 8898952920362644642485150113975087272459644798001681531107645189723089497453, + 6001561412801564337733368451548168603512566924071450668780210263878044385747, + 2763735108755993076083488174376824827135452953930403232965623991969084506680, + 12832551026091610983677812521889191212966363888408338625876158376369909780734, + 11783759681504922287184692251022298683508194634417595333763669555221940743325, + 200331477585946371556653218084153252343225497373361271425826387226351347109, + 4926371182919005146124278944473793614815446600201211448352516512667191831337, + 19204580681385387501717292285913342621312288061447302924700118475304449917344, + 530781798581820434195100553252847049770450473476548538115587271915019592680, + 4439993769588176984908949084508288149727531367374931869016447111580770726291, + 14562955672837627087405571018207569746774379520008027634431380250522393693149, + 13901394713644702390888989303698197961918324169576107233099298551992814890668, + 1527465159374431915328497116935179161014331322368960485951268517950184093102, + 2999460649619702679541095491745297380023500894714561518257783449210587957383, + 14714319155247042074071892900908664598841430856069541512990643427826821281780, + 4159960804810595215370167818643118481090890411267949340371287733342009127558, + 17148392116158985283522467838505069842807869130817455793259369503963362365419, + 7386018680896664845814314739404608274906642913094681192334051733974875574294, + 7704639827042026470382886782704922846194857143684909998506614722355925634110, + 17560439792323610253966835856971896341874273783519888629784421566007464086852, + 2530775162419935843602399632898103860443503083187669040426273577202866305899, + 4614803373977649599351157313760356431226431023149746330280811761359286424824, + 13256385979709478041825407576283983783238279154098759374429323029806284937096, + 13058054820872484446482705680895825229848765878538036634541145702916948409317, + 4444740815889402603535294170722302758225367627362056425101568584910268024244, + 2996627638141983540785345403516715204392112718771954261136876416010860119534, + 11545659967353775828012016060593140604954891323989821148839280018221651568032, + 7842793601032302949523554533282628306960208234171087882902686383036781831313, + 6550357352200013451728947797021181791941851093076327248778209640258060665049, + 9131250401703579154075010844842661420323554892635766883331587686396891544864, + 20138029708002540939045942557909831188002117788940421578090094393767196051954 + ], + "G1y": [ + 1145283673551783492487423178395020830991754869805176606412560778073024405948, + 19044000801692817875480095431895877480063996883386002036605554354446588492135, + 5342903000878945690349144853419533627975245417956505609802636133196782326796, + 19812855821328834137390487293807252005891943172190598302612838254963792233640, + 20159074989442224803879149737393061036261376444969721831643481107965996821818, + 19533369879727983891819280176467167802746999518016786420282324811378212929644, + 17340519823350055283445267380756340970377174418994361538996941446413182608507, + 19746888482404066651518785497076001746176645128293718248229144528632008630886, + 18773520746568100746837892938610938204094534262114664675862018466792560849, + 5221542821457984485577786120518539672849655396533551547116902579546982121924, + 10505867816134810380799117821540686299058523791552723952628244765578725946327, + 15229925274868344308118299939768253264169436094477243810968543320324157201350, + 20792135454608030201903199625673964159744755218442260092768620403349374102584, + 10835988878649991885366342337537668134157763390434179902893351965497482662739, + 17746582939957259571898679290923665088372447833861360288397293088284607838296, + 11134054734384804449614657981807313142120307155684566328305729540697796212075, + 8587206957319665506998757723847569328119816352489710653434231214712787923144, + 19144605879150273414601776380457513460094228635793066771119021730299648624873, + 7230115998589026402668982785059803900752340749261210412514987865249802353968, + 20155555882542291335278731651118125280726620013507295119885477785399589563964, + 5567073648146441405397632511045086664927106903972848363063713213909066978511, + 3201642656434336042262664429590415684886404362471162266099087526094557933881, + 16310793062231163621706834544073169139889248389392396075528557140919152335715, + 3198794566582343866367627870237041748850878228221344783343075384621226180833, + 16481341146145551411884899470025387078572234413815526172759626484549507503335, + 15514573173146200595016466135822141999394505178480103495696271267158458098108, + 6132642251294427119375180147349983541569387941788025780665104001559216576968, + 7161161050947921513524916363291089824584031311486819921193272459104706559977, + 21395453472676050092918700201016712833704227132892313133258156405991376729931, + 9700737818160183488669983068541523326682863375700314518150162405056587364288, + 18572928620922924200074661834417300912143511802421857439801444543761378111888, + 6117907817141668074656559552838788699644312619688308158531883778732448013064, + 14912451584752984949430273978379139533073892683860694635635525073899425482138, + 18924661395393895889209430839689985345119352834747028137037680748388518439784, + 10690350902752859070929771333178848535750650443212722359074912008756126914039, + 10946761185450384987004136032644427160416294103430196957117419098829972101765, + 17212306971357516245472845055422274216420387002533059109128177883787327902262, + 14852902744279479968143956402161259380860181373761672975822384807227338797385, + 11718841622355704844012003321078636855324380147928608841336118615228855427842, + 21607485692943166086724546510471083165503732642787700649794553159463917736714, + 6021878627064816393651670653005856828594946608929679493763803057547164563728, + 9783239066743718683854580760792275067352132322115942910878363976126295863846, + 13546414870480803739723493358302948408034575348712520016069419229192165538609, + 12463879440124563385345380635251124666732206694926968694744648101553396003046, + 355119712084491502725349466479157817305510660180791852747937543735726378907, + 10422392878856862891015606373464287806299079786495103256332386337642703494395, + 7392240906828207680730295507113397764375457017498846484728101555798495934887, + 2718741004502733460325918899267929571739516198559902795219371839316616123628, + 6171247213306619778480646816426105014676926474591866308324693176592430029975, + 7398014441975452127327904514462525386971078203641224470833855929919001556820, + 13296900385261935021718889695689394625708483652039722230815936262285054528714, + 18091084185225619324695813997540889156240219599145856245586608617647268619184, + 8661261225786786859924392677868236399403630901791277659828512203212549248916, + 13116341745572477832466032345662233542186252129301492224055351513067394711956, + 16174946973653419655302067282033065222678330836639365790247520516052585304183, + 2012016135190743098616400293640701700807029215243959514184616000945488872971, + 1641136923307554397473256919318493554704076217632571191244892769612401429030, + 18449888211831023274162534382959366696222758120288292691625254841561601750069, + 16576954780579611386978155328473760667017224490773074087736583011508694407189, + 5773138814183995099697738247662962345870326646182909920827432711192337064553, + 19165945065770289131182089455922938056072492622814979068462748642445666121287, + 13229679063332984953643376651220668281934817685695798123021937567073665918126, + 20867541899062692984451210604680459814351012630966224264953850515535097280322, + 20733107559068364371775124442880704706239403695474837210542619956669018445425, + 16422604709081499679843296942405574005002870430295653394162792937977117529960, + 6746251577919101372414518278270867459405526298432486758706646327753572903990, + 5574822638119477302795944030532496311612212783704331576255063278488607161000, + 4839998090821649692976471525184888052962395540167885944174024872204948319046, + 8902203974290145254449245875701134903083487921935873426458064069251409652135, + 1355950543341401923755736503993572816494983449140472470668556692959284125219, + 16325497147363218772184310865556097850025972350591974597093925415180336291265, + 3437152549864155262937176915925322437455960322031452012554313121936275193042, + 18813763293032256545937756946359266117037834559191913266454084342712532869153, + 20230470907326929657506857000266841113729578567152827288490500280080732133395, + 10847295585690477628232535952325692755760584284769096233670511509129045083615, + 11530586200294541059507619128844541656466953478994091850001748308132859038813, + 647948275281887556783247799715457709588896919763793635933460475337967014143, + 13568228604968956950033958874107812887769572974913735485473092530818098143748, + 16763145739304362238829267268934143212822778165814674238054900985236651003415, + 18407501865298445155668734383407877311951926740547145686100890453033561895180, + 3594038466846216701209909800612432640396972846025922658654537377324343469225, + 15968495061591974818369503561669603416490648399745553243439919872679665689139, + 19864079597151933782537079035989572726412361218228115620743258298679811414091, + 7537267809722317952761385348993569627355103028832599118744346462677036156508, + 10159813807457260457888080478238238947089035472606116961215630047622509705620, + 1356416337275265272099393963981926016559919540973026277078497942828025284210, + 12730997959412505899974417090059814543566823763525054065624068029008563377640, + 16196642102283816477632471311628253159947093948639740204155549891484678067833, + 9734489469842827666758862010166872175233479336248812513542276890147102850151, + 17402417066397786580902493513910699728085956899147279945127996483343424419888, + 17811239303984065076276123229384062955888419423165979630186251107710976832366, + 7809354174443370407285436184170596638054012602210636316839373867916701870951, + 8152550590391093202378849019940156446008614768414189477796647947556068659629, + 9576676515110307973671530100378340235076066568263248557753890500035042188276, + 17260966383957568577885913469953890080695338407838647423333184706279273629148, + 16316439522088596068781381218723747057662800584054386844327077744810846116734, + 6244986047891617843224744128151614460105311096976451825499259061007648747280, + 6191338025971026931806054315082254726304509337216191177468857133559794779222, + 13147641702224912599336949789618904497478006165035110998300958949533974265674, + 7928257712604439464760514732782600718899438913627232834147760319141315411020, + 11892667433320824814301195112101845437382073584826656610566791214091808006785, + 12692297360316042474584864011813882741155153223921991389616278254945137148613, + 21246109564380899691094347869997215883796539825787874625385821239187629006392, + 19008874223459141106713492074684592890108115748079987086393333890059985900071, + 19396910910782518258932075159749201587648396619397950827257811272428970976095, + 5568348044397782651154348210982710547078422105541356440912927123706376758057, + 9033638181081819064719200817594412015270515889061669257083004696037149714366, + 6927479240344301617433731244555880051806323234662895123875389729788811000487, + 12156941134424327120357143506488730921435634138159788452385696594001989421471, + 9352012977010730965150450381979128308524479261615684039985789103565906182992, + 4909426047907784472051609098319980803795989430035772130543058702985971937596, + 20215533543601155822038742191263222332989478035953948474544154592294549743185, + 11621291358113510529553172185580040092401879918544838850397626906358644549820, + 4690898325322448066681080339494390570249415691112109519449701719365615271922, + 20039895486962971312547628870777137671071775187405127604902677632326519684280, + 11892531497564550270640974777300585696360189048555847433894397739103640578874, + 21593257665558559126008618597471436986183267947125249299446142297903094174767, + 6811127957755585863574857265684051972152439273185629173677226084569550387986, + 5743606749675771187223829279663761451826805294366004525573279187911892522595, + 18370034274990972943314327192531376607649068344019112270343176555379735811313, + 14602078196954241221236114866698383250724712865328324035404684058530025587600, + 5731431698748900716888985256445043446183843485893154627296513971775351486907, + 540835503664108405238001857153052524506437291404081175555839975848847726302, + 14436101120768867990263026828220718589484728450168954749243093543006287499498, + 11116184733298917175033807388259057313824631517658218201889948192673775420657, + 1778726798519900263032462255183166302989403596381730183535085586499987568162, + 3097434001403605815138448380136495440524244032504546416970701306470368425560, + 5582122555171712840168562533469717533820220898057363286164994099897330319896, + 4223194912295492163595167048932906417406952887351813208508469236242673400842, + 2802484140856827521246385702860457138638010669954881411915001585207441689408, + 7448334586337759222910235381652615860844843910517626215771103976287038544223, + 21309415236119591559673079935809830303570631654873689429294101461187225496728, + 2440971123040292464580572667942169455495675628268615304726344358818910012443, + 3288442270860272965558935704931099893127729357018543125960920651435858595070, + 4098989460078830340967924135507277108877082701930763961699251044003473181783, + 173307216912672474084349778679998490374258227318786418789727665986438743575, + 294706340636858478072285921295565837697874875122459431569901946380063160820, + 18456548560916331602912926306132216314029103442570467520030714287463663922742, + 9751343461740795628323182552759520175244037749699475499225990823807300394547, + 21411490936608904607626131892667221336531304009847650358411209539814283513476, + 19636289674051324611343799370096085899668362391482258326346609645617307236475, + 3581347812477748791884873754665633919991010157385542563074993211889817269710, + 2032616161731876182580090816014255543000696876434635548241884833439314546899, + 12565688401713897976173322305695617734280025339331296474382048828242834797264, + 5341762011083864829430654352425252220278901024158591213572032208695556239140, + 5620133069781043134706412799597627644713211334920176766039983212160135461265, + 11559370949512206426967108444853043391839496789081397374205176934520670305273, + 20219132183268007163870058342708925482116042569488599830352162992251560628121, + 21640474737176494301628543996026422412779492879100870503935823533565356453240, + 19993989838959241858140530867832125726222854883954655514960892767475059706986, + 15501108696882993081421880466812864875484785033847859249364088125340753732657, + 12323670002047520216005297684042939177702593408723445520003368308007214642769, + 9390525596321673035278554623788843127823368404689746612043348029733527359807, + 7565635073463455968040215270195650270943151773464761819879832946074375859890, + 8336944489760578462297433326834903038950168425266080275229129875701257848679, + 13314993866506708066227836427580341605951279028324215712035847838895862981522, + 1818168370768330346590552350313366493206331657491384194643421476431462473807, + 13277553045337742037250285604582008141373532006643613817493471240740777752678, + 13831284242895716944280151522947773119043295495670056116585213391826413440510, + 12673157264114699244312295812973661587499042232241962745614715633628746931962, + 17503510298698008200235258887844477681954701564996853212260419672366164546606, + 16740786290164064572534924028868291591074863128631635140045538139135516538067, + 6189775778060918028520904409398115747229531698531440981435099301292323301139, + 18376607814593862144858098906377691492462478316852808063329998411342742384497, + 19521843329763029480438735371451116678177931327248380146196642919230980579494, + 17063130108049825168764659754731928816245619340444518567222000281866131469355, + 6381840907712825376277075992338454449794938263721225308304231447820985785733, + 5177500118726043314778534835818052923011986502171642930594995798596534170922, + 2068727483459102094428288051912103755614219936218374731592143826463351825437, + 17687744857226258330114015037329794279468071338417549150877512616847733123483, + 16836239046387831213076974242667538298373441215110151473999119625719220214061, + 2424099571483115408813176031501898327912961720777692067266878781827457898706, + 19886573840309104775406235128458398179544079263312633289381556655380331944849, + 4154394677815032565855584463024837755802121611489575973360003526978624023571, + 4311485783131452848281788696116477530511111069229267992297348570027830381704, + 3704701901218665687465766914668374139464398466419565401338617392982138174089, + 19311206837016985221381009994405681766413329602214899721450250707981584815953, + 3812568471850502639929189304205717749371445470158057554859876498149782668902, + 2542364243123249463528354816015899831923204341352312382532722761470729613037, + 6745040272952410961385849610705284800695362309364314011363699663255388090718, + 10827450709691813710231306967115124598825778494633792146301488488501226003114, + 17274044707157828649723710289902216429715848248207037129568326237800068062774, + 948577821678771846025107600219447912884478799912945846645644684318124577405, + 12540869786966023273429972604644860312144492000974914873822247272969941867727, + 14245060049908199972382138125054662622539659962213049773539545332340235451358, + 1415408621383222022164637154950268163565869548406666331998815825114479211428, + 5852141382496003785706624430625245910156483599429242455944689364421678894028, + 20801469559537208463327869011066625343956206261765917350418285417548713951491, + 13638562623462521126290788736651402391208068016416384267917748403230002267361, + 1883216930721399434690507525619711521671627363805165778452895487082319114365, + 20545145196779345570873517777176073791751194980483264965528303332233062256997, + 21513102545268876961651414862126510904709719983608676746884501617698560681524, + 13307865924901068251957911404220415995548975094597054311740487760190290250898, + 10537263096529483164618820017164668921386457028564663708352735080900270541420, + 14444820234255683498437848308618143244015651011647935294035551125209297222783, + 16928445395835030921123521050522768363349431205352462786524969570083384560297, + 18135165633676939551980707523032992248641503689219020416197504228328037443352, + 11764198851342789070312652960755679329204387800111654073605204989399361130027, + 17838050142922962028521120373008136505658529078108364150781877272479502219489, + 7886025129940745206646970898226747923045561469458371375059406708569249465884 + ], + "G2x1": [ + 6165304727519233866734872371230711537271438274887895122159800183137631832999, + 7773441516299720935324307422854513710036028188797462287359801285310623311564, + 11911415543538118600461872557743081256134821532065110074712641228321047617336, + 1996139459207347931963042929137504485589765836463386528151631258969542644046, + 8425603796486075155592636673071414838984440469972644782574880017889518571076, + 13889109852469904049868551678859299744614480488856917686084411007813103102616, + 9279367383141766186374885513526066090823381832516962904796744261273767392445, + 1609543646436173017960385055491854504879326427817534608273952707282919991633, + 20193678945114576765080279868376952466775580695657055291546232796493422096089, + 10443904246732240999161265919148784037138150890604629711723345065003327242585, + 20493329474151044514812562349036713184017876256002801188742521965217923724865, + 12515546713406807268271491381108620429856721153979272146992657275228323975064, + 8472151341754925747860535367990505955708751825377817860727104273184244800723, + 13388822549373778026129670776006986208780964883345661516612743207655017132778, + 18644838163161152847528525737641729807088491829090382683854586484505611895274, + 13310692019249325365826848024252783961167158295946992400475788570728322200041, + 9587853618527555487934474373361586658724006379929297927690684012926654040229, + 13227684903893563143508500371360359177667163486926346070471263257904198645692, + 18474070379187179732783176887379577736742825448650635801369042771080217802372, + 18283516769261482215139338736552537580841555206071507861967180595763091187351, + 20296251682307757826502981763528094228129246132545740182763753523301226118132, + 21612664169888226948764020049202293637369585738214330288805533808714262410288, + 1904334131489681706296991236481494317887557320454969288725855419962837469933, + 5441861471556124876203850780175511713751959213824869726729099333615879118810, + 11804495250028695359771901963377513448574861601308919935881748323339829880027, + 12912325594278932645026337376546720035201819927627776608118317448304208480058, + 10191129150170504690859455063377241352678147020731325090942140630855943625622, + 12686703398709580379026248820388151633550848765596155934855273105874998980968, + 17307110952461258332408259513916882811173072507569397796371595880505897740059, + 12378716606620215567346420623360837910474223641123907152786538902147993283803, + 13332781202438395322870601134089338210899833268143761242757822864426894476255, + 9612808266836339293910077101704056570395765052009547659617651194009811937560, + 1563797175122403387968193028222409038273957538617048877093667482284629811605, + 17322369349692087243447028505687535678015944818229625650476124495994659493777, + 955645704892042345948768988213143634284063201459610722604830130368457581752, + 9960882087347388286631779942586492920020868068121693315413097653469393939406, + 5100983425433158851097753072537356956519672566298367840002830795777147920172, + 17361715326356299798170682883676973632715880986295040010953577275435589650649, + 8564966529265716554628357919108120606107168145978471241489032653494702818906, + 13114567375157392913969153982619766455928668743086543011815783210074635117344, + 7586206128041850101711044679308725743355054867593374654687681076188320359853, + 15410361870373365632534242327934243506312727574174986996534222697944723149719, + 3882236704872894632555550139673736373194471995389671789074415634548314021900, + 6061919926148464607834578861560396536478789610455380108336488256494200416938, + 4890464849356750986461441050339287423508662304654463186815633504830328546459, + 127661424318974955547329756398406845459719481486117293898834241788993285480, + 299232422619317032872056303519217435146718232629212024354461724546609465722, + 19001824577388446853833224075771409488033001687586886836679425300310820672767, + 12801609631033252154176107927798157661519862781472463602094942586183190478740, + 5444238243323360425266623541339564614050203258746370084720873485434101915025, + 15315709620702712460485525966545043944570955016708868204420815750896718746085, + 12500467286922735215494498574602166345932972302780305743054810828266809551022, + 18698635975422260466246394363004078776241731118018842917637384316618786476776, + 822794966917994937300793157440300310936470726810918882610415367702371605130, + 9529920943628042491458521959890931119342620153526235298108798066835405732949, + 3940192194313361910400747709824316160530767632528038403520296866226173790823, + 4155564696512398714288259584294125760252549705202122495481948496404015363301, + 10973861204576799842080301627882046396876946119941578624790901578112014047361, + 20358714186654557356830566572006415782739233988945768404404768427353823242310, + 3178025828929700714297036690641216350604009280090756356259170442087114246923, + 10844875747767898698368195686620461226918236716218019209808138563937240355212, + 15272893042387218721734975278401620411214162394283280973294363581612306655168, + 19654936136245213357227473439795906126569298821413318300563937640476474433734, + 18535645111250443530352605565126782383115934351323417280259982063617306302186, + 10875591160730160270068431340682089749906954561182346580835990640726775143333, + 3652944244452048690131720651805781896380113232659416636763849273822579013013, + 7250033522805425588435437439711730655794376979662717405069750096375356770704, + 17997263845692540689707413750639124639956079375882845344619094991460142041978, + 13054664930067438962929623940746183076944905674637890882829262026770884024146, + 1186553497223000062090664624055071241559795266243706799023964024401557333932, + 3720804974865066773179990788242864433836168490902711729141383314683364018525, + 19003752726178858311352599466277212812852228428368891919039693927396748354555, + 11166086885672626473267565287145132336823242144708474818695443831501089511977, + 1368472988174922077089783625702459069900911116848906987378634703269489512819, + 5166705521711217678568365958006896871371664816789533039353858785767386834644, + 15566304215144938522531543211275904786085279816288238394366559920757279948914, + 8321279128471838426902604847541810191823856600858594033770500616768509988802, + 14138510896873094145239200989718392132503815638767587400864262443207383846004, + 11020689288735312048281211480914691538177917340085619631160164732621790506794, + 18103483701882021709700772475909291367931389893038031361607344626057669581785, + 3226023762702013278888751706600528326142843281550486337107811234763956451996, + 14143832989706146523048254373240147588031978538816328398418581689787667712938, + 13229447132541490166817130667465030432275147830674433264233542784130393345935, + 2184577999045140018835016427840355945363953230014990607587730839092583009274, + 477165411396514033674776168372174381623670200504244312657234281285313752495, + 5177493492099041708391419461950087427795646737509555174071300754212967667202, + 162987121838956768936796267357867840076518907324250034233989119562079642998, + 1353705012974904256969381894278339937666329184190186645665655512505192776877, + 10268939539863294860046314125420306492195649716582995664288710833241719202942, + 18786842170127821812846841308251379223409841164863951873777593606977628085212, + 5740676880780351821897236910731828656579158057787787664086741849246512845763, + 6796222810610176583640253016064427379720569220532816811297156498654695659892, + 10705301050180556033214199865810926114968572382610501876625543564318365493793, + 15869880150659454389485328494840791287701719002366808990726026795484078181632, + 21509076414763262370254193709619846209714673328379426536946417427169193267884, + 1504823199445777083272979120726712952809523798373781435065848684528355216914, + 185874286088638433409504047417468142621563722838415609738582999165615375761, + 13168613603367703919042664033810152435858939873917874427412955802242412962076, + 20517035760123665455976946118824655352318328264498063685967839258810944855039, + 14799577440666641573576387178058106950299254683982400514838267522057160984548, + 8805432537064262209731388397455783223045068109972333962812706678239466027991, + 18555009837203171062786250448816622055772479634277025843893774750735773975615, + 9734227755456009818329900966539017770998689603044139418403600871579110190824, + 19422838124979053436378103904099977840129717542419948570526713515302687725794, + 6426248421113202129163868618484678291177359669284464574530713661588414452874, + 6590079038288241647623257490779541077997978468391127339253436717310873538021, + 3681640716116594061880055473866291366191873872947427741100200486608138585690, + 5809835194233964450596730860418691521096903169673085128476110681331351744227, + 11091881747774176191134716528914863959336828362897365217560614620821019304251, + 15356797785556737683911159859261760904801763570546520324754205440867115529012, + 10862990213941985624262484113429150844648810761598037454245314597366019692271, + 10638333054462767823405224659224661740115151288210971738086172362879004707726, + 16016219367303803267968667457607419815117436616269227227015033459309158706710, + 15082044150944922169617352312368185463627616302493232066660258401254934101126, + 7128272929151696800350358327918917370230796204793440229479603566374793080262, + 9921571815986165874776436949344440077605146167115329042734885032782248375050, + 19354163978398850308633441351042998358473726459102325674811431806118942414919, + 12114884527300456612293225777095485969640189778934075579141275639010030706328, + 6729407054882595016830197759455611670160623913602730181476478313812883598148, + 8948760538632946464515573498755103185428853338580168223235572598030851577793, + 7540793490174742241667967552608123671841764300669942723577448757649112705112, + 14494097666522674526172262578341332840309167237235910412967169199570121924860, + 3422176839735843643577512702252960766443933154095106059593868758352128430632, + 18375311162549781669655443383955616368297193499218069687611405784560648203920, + 1216941076392839345943715921410106362903415376464465783219094107406977212412, + 11684668858487729154129153798099685321622134855077114566759572657313317514170, + 2429565646086439886257107444069016491711144332154997739113157622608119686403, + 2860131118345180793037544090977840748926535018577770017977838327589784182332, + 9785916955317569401299951855776212167546263973863241139399568006596116682042, + 20099299229705462077759539205952112415265088185603613688326351419777176361678, + 19065056415550943387622420141878541275243634280756890025890390609103726472864, + 6694446982369295310091030961316412809640965167182899383782404147675136871170, + 6177371739752469148462642555075020230677192521597297962993606965867046128528, + 13336051216799233397425171705413019817432261264277553698851043903438362044019, + 8303047140913310262168806830343160797411598890416290381590131124774435918886, + 7494939180181400293806857742235798949020891429469462346548002289869833936040, + 424619977162573850286288616121532390647686617556449648985980184525114671695, + 12171361734459713515602407650777701952319316294372179684961233815315957386905, + 1402068126548660835932371371443103244925219030118796318365315104606268470290, + 17302719696945102489919891004100783426876022253374153022555777081214519411107, + 19254034509396986466342163389278251603973543185212347592300157821264485807186, + 20604579204262711221565642906271902142948120791080535851695570753500225333286, + 4614330290568023967014116061371013546108888863158293733367927166967039617423, + 20612212392094086306364540745946752302460861136183711417678330327971014080866, + 18536114865609641562988812770759740357525014438418135524686174345990305476722, + 8868637192764333745359155553236444618095679430761448812331022285622194148106, + 13099081787400673219867134491757424918132400749090140622350105183531385023514, + 18837906609525522839296652777729470896280837093232859812192423727108087413838, + 9942744204890557577550460485744356036734661028824060316716112001707538167642, + 2819367328143509878504646248429895972325555586289405201223585116537135132939, + 6378968415170612212089025724228493060057569696288093229825195132879777160012, + 16790195669981983459746250689079449909780531773689179333275408539302566037337, + 482470966444160432692764500997760988411438031217845079550668472008675763839, + 16045721213745959675712095981600855176064734436571349914301169840544017407557, + 20489307091806964533792481858769013590156445602291287499683658565185857844225, + 20349551007043735336254173840421709567230668359831461402932114242848569235513, + 21859032940795320920358065233345131801414233759907416819756869819862305675119, + 13749015762483683258627938488493065183824886449910204399499083333470080649249, + 6000235262008578477437851372893643236673865327002131698174406769199691026265, + 875353395004392598772880173604831075599737215990478879269807725993308172506, + 9303563529977594507814650642126366020396330918866687318011909410423488226687, + 16048045713821560465339973035445361548557153291253643110086216962382570918978, + 13216663907656734592879622596318741083575998897394036532409519582763346909566, + 14730210116584595847519437479666769670056547969673055037975057548998498371903, + 6456037509334302824654022642469282367028920926703854020954458118398749137895, + 17457032630819347174188254764839853274874581509599466746120517593662240995674, + 6564279789362509311087503913524048698393915285805076947742516887552078291197, + 11607756822958653380489193862343981327019410989356756451300968477960304389667, + 16159074894569021420535315251830355988071579335278183397490524927651001984918, + 21318483261580896336636172500773220087664725194306294484941101043782914366234, + 14633183957969649899211078806583430338600193621975939486304813006159707895645, + 19383189362220138464863636484778106703238713874726057241442406208817576717813, + 3685395838002359215874941773555108622460173201676624409464977943769857954616, + 6214394231657692917435046018337414783524113254013777041242642753434980160022, + 429036605114654966190140658480071851931549902455772691324774299778134546419, + 15871043243534026252021207504825132381489215097315889635624900731495339767577, + 21211198530176097518555076944455108383474067668892569612472387300806254086309, + 21233023551790009339418416327631067781036943343137622426674016714897998861531, + 14588069297391034536055150768959072733472714327181076389003601556611142886806, + 10508232514877868316115601576838604591213609001419675615867299258097493036522, + 1748454006313421356682891590621306120637773606084132332786908897008699917614, + 16254737008305706031004429264063885572618336716292470244842285039341668886874, + 4582422323682090513802891101670807725271018041824186107239905598136144764464, + 11651961124184381530564573708781297033001808787828921383479148832825700063420, + 506336197030188074891911006631496470998678178221642355710755974161056678448, + 21517936595314105837856810611109210625524527201741847745415765590281397096570, + 621558992128092007050665775023399480152282728710025546868013879660036954912, + 4008205296683839311557376756874426081165963514278698587482739122532637835199, + 14219127006961830781043579545425479089763450022022487842490533340284229278361, + 2365929042585154081476530140822923368259061803995224486063606745651506795374, + 16861020401045891085321275632461133367356721853734134862733719965260700510478, + 6285165725048531739003342960024520813861373245759684105802488704749578653826, + 5929301483884439035786525068676746079401949043221900256833392818256281530615, + 14502447760486387799059318541209757040844770937862468921929310682431317530875, + 9007856412282695610891705582422837496803878945156036629283651376250313502360, + 15216570289744605550341407848778482417692799054445922651390366634630738646809, + 20060814566956807427060449271476431041068053420447646720001621891002037820321, + 14057021682112087183752240480410200111415157799617466665792193256164997770422, + 518287865670150261769895405316565233110161669249187832162346288866192742873, + 11827327624663163718047083444043157284933915059162597636458745165448077289634 + ], + "G2y1": [ + 18968097867253340074033854544884184550661418114696404027942755287485933653143, + 5661361201017017825360842133332836503448610480744021906076346401101946631615, + 19708840386294811113624709115729187405908888183101899073665897165601780071515, + 18003368293789464684485377053927109556895510077662943893746716915217039499730, + 672391077561000160281991800711229107072503946706433982509089570128799022765, + 21209315223070360493213834363151451041089018455343847321391523612125707152373, + 12540686291820950940932205931023614409124851929139775350894755668003377162246, + 18433133051894598436878689727025558213515778971668779413978937450088645411643, + 11293672538500646946975044631912367597762576131458057591245454860993701040295, + 4215026149885710864540862415620346240963398480557172554265273472862145085498, + 4715428582687841610966109489562643396602540463533529156784767321266323291425, + 1910913300402043381029953266503057320298944759147092220132262464171864167687, + 1196137947243150610106053819405501111182787323156221967342356892090037828244, + 10111670233021014678475917570148743450976279116148309837481947726505642728043, + 12860579430844465942811393670076360424117366896412461156190283343004597770225, + 20762293873042460413493762937297710142491081139989683569003378107359647701355, + 10586747616677192985116052057500894924428845405684394590750789455370608308766, + 1507005905758573255637908214470829508320172039536438264147720182507686188985, + 9708063584761361638328176053752653197872643066840626628752170385967429162825, + 6074075922387523318710811942463646698326906431927785776534691942524653262999, + 11265159665589978523842922743706412330870416917471322956566040858850836957781, + 6118458936203391851270038888131827889456655563565665117961127918718486283489, + 18815937511388497680073777576717133672024710446391647013234038211663821616059, + 3427038646323113567719363257771645070747804972403159543925572129384733776001, + 12464565814521853404805963771292111272673359066388138648817739183336356381960, + 15229533568535731243709746137939738538889414502886048931850505709951468103617, + 16727484375212017249697795760885267597317766655549468217180521378213906474374, + 15036963974945953467543996913136311890910557802523099958248528741794957432834, + 3962317389705619564213407025276618294627648081692521478300730203817374897677, + 18938259518931026571050180795672838699208390390917477262552436715427821441533, + 8128668100383304106736690963746380832034651586285761454876014994358347766010, + 13960514790508566329804693635093546927808922554514485954126345446279049029284, + 15030617573627986977854284995088903550658569696812069122595591069749188257962, + 15491351605040989835654031651748126421046576685865653138953335697202469887252, + 15957370157878982549462006839827620100511579409568780380249003896446559572854, + 4695153506987052686385466783620845131394156352716305570020823670948918244200, + 2736676534023842761487401609633491578564239485803776990884836272466896468078, + 6415180495920617690257011046714999151822637428576113675409973283994431811040, + 16288537795999407982158134695199175591697240367634853542379621947807894328413, + 20642513273988461764017059987774782305101611961398286379072913486358514907424, + 7224903234523362716859837341766075108864852287272620982296840377641817424074, + 13396974869692980032158062892111135588534677092434896041135837771698231894294, + 12134840411870891812812494960085470541580625850836952192336583147192851473623, + 9946447603419966026677529605932170818340366745138424171346269289547556154858, + 6842389175433932501741624913980213677703045397858674328484681277280985889689, + 9815779837984946569414691344205194832125833151290526814906667553650611703542, + 21561058776610520359114739464501212537109913245108087619400136073658317017774, + 198173876416825745338038343239760537367087412390301804163287048983265857680, + 10180173847362060668484407046060847820686018471991865896371310091850399827321, + 19122988109627506587850728746313117982906804188872835047510470241085585636396, + 19804470431547976995467325770475378164766256111835164108366808772087600898145, + 10035058938654403340899380960544925632803321066136260391733096006375548177560, + 15229018856390241838051192567522300981164104065941454996537754391859373296602, + 4756161422408662759696349363485467499921026379090429770022453392030664483676, + 19400178174472984141618725040712938935547534920030449007883881556571032363329, + 11495705679239936119427482283580620450833890153855234313443436845765650854466, + 13537823018301506822542368095451659296228365774830237979472085385367082466465, + 16935872688498842641994693139833221698800431761467632129091899930252127300858, + 12385954073607545574421353010931530022897673042454074536119829402759154593679, + 9477094361282545298381157214920180447640599696787842495518690688539555316623, + 4133219819770197811052946415847110043763247656042669222602774028715715185553, + 1090672349573567569508149014609920440583120423377273844352904239353788122828, + 18353417688324465326604619010428086051053326850972540194944071352010342211775, + 9451370519901661958777312938615285748994826224794388998010021074549157067545, + 17985766113228818554410599827758464058917747146027539762314016117940993565789, + 629382356322783828454499106094663302110147664609648475132886156832030153552, + 10266599843356256575939255599199587587037830431273051138663023939780811108935, + 2472959950182402570263126701974037630572870992070530251536786675989981747904, + 13489757049073207147482585551342951990292215138518987087788834554171936871729, + 14462297607317483327721321524411901640203286791029839708907980463023707628754, + 5710421778534034290535046794076802759309532389932047832040345375531176168829, + 14727356895407021250500452648998086555361723630672816730864589103581549303915, + 10576778712883087908382530888778326306865681986179249638025895353796469496812, + 12975444748996510764287992835586503285209506013718303709636277534603368419756, + 11455600697554802885360990595014223973262708724736114635753047689378024545255, + 14317677785205376593346637540078199442740222486481139959657224301903822374836, + 19653771906124489473713165824596900056508139823222874673597454251183550793005, + 21860851119088842141958803098603026431428482844748375004715752545353021322421, + 7379161604680511491978531042896802511076016678776572191380509014955756140631, + 13248939558546781635650567764805705169373088559731530908023244743843207921691, + 7240729899778330718591698618955712983137224752215256150940224546589591271330, + 20432982252765635645116545047863961849856605889838248148416853935944195416955, + 8893886691731007795802855141391660864699095392032620900515708253112851531222, + 7937708606987785559763966409799358086465814137765222121348754902054852517395, + 4095165345051219360780587286732761584081341597545898214711267841551555549893, + 8444193412518739614622451936893876581722537449524925538672193704648018934959, + 11474753921053463533844449456113465953892219210488640332378751204324876796187, + 15544891976126708444547483402455858458466053024449383569110576641664086838278, + 10533775257851585049512242634010116028131130364075802159725723968838795794308, + 13811293812901640637034929667970010311572892486191944642516483726279145081661, + 14997917894493614566089797328517375328801094959789823281739940289428187312900, + 8419322626253614958610061109337932548225855795340049006428337577413104231591, + 6496754123789516438308123474146728143753828911158329502010988026286048449510, + 9591979334952129978934486104912637502879748632401817316037029348385526860174, + 2517925196309034532380945343353861525927731746541487865168142113951595900281, + 13732537529474812855656521104921986665966556809388703475810564814088173548500, + 7952100895539184995978585786815171563125645996251930064731224596778742414071, + 10632353405433832673646130425473747041829256885901794032683953728293232938529, + 21778426767599203191826082487954441570825894074911548579621498946576918714697, + 9115232163801585785488996663620326145654100013915716391407602673220453726829, + 5725842153379383921589462837590915882948636039450740760786820145583425453717, + 14626549664492606656453098372916454696376544737420156676027292541189874472868, + 19281123262985977396896281011645338066507379997604918094078539491940835558071, + 10190605348650042908406154625891300074993590852935921709588623599053475782086, + 19097392929152881174875088411089890866993028206617489515322558155344889500794, + 6170446615495868161488766967669912606573280683639945062891043369896563906254, + 5256554292991562761667248816065896508827423234115314089464415764348855101357, + 18445894882345798042552596327657010615487179987950723352236969846152947478396, + 5434620404144427884631858067678770197351596515438312930450145856629571601445, + 7432728030916556594903253070485031957526193804298696224010135388229715846631, + 5569739673502653067041305690437107464558687878881819334533374032439430976352, + 18133643376513190205230885110926279323711443633200683202725365546152641282795, + 2897956521721669415559651570044340105558668720617968270157874692889674865478, + 14439883982739463253782820073542177718014081478024756305348782325077578216449, + 12350758075137283445454478915256736179825079967581332208753280005710696532577, + 5108142851998357126916821306394525932146227797568222306353138452670579323714, + 9075324399402750756158030360070893260525174254338996708126236692562793291855, + 12355343258048631004670705271107726635685718554438672491568752438400906770689, + 13346281233477235066610302932936871014092208825665061566431422070907048075948, + 11767302002144084642833695416766908791936532018651647770332319459131524092692, + 1447438525655515081079630875353476806063758129095253987808766744057312558717, + 3786485314037383579272421202823435410229176455143126622092695452045516116581, + 5873520565998122640774253709468845083826129197980545879367249660359920981815, + 10502675679031380770021331101736749816785939810119407771459016271392601228799, + 13550446183522744387412590077704274172885615223723428436699887812236046957173, + 685435161495913207569982768880304127536697589132191371680245784514131028737, + 16911281665844149601000481202073018524809573693939389703162654014926641199289, + 20546633119495026777386729234932806546878001604397891464185167687022728444380, + 19015522182933721948342397518447497475465580074745046765442153689627118951740, + 20246590030952734403596169713547128836622675102441671493935242544853746353737, + 2755158880469156001007395154971863856218172111000318712073484116889784499468, + 17478479175090117650117488506517399454811215965098821161412407641400760822710, + 2698398568262266738260178339051254718897740381882317514645403020783865474887, + 8589690792863225986668482066667610564954409227406711133301860665960659900589, + 20747911604131798456741437095022830556276858181366142316610441145582215447131, + 5024503204253650741767613260467675045359208481415278021961970421025207860216, + 11570599453963340068184737787104852121859149815775826218499543142694353724454, + 1464358053792045166855740814068724020538737441454637497761717557558902774016, + 4566017103813659772209567567652509922374600516672465084898995423093672323257, + 10891007679879083634470916653424725253134102081206186509159398904788382260802, + 2433271159729628011904448046124338517209343284545157871933328045395710208456, + 4316182688640878514803455718486237768762505459454734861741340849130998398540, + 19051569730234783030194592863331015938248324367201441526870122364940590941480, + 21565022623258350584099627224199690557564040841853974577221108886135149707376, + 2239645466745334866400865708232339757390663773934422159853738458059643794970, + 7918128832168718965172304659619406695926701498668421336605127210412672335988, + 13359547783129155542529166480754796083631692020396355933036669241457812966367, + 5562256060176815972630497125499936016825534645936408164128632506050581473445, + 11091945292265504538938221393102801896664834939958169068284386788680248018956, + 9014289808091773814719383880368185785885550698210601540689240439404408915803, + 12184379022459217096585782536965269216795042310489267729861623914173277685336, + 16283114912518426817996695867573078482108301743523568925026982981809060776142, + 6319942476958545623863182963463384804626344062976692160276826218030284537264, + 9242281171871970834183148352021285658568332986969387379396942083725710222144, + 9213379225324375969163173806320458005537601245340675136302960164097021125201, + 15587504941299754621610294618526996060235709057179179406000103472095392038719, + 11666683219691991958269355392575383101244848933880241863614208515997182820772, + 20799491176555682977977230823811409252968306687721053970095934314145499999673, + 17908283593849320483487298434149502317772931875571919243457549393539545142653, + 12568048303398586281879891256870977151047528045212641466170537803517630218950, + 8673245123330358023882476909326905047688076976228030421263065688925439587278, + 2174335865743951132717295346480745255754135617243174261691071084378800423068, + 17256374188744008793654026245786274411203032380747159831138324254606457510213, + 19156429547098333552730560866052532623264747043871722770531728286191583268984, + 13691833203523170514906898999240054352777549970395969967820349384017999130358, + 376888958336102392945338937920956191656274086247294371298956066730743293459, + 11202274155224584083658157419267652549156301772838845348054877142748490385126, + 17420951384902980833000003109017311666959502098608358881576668350659208370599, + 14794804934634102972464511219883473442466203231754146907682745603139777761056, + 18080235419573395363278985537259801088768133391584360235133766774938097346827, + 16381567982113249064976062597482393531076528449204069591609672673541334956819, + 11471526823481415603654209788801493790621174383096412871026655594232761808867, + 2876357790878410098467530521764620784730351259052925249427203583453012972236, + 5176803652428112858134020774938286793679531096712021316558795606958422445775, + 6603177804562133064581324655317412822160275177084188254417394345791220753948, + 5221766703306568630121881054961416110915408155639156809163390343713727427325, + 6946911027361790126049866780307248009297903216970608782994142438670886522070, + 8748990031933031479264335356445968651040010551042242624599845133099171399249, + 12807622275707030859011149681857694626427852098788353525442815834706710199274, + 4672859274989757543535065323710054959604900690394887826425402169066127862530, + 2424026085069825391033580472035295648612530401925277718375456267723935379690, + 10847281460042142598816270676372539992803021388916026621484136992759522018115, + 5163443526634700205638666313378686284234659189339610129373018212614642490790, + 5232191102319028239097039147966551988902868957238930175913411970265305732321, + 10900980854218197481501966243272435308822088188944312319054456293903610310681, + 17702738614276191445715050329562974927852314859200381036171494587802531883408, + 8902022306587378163012985663083783148781144500978766218871196720093364606291, + 11412494806091777564915610392867418796200589451914132171350253545714399012718, + 14021669236222066817978284484789457702026644607907427560818486022558776481890, + 15062734216171294065071101804759345849132016497684900585956969843512655349585, + 19232690621576316199487595886715769042962368936523487613161146409817458959457, + 19399436178316165417524157780862233302323855835693574339977106278123018041456, + 9880617184365958230339455209899539745963015893014809146671717423589770216261, + 11721331165636005533649329538372312212753336165656329339895621434122061690013, + 20881480212974656392733247983260002846720618903992756897852873460001749653190, + 21771084268983950869047634974862022273402966136319240795470369951458111825678, + 16859661286396186113420728441519876900070580483002074363358339671960298627434, + 13323379316751184198423913187756765367670354109369974870210043691240101881139, + 21218166118545889632529142693287810641327186929042980516297519317440456986235, + 17932375247592326066396042368106141010400315005281728347414521281210841626390 + ], + "G2x0": [ + 18365931514869092612260933343012094946038116831347190782780094018746688809344, + 2264488536370313438015676782493042824511712003635660499134753082505547785052, + 200896809724176555912214810356337687948426066255343053374058752747451673207, + 20479018417039574915539595142426318298074660245365928299619649106122414249273, + 6219949667714653272126033840523576620041266246711751408549479175935883762814, + 5158849249017764357367123555493553794013299475695582090595438540449792024394, + 2465488771340572270481637869448229907759184238091913776130352521342479103177, + 11871610707498513614026824626354232510413054289913097252902128995405885926931, + 14298535851549699567349814442830355147588541976754506316848357807497105504150, + 5913966522097312762684248075293796157825665268874621521815283034218656807321, + 2616817808844609924852642638504457458886913225001596897385196425952799043171, + 3252056134942514392551718374005632714398053416514749213335421244869989200166, + 15624790064206502667756020446826209080711344272800176518784649088946231692936, + 9933569135540839212218309612295338064020425584573222940189011551715588634012, + 20587929387041036024203635884806969165922473434981288783401522660123880171676, + 20341489339328134830540134836986685484659874606544620785987445909125566172408, + 2485403698679716981065019155637102549530012533740548993483508817326201526689, + 13629114897952053417906539938577964911921951515022915637600461928677325528252, + 12078301631861680797106834692645488698204323121346057684350820425993729289164, + 14564405361089553545827769819929709155278465929459772321312042130258066083018, + 19324671654010899242071096366914115455822022307631779966354004908794544400894, + 11981678503058913086386851692196220408313953386456961483032201277155791004583, + 12033855952470059571057549431932197098694041431065876870332622905041983729429, + 4140708607947971318126357909789803787638819949493743443129513131355943050141, + 2788890433650529662185345513603661311949628314799257413639420290945653658549, + 6378325937030093396233343497447575845595756329362598238229568603807864429310, + 12345624066896925082600651626583520268054356403303305150512393106955803260718, + 2839204914691120513310090364786159537060575893010743470212425591240641262221, + 11078209160611459937094652514027310939991254605128750392676399180878752874446, + 10011210452673288872971406038467729484880422234104651982201937206762812304807, + 4791419602180942728193160408483019902702505733413157707940921052182764872287, + 14252346814618955047928403908921414157122808955993210059627839578124288715012, + 13124223624110334292479357368824591511349189740310578102336209212610997004111, + 13380007740614884042676552027792669517352976714172339801095960593301186558468, + 10948664731666075299632652751022992358197769851882256629883972513849259589922, + 10597453999641953242099856116330180977706327925353283597976844449416806659483, + 454574831213596429370234697053993726962126524090056882194674776543181786840, + 1306773148321414164986716178520473956232432910033853141119308505774460347843, + 7888618543244467442382435429540487983115210183058629282976348231414431872720, + 14786640071094433685754759385543320710083815148806936785724685508855873532085, + 8571095510928581939659707223797243015629876724061815206790614585856791291110, + 9289814502494659294201636727878286317594376940610257439028735980009219132148, + 4348558845092961639957591215265735281815977408460380014280859569218137959191, + 6786044800784335826632790808716856545803092910774295059250184227486779370528, + 19581850476684470003511934413615653301897975721146688582876299040200752151008, + 2107849839712525703650312883703759056906548247032174130341003405937918420200, + 15239218334197424606677039841543973637518507080684501011452529482673251251834, + 8945283679656393227634960685090769576942152662279982007056944887429787395446, + 7760796635005981363348828475643582590315795048678466122238198482249363884558, + 11442079509739892047195422828129084422361473444378456757802997603457153209039, + 8198197634290639555322052407476232699891641457211856758911101094525731144652, + 83904921068088499673627392792975875036241988782533740337078659487824060111, + 20461820534310089705837316382650004861331676475666025550713688395749386683579, + 12041242787136840614224004059569305357588387496145111649807689250206406901341, + 9741396506625439372039171203340224845623182621270628218178892578947495170595, + 73622293228244162092566494891782860242932992568608353224930187548264463587, + 13220361572123530920750121847184465332944224869957138406114042416276868018720, + 850552766577157374724621938905925371059953822675600962003519227218775849712, + 20590522738311296419574575072240010525934951272777959329126519042957800091983, + 10801738871033577987183393742212893503726430425704910087583963891226953796668, + 16527396813936314699469064222550170085982136026953673229220255385328568480582, + 16137896349323260557724882795159221376713634158848474373792683621932405115526, + 17673714925721244454372736380733364508904427078538404577861043514762764311161, + 9695469689391648568711028433341279735342618342738397905204382840434564678342, + 6738635723688478940757132676745869736397910425351811421371560694470729664002, + 10812371261717585165863663760744463446109764957097081343164168817065098208060, + 15409962890957969219681198692128259692999503344385038253547781190085576328131, + 6214796694082284423006229336201915300275728865673572849739375925269063772583, + 6721885892833533345177591131103480799286323597735075043514348027731537024268, + 19659023877273896470507910036838019529796231834454220503085827643206375823602, + 16537441505764291820051224792496693656364307786776722209178963478489950926844, + 21566093092246231355790990734824018376039219923939850334873409292796570091408, + 1513450333913810775282357068930057790874607011341873340507105465411024430745, + 2834040497794917645508066077900205681738116408700987232592408263365065527382, + 4120491697885341438273328867578609391753327129789643019173459428403596408403, + 1795777653231597313823573626581993808387437009653918595824227667874327444611, + 5563109716166703377606075806731112350729123336658892750454638794911084490794, + 12233583562936508624623932324185331880032351752277471202728865419977788895662, + 21065141958050601296937011087741705663431240629469795013262995098096048088102, + 18789009715283011768896844298901462792263615245598075400130859326346324257527, + 6962426106362284999445797731663106728178463149711878775995610986459147918049, + 13385634537110816146075167362298676524991671876402239374938742127033540093238, + 15177653098198672052617581857884576579639008263170076029078955529937590593556, + 17843788422655299923170619407088164674192347050927261221164814741033434585213, + 7516776730978555978581911749850208353431601117286340102671328559667046564312, + 5065618459992826958584571778555363212819297345800828471259689976412338895275, + 9025156380866995925646548378239139916167970656736496895947843887452028312701, + 5103341842558622180040404840499108796973640022082266333242501798599728008100, + 15453350038377438080457495849148484622966128728427358777906943618363003749253, + 9198942760055326908232303066005098228559653763524367226986169430297972537852, + 20748223994276786466084749428941705272858007702379439535577016201249357207755, + 10319113337330814437991830372766631793701050845454299824016371708405713780604, + 13823002048386680423698774078234689319636295032332639054473209424649392937696, + 14829303193996083604754347607184395676815645658635300482358962528341539435153, + 16227984862498572546205047554307578826556573837964171471941337925867594649379, + 20541234261338766433900303435796278523012250472310388963524818138170335169457, + 13512809956514965235425552907651904286615025444806797620294794451206310155183, + 3819755647892194247500951887296807134443489346449967387504727321014923348879, + 15072020905863493772312471126681749556523602015195042276767341986014237712451, + 19971298882176731214267442735068120366504610181884953090056095067296060783422, + 19052677405298699704156942333104669581792166783569412918834198071199113653660, + 9320505397045328577229694232849910721088563475866109707251840448069115726702, + 12728244201321846302761501837228478431906409257357312193393781877109034477959, + 17734465527295505389694140171829401644623728804276528041263602708069462899749, + 2636312628811617493004987265084086710856030993405631998745568210669091746439, + 17630012707633487084719771040092056597827399393075959012839721866880206634686, + 15016411745228456000390843451807665370169183151745751857293180737989705878629, + 1245012374928079300457046537178957162268208476005557982262150718981677392763, + 17702422625581524867986137522111903954906120512211554747840865305590699647223, + 16132130587712268153413859576538639624161418663865311996102073993958799140761, + 8397494249094907063844858091284032676929842280251151388617173901153734667249, + 10355228377591189214247507915956031728907176612814797946067825897986574097188, + 2239789587981978981020920098329410234623909905049303632685819357805710822728, + 3918814681806325762880780798613672555128090660817912357333084579291816507742, + 15446041361224171608462614444357116251944045643877045251834060661124401052469, + 8869756165219719338320970531854560469557980363077973177520704289170657290498, + 11555138798425692227402592624617661352904260097841244557840326479269358813253, + 8760889932526253807488128068563813397634368019459850118195022718695174779524, + 6155003590895006153198585551813791483447998470099322287871782057702743652855, + 21392637074640269169610751892385650891052054308321407470716231346995977434430, + 454566442147800410179890798855328638820503440897322648908980348298145788212, + 19974530539777848762094098616608785204814332067793209599542489768373301759422, + 12537673901413488976022732694559403660565095083955194429984527002181624936409, + 18317393455059494427028681810049998577837677220322646867734612669078682868404, + 12734218989779977835570346351490275017310208592099459547263250662866432919500, + 15686484365428836828601883278742085806006788642130533628110612813662214331767, + 4979548486672628926119597731536673023058925620964127244903871039538150024826, + 3445586928701280109052201253917425627992726577614466352720303413124041729587, + 11576350320105569908685029270864929204442611503226680677895919230925069207949, + 18573054050410200685334372905399341720484173078906562959439673453955368788833, + 7441726286819858314632532901986971515106409264284715854536047547086650859122, + 18630586678691712083430720260599252895069923094430235295111565780113898683436, + 21672287626176814025995634398513787866643925353268173553495356909667300560367, + 4223541897218034772489308554703631900412225505600032161509417263929627799922, + 494184049120368663808350406804549487382517587426824637494868153858178477941, + 12661769106609959406815148020257637370770943538134762919421299103762150053345, + 4908477033626173050727665504879410210522626518460529438325875582488327715267, + 19419004138475218227893921649613182384889551270116632296765843633358852789725, + 21820573574421856267922854958239128327287716941331095279418958497153552790389, + 9288281135489488472692560605678577697053805848565742640349891342829489217763, + 2044872546984175075993681893286075211280341788407374917952012872779058796192, + 1802566820518935048422211443943506588319772506313996966422336311080888473432, + 10753633821437406936056867919114378961987568905674793813837264752518130120411, + 6437904630709262427076771279303527374478637745469415580882092156608085150344, + 19228199232387808507609727756320977967906711337966641834537345166769568686572, + 16592967278897516143840106896440031643448345644714333253437457784893622859904, + 7426122034337335243425597680038973161264739546815343648954031461036931755830, + 13220290284438035158366566192568597019656669943631188077425630246136748623336, + 21725691489983947042608453882480093602786810692171030512847434689856594056071, + 21281789044836843180498550503027105455144582313065738378388750544318016425982, + 6134617962756568455932173094690199513491829035806626575852204114871458416978, + 14339843088117309194401831174363219809749560579721753226760569839161147428684, + 16557828034040985843124761825906048227737235977672730868355331285937306827169, + 11963879875151339591869410321261939767206396705751817032389165076529359781274, + 19361176639528310920205938793794325546634538201671433849268937879371315623961, + 6328776563933058463351784707460307891410296691416026733384833617000436684698, + 6346682876903593896962369915426226898311497740730316297600845995193167546034, + 10497613591772439709181017302350015534585735946713038879237078432152719224019, + 17988083690400713336639611488036295241994787794292953745675830194817417985462, + 3108938095160154366739982185293973232094645144098816772059769943774794650447, + 8803712070727938135326544295841131471517750015314295362880080609830438343476, + 13727337404789446889413715457630837815186405917423662250574955774687068330158, + 18579992949643501551726833006415781848040935831508982877060290346049673518001, + 2382425876723121107800112487782149588174663547482320983917011911612792198853, + 13449118118356951903061198434056307721192601736113273983962593880345790840785, + 455731445451576535390949786105922558075859983907628641677835089814218044433, + 5386131811811934740077417356789820615076314357693379904674490640214440078403, + 13555404565236616136169845317996452956494221574071428165583519453576182251620, + 2105550596641406504449123957639171866781005107487041933562802923945487978124, + 18280291745918322060204199604298456969024661725018018016575552767485611169376, + 17496338914990926928967013092238487175952659732051281080333073152269921949657, + 19327502229264802612009959524323046881731659190417756838329941357111855837921, + 6328090823179951048271088494010876127341614179041678356457551418071861151695, + 15012392724687747812890141395518035016656567994140268101962185717293097939736, + 20846672226738361627512370822971075892249040638200113929221057960291861729055, + 6095429006392825162358554192721850823327348421103475408442239841095599037262, + 8734346967381535301362454931787237503766587926482837886776029429122363884630, + 700037584925559105882420540176757067749445068608690673714117124506195510229, + 21242822480574167785020479076686368465850689734473057721483580417426530579615, + 17363866289100926872031594925164484266693179012300769063677778241094733880313, + 2391345085745717787586210231595390595026583799220653527841196749901710284505, + 3045295354179676677849867948999926981809716450107785272685219528794174444834, + 14105234525990333438925162493957965264053152443696001103377378402176244852796, + 18005059545864874290954801083609866337278674551269200979000197227129855942386, + 18644943348344790585272518184932127219629679157597094316427334094237269738600, + 14587687180837264702081768909183963016484365900743476233020027168409743575370, + 19125738320200004777184515197212272561192566329996294693690311408058293809586, + 2536335181341489645832312321614831232140105990221953454565250755922334011706, + 21516959414663183477161787134470283166594799297503429234372339257315734123527, + 16913735617620267518790672922054037799588901797814379347446101725977608471857, + 7179095631292278984729640235629216372312318848019986361019177768121107379698, + 21301818536605812722823194635756165446131746852864047913475599504788403758756, + 14541847050801317278711064427610283857159308852659426780217133385147192396128, + 2443430939986969712743682923434644543094899517010817087050769422599268135103, + 11805686464564037728868053057875131653492475965747282117656468411920588992033, + 17976703493570075145378060352934321086235001377138081266562300107833949822521, + 16308632548750996586097803077517333136075334956979723962613542668227664294939, + 11848823194768764086608711924925380732672801151693595817335612627315426596223, + 5776559862255212256001493282150023705079197894618898974792631862701098795352, + 12372807948585627152011347873247822621530318805284976734954205676339923350288 + ], + "G2y0": [ + 21760225064598292598109136295946448694742398357854681562699679980396051425166, + 14874919622305550515568526617169528522147070432223742891264565240670568164497, + 21495617400890993348893909687184483331003603636513812857719618360307739752258, + 18294733813562188333642306750738527682233441478245466234826339038413197108102, + 20973342314320144794704402144629835017906878048524972269170222385835988990597, + 21728050075109952765283887771812440281489089247024285081735552447120153309052, + 14302274557696761751810683703040095615447822163300545781451395987360210204229, + 11303858708783564892740967202582628258628169225930887124073578980208720295675, + 20530157538545758663606922808086827633385593688919526571677955163347914682244, + 9575987743055256279858351980078220921290029296718372125035457918769688314404, + 7972809521520820251979895865991108850581699287614586875845458293875284568079, + 21551186949989118622635557665998123482817515274599297197806859380746845220356, + 19488077321171448217727198730828487286865984357780136663388739985720647978898, + 3543973950619808964428707965193769832159915648534091839492582520752685518079, + 18117469635628828786472523170473826212207747578637224483457912890937392075915, + 3145708085115522099948117952987461520503331619564924237963287870654283689240, + 10746599879669312865974643055221541413017496529649705150134036136868079443818, + 4572487487480618770110299110524498444217059341677348111461748164333040044760, + 7048828541081679764839542390833460659026099631489649327291732150382864602569, + 18269702140942631494101061591417554054957757863694242926230486076304135809952, + 73004118945779706035055665697945688123763831841357617361717130246598643724, + 2154094957111248607203672680127355812736558763296137648888814221629696544303, + 13206687073957381007569405998039344154731105406761332588575962243038777072583, + 10555033719671967065098564432077694155110298840102543354312528819329758288769, + 4877123491179678130036640538975027247745710827165808009712029384257574646577, + 18276504329340564895045294992273424610941709868707988352159387788161575457973, + 13790151551682513054696583104432356791070435696840691503641536676885931241944, + 2031113207680033985506705929889241061543749475871417603889653589459761208583, + 15353266412375416658879471701952379528590829658791694205657600099001591617146, + 14902865970891675241821346253073815951697768965235595327419772034838645240927, + 17476704132180592203350283879696804068220732910505994824254352236785414960151, + 10071830857714014039147320163324806057575859056173323894532917560709346559644, + 10460587797427063306766737883388427059245296329078504040633545239689939835260, + 16468620448456686443772276482522600812800837353895826753363425853415626031564, + 18795474189508606691662022172265339449744508932670802117786238148827527317956, + 9426119476569270669287050986120212900317242054503510889599566205342053090192, + 11253071111120312871490910101706568776619479863484607969906335424962920325928, + 5532425087728708852980096528845052655724223846736610421548139007964620760630, + 1168515780585523248680810084474502022242758192687252577340566960085409888099, + 806893029439617500195508379082893309299881089592979849925429635709768150840, + 17313730575336848827129508943097136531754351823746628988359011270157395188054, + 18393442982065292358061252042291469158205475662862840644674934049534061690995, + 20533765002948593559891697374837033832695459775822321028189015188373928839976, + 14504488557776949580294978442470498894137476771301681301967188725522901641671, + 11704251513331443006581891505427702431643807754885091694535117309149264715378, + 15540220074236612602083936912435773510717467486300586747836080577665405584974, + 7987036627769384258859244402106310072136682466512286773248717328373337823201, + 13211028306481861388987970045498202236979470879680867954513067146541747179265, + 7120057125329396904555549475161480691785776103281652797285510460525156691898, + 13997846426758768609665413549893293907918315278553089845733411881054794516627, + 4235451872741546336515947567132583436895052948569531554551940659752625222062, + 16044718736216422063144393683591252860377928732516838650735276086416779904911, + 14248279195283583480548074172769141738101406409031859198710266127873000271045, + 4520083578070864905248425459627273264407470358824764821617004360723472627001, + 14452604317822855165720175144767391508729644120090586963307379938745717340133, + 2430247701221291883015067430294873994352708000141035892070736762359226582923, + 11049439363428178909828467076837634681484636387960554853946390504458898549016, + 14536784021629588413897362558898449395104609588226958937262271420865901574160, + 16305938832465768387146665990177958421851472760149688778575523721360196382586, + 14545069268165397601482227950718263961050589601106705871974260378650205429308, + 10998288128814615725876434189478591261015987873175475265668689237711307093559, + 21285886530186567673583198057143184944479660278132460798583328246298856057901, + 17488335011708845990325743025520987093704191594271843420672600624334694359128, + 5161692474937274181386502231016388376393577264394629315509299285534171389976, + 19952437106464984466144152013496402452697522822430351032329981675288834452399, + 1404352740305291336715557842221350464940017740178586754575947728346574849346, + 8953287018295400840490066084820483577605428148674820030992161202147285270275, + 17478887538717806080690298495464945743859292414127554375375622151608529848861, + 3069367142800868810559836156340859823385134805218871608378595380422336138814, + 1602912122652934445080671509373966218829744797824562928373047501242027894236, + 5542210462136283700759952483418680686865238601127568509231784310772131602437, + 7460894417493896729949244015959712098381245622587552107220105731099491427330, + 20245151454212206884108313452940569906396451322269011731680309881579291004202, + 19537886349704135054411189036334488973931140049052765532390874276186701038223, + 18768478964768234388416373463630705736247234378827018020728845027422770696786, + 20263167515714545060677024112335049103570524688451116362154540095785016305117, + 14959026762050120772739262294906519108792945505677277299316175587419840165186, + 3270378321704155957479763576239847313166162840465145820178014139390922501458, + 3051402937792372315480611653439850734100347260926482317221602680166276154414, + 582858194608359141771757054040481324936194448117860136892152757632482173697, + 19098132132189775374932954741848177083347217259191584580833441187407854639498, + 2884054209383951286944488467224802804091196100643239868864523935395112773367, + 14371847168297187634248846186079618475716289471627861603671006945369344843121, + 820643489088847927440193965304658427646920265614229601851090719342588155027, + 6083966317333683115455825953934261372227547422894233996387175625502633709346, + 16299746027004821021978120456882607441406536084181657209409125744156403432255, + 14342373207466605734996088318528667892090325389207298940312707888243795141948, + 2953579086196026352413897497781103497624965848835227247140199238001467969643, + 17374420628530420793128950351545451585289454432965202188881395802644154727050, + 6526620518237399706696027372630431832694379296268320418126169075324545628817, + 19264779732924654337234564955971653280542247987596552431163869486658846657081, + 12092178968168341573252443470098032371488906139583488197678228325119318691074, + 17201971871716648921573586649809288232209063775464590958424102624795057346905, + 5873054385008023635179741797915535278057730001411819024071671081527696854789, + 12298958590714771493956363896151591783907873015727059282512358561651611016643, + 18392460886247417597970960088700174734512861385932135273737055851621241793419, + 436495861494930647165415186600305109370700705243182296750832310286865746776, + 12698061506396190300244043521874911272193551721809157633283277555451010932444, + 19884686647185568791556323625472381679561682367850270860762149611783342864288, + 5278514730308028680671632091212326133644246288228682076550704447346553594852, + 3427556862833396512227213145058237135387636307567605621100318574617632076578, + 17716696522451844512770855261912100432073200611678283185542977121335221276302, + 9315223318351755369682015864839941733287675033789393604792801123520012129980, + 21380655003045951494626411096927769976327908633064550950976644921910192660054, + 4176244323715169157949860244064929422348066355640304033039652090368263943720, + 19016393523958479193929506671018027722137634241038052491383256678625850475664, + 15465040869692114519670567821074144945096466382974160122740957973999030357612, + 7476248345760575262677309887504508579798402428949356808563031498690152871942, + 17730096737022781609253454653264959768311444407059233077339226099229649516896, + 15285628956979689078369175429429200857253773165142358433119971973633206350397, + 1291871628593397005522497804012815399797174978366790295071682974264205458422, + 14610633342964217746241647845070215337648024151849624198191337742993574372593, + 2368225523769950655457368780373059450536280985197039470936905932127505011188, + 10454278249596644451350894345622059218989945974131511990715026675153755925897, + 10911333949445475401918056106923187519704625974043042047384087728613066209410, + 3327757342608798273403354646225694634444590251881588779059521150632105320538, + 1546517107865855192006372547903767689103635450733227162228445987065770350677, + 4636070373363806241891088889779572046540501491239327624081786788482793835025, + 17280593666807023472797871731800194657782764735961713456757774660794294494349, + 13045468440935924936737319480858880099228229620370313425083670565849861876733, + 14748563966833279356409376229597074134057338766037206549015444396915345878698, + 13708595456338639911509119029686054919762334313062016061892499381642600504594, + 7842045849139628952740994290150012870613503236269653328239290990207371146041, + 4756191507017037056536003446432963155433139337915402598975386218505279583941, + 12884466897995455367255694077295111333437129522638286104650661001358407075083, + 3081105067856181401992738154547142528438559420266203248636281087608283619234, + 12620315262970131818475103625318317409408579581119889519302506372523830142199, + 21148677212363539148657688160783572146769452718279046390154185117006428399532, + 2819420487700261225246293744569925767346412966873172733264241612097614307589, + 505385584435858720389390000469736519843279397524111580177616715202404242972, + 1679912921790563327185327692836705495590342514103820355672810637495607684507, + 1076615569132690459319815668501293856006565776644024193578921407095424593694, + 4878126720525392750062909612811274150999078063891388611903389377900394843313, + 3464479980965492933832392178094394811175104694227548891696772752598149662990, + 10061156160890546769743257920109193999155421794320929196688332430091591397839, + 4411429369064012533774848098069896891064357451141725188131407837541063501378, + 17192305866099418189556343151510918713848535323037144952813006614673124993050, + 529413236203775896251485133651131662988125100097575078206316164421756541928, + 5524686976034248206370416546876458595330886008831887201923063589177256410549, + 9922235464665344972206286390664546379662292894038923790318710760981368602447, + 21624708130613993687876905730813711613050584586262196955974878488883971357550, + 20448703027404506080768284343530734626804396513863986051838193528290875358462, + 5196442347159187410846045523254570354697058017421065475261441145732676583858, + 185005392932418116559214466311134383327539521921765719365598421090223115630, + 19902104297996951939118688294222732083431120811271735138656840701252738396916, + 18425735591864704335530632550499686150617459509421082639088367621221627061834, + 982639954624542814929721538570927646318411492528126223324111388714363171179, + 18368189142534161849769698344686152815516101408020380304333063329488664666874, + 1879657727125156071226322990932878531682787311609733759351123284373241242107, + 9827974925013331806070187363032421707888669033347866038813837909120333729006, + 6057895725834009762604597147571021215794253606132705520780875614982233758103, + 6046384396628156558153268520085257900432006902153645778068368495073097017827, + 8949640353600011747893128926970274799898312215454933979173080082512305404252, + 12775596875836580367667197397669976631837296658577367651254527663242339367629, + 6565559009599655752348729795698499788737606511261261404528119091448841212424, + 13967437475673850146947127344174047713271427924343178297454774939390105270774, + 21875064044363232792241110576508729628349751990693785594394275473285509584618, + 6732262968838004714352311272767678321545200018400411710709600368352097894769, + 959348921491940475779913228089799296880889719435980231016541405964178555395, + 10900590699921485648626175946711400216337317311176285771953445775303878487696, + 13123203492284535363237384963750631410698341572999884615051445255978534953281, + 11918467179704786952205733193878521993862299846500371948099669456927716178448, + 4673909833822482453708670677106285305954435808494035165968263510495957171259, + 16084712575616153406742586792350791886289666054426310479378313109701196550664, + 16767809902310533112770385908372758047199817212364113687968191501750984425338, + 10603887953441115378701380797540106802992570431021259171147497285359022366530, + 15508145014687767573618084142387342672301565152470986006767817898696543800838, + 7580603962237961750688744764910560497782390265743578917287177212145536969841, + 1025514873270548083495173235543482371584279187582850926728834602828562891845, + 16351618100949071115464870875034225200055530353159282631317190209125274191315, + 13026868814244239480764037342583546446602514564000780473127260647088983379093, + 9782888818023151317744049031684575654317503572897756958728635524043882606275, + 15782257911302198003039561024959561051000542539873578256609646287034751094308, + 7324960388624406828110989443090747922453891336968956485896138528883871731568, + 14509166797301719963305583190584722067525188330699884421171661622364281732186, + 3576015785306001798848369827090561689950315391378856369238747834977910764359, + 15408031531397588748526508037562593237244827790619098124917546074545291717053, + 15525333419962742663515320510476264064935091064203281350314466524608319476543, + 17928936978367478217540536376038670794740076463804851071854045508766762129646, + 11301645668624916793310973638935928897982953673172686353576367383690479305853, + 17651921822081307631404076707307232862356810695205154770940273014229496932657, + 3687031281311398245656729489850260357742732581131462810186398483442070052844, + 86267700407064063749747625233446808497733886600688624904128414614809996280, + 12992895643788698378609916166424551263973151788999554383288274972006992966390, + 17331114571753760162233864843269502949375637222663621984345583896890943210742, + 15466454003559083730859763536366330362550989787053140400649001057288325105373, + 13461716884804472952969729794654803787049906186329021609941488265065178562843, + 19832475953555434807962724902630156825185268700134146369207754142403145797272, + 428790794741557512337364115659177190816156153047779431778700163962920934621, + 7753771936049682107611811399962369199815844995829237983790716013608398144334, + 13302541249779248722384348211098812155141093147180769444526784192055285805212, + 19204211516165656949548084335011970236370395037764623399882989951391901567173, + 15692624244798540949693402453200367020816291014230712210424060521416697301927, + 4704672529862198727079301732358554332963871698433558481208245291096060730807, + 19103886272420750724675372273068710842383071003606553325026872170901346886458, + 11908029324874885282813598716023852724932299396023119471120610283191872443619, + 3889268111540334964168406219787256982048235443915820985801351024189040098463, + 5113620562344570461543150895189216782236713616414649102346824164370351402924, + 3379363301564867150016193565847611009632649909813119301161190724588705650417, + 469231336716143602782095954078789347475601227607299910428463800519773753870 + ] +} \ No newline at end of file diff --git a/test/integration/CoreRegistration.t.sol b/test/integration/CoreRegistration.t.sol index ff0a0bba..74c5e57b 100644 --- a/test/integration/CoreRegistration.t.sol +++ b/test/integration/CoreRegistration.t.sol @@ -2,8 +2,11 @@ pragma solidity =0.8.12; import "../utils/MockAVSDeployer.sol"; +import { AVSDirectory } from "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; +import { IAVSDirectory } from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import { DelegationManager } from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import { IDelegationManager } from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; +import { IAVSDirectory } from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; contract Test_CoreRegistration is MockAVSDeployer { // Contracts @@ -23,6 +26,8 @@ contract Test_CoreRegistration is MockAVSDeployer { // Deploy New DelegationManager DelegationManager delegationManagerImplementation = new DelegationManager(strategyManagerMock, slasher, eigenPodManagerMock); + IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0); + uint256[] memory initializeWithdrawalDelayBlocks = new uint256[](0); delegationManager = DelegationManager( address( new TransparentUpgradeableProxy( @@ -33,15 +38,35 @@ contract Test_CoreRegistration is MockAVSDeployer { address(this), pauserRegistry, 0, // 0 is initialPausedStatus - 50400 // Initial withdrawal delay blocks + 50400, // Initial withdrawal delay blocks + initializeStrategiesToSetDelayBlocks, + initializeWithdrawalDelayBlocks ) ) ) ); + // Deploy New AVS Directory + AVSDirectory avsDirectoryImplementation = new AVSDirectory(delegationManager); + avsDirectory = AVSDirectory( + address( + new TransparentUpgradeableProxy( + address(avsDirectoryImplementation), + address(proxyAdmin), + abi.encodeWithSelector( + AVSDirectory.initialize.selector, + address(this), // owner + pauserRegistry, + 0 // 0 is initialPausedStatus + ) + ) + ) + ); + + // Deploy New ServiceManager & RegistryCoordinator implementations - serviceManagerImplementation = new ServiceManagerBase( - delegationManager, + serviceManagerImplementation = new ServiceManagerMock( + avsDirectory, registryCoordinator, stakeRegistry ); @@ -84,7 +109,7 @@ contract Test_CoreRegistration is MockAVSDeployer { bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(MAX_QUORUM_BITMAP); for (uint i = 0; i < quorumNumbers.length; i++) { _setOperatorWeight(operator, uint8(quorumNumbers[i]), defaultStake); - } + } } function test_registerOperator_coreStateChanges() public { @@ -99,13 +124,16 @@ contract Test_CoreRegistration is MockAVSDeployer { maxExpiry ); + // set operator as registered in Eigenlayer + delegationMock.setIsOperator(operator, true); + // Register operator cheats.prank(operator); registryCoordinator.registerOperator(quorumNumbers, defaultSocket, pubkeyRegistrationParams, operatorSignature); // Check operator is registered - IDelegationManager.OperatorAVSRegistrationStatus operatorStatus = delegationManager.avsOperatorStatus(address(serviceManager), operator); - assertEq(uint8(operatorStatus), uint8(IDelegationManager.OperatorAVSRegistrationStatus.REGISTERED)); + IAVSDirectory.OperatorAVSRegistrationStatus operatorStatus = avsDirectory.avsOperatorStatus(address(serviceManager), operator); + assertEq(uint8(operatorStatus), uint8(IAVSDirectory.OperatorAVSRegistrationStatus.REGISTERED)); } function test_deregisterOperator_coreStateChanges() public { @@ -118,8 +146,8 @@ contract Test_CoreRegistration is MockAVSDeployer { registryCoordinator.deregisterOperator(quorumNumbers); // Check operator is deregistered - IDelegationManager.OperatorAVSRegistrationStatus operatorStatus = delegationManager.avsOperatorStatus(address(serviceManager), operator); - assertEq(uint8(operatorStatus), uint8(IDelegationManager.OperatorAVSRegistrationStatus.UNREGISTERED)); + IAVSDirectory.OperatorAVSRegistrationStatus operatorStatus = avsDirectory.avsOperatorStatus(address(serviceManager), operator); + assertEq(uint8(operatorStatus), uint8(IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED)); } function test_deregisterOperator_notGloballyDeregistered() public { @@ -134,8 +162,8 @@ contract Test_CoreRegistration is MockAVSDeployer { registryCoordinator.deregisterOperator(quorumNumbers); // Check operator is still registered - IDelegationManager.OperatorAVSRegistrationStatus operatorStatus = delegationManager.avsOperatorStatus(address(serviceManager), operator); - assertEq(uint8(operatorStatus), uint8(IDelegationManager.OperatorAVSRegistrationStatus.REGISTERED)); + IAVSDirectory.OperatorAVSRegistrationStatus operatorStatus = avsDirectory.avsOperatorStatus(address(serviceManager), operator); + assertEq(uint8(operatorStatus), uint8(IAVSDirectory.OperatorAVSRegistrationStatus.REGISTERED)); } function test_setMetadataURI_fail_notServiceManagerOwner() public { @@ -145,11 +173,14 @@ contract Test_CoreRegistration is MockAVSDeployer { serviceManager.setMetadataURI("Test MetadataURI"); } + event AVSMetadataURIUpdated(address indexed avs, string metadataURI); + function test_setMetadataURI() public { address toPrankFrom = serviceManager.owner(); cheats.prank(toPrankFrom); + cheats.expectEmit(true, true, true, true); + emit AVSMetadataURIUpdated(address(serviceManager), "Test MetadataURI"); serviceManager.setMetadataURI("Test MetadataURI"); - // TODO: check effects here } // Utils @@ -163,6 +194,9 @@ contract Test_CoreRegistration is MockAVSDeployer { maxExpiry ); + // set operator as registered in Eigenlayer + delegationMock.setIsOperator(operator, true); + // Register operator cheats.prank(operator); registryCoordinator.registerOperator(quorumNumbers, defaultSocket, pubkeyRegistrationParams, operatorSignature); @@ -178,7 +212,7 @@ contract Test_CoreRegistration is MockAVSDeployer { operatorSignature.salt = salt; operatorSignature.expiry = expiry; { - bytes32 digestHash = delegationManager.calculateOperatorAVSRegistrationDigestHash(operatorToSign, avs, salt, expiry); + bytes32 digestHash = avsDirectory.calculateOperatorAVSRegistrationDigestHash(operatorToSign, avs, salt, expiry); (uint8 v, bytes32 r, bytes32 s) = cheats.sign(_operatorPrivateKey, digestHash); operatorSignature.signature = abi.encodePacked(r, s, v); } diff --git a/test/integration/IntegrationBase.t.sol b/test/integration/IntegrationBase.t.sol index 5a1ba185..814a8460 100644 --- a/test/integration/IntegrationBase.t.sol +++ b/test/integration/IntegrationBase.t.sol @@ -163,18 +163,18 @@ abstract contract IntegrationBase is IntegrationConfig { } } - /// DelegationManager: + /// AVSDirectory: function assert_NotRegisteredToAVS(User operator, string memory err) internal { - IDelegationManager.OperatorAVSRegistrationStatus status = delegationManager.avsOperatorStatus(address(serviceManager), address(operator)); + IAVSDirectory.OperatorAVSRegistrationStatus status = avsDirectory.avsOperatorStatus(address(serviceManager), address(operator)); - assertTrue(status == IDelegationManager.OperatorAVSRegistrationStatus.UNREGISTERED, err); + assertTrue(status == IAVSDirectory.OperatorAVSRegistrationStatus.UNREGISTERED, err); } function assert_IsRegisteredToAVS(User operator, string memory err) internal { - IDelegationManager.OperatorAVSRegistrationStatus status = delegationManager.avsOperatorStatus(address(serviceManager), address(operator)); + IAVSDirectory.OperatorAVSRegistrationStatus status = avsDirectory.avsOperatorStatus(address(serviceManager), address(operator)); - assertTrue(status == IDelegationManager.OperatorAVSRegistrationStatus.REGISTERED, err); + assertTrue(status == IAVSDirectory.OperatorAVSRegistrationStatus.REGISTERED, err); } /******************************************************************************* diff --git a/test/integration/IntegrationChecks.t.sol b/test/integration/IntegrationChecks.t.sol index 81df7b21..c5f04038 100644 --- a/test/integration/IntegrationChecks.t.sol +++ b/test/integration/IntegrationChecks.t.sol @@ -71,7 +71,7 @@ contract IntegrationChecks is IntegrationBase { assert_Snap_Added_OperatorListEntry(operator, quorums, "operator list should have one more entry"); - // DelegationManager + // AVSDirectory assert_IsRegisteredToAVS(operator, "operator should be registered to AVS"); } @@ -128,7 +128,7 @@ contract IntegrationChecks is IntegrationBase { assert_Snap_Replaced_OperatorListEntries(incomingOperator, churnedOperators, churnedQuorums, "operator list should contain incoming operator and should not contain churned operators"); - // DelegationManager + // AVSDirectory assert_IsRegisteredToAVS(incomingOperator, "operator should be registered to AVS"); @@ -235,7 +235,7 @@ contract IntegrationChecks is IntegrationBase { assert_Snap_Unchanged_OperatorListEntry(quorums, "operator list should be unchanged for each quorum"); - // DelegationManager + // AVSDirectory assert_IsRegisteredToAVS(operator, "operator should be registered to AVS"); } @@ -315,7 +315,7 @@ contract IntegrationChecks is IntegrationBase { assert_Snap_Removed_OperatorListEntry(operator, quorums, "operator list should have one fewer entry"); - // DelegationManager + // AVSDirectory assert_NotRegisteredToAVS(operator, "operator should not be registered to the AVS"); } @@ -404,7 +404,7 @@ contract IntegrationChecks is IntegrationBase { assert_HasDeregisteredStatus(operator, "operatorInfo status should be DEREGISTERED"); - // DelegationManager + // AVSDirectory assert_NotRegisteredToAVS(operator, "operator should not be registered to the AVS"); } diff --git a/test/integration/IntegrationConfig.t.sol b/test/integration/IntegrationConfig.t.sol index ad04e208..c26d49ee 100644 --- a/test/integration/IntegrationConfig.t.sol +++ b/test/integration/IntegrationConfig.t.sol @@ -58,6 +58,9 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { uint constant ONE = (FLAG << 0); uint constant TWO = (FLAG << 1); uint constant MANY = (FLAG << 2); + uint constant FIFTEEN = (FLAG << 3); + uint constant TWENTY = (FLAG << 4); + uint constant TWENTYFIVE = (FLAG << 5); /// @dev Flags for minimumStake uint constant NO_MINIMUM = (FLAG << 0); @@ -81,6 +84,9 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { /// @dev Number of operators generated so far uint numOperators = 0; + /// @dev current array of operatorIds registered so far per quorum. + /// does not update and remove if an operator is deregistered however, used for testing updateOperatorsForQuorum + mapping(uint8 => address[]) operatorsForQuorum; /** * Since BLS key generation uses FFI, it's pretty slow. Pregenerating keys @@ -185,6 +191,10 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { User operator = _newRandomOperator(); operator.registerOperator(quorumArray); + for (uint k = 0; k < quorumArray.length; k++) { + uint8 quorum = uint8(quorumArray[k]); + operatorsForQuorum[quorum].push(address(operator)); + } } emit log("====================="); @@ -488,6 +498,12 @@ contract IntegrationConfig is IntegrationDeployer, G2Operations, Constants { strategyCount = 2; } else if (strategyFlag == MANY) { strategyCount = _randUint({ min: 3, max: allStrats.length - 1 }); + } else if (strategyFlag == FIFTEEN) { + strategyCount = 15; + } else if (strategyFlag == TWENTY) { + strategyCount = 20; + } else if (strategyFlag == TWENTYFIVE) { + strategyCount = 25; } else { revert("_randStrategyCount: flag not recognized"); } diff --git a/test/integration/IntegrationDeployer.t.sol b/test/integration/IntegrationDeployer.t.sol index 5ce11b4c..3ef617af 100644 --- a/test/integration/IntegrationDeployer.t.sol +++ b/test/integration/IntegrationDeployer.t.sol @@ -15,6 +15,7 @@ import "@openzeppelin/contracts/utils/Strings.sol"; import "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import "eigenlayer-contracts/src/contracts/core/StrategyManager.sol"; import "eigenlayer-contracts/src/contracts/core/Slasher.sol"; +import "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; import "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPod.sol"; @@ -29,7 +30,7 @@ import "src/RegistryCoordinator.sol"; import "src/StakeRegistry.sol"; import "src/IndexRegistry.sol"; import "src/BLSApkRegistry.sol"; -import "src/ServiceManagerBase.sol"; +import "test/mocks/ServiceManagerMock.sol"; import "src/OperatorStateRetriever.sol"; // Mocks and More @@ -48,6 +49,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { // Core contracts to deploy DelegationManager delegationManager; + AVSDirectory public avsDirectory; StrategyManager strategyManager; EigenPodManager eigenPodManager; PauserRegistry pauserRegistry; @@ -63,7 +65,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { // Middleware contracts to deploy RegistryCoordinator public registryCoordinator; - ServiceManagerBase serviceManager; + ServiceManagerMock serviceManager; BLSApkRegistry blsApkRegistry; StakeRegistry stakeRegistry; IndexRegistry indexRegistry; @@ -126,6 +128,9 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { delayedWithdrawalRouter = DelayedWithdrawalRouter( address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")) ); + avsDirectory = AVSDirectory( + address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")) + ); // Deploy EigenPod Contracts pod = new EigenPod( @@ -150,9 +155,12 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { delegationManager ); DelayedWithdrawalRouter delayedWithdrawalRouterImplementation = new DelayedWithdrawalRouter(eigenPodManager); + AVSDirectory avsDirectoryImplemntation = new AVSDirectory(delegationManager); // Third, upgrade the proxy contracts to point to the implementations - uint256 withdrawalDelayBlocks = 7 days / 12 seconds; + uint256 minWithdrawalDelayBlocks = 7 days / 12 seconds; + IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0); + uint256[] memory initializeWithdrawalDelayBlocks = new uint256[](0); // DelegationManager proxyAdmin.upgradeAndCall( TransparentUpgradeableProxy(payable(address(delegationManager))), @@ -162,7 +170,9 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { eigenLayerReputedMultisig, // initialOwner pauserRegistry, 0 /* initialPausedStatus */, - withdrawalDelayBlocks + minWithdrawalDelayBlocks, + initializeStrategiesToSetDelayBlocks, + initializeWithdrawalDelayBlocks ) ); // StrategyManager @@ -210,7 +220,18 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { eigenLayerReputedMultisig, // initialOwner pauserRegistry, 0, // initialPausedStatus - withdrawalDelayBlocks + minWithdrawalDelayBlocks + ) + ); + // AVSDirectory + proxyAdmin.upgradeAndCall( + TransparentUpgradeableProxy(payable(address(avsDirectory))), + address(avsDirectoryImplemntation), + abi.encodeWithSelector( + AVSDirectory.initialize.selector, + eigenLayerReputedMultisig, // initialOwner + pauserRegistry, + 0 // initialPausedStatus ) ); @@ -265,7 +286,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { ) ); - serviceManager = ServiceManagerBase( + serviceManager = ServiceManagerMock( address( new TransparentUpgradeableProxy( address(emptyContract), @@ -279,7 +300,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { StakeRegistry stakeRegistryImplementation = new StakeRegistry(IRegistryCoordinator(registryCoordinator), IDelegationManager(delegationManager)); BLSApkRegistry blsApkRegistryImplementation = new BLSApkRegistry(IRegistryCoordinator(registryCoordinator)); IndexRegistry indexRegistryImplementation = new IndexRegistry(IRegistryCoordinator(registryCoordinator)); - ServiceManagerBase serviceManagerImplementation = new ServiceManagerBase(IDelegationManager(delegationManager), IRegistryCoordinator(registryCoordinator), stakeRegistry); + ServiceManagerMock serviceManagerImplementation = new ServiceManagerMock(IAVSDirectory(avsDirectory), IRegistryCoordinator(registryCoordinator), stakeRegistry); proxyAdmin.upgrade( TransparentUpgradeableProxy(payable(address(stakeRegistry))), @@ -339,12 +360,13 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { // Whitelist strategy IStrategy[] memory strategies = new IStrategy[](1); + bool[] memory thirdPartyTransfersForbiddenValues = new bool[](1); strategies[0] = strategy; cheats.prank(strategyManager.strategyWhitelister()); - strategyManager.addStrategiesToDepositWhitelist(strategies); + strategyManager.addStrategiesToDepositWhitelist(strategies, thirdPartyTransfersForbiddenValues); // Add to allStrats allStrats.push(strategy); allTokens.push(underlyingToken); } -} \ No newline at end of file +} diff --git a/test/integration/User.t.sol b/test/integration/User.t.sol index a31eaa47..a85699dd 100644 --- a/test/integration/User.t.sol +++ b/test/integration/User.t.sol @@ -12,6 +12,7 @@ import "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; // Core import "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import "eigenlayer-contracts/src/contracts/core/StrategyManager.sol"; +import "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; // Middleware import "src/RegistryCoordinator.sol"; @@ -29,6 +30,7 @@ import "test/integration/utils/BitmapStrings.t.sol"; interface IUserDeployer { function registryCoordinator() external view returns (RegistryCoordinator); + function avsDirectory() external view returns (AVSDirectory); function timeMachine() external view returns (TimeMachine); function churnApproverPrivateKey() external view returns (uint); function churnApprover() external view returns (address); @@ -46,6 +48,7 @@ contract User is Test { // Core contracts DelegationManager delegationManager; StrategyManager strategyManager; + AVSDirectory avsDirectory; // Middleware contracts RegistryCoordinator registryCoordinator; @@ -74,6 +77,7 @@ contract User is Test { IUserDeployer deployer = IUserDeployer(msg.sender); registryCoordinator = deployer.registryCoordinator(); + avsDirectory = deployer.avsDirectory(); serviceManager = ServiceManagerBase(address(registryCoordinator.serviceManager())); blsApkRegistry = BLSApkRegistry(address(registryCoordinator.blsApkRegistry())); @@ -82,6 +86,7 @@ contract User is Test { delegationManager = DelegationManager(address(stakeRegistry.delegation())); strategyManager = StrategyManager(address(delegationManager.strategyManager())); + avsDirectory = AVSDirectory(address(serviceManager.avsDirectory())); timeMachine = deployer.timeMachine(); @@ -180,6 +185,7 @@ contract User is Test { bytes32 _salt = keccak256(abi.encodePacked(++salt, address(this))); uint expiry = type(uint).max; bytes32 digest = registryCoordinator.calculateOperatorChurnApprovalDigestHash({ + registeringOperator: address(this), registeringOperatorId: operatorId, operatorKickParams: kickParams, salt: _salt, @@ -300,7 +306,7 @@ contract User is Test { expiry: type(uint256).max }); - bytes32 digest = delegationManager.calculateOperatorAVSRegistrationDigestHash({ + bytes32 digest = avsDirectory.calculateOperatorAVSRegistrationDigestHash({ operator: address(this), avs: address(serviceManager), salt: signature.salt, diff --git a/test/mocks/AVSDirectoryMock.sol b/test/mocks/AVSDirectoryMock.sol new file mode 100644 index 00000000..ba7e3e82 --- /dev/null +++ b/test/mocks/AVSDirectoryMock.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity =0.8.12; + +import {IAVSDirectory, ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; + +contract AVSDirectoryMock is IAVSDirectory { + /** + * @notice Called by an avs to register an operator with the avs. + * @param operator The address of the operator to register. + * @param operatorSignature The signature, salt, and expiry of the operator's signature. + */ + function registerOperatorToAVS( + address operator, + ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature + ) external {} + + /** + * @notice Called by an avs to deregister an operator with the avs. + * @param operator The address of the operator to deregister. + */ + function deregisterOperatorFromAVS(address operator) external {} + + /** + * @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated. + * @param metadataURI The URI for metadata associated with an AVS + * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `AVSMetadataURIUpdated` event + */ + function updateAVSMetadataURI(string calldata metadataURI) external {} + + /** + * @notice Returns whether or not the salt has already been used by the operator. + * @dev Salts is used in the `registerOperatorToAVS` function. + */ + function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool) {} + + /** + * @notice Calculates the digest hash to be signed by an operator to register with an AVS + * @param operator The account registering as an operator + * @param avs The AVS the operator is registering to + * @param salt A unique and single use value associated with the approver signature. + * @param expiry Time after which the approver's signature becomes invalid + */ + function calculateOperatorAVSRegistrationDigestHash( + address operator, + address avs, + bytes32 salt, + uint256 expiry + ) external view returns (bytes32) {} + + /// @notice The EIP-712 typehash for the Registration struct used by the contract + function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {} +} diff --git a/test/mocks/DelegationMock.sol b/test/mocks/DelegationMock.sol index 7d84d0be..44d3047c 100644 --- a/test/mocks/DelegationMock.sol +++ b/test/mocks/DelegationMock.sol @@ -77,10 +77,33 @@ contract DelegationMock is IDelegationManager { return 0; } - function withdrawalDelayBlocks() external pure returns (uint256) { + function minWithdrawalDelayBlocks() external view returns (uint256) { return 50400; } + /** + * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner, + * up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced). + */ + function strategyWithdrawalDelayBlocks(IStrategy /*strategy*/) external view returns (uint256) { + return 0; + } + + function getOperatorShares( + address operator, + IStrategy[] memory strategies + ) external view returns (uint256[] memory) { + uint256[] memory shares = new uint256[](strategies.length); + for (uint256 i = 0; i < strategies.length; ++i) { + shares[i] = operatorShares[operator][strategies[i]]; + } + return shares; + } + + function getWithdrawalDelay(IStrategy[] calldata /*strategies*/) public view returns (uint256) { + return 0; + } + function isDelegated(address staker) external view returns (bool) { return (delegatedTo[staker] != address(0)); } @@ -120,18 +143,12 @@ contract DelegationMock is IDelegationManager { function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32) {} - function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {} - function domainSeparator() external view returns (bytes32) {} function cumulativeWithdrawalsQueued(address staker) external view returns (uint256) {} function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32) {} - function registerOperatorToAVS(address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature) external {} - - function deregisterOperatorFromAVS(address operator) external {} - function operatorSaltIsSpent(address avs, bytes32 salt) external view returns (bool) {} function queueWithdrawals( @@ -158,10 +175,11 @@ contract DelegationMock is IDelegationManager { function addShares( IStrategyManager strategyManager, address staker, + IERC20 token, IStrategy strategy, uint256 shares ) external { - strategyManager.addShares(staker, strategy, shares); + strategyManager.addShares(staker, token, strategy, shares); } function removeShares( diff --git a/test/mocks/ServiceManagerMock.sol b/test/mocks/ServiceManagerMock.sol new file mode 100644 index 00000000..3101aa2b --- /dev/null +++ b/test/mocks/ServiceManagerMock.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity =0.8.12; + +import "../../src/ServiceManagerBase.sol"; + +contract ServiceManagerMock is ServiceManagerBase { + constructor( + IAVSDirectory _avsDirectory, + IRegistryCoordinator _registryCoordinator, + IStakeRegistry _stakeRegistry + ) ServiceManagerBase(_avsDirectory, _registryCoordinator, _stakeRegistry) {} + + function initialize(address initialOwner) public virtual initializer { + __ServiceManagerBase_init(initialOwner); + } +} diff --git a/test/tree/BLSSignatureCheckerUnit.tree b/test/tree/BLSSignatureCheckerUnit.tree index a23e800d..3284c2c7 100644 --- a/test/tree/BLSSignatureCheckerUnit.tree +++ b/test/tree/BLSSignatureCheckerUnit.tree @@ -20,7 +20,7 @@ │ ├── given that the non-signer pubkeys contain any duplicates (technically a sub-case of above) │ │ └── it should revert │ ├── given that the staleStakesForbidden flag is set and the quorumUpdateBlock number is strictly within -│ │ `delegation.withdrawalDelayBlocks()` of the present block, for any of the quorumNumbers +│ │ `delegation.minWithdrawalDelayBlocks()` of the present block, for any of the quorumNumbers │ │ └── it should revert │ ├── given that any of the provided nonSignerQuorumBitmapIndices is incorrect for the referenceBlockNumber │ │ └── ***it should revert (via bubbling up a revert from the RegistryCoordinator) diff --git a/test/unit/BLSApkRegistryUnit.t.sol b/test/unit/BLSApkRegistryUnit.t.sol index c85927be..82ff0a87 100644 --- a/test/unit/BLSApkRegistryUnit.t.sol +++ b/test/unit/BLSApkRegistryUnit.t.sol @@ -327,13 +327,14 @@ contract BLSApkRegistryUnitTests_registerBLSPublicKey is BLSApkRegistryUnitTests address operator, address operator2 ) public { + cheats.assume(operator != address(0)); cheats.assume(operator != operator2); BN254.G1Point memory messageHash = registryCoordinator.pubkeyRegistrationMessageHash(operator); pubkeyRegistrationParams.pubkeyRegistrationSignature = _signMessage(operator); cheats.startPrank(address(registryCoordinator)); - blsApkRegistry.registerBLSPublicKey(operator, pubkeyRegistrationParams, messageHash); + blsApkRegistry.registerBLSPublicKey(operator, pubkeyRegistrationParams, messageHash); cheats.expectRevert("BLSApkRegistry.registerBLSPublicKey: public key already registered"); blsApkRegistry.registerBLSPublicKey(operator2, pubkeyRegistrationParams, messageHash); diff --git a/test/unit/BLSSignatureCheckerUnit.t.sol b/test/unit/BLSSignatureCheckerUnit.t.sol index ec711cb1..e9d50769 100644 --- a/test/unit/BLSSignatureCheckerUnit.t.sol +++ b/test/unit/BLSSignatureCheckerUnit.t.sol @@ -38,7 +38,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // this test checks that a valid signature from maxOperatorsToRegister with a random number of nonsigners is checked // correctly on the BLSSignatureChecker contract when all operators are only regsitered for a single quorum and // the signature is only checked for stakes on that quorum - function test_checkSignatures_SingleQuorum(uint256 pseudoRandomNumber) public { + function testFuzz_checkSignatures_SingleQuorum(uint256 pseudoRandomNumber) public { uint256 numNonSigners = pseudoRandomNumber % (maxOperatorsToRegister - 1); uint256 quorumBitmap = 1; bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(quorumBitmap); @@ -241,11 +241,13 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { (/*uint32 referenceBlockNumber*/, BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature) = _registerSignatoriesAndGetNonSignerStakeAndSignatureRandom(pseudoRandomNumber, numNonSigners, quorumBitmap); + // Create an invalid reference block: any block number >= the current block + uint32 invalidReferenceBlock = uint32(block.number + (pseudoRandomNumber % 20)); cheats.expectRevert("BLSSignatureChecker.checkSignatures: invalid reference block"); blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, - uint32(block.number + 1), + invalidReferenceBlock, nonSignerStakesAndSignature ); } @@ -312,9 +314,10 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { } // move referenceBlockNumber forward to a block number the last block number where the stakes will be considered "not stale" - referenceBlockNumber = uint32(stalestUpdateBlock + delegationMock.withdrawalDelayBlocks()); + referenceBlockNumber = uint32(stalestUpdateBlock + delegationMock.minWithdrawalDelayBlocks()); // roll forward to make the reference block number valid - cheats.roll(referenceBlockNumber); + // we roll to referenceBlockNumber + 1 because the current block number is not a valid reference block + cheats.roll(referenceBlockNumber + 1); blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, @@ -324,8 +327,8 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // move referenceBlockNumber forward one more block, making the stakes "stale" referenceBlockNumber += 1; - // roll forward to make the reference block number valid - cheats.roll(referenceBlockNumber); + // roll forward to reference + 1 to ensure the referenceBlockNumber is still valid + cheats.roll(referenceBlockNumber + 1); cheats.expectRevert("BLSSignatureChecker.checkSignatures: StakeRegistry updates must be within withdrawalDelayBlocks window"); blsSignatureChecker.checkSignatures( msgHash, @@ -369,7 +372,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // set the totalStakeIndices to a different value nonSignerStakesAndSignature.totalStakeIndices[0] = 0; - cheats.expectRevert("StakeRegistry._validateOperatorStakeAtBlockNumber: there is a newer operatorStakeUpdate available before blockNumber"); + cheats.expectRevert("StakeRegistry._validateStakeUpdateAtBlockNumber: there is a newer stakeUpdate available before blockNumber"); blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, @@ -398,7 +401,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer { // set the nonSignerStakeIndices to a different value nonSignerStakesAndSignature.nonSignerStakeIndices[0][0] = 1; - cheats.expectRevert("StakeRegistry._validateOperatorStakeAtBlockNumber: operatorStakeUpdate is from after blockNumber"); + cheats.expectRevert("StakeRegistry._validateStakeUpdateAtBlockNumber: stakeUpdate is from after blockNumber"); blsSignatureChecker.checkSignatures( msgHash, quorumNumbers, diff --git a/test/unit/OperatorStateRetrieverUnit.t.sol b/test/unit/OperatorStateRetrieverUnit.t.sol index 0781202a..707d557e 100644 --- a/test/unit/OperatorStateRetrieverUnit.t.sol +++ b/test/unit/OperatorStateRetrieverUnit.t.sol @@ -55,7 +55,7 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer { } function test_getOperatorState_revert_quorumNotCreatedAtCallTime() public { - cheats.expectRevert("IndexRegistry._operatorCountAtBlockNumber: quorum does not exist"); + cheats.expectRevert("IndexRegistry._operatorCountAtBlockNumber: quorum did not exist at given block number"); operatorStateRetriever.getOperatorState(registryCoordinator, BitmapUtils.bitmapToBytesArray(1 << numQuorums), uint32(block.number)); } diff --git a/test/unit/RegistryCoordinatorUnit.t.sol b/test/unit/RegistryCoordinatorUnit.t.sol index 0501c966..b977f780 100644 --- a/test/unit/RegistryCoordinatorUnit.t.sol +++ b/test/unit/RegistryCoordinatorUnit.t.sol @@ -1347,7 +1347,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord { ISignatureUtils.SignatureWithSaltAndExpiry memory emptyAVSRegSig; ISignatureUtils.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval(operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); + _signOperatorChurnApproval(operatorToRegister, operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); cheats.prank(operatorToRegister); uint256 gasBefore = gasleft(); registryCoordinator.registerOperatorWithChurn( @@ -1402,7 +1402,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtils.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval(operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); + _signOperatorChurnApproval(operatorToRegister, operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); cheats.prank(operatorToRegister); cheats.expectRevert("RegistryCoordinator._validateChurn: incoming operator has insufficient stake for churn"); registryCoordinator.registerOperatorWithChurn( @@ -1434,7 +1434,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtils.SignatureWithSaltAndExpiry memory signatureWithExpiry = - _signOperatorChurnApproval(operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); + _signOperatorChurnApproval(operatorToRegister, operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp + 10); cheats.prank(operatorToRegister); cheats.expectRevert("RegistryCoordinator._validateChurn: cannot kick operator with more than kickBIPsOfTotalStake"); registryCoordinator.registerOperatorWithChurn( @@ -1496,7 +1496,7 @@ contract RegistryCoordinatorUnitTests_RegisterOperatorWithChurn is RegistryCoord cheats.roll(registrationBlockNumber); ISignatureUtils.SignatureWithSaltAndExpiry memory signatureWithSaltAndExpiry = - _signOperatorChurnApproval(operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp - 1); + _signOperatorChurnApproval(operatorToRegister, operatorToRegisterId, operatorKickParams, defaultSalt, block.timestamp - 1); cheats.prank(operatorToRegister); cheats.expectRevert("RegistryCoordinator._verifyChurnApproverSignature: churnApprover signature expired"); registryCoordinator.registerOperatorWithChurn( diff --git a/test/utils/BLSMockAVSDeployer.sol b/test/utils/BLSMockAVSDeployer.sol index 4e1476b6..7e870a7a 100644 --- a/test/utils/BLSMockAVSDeployer.sol +++ b/test/utils/BLSMockAVSDeployer.sol @@ -57,13 +57,22 @@ contract BLSMockAVSDeployer is MockAVSDeployer { uint256[] memory nonSignerPrivateKeys = new uint256[](numNonSigners); for (uint i = 0; i < numNonSigners; i++) { nonSignerPrivateKeys[i] = uint256(keccak256(abi.encodePacked("nonSignerPrivateKey", pseudoRandomNumber, i))) % BN254.FR_MODULUS; - uint256 j = 0; - if(i != 0) { - while(BN254.generatorG1().scalar_mul(nonSignerPrivateKeys[i]).hashG1Point() <= BN254.generatorG1().scalar_mul(nonSignerPrivateKeys[i-1]).hashG1Point()){ - nonSignerPrivateKeys[i] = uint256(keccak256(abi.encodePacked("nonSignerPrivateKey", pseudoRandomNumber, j))) % BN254.FR_MODULUS; - j++; - } + } + + // Sort nonSignerPrivateKeys in order of ascending pubkeyHash + // Uses insertion sort to sort array in place + for (uint i = 1; i < nonSignerPrivateKeys.length; i++) { + uint privateKey = nonSignerPrivateKeys[i]; + bytes32 pubkeyHash = _toPubkeyHash(privateKey); + uint j = i; + + // Move elements of nonSignerPrivateKeys[0..i-1] that are greater than the current key + // to one position ahead of their current position + while (j > 0 && _toPubkeyHash(nonSignerPrivateKeys[j - 1]) > pubkeyHash) { + nonSignerPrivateKeys[j] = nonSignerPrivateKeys[j - 1]; + j--; } + nonSignerPrivateKeys[j] = privateKey; } return (signerPrivateKeys, nonSignerPrivateKeys); @@ -135,4 +144,8 @@ contract BLSMockAVSDeployer is MockAVSDeployer { return (referenceBlockNumber, nonSignerStakesAndSignature); } + + function _toPubkeyHash(uint privKey) internal view returns (bytes32) { + return BN254.generatorG1().scalar_mul(privKey).hashG1Point(); + } } diff --git a/test/utils/MockAVSDeployer.sol b/test/utils/MockAVSDeployer.sol index bc3e2c0c..d7533b58 100644 --- a/test/utils/MockAVSDeployer.sol +++ b/test/utils/MockAVSDeployer.sol @@ -16,7 +16,7 @@ import {OperatorStateRetriever} from "../../src/OperatorStateRetriever.sol"; import {RegistryCoordinator} from "../../src/RegistryCoordinator.sol"; import {RegistryCoordinatorHarness} from "../harnesses/RegistryCoordinatorHarness.t.sol"; import {BLSApkRegistry} from "../../src/BLSApkRegistry.sol"; -import {ServiceManagerBase} from "../../src/ServiceManagerBase.sol"; +import {ServiceManagerMock} from "../mocks/ServiceManagerMock.sol"; import {StakeRegistry} from "../../src/StakeRegistry.sol"; import {IndexRegistry} from "../../src/IndexRegistry.sol"; import {IBLSApkRegistry} from "../../src/interfaces/IBLSApkRegistry.sol"; @@ -28,7 +28,13 @@ import {IServiceManager} from "../../src/interfaces/IServiceManager.sol"; import {StrategyManagerMock} from "eigenlayer-contracts/src/test/mocks/StrategyManagerMock.sol"; import {EigenPodManagerMock} from "eigenlayer-contracts/src/test/mocks/EigenPodManagerMock.sol"; +import {AVSDirectoryMock} from "../mocks/AVSDirectoryMock.sol"; import {DelegationMock} from "../mocks/DelegationMock.sol"; +import {AVSDirectory} from "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; +import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; + + +import {AVSDirectoryMock} from "../mocks/AVSDirectoryMock.sol"; import {BLSApkRegistryHarness} from "../harnesses/BLSApkRegistryHarness.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; @@ -53,18 +59,21 @@ contract MockAVSDeployer is Test { StakeRegistryHarness public stakeRegistryImplementation; IBLSApkRegistry public blsApkRegistryImplementation; IIndexRegistry public indexRegistryImplementation; - ServiceManagerBase public serviceManagerImplementation; + ServiceManagerMock public serviceManagerImplementation; OperatorStateRetriever public operatorStateRetriever; RegistryCoordinatorHarness public registryCoordinator; StakeRegistryHarness public stakeRegistry; BLSApkRegistryHarness public blsApkRegistry; IIndexRegistry public indexRegistry; - ServiceManagerBase public serviceManager; + ServiceManagerMock public serviceManager; StrategyManagerMock public strategyManagerMock; DelegationMock public delegationMock; EigenPodManagerMock public eigenPodManagerMock; + AVSDirectory public avsDirectory; + AVSDirectory public avsDirectoryImplementation; + AVSDirectoryMock public avsDirectoryMock; /// @notice StakeRegistry, Constant used as a divisor in calculating weights. uint256 public constant WEIGHTING_DIVISOR = 1e18; @@ -127,7 +136,9 @@ contract MockAVSDeployer is Test { pausers[0] = pauser; pauserRegistry = new PauserRegistry(pausers, unpauser); + delegationMock = new DelegationMock(); + avsDirectoryMock = new AVSDirectoryMock(); eigenPodManagerMock = new EigenPodManagerMock(); strategyManagerMock = new StrategyManagerMock(); slasherImplementation = new Slasher(strategyManagerMock, delegationMock); @@ -140,6 +151,17 @@ contract MockAVSDeployer is Test { ) ) ); + avsDirectoryMock = new AVSDirectoryMock(); + avsDirectoryImplementation = new AVSDirectory(delegationMock); + avsDirectory = AVSDirectory( + address( + new TransparentUpgradeableProxy( + address(avsDirectoryImplementation), + address(proxyAdmin), + abi.encodeWithSelector(AVSDirectory.initialize.selector, msg.sender, pauserRegistry, 0/*initialPausedStatus*/) + ) + ) + ); strategyManagerMock.setAddresses( delegationMock, @@ -187,7 +209,7 @@ contract MockAVSDeployer is Test { ) ); - serviceManager = ServiceManagerBase( + serviceManager = ServiceManagerMock( address( new TransparentUpgradeableProxy( address(emptyContract), @@ -229,8 +251,8 @@ contract MockAVSDeployer is Test { address(indexRegistryImplementation) ); - serviceManagerImplementation = new ServiceManagerBase( - delegationMock, + serviceManagerImplementation = new ServiceManagerMock( + avsDirectoryMock, registryCoordinator, stakeRegistry ); @@ -412,8 +434,9 @@ contract MockAVSDeployer is Test { return bytes32(uint256(start) + inc); } - function _signOperatorChurnApproval(bytes32 registeringOperatorId, IRegistryCoordinator.OperatorKickParam[] memory operatorKickParams, bytes32 salt, uint256 expiry) internal view returns(ISignatureUtils.SignatureWithSaltAndExpiry memory) { + function _signOperatorChurnApproval(address registeringOperator, bytes32 registeringOperatorId, IRegistryCoordinator.OperatorKickParam[] memory operatorKickParams, bytes32 salt, uint256 expiry) internal view returns(ISignatureUtils.SignatureWithSaltAndExpiry memory) { bytes32 digestHash = registryCoordinator.calculateOperatorChurnApprovalDigestHash( + registeringOperator, registeringOperatorId, operatorKickParams, salt,