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

LightClientServer only import block if its new head #3967

Merged
merged 1 commit into from
May 4, 2022

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented May 3, 2022

Motivation

A block maybe imported to LightClientServer but it's not part of canonical chain in the end

Description
Only import block if it's new head

Closes #3932

@twoeths twoeths requested a review from a team as a code owner May 3, 2022 02:37
@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #3967 (986ee75) into master (a3cb495) will not change coverage.
The diff coverage is n/a.

❗ Current head 986ee75 differs from pull request most recent head d5671c9. Consider uploading reports for the commit d5671c9 to get more accurate results

@@           Coverage Diff           @@
##           master    #3967   +/-   ##
=======================================
  Coverage   36.30%   36.30%           
=======================================
  Files         324      324           
  Lines        9107     9107           
  Branches     1468     1468           
=======================================
  Hits         3306     3306           
  Misses       5628     5628           
  Partials      173      173           

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 986ee75 Previous: a3cb495 Ratio
BeaconState.hashTreeRoot - No change 478.00 ns/op 540.00 ns/op 0.89
BeaconState.hashTreeRoot - 1 full validator 60.396 us/op 55.083 us/op 1.10
BeaconState.hashTreeRoot - 32 full validator 582.77 us/op 545.85 us/op 1.07
BeaconState.hashTreeRoot - 512 full validator 6.4973 ms/op 6.0044 ms/op 1.08
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 76.366 us/op 70.324 us/op 1.09
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.0393 ms/op 957.38 us/op 1.09
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.816 ms/op 13.434 ms/op 1.03
BeaconState.hashTreeRoot - 1 balances 58.187 us/op 53.034 us/op 1.10
BeaconState.hashTreeRoot - 32 balances 502.41 us/op 474.25 us/op 1.06
BeaconState.hashTreeRoot - 512 balances 5.0713 ms/op 4.6279 ms/op 1.10
BeaconState.hashTreeRoot - 250000 balances 115.81 ms/op 102.05 ms/op 1.13
processSlot - 1 slots 10.165 us/op 9.5420 us/op 1.07
processSlot - 32 slots 1.6956 ms/op 1.5799 ms/op 1.07
getCommitteeAssignments - req 1 vs - 250000 vc 5.4523 ms/op 5.2415 ms/op 1.04
getCommitteeAssignments - req 100 vs - 250000 vc 7.8303 ms/op 7.3016 ms/op 1.07
getCommitteeAssignments - req 1000 vs - 250000 vc 8.2152 ms/op 7.8429 ms/op 1.05
computeProposers - vc 250000 17.901 ms/op 16.627 ms/op 1.08
computeEpochShuffling - vc 250000 172.26 ms/op 158.93 ms/op 1.08
getNextSyncCommittee - vc 250000 289.69 ms/op 275.25 ms/op 1.05
altair processAttestation - 250000 vs - 7PWei normalcase 3.9544 ms/op 3.9244 ms/op 1.01
altair processAttestation - 250000 vs - 7PWei worstcase 5.3839 ms/op 5.5753 ms/op 0.97
altair processAttestation - setStatus - 1/6 committees join 204.72 us/op 195.17 us/op 1.05
altair processAttestation - setStatus - 1/3 committees join 399.01 us/op 380.33 us/op 1.05
altair processAttestation - setStatus - 1/2 committees join 581.04 us/op 527.76 us/op 1.10
altair processAttestation - setStatus - 2/3 committees join 735.32 us/op 678.48 us/op 1.08
altair processAttestation - setStatus - 4/5 committees join 1.0863 ms/op 944.43 us/op 1.15
altair processAttestation - setStatus - 100% committees join 1.2549 ms/op 1.1218 ms/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase 27.509 ms/op 23.665 ms/op 1.16
altair processBlock - 250000 vs - 7PWei normalcase hashState 36.521 ms/op 34.344 ms/op 1.06
altair processBlock - 250000 vs - 7PWei worstcase 78.858 ms/op 75.794 ms/op 1.04
altair processBlock - 250000 vs - 7PWei worstcase hashState 123.49 ms/op 94.679 ms/op 1.30
altair processEth1Data - 250000 vs - 7PWei normalcase 867.39 us/op 806.54 us/op 1.08
altair processEpoch - mainnet_e81889 621.03 ms/op 467.27 ms/op 1.33
mainnet_e81889 - altair beforeProcessEpoch 146.84 ms/op 135.78 ms/op 1.08
mainnet_e81889 - altair processJustificationAndFinalization 54.784 us/op 25.084 us/op 2.18
mainnet_e81889 - altair processInactivityUpdates 11.783 ms/op 10.947 ms/op 1.08
mainnet_e81889 - altair processRewardsAndPenalties 90.251 ms/op 131.82 ms/op 0.68
mainnet_e81889 - altair processRegistryUpdates 11.032 us/op 3.8710 us/op 2.85
mainnet_e81889 - altair processSlashings 3.8840 us/op 1.2620 us/op 3.08
mainnet_e81889 - altair processEth1DataReset 4.3350 us/op 1.0930 us/op 3.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 7.2518 ms/op 7.0392 ms/op 1.03
mainnet_e81889 - altair processSlashingsReset 17.108 us/op 5.6690 us/op 3.02
mainnet_e81889 - altair processRandaoMixesReset 18.212 us/op 6.7940 us/op 2.68
mainnet_e81889 - altair processHistoricalRootsUpdate 6.6200 us/op 1.4690 us/op 4.51
mainnet_e81889 - altair processParticipationFlagUpdates 10.349 us/op 3.0520 us/op 3.39
mainnet_e81889 - altair processSyncCommitteeUpdates 3.7680 us/op 1.1870 us/op 3.17
mainnet_e81889 - altair afterProcessEpoch 205.39 ms/op 182.55 ms/op 1.13
altair processInactivityUpdates - 250000 normalcase 38.656 ms/op 30.432 ms/op 1.27
altair processInactivityUpdates - 250000 worstcase 29.596 ms/op 26.019 ms/op 1.14
altair processRewardsAndPenalties - 250000 normalcase 139.79 ms/op 78.763 ms/op 1.77
altair processRewardsAndPenalties - 250000 worstcase 122.71 ms/op 111.53 ms/op 1.10
altair processSyncCommitteeUpdates - 250000 303.74 ms/op 281.04 ms/op 1.08
Tree 40 250000 create 638.19 ms/op 641.40 ms/op 0.99
Tree 40 250000 get(125000) 304.19 ns/op 288.62 ns/op 1.05
Tree 40 250000 set(125000) 2.0823 us/op 2.1430 us/op 0.97
Tree 40 250000 toArray() 30.859 ms/op 31.324 ms/op 0.99
Tree 40 250000 iterate all - toArray() + loop 31.078 ms/op 31.005 ms/op 1.00
Tree 40 250000 iterate all - get(i) 115.20 ms/op 109.37 ms/op 1.05
MutableVector 250000 create 16.340 ms/op 14.623 ms/op 1.12
MutableVector 250000 get(125000) 14.743 ns/op 13.108 ns/op 1.12
MutableVector 250000 set(125000) 540.02 ns/op 567.08 ns/op 0.95
MutableVector 250000 toArray() 6.1356 ms/op 6.4947 ms/op 0.94
MutableVector 250000 iterate all - toArray() + loop 6.5572 ms/op 6.6496 ms/op 0.99
MutableVector 250000 iterate all - get(i) 3.5996 ms/op 3.4410 ms/op 1.05
Array 250000 create 5.6806 ms/op 5.9908 ms/op 0.95
Array 250000 clone - spread 2.6804 ms/op 2.5079 ms/op 1.07
Array 250000 get(125000) 1.2320 ns/op 1.1610 ns/op 1.06
Array 250000 set(125000) 1.2440 ns/op 1.1400 ns/op 1.09
Array 250000 iterate all - loop 188.17 us/op 168.91 us/op 1.11
effectiveBalanceIncrements clone Uint8Array 300000 73.965 us/op 78.446 us/op 0.94
effectiveBalanceIncrements clone MutableVector 300000 849.00 ns/op 530.00 ns/op 1.60
effectiveBalanceIncrements rw all Uint8Array 300000 325.31 us/op 301.81 us/op 1.08
effectiveBalanceIncrements rw all MutableVector 300000 181.08 ms/op 146.79 ms/op 1.23
aggregationBits - 2048 els - zipIndexesInBitList 29.191 us/op 23.452 us/op 1.24
regular array get 100000 times 75.634 us/op 67.449 us/op 1.12
wrappedArray get 100000 times 74.559 us/op 67.433 us/op 1.11
arrayWithProxy get 100000 times 32.829 ms/op 32.761 ms/op 1.00
ssz.Root.equals 536.00 ns/op 434.00 ns/op 1.24
byteArrayEquals 512.00 ns/op 440.00 ns/op 1.16
phase0 processBlock - 250000 vs - 7PWei normalcase 3.9552 ms/op 3.3400 ms/op 1.18
phase0 processBlock - 250000 vs - 7PWei worstcase 50.481 ms/op 45.512 ms/op 1.11
phase0 afterProcessEpoch - 250000 vs - 7PWei 193.75 ms/op 174.23 ms/op 1.11
phase0 beforeProcessEpoch - 250000 vs - 7PWei 79.330 ms/op 72.690 ms/op 1.09
phase0 processEpoch - mainnet_e58758 544.78 ms/op 498.77 ms/op 1.09
mainnet_e58758 - phase0 beforeProcessEpoch 237.38 ms/op 217.44 ms/op 1.09
mainnet_e58758 - phase0 processJustificationAndFinalization 53.909 us/op 22.576 us/op 2.39
mainnet_e58758 - phase0 processRewardsAndPenalties 143.85 ms/op 127.28 ms/op 1.13
mainnet_e58758 - phase0 processRegistryUpdates 18.734 us/op 9.3320 us/op 2.01
mainnet_e58758 - phase0 processSlashings 4.8980 us/op 1.2600 us/op 3.89
mainnet_e58758 - phase0 processEth1DataReset 4.3850 us/op 1.0270 us/op 4.27
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 6.2322 ms/op 6.3587 ms/op 0.98
mainnet_e58758 - phase0 processSlashingsReset 15.742 us/op 5.3130 us/op 2.96
mainnet_e58758 - phase0 processRandaoMixesReset 15.459 us/op 5.4670 us/op 2.83
mainnet_e58758 - phase0 processHistoricalRootsUpdate 5.2250 us/op 1.4710 us/op 3.55
mainnet_e58758 - phase0 processParticipationRecordUpdates 14.574 us/op 5.0620 us/op 2.88
mainnet_e58758 - phase0 afterProcessEpoch 163.94 ms/op 152.55 ms/op 1.07
phase0 processEffectiveBalanceUpdates - 250000 normalcase 7.2780 ms/op 6.3401 ms/op 1.15
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 7.6350 ms/op 6.8694 ms/op 1.11
phase0 processRegistryUpdates - 250000 normalcase 21.267 us/op 8.5200 us/op 2.50
phase0 processRegistryUpdates - 250000 badcase_full_deposits 640.02 us/op 434.01 us/op 1.47
phase0 processRegistryUpdates - 250000 worstcase 0.5 232.75 ms/op 213.73 ms/op 1.09
phase0 getAttestationDeltas - 250000 normalcase 15.942 ms/op 15.586 ms/op 1.02
phase0 getAttestationDeltas - 250000 worstcase 15.729 ms/op 15.369 ms/op 1.02
phase0 processSlashings - 250000 worstcase 7.1637 ms/op 5.9234 ms/op 1.21
shuffle list - 16384 els 11.518 ms/op 10.678 ms/op 1.08
shuffle list - 250000 els 166.62 ms/op 153.97 ms/op 1.08
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 395.08 us/op 359.39 us/op 1.10
pass gossip attestations to forkchoice per slot 3.6073 ms/op 3.3897 ms/op 1.06
computeDeltas 3.9416 ms/op 3.3259 ms/op 1.19
computeProposerBoostScoreFromBalances 547.94 us/op 502.78 us/op 1.09
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.0180 ms/op 2.1305 ms/op 0.95
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 75.065 us/op 72.874 us/op 1.03
BLS verify - blst-native 2.0074 ms/op 1.8550 ms/op 1.08
BLS verifyMultipleSignatures 3 - blst-native 4.1910 ms/op 3.7922 ms/op 1.11
BLS verifyMultipleSignatures 8 - blst-native 8.9868 ms/op 8.1648 ms/op 1.10
BLS verifyMultipleSignatures 32 - blst-native 31.756 ms/op 29.630 ms/op 1.07
BLS aggregatePubkeys 32 - blst-native 42.437 us/op 39.928 us/op 1.06
BLS aggregatePubkeys 128 - blst-native 167.91 us/op 153.09 us/op 1.10
getAttestationsForBlock 60.552 ms/op 56.020 ms/op 1.08
CheckpointStateCache - add get delete 11.018 us/op 10.308 us/op 1.07
validate gossip signedAggregateAndProof - struct 4.6088 ms/op 4.2653 ms/op 1.08
validate gossip attestation - struct 2.2247 ms/op 2.0266 ms/op 1.10
pickEth1Vote - no votes 2.4354 ms/op 2.1850 ms/op 1.11
pickEth1Vote - max votes 20.247 ms/op 19.025 ms/op 1.06
pickEth1Vote - Eth1Data hashTreeRoot value x2048 11.368 ms/op 11.002 ms/op 1.03
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.466 ms/op 19.828 ms/op 1.08
pickEth1Vote - Eth1Data fastSerialize value x2048 1.7217 ms/op 1.6743 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize tree x2048 12.435 ms/op 12.177 ms/op 1.02
bytes32 toHexString 1.0100 us/op 933.00 ns/op 1.08
bytes32 Buffer.toString(hex) 816.00 ns/op 681.00 ns/op 1.20
bytes32 Buffer.toString(hex) from Uint8Array 964.00 ns/op 915.00 ns/op 1.05
bytes32 Buffer.toString(hex) + 0x 750.00 ns/op 698.00 ns/op 1.07
Object access 1 prop 0.36000 ns/op 0.34300 ns/op 1.05
Map access 1 prop 0.34400 ns/op 0.29800 ns/op 1.15
Object get x1000 18.725 ns/op 17.130 ns/op 1.09
Map get x1000 1.0830 ns/op 1.0090 ns/op 1.07
Object set x1000 109.41 ns/op 108.89 ns/op 1.00
Map set x1000 65.499 ns/op 68.058 ns/op 0.96
Return object 10000 times 0.43120 ns/op 0.37100 ns/op 1.16
Throw Error 10000 times 6.4693 us/op 5.8652 us/op 1.10
enrSubnets - fastDeserialize 64 bits 2.9300 us/op 2.6710 us/op 1.10
enrSubnets - ssz BitVector 64 bits 836.00 ns/op 753.00 ns/op 1.11
enrSubnets - fastDeserialize 4 bits 458.00 ns/op 406.00 ns/op 1.13
enrSubnets - ssz BitVector 4 bits 854.00 ns/op 773.00 ns/op 1.10
RateTracker 1000000 limit, 1 obj count per request 193.90 ns/op 182.33 ns/op 1.06
RateTracker 1000000 limit, 2 obj count per request 141.64 ns/op 136.55 ns/op 1.04
RateTracker 1000000 limit, 4 obj count per request 118.97 ns/op 113.66 ns/op 1.05
RateTracker 1000000 limit, 8 obj count per request 101.11 ns/op 101.66 ns/op 0.99
RateTracker with prune 3.7750 us/op 3.8200 us/op 0.99
array of 16000 items push then shift 3.3140 us/op 3.0858 us/op 1.07
LinkedList of 16000 items push then shift 17.116 ns/op 16.502 ns/op 1.04
array of 16000 items push then pop 230.21 ns/op 203.02 ns/op 1.13
LinkedList of 16000 items push then pop 17.119 ns/op 15.267 ns/op 1.12
array of 24000 items push then shift 5.0903 us/op 4.5566 us/op 1.12
LinkedList of 24000 items push then shift 19.556 ns/op 18.449 ns/op 1.06
array of 24000 items push then pop 212.05 ns/op 193.15 ns/op 1.10
LinkedList of 24000 items push then pop 18.247 ns/op 17.022 ns/op 1.07

by benchmarkbot/action

@dapplion dapplion merged commit 3eeb6e2 into master May 4, 2022
@dapplion dapplion deleted the tuyen/light-client-server-on-import-block branch May 4, 2022 17:05
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.

Lightclient may use a missed block as best partial update
3 participants