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

Reject many skipped blocks #4020

Merged
merged 1 commit into from Jul 19, 2022
Merged

Conversation

dadepo
Copy link
Contributor

@dadepo dadepo commented May 13, 2022

Motivation

Description

Closes #3988

Steps to test or reproduce

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #4020 (348a895) into unstable (c0efff4) will not change coverage.
The diff coverage is n/a.

❗ Current head 348a895 differs from pull request most recent head 94dc8e0. Consider uploading reports for the commit 94dc8e0 to get more accurate results

@@       Coverage Diff        @@
##   unstable   #4020   +/-   ##
================================
================================

@github-actions
Copy link
Contributor

github-actions bot commented May 13, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: e283e72 Previous: 57673fe Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.1983 ms/op 2.5853 ms/op 0.85
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 82.496 us/op 79.186 us/op 1.04
BLS verify - blst-native 2.1092 ms/op 1.8551 ms/op 1.14
BLS verifyMultipleSignatures 3 - blst-native 4.4123 ms/op 3.8050 ms/op 1.16
BLS verifyMultipleSignatures 8 - blst-native 9.4921 ms/op 8.1838 ms/op 1.16
BLS verifyMultipleSignatures 32 - blst-native 33.309 ms/op 29.681 ms/op 1.12
BLS aggregatePubkeys 32 - blst-native 44.970 us/op 39.199 us/op 1.15
BLS aggregatePubkeys 128 - blst-native 177.99 us/op 152.62 us/op 1.17
getAttestationsForBlock 50.215 ms/op 51.804 ms/op 0.97
isKnown best case - 1 super set check 493.00 ns/op 427.00 ns/op 1.15
isKnown normal case - 2 super set checks 489.00 ns/op 414.00 ns/op 1.18
isKnown worse case - 16 super set checks 474.00 ns/op 411.00 ns/op 1.15
CheckpointStateCache - add get delete 9.9990 us/op 9.3870 us/op 1.07
validate gossip signedAggregateAndProof - struct 4.8404 ms/op 4.3724 ms/op 1.11
validate gossip attestation - struct 2.3121 ms/op 2.0271 ms/op 1.14
altair verifyImport mainnet_s3766816:31 13.189 s/op 12.741 s/op 1.04
pickEth1Vote - no votes 2.3214 ms/op 2.1312 ms/op 1.09
pickEth1Vote - max votes 24.214 ms/op 24.597 ms/op 0.98
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.708 ms/op 11.591 ms/op 1.10
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 22.689 ms/op 21.908 ms/op 1.04
pickEth1Vote - Eth1Data fastSerialize value x2048 1.7747 ms/op 1.6431 ms/op 1.08
pickEth1Vote - Eth1Data fastSerialize tree x2048 17.976 ms/op 19.185 ms/op 0.94
bytes32 toHexString 1.2670 us/op 1.2150 us/op 1.04
bytes32 Buffer.toString(hex) 827.00 ns/op 766.00 ns/op 1.08
bytes32 Buffer.toString(hex) from Uint8Array 1.0870 us/op 963.00 ns/op 1.13
bytes32 Buffer.toString(hex) + 0x 841.00 ns/op 754.00 ns/op 1.12
Object access 1 prop 0.44400 ns/op 0.41800 ns/op 1.06
Map access 1 prop 0.34700 ns/op 0.29200 ns/op 1.19
Object get x1000 21.487 ns/op 17.875 ns/op 1.20
Map get x1000 1.1240 ns/op 1.0510 ns/op 1.07
Object set x1000 136.05 ns/op 135.58 ns/op 1.00
Map set x1000 80.637 ns/op 77.840 ns/op 1.04
Return object 10000 times 0.44010 ns/op 0.37740 ns/op 1.17
Throw Error 10000 times 6.9479 us/op 6.0253 us/op 1.15
enrSubnets - fastDeserialize 64 bits 3.1760 us/op 3.0640 us/op 1.04
enrSubnets - ssz BitVector 64 bits 835.00 ns/op 808.00 ns/op 1.03
enrSubnets - fastDeserialize 4 bits 474.00 ns/op 462.00 ns/op 1.03
enrSubnets - ssz BitVector 4 bits 842.00 ns/op 832.00 ns/op 1.01
prioritizePeers score -10:0 att 32-0.1 sync 2-0 109.22 us/op 108.39 us/op 1.01
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 140.98 us/op 125.30 us/op 1.13
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 237.64 us/op 245.63 us/op 0.97
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 513.67 us/op 511.25 us/op 1.00
prioritizePeers score 0:0 att 64-1 sync 4-1 523.49 us/op 464.58 us/op 1.13
RateTracker 1000000 limit, 1 obj count per request 212.11 ns/op 207.99 ns/op 1.02
RateTracker 1000000 limit, 2 obj count per request 164.95 ns/op 159.57 ns/op 1.03
RateTracker 1000000 limit, 4 obj count per request 131.40 ns/op 136.15 ns/op 0.97
RateTracker 1000000 limit, 8 obj count per request 117.03 ns/op 121.80 ns/op 0.96
RateTracker with prune 4.7570 us/op 5.4770 us/op 0.87
array of 16000 items push then shift 3.5414 us/op 3.2046 us/op 1.11
LinkedList of 16000 items push then shift 27.156 ns/op 30.141 ns/op 0.90
array of 16000 items push then pop 280.03 ns/op 258.47 ns/op 1.08
LinkedList of 16000 items push then pop 23.773 ns/op 23.620 ns/op 1.01
array of 24000 items push then shift 5.2286 us/op 4.5582 us/op 1.15
LinkedList of 24000 items push then shift 29.306 ns/op 32.164 ns/op 0.91
array of 24000 items push then pop 244.47 ns/op 219.43 ns/op 1.11
LinkedList of 24000 items push then pop 22.711 ns/op 23.820 ns/op 0.95
intersect bitArray bitLen 8 13.294 ns/op 11.817 ns/op 1.12
intersect array and set length 8 187.08 ns/op 199.48 ns/op 0.94
intersect bitArray bitLen 128 67.146 ns/op 62.031 ns/op 1.08
intersect array and set length 128 2.6852 us/op 2.5561 us/op 1.05
pass gossip attestations to forkchoice per slot 7.0717 ms/op 6.6769 ms/op 1.06
computeDeltas 4.5668 ms/op 3.8081 ms/op 1.20
computeProposerBoostScoreFromBalances 1.0107 ms/op 907.71 us/op 1.11
altair processAttestation - 250000 vs - 7PWei normalcase 4.1299 ms/op 4.9866 ms/op 0.83
altair processAttestation - 250000 vs - 7PWei worstcase 6.6375 ms/op 6.8111 ms/op 0.97
altair processAttestation - setStatus - 1/6 committees join 226.55 us/op 584.04 us/op 0.39
altair processAttestation - setStatus - 1/3 committees join 450.70 us/op 414.25 us/op 1.09
altair processAttestation - setStatus - 1/2 committees join 675.74 us/op 578.02 us/op 1.17
altair processAttestation - setStatus - 2/3 committees join 769.49 us/op 738.06 us/op 1.04
altair processAttestation - setStatus - 4/5 committees join 1.0742 ms/op 1.0207 ms/op 1.05
altair processAttestation - setStatus - 100% committees join 1.2600 ms/op 1.2171 ms/op 1.04
altair processBlock - 250000 vs - 7PWei normalcase 28.099 ms/op 29.569 ms/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase hashState 43.468 ms/op 45.670 ms/op 0.95
altair processBlock - 250000 vs - 7PWei worstcase 95.165 ms/op 84.609 ms/op 1.12
altair processBlock - 250000 vs - 7PWei worstcase hashState 112.36 ms/op 117.35 ms/op 0.96
phase0 processBlock - 250000 vs - 7PWei normalcase 5.0175 ms/op 4.5695 ms/op 1.10
phase0 processBlock - 250000 vs - 7PWei worstcase 51.962 ms/op 48.594 ms/op 1.07
altair processEth1Data - 250000 vs - 7PWei normalcase 1.0128 ms/op 939.20 us/op 1.08
Tree 40 250000 create 854.48 ms/op 996.10 ms/op 0.86
Tree 40 250000 get(125000) 329.45 ns/op 286.90 ns/op 1.15
Tree 40 250000 set(125000) 2.9358 us/op 2.9963 us/op 0.98
Tree 40 250000 toArray() 36.678 ms/op 33.923 ms/op 1.08
Tree 40 250000 iterate all - toArray() + loop 36.021 ms/op 34.884 ms/op 1.03
Tree 40 250000 iterate all - get(i) 123.03 ms/op 113.19 ms/op 1.09
MutableVector 250000 create 16.674 ms/op 18.058 ms/op 0.92
MutableVector 250000 get(125000) 16.911 ns/op 14.763 ns/op 1.15
MutableVector 250000 set(125000) 715.85 ns/op 779.30 ns/op 0.92
MutableVector 250000 toArray() 8.3961 ms/op 8.0287 ms/op 1.05
MutableVector 250000 iterate all - toArray() + loop 9.1091 ms/op 8.3950 ms/op 1.09
MutableVector 250000 iterate all - get(i) 3.6484 ms/op 3.4390 ms/op 1.06
Array 250000 create 6.9687 ms/op 7.7516 ms/op 0.90
Array 250000 clone - spread 3.1283 ms/op 4.1488 ms/op 0.75
Array 250000 get(125000) 1.3610 ns/op 1.8760 ns/op 0.73
Array 250000 set(125000) 1.3130 ns/op 1.7840 ns/op 0.74
Array 250000 iterate all - loop 178.39 us/op 167.93 us/op 1.06
effectiveBalanceIncrements clone Uint8Array 300000 77.525 us/op 116.31 us/op 0.67
effectiveBalanceIncrements clone MutableVector 300000 936.00 ns/op 1.4210 us/op 0.66
effectiveBalanceIncrements rw all Uint8Array 300000 282.49 us/op 252.54 us/op 1.12
effectiveBalanceIncrements rw all MutableVector 300000 180.09 ms/op 268.09 ms/op 0.67
phase0 afterProcessEpoch - 250000 vs - 7PWei 206.20 ms/op 184.32 ms/op 1.12
phase0 beforeProcessEpoch - 250000 vs - 7PWei 90.071 ms/op 106.30 ms/op 0.85
altair processEpoch - mainnet_e81889 601.92 ms/op 608.76 ms/op 0.99
mainnet_e81889 - altair beforeProcessEpoch 108.63 ms/op 167.74 ms/op 0.65
mainnet_e81889 - altair processJustificationAndFinalization 40.226 us/op 22.460 us/op 1.79
mainnet_e81889 - altair processInactivityUpdates 11.461 ms/op 11.642 ms/op 0.98
mainnet_e81889 - altair processRewardsAndPenalties 187.94 ms/op 98.461 ms/op 1.91
mainnet_e81889 - altair processRegistryUpdates 10.185 us/op 3.9400 us/op 2.59
mainnet_e81889 - altair processSlashings 1.9380 us/op 714.00 ns/op 2.71
mainnet_e81889 - altair processEth1DataReset 2.3020 us/op 850.00 ns/op 2.71
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.7930 ms/op 2.2725 ms/op 1.23
mainnet_e81889 - altair processSlashingsReset 11.497 us/op 6.0230 us/op 1.91
mainnet_e81889 - altair processRandaoMixesReset 10.883 us/op 5.7690 us/op 1.89
mainnet_e81889 - altair processHistoricalRootsUpdate 1.6880 us/op 922.00 ns/op 1.83
mainnet_e81889 - altair processParticipationFlagUpdates 5.8290 us/op 3.7640 us/op 1.55
mainnet_e81889 - altair processSyncCommitteeUpdates 1.7520 us/op 700.00 ns/op 2.50
mainnet_e81889 - altair afterProcessEpoch 222.87 ms/op 255.88 ms/op 0.87
phase0 processEpoch - mainnet_e58758 584.25 ms/op 606.37 ms/op 0.96
mainnet_e58758 - phase0 beforeProcessEpoch 245.21 ms/op 260.77 ms/op 0.94
mainnet_e58758 - phase0 processJustificationAndFinalization 40.904 us/op 18.745 us/op 2.18
mainnet_e58758 - phase0 processRewardsAndPenalties 142.33 ms/op 83.638 ms/op 1.70
mainnet_e58758 - phase0 processRegistryUpdates 22.076 us/op 10.789 us/op 2.05
mainnet_e58758 - phase0 processSlashings 2.3590 us/op 1.0250 us/op 2.30
mainnet_e58758 - phase0 processEth1DataReset 2.0030 us/op 897.00 ns/op 2.23
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.1675 ms/op 1.8598 ms/op 1.17
mainnet_e58758 - phase0 processSlashingsReset 11.602 us/op 3.7010 us/op 3.13
mainnet_e58758 - phase0 processRandaoMixesReset 13.147 us/op 6.1100 us/op 2.15
mainnet_e58758 - phase0 processHistoricalRootsUpdate 2.9810 us/op 940.00 ns/op 3.17
mainnet_e58758 - phase0 processParticipationRecordUpdates 12.949 us/op 5.0710 us/op 2.55
mainnet_e58758 - phase0 afterProcessEpoch 177.46 ms/op 160.54 ms/op 1.11
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.9291 ms/op 2.5499 ms/op 1.15
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.8707 ms/op 2.9617 ms/op 1.31
altair processInactivityUpdates - 250000 normalcase 46.914 ms/op 43.606 ms/op 1.08
altair processInactivityUpdates - 250000 worstcase 45.358 ms/op 43.093 ms/op 1.05
phase0 processRegistryUpdates - 250000 normalcase 18.780 us/op 9.9900 us/op 1.88
phase0 processRegistryUpdates - 250000 badcase_full_deposits 567.16 us/op 421.59 us/op 1.35
phase0 processRegistryUpdates - 250000 worstcase 0.5 238.28 ms/op 234.64 ms/op 1.02
altair processRewardsAndPenalties - 250000 normalcase 154.59 ms/op 121.23 ms/op 1.28
altair processRewardsAndPenalties - 250000 worstcase 139.95 ms/op 150.58 ms/op 0.93
phase0 getAttestationDeltas - 250000 normalcase 13.820 ms/op 12.773 ms/op 1.08
phase0 getAttestationDeltas - 250000 worstcase 14.629 ms/op 12.723 ms/op 1.15
phase0 processSlashings - 250000 worstcase 6.2760 ms/op 5.4393 ms/op 1.15
altair processSyncCommitteeUpdates - 250000 317.65 ms/op 282.97 ms/op 1.12
BeaconState.hashTreeRoot - No change 542.00 ns/op 477.00 ns/op 1.14
BeaconState.hashTreeRoot - 1 full validator 70.413 us/op 63.254 us/op 1.11
BeaconState.hashTreeRoot - 32 full validator 677.66 us/op 640.24 us/op 1.06
BeaconState.hashTreeRoot - 512 full validator 7.2582 ms/op 5.9574 ms/op 1.22
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 95.640 us/op 81.114 us/op 1.18
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2762 ms/op 1.2084 ms/op 1.06
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.408 ms/op 16.339 ms/op 1.07
BeaconState.hashTreeRoot - 1 balances 64.189 us/op 63.321 us/op 1.01
BeaconState.hashTreeRoot - 32 balances 934.58 us/op 758.58 us/op 1.23
BeaconState.hashTreeRoot - 512 balances 6.0464 ms/op 5.6295 ms/op 1.07
BeaconState.hashTreeRoot - 250000 balances 94.232 ms/op 86.953 ms/op 1.08
aggregationBits - 2048 els - zipIndexesInBitList 31.298 us/op 35.100 us/op 0.89
regular array get 100000 times 71.844 us/op 67.426 us/op 1.07
wrappedArray get 100000 times 73.406 us/op 67.449 us/op 1.09
arrayWithProxy get 100000 times 31.636 ms/op 29.256 ms/op 1.08
ssz.Root.equals 545.00 ns/op 535.00 ns/op 1.02
byteArrayEquals 521.00 ns/op 523.00 ns/op 1.00
shuffle list - 16384 els 12.491 ms/op 11.059 ms/op 1.13
shuffle list - 250000 els 187.55 ms/op 163.29 ms/op 1.15
processSlot - 1 slots 13.628 us/op 13.579 us/op 1.00
processSlot - 32 slots 2.0022 ms/op 1.8778 ms/op 1.07
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 476.56 us/op 374.64 us/op 1.27
getCommitteeAssignments - req 1 vs - 250000 vc 6.0435 ms/op 5.3415 ms/op 1.13
getCommitteeAssignments - req 100 vs - 250000 vc 8.3090 ms/op 7.3346 ms/op 1.13
getCommitteeAssignments - req 1000 vs - 250000 vc 9.0992 ms/op 7.8077 ms/op 1.17
computeProposers - vc 250000 21.524 ms/op 19.029 ms/op 1.13
computeEpochShuffling - vc 250000 189.25 ms/op 166.26 ms/op 1.14
getNextSyncCommittee - vc 250000 309.25 ms/op 275.04 ms/op 1.12

by benchmarkbot/action

@dadepo dadepo changed the title Dadepo/reject many skipped blocks Reject many skipped blocks May 14, 2022
@@ -66,6 +66,12 @@ Will double processing times. Use only for debugging purposes.",
group: "chain",
},

"chain.maxSkipSlots": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dapplion should this option to be hidden? Also should it have a default value? I do not see a default value set in LH implementation though. If there is a need to set a default, what range of value will be advisable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Lighthouse doesn't have a default value because it's disabled by default. If the CLI value is not set the check does not apply

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I was asking, should we also implement it that way (that is have it disabled by default, and hence do not have a default value)? Or do we consider the possibility of a DoS via this avenue high enough that we want to have a default value? (and hence have the check enabled by default)

Copy link
Contributor

Choose a reason for hiding this comment

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

With this enabled by default you can also reject valid blocks so it's a dangerous feature if miss-used. I imagine that's why Lighthouse has disabled it by default

@dadepo dadepo marked this pull request as ready for review May 17, 2022 10:03
@dadepo dadepo requested a review from a team as a code owner May 17, 2022 10:03
@dapplion dapplion changed the base branch from master to unstable May 27, 2022 04:30
wemeetagain
wemeetagain previously approved these changes Jun 3, 2022
"safe-slots-to-import-optimistically": number;
// this is defined as part of IBeaconPaths
// "chain.persistInvalidSszObjectsDir": string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this comment deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I was not sure of the value of keeping the property commented out...it felt like something that was marked for removal.

I have brought it back and updated it a bit to be more clear.

@@ -35,6 +36,9 @@ describe("gossip block validation", function () {
chain.forkChoice = forkChoice;
regen = chain.regen = sinon.createStubInstance(StateRegenerator);

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(chain as any).opts = {maxSkipSlots};
Copy link
Contributor

Choose a reason for hiding this comment

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

You can cast to the full class, which should allow editing. Better than any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately on the full class ie BeaconChain, opts is a readonly value, so casting it to the full class will not allow editing

Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep trying other strategies before casting to any, for example

((chain as Pick<BeaconChain, "opts">) as {opts: BeaconChain["opts"]}).opts = {maxSkipSlots}

Or what about just

chain.opts.maxSkipSlots = maxSkipSlots

Just keep iterating until you find the strongest chain of casting that will not compile if something changes

@dadepo
Copy link
Contributor Author

dadepo commented Jun 29, 2022

@dapplion I responded to your recent comments...if you are fine by them...is it possible to help merge?

@wemeetagain wemeetagain added status-needs-review help-wanted The author indicates that additional help is wanted. labels Jul 4, 2022
@dapplion dapplion force-pushed the dadepo/reject-many-skipped-blocks branch from b1e598a to 309170d Compare July 12, 2022 14:13
@dapplion dapplion removed the help-wanted The author indicates that additional help is wanted. label Jul 18, 2022
@dapplion dapplion force-pushed the dadepo/reject-many-skipped-blocks branch from 348a895 to 94dc8e0 Compare July 18, 2022 15:23
@dapplion dapplion merged commit 871f457 into unstable Jul 19, 2022
@dapplion dapplion deleted the dadepo/reject-many-skipped-blocks branch July 19, 2022 06:07
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.

Reject importing blocks with many skipped slots
4 participants