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

Fix LightClientUpdate headers #3656

Merged
merged 3 commits into from
Jan 28, 2022
Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Jan 22, 2022

Motivation

Fix LightClientUpdate wrong header assignments

@codeclimate
Copy link

codeclimate bot commented Jan 22, 2022

Code Climate has analyzed commit aa4d279 and detected 0 issues on this pull request.

View more on Code Climate.

@codecov
Copy link

codecov bot commented Jan 22, 2022

Codecov Report

Merging #3656 (aa4d279) into master (f9cb593) will decrease coverage by 0.44%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3656      +/-   ##
==========================================
- Coverage   37.16%   36.72%   -0.45%     
==========================================
  Files         321      322       +1     
  Lines        8696     9147     +451     
  Branches     1348     1483     +135     
==========================================
+ Hits         3232     3359     +127     
- Misses       5319     5642     +323     
- Partials      145      146       +1     

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 76903d7 Previous: 50a46bb Ratio
BeaconState.hashTreeRoot - No change 640.00 ns/op 649.00 ns/op 0.99
BeaconState.hashTreeRoot - 1 full validator 153.42 us/op 175.63 us/op 0.87
BeaconState.hashTreeRoot - 32 full validator 2.3292 ms/op 2.5263 ms/op 0.92
BeaconState.hashTreeRoot - 512 full validator 30.747 ms/op 32.781 ms/op 0.94
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 156.43 us/op 168.19 us/op 0.93
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.4952 ms/op 2.6842 ms/op 0.93
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 33.775 ms/op 34.358 ms/op 0.98
BeaconState.hashTreeRoot - 1 balances 110.67 us/op 124.53 us/op 0.89
BeaconState.hashTreeRoot - 32 balances 908.30 us/op 1.0309 ms/op 0.88
BeaconState.hashTreeRoot - 512 balances 9.0589 ms/op 9.3286 ms/op 0.97
BeaconState.hashTreeRoot - 250000 balances 163.23 ms/op 172.17 ms/op 0.95
processSlot - 1 slots 58.362 us/op 65.688 us/op 0.89
processSlot - 32 slots 3.9677 ms/op 3.6685 ms/op 1.08
getCommitteeAssignments - req 1 vs - 250000 vc 6.6806 ms/op 5.0255 ms/op 1.33
getCommitteeAssignments - req 100 vs - 250000 vc 9.1691 ms/op 7.5568 ms/op 1.21
getCommitteeAssignments - req 1000 vs - 250000 vc 9.3808 ms/op 8.1266 ms/op 1.15
computeProposers - vc 250000 24.364 ms/op 24.602 ms/op 0.99
computeEpochShuffling - vc 250000 217.89 ms/op 191.59 ms/op 1.14
getNextSyncCommittee - vc 250000 398.15 ms/op 402.73 ms/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 51.503 ms/op 50.495 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei worstcase 54.657 ms/op 53.221 ms/op 1.03
altair processAttestation - setStatus - 1/6 committees join 12.825 ms/op 14.207 ms/op 0.90
altair processAttestation - setStatus - 1/3 committees join 33.999 ms/op 29.416 ms/op 1.16
altair processAttestation - setStatus - 1/2 committees join 42.705 ms/op 42.020 ms/op 1.02
altair processAttestation - setStatus - 2/3 committees join 55.377 ms/op 56.116 ms/op 0.99
altair processAttestation - setStatus - 4/5 committees join 66.768 ms/op 67.494 ms/op 0.99
altair processAttestation - setStatus - 100% committees join 81.998 ms/op 89.439 ms/op 0.92
altair processAttestation - updateEpochParticipants - 1/6 committees join 14.312 ms/op 14.334 ms/op 1.00
altair processAttestation - updateEpochParticipants - 1/3 committees join 29.776 ms/op 29.694 ms/op 1.00
altair processAttestation - updateEpochParticipants - 1/2 committees join 38.338 ms/op 30.407 ms/op 1.26
altair processAttestation - updateEpochParticipants - 2/3 committees join 33.962 ms/op 38.269 ms/op 0.89
altair processAttestation - updateEpochParticipants - 4/5 committees join 36.227 ms/op 32.768 ms/op 1.11
altair processAttestation - updateEpochParticipants - 100% committees join 36.970 ms/op 36.477 ms/op 1.01
altair processAttestation - updateAllStatus 26.159 ms/op 25.089 ms/op 1.04
altair processBlock - 250000 vs - 7PWei normalcase 54.521 ms/op 157.16 ms/op 0.35
altair processBlock - 250000 vs - 7PWei worstcase 141.25 ms/op 132.33 ms/op 1.07
altair processEpoch - mainnet_e81889 1.3052 s/op 1.2040 s/op 1.08
mainnet_e81889 - altair beforeProcessEpoch 321.61 ms/op 395.99 ms/op 0.81
mainnet_e81889 - altair processJustificationAndFinalization 71.204 us/op 115.28 us/op 0.62
mainnet_e81889 - altair processInactivityUpdates 21.631 ms/op 19.006 ms/op 1.14
mainnet_e81889 - altair processRewardsAndPenalties 280.82 ms/op 280.57 ms/op 1.00
mainnet_e81889 - altair processRegistryUpdates 10.509 us/op 21.003 us/op 0.50
mainnet_e81889 - altair processSlashings 3.5070 us/op 6.3970 us/op 0.55
mainnet_e81889 - altair processEth1DataReset 2.8060 us/op 6.0870 us/op 0.46
mainnet_e81889 - altair processEffectiveBalanceUpdates 14.060 ms/op 14.744 ms/op 0.95
mainnet_e81889 - altair processSlashingsReset 16.117 us/op 34.467 us/op 0.47
mainnet_e81889 - altair processRandaoMixesReset 22.990 us/op 40.933 us/op 0.56
mainnet_e81889 - altair processHistoricalRootsUpdate 4.2220 us/op 8.9130 us/op 0.47
mainnet_e81889 - altair processParticipationFlagUpdates 167.86 ms/op 122.26 ms/op 1.37
mainnet_e81889 - altair processSyncCommitteeUpdates 2.9440 us/op 5.7090 us/op 0.52
mainnet_e81889 - altair afterProcessEpoch 267.34 ms/op 274.68 ms/op 0.97
altair processInactivityUpdates - 250000 normalcase 87.377 ms/op 95.129 ms/op 0.92
altair processInactivityUpdates - 250000 worstcase 87.935 ms/op 77.601 ms/op 1.13
altair processParticipationFlagUpdates - 250000 anycase 133.90 ms/op 133.98 ms/op 1.00
altair processRewardsAndPenalties - 250000 normalcase 284.14 ms/op 255.26 ms/op 1.11
altair processRewardsAndPenalties - 250000 worstcase 255.27 ms/op 290.75 ms/op 0.88
altair processSyncCommitteeUpdates - 250000 421.53 ms/op 465.03 ms/op 0.91
Tree 40 250000 create 986.10 ms/op 909.36 ms/op 1.08
Tree 40 250000 get(125000) 384.03 ns/op 333.01 ns/op 1.15
Tree 40 250000 set(125000) 2.1578 us/op 3.1076 us/op 0.69
Tree 40 250000 toArray() 43.875 ms/op 58.742 ms/op 0.75
Tree 40 250000 iterate all - toArray() + loop 52.434 ms/op 46.684 ms/op 1.12
Tree 40 250000 iterate all - get(i) 141.51 ms/op 134.54 ms/op 1.05
MutableVector 250000 create 31.935 ms/op 20.609 ms/op 1.55
MutableVector 250000 get(125000) 17.857 ns/op 16.400 ns/op 1.09
MutableVector 250000 set(125000) 610.71 ns/op 700.23 ns/op 0.87
MutableVector 250000 toArray() 10.605 ms/op 9.9587 ms/op 1.06
MutableVector 250000 iterate all - toArray() + loop 10.924 ms/op 9.0941 ms/op 1.20
MutableVector 250000 iterate all - get(i) 4.0945 ms/op 3.5086 ms/op 1.17
Array 250000 create 7.1740 ms/op 5.6584 ms/op 1.27
Array 250000 clone - spread 2.9811 ms/op 1.9603 ms/op 1.52
Array 250000 get(125000) 1.3120 ns/op 1.0750 ns/op 1.22
Array 250000 set(125000) 1.3020 ns/op 1.0240 ns/op 1.27
Array 250000 iterate all - loop 200.80 us/op 138.48 us/op 1.45
aggregationBits - 2048 els - readonlyValues 291.32 us/op 243.03 us/op 1.20
aggregationBits - 2048 els - zipIndexesInBitList 49.219 us/op 40.483 us/op 1.22
regular array get 100000 times 80.741 us/op 57.292 us/op 1.41
wrappedArray get 100000 times 79.488 us/op 58.183 us/op 1.37
arrayWithProxy get 100000 times 36.009 ms/op 41.356 ms/op 0.87
ssz.Root.equals 1.3440 us/op 1.5060 us/op 0.89
ssz.Root.equals with valueOf() 1.6180 us/op 1.5140 us/op 1.07
byteArrayEquals with valueOf() 1.7070 us/op 1.4560 us/op 1.17
phase0 processBlock - 250000 vs - 7PWei normalcase 13.081 ms/op 14.167 ms/op 0.92
phase0 processBlock - 250000 vs - 7PWei worstcase 90.597 ms/op 99.054 ms/op 0.91
phase0 afterProcessEpoch - 250000 vs - 7PWei 247.45 ms/op 229.04 ms/op 1.08
phase0 beforeProcessEpoch - 250000 vs - 7PWei 681.93 ms/op 721.27 ms/op 0.95
phase0 processEpoch - mainnet_e58758 1.0553 s/op 1.0180 s/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 541.05 ms/op 595.32 ms/op 0.91
mainnet_e58758 - phase0 processJustificationAndFinalization 81.112 us/op 110.48 us/op 0.73
mainnet_e58758 - phase0 processRewardsAndPenalties 189.20 ms/op 160.86 ms/op 1.18
mainnet_e58758 - phase0 processRegistryUpdates 78.486 us/op 80.258 us/op 0.98
mainnet_e58758 - phase0 processSlashings 3.1850 us/op 7.0520 us/op 0.45
mainnet_e58758 - phase0 processEth1DataReset 2.9230 us/op 5.9090 us/op 0.49
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 11.111 ms/op 11.748 ms/op 0.95
mainnet_e58758 - phase0 processSlashingsReset 13.861 us/op 28.964 us/op 0.48
mainnet_e58758 - phase0 processRandaoMixesReset 19.216 us/op 41.327 us/op 0.46
mainnet_e58758 - phase0 processHistoricalRootsUpdate 4.1330 us/op 7.4870 us/op 0.55
mainnet_e58758 - phase0 processParticipationRecordUpdates 13.920 us/op 28.986 us/op 0.48
mainnet_e58758 - phase0 afterProcessEpoch 211.53 ms/op 212.30 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 normalcase 12.436 ms/op 11.969 ms/op 1.04
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4241 s/op 1.6886 s/op 0.84
phase0 processRegistryUpdates - 250000 normalcase 59.455 us/op 90.533 us/op 0.66
phase0 processRegistryUpdates - 250000 badcase_full_deposits 3.1856 ms/op 3.6369 ms/op 0.88
phase0 processRegistryUpdates - 250000 worstcase 0.5 1.9928 s/op 2.3794 s/op 0.84
phase0 getAttestationDeltas - 250000 normalcase 91.428 ms/op 91.210 ms/op 1.00
phase0 getAttestationDeltas - 250000 worstcase 92.081 ms/op 92.632 ms/op 0.99
phase0 processSlashings - 250000 worstcase 41.168 ms/op 49.952 ms/op 0.82
shuffle list - 16384 els 31.655 ms/op 13.352 ms/op 2.37
shuffle list - 250000 els 218.36 ms/op 193.03 ms/op 1.13
getEffectiveBalances - 250000 vs - 7PWei 13.161 ms/op 12.197 ms/op 1.08
pass gossip attestations to forkchoice per slot 17.992 ms/op 19.618 ms/op 0.92
computeDeltas 3.7383 ms/op 4.2206 ms/op 0.89
computeProposerBoostScoreFromBalances 400.79 us/op 283.45 us/op 1.41
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.5175 ms/op 2.6233 ms/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 837.05 us/op 776.36 us/op 1.08
BLS verify - blst-native 2.1516 ms/op 2.1211 ms/op 1.01
BLS verifyMultipleSignatures 3 - blst-native 4.4205 ms/op 4.3872 ms/op 1.01
BLS verifyMultipleSignatures 8 - blst-native 9.6784 ms/op 9.4074 ms/op 1.03
BLS verifyMultipleSignatures 32 - blst-native 35.348 ms/op 34.440 ms/op 1.03
BLS aggregatePubkeys 32 - blst-native 46.267 us/op 45.749 us/op 1.01
BLS aggregatePubkeys 128 - blst-native 184.50 us/op 177.61 us/op 1.04
getAttestationsForBlock 100.70 ms/op 109.01 ms/op 0.92
CheckpointStateCache - add get delete 23.088 us/op 22.751 us/op 1.01
validate gossip signedAggregateAndProof - struct 5.3360 ms/op 5.1810 ms/op 1.03
validate gossip signedAggregateAndProof - treeBacked 5.2004 ms/op 5.2232 ms/op 1.00
validate gossip attestation - struct 2.5219 ms/op 2.4126 ms/op 1.05
validate gossip attestation - treeBacked 2.5100 ms/op 2.5028 ms/op 1.00
bytes32 toHexString 1.9800 us/op 1.9130 us/op 1.04
bytes32 Buffer.toString(hex) 800.00 ns/op 785.00 ns/op 1.02
bytes32 Buffer.toString(hex) from Uint8Array 1.1100 us/op 982.00 ns/op 1.13
bytes32 Buffer.toString(hex) + 0x 805.00 ns/op 782.00 ns/op 1.03
Object access 1 prop 0.38800 ns/op 0.38500 ns/op 1.01
Map access 1 prop 0.32300 ns/op 0.31300 ns/op 1.03
Object get x1000 21.106 ns/op 15.764 ns/op 1.34
Map get x1000 1.2630 ns/op 0.90400 ns/op 1.40
Object set x1000 133.08 ns/op 113.55 ns/op 1.17
Map set x1000 77.492 ns/op 78.251 ns/op 0.99
Return object 10000 times 0.43860 ns/op 0.40770 ns/op 1.08
Throw Error 10000 times 6.9864 us/op 6.7300 us/op 1.04
enrSubnets - fastDeserialize 64 bits 1.5690 us/op 1.4430 us/op 1.09
enrSubnets - ssz BitVector 64 bits 20.089 us/op 18.656 us/op 1.08
enrSubnets - fastDeserialize 4 bits 511.00 ns/op 494.00 ns/op 1.03
enrSubnets - ssz BitVector 4 bits 3.4130 us/op 3.2480 us/op 1.05
RateTracker 1000000 limit, 1 obj count per request 216.83 ns/op 194.90 ns/op 1.11
RateTracker 1000000 limit, 2 obj count per request 159.79 ns/op 147.04 ns/op 1.09
RateTracker 1000000 limit, 4 obj count per request 132.27 ns/op 121.82 ns/op 1.09
RateTracker 1000000 limit, 8 obj count per request 120.85 ns/op 112.97 ns/op 1.07
RateTracker with prune 4.7170 us/op 4.8840 us/op 0.97

by benchmarkbot/action

@dapplion
Copy link
Contributor

Something is off in the client or consumer

@chainsafe/lodestar: Eph 36/6 0.263 [LC]              error: Error sync message=Invalid finality header merkle branch
@chainsafe/lodestar: Error: Invalid finality header merkle branch
@chainsafe/lodestar:     at assertValidFinalityProof (/home/runner/work/lodestar/lodestar/packages/light-client/src/validation.ts:75:11)
@chainsafe/lodestar:     at assertValidLightClientUpdate (/home/runner/work/lodestar/lodestar/packages/light-client/src/validation.ts:39:5)
@chainsafe/lodestar:     at Lightclient.processSyncCommitteeUpdate (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:459:33)
@chainsafe/lodestar:     at Lightclient.sync (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:248:14)
@chainsafe/lodestar:     at runMicrotasks (<anonymous>)
@chainsafe/lodestar:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
@chainsafe/lodestar:     at Lightclient.runLoop (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:274:11)
@chainsafe/lodestar: Eph 36/6 0.501 [NODE]             info: Synced - slot: 294 - head: 294 0x3e86…d07b - finalized: 0xd74f…5c2e:34 - peers: 0
@chainsafe/lodestar: Eph 36/7 0.046 [NODE NODE API]   error: Req req-cy getStateProof error message=No state found for id '0xf06033e76b7dba9ce2c36c76302de4e882667af8b6cb867b721d7d214862cbb4'
@chainsafe/lodestar: Error: No state found for id '0xf06033e76b7dba9ce2c36c76302de4e882667af8b6cb867b721d7d214862cbb4'
@chainsafe/lodestar:     at resolveStateId (/home/runner/work/lodestar/lodestar/packages/lodestar/src/api/impl/beacon/state/utils.ts:41:11)
@chainsafe/lodestar:     at Object.getStateProof (/home/runner/work/lodestar/lodestar/packages/lodestar/src/api/impl/lightclient/index.ts:22:21)
@chainsafe/lodestar:     at Object.handler (/home/runner/work/lodestar/lodestar/packages/api/src/server/lightclient.ts:22:31)

@g11tech
Copy link
Contributor

g11tech commented Jan 22, 2022

Something is off in the client or consumer

@chainsafe/lodestar: Eph 36/6 0.263 [LC]              error: Error sync message=Invalid finality header merkle branch
@chainsafe/lodestar: Error: Invalid finality header merkle branch
@chainsafe/lodestar:     at assertValidFinalityProof (/home/runner/work/lodestar/lodestar/packages/light-client/src/validation.ts:75:11)
@chainsafe/lodestar:     at assertValidLightClientUpdate (/home/runner/work/lodestar/lodestar/packages/light-client/src/validation.ts:39:5)
@chainsafe/lodestar:     at Lightclient.processSyncCommitteeUpdate (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:459:33)
@chainsafe/lodestar:     at Lightclient.sync (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:248:14)
@chainsafe/lodestar:     at runMicrotasks (<anonymous>)
@chainsafe/lodestar:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
@chainsafe/lodestar:     at Lightclient.runLoop (/home/runner/work/lodestar/lodestar/packages/light-client/src/index.ts:274:11)
@chainsafe/lodestar: Eph 36/6 0.501 [NODE]             info: Synced - slot: 294 - head: 294 0x3e86…d07b - finalized: 0xd74f…5c2e:34 - peers: 0
@chainsafe/lodestar: Eph 36/7 0.046 [NODE NODE API]   error: Req req-cy getStateProof error message=No state found for id '0xf06033e76b7dba9ce2c36c76302de4e882667af8b6cb867b721d7d214862cbb4'
@chainsafe/lodestar: Error: No state found for id '0xf06033e76b7dba9ce2c36c76302de4e882667af8b6cb867b721d7d214862cbb4'
@chainsafe/lodestar:     at resolveStateId (/home/runner/work/lodestar/lodestar/packages/lodestar/src/api/impl/beacon/state/utils.ts:41:11)
@chainsafe/lodestar:     at Object.getStateProof (/home/runner/work/lodestar/lodestar/packages/lodestar/src/api/impl/lightclient/index.ts:22:21)
@chainsafe/lodestar:     at Object.handler (/home/runner/work/lodestar/lodestar/packages/api/src/server/lightclient.ts:22:31)

this was how it was before I updated the headers, as per my understanding, they already look correct (unless they were wrong assigned in first place):
image

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.

Thanks for looking into this!

@wemeetagain wemeetagain merged commit e86f50a into master Jan 28, 2022
@wemeetagain wemeetagain deleted the tuyen/fix-lightclientupdate-headers branch January 28, 2022 14:53
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