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

Implement standard keymanager API #3522

Merged
merged 131 commits into from
Apr 1, 2022
Merged

Implement standard keymanager API #3522

merged 131 commits into from
Apr 1, 2022

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Dec 15, 2021

Motivation

Implements the standard key manager API from https://ethereum.github.io/keymanager-APIs/, formerly ethereum/beacon-APIs#151

Closes #3523

Description

  • Add all of the new endpoints from the standard API: GET, POST and DELETE.
  • Ensure atomic disable + export.
  • Add tests for all the common sequential accesses of the API
  • When a key is removed from validator store, delete the key from index service and all the duty services (att, block, sync)
  • Add tests for interactions with remote signer validators
  • Add end-to-end tests for migration of validators from one VC to another
  • Implement the authentication scheme from the standard (token bearer auth)

@codeclimate
Copy link

codeclimate bot commented Dec 15, 2021

Code Climate has analyzed commit a497722 and detected 8 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 6
Duplication 2

View more on Code Climate.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2021

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 5db8dc3 Previous: d8ec024 Ratio
BeaconState.hashTreeRoot - No change 689.00 ns/op 567.00 ns/op 1.22
BeaconState.hashTreeRoot - 1 full validator 152.19 us/op 125.25 us/op 1.22
BeaconState.hashTreeRoot - 32 full validator 2.4309 ms/op 1.9270 ms/op 1.26
BeaconState.hashTreeRoot - 512 full validator 31.644 ms/op 25.680 ms/op 1.23
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 155.34 us/op 126.21 us/op 1.23
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.8266 ms/op 2.2782 ms/op 1.24
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 34.464 ms/op 27.811 ms/op 1.24
BeaconState.hashTreeRoot - 1 balances 106.60 us/op 89.489 us/op 1.19
BeaconState.hashTreeRoot - 32 balances 901.85 us/op 765.86 us/op 1.18
BeaconState.hashTreeRoot - 512 balances 9.2347 ms/op 7.3286 ms/op 1.26
BeaconState.hashTreeRoot - 250000 balances 160.59 ms/op 135.97 ms/op 1.18
processSlot - 1 slots 54.503 us/op 55.111 us/op 0.99
processSlot - 32 slots 3.4223 ms/op 2.8736 ms/op 1.19
getCommitteeAssignments - req 1 vs - 250000 vc 6.3298 ms/op 5.2263 ms/op 1.21
getCommitteeAssignments - req 100 vs - 250000 vc 8.7845 ms/op 7.2367 ms/op 1.21
getCommitteeAssignments - req 1000 vs - 250000 vc 9.4226 ms/op 7.7795 ms/op 1.21
computeProposers - vc 250000 25.489 ms/op 20.688 ms/op 1.23
computeEpochShuffling - vc 250000 228.09 ms/op 185.50 ms/op 1.23
getNextSyncCommittee - vc 250000 414.25 ms/op 340.09 ms/op 1.22
altair processAttestation - 250000 vs - 7PWei normalcase 42.056 ms/op 36.204 ms/op 1.16
altair processAttestation - 250000 vs - 7PWei worstcase 47.607 ms/op 36.257 ms/op 1.31
altair processAttestation - setStatus - 1/6 committees join 13.888 ms/op 13.010 ms/op 1.07
altair processAttestation - setStatus - 1/3 committees join 28.442 ms/op 26.485 ms/op 1.07
altair processAttestation - setStatus - 1/2 committees join 42.253 ms/op 36.307 ms/op 1.16
altair processAttestation - setStatus - 2/3 committees join 56.848 ms/op 46.703 ms/op 1.22
altair processAttestation - setStatus - 4/5 committees join 67.592 ms/op 64.630 ms/op 1.05
altair processAttestation - setStatus - 100% committees join 85.889 ms/op 67.005 ms/op 1.28
altair processAttestation - updateEpochParticipants - 1/6 committees join 15.096 ms/op 10.951 ms/op 1.38
altair processAttestation - updateEpochParticipants - 1/3 committees join 30.596 ms/op 22.460 ms/op 1.36
altair processAttestation - updateEpochParticipants - 1/2 committees join 24.727 ms/op 20.767 ms/op 1.19
altair processAttestation - updateEpochParticipants - 2/3 committees join 29.662 ms/op 22.239 ms/op 1.33
altair processAttestation - updateEpochParticipants - 4/5 committees join 27.218 ms/op 23.383 ms/op 1.16
altair processAttestation - updateEpochParticipants - 100% committees join 28.383 ms/op 27.273 ms/op 1.04
altair processAttestation - updateAllStatus 22.621 ms/op 19.078 ms/op 1.19
altair processBlock - 250000 vs - 7PWei normalcase 39.596 ms/op 33.210 ms/op 1.19
altair processBlock - 250000 vs - 7PWei worstcase 124.67 ms/op 103.12 ms/op 1.21
altair processEpoch - mainnet_e81889 971.26 ms/op 788.19 ms/op 1.23
mainnet_e81889 - altair beforeProcessEpoch 361.99 ms/op 314.92 ms/op 1.15
mainnet_e81889 - altair processJustificationAndFinalization 75.829 us/op 65.865 us/op 1.15
mainnet_e81889 - altair processInactivityUpdates 22.245 ms/op 18.253 ms/op 1.22
mainnet_e81889 - altair processRewardsAndPenalties 142.33 ms/op 97.669 ms/op 1.46
mainnet_e81889 - altair processRegistryUpdates 10.411 us/op 7.9720 us/op 1.31
mainnet_e81889 - altair processSlashings 2.6720 us/op 1.3370 us/op 2.00
mainnet_e81889 - altair processEth1DataReset 3.2970 us/op 1.5550 us/op 2.12
mainnet_e81889 - altair processEffectiveBalanceUpdates 7.5857 ms/op 6.9512 ms/op 1.09
mainnet_e81889 - altair processSlashingsReset 15.780 us/op 12.686 us/op 1.24
mainnet_e81889 - altair processRandaoMixesReset 20.488 us/op 17.153 us/op 1.19
mainnet_e81889 - altair processHistoricalRootsUpdate 4.4920 us/op 1.9410 us/op 2.31
mainnet_e81889 - altair processParticipationFlagUpdates 80.365 ms/op 68.277 ms/op 1.18
mainnet_e81889 - altair processSyncCommitteeUpdates 3.1230 us/op 1.4580 us/op 2.14
mainnet_e81889 - altair afterProcessEpoch 265.20 ms/op 222.41 ms/op 1.19
altair processInactivityUpdates - 250000 normalcase 82.548 ms/op 70.438 ms/op 1.17
altair processInactivityUpdates - 250000 worstcase 87.481 ms/op 75.841 ms/op 1.15
altair processParticipationFlagUpdates - 250000 anycase 70.594 ms/op 69.706 ms/op 1.01
altair processRewardsAndPenalties - 250000 normalcase 107.05 ms/op 82.491 ms/op 1.30
altair processRewardsAndPenalties - 250000 worstcase 119.08 ms/op 108.26 ms/op 1.10
altair processSyncCommitteeUpdates - 250000 428.46 ms/op 354.45 ms/op 1.21
Tree 40 250000 create 861.54 ms/op 644.13 ms/op 1.34
Tree 40 250000 get(125000) 403.80 ns/op 325.94 ns/op 1.24
Tree 40 250000 set(125000) 2.5625 us/op 2.0970 us/op 1.22
Tree 40 250000 toArray() 49.332 ms/op 40.997 ms/op 1.20
Tree 40 250000 iterate all - toArray() + loop 49.130 ms/op 42.662 ms/op 1.15
Tree 40 250000 iterate all - get(i) 146.93 ms/op 122.81 ms/op 1.20
MutableVector 250000 create 25.669 ms/op 20.209 ms/op 1.27
MutableVector 250000 get(125000) 15.078 ns/op 12.966 ns/op 1.16
MutableVector 250000 set(125000) 798.57 ns/op 544.34 ns/op 1.47
MutableVector 250000 toArray() 11.063 ms/op 8.5468 ms/op 1.29
MutableVector 250000 iterate all - toArray() + loop 11.467 ms/op 8.7689 ms/op 1.31
MutableVector 250000 iterate all - get(i) 4.0671 ms/op 3.3947 ms/op 1.20
Array 250000 create 7.0468 ms/op 5.6533 ms/op 1.25
Array 250000 clone - spread 2.7903 ms/op 2.3347 ms/op 1.20
Array 250000 get(125000) 1.3470 ns/op 1.1290 ns/op 1.19
Array 250000 set(125000) 1.3440 ns/op 1.1210 ns/op 1.20
Array 250000 iterate all - loop 202.18 us/op 167.82 us/op 1.20
effectiveBalanceIncrements clone Uint8Array 300000 102.32 us/op 77.311 us/op 1.32
effectiveBalanceIncrements clone MutableVector 300000 636.00 ns/op 506.00 ns/op 1.26
effectiveBalanceIncrements rw all Uint8Array 300000 363.19 us/op 301.83 us/op 1.20
effectiveBalanceIncrements rw all MutableVector 300000 205.55 ms/op 170.54 ms/op 1.21
aggregationBits - 2048 els - readonlyValues 226.75 us/op 180.82 us/op 1.25
aggregationBits - 2048 els - zipIndexesInBitList 41.534 us/op 34.468 us/op 1.21
regular array get 100000 times 83.006 us/op 67.431 us/op 1.23
wrappedArray get 100000 times 82.232 us/op 67.432 us/op 1.22
arrayWithProxy get 100000 times 49.659 ms/op 29.929 ms/op 1.66
ssz.Root.equals 1.3320 us/op 1.0990 us/op 1.21
ssz.Root.equals with valueOf() 1.5690 us/op 1.3090 us/op 1.20
byteArrayEquals with valueOf() 1.5440 us/op 1.3000 us/op 1.19
phase0 processBlock - 250000 vs - 7PWei normalcase 9.4904 ms/op 7.9290 ms/op 1.20
phase0 processBlock - 250000 vs - 7PWei worstcase 85.743 ms/op 73.546 ms/op 1.17
phase0 afterProcessEpoch - 250000 vs - 7PWei 253.67 ms/op 202.42 ms/op 1.25
phase0 beforeProcessEpoch - 250000 vs - 7PWei 649.05 ms/op 554.75 ms/op 1.17
phase0 processEpoch - mainnet_e58758 921.29 ms/op 769.03 ms/op 1.20
mainnet_e58758 - phase0 beforeProcessEpoch 505.95 ms/op 437.59 ms/op 1.16
mainnet_e58758 - phase0 processJustificationAndFinalization 64.566 us/op 55.579 us/op 1.16
mainnet_e58758 - phase0 processRewardsAndPenalties 133.93 ms/op 82.775 ms/op 1.62
mainnet_e58758 - phase0 processRegistryUpdates 45.473 us/op 37.075 us/op 1.23
mainnet_e58758 - phase0 processSlashings 3.0470 us/op 1.3820 us/op 2.20
mainnet_e58758 - phase0 processEth1DataReset 2.6890 us/op 1.2640 us/op 2.13
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 6.2312 ms/op 5.7300 ms/op 1.09
mainnet_e58758 - phase0 processSlashingsReset 15.244 us/op 7.2590 us/op 2.10
mainnet_e58758 - phase0 processRandaoMixesReset 19.146 us/op 14.712 us/op 1.30
mainnet_e58758 - phase0 processHistoricalRootsUpdate 4.3430 us/op 1.9510 us/op 2.23
mainnet_e58758 - phase0 processParticipationRecordUpdates 12.911 us/op 12.925 us/op 1.00
mainnet_e58758 - phase0 afterProcessEpoch 218.17 ms/op 182.02 ms/op 1.20
phase0 processEffectiveBalanceUpdates - 250000 normalcase 7.4444 ms/op 6.5273 ms/op 1.14
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 7.6234 ms/op 7.0997 ms/op 1.07
phase0 processRegistryUpdates - 250000 normalcase 44.638 us/op 54.904 us/op 0.81
phase0 processRegistryUpdates - 250000 badcase_full_deposits 3.3769 ms/op 3.1470 ms/op 1.07
phase0 processRegistryUpdates - 250000 worstcase 0.5 2.0220 s/op 1.5127 s/op 1.34
phase0 getAttestationDeltas - 250000 normalcase 15.152 ms/op 12.959 ms/op 1.17
phase0 getAttestationDeltas - 250000 worstcase 15.260 ms/op 12.941 ms/op 1.18
phase0 processSlashings - 250000 worstcase 44.288 ms/op 35.685 ms/op 1.24
shuffle list - 16384 els 15.741 ms/op 12.790 ms/op 1.23
shuffle list - 250000 els 225.12 ms/op 182.94 ms/op 1.23
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 579.39 us/op 461.88 us/op 1.25
pass gossip attestations to forkchoice per slot 17.538 ms/op 15.029 ms/op 1.17
computeDeltas 3.7587 ms/op 3.7272 ms/op 1.01
computeProposerBoostScoreFromBalances 623.33 us/op 503.08 us/op 1.24
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3943 ms/op 1.7986 ms/op 1.33
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 883.10 us/op 707.85 us/op 1.25
BLS verify - blst-native 2.2827 ms/op 1.8562 ms/op 1.23
BLS verifyMultipleSignatures 3 - blst-native 4.6751 ms/op 3.8020 ms/op 1.23
BLS verifyMultipleSignatures 8 - blst-native 10.130 ms/op 8.1830 ms/op 1.24
BLS verifyMultipleSignatures 32 - blst-native 36.827 ms/op 29.675 ms/op 1.24
BLS aggregatePubkeys 32 - blst-native 49.742 us/op 40.431 us/op 1.23
BLS aggregatePubkeys 128 - blst-native 191.62 us/op 154.30 us/op 1.24
getAttestationsForBlock 69.662 ms/op 59.672 ms/op 1.17
CheckpointStateCache - add get delete 21.881 us/op 17.774 us/op 1.23
validate gossip signedAggregateAndProof - struct 5.3573 ms/op 4.4175 ms/op 1.21
validate gossip signedAggregateAndProof - treeBacked 5.3542 ms/op 4.3703 ms/op 1.23
validate gossip attestation - struct 2.5242 ms/op 2.0805 ms/op 1.21
validate gossip attestation - treeBacked 2.6114 ms/op 2.1108 ms/op 1.24
pickEth1Vote - no votes 11.158 ms/op 10.011 ms/op 1.11
pickEth1Vote - max votes 59.457 ms/op 53.318 ms/op 1.12
pickEth1Vote - Eth1Data hashTreeRoot value x2048 29.518 ms/op 24.974 ms/op 1.18
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 11.552 ms/op 9.7305 ms/op 1.19
pickEth1Vote - Eth1Data fastSerialize value x2048 6.2631 ms/op 5.1990 ms/op 1.20
pickEth1Vote - Eth1Data fastSerialize tree x2048 26.844 ms/op 24.044 ms/op 1.12
bytes32 toHexString 2.0560 us/op 1.6760 us/op 1.23
bytes32 Buffer.toString(hex) 820.00 ns/op 701.00 ns/op 1.17
bytes32 Buffer.toString(hex) from Uint8Array 1.0420 us/op 965.00 ns/op 1.08
bytes32 Buffer.toString(hex) + 0x 834.00 ns/op 710.00 ns/op 1.17
Object access 1 prop 0.41400 ns/op 0.32600 ns/op 1.27
Map access 1 prop 0.36200 ns/op 0.30800 ns/op 1.18
Object get x1000 21.106 ns/op 17.337 ns/op 1.22
Map get x1000 1.2790 ns/op 0.98600 ns/op 1.30
Object set x1000 127.03 ns/op 103.05 ns/op 1.23
Map set x1000 76.373 ns/op 64.932 ns/op 1.18
Return object 10000 times 0.44890 ns/op 0.37470 ns/op 1.20
Throw Error 10000 times 7.0404 us/op 5.7847 us/op 1.22
enrSubnets - fastDeserialize 64 bits 1.4950 us/op 1.2830 us/op 1.17
enrSubnets - ssz BitVector 64 bits 19.807 us/op 16.760 us/op 1.18
enrSubnets - fastDeserialize 4 bits 551.00 ns/op 480.00 ns/op 1.15
enrSubnets - ssz BitVector 4 bits 3.4600 us/op 3.0060 us/op 1.15
RateTracker 1000000 limit, 1 obj count per request 214.80 ns/op 181.62 ns/op 1.18
RateTracker 1000000 limit, 2 obj count per request 160.45 ns/op 137.93 ns/op 1.16
RateTracker 1000000 limit, 4 obj count per request 133.25 ns/op 114.00 ns/op 1.17
RateTracker 1000000 limit, 8 obj count per request 119.87 ns/op 101.63 ns/op 1.18
RateTracker with prune 4.8260 us/op 3.7660 us/op 1.28
array of 16000 items push then shift 3.7545 us/op 3.1588 us/op 1.19
LinkedList of 16000 items push then shift 19.323 ns/op 17.363 ns/op 1.11
array of 16000 items push then pop 237.97 ns/op 207.32 ns/op 1.15
LinkedList of 16000 items push then pop 18.213 ns/op 17.108 ns/op 1.06
array of 24000 items push then shift 5.5704 us/op 4.5554 us/op 1.22
LinkedList of 24000 items push then shift 21.923 ns/op 21.348 ns/op 1.03
array of 24000 items push then pop 246.32 ns/op 185.25 ns/op 1.33
LinkedList of 24000 items push then pop 20.443 ns/op 19.248 ns/op 1.06

by benchmarkbot/action

wemeetagain and others added 23 commits December 16, 2021 09:50
… a dummy api that returns static data"

This reverts commit c3c220e.
@dapplion
Copy link
Contributor Author

@dadepo Failing tests and conflicts

wemeetagain
wemeetagain previously approved these changes Mar 14, 2022
@dapplion
Copy link
Contributor Author

@dadepo failed build

Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

LGTM. Looking for another +1 before merging

@philknows philknows mentioned this pull request Mar 28, 2022
6 tasks
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

LGTM! should we in future save this in a leveldb repo?

@dadepo
Copy link
Contributor

dadepo commented Mar 29, 2022

... should we in future save this in a leveldb repo?

Thats an interesting one. So far, what I have observed is: it seem the general practice is to have the keystore files stored on the filesystem, but we can definitely consider/discuss pros/cons of moving it to a leveldb repo

@g11tech g11tech merged commit c5997e0 into master Apr 1, 2022
@g11tech g11tech deleted the dapplion/keymanager branch April 1, 2022 14:05
@dapplion
Copy link
Contributor Author

dapplion commented Apr 3, 2022

LGTM! should we in future save this in a leveldb repo?

I don't think so, I doesn't feel right to store a keystore in a level db. Regular JSON files feel more "auditable" and transparent

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.

Add standard keymanager API
6 participants