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

Use fastify req.routeConfig instead of res.context.config #5398

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Apr 21, 2023

Motivation

With update to Fastify v4 in #5369, res.context.config has been deprecated

@deprecated — Use Request#routeConfig or Request#routeSchema instead

Description

Use fastify req.routeConfig instead of res.context.config

@nflaig nflaig requested a review from a team as a code owner April 21, 2023 13:32
@@ -78,25 +78,25 @@ export class RestApiServer {

// Log all incoming request to debug (before parsing). TODO: Should we hook latter in the lifecycle? https://www.fastify.io/docs/latest/Lifecycle/
// Note: Must be an async method so fastify can continue the release lifecycle. Otherwise we must call done() or the request stalls
server.addHook("onRequest", async (req, res) => {
const {operationId} = res.context.config as RouteConfig;
server.addHook("onRequest", async (req, _res) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

kept _res for debugging purposes

@wemeetagain wemeetagain enabled auto-merge (squash) April 21, 2023 13:41
@wemeetagain wemeetagain merged commit 7469f0d into unstable Apr 21, 2023
@wemeetagain wemeetagain deleted the nflaig/update-res-context-config branch April 21, 2023 13:45
@github-actions
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 23ecae1 Previous: fb192bf Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 561.23 us/op 721.78 us/op 0.78
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 50.522 us/op 48.913 us/op 1.03
BLS verify - blst-native 1.2397 ms/op 1.2447 ms/op 1.00
BLS verifyMultipleSignatures 3 - blst-native 2.4889 ms/op 2.5650 ms/op 0.97
BLS verifyMultipleSignatures 8 - blst-native 5.3356 ms/op 5.5203 ms/op 0.97
BLS verifyMultipleSignatures 32 - blst-native 19.560 ms/op 19.837 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 26.056 us/op 26.935 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 102.74 us/op 103.38 us/op 0.99
getAttestationsForBlock 62.527 ms/op 64.471 ms/op 0.97
isKnown best case - 1 super set check 268.00 ns/op 279.00 ns/op 0.96
isKnown normal case - 2 super set checks 272.00 ns/op 275.00 ns/op 0.99
isKnown worse case - 16 super set checks 273.00 ns/op 273.00 ns/op 1.00
CheckpointStateCache - add get delete 5.6120 us/op 6.2390 us/op 0.90
validate gossip signedAggregateAndProof - struct 2.9231 ms/op 2.8864 ms/op 1.01
validate gossip attestation - struct 1.3873 ms/op 1.3822 ms/op 1.00
pickEth1Vote - no votes 1.3999 ms/op 1.4212 ms/op 0.99
pickEth1Vote - max votes 13.350 ms/op 10.615 ms/op 1.26
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.088 ms/op 9.4887 ms/op 1.06
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 15.872 ms/op 17.723 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize value x2048 707.84 us/op 804.53 us/op 0.88
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.6738 ms/op 9.3120 ms/op 0.72
bytes32 toHexString 515.00 ns/op 952.00 ns/op 0.54
bytes32 Buffer.toString(hex) 358.00 ns/op 461.00 ns/op 0.78
bytes32 Buffer.toString(hex) from Uint8Array 573.00 ns/op 697.00 ns/op 0.82
bytes32 Buffer.toString(hex) + 0x 361.00 ns/op 476.00 ns/op 0.76
Object access 1 prop 0.17500 ns/op 0.24000 ns/op 0.73
Map access 1 prop 0.16900 ns/op 0.17700 ns/op 0.95
Object get x1000 6.7010 ns/op 8.3250 ns/op 0.80
Map get x1000 0.64100 ns/op 0.73300 ns/op 0.87
Object set x1000 53.408 ns/op 86.286 ns/op 0.62
Map set x1000 45.266 ns/op 64.053 ns/op 0.71
Return object 10000 times 0.24730 ns/op 0.30460 ns/op 0.81
Throw Error 10000 times 4.3616 us/op 4.7827 us/op 0.91
fastMsgIdFn sha256 / 200 bytes 3.5160 us/op 3.8580 us/op 0.91
fastMsgIdFn h32 xxhash / 200 bytes 304.00 ns/op 358.00 ns/op 0.85
fastMsgIdFn h64 xxhash / 200 bytes 438.00 ns/op 546.00 ns/op 0.80
fastMsgIdFn sha256 / 1000 bytes 11.813 us/op 12.280 us/op 0.96
fastMsgIdFn h32 xxhash / 1000 bytes 433.00 ns/op 515.00 ns/op 0.84
fastMsgIdFn h64 xxhash / 1000 bytes 522.00 ns/op 601.00 ns/op 0.87
fastMsgIdFn sha256 / 10000 bytes 106.07 us/op 108.73 us/op 0.98
fastMsgIdFn h32 xxhash / 10000 bytes 2.0160 us/op 2.1120 us/op 0.95
fastMsgIdFn h64 xxhash / 10000 bytes 1.4820 us/op 1.5380 us/op 0.96
enrSubnets - fastDeserialize 64 bits 1.4270 us/op 1.9040 us/op 0.75
enrSubnets - ssz BitVector 64 bits 528.00 ns/op 696.00 ns/op 0.76
enrSubnets - fastDeserialize 4 bits 188.00 ns/op 243.00 ns/op 0.77
enrSubnets - ssz BitVector 4 bits 543.00 ns/op 707.00 ns/op 0.77
prioritizePeers score -10:0 att 32-0.1 sync 2-0 128.50 us/op 129.23 us/op 0.99
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 164.75 us/op 181.94 us/op 0.91
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 194.74 us/op 239.46 us/op 0.81
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 389.99 us/op 374.13 us/op 1.04
prioritizePeers score 0:0 att 64-1 sync 4-1 477.61 us/op 435.76 us/op 1.10
array of 16000 items push then shift 1.8425 us/op 1.7801 us/op 1.04
LinkedList of 16000 items push then shift 11.389 ns/op 10.026 ns/op 1.14
array of 16000 items push then pop 125.54 ns/op 114.63 ns/op 1.10
LinkedList of 16000 items push then pop 9.6300 ns/op 9.5000 ns/op 1.01
array of 24000 items push then shift 2.5571 us/op 2.4945 us/op 1.03
LinkedList of 24000 items push then shift 10.103 ns/op 10.233 ns/op 0.99
array of 24000 items push then pop 89.795 ns/op 92.094 ns/op 0.98
LinkedList of 24000 items push then pop 9.3230 ns/op 10.441 ns/op 0.89
intersect bitArray bitLen 8 14.066 ns/op 32.375 ns/op 0.43
intersect array and set length 8 113.72 ns/op 102.72 ns/op 1.11
intersect bitArray bitLen 128 46.964 ns/op 70.377 ns/op 0.67
intersect array and set length 128 1.3885 us/op 1.3294 us/op 1.04
Buffer.concat 32 items 3.2600 us/op 3.2410 us/op 1.01
Uint8Array.set 32 items 3.0820 us/op 2.7410 us/op 1.12
pass gossip attestations to forkchoice per slot 3.5414 ms/op 3.4681 ms/op 1.02
computeDeltas 3.1071 ms/op 3.4194 ms/op 0.91
computeProposerBoostScoreFromBalances 1.8151 ms/op 1.8748 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei normalcase 2.4842 ms/op 3.4719 ms/op 0.72
altair processAttestation - 250000 vs - 7PWei worstcase 3.3591 ms/op 4.7791 ms/op 0.70
altair processAttestation - setStatus - 1/6 committees join 146.81 us/op 150.73 us/op 0.97
altair processAttestation - setStatus - 1/3 committees join 290.18 us/op 284.46 us/op 1.02
altair processAttestation - setStatus - 1/2 committees join 371.56 us/op 394.67 us/op 0.94
altair processAttestation - setStatus - 2/3 committees join 480.30 us/op 478.49 us/op 1.00
altair processAttestation - setStatus - 4/5 committees join 659.40 us/op 687.19 us/op 0.96
altair processAttestation - setStatus - 100% committees join 779.72 us/op 786.03 us/op 0.99
altair processBlock - 250000 vs - 7PWei normalcase 16.468 ms/op 19.866 ms/op 0.83
altair processBlock - 250000 vs - 7PWei normalcase hashState 25.302 ms/op 29.611 ms/op 0.85
altair processBlock - 250000 vs - 7PWei worstcase 50.187 ms/op 57.298 ms/op 0.88
altair processBlock - 250000 vs - 7PWei worstcase hashState 73.330 ms/op 78.047 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei normalcase 2.2099 ms/op 2.4653 ms/op 0.90
phase0 processBlock - 250000 vs - 7PWei worstcase 30.407 ms/op 31.087 ms/op 0.98
altair processEth1Data - 250000 vs - 7PWei normalcase 515.61 us/op 643.19 us/op 0.80
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 7.6260 us/op 10.827 us/op 0.70
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 23.069 us/op 32.762 us/op 0.70
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 9.9040 us/op 15.159 us/op 0.65
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 7.3600 us/op 13.689 us/op 0.54
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 88.026 us/op 113.98 us/op 0.77
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 655.56 us/op 778.15 us/op 0.84
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 940.81 us/op 1.0975 ms/op 0.86
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 912.79 us/op 941.57 us/op 0.97
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.4586 ms/op 3.1660 ms/op 0.78
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.5216 ms/op 1.7494 ms/op 0.87
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.9436 ms/op 4.4430 ms/op 0.89
Tree 40 250000 create 329.52 ms/op 582.73 ms/op 0.57
Tree 40 250000 get(125000) 182.60 ns/op 203.38 ns/op 0.90
Tree 40 250000 set(125000) 1.0071 us/op 1.3292 us/op 0.76
Tree 40 250000 toArray() 18.684 ms/op 29.882 ms/op 0.63
Tree 40 250000 iterate all - toArray() + loop 21.868 ms/op 28.727 ms/op 0.76
Tree 40 250000 iterate all - get(i) 70.806 ms/op 80.826 ms/op 0.88
MutableVector 250000 create 9.6580 ms/op 11.643 ms/op 0.83
MutableVector 250000 get(125000) 6.3860 ns/op 7.1360 ns/op 0.89
MutableVector 250000 set(125000) 254.41 ns/op 521.70 ns/op 0.49
MutableVector 250000 toArray() 2.8790 ms/op 4.4363 ms/op 0.65
MutableVector 250000 iterate all - toArray() + loop 3.1673 ms/op 4.8298 ms/op 0.66
MutableVector 250000 iterate all - get(i) 1.5462 ms/op 1.6995 ms/op 0.91
Array 250000 create 2.5592 ms/op 4.3538 ms/op 0.59
Array 250000 clone - spread 1.1574 ms/op 1.4609 ms/op 0.79
Array 250000 get(125000) 0.56000 ns/op 0.91300 ns/op 0.61
Array 250000 set(125000) 0.65200 ns/op 1.1750 ns/op 0.55
Array 250000 iterate all - loop 83.519 us/op 113.18 us/op 0.74
effectiveBalanceIncrements clone Uint8Array 300000 29.411 us/op 69.333 us/op 0.42
effectiveBalanceIncrements clone MutableVector 300000 327.00 ns/op 490.00 ns/op 0.67
effectiveBalanceIncrements rw all Uint8Array 300000 170.34 us/op 186.87 us/op 0.91
effectiveBalanceIncrements rw all MutableVector 300000 78.702 ms/op 122.13 ms/op 0.64
phase0 afterProcessEpoch - 250000 vs - 7PWei 115.47 ms/op 130.81 ms/op 0.88
phase0 beforeProcessEpoch - 250000 vs - 7PWei 36.538 ms/op 47.385 ms/op 0.77
altair processEpoch - mainnet_e81889 317.97 ms/op 335.21 ms/op 0.95
mainnet_e81889 - altair beforeProcessEpoch 65.528 ms/op 73.165 ms/op 0.90
mainnet_e81889 - altair processJustificationAndFinalization 21.496 us/op 24.808 us/op 0.87
mainnet_e81889 - altair processInactivityUpdates 6.3627 ms/op 6.7402 ms/op 0.94
mainnet_e81889 - altair processRewardsAndPenalties 53.826 ms/op 57.333 ms/op 0.94
mainnet_e81889 - altair processRegistryUpdates 2.6730 us/op 3.0200 us/op 0.89
mainnet_e81889 - altair processSlashings 721.00 ns/op 614.00 ns/op 1.17
mainnet_e81889 - altair processEth1DataReset 1.1640 us/op 1.1780 us/op 0.99
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.3783 ms/op 1.3751 ms/op 1.00
mainnet_e81889 - altair processSlashingsReset 5.0570 us/op 6.8620 us/op 0.74
mainnet_e81889 - altair processRandaoMixesReset 4.3020 us/op 9.4580 us/op 0.45
mainnet_e81889 - altair processHistoricalRootsUpdate 703.00 ns/op 1.3070 us/op 0.54
mainnet_e81889 - altair processParticipationFlagUpdates 4.1430 us/op 4.6160 us/op 0.90
mainnet_e81889 - altair processSyncCommitteeUpdates 899.00 ns/op 1.0110 us/op 0.89
mainnet_e81889 - altair afterProcessEpoch 135.38 ms/op 132.70 ms/op 1.02
phase0 processEpoch - mainnet_e58758 361.10 ms/op 405.91 ms/op 0.89
mainnet_e58758 - phase0 beforeProcessEpoch 138.68 ms/op 166.15 ms/op 0.83
mainnet_e58758 - phase0 processJustificationAndFinalization 18.666 us/op 22.853 us/op 0.82
mainnet_e58758 - phase0 processRewardsAndPenalties 54.870 ms/op 68.801 ms/op 0.80
mainnet_e58758 - phase0 processRegistryUpdates 8.3830 us/op 11.140 us/op 0.75
mainnet_e58758 - phase0 processSlashings 487.00 ns/op 652.00 ns/op 0.75
mainnet_e58758 - phase0 processEth1DataReset 478.00 ns/op 652.00 ns/op 0.73
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0380 ms/op 1.2026 ms/op 0.86
mainnet_e58758 - phase0 processSlashingsReset 4.7940 us/op 7.6120 us/op 0.63
mainnet_e58758 - phase0 processRandaoMixesReset 5.4050 us/op 5.1890 us/op 1.04
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.0400 us/op 599.00 ns/op 1.74
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.6130 us/op 4.4810 us/op 1.25
mainnet_e58758 - phase0 afterProcessEpoch 96.775 ms/op 101.59 ms/op 0.95
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2738 ms/op 1.2813 ms/op 0.99
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.8732 ms/op 1.4880 ms/op 1.26
altair processInactivityUpdates - 250000 normalcase 27.558 ms/op 26.792 ms/op 1.03
altair processInactivityUpdates - 250000 worstcase 28.947 ms/op 29.661 ms/op 0.98
phase0 processRegistryUpdates - 250000 normalcase 6.3570 us/op 11.689 us/op 0.54
phase0 processRegistryUpdates - 250000 badcase_full_deposits 277.63 us/op 286.11 us/op 0.97
phase0 processRegistryUpdates - 250000 worstcase 0.5 133.39 ms/op 142.73 ms/op 0.93
altair processRewardsAndPenalties - 250000 normalcase 71.453 ms/op 71.428 ms/op 1.00
altair processRewardsAndPenalties - 250000 worstcase 75.862 ms/op 81.181 ms/op 0.93
phase0 getAttestationDeltas - 250000 normalcase 8.4725 ms/op 8.7636 ms/op 0.97
phase0 getAttestationDeltas - 250000 worstcase 8.7118 ms/op 8.6102 ms/op 1.01
phase0 processSlashings - 250000 worstcase 3.8507 ms/op 3.8264 ms/op 1.01
altair processSyncCommitteeUpdates - 250000 189.07 ms/op 194.82 ms/op 0.97
BeaconState.hashTreeRoot - No change 295.00 ns/op 294.00 ns/op 1.00
BeaconState.hashTreeRoot - 1 full validator 54.610 us/op 56.637 us/op 0.96
BeaconState.hashTreeRoot - 32 full validator 631.78 us/op 621.98 us/op 1.02
BeaconState.hashTreeRoot - 512 full validator 5.8583 ms/op 5.8540 ms/op 1.00
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 70.059 us/op 68.699 us/op 1.02
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.0080 ms/op 949.64 us/op 1.06
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.170 ms/op 13.139 ms/op 1.00
BeaconState.hashTreeRoot - 1 balances 56.349 us/op 54.735 us/op 1.03
BeaconState.hashTreeRoot - 32 balances 494.52 us/op 469.46 us/op 1.05
BeaconState.hashTreeRoot - 512 balances 5.1826 ms/op 4.6164 ms/op 1.12
BeaconState.hashTreeRoot - 250000 balances 87.057 ms/op 74.579 ms/op 1.17
aggregationBits - 2048 els - zipIndexesInBitList 23.843 us/op 18.266 us/op 1.31
regular array get 100000 times 34.876 us/op 35.059 us/op 0.99
wrappedArray get 100000 times 45.283 us/op 39.886 us/op 1.14
arrayWithProxy get 100000 times 17.873 ms/op 15.968 ms/op 1.12
ssz.Root.equals 588.00 ns/op 601.00 ns/op 0.98
byteArrayEquals 594.00 ns/op 600.00 ns/op 0.99
shuffle list - 16384 els 7.2524 ms/op 7.1355 ms/op 1.02
shuffle list - 250000 els 103.97 ms/op 104.35 ms/op 1.00
processSlot - 1 slots 9.2900 us/op 9.3710 us/op 0.99
processSlot - 32 slots 1.4304 ms/op 1.3898 ms/op 1.03
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 36.465 ms/op 38.503 ms/op 0.95
getCommitteeAssignments - req 1 vs - 250000 vc 2.9548 ms/op 2.9863 ms/op 0.99
getCommitteeAssignments - req 100 vs - 250000 vc 4.2062 ms/op 4.3075 ms/op 0.98
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5546 ms/op 4.7006 ms/op 0.97
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.8800 ns/op 5.0700 ns/op 0.96
state getBlockRootAtSlot - 250000 vs - 7PWei 838.76 ns/op 1.1022 us/op 0.76
computeProposers - vc 250000 10.842 ms/op 11.485 ms/op 0.94
computeEpochShuffling - vc 250000 104.29 ms/op 105.82 ms/op 0.99
getNextSyncCommittee - vc 250000 173.94 ms/op 195.01 ms/op 0.89
computeSigningRoot for AttestationData 13.061 us/op 15.162 us/op 0.86
hash AttestationData serialized data then Buffer.toString(base64) 2.4088 us/op 2.5687 us/op 0.94
toHexString serialized data 1.0561 us/op 1.8395 us/op 0.57
Buffer.toString(base64) 303.75 ns/op 386.75 ns/op 0.79

by benchmarkbot/action

@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.

2 participants