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

Correctly override active preset #5389

Merged
merged 5 commits into from
Apr 20, 2023
Merged

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Apr 19, 2023

Motivation

Fix for #4601 and #5387, setActivePreset now correctly overrides not only the variables that are exported individually/explicitly but also the exported activePreset object.

Description

  • Correctly override the active preset
  • Add beacon preset types to filter out extraneous keys
  • Improve consistency with ChainConfig by converting BeaconPreset to type and renaming the file to types.ts
  • Add jsdoc to BeaconPreset
  • Verify that preset values in activePreset are overridden

Note: Initial implementation in #5387 did not filter out extraneous keys due to the fact that the destructuring did that already. However, since we override the activePreset object now I think it is better to apply filtering to not pollute the object as it is done in chainConfigToJson.

@nflaig nflaig requested a review from a team as a code owner April 19, 2023 20:13
@nflaig nflaig force-pushed the nflaig/correctly-update-preset branch from 4d04366 to 9d71502 Compare April 19, 2023 20:21
@nflaig nflaig force-pushed the nflaig/correctly-update-preset branch from 9d71502 to 0aafe75 Compare April 19, 2023 20:24
@nflaig nflaig changed the title Nflaig/correctly update preset Correctly override the active preset Apr 19, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 19, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 62fe7b3 Previous: 35fe214 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 811.18 us/op 895.18 us/op 0.91
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 53.502 us/op 78.171 us/op 0.68
BLS verify - blst-native 1.2326 ms/op 1.8978 ms/op 0.65
BLS verifyMultipleSignatures 3 - blst-native 2.4973 ms/op 3.4992 ms/op 0.71
BLS verifyMultipleSignatures 8 - blst-native 5.3772 ms/op 6.3512 ms/op 0.85
BLS verifyMultipleSignatures 32 - blst-native 19.527 ms/op 23.447 ms/op 0.83
BLS aggregatePubkeys 32 - blst-native 25.988 us/op 31.114 us/op 0.84
BLS aggregatePubkeys 128 - blst-native 101.91 us/op 124.86 us/op 0.82
getAttestationsForBlock 56.660 ms/op 104.20 ms/op 0.54
isKnown best case - 1 super set check 265.00 ns/op 356.00 ns/op 0.74
isKnown normal case - 2 super set checks 263.00 ns/op 296.00 ns/op 0.89
isKnown worse case - 16 super set checks 252.00 ns/op 319.00 ns/op 0.79
CheckpointStateCache - add get delete 5.2370 us/op 7.3770 us/op 0.71
validate gossip signedAggregateAndProof - struct 2.7962 ms/op 3.1878 ms/op 0.88
validate gossip attestation - struct 1.3193 ms/op 1.7663 ms/op 0.75
pickEth1Vote - no votes 1.3181 ms/op 1.5865 ms/op 0.83
pickEth1Vote - max votes 9.1507 ms/op 16.371 ms/op 0.56
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.9267 ms/op 13.183 ms/op 0.68
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.590 ms/op 21.800 ms/op 0.67
pickEth1Vote - Eth1Data fastSerialize value x2048 738.08 us/op 931.01 us/op 0.79
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.7360 ms/op 7.5940 ms/op 0.62
bytes32 toHexString 488.00 ns/op 1.0680 us/op 0.46
bytes32 Buffer.toString(hex) 357.00 ns/op 527.00 ns/op 0.68
bytes32 Buffer.toString(hex) from Uint8Array 552.00 ns/op 733.00 ns/op 0.75
bytes32 Buffer.toString(hex) + 0x 380.00 ns/op 495.00 ns/op 0.77
Object access 1 prop 0.16900 ns/op 0.24400 ns/op 0.69
Map access 1 prop 0.15700 ns/op 0.19300 ns/op 0.81
Object get x1000 7.0150 ns/op 7.5130 ns/op 0.93
Map get x1000 0.62800 ns/op 0.85600 ns/op 0.73
Object set x1000 52.448 ns/op 89.315 ns/op 0.59
Map set x1000 42.387 ns/op 66.314 ns/op 0.64
Return object 10000 times 0.23390 ns/op 0.30200 ns/op 0.77
Throw Error 10000 times 4.1516 us/op 6.4323 us/op 0.65
fastMsgIdFn sha256 / 200 bytes 3.4440 us/op 4.8430 us/op 0.71
fastMsgIdFn h32 xxhash / 200 bytes 286.00 ns/op 482.00 ns/op 0.59
fastMsgIdFn h64 xxhash / 200 bytes 388.00 ns/op 618.00 ns/op 0.63
fastMsgIdFn sha256 / 1000 bytes 11.456 us/op 14.537 us/op 0.79
fastMsgIdFn h32 xxhash / 1000 bytes 407.00 ns/op 612.00 ns/op 0.67
fastMsgIdFn h64 xxhash / 1000 bytes 456.00 ns/op 860.00 ns/op 0.53
fastMsgIdFn sha256 / 10000 bytes 102.47 us/op 133.59 us/op 0.77
fastMsgIdFn h32 xxhash / 10000 bytes 1.8930 us/op 2.2760 us/op 0.83
fastMsgIdFn h64 xxhash / 10000 bytes 1.3380 us/op 1.7070 us/op 0.78
enrSubnets - fastDeserialize 64 bits 1.2820 us/op 2.0920 us/op 0.61
enrSubnets - ssz BitVector 64 bits 480.00 ns/op 709.00 ns/op 0.68
enrSubnets - fastDeserialize 4 bits 161.00 ns/op 252.00 ns/op 0.64
enrSubnets - ssz BitVector 4 bits 471.00 ns/op 734.00 ns/op 0.64
prioritizePeers score -10:0 att 32-0.1 sync 2-0 103.25 us/op 142.83 us/op 0.72
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 131.30 us/op 196.96 us/op 0.67
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 160.14 us/op 230.01 us/op 0.70
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 292.77 us/op 507.91 us/op 0.58
prioritizePeers score 0:0 att 64-1 sync 4-1 352.85 us/op 525.52 us/op 0.67
array of 16000 items push then shift 1.5765 us/op 2.1819 us/op 0.72
LinkedList of 16000 items push then shift 8.6210 ns/op 11.267 ns/op 0.77
array of 16000 items push then pop 79.160 ns/op 143.29 ns/op 0.55
LinkedList of 16000 items push then pop 8.4140 ns/op 12.286 ns/op 0.68
array of 24000 items push then shift 2.3284 us/op 3.5229 us/op 0.66
LinkedList of 24000 items push then shift 8.5710 ns/op 15.293 ns/op 0.56
array of 24000 items push then pop 72.262 ns/op 135.91 ns/op 0.53
LinkedList of 24000 items push then pop 8.4000 ns/op 13.051 ns/op 0.64
intersect bitArray bitLen 8 12.892 ns/op 22.157 ns/op 0.58
intersect array and set length 8 76.684 ns/op 138.57 ns/op 0.55
intersect bitArray bitLen 128 43.427 ns/op 68.213 ns/op 0.64
intersect array and set length 128 1.0384 us/op 1.8323 us/op 0.57
Buffer.concat 32 items 2.5920 us/op 4.3000 us/op 0.60
Uint8Array.set 32 items 2.0730 us/op 4.1020 us/op 0.51
pass gossip attestations to forkchoice per slot 2.7255 ms/op 4.5814 ms/op 0.59
computeDeltas 2.8636 ms/op 3.9152 ms/op 0.73
computeProposerBoostScoreFromBalances 1.7679 ms/op 2.1735 ms/op 0.81
altair processAttestation - 250000 vs - 7PWei normalcase 2.1915 ms/op 4.3472 ms/op 0.50
altair processAttestation - 250000 vs - 7PWei worstcase 3.2182 ms/op 5.7078 ms/op 0.56
altair processAttestation - setStatus - 1/6 committees join 138.47 us/op 208.69 us/op 0.66
altair processAttestation - setStatus - 1/3 committees join 272.52 us/op 367.37 us/op 0.74
altair processAttestation - setStatus - 1/2 committees join 362.29 us/op 614.54 us/op 0.59
altair processAttestation - setStatus - 2/3 committees join 463.02 us/op 681.62 us/op 0.68
altair processAttestation - setStatus - 4/5 committees join 660.83 us/op 884.28 us/op 0.75
altair processAttestation - setStatus - 100% committees join 758.40 us/op 954.54 us/op 0.79
altair processBlock - 250000 vs - 7PWei normalcase 18.708 ms/op 26.958 ms/op 0.69
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.516 ms/op 39.614 ms/op 0.75
altair processBlock - 250000 vs - 7PWei worstcase 53.360 ms/op 74.809 ms/op 0.71
altair processBlock - 250000 vs - 7PWei worstcase hashState 76.057 ms/op 99.292 ms/op 0.77
phase0 processBlock - 250000 vs - 7PWei normalcase 2.1574 ms/op 3.4705 ms/op 0.62
phase0 processBlock - 250000 vs - 7PWei worstcase 31.900 ms/op 40.463 ms/op 0.79
altair processEth1Data - 250000 vs - 7PWei normalcase 469.79 us/op 885.37 us/op 0.53
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 7.9330 us/op 14.874 us/op 0.53
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 23.660 us/op 41.383 us/op 0.57
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 13.662 us/op 21.332 us/op 0.64
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 9.8200 us/op 16.640 us/op 0.59
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 93.006 us/op 123.24 us/op 0.75
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 693.59 us/op 939.69 us/op 0.74
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 1.2499 ms/op 1.0015 ms/op 1.25
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.4752 ms/op 1.4407 ms/op 1.02
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 4.3194 ms/op 4.5426 ms/op 0.95
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 3.4970 ms/op 2.5841 ms/op 1.35
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 5.8364 ms/op 7.1813 ms/op 0.81
Tree 40 250000 create 460.50 ms/op 824.19 ms/op 0.56
Tree 40 250000 get(125000) 216.56 ns/op 233.07 ns/op 0.93
Tree 40 250000 set(125000) 1.1920 us/op 2.7860 us/op 0.43
Tree 40 250000 toArray() 24.041 ms/op 29.665 ms/op 0.81
Tree 40 250000 iterate all - toArray() + loop 28.168 ms/op 30.121 ms/op 0.94
Tree 40 250000 iterate all - get(i) 77.551 ms/op 93.518 ms/op 0.83
MutableVector 250000 create 10.148 ms/op 14.440 ms/op 0.70
MutableVector 250000 get(125000) 6.4160 ns/op 7.4300 ns/op 0.86
MutableVector 250000 set(125000) 276.86 ns/op 730.10 ns/op 0.38
MutableVector 250000 toArray() 3.2749 ms/op 5.5196 ms/op 0.59
MutableVector 250000 iterate all - toArray() + loop 3.7739 ms/op 6.0607 ms/op 0.62
MutableVector 250000 iterate all - get(i) 1.5628 ms/op 2.1970 ms/op 0.71
Array 250000 create 3.0210 ms/op 5.9505 ms/op 0.51
Array 250000 clone - spread 1.1622 ms/op 2.9590 ms/op 0.39
Array 250000 get(125000) 0.71200 ns/op 1.4880 ns/op 0.48
Array 250000 set(125000) 0.71000 ns/op 1.3950 ns/op 0.51
Array 250000 iterate all - loop 87.665 us/op 125.06 us/op 0.70
effectiveBalanceIncrements clone Uint8Array 300000 48.125 us/op 78.129 us/op 0.62
effectiveBalanceIncrements clone MutableVector 300000 403.00 ns/op 721.00 ns/op 0.56
effectiveBalanceIncrements rw all Uint8Array 300000 184.56 us/op 201.41 us/op 0.92
effectiveBalanceIncrements rw all MutableVector 300000 115.02 ms/op 188.95 ms/op 0.61
phase0 afterProcessEpoch - 250000 vs - 7PWei 120.33 ms/op 178.68 ms/op 0.67
phase0 beforeProcessEpoch - 250000 vs - 7PWei 43.242 ms/op 61.339 ms/op 0.70
altair processEpoch - mainnet_e81889 356.77 ms/op 462.78 ms/op 0.77
mainnet_e81889 - altair beforeProcessEpoch 67.488 ms/op 100.77 ms/op 0.67
mainnet_e81889 - altair processJustificationAndFinalization 24.545 us/op 41.399 us/op 0.59
mainnet_e81889 - altair processInactivityUpdates 6.7052 ms/op 9.5439 ms/op 0.70
mainnet_e81889 - altair processRewardsAndPenalties 56.058 ms/op 75.740 ms/op 0.74
mainnet_e81889 - altair processRegistryUpdates 4.2750 us/op 8.6870 us/op 0.49
mainnet_e81889 - altair processSlashings 1.0400 us/op 1.6110 us/op 0.65
mainnet_e81889 - altair processEth1DataReset 1.2930 us/op 1.9780 us/op 0.65
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.6578 ms/op 1.8819 ms/op 0.88
mainnet_e81889 - altair processSlashingsReset 7.7830 us/op 14.029 us/op 0.55
mainnet_e81889 - altair processRandaoMixesReset 9.2500 us/op 12.776 us/op 0.72
mainnet_e81889 - altair processHistoricalRootsUpdate 1.3890 us/op 2.4420 us/op 0.57
mainnet_e81889 - altair processParticipationFlagUpdates 6.0180 us/op 9.4340 us/op 0.64
mainnet_e81889 - altair processSyncCommitteeUpdates 1.1720 us/op 2.1490 us/op 0.55
mainnet_e81889 - altair afterProcessEpoch 137.72 ms/op 184.83 ms/op 0.75
phase0 processEpoch - mainnet_e58758 402.90 ms/op 569.50 ms/op 0.71
mainnet_e58758 - phase0 beforeProcessEpoch 147.99 ms/op 254.50 ms/op 0.58
mainnet_e58758 - phase0 processJustificationAndFinalization 22.354 us/op 40.239 us/op 0.56
mainnet_e58758 - phase0 processRewardsAndPenalties 67.428 ms/op 64.063 ms/op 1.05
mainnet_e58758 - phase0 processRegistryUpdates 8.4730 us/op 22.687 us/op 0.37
mainnet_e58758 - phase0 processSlashings 812.00 ns/op 1.8950 us/op 0.43
mainnet_e58758 - phase0 processEth1DataReset 637.00 ns/op 1.8020 us/op 0.35
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.3498 ms/op 1.9964 ms/op 0.68
mainnet_e58758 - phase0 processSlashingsReset 3.4520 us/op 9.8590 us/op 0.35
mainnet_e58758 - phase0 processRandaoMixesReset 4.3830 us/op 15.657 us/op 0.28
mainnet_e58758 - phase0 processHistoricalRootsUpdate 598.00 ns/op 2.3240 us/op 0.26
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.1600 us/op 12.583 us/op 0.33
mainnet_e58758 - phase0 afterProcessEpoch 99.160 ms/op 124.76 ms/op 0.79
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2410 ms/op 2.3862 ms/op 0.52
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5075 ms/op 2.6006 ms/op 0.58
altair processInactivityUpdates - 250000 normalcase 26.322 ms/op 37.153 ms/op 0.71
altair processInactivityUpdates - 250000 worstcase 24.853 ms/op 29.482 ms/op 0.84
phase0 processRegistryUpdates - 250000 normalcase 7.1430 us/op 17.953 us/op 0.40
phase0 processRegistryUpdates - 250000 badcase_full_deposits 280.03 us/op 307.45 us/op 0.91
phase0 processRegistryUpdates - 250000 worstcase 0.5 133.12 ms/op 129.77 ms/op 1.03
altair processRewardsAndPenalties - 250000 normalcase 69.285 ms/op 57.883 ms/op 1.20
altair processRewardsAndPenalties - 250000 worstcase 65.418 ms/op 55.191 ms/op 1.19
phase0 getAttestationDeltas - 250000 normalcase 7.1026 ms/op 7.0069 ms/op 1.01
phase0 getAttestationDeltas - 250000 worstcase 7.0172 ms/op 7.0916 ms/op 0.99
phase0 processSlashings - 250000 worstcase 3.7087 ms/op 3.5441 ms/op 1.05
altair processSyncCommitteeUpdates - 250000 182.12 ms/op 187.78 ms/op 0.97
BeaconState.hashTreeRoot - No change 272.00 ns/op 273.00 ns/op 1.00
BeaconState.hashTreeRoot - 1 full validator 53.390 us/op 54.180 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 536.67 us/op 533.26 us/op 1.01
BeaconState.hashTreeRoot - 512 full validator 5.1057 ms/op 6.0275 ms/op 0.85
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 65.672 us/op 67.514 us/op 0.97
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 890.41 us/op 925.59 us/op 0.96
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.605 ms/op 12.151 ms/op 1.04
BeaconState.hashTreeRoot - 1 balances 50.669 us/op 48.314 us/op 1.05
BeaconState.hashTreeRoot - 32 balances 501.81 us/op 467.12 us/op 1.07
BeaconState.hashTreeRoot - 512 balances 4.7835 ms/op 4.7142 ms/op 1.01
BeaconState.hashTreeRoot - 250000 balances 75.454 ms/op 69.519 ms/op 1.09
aggregationBits - 2048 els - zipIndexesInBitList 17.540 us/op 19.489 us/op 0.90
regular array get 100000 times 33.243 us/op 33.960 us/op 0.98
wrappedArray get 100000 times 33.221 us/op 34.400 us/op 0.97
arrayWithProxy get 100000 times 17.534 ms/op 16.826 ms/op 1.04
ssz.Root.equals 601.00 ns/op 578.00 ns/op 1.04
byteArrayEquals 585.00 ns/op 574.00 ns/op 1.02
shuffle list - 16384 els 7.5184 ms/op 7.2520 ms/op 1.04
shuffle list - 250000 els 106.41 ms/op 107.07 ms/op 0.99
processSlot - 1 slots 9.1310 us/op 9.1680 us/op 1.00
processSlot - 32 slots 1.4069 ms/op 1.4139 ms/op 1.00
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.365 ms/op 33.799 ms/op 1.11
getCommitteeAssignments - req 1 vs - 250000 vc 3.0091 ms/op 2.9347 ms/op 1.03
getCommitteeAssignments - req 100 vs - 250000 vc 4.2594 ms/op 4.1443 ms/op 1.03
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5996 ms/op 4.5331 ms/op 1.01
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.9600 ns/op 4.7700 ns/op 1.04
state getBlockRootAtSlot - 250000 vs - 7PWei 733.93 ns/op 780.80 ns/op 0.94
computeProposers - vc 250000 11.524 ms/op 10.648 ms/op 1.08
computeEpochShuffling - vc 250000 111.87 ms/op 102.74 ms/op 1.09
getNextSyncCommittee - vc 250000 189.60 ms/op 175.92 ms/op 1.08
computeSigningRoot for AttestationData 14.273 us/op 13.991 us/op 1.02
hash AttestationData serialized data then Buffer.toString(base64) 2.5720 us/op 2.4579 us/op 1.05
toHexString serialized data 1.6088 us/op 1.1221 us/op 1.43
Buffer.toString(base64) 410.70 ns/op 361.70 ns/op 1.14

by benchmarkbot/action

@nflaig nflaig changed the title Correctly override the active preset Correctly override active preset Apr 19, 2023
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

lgtm

@wemeetagain wemeetagain merged commit ddbae50 into unstable Apr 20, 2023
9 checks passed
@wemeetagain wemeetagain deleted the nflaig/correctly-update-preset branch April 20, 2023 14:25
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.8.0 🎉

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.

None yet

2 participants