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

Lodestar prover for execution api #5222

Merged
merged 30 commits into from
Mar 26, 2023
Merged

Lodestar prover for execution api #5222

merged 30 commits into from
Mar 26, 2023

Conversation

nazarhussain
Copy link
Contributor

@nazarhussain nazarhussain commented Mar 1, 2023

Motivation

Make it easier for third party developers to utilize the light client and verify the non-trusted eth responses.

Description

Create a lightclient prover utility for web3 providers.

Closes #4706

Steps to test or reproduce

Run all tests.

git checkout <feature_branch>
lodestar beacon --new-flag option1

Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Overall direction looks good! 🔥 looking forward to the polished PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: a374790 Previous: 6d3ec2b Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 918.01 us/op 959.61 us/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.270 us/op 49.781 us/op 0.93
BLS verify - blst-native 1.2041 ms/op 1.2256 ms/op 0.98
BLS verifyMultipleSignatures 3 - blst-native 2.4483 ms/op 2.4974 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst-native 5.2590 ms/op 5.3834 ms/op 0.98
BLS verifyMultipleSignatures 32 - blst-native 19.058 ms/op 19.325 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 25.233 us/op 26.122 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 97.842 us/op 101.10 us/op 0.97
getAttestationsForBlock 53.009 ms/op 58.476 ms/op 0.91
isKnown best case - 1 super set check 247.00 ns/op 261.00 ns/op 0.95
isKnown normal case - 2 super set checks 240.00 ns/op 254.00 ns/op 0.94
isKnown worse case - 16 super set checks 242.00 ns/op 251.00 ns/op 0.96
CheckpointStateCache - add get delete 4.6770 us/op 5.6760 us/op 0.82
validate gossip signedAggregateAndProof - struct 2.7338 ms/op 2.8186 ms/op 0.97
validate gossip attestation - struct 1.2921 ms/op 1.3426 ms/op 0.96
pickEth1Vote - no votes 1.2508 ms/op 1.3643 ms/op 0.92
pickEth1Vote - max votes 10.204 ms/op 8.9592 ms/op 1.14
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.5275 ms/op 8.5147 ms/op 1.00
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.418 ms/op 14.026 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize value x2048 705.35 us/op 717.71 us/op 0.98
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.8233 ms/op 5.1744 ms/op 1.51
bytes32 toHexString 478.00 ns/op 663.00 ns/op 0.72
bytes32 Buffer.toString(hex) 340.00 ns/op 426.00 ns/op 0.80
bytes32 Buffer.toString(hex) from Uint8Array 552.00 ns/op 612.00 ns/op 0.90
bytes32 Buffer.toString(hex) + 0x 342.00 ns/op 399.00 ns/op 0.86
Object access 1 prop 0.16100 ns/op 0.19200 ns/op 0.84
Map access 1 prop 0.15700 ns/op 0.16300 ns/op 0.96
Object get x1000 6.6400 ns/op 6.8570 ns/op 0.97
Map get x1000 0.60900 ns/op 0.61600 ns/op 0.99
Object set x1000 50.720 ns/op 56.105 ns/op 0.90
Map set x1000 41.727 ns/op 46.927 ns/op 0.89
Return object 10000 times 0.23320 ns/op 0.24050 ns/op 0.97
Throw Error 10000 times 4.1522 us/op 4.2512 us/op 0.98
fastMsgIdFn sha256 / 200 bytes 3.3860 us/op 3.4630 us/op 0.98
fastMsgIdFn h32 xxhash / 200 bytes 276.00 ns/op 301.00 ns/op 0.92
fastMsgIdFn h64 xxhash / 200 bytes 387.00 ns/op 427.00 ns/op 0.91
fastMsgIdFn sha256 / 1000 bytes 11.428 us/op 11.728 us/op 0.97
fastMsgIdFn h32 xxhash / 1000 bytes 401.00 ns/op 433.00 ns/op 0.93
fastMsgIdFn h64 xxhash / 1000 bytes 457.00 ns/op 489.00 ns/op 0.93
fastMsgIdFn sha256 / 10000 bytes 102.78 us/op 104.09 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 1.8950 us/op 1.9280 us/op 0.98
fastMsgIdFn h64 xxhash / 10000 bytes 1.3590 us/op 1.3520 us/op 1.01
enrSubnets - fastDeserialize 64 bits 1.2620 us/op 1.3180 us/op 0.96
enrSubnets - ssz BitVector 64 bits 470.00 ns/op 494.00 ns/op 0.95
enrSubnets - fastDeserialize 4 bits 167.00 ns/op 170.00 ns/op 0.98
enrSubnets - ssz BitVector 4 bits 479.00 ns/op 512.00 ns/op 0.94
prioritizePeers score -10:0 att 32-0.1 sync 2-0 102.18 us/op 122.15 us/op 0.84
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 130.34 us/op 144.79 us/op 0.90
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 165.87 us/op 173.98 us/op 0.95
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 299.77 us/op 341.38 us/op 0.88
prioritizePeers score 0:0 att 64-1 sync 4-1 360.42 us/op 408.54 us/op 0.88
array of 16000 items push then shift 1.6397 us/op 1.6611 us/op 0.99
LinkedList of 16000 items push then shift 8.7890 ns/op 8.9060 ns/op 0.99
array of 16000 items push then pop 81.682 ns/op 106.58 ns/op 0.77
LinkedList of 16000 items push then pop 8.4540 ns/op 8.6620 ns/op 0.98
array of 24000 items push then shift 2.3589 us/op 2.3681 us/op 1.00
LinkedList of 24000 items push then shift 8.7140 ns/op 8.8270 ns/op 0.99
array of 24000 items push then pop 76.618 ns/op 82.501 ns/op 0.93
LinkedList of 24000 items push then pop 8.2070 ns/op 8.6070 ns/op 0.95
intersect bitArray bitLen 8 12.818 ns/op 13.378 ns/op 0.96
intersect array and set length 8 74.848 ns/op 79.891 ns/op 0.94
intersect bitArray bitLen 128 42.707 ns/op 44.465 ns/op 0.96
intersect array and set length 128 1.0114 us/op 1.1355 us/op 0.89
Buffer.concat 32 items 2.5840 us/op 2.9880 us/op 0.86
Uint8Array.set 32 items 2.6490 us/op 2.8920 us/op 0.92
pass gossip attestations to forkchoice per slot 3.0855 ms/op 3.0049 ms/op 1.03
computeDeltas 2.8362 ms/op 2.9022 ms/op 0.98
computeProposerBoostScoreFromBalances 1.7823 ms/op 1.8197 ms/op 0.98
altair processAttestation - 250000 vs - 7PWei normalcase 2.1433 ms/op 3.1364 ms/op 0.68
altair processAttestation - 250000 vs - 7PWei worstcase 3.2753 ms/op 3.8072 ms/op 0.86
altair processAttestation - setStatus - 1/6 committees join 138.13 us/op 140.33 us/op 0.98
altair processAttestation - setStatus - 1/3 committees join 271.05 us/op 279.85 us/op 0.97
altair processAttestation - setStatus - 1/2 committees join 374.21 us/op 371.02 us/op 1.01
altair processAttestation - setStatus - 2/3 committees join 466.49 us/op 470.72 us/op 0.99
altair processAttestation - setStatus - 4/5 committees join 649.09 us/op 682.46 us/op 0.95
altair processAttestation - setStatus - 100% committees join 765.58 us/op 767.75 us/op 1.00
altair processBlock - 250000 vs - 7PWei normalcase 18.683 ms/op 19.100 ms/op 0.98
altair processBlock - 250000 vs - 7PWei normalcase hashState 25.851 ms/op 26.868 ms/op 0.96
altair processBlock - 250000 vs - 7PWei worstcase 46.853 ms/op 52.310 ms/op 0.90
altair processBlock - 250000 vs - 7PWei worstcase hashState 66.482 ms/op 76.643 ms/op 0.87
phase0 processBlock - 250000 vs - 7PWei normalcase 2.1478 ms/op 2.3170 ms/op 0.93
phase0 processBlock - 250000 vs - 7PWei worstcase 28.673 ms/op 30.417 ms/op 0.94
altair processEth1Data - 250000 vs - 7PWei normalcase 463.84 us/op 500.45 us/op 0.93
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 6.8560 us/op 8.0550 us/op 0.85
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 19.051 us/op 26.643 us/op 0.72
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 8.2890 us/op 10.782 us/op 0.77
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.5060 us/op 7.6990 us/op 0.85
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 74.646 us/op 99.942 us/op 0.75
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 624.48 us/op 656.94 us/op 0.95
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 901.47 us/op 915.90 us/op 0.98
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 828.31 us/op 891.92 us/op 0.93
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.2325 ms/op 2.4659 ms/op 0.91
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.6864 ms/op 1.6442 ms/op 1.03
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.9282 ms/op 4.6801 ms/op 0.84
Tree 40 250000 create 306.59 ms/op 312.27 ms/op 0.98
Tree 40 250000 get(125000) 182.24 ns/op 178.30 ns/op 1.02
Tree 40 250000 set(125000) 940.63 ns/op 913.12 ns/op 1.03
Tree 40 250000 toArray() 16.678 ms/op 17.081 ms/op 0.98
Tree 40 250000 iterate all - toArray() + loop 16.958 ms/op 16.692 ms/op 1.02
Tree 40 250000 iterate all - get(i) 64.128 ms/op 64.967 ms/op 0.99
MutableVector 250000 create 9.8341 ms/op 10.592 ms/op 0.93
MutableVector 250000 get(125000) 6.1530 ns/op 6.3150 ns/op 0.97
MutableVector 250000 set(125000) 242.54 ns/op 257.12 ns/op 0.94
MutableVector 250000 toArray() 2.6542 ms/op 2.8681 ms/op 0.93
MutableVector 250000 iterate all - toArray() + loop 2.7605 ms/op 3.0020 ms/op 0.92
MutableVector 250000 iterate all - get(i) 1.5176 ms/op 1.5067 ms/op 1.01
Array 250000 create 2.5202 ms/op 2.6193 ms/op 0.96
Array 250000 clone - spread 1.2011 ms/op 1.2643 ms/op 0.95
Array 250000 get(125000) 0.58400 ns/op 0.60000 ns/op 0.97
Array 250000 set(125000) 0.66000 ns/op 0.68800 ns/op 0.96
Array 250000 iterate all - loop 91.975 us/op 100.73 us/op 0.91
effectiveBalanceIncrements clone Uint8Array 300000 25.510 us/op 29.733 us/op 0.86
effectiveBalanceIncrements clone MutableVector 300000 384.00 ns/op 415.00 ns/op 0.93
effectiveBalanceIncrements rw all Uint8Array 300000 168.41 us/op 167.24 us/op 1.01
effectiveBalanceIncrements rw all MutableVector 300000 81.653 ms/op 84.220 ms/op 0.97
phase0 afterProcessEpoch - 250000 vs - 7PWei 112.05 ms/op 109.93 ms/op 1.02
phase0 beforeProcessEpoch - 250000 vs - 7PWei 38.475 ms/op 32.633 ms/op 1.18
altair processEpoch - mainnet_e81889 298.47 ms/op 323.77 ms/op 0.92
mainnet_e81889 - altair beforeProcessEpoch 46.221 ms/op 48.685 ms/op 0.95
mainnet_e81889 - altair processJustificationAndFinalization 17.649 us/op 17.546 us/op 1.01
mainnet_e81889 - altair processInactivityUpdates 4.7163 ms/op 5.7535 ms/op 0.82
mainnet_e81889 - altair processRewardsAndPenalties 68.689 ms/op 53.093 ms/op 1.29
mainnet_e81889 - altair processRegistryUpdates 2.8560 us/op 2.4960 us/op 1.14
mainnet_e81889 - altair processSlashings 471.00 ns/op 426.00 ns/op 1.11
mainnet_e81889 - altair processEth1DataReset 521.00 ns/op 500.00 ns/op 1.04
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2357 ms/op 1.2326 ms/op 1.00
mainnet_e81889 - altair processSlashingsReset 4.5290 us/op 5.3290 us/op 0.85
mainnet_e81889 - altair processRandaoMixesReset 4.3130 us/op 4.6890 us/op 0.92
mainnet_e81889 - altair processHistoricalRootsUpdate 536.00 ns/op 603.00 ns/op 0.89
mainnet_e81889 - altair processParticipationFlagUpdates 2.4960 us/op 2.3860 us/op 1.05
mainnet_e81889 - altair processSyncCommitteeUpdates 536.00 ns/op 522.00 ns/op 1.03
mainnet_e81889 - altair afterProcessEpoch 116.83 ms/op 116.66 ms/op 1.00
phase0 processEpoch - mainnet_e58758 316.06 ms/op 313.18 ms/op 1.01
mainnet_e58758 - phase0 beforeProcessEpoch 119.74 ms/op 122.34 ms/op 0.98
mainnet_e58758 - phase0 processJustificationAndFinalization 16.484 us/op 16.862 us/op 0.98
mainnet_e58758 - phase0 processRewardsAndPenalties 57.725 ms/op 54.104 ms/op 1.07
mainnet_e58758 - phase0 processRegistryUpdates 7.4810 us/op 7.6730 us/op 0.97
mainnet_e58758 - phase0 processSlashings 498.00 ns/op 460.00 ns/op 1.08
mainnet_e58758 - phase0 processEth1DataReset 472.00 ns/op 541.00 ns/op 0.87
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 941.78 us/op 938.03 us/op 1.00
mainnet_e58758 - phase0 processSlashingsReset 2.8780 us/op 2.9430 us/op 0.98
mainnet_e58758 - phase0 processRandaoMixesReset 4.4590 us/op 4.5390 us/op 0.98
mainnet_e58758 - phase0 processHistoricalRootsUpdate 614.00 ns/op 600.00 ns/op 1.02
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.8160 us/op 3.9800 us/op 0.96
mainnet_e58758 - phase0 afterProcessEpoch 96.062 ms/op 96.417 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2054 ms/op 1.2005 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4432 ms/op 1.3547 ms/op 1.07
altair processInactivityUpdates - 250000 normalcase 21.852 ms/op 20.033 ms/op 1.09
altair processInactivityUpdates - 250000 worstcase 22.143 ms/op 22.663 ms/op 0.98
phase0 processRegistryUpdates - 250000 normalcase 6.2340 us/op 6.1300 us/op 1.02
phase0 processRegistryUpdates - 250000 badcase_full_deposits 241.92 us/op 240.20 us/op 1.01
phase0 processRegistryUpdates - 250000 worstcase 0.5 115.18 ms/op 111.72 ms/op 1.03
altair processRewardsAndPenalties - 250000 normalcase 42.120 ms/op 56.164 ms/op 0.75
altair processRewardsAndPenalties - 250000 worstcase 56.574 ms/op 50.605 ms/op 1.12
phase0 getAttestationDeltas - 250000 normalcase 6.4392 ms/op 6.3181 ms/op 1.02
phase0 getAttestationDeltas - 250000 worstcase 6.3859 ms/op 6.4741 ms/op 0.99
phase0 processSlashings - 250000 worstcase 3.5124 ms/op 3.4894 ms/op 1.01
altair processSyncCommitteeUpdates - 250000 171.54 ms/op 173.56 ms/op 0.99
BeaconState.hashTreeRoot - No change 258.00 ns/op 258.00 ns/op 1.00
BeaconState.hashTreeRoot - 1 full validator 50.389 us/op 49.978 us/op 1.01
BeaconState.hashTreeRoot - 32 full validator 482.07 us/op 498.61 us/op 0.97
BeaconState.hashTreeRoot - 512 full validator 5.4400 ms/op 4.9709 ms/op 1.09
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 60.888 us/op 67.433 us/op 0.90
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 871.00 us/op 893.16 us/op 0.98
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.077 ms/op 12.164 ms/op 0.91
BeaconState.hashTreeRoot - 1 balances 48.214 us/op 48.522 us/op 0.99
BeaconState.hashTreeRoot - 32 balances 444.83 us/op 454.55 us/op 0.98
BeaconState.hashTreeRoot - 512 balances 4.2966 ms/op 4.3966 ms/op 0.98
BeaconState.hashTreeRoot - 250000 balances 73.265 ms/op 72.032 ms/op 1.02
aggregationBits - 2048 els - zipIndexesInBitList 16.011 us/op 16.348 us/op 0.98
regular array get 100000 times 31.332 us/op 32.306 us/op 0.97
wrappedArray get 100000 times 31.428 us/op 33.001 us/op 0.95
arrayWithProxy get 100000 times 15.879 ms/op 16.311 ms/op 0.97
ssz.Root.equals 524.00 ns/op 542.00 ns/op 0.97
byteArrayEquals 513.00 ns/op 542.00 ns/op 0.95
shuffle list - 16384 els 6.7775 ms/op 6.9222 ms/op 0.98
shuffle list - 250000 els 99.760 ms/op 102.77 ms/op 0.97
processSlot - 1 slots 8.4360 us/op 8.6700 us/op 0.97
processSlot - 32 slots 1.3198 ms/op 1.3764 ms/op 0.96
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 33.798 ms/op 33.643 ms/op 1.00
getCommitteeAssignments - req 1 vs - 250000 vc 2.9252 ms/op 2.9890 ms/op 0.98
getCommitteeAssignments - req 100 vs - 250000 vc 4.1205 ms/op 4.2375 ms/op 0.97
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5026 ms/op 4.5989 ms/op 0.98
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.6700 ns/op 5.0100 ns/op 0.93
state getBlockRootAtSlot - 250000 vs - 7PWei 898.38 ns/op 657.12 ns/op 1.37
computeProposers - vc 250000 10.058 ms/op 11.946 ms/op 0.84
computeEpochShuffling - vc 250000 98.915 ms/op 108.73 ms/op 0.91
getNextSyncCommittee - vc 250000 174.28 ms/op 191.41 ms/op 0.91

by benchmarkbot/action

@nazarhussain
Copy link
Contributor Author

This PR functionality is ready and tested manually with the example given in the readme file. Now adding the unit and integration tests.

Please share your earlier feedback.

const verifiedHandler = supportedELRequests[payload.method];

if (verifiedHandler !== undefined) {
return verifiedHandler({payload, handler, rootProvider: proofProvider});

Check failure

Code scanning / CodeQL

Unvalidated dynamic method call

Invocation of method with [user-controlled](1) name may dispatch to unexpected target and cause an exception.
@nazarhussain nazarhussain marked this pull request as ready for review March 8, 2023 21:41
@nazarhussain nazarhussain requested a review from a team as a code owner March 8, 2023 21:41
@g11tech
Copy link
Contributor

g11tech commented Mar 13, 2023

looks exciting on the first pass 👏 , will need to give more brain/review cycles to the PR

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.

approving with the caveat that followup PRs would need to polish and address some of the unaddressed issues here to productionize the prover

But an amazing effort here to bring such an amazing functionality to lodestar codebase! 👏

@nazarhussain
Copy link
Contributor Author

approving with the caveat that followup PRs would need to polish and address some of the unaddressed issues here to productionize the prover

But an amazing effort here to bring such an amazing functionality to lodestar codebase! 👏

All the remaining points are added as action item to this issue #4706 so we will not forget it.

@nazarhussain nazarhussain merged commit 358b9e0 into unstable Mar 26, 2023
@nazarhussain nazarhussain deleted the nh/4706-lc-prover branch March 26, 2023 13:28
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.8.0 🎉

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.

Lodestar prover for execution api
4 participants