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

feat: add swagger ui API explorer #5970

Merged
merged 7 commits into from
Sep 22, 2023
Merged

feat: add swagger ui API explorer #5970

merged 7 commits into from
Sep 22, 2023

Conversation

wemeetagain
Copy link
Member

Motivation

Description

  • Add a --rest.swaggerUI cli option (default to false)
  • When set, a swagger ui will be served at /documentation

Screenshot from 2023-09-19 22-31-31

@wemeetagain wemeetagain requested a review from a team as a code owner September 20, 2023 02:43
): void {
server.route({
url: route.url,
method: route.method,
handler: route.handler,
schema: route.schema,
// append the namespace as a tag for downstream consumption of our API schema, eg: for swagger UI
schema: {...route.schema, ...(namespace ? {tags: [namespace]} : undefined)},
Copy link
Member Author

Choose a reason for hiding this comment

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

This was required in order to group paths by namespace.

It would be nice to be able to reuse more of the beacon API schema but 🤷 that seems like a larger refactor.

Copy link
Member

Choose a reason for hiding this comment

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

Enriched schema would definitely be nice to have, especially for POST requests. I think we would have to pull a pinned version of the beacon-API schema from github and then override each route based on operationId. This will become especially important if we want to generate a API docs page with redoc (or similar tooling).

packages/beacon-node/src/api/rest/swaggerUI.ts Outdated Show resolved Hide resolved
opts: BeaconRestApiServerOpts,
version = ""
): Promise<void> {
await server.register(await import("@fastify/swagger"), {
Copy link
Member Author

Choose a reason for hiding this comment

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

tags: opts.api.map((namespace) => ({name: namespace})),
},
});
await server.register(await import("@fastify/swagger-ui"), {
Copy link
Member Author

Choose a reason for hiding this comment

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

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: ba92e6f Previous: e17fe6b Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 621.51 us/op 859.41 us/op 0.72
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 80.123 us/op 94.194 us/op 0.85
BLS verify - blst-native 1.3491 ms/op 1.3538 ms/op 1.00
BLS verifyMultipleSignatures 3 - blst-native 2.8128 ms/op 2.8190 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 6.1453 ms/op 6.1800 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 22.418 ms/op 22.704 ms/op 0.99
BLS verifyMultipleSignatures 64 - blst-native 44.190 ms/op 44.508 ms/op 0.99
BLS verifyMultipleSignatures 128 - blst-native 88.527 ms/op 87.825 ms/op 1.01
BLS deserializing 10000 signatures 912.47 ms/op 899.24 ms/op 1.01
BLS deserializing 100000 signatures 9.3267 s/op 9.0956 s/op 1.03
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3923 ms/op 1.3965 ms/op 1.00
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.6002 ms/op 1.5365 ms/op 1.04
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.4550 ms/op 2.6178 ms/op 0.94
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5892 ms/op 3.4863 ms/op 1.03
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.7420 ms/op 6.4295 ms/op 0.89
BLS aggregatePubkeys 32 - blst-native 26.818 us/op 28.871 us/op 0.93
BLS aggregatePubkeys 128 - blst-native 102.37 us/op 105.00 us/op 0.97
getAttestationsForBlock 45.646 ms/op 48.917 ms/op 0.93
isKnown best case - 1 super set check 353.00 ns/op 475.00 ns/op 0.74
isKnown normal case - 2 super set checks 317.00 ns/op 447.00 ns/op 0.71
isKnown worse case - 16 super set checks 300.00 ns/op 446.00 ns/op 0.67
CheckpointStateCache - add get delete 6.3750 us/op 6.3710 us/op 1.00
validate api signedAggregateAndProof - struct 2.8801 ms/op 2.8824 ms/op 1.00
validate gossip signedAggregateAndProof - struct 2.9090 ms/op 2.8931 ms/op 1.01
validate gossip attestation - vc 640000 1.3916 ms/op 1.4010 ms/op 0.99
batch validate gossip attestation - vc 640000 - chunk 32 170.18 us/op 171.71 us/op 0.99
batch validate gossip attestation - vc 640000 - chunk 64 146.32 us/op 157.63 us/op 0.93
batch validate gossip attestation - vc 640000 - chunk 128 139.72 us/op 148.22 us/op 0.94
batch validate gossip attestation - vc 640000 - chunk 256 137.51 us/op 131.22 us/op 1.05
pickEth1Vote - no votes 1.2820 ms/op 1.2555 ms/op 1.02
pickEth1Vote - max votes 10.523 ms/op 11.814 ms/op 0.89
pickEth1Vote - Eth1Data hashTreeRoot value x2048 18.272 ms/op 15.798 ms/op 1.16
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 23.257 ms/op 20.952 ms/op 1.11
pickEth1Vote - Eth1Data fastSerialize value x2048 643.04 us/op 601.14 us/op 1.07
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.6224 ms/op 4.3059 ms/op 1.77
bytes32 toHexString 493.00 ns/op 517.00 ns/op 0.95
bytes32 Buffer.toString(hex) 307.00 ns/op 298.00 ns/op 1.03
bytes32 Buffer.toString(hex) from Uint8Array 465.00 ns/op 464.00 ns/op 1.00
bytes32 Buffer.toString(hex) + 0x 318.00 ns/op 310.00 ns/op 1.03
Object access 1 prop 0.17900 ns/op 0.17800 ns/op 1.01
Map access 1 prop 0.15800 ns/op 0.14700 ns/op 1.07
Object get x1000 8.0580 ns/op 7.9700 ns/op 1.01
Map get x1000 0.66200 ns/op 0.63500 ns/op 1.04
Object set x1000 55.784 ns/op 62.619 ns/op 0.89
Map set x1000 41.189 ns/op 46.345 ns/op 0.89
Return object 10000 times 0.24540 ns/op 0.24520 ns/op 1.00
Throw Error 10000 times 3.9474 us/op 3.8871 us/op 1.02
fastMsgIdFn sha256 / 200 bytes 3.4380 us/op 3.3910 us/op 1.01
fastMsgIdFn h32 xxhash / 200 bytes 299.00 ns/op 291.00 ns/op 1.03
fastMsgIdFn h64 xxhash / 200 bytes 352.00 ns/op 375.00 ns/op 0.94
fastMsgIdFn sha256 / 1000 bytes 11.701 us/op 11.826 us/op 0.99
fastMsgIdFn h32 xxhash / 1000 bytes 430.00 ns/op 438.00 ns/op 0.98
fastMsgIdFn h64 xxhash / 1000 bytes 419.00 ns/op 502.00 ns/op 0.83
fastMsgIdFn sha256 / 10000 bytes 109.83 us/op 106.16 us/op 1.03
fastMsgIdFn h32 xxhash / 10000 bytes 2.0150 us/op 2.0330 us/op 0.99
fastMsgIdFn h64 xxhash / 10000 bytes 1.4030 us/op 1.3820 us/op 1.02
send data - 1000 256B messages 21.138 ms/op 20.314 ms/op 1.04
send data - 1000 512B messages 28.493 ms/op 26.930 ms/op 1.06
send data - 1000 1024B messages 43.503 ms/op 40.492 ms/op 1.07
send data - 1000 1200B messages 23.000 ms/op 23.541 ms/op 0.98
send data - 1000 2048B messages 30.720 ms/op 30.806 ms/op 1.00
send data - 1000 4096B messages 37.477 ms/op 35.758 ms/op 1.05
send data - 1000 16384B messages 77.787 ms/op 79.956 ms/op 0.97
send data - 1000 65536B messages 286.80 ms/op 269.35 ms/op 1.06
enrSubnets - fastDeserialize 64 bits 1.4120 us/op 1.2230 us/op 1.15
enrSubnets - ssz BitVector 64 bits 464.00 ns/op 426.00 ns/op 1.09
enrSubnets - fastDeserialize 4 bits 177.00 ns/op 176.00 ns/op 1.01
enrSubnets - ssz BitVector 4 bits 453.00 ns/op 418.00 ns/op 1.08
prioritizePeers score -10:0 att 32-0.1 sync 2-0 105.46 us/op 100.96 us/op 1.04
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 136.82 us/op 125.84 us/op 1.09
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 191.05 us/op 157.22 us/op 1.22
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 302.25 us/op 283.45 us/op 1.07
prioritizePeers score 0:0 att 64-1 sync 4-1 351.60 us/op 340.05 us/op 1.03
array of 16000 items push then shift 1.6863 us/op 1.6028 us/op 1.05
LinkedList of 16000 items push then shift 9.4850 ns/op 8.8910 ns/op 1.07
array of 16000 items push then pop 92.847 ns/op 83.206 ns/op 1.12
LinkedList of 16000 items push then pop 8.9820 ns/op 8.6710 ns/op 1.04
array of 24000 items push then shift 2.5224 us/op 2.3742 us/op 1.06
LinkedList of 24000 items push then shift 9.4210 ns/op 8.8560 ns/op 1.06
array of 24000 items push then pop 134.99 ns/op 98.340 ns/op 1.37
LinkedList of 24000 items push then pop 9.3220 ns/op 8.6790 ns/op 1.07
intersect bitArray bitLen 8 7.1390 ns/op 6.9320 ns/op 1.03
intersect array and set length 8 69.593 ns/op 53.322 ns/op 1.31
intersect bitArray bitLen 128 33.626 ns/op 31.985 ns/op 1.05
intersect array and set length 128 901.40 ns/op 812.97 ns/op 1.11
bitArray.getTrueBitIndexes() bitLen 128 1.7290 us/op 1.4090 us/op 1.23
bitArray.getTrueBitIndexes() bitLen 248 2.7960 us/op 2.3230 us/op 1.20
bitArray.getTrueBitIndexes() bitLen 512 5.3300 us/op 4.5500 us/op 1.17
Buffer.concat 32 items 990.00 ns/op 889.00 ns/op 1.11
Uint8Array.set 32 items 1.9370 us/op 1.6890 us/op 1.15
Set add up to 64 items then delete first 4.9999 us/op 4.2444 us/op 1.18
OrderedSet add up to 64 items then delete first 5.7022 us/op 5.2977 us/op 1.08
Set add up to 64 items then delete last 5.1728 us/op 4.4683 us/op 1.16
OrderedSet add up to 64 items then delete last 6.6988 us/op 5.8128 us/op 1.15
Set add up to 64 items then delete middle 5.0921 us/op 4.6659 us/op 1.09
OrderedSet add up to 64 items then delete middle 7.8418 us/op 7.4345 us/op 1.05
Set add up to 128 items then delete first 10.362 us/op 9.0266 us/op 1.15
OrderedSet add up to 128 items then delete first 13.611 us/op 11.954 us/op 1.14
Set add up to 128 items then delete last 10.378 us/op 9.3241 us/op 1.11
OrderedSet add up to 128 items then delete last 13.435 us/op 11.914 us/op 1.13
Set add up to 128 items then delete middle 10.295 us/op 9.3995 us/op 1.10
OrderedSet add up to 128 items then delete middle 18.891 us/op 16.912 us/op 1.12
Set add up to 256 items then delete first 20.930 us/op 18.467 us/op 1.13
OrderedSet add up to 256 items then delete first 28.804 us/op 24.965 us/op 1.15
Set add up to 256 items then delete last 20.324 us/op 18.632 us/op 1.09
OrderedSet add up to 256 items then delete last 26.838 us/op 25.332 us/op 1.06
Set add up to 256 items then delete middle 19.508 us/op 19.430 us/op 1.00
OrderedSet add up to 256 items then delete middle 48.585 us/op 49.014 us/op 0.99
transfer serialized Status (84 B) 1.9820 us/op 2.0080 us/op 0.99
copy serialized Status (84 B) 1.7380 us/op 1.7110 us/op 1.02
transfer serialized SignedVoluntaryExit (112 B) 2.2250 us/op 2.2670 us/op 0.98
copy serialized SignedVoluntaryExit (112 B) 1.7960 us/op 1.8000 us/op 1.00
transfer serialized ProposerSlashing (416 B) 2.7670 us/op 3.1520 us/op 0.88
copy serialized ProposerSlashing (416 B) 2.7960 us/op 3.0140 us/op 0.93
transfer serialized Attestation (485 B) 2.7850 us/op 3.1550 us/op 0.88
copy serialized Attestation (485 B) 2.8700 us/op 2.9750 us/op 0.96
transfer serialized AttesterSlashing (33232 B) 2.8380 us/op 3.0380 us/op 0.93
copy serialized AttesterSlashing (33232 B) 7.1750 us/op 5.9420 us/op 1.21
transfer serialized Small SignedBeaconBlock (128000 B) 3.3060 us/op 2.8770 us/op 1.15
copy serialized Small SignedBeaconBlock (128000 B) 23.857 us/op 13.262 us/op 1.80
transfer serialized Avg SignedBeaconBlock (200000 B) 3.3280 us/op 4.5710 us/op 0.73
copy serialized Avg SignedBeaconBlock (200000 B) 34.669 us/op 51.328 us/op 0.68
transfer serialized BlobsSidecar (524380 B) 3.3120 us/op 6.0170 us/op 0.55
copy serialized BlobsSidecar (524380 B) 111.28 us/op 150.72 us/op 0.74
transfer serialized Big SignedBeaconBlock (1000000 B) 3.5650 us/op 7.7400 us/op 0.46
copy serialized Big SignedBeaconBlock (1000000 B) 210.92 us/op 259.72 us/op 0.81
pass gossip attestations to forkchoice per slot 4.0117 ms/op 6.9729 ms/op 0.58
forkChoice updateHead vc 100000 bc 64 eq 0 711.60 us/op 924.28 us/op 0.77
forkChoice updateHead vc 600000 bc 64 eq 0 4.4012 ms/op 9.4770 ms/op 0.46
forkChoice updateHead vc 1000000 bc 64 eq 0 7.9339 ms/op 10.391 ms/op 0.76
forkChoice updateHead vc 600000 bc 320 eq 0 4.5184 ms/op 5.5318 ms/op 0.82
forkChoice updateHead vc 600000 bc 1200 eq 0 4.6791 ms/op 4.8268 ms/op 0.97
forkChoice updateHead vc 600000 bc 7200 eq 0 5.6120 ms/op 5.6666 ms/op 0.99
forkChoice updateHead vc 600000 bc 64 eq 1000 12.284 ms/op 11.715 ms/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 10000 13.126 ms/op 12.060 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 300000 18.483 ms/op 16.085 ms/op 1.15
computeDeltas 500000 validators 300 proto nodes 6.6995 ms/op 6.3783 ms/op 1.05
computeDeltas 500000 validators 1200 proto nodes 6.6349 ms/op 6.2360 ms/op 1.06
computeDeltas 500000 validators 7200 proto nodes 6.5279 ms/op 6.2359 ms/op 1.05
computeDeltas 750000 validators 300 proto nodes 9.9348 ms/op 9.2564 ms/op 1.07
computeDeltas 750000 validators 1200 proto nodes 9.8316 ms/op 9.2076 ms/op 1.07
computeDeltas 750000 validators 7200 proto nodes 9.6872 ms/op 9.2244 ms/op 1.05
computeDeltas 1400000 validators 300 proto nodes 18.301 ms/op 17.444 ms/op 1.05
computeDeltas 1400000 validators 1200 proto nodes 18.228 ms/op 17.744 ms/op 1.03
computeDeltas 1400000 validators 7200 proto nodes 18.038 ms/op 18.466 ms/op 0.98
computeDeltas 2100000 validators 300 proto nodes 27.765 ms/op 26.712 ms/op 1.04
computeDeltas 2100000 validators 1200 proto nodes 29.501 ms/op 26.298 ms/op 1.12
computeDeltas 2100000 validators 7200 proto nodes 27.938 ms/op 26.613 ms/op 1.05
computeProposerBoostScoreFromBalances 500000 validators 3.4163 ms/op 3.3151 ms/op 1.03
computeProposerBoostScoreFromBalances 750000 validators 3.4571 ms/op 3.4995 ms/op 0.99
computeProposerBoostScoreFromBalances 1400000 validators 3.5744 ms/op 3.5207 ms/op 1.02
computeProposerBoostScoreFromBalances 2100000 validators 3.5436 ms/op 3.6749 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 2.3900 ms/op 5.1323 ms/op 0.47
altair processAttestation - 250000 vs - 7PWei worstcase 3.5101 ms/op 4.8568 ms/op 0.72
altair processAttestation - setStatus - 1/6 committees join 174.15 us/op 224.46 us/op 0.78
altair processAttestation - setStatus - 1/3 committees join 348.56 us/op 354.91 us/op 0.98
altair processAttestation - setStatus - 1/2 committees join 460.20 us/op 500.96 us/op 0.92
altair processAttestation - setStatus - 2/3 committees join 594.94 us/op 593.02 us/op 1.00
altair processAttestation - setStatus - 4/5 committees join 793.74 us/op 820.13 us/op 0.97
altair processAttestation - setStatus - 100% committees join 917.38 us/op 985.00 us/op 0.93
altair processBlock - 250000 vs - 7PWei normalcase 7.3298 ms/op 8.0491 ms/op 0.91
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.842 ms/op 31.236 ms/op 0.96
altair processBlock - 250000 vs - 7PWei worstcase 37.999 ms/op 40.554 ms/op 0.94
altair processBlock - 250000 vs - 7PWei worstcase hashState 90.520 ms/op 91.066 ms/op 0.99
phase0 processBlock - 250000 vs - 7PWei normalcase 2.8311 ms/op 2.8489 ms/op 0.99
phase0 processBlock - 250000 vs - 7PWei worstcase 32.053 ms/op 34.918 ms/op 0.92
altair processEth1Data - 250000 vs - 7PWei normalcase 499.60 us/op 679.11 us/op 0.74
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 15.245 us/op 12.436 us/op 1.23
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 62.291 us/op 91.317 us/op 0.68
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 14.048 us/op 30.781 us/op 0.46
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 14.993 us/op 22.033 us/op 0.68
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 230.20 us/op 195.74 us/op 1.18
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.5876 ms/op 1.6501 ms/op 0.96
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.2151 ms/op 1.9406 ms/op 1.14
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.8672 ms/op 1.9850 ms/op 0.94
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.9272 ms/op 4.2599 ms/op 0.92
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.6556 ms/op 3.2373 ms/op 0.82
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.8849 ms/op 7.4333 ms/op 0.79
Tree 40 250000 create 370.70 ms/op 524.19 ms/op 0.71
Tree 40 250000 get(125000) 212.44 ns/op 213.76 ns/op 0.99
Tree 40 250000 set(125000) 1.0519 us/op 1.1646 us/op 0.90
Tree 40 250000 toArray() 22.797 ms/op 22.060 ms/op 1.03
Tree 40 250000 iterate all - toArray() + loop 22.458 ms/op 22.285 ms/op 1.01
Tree 40 250000 iterate all - get(i) 76.107 ms/op 81.728 ms/op 0.93
MutableVector 250000 create 14.228 ms/op 14.216 ms/op 1.00
MutableVector 250000 get(125000) 6.7460 ns/op 6.8580 ns/op 0.98
MutableVector 250000 set(125000) 260.72 ns/op 460.28 ns/op 0.57
MutableVector 250000 toArray() 3.4999 ms/op 4.0850 ms/op 0.86
MutableVector 250000 iterate all - toArray() + loop 3.6045 ms/op 4.3253 ms/op 0.83
MutableVector 250000 iterate all - get(i) 1.5865 ms/op 1.7741 ms/op 0.89
Array 250000 create 3.0098 ms/op 3.7664 ms/op 0.80
Array 250000 clone - spread 1.0825 ms/op 1.2769 ms/op 0.85
Array 250000 get(125000) 0.54300 ns/op 0.61900 ns/op 0.88
Array 250000 set(125000) 0.61800 ns/op 0.70000 ns/op 0.88
Array 250000 iterate all - loop 86.603 us/op 87.425 us/op 0.99
effectiveBalanceIncrements clone Uint8Array 300000 29.828 us/op 44.757 us/op 0.67
effectiveBalanceIncrements clone MutableVector 300000 314.00 ns/op 268.00 ns/op 1.17
effectiveBalanceIncrements rw all Uint8Array 300000 186.62 us/op 206.09 us/op 0.91
effectiveBalanceIncrements rw all MutableVector 300000 85.842 ms/op 130.02 ms/op 0.66
phase0 afterProcessEpoch - 250000 vs - 7PWei 119.25 ms/op 125.50 ms/op 0.95
phase0 beforeProcessEpoch - 250000 vs - 7PWei 43.203 ms/op 40.388 ms/op 1.07
altair processEpoch - mainnet_e81889 490.16 ms/op 479.41 ms/op 1.02
mainnet_e81889 - altair beforeProcessEpoch 63.531 ms/op 55.079 ms/op 1.15
mainnet_e81889 - altair processJustificationAndFinalization 15.135 us/op 18.445 us/op 0.82
mainnet_e81889 - altair processInactivityUpdates 9.3331 ms/op 8.7394 ms/op 1.07
mainnet_e81889 - altair processRewardsAndPenalties 60.305 ms/op 67.186 ms/op 0.90
mainnet_e81889 - altair processRegistryUpdates 3.7620 us/op 3.4240 us/op 1.10
mainnet_e81889 - altair processSlashings 493.00 ns/op 885.00 ns/op 0.56
mainnet_e81889 - altair processEth1DataReset 647.00 ns/op 1.4030 us/op 0.46
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.6053 ms/op 2.2092 ms/op 0.73
mainnet_e81889 - altair processSlashingsReset 5.7110 us/op 7.2370 us/op 0.79
mainnet_e81889 - altair processRandaoMixesReset 6.0130 us/op 11.982 us/op 0.50
mainnet_e81889 - altair processHistoricalRootsUpdate 781.00 ns/op 894.00 ns/op 0.87
mainnet_e81889 - altair processParticipationFlagUpdates 3.2600 us/op 4.0600 us/op 0.80
mainnet_e81889 - altair processSyncCommitteeUpdates 834.00 ns/op 1.6920 us/op 0.49
mainnet_e81889 - altair afterProcessEpoch 131.55 ms/op 139.11 ms/op 0.95
capella processEpoch - mainnet_e217614 1.5622 s/op 1.6684 s/op 0.94
mainnet_e217614 - capella beforeProcessEpoch 254.44 ms/op 266.32 ms/op 0.96
mainnet_e217614 - capella processJustificationAndFinalization 15.245 us/op 19.497 us/op 0.78
mainnet_e217614 - capella processInactivityUpdates 18.943 ms/op 21.489 ms/op 0.88
mainnet_e217614 - capella processRewardsAndPenalties 292.17 ms/op 263.20 ms/op 1.11
mainnet_e217614 - capella processRegistryUpdates 17.913 us/op 38.908 us/op 0.46
mainnet_e217614 - capella processSlashings 602.00 ns/op 728.00 ns/op 0.83
mainnet_e217614 - capella processEth1DataReset 521.00 ns/op 655.00 ns/op 0.80
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.2966 ms/op 4.2358 ms/op 1.01
mainnet_e217614 - capella processSlashingsReset 2.5510 us/op 5.1300 us/op 0.50
mainnet_e217614 - capella processRandaoMixesReset 5.1430 us/op 4.8870 us/op 1.05
mainnet_e217614 - capella processHistoricalRootsUpdate 817.00 ns/op 671.00 ns/op 1.22
mainnet_e217614 - capella processParticipationFlagUpdates 1.9310 us/op 1.7310 us/op 1.12
mainnet_e217614 - capella afterProcessEpoch 312.52 ms/op 309.64 ms/op 1.01
phase0 processEpoch - mainnet_e58758 500.01 ms/op 507.25 ms/op 0.99
mainnet_e58758 - phase0 beforeProcessEpoch 139.22 ms/op 123.74 ms/op 1.13
mainnet_e58758 - phase0 processJustificationAndFinalization 18.572 us/op 19.328 us/op 0.96
mainnet_e58758 - phase0 processRewardsAndPenalties 45.482 ms/op 50.461 ms/op 0.90
mainnet_e58758 - phase0 processRegistryUpdates 9.8730 us/op 15.337 us/op 0.64
mainnet_e58758 - phase0 processSlashings 534.00 ns/op 675.00 ns/op 0.79
mainnet_e58758 - phase0 processEth1DataReset 487.00 ns/op 501.00 ns/op 0.97
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.2627 ms/op 1.1554 ms/op 1.09
mainnet_e58758 - phase0 processSlashingsReset 2.7270 us/op 3.4690 us/op 0.79
mainnet_e58758 - phase0 processRandaoMixesReset 4.6610 us/op 5.8430 us/op 0.80
mainnet_e58758 - phase0 processHistoricalRootsUpdate 933.00 ns/op 557.00 ns/op 1.68
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.7100 us/op 6.3290 us/op 0.74
mainnet_e58758 - phase0 afterProcessEpoch 106.46 ms/op 109.69 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.3430 ms/op 1.3606 ms/op 1.72
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.8450 ms/op 2.0833 ms/op 0.89
altair processInactivityUpdates - 250000 normalcase 23.109 ms/op 18.538 ms/op 1.25
altair processInactivityUpdates - 250000 worstcase 21.482 ms/op 20.031 ms/op 1.07
phase0 processRegistryUpdates - 250000 normalcase 12.289 us/op 9.2110 us/op 1.33
phase0 processRegistryUpdates - 250000 badcase_full_deposits 476.64 us/op 337.65 us/op 1.41
phase0 processRegistryUpdates - 250000 worstcase 0.5 150.34 ms/op 136.80 ms/op 1.10
altair processRewardsAndPenalties - 250000 normalcase 52.202 ms/op 45.953 ms/op 1.14
altair processRewardsAndPenalties - 250000 worstcase 61.948 ms/op 42.595 ms/op 1.45
phase0 getAttestationDeltas - 250000 normalcase 9.9113 ms/op 7.9445 ms/op 1.25
phase0 getAttestationDeltas - 250000 worstcase 9.4560 ms/op 8.0417 ms/op 1.18
phase0 processSlashings - 250000 worstcase 2.5658 ms/op 2.3303 ms/op 1.10
altair processSyncCommitteeUpdates - 250000 167.00 ms/op 151.50 ms/op 1.10
BeaconState.hashTreeRoot - No change 374.00 ns/op 346.00 ns/op 1.08
BeaconState.hashTreeRoot - 1 full validator 146.21 us/op 146.31 us/op 1.00
BeaconState.hashTreeRoot - 32 full validator 1.8194 ms/op 1.7401 ms/op 1.05
BeaconState.hashTreeRoot - 512 full validator 19.411 ms/op 18.304 ms/op 1.06
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 178.49 us/op 172.42 us/op 1.04
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 3.1979 ms/op 2.7210 ms/op 1.18
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 40.212 ms/op 33.197 ms/op 1.21
BeaconState.hashTreeRoot - 1 balances 202.73 us/op 162.73 us/op 1.25
BeaconState.hashTreeRoot - 32 balances 2.1120 ms/op 1.2036 ms/op 1.75
BeaconState.hashTreeRoot - 512 balances 16.499 ms/op 11.812 ms/op 1.40
BeaconState.hashTreeRoot - 250000 balances 262.72 ms/op 175.97 ms/op 1.49
aggregationBits - 2048 els - zipIndexesInBitList 28.267 us/op 15.868 us/op 1.78
regular array get 100000 times 50.544 us/op 44.526 us/op 1.14
wrappedArray get 100000 times 49.661 us/op 43.551 us/op 1.14
arrayWithProxy get 100000 times 19.750 ms/op 14.665 ms/op 1.35
ssz.Root.equals 319.00 ns/op 237.00 ns/op 1.35
byteArrayEquals 342.00 ns/op 222.00 ns/op 1.54
shuffle list - 16384 els 8.3823 ms/op 6.9685 ms/op 1.20
shuffle list - 250000 els 123.40 ms/op 102.65 ms/op 1.20
processSlot - 1 slots 28.932 us/op 16.284 us/op 1.78
processSlot - 32 slots 5.3697 ms/op 3.3296 ms/op 1.61
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 67.972 ms/op 51.040 ms/op 1.33
getCommitteeAssignments - req 1 vs - 250000 vc 3.2010 ms/op 2.5044 ms/op 1.28
getCommitteeAssignments - req 100 vs - 250000 vc 4.5019 ms/op 3.7013 ms/op 1.22
getCommitteeAssignments - req 1000 vs - 250000 vc 5.0036 ms/op 4.0248 ms/op 1.24
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.6700 ns/op 4.7300 ns/op 1.41
state getBlockRootAtSlot - 250000 vs - 7PWei 967.96 ns/op 738.90 ns/op 1.31
computeProposers - vc 250000 11.016 ms/op 8.9686 ms/op 1.23
computeEpochShuffling - vc 250000 117.68 ms/op 106.51 ms/op 1.10
getNextSyncCommittee - vc 250000 207.73 ms/op 151.83 ms/op 1.37
computeSigningRoot for AttestationData 34.091 us/op 22.546 us/op 1.51
hash AttestationData serialized data then Buffer.toString(base64) 2.6227 us/op 2.3550 us/op 1.11
toHexString serialized data 1.7349 us/op 1.1611 us/op 1.49
Buffer.toString(base64) 307.50 ns/op 218.35 ns/op 1.41

by benchmarkbot/action

Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

This is pretty cool! Left a few suggestions

): void {
server.route({
url: route.url,
method: route.method,
handler: route.handler,
schema: route.schema,
// append the namespace as a tag for downstream consumption of our API schema, eg: for swagger UI
schema: {...route.schema, ...(namespace ? {tags: [namespace]} : undefined)},
Copy link
Member

Choose a reason for hiding this comment

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

Enriched schema would definitely be nice to have, especially for POST requests. I think we would have to pull a pinned version of the beacon-API schema from github and then override each route based on operationId. This will become especially important if we want to generate a API docs page with redoc (or similar tooling).

packages/api/src/utils/server/registerRoute.ts Outdated Show resolved Hide resolved
@@ -89,4 +91,12 @@ export const options: CliCommandOptions<ApiArgs> = {
type: "number",
description: "Defines the maximum payload, in bytes, the server is allowed to accept",
},

"rest.swaggerUI": {
Copy link
Member

Choose a reason for hiding this comment

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

should we also support this for the validator keymanager API?

"keymanager.bodyLimit"?: number;

For keymanager would also be nice to support bearer auth through the explorer but again might not be worth the effort.

packages/cli/src/options/beaconNodeOptions/api.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/api/rest/swaggerUI.ts Outdated Show resolved Hide resolved
packages/cli/src/options/beaconNodeOptions/api.ts Outdated Show resolved Hide resolved
"Enable Swagger UI for API exploration at http://{address}:{port}/documentation. This should not be used in production.",
default: Boolean(defaultOptions.api.rest.swaggerUI),
group: "api",
},
Copy link
Member

Choose a reason for hiding this comment

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

Potential other config options

  • path
  • server url (would be required if node runs behind proxy)

Depending on what use cases we see for this, might not be worth to add those now.

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
const url = await import("node:url");
// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
return await fs.readFile(path.join(__dirname, "../../../../../assets/", name));
Copy link
Member

@nflaig nflaig Sep 22, 2023

Choose a reason for hiding this comment

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

Just noticed we don't copy assets in our docker build

assets

I think we can just include them, size impact is relatively low

1.2M    assets
288.1M  node_modules

@wemeetagain wemeetagain merged commit 9618dd1 into unstable Sep 22, 2023
14 of 15 checks passed
@wemeetagain wemeetagain deleted the cayman/swagger-ui branch September 22, 2023 19:55
@wemeetagain
Copy link
Member Author

🎉 This PR is included in v1.12.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