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: only check parent for maybeUpdateBestChildAndDescendant #5580

Closed
wants to merge 2 commits into from

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented May 30, 2023

Motivation

I'm not sure why we need to recursively run maybeUpdateBestChildAndDescendant on the entire chain instead of just the parent. The only possible change after adding a block is that the block becomes best child of the parent.

Description

In on_block, only check parent for maybeUpdateBestChildAndDescendant

if (node.parent !== undefined) {
this.maybeUpdateBestChildAndDescendant(node.parent, nodeIndex, currentSlot);
// If this node is valid, lets propagate the valid status up the chain
// and throw error if we counter invalid, as this breaks consensus
if (node.executionStatus === ExecutionStatus.Valid) {
this.propagateValidExecutionStatusByIndex(node.parent);
}
}

@dapplion dapplion requested a review from a team as a code owner May 30, 2023 10:24
@dapplion dapplion changed the title Only check parent for maybeUpdateBestChildAndDescendant refactor: only check parent for maybeUpdateBestChildAndDescendant May 30, 2023
@dapplion dapplion changed the title refactor: only check parent for maybeUpdateBestChildAndDescendant fix: only check parent for maybeUpdateBestChildAndDescendant May 30, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 30, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: cc99d5e Previous: cef8562 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 538.57 us/op 695.66 us/op 0.77
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 48.180 us/op 68.981 us/op 0.70
BLS verify - blst-native 1.2540 ms/op 1.2605 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.5746 ms/op 2.5793 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 5.5833 ms/op 6.5128 ms/op 0.86
BLS verifyMultipleSignatures 32 - blst-native 20.017 ms/op 20.195 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 26.830 us/op 27.639 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 106.12 us/op 106.41 us/op 1.00
getAttestationsForBlock 60.900 ms/op 91.922 ms/op 0.66
isKnown best case - 1 super set check 260.00 ns/op 290.00 ns/op 0.90
isKnown normal case - 2 super set checks 255.00 ns/op 264.00 ns/op 0.97
isKnown worse case - 16 super set checks 249.00 ns/op 319.00 ns/op 0.78
CheckpointStateCache - add get delete 5.6440 us/op 6.3810 us/op 0.88
validate gossip signedAggregateAndProof - struct 2.8538 ms/op 3.3195 ms/op 0.86
validate gossip attestation - struct 1.3471 ms/op 1.3789 ms/op 0.98
pickEth1Vote - no votes 1.3656 ms/op 1.7017 ms/op 0.80
pickEth1Vote - max votes 9.3141 ms/op 26.095 ms/op 0.36
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.1655 ms/op 12.163 ms/op 0.75
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.519 ms/op 19.987 ms/op 0.73
pickEth1Vote - Eth1Data fastSerialize value x2048 693.27 us/op 909.49 us/op 0.76
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.0803 ms/op 11.234 ms/op 0.45
bytes32 toHexString 514.00 ns/op 1.0100 us/op 0.51
bytes32 Buffer.toString(hex) 427.00 ns/op 627.00 ns/op 0.68
bytes32 Buffer.toString(hex) from Uint8Array 654.00 ns/op 944.00 ns/op 0.69
bytes32 Buffer.toString(hex) + 0x 447.00 ns/op 726.00 ns/op 0.62
Object access 1 prop 0.21300 ns/op 0.27100 ns/op 0.79
Map access 1 prop 0.18000 ns/op 0.22700 ns/op 0.79
Object get x1000 7.4370 ns/op 10.052 ns/op 0.74
Map get x1000 0.72300 ns/op 0.80500 ns/op 0.90
Object set x1000 76.654 ns/op 118.03 ns/op 0.65
Map set x1000 59.104 ns/op 84.302 ns/op 0.70
Return object 10000 times 0.27720 ns/op 0.53250 ns/op 0.52
Throw Error 10000 times 4.7567 us/op 6.0211 us/op 0.79
fastMsgIdFn sha256 / 200 bytes 3.6750 us/op 4.1840 us/op 0.88
fastMsgIdFn h32 xxhash / 200 bytes 340.00 ns/op 413.00 ns/op 0.82
fastMsgIdFn h64 xxhash / 200 bytes 470.00 ns/op 608.00 ns/op 0.77
fastMsgIdFn sha256 / 1000 bytes 12.103 us/op 13.375 us/op 0.90
fastMsgIdFn h32 xxhash / 1000 bytes 456.00 ns/op 472.00 ns/op 0.97
fastMsgIdFn h64 xxhash / 1000 bytes 554.00 ns/op 605.00 ns/op 0.92
fastMsgIdFn sha256 / 10000 bytes 109.06 us/op 107.76 us/op 1.01
fastMsgIdFn h32 xxhash / 10000 bytes 2.0710 us/op 2.1040 us/op 0.98
fastMsgIdFn h64 xxhash / 10000 bytes 1.5060 us/op 1.5880 us/op 0.95
enrSubnets - fastDeserialize 64 bits 1.6030 us/op 2.1870 us/op 0.73
enrSubnets - ssz BitVector 64 bits 620.00 ns/op 699.00 ns/op 0.89
enrSubnets - fastDeserialize 4 bits 204.00 ns/op 222.00 ns/op 0.92
enrSubnets - ssz BitVector 4 bits 587.00 ns/op 673.00 ns/op 0.87
prioritizePeers score -10:0 att 32-0.1 sync 2-0 120.21 us/op 169.89 us/op 0.71
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 162.00 us/op 196.62 us/op 0.82
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 191.99 us/op 240.00 us/op 0.80
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 367.81 us/op 477.74 us/op 0.77
prioritizePeers score 0:0 att 64-1 sync 4-1 444.73 us/op 474.62 us/op 0.94
array of 16000 items push then shift 1.7506 us/op 1.8015 us/op 0.97
LinkedList of 16000 items push then shift 9.4400 ns/op 10.529 ns/op 0.90
array of 16000 items push then pop 115.56 ns/op 120.09 ns/op 0.96
LinkedList of 16000 items push then pop 9.1730 ns/op 9.4210 ns/op 0.97
array of 24000 items push then shift 2.4596 us/op 2.4618 us/op 1.00
LinkedList of 24000 items push then shift 9.6610 ns/op 11.580 ns/op 0.83
array of 24000 items push then pop 90.435 ns/op 117.01 ns/op 0.77
LinkedList of 24000 items push then pop 9.2060 ns/op 9.4140 ns/op 0.98
intersect bitArray bitLen 8 14.216 ns/op 14.470 ns/op 0.98
intersect array and set length 8 105.29 ns/op 102.71 ns/op 1.03
intersect bitArray bitLen 128 45.940 ns/op 48.514 ns/op 0.95
intersect array and set length 128 1.3291 us/op 1.3583 us/op 0.98
Buffer.concat 32 items 3.4790 us/op 2.8550 us/op 1.22
Uint8Array.set 32 items 2.8890 us/op 3.1020 us/op 0.93
transfer serialized Status (84 B) 2.2270 us/op 2.5320 us/op 0.88
copy serialized Status (84 B) 2.1650 us/op 2.0750 us/op 1.04
transfer serialized SignedVoluntaryExit (112 B) 2.7330 us/op 2.5800 us/op 1.06
copy serialized SignedVoluntaryExit (112 B) 2.1340 us/op 2.3000 us/op 0.93
transfer serialized ProposerSlashing (416 B) 3.4820 us/op 3.1960 us/op 1.09
copy serialized ProposerSlashing (416 B) 3.4840 us/op 3.1730 us/op 1.10
transfer serialized Attestation (485 B) 2.8260 us/op 3.2170 us/op 0.88
copy serialized Attestation (485 B) 2.9190 us/op 3.2590 us/op 0.90
transfer serialized AttesterSlashing (33232 B) 3.5710 us/op 3.4080 us/op 1.05
copy serialized AttesterSlashing (33232 B) 8.4630 us/op 17.092 us/op 0.50
transfer serialized Small SignedBeaconBlock (128000 B) 3.1070 us/op 3.3960 us/op 0.91
copy serialized Small SignedBeaconBlock (128000 B) 21.928 us/op 36.713 us/op 0.60
transfer serialized Avg SignedBeaconBlock (200000 B) 3.7030 us/op 3.6070 us/op 1.03
copy serialized Avg SignedBeaconBlock (200000 B) 32.467 us/op 61.591 us/op 0.53
transfer serialized BlobsSidecar (524380 B) 4.3670 us/op 5.6230 us/op 0.78
copy serialized BlobsSidecar (524380 B) 105.81 us/op 245.34 us/op 0.43
transfer serialized Big SignedBeaconBlock (1000000 B) 4.7280 us/op 6.3910 us/op 0.74
copy serialized Big SignedBeaconBlock (1000000 B) 392.33 us/op 467.89 us/op 0.84
pass gossip attestations to forkchoice per slot 2.8573 ms/op 3.7209 ms/op 0.77
forkChoice updateHead vc 100000 bc 64 eq 0 2.1830 ms/op
forkChoice updateHead vc 600000 bc 64 eq 0 12.991 ms/op
forkChoice updateHead vc 1000000 bc 64 eq 0 27.012 ms/op
forkChoice updateHead vc 600000 bc 320 eq 0 17.989 ms/op
forkChoice updateHead vc 600000 bc 1200 eq 0 89.364 ms/op
forkChoice updateHead vc 600000 bc 64 eq 1000 21.880 ms/op
forkChoice updateHead vc 600000 bc 64 eq 10000 23.264 ms/op
forkChoice updateHead vc 600000 bc 64 eq 300000 55.022 ms/op
computeDeltas 3.6203 ms/op 3.8875 ms/op 0.93
computeProposerBoostScoreFromBalances 2.0748 ms/op 2.1255 ms/op 0.98
altair processAttestation - 250000 vs - 7PWei normalcase 3.3600 ms/op 4.3520 ms/op 0.77
altair processAttestation - 250000 vs - 7PWei worstcase 5.1598 ms/op 5.6208 ms/op 0.92
altair processAttestation - setStatus - 1/6 committees join 148.47 us/op 151.22 us/op 0.98
altair processAttestation - setStatus - 1/3 committees join 295.98 us/op 452.65 us/op 0.65
altair processAttestation - setStatus - 1/2 committees join 407.83 us/op 493.00 us/op 0.83
altair processAttestation - setStatus - 2/3 committees join 495.22 us/op 528.14 us/op 0.94
altair processAttestation - setStatus - 4/5 committees join 691.79 us/op 970.63 us/op 0.71
altair processAttestation - setStatus - 100% committees join 800.29 us/op 877.98 us/op 0.91
altair processBlock - 250000 vs - 7PWei normalcase 17.969 ms/op 22.101 ms/op 0.81
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.664 ms/op 37.042 ms/op 0.80
altair processBlock - 250000 vs - 7PWei worstcase 56.593 ms/op 67.818 ms/op 0.83
altair processBlock - 250000 vs - 7PWei worstcase hashState 78.629 ms/op 102.54 ms/op 0.77
phase0 processBlock - 250000 vs - 7PWei normalcase 2.7856 ms/op 4.5267 ms/op 0.62
phase0 processBlock - 250000 vs - 7PWei worstcase 32.163 ms/op 39.687 ms/op 0.81
altair processEth1Data - 250000 vs - 7PWei normalcase 662.59 us/op 1.0207 ms/op 0.65
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 13.626 us/op 16.739 us/op 0.81
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 36.474 us/op 35.354 us/op 1.03
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 16.764 us/op 16.606 us/op 1.01
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 12.731 us/op 10.771 us/op 1.18
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 119.08 us/op 115.59 us/op 1.03
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 815.45 us/op 773.06 us/op 1.05
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.0268 ms/op 1.5846 ms/op 0.65
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.1047 ms/op 1.4532 ms/op 0.76
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.9617 ms/op 3.2900 ms/op 0.90
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.6719 ms/op 2.0958 ms/op 0.80
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.7436 ms/op 6.4566 ms/op 0.73
Tree 40 250000 create 399.74 ms/op 585.95 ms/op 0.68
Tree 40 250000 get(125000) 210.49 ns/op 200.09 ns/op 1.05
Tree 40 250000 set(125000) 1.4800 us/op 1.9940 us/op 0.74
Tree 40 250000 toArray() 27.402 ms/op 25.321 ms/op 1.08
Tree 40 250000 iterate all - toArray() + loop 28.865 ms/op 33.849 ms/op 0.85
Tree 40 250000 iterate all - get(i) 85.055 ms/op 97.322 ms/op 0.87
MutableVector 250000 create 12.928 ms/op 12.338 ms/op 1.05
MutableVector 250000 get(125000) 7.3250 ns/op 6.8630 ns/op 1.07
MutableVector 250000 set(125000) 477.73 ns/op 471.26 ns/op 1.01
MutableVector 250000 toArray() 4.6661 ms/op 6.0828 ms/op 0.77
MutableVector 250000 iterate all - toArray() + loop 4.6684 ms/op 6.3203 ms/op 0.74
MutableVector 250000 iterate all - get(i) 1.6076 ms/op 1.6694 ms/op 0.96
Array 250000 create 3.8636 ms/op 5.3636 ms/op 0.72
Array 250000 clone - spread 1.2118 ms/op 5.6017 ms/op 0.22
Array 250000 get(125000) 0.62200 ns/op 2.1760 ns/op 0.29
Array 250000 set(125000) 0.96800 ns/op 1.3280 ns/op 0.73
Array 250000 iterate all - loop 114.13 us/op 91.776 us/op 1.24
effectiveBalanceIncrements clone Uint8Array 300000 52.486 us/op 74.901 us/op 0.70
effectiveBalanceIncrements clone MutableVector 300000 355.00 ns/op 480.00 ns/op 0.74
effectiveBalanceIncrements rw all Uint8Array 300000 179.72 us/op 191.80 us/op 0.94
effectiveBalanceIncrements rw all MutableVector 300000 108.87 ms/op 132.34 ms/op 0.82
phase0 afterProcessEpoch - 250000 vs - 7PWei 123.57 ms/op 134.04 ms/op 0.92
phase0 beforeProcessEpoch - 250000 vs - 7PWei 47.714 ms/op 67.327 ms/op 0.71
altair processEpoch - mainnet_e81889 366.57 ms/op 425.76 ms/op 0.86
mainnet_e81889 - altair beforeProcessEpoch 87.557 ms/op 89.272 ms/op 0.98
mainnet_e81889 - altair processJustificationAndFinalization 29.642 us/op 27.960 us/op 1.06
mainnet_e81889 - altair processInactivityUpdates 7.5651 ms/op 7.6566 ms/op 0.99
mainnet_e81889 - altair processRewardsAndPenalties 58.625 ms/op 88.035 ms/op 0.67
mainnet_e81889 - altair processRegistryUpdates 5.4400 us/op 6.3200 us/op 0.86
mainnet_e81889 - altair processSlashings 1.2280 us/op 1.4170 us/op 0.87
mainnet_e81889 - altair processEth1DataReset 1.2470 us/op 1.2300 us/op 1.01
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.5796 ms/op 4.5459 ms/op 0.35
mainnet_e81889 - altair processSlashingsReset 12.480 us/op 10.372 us/op 1.20
mainnet_e81889 - altair processRandaoMixesReset 10.309 us/op 11.642 us/op 0.89
mainnet_e81889 - altair processHistoricalRootsUpdate 1.4620 us/op 1.5930 us/op 0.92
mainnet_e81889 - altair processParticipationFlagUpdates 4.2760 us/op 5.2180 us/op 0.82
mainnet_e81889 - altair processSyncCommitteeUpdates 1.9870 us/op 1.1100 us/op 1.79
mainnet_e81889 - altair afterProcessEpoch 142.76 ms/op 132.32 ms/op 1.08
phase0 processEpoch - mainnet_e58758 388.30 ms/op 352.65 ms/op 1.10
mainnet_e58758 - phase0 beforeProcessEpoch 164.54 ms/op 168.00 ms/op 0.98
mainnet_e58758 - phase0 processJustificationAndFinalization 23.880 us/op 31.805 us/op 0.75
mainnet_e58758 - phase0 processRewardsAndPenalties 73.438 ms/op 52.866 ms/op 1.39
mainnet_e58758 - phase0 processRegistryUpdates 12.011 us/op 14.934 us/op 0.80
mainnet_e58758 - phase0 processSlashings 895.00 ns/op 1.4800 us/op 0.60
mainnet_e58758 - phase0 processEth1DataReset 1.0730 us/op 1.0750 us/op 1.00
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.7235 ms/op 1.0414 ms/op 1.66
mainnet_e58758 - phase0 processSlashingsReset 6.2520 us/op 4.5030 us/op 1.39
mainnet_e58758 - phase0 processRandaoMixesReset 11.615 us/op 10.631 us/op 1.09
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.3000 us/op 2.1750 us/op 0.60
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.5190 us/op 10.535 us/op 0.52
mainnet_e58758 - phase0 afterProcessEpoch 106.26 ms/op 109.54 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3806 ms/op 1.3507 ms/op 1.02
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.7948 ms/op 1.5600 ms/op 1.15
altair processInactivityUpdates - 250000 normalcase 28.578 ms/op 26.307 ms/op 1.09
altair processInactivityUpdates - 250000 worstcase 27.830 ms/op 37.815 ms/op 0.74
phase0 processRegistryUpdates - 250000 normalcase 7.4160 us/op 11.632 us/op 0.64
phase0 processRegistryUpdates - 250000 badcase_full_deposits 303.02 us/op 347.19 us/op 0.87
phase0 processRegistryUpdates - 250000 worstcase 0.5 136.44 ms/op 127.63 ms/op 1.07
altair processRewardsAndPenalties - 250000 normalcase 71.948 ms/op 84.567 ms/op 0.85
altair processRewardsAndPenalties - 250000 worstcase 71.168 ms/op 73.744 ms/op 0.97
phase0 getAttestationDeltas - 250000 normalcase 8.1627 ms/op 8.9029 ms/op 0.92
phase0 getAttestationDeltas - 250000 worstcase 8.2347 ms/op 7.3780 ms/op 1.12
phase0 processSlashings - 250000 worstcase 4.0042 ms/op 3.5296 ms/op 1.13
altair processSyncCommitteeUpdates - 250000 196.67 ms/op 188.86 ms/op 1.04
BeaconState.hashTreeRoot - No change 294.00 ns/op 423.00 ns/op 0.70
BeaconState.hashTreeRoot - 1 full validator 59.452 us/op 59.044 us/op 1.01
BeaconState.hashTreeRoot - 32 full validator 598.72 us/op 510.14 us/op 1.17
BeaconState.hashTreeRoot - 512 full validator 6.2731 ms/op 6.0889 ms/op 1.03
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 68.519 us/op 66.861 us/op 1.02
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 984.50 us/op 976.32 us/op 1.01
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.869 ms/op 12.788 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 51.916 us/op 52.965 us/op 0.98
BeaconState.hashTreeRoot - 32 balances 501.79 us/op 538.89 us/op 0.93
BeaconState.hashTreeRoot - 512 balances 4.6908 ms/op 4.6234 ms/op 1.01
BeaconState.hashTreeRoot - 250000 balances 76.303 ms/op 78.717 ms/op 0.97
aggregationBits - 2048 els - zipIndexesInBitList 19.224 us/op 16.618 us/op 1.16
regular array get 100000 times 35.693 us/op 34.297 us/op 1.04
wrappedArray get 100000 times 34.948 us/op 40.857 us/op 0.86
arrayWithProxy get 100000 times 17.118 ms/op 18.394 ms/op 0.93
ssz.Root.equals 576.00 ns/op 598.00 ns/op 0.96
byteArrayEquals 592.00 ns/op 556.00 ns/op 1.06
shuffle list - 16384 els 7.2079 ms/op 7.2747 ms/op 0.99
shuffle list - 250000 els 107.81 ms/op 102.94 ms/op 1.05
processSlot - 1 slots 9.9860 us/op 10.748 us/op 0.93
processSlot - 32 slots 1.5010 ms/op 1.5718 ms/op 0.95
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 36.052 ms/op 36.626 ms/op 0.98
getCommitteeAssignments - req 1 vs - 250000 vc 2.9582 ms/op 2.9939 ms/op 0.99
getCommitteeAssignments - req 100 vs - 250000 vc 4.2703 ms/op 4.1181 ms/op 1.04
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5778 ms/op 4.5020 ms/op 1.02
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.1800 ns/op 4.7600 ns/op 1.09
state getBlockRootAtSlot - 250000 vs - 7PWei 595.28 ns/op 853.52 ns/op 0.70
computeProposers - vc 250000 11.120 ms/op 10.895 ms/op 1.02
computeEpochShuffling - vc 250000 114.98 ms/op 103.74 ms/op 1.11
getNextSyncCommittee - vc 250000 184.40 ms/op 184.93 ms/op 1.00
computeSigningRoot for AttestationData 14.248 us/op 13.341 us/op 1.07
hash AttestationData serialized data then Buffer.toString(base64) 2.5784 us/op 2.4449 us/op 1.05
toHexString serialized data 1.1154 us/op 1.1197 us/op 1.00
Buffer.toString(base64) 358.02 ns/op 344.07 ns/op 1.04

by benchmarkbot/action

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.

2 participants