Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Anvil testing updateOperatorsForQuorum #66

Closed
wants to merge 35 commits into from

Conversation

8sunyuan
Copy link
Collaborator

Ran tests with anvil node running the following commands

anvil -f https://ethereum-goerli.publicnode.com --accounts 200
forge script script/test/M2_DeployTesting.s.sol:Deployer_M2 --rpc-url http://127.0.0.1:8545  --private-key $PRIVATE_KEY --broadcast -vvv

Assumptions:

  • Quorum0(10 strategies) has 200 operators
  • Quorums1-9(1 strategy each) has 50 operators each

Running updates for Quorum0 with 200 operators costs ~11.4M gas, updates for Quorums1-9 with 50 operators each costs ~6.4M gas. If using 30 operator cap instead of 50 then its ~4M.

Only mocked the BLSPubkeyRegistry contract in tests as generating BLS pubkeys for all 200 operators would have been much more of a chore. This affects gas estimations in the event that the operator stake is below the minimum requirement for the quorum and we have to rederegister them from all other registries.
In this scenario, for Quorum0 and de-registering ALL 200 operators, it would cost approximately 2-3M more gas to perform the transaction. For updating all Quorums1-9 and all operators de-registering, it would cost approximately 3-5M more gas.

TL;DR In the worst case scenario where all operators deregister/have below minimum quorum stake, we can still update operators for Quorum0 and Quorums1-9 in two separate tx's.

8sunyuan and others added 7 commits November 8, 2023 23:05
Additionally
- renamed updateOperatorsPerQuorum to updateOperatorsForQuorum
- sort by operator addresses instead of operatorIds
- sorted by ascending address instead of operatorId
- sanitization checks on quorumNumbers, added quorumsAllExist modifier
- performing `OperatorStatus.REGISTERED` checks now
- Removed uneccesary bitmapToBytes calls and doing bytes slicing for quorumNumbers
- using internal function and scoping to fix stack-too-deep
small off by 1 error, for example of quorumCount = 1,3
1 << 1 = 2, bit rep is 10
1 << 1 - 1 = 1, bit rep is 01

1 << 3 = 8, bit rep is 1000
1 << 3 - 1 = 7, bit rep is 0111
We should be subtracting by 1 instead of 2 here to get the bitmap
@8sunyuan 8sunyuan marked this pull request as draft November 16, 2023 16:53
}
}

quorumUpdateTimestamp[quorumNumber] = block.timestamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

);

{
uint192 currentBitmap = _currentOperatorBitmap(operatorId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any way to reduce duplication between this and the other update stakes method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try to create another PR for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#68
Take a look here

@@ -73,6 +73,10 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
// loop through every quorumNumber and keep track of the apk
BN254.G1Point memory apk = BN254.G1Point(0, 0);
for (uint i = 0; i < quorumNumbers.length; i++) {
require(
registryCoordinator.quorumUpdateTimestamp(uint8(quorumNumbers[i])) + 1 weeks <= block.timestamp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we set a minimum withdrawalDelayBlocks in delegation manager and set this to that?

cc @ChaoticWalrus

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we just read the current DelegationManager.withdrawalDelayBlocks value instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yup! that'l work

Copy link
Collaborator Author

@8sunyuan 8sunyuan Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this in the feature PR e4f39f6 as well as the interface change to read off of the DM Layr-Labs/eigenlayer-contracts#344

@8sunyuan 8sunyuan force-pushed the test/gas-testing-updates-per-quorum branch from f836cf2 to 9d9c328 Compare November 30, 2023 21:07
8sunyuan and others added 8 commits December 1, 2023 16:00
Additionally
- renamed updateOperatorsPerQuorum to updateOperatorsForQuorum
- sort by operator addresses instead of operatorIds
- sorted by ascending address instead of operatorId
- sanitization checks on quorumNumbers, added quorumsAllExist modifier
- performing `OperatorStatus.REGISTERED` checks now
- Removed uneccesary bitmapToBytes calls and doing bytes slicing for quorumNumbers
- using internal function and scoping to fix stack-too-deep
small off by 1 error, for example of quorumCount = 1,3
1 << 1 = 2, bit rep is 10
1 << 1 - 1 = 1, bit rep is 01

1 << 3 = 8, bit rep is 1000
1 << 3 - 1 = 7, bit rep is 0111
We should be subtracting by 1 instead of 2 here to get the bitmap
@8sunyuan 8sunyuan closed this Dec 11, 2023
@8sunyuan 8sunyuan deleted the test/gas-testing-updates-per-quorum branch December 11, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants