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

Skip check for old finalized epoch in assertPeerRelevance #3405

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Nov 2, 2021

Motivation

Current assertPeerRelevance implementation doesn't have access to old finalized roots since it uses the state block roots. A recurring error seen by users is

Nov-01 17:25:14.863 [NETWORK]         error: Unexpected error in assertPeerRelevance peer=16...5JtCA2 message=Cannot get block root more than 8192 in the past
Error: Cannot get block root more than 8192 in the past
    at getBlockRootAtSlot (/home/lion/Code/eth2.0/lodestar/packages/beacon-state-transition/src/util/blockRoot.ts:20:11)
    at getRootAtHistoricalEpoch (/home/lion/Code/eth2.0/lodestar/packages/lodestar/src/network/peers/utils/assertPeerRelevance.ts:98:28)
    at assertPeerRelevance (/home/lion/Code/eth2.0/lodestar/packages/lodestar/src/network/peers/utils/assertPeerRelevance.ts:72:11)
    at PeerManager.onStatus (/home/lion/Code/eth2.0/lodestar/packages/lodestar/src/network/peers/peerManager.ts:250:26)
    at PeerManager.requestStatus (/home/lion/Code/eth2.0/lodestar/packages/lodestar/src/network/peers/peerManager.ts:289:12)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 0)
    at PeerManager.requestStatusMany (/home/lion/Code/eth2.0/lodestar/packages/lodestar/src/network/peers/peerManager.ts:298:7)

caused by this limitation.

Description

This PR is a short term solution to prevent this error from happening. If the incoming peer finalized epoch is too old, it will accept the PR as "relevant". The long term solution is to use the archived block db repository to fetch old finalized roots and check against them.

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #3405 (fbeabc6) into master (aafc5d7) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3405      +/-   ##
==========================================
- Coverage   38.36%   38.36%   -0.01%     
==========================================
  Files         303      303              
  Lines        7738     7741       +3     
  Branches     1157     1158       +1     
==========================================
+ Hits         2969     2970       +1     
- Misses       4628     4630       +2     
  Partials      141      141              

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2021

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 7bbc05b Previous: 13b61a3 Ratio
BeaconState.hashTreeRoot - No change 707.00 ns/op 701.00 ns/op 1.01
BeaconState.hashTreeRoot - 1 full validator 80.745 us/op 79.749 us/op 1.01
BeaconState.hashTreeRoot - 32 full validator 1.1510 ms/op 1.1442 ms/op 1.01
BeaconState.hashTreeRoot - 512 full validator 15.004 ms/op 15.146 ms/op 0.99
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 79.513 us/op 79.066 us/op 1.01
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2428 ms/op 1.2045 ms/op 1.03
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 19.380 ms/op 17.934 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 57.140 us/op 58.262 us/op 0.98
BeaconState.hashTreeRoot - 32 balances 507.71 us/op 482.44 us/op 1.05
BeaconState.hashTreeRoot - 512 balances 4.9376 ms/op 4.9049 ms/op 1.01
BeaconState.hashTreeRoot - 250000 balances 93.181 ms/op 91.132 ms/op 1.02
processSlot - 1 slots 38.952 us/op 38.143 us/op 1.02
processSlot - 32 slots 2.1501 ms/op 2.1177 ms/op 1.02
getCommitteeAssignments - req 1 vs - 250000 vc 5.2232 ms/op 5.2370 ms/op 1.00
getCommitteeAssignments - req 100 vs - 250000 vc 7.1802 ms/op 7.2559 ms/op 0.99
getCommitteeAssignments - req 1000 vs - 250000 vc 7.6453 ms/op 7.7294 ms/op 0.99
computeProposers - vc 250000 21.517 ms/op 20.679 ms/op 1.04
computeEpochShuffling - vc 250000 201.77 ms/op 190.40 ms/op 1.06
getNextSyncCommittee - vc 250000 345.86 ms/op 343.96 ms/op 1.01
altair processAttestation - 250000 vs - 7PWei normalcase 37.089 ms/op 36.131 ms/op 1.03
altair processAttestation - 250000 vs - 7PWei worstcase 45.448 ms/op 42.598 ms/op 1.07
altair processAttestation - setStatus - 1/6 committees join 11.019 ms/op 10.348 ms/op 1.06
altair processAttestation - setStatus - 1/3 committees join 22.158 ms/op 21.291 ms/op 1.04
altair processAttestation - setStatus - 1/2 committees join 35.394 ms/op 32.588 ms/op 1.09
altair processAttestation - setStatus - 2/3 committees join 46.897 ms/op 43.540 ms/op 1.08
altair processAttestation - setStatus - 4/5 committees join 56.732 ms/op 53.334 ms/op 1.06
altair processAttestation - setStatus - 100% committees join 71.361 ms/op 66.646 ms/op 1.07
altair processAttestation - updateEpochParticipants - 1/6 committees join 11.565 ms/op 11.203 ms/op 1.03
altair processAttestation - updateEpochParticipants - 1/3 committees join 23.741 ms/op 22.826 ms/op 1.04
altair processAttestation - updateEpochParticipants - 1/2 committees join 26.316 ms/op 24.240 ms/op 1.09
altair processAttestation - updateEpochParticipants - 2/3 committees join 25.792 ms/op 26.096 ms/op 0.99
altair processAttestation - updateEpochParticipants - 4/5 committees join 27.443 ms/op 27.150 ms/op 1.01
altair processAttestation - updateEpochParticipants - 100% committees join 29.310 ms/op 31.885 ms/op 0.92
altair processAttestation - updateAllStatus 20.707 ms/op 20.817 ms/op 0.99
altair processBlock - 250000 vs - 7PWei normalcase 43.676 ms/op 41.402 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase 114.89 ms/op 109.27 ms/op 1.05
altair processEpoch - pyrmont_e62330 464.41 ms/op 437.37 ms/op 1.06
pyrmont_e62330 - altair beforeProcessEpoch 158.68 ms/op 146.12 ms/op 1.09
pyrmont_e62330 - altair processJustificationAndFinalization 61.916 us/op 49.822 us/op 1.24
pyrmont_e62330 - altair processInactivityUpdates 8.8344 ms/op 8.3522 ms/op 1.06
pyrmont_e62330 - altair processRewardsAndPenalties 58.590 ms/op 53.282 ms/op 1.10
pyrmont_e62330 - altair processRegistryUpdates 7.4690 us/op 5.9470 us/op 1.26
pyrmont_e62330 - altair processSlashings 1.5820 us/op 1.2900 us/op 1.23
pyrmont_e62330 - altair processEth1DataReset 1.2800 us/op 1.1930 us/op 1.07
pyrmont_e62330 - altair processEffectiveBalanceUpdates 8.9329 ms/op 5.6476 ms/op 1.58
pyrmont_e62330 - altair processSlashingsReset 10.143 us/op 9.1590 us/op 1.11
pyrmont_e62330 - altair processRandaoMixesReset 14.384 us/op 12.372 us/op 1.16
pyrmont_e62330 - altair processHistoricalRootsUpdate 1.6690 us/op 1.3950 us/op 1.20
pyrmont_e62330 - altair processParticipationFlagUpdates 41.746 ms/op 39.646 ms/op 1.05
pyrmont_e62330 - altair processSyncCommitteeUpdates 1.3620 us/op 1.1390 us/op 1.20
pyrmont_e62330 - altair afterProcessEpoch 117.53 ms/op 114.45 ms/op 1.03
altair processInactivityUpdates - 250000 normalcase 73.857 ms/op 71.001 ms/op 1.04
altair processInactivityUpdates - 250000 worstcase 74.637 ms/op 70.624 ms/op 1.06
altair processParticipationFlagUpdates - 250000 anycase 100.11 ms/op 84.597 ms/op 1.18
altair processRewardsAndPenalties - 250000 normalcase 133.01 ms/op 111.92 ms/op 1.19
altair processRewardsAndPenalties - 250000 worstcase 116.38 ms/op 112.33 ms/op 1.04
altair processSyncCommitteeUpdates - 250000 368.77 ms/op 356.90 ms/op 1.03
Tree 40 250000 create 559.50 ms/op 546.10 ms/op 1.02
Tree 40 250000 get(125000) 273.78 ns/op 270.31 ns/op 1.01
Tree 40 250000 set(125000) 1.7813 us/op 1.5538 us/op 1.15
Tree 40 250000 toArray() 43.385 ms/op 42.401 ms/op 1.02
Tree 40 250000 iterate all - toArray() + loop 43.890 ms/op 37.606 ms/op 1.17
Tree 40 250000 iterate all - get(i) 106.45 ms/op 102.02 ms/op 1.04
MutableVector 250000 create 25.283 ms/op 20.766 ms/op 1.22
MutableVector 250000 get(125000) 13.001 ns/op 12.941 ns/op 1.00
MutableVector 250000 set(125000) 610.61 ns/op 571.68 ns/op 1.07
MutableVector 250000 toArray() 9.5783 ms/op 8.7564 ms/op 1.09
MutableVector 250000 iterate all - toArray() + loop 10.079 ms/op 8.9550 ms/op 1.13
MutableVector 250000 iterate all - get(i) 3.4197 ms/op 3.1414 ms/op 1.09
Array 250000 create 5.8149 ms/op 5.7040 ms/op 1.02
Array 250000 clone - spread 1.9436 ms/op 1.9839 ms/op 0.98
Array 250000 get(125000) 1.1100 ns/op 1.1070 ns/op 1.00
Array 250000 set(125000) 1.1000 ns/op 0.78100 ns/op 1.41
Array 250000 iterate all - loop 167.91 us/op 169.13 us/op 0.99
aggregationBits - 2048 els - readonlyValues 228.59 us/op 231.56 us/op 0.99
aggregationBits - 2048 els - zipIndexesInBitList 41.690 us/op 41.961 us/op 0.99
ssz.Root.equals 1.4150 us/op 1.4710 us/op 0.96
ssz.Root.equals with valueOf() 1.6910 us/op 1.7730 us/op 0.95
byteArrayEquals with valueOf() 1.7070 us/op 1.7870 us/op 0.96
phase0 processBlock - 250000 vs - 7PWei normalcase 10.740 ms/op 10.315 ms/op 1.04
phase0 processBlock - 250000 vs - 7PWei worstcase 75.278 ms/op 73.428 ms/op 1.03
phase0 afterProcessEpoch - 250000 vs - 7PWei 212.85 ms/op 208.97 ms/op 1.02
phase0 beforeProcessEpoch - 250000 vs - 7PWei 567.65 ms/op 547.53 ms/op 1.04
phase0 processEpoch - mainnet_e58758 798.90 ms/op 766.24 ms/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 486.52 ms/op 453.43 ms/op 1.07
mainnet_e58758 - phase0 processJustificationAndFinalization 47.186 us/op 46.630 us/op 1.01
mainnet_e58758 - phase0 processRewardsAndPenalties 88.846 ms/op 79.438 ms/op 1.12
mainnet_e58758 - phase0 processRegistryUpdates 34.710 us/op 33.694 us/op 1.03
mainnet_e58758 - phase0 processSlashings 1.2530 us/op 1.2990 us/op 0.96
mainnet_e58758 - phase0 processEth1DataReset 1.1360 us/op 1.1370 us/op 1.00
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 9.6698 ms/op 9.5086 ms/op 1.02
mainnet_e58758 - phase0 processSlashingsReset 8.1680 us/op 7.6780 us/op 1.06
mainnet_e58758 - phase0 processRandaoMixesReset 11.982 us/op 12.253 us/op 0.98
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.4140 us/op 1.3400 us/op 1.06
mainnet_e58758 - phase0 processParticipationRecordUpdates 9.1840 us/op 8.4220 us/op 1.09
mainnet_e58758 - phase0 afterProcessEpoch 190.42 ms/op 185.28 ms/op 1.03
phase0 processEffectiveBalanceUpdates - 250000 normalcase 12.579 ms/op 11.344 ms/op 1.11
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.2221 s/op 1.1222 s/op 1.09
phase0 processRegistryUpdates - 250000 normalcase 38.612 us/op 34.151 us/op 1.13
phase0 processRegistryUpdates - 250000 badcase_full_deposits 3.1895 ms/op 3.0011 ms/op 1.06
phase0 processRegistryUpdates - 250000 worstcase 0.5 1.6038 s/op 1.4701 s/op 1.09
phase0 getAttestationDeltas - 250000 normalcase 38.184 ms/op 36.356 ms/op 1.05
phase0 getAttestationDeltas - 250000 worstcase 38.479 ms/op 36.845 ms/op 1.04
phase0 processSlashings - 250000 worstcase 34.729 ms/op 35.753 ms/op 0.97
shuffle list - 16384 els 13.079 ms/op 13.009 ms/op 1.01
shuffle list - 250000 els 187.93 ms/op 186.81 ms/op 1.01
getEffectiveBalances - 250000 vs - 7PWei 13.984 ms/op 14.328 ms/op 0.98
computeDeltas 4.0332 ms/op 3.3364 ms/op 1.21
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.8103 ms/op 2.5084 ms/op 1.12
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 961.70 us/op 959.72 us/op 1.00
BLS verify - blst-native 1.8591 ms/op 1.8569 ms/op 1.00
BLS verifyMultipleSignatures 3 - blst-native 3.8111 ms/op 3.8108 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 8.2095 ms/op 8.2153 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 29.797 ms/op 29.791 ms/op 1.00
BLS aggregatePubkeys 32 - blst-native 39.835 us/op 39.842 us/op 1.00
BLS aggregatePubkeys 128 - blst-native 155.64 us/op 156.21 us/op 1.00
getAttestationsForBlock 92.628 ms/op 79.554 ms/op 1.16
CheckpointStateCache - add get delete 15.606 us/op 14.762 us/op 1.06
validate gossip signedAggregateAndProof - struct 4.4542 ms/op 4.4886 ms/op 0.99
validate gossip signedAggregateAndProof - treeBacked 4.4765 ms/op 4.4168 ms/op 1.01
validate gossip attestation - struct 2.0785 ms/op 2.1183 ms/op 0.98
validate gossip attestation - treeBacked 2.1016 ms/op 2.1297 ms/op 0.99

by benchmarkbot/action

@codeclimate
Copy link

codeclimate bot commented Nov 3, 2021

The SHA range provided is invalid

View more on Code Climate.

@wemeetagain wemeetagain merged commit 397327a into master Nov 3, 2021
@wemeetagain wemeetagain deleted the dapplion/assert-relevance-old-slot branch November 3, 2021 14:44
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.

3 participants