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

refactor!: move getNetworkIdentity to network class #5453

Merged
merged 2 commits into from
May 2, 2023

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented May 2, 2023

Motivation

Description

Move getNetworkIdentity logic into network class to reduce interface surface

@dapplion dapplion requested a review from a team as a code owner May 2, 2023 03:37
@dapplion dapplion changed the title Move getNetworkIdentity to network class refactor!: move getNetworkIdentity to network class May 2, 2023
wemeetagain
wemeetagain previously approved these changes May 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 010f87d Previous: 22b6f6b Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 589.74 us/op 854.45 us/op 0.69
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 53.020 us/op 52.965 us/op 1.00
BLS verify - blst-native 1.2472 ms/op 1.2645 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.5565 ms/op 2.5271 ms/op 1.01
BLS verifyMultipleSignatures 8 - blst-native 5.4909 ms/op 5.4664 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 20.021 ms/op 19.559 ms/op 1.02
BLS aggregatePubkeys 32 - blst-native 27.147 us/op 26.335 us/op 1.03
BLS aggregatePubkeys 128 - blst-native 104.72 us/op 103.17 us/op 1.02
getAttestationsForBlock 60.443 ms/op 58.868 ms/op 1.03
isKnown best case - 1 super set check 270.00 ns/op 250.00 ns/op 1.08
isKnown normal case - 2 super set checks 266.00 ns/op 244.00 ns/op 1.09
isKnown worse case - 16 super set checks 267.00 ns/op 244.00 ns/op 1.09
CheckpointStateCache - add get delete 5.3130 us/op 5.6230 us/op 0.94
validate gossip signedAggregateAndProof - struct 2.7898 ms/op 2.7796 ms/op 1.00
validate gossip attestation - struct 1.3242 ms/op 1.3341 ms/op 0.99
pickEth1Vote - no votes 1.3343 ms/op 1.4144 ms/op 0.94
pickEth1Vote - max votes 9.8933 ms/op 11.081 ms/op 0.89
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.0839 ms/op 9.4597 ms/op 0.96
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.748 ms/op 17.538 ms/op 0.95
pickEth1Vote - Eth1Data fastSerialize value x2048 755.64 us/op 796.33 us/op 0.95
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.9501 ms/op 6.1806 ms/op 0.96
bytes32 toHexString 531.00 ns/op 757.00 ns/op 0.70
bytes32 Buffer.toString(hex) 381.00 ns/op 446.00 ns/op 0.85
bytes32 Buffer.toString(hex) from Uint8Array 609.00 ns/op 694.00 ns/op 0.88
bytes32 Buffer.toString(hex) + 0x 387.00 ns/op 454.00 ns/op 0.85
Object access 1 prop 0.16800 ns/op 0.19500 ns/op 0.86
Map access 1 prop 0.16500 ns/op 0.16300 ns/op 1.01
Object get x1000 6.5030 ns/op 7.1570 ns/op 0.91
Map get x1000 0.55900 ns/op 0.66600 ns/op 0.84
Object set x1000 57.559 ns/op 76.767 ns/op 0.75
Map set x1000 44.403 ns/op 58.436 ns/op 0.76
Return object 10000 times 0.23730 ns/op 0.25070 ns/op 0.95
Throw Error 10000 times 4.3256 us/op 4.4399 us/op 0.97
fastMsgIdFn sha256 / 200 bytes 3.5350 us/op 3.6050 us/op 0.98
fastMsgIdFn h32 xxhash / 200 bytes 305.00 ns/op 326.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 200 bytes 446.00 ns/op 490.00 ns/op 0.91
fastMsgIdFn sha256 / 1000 bytes 11.964 us/op 12.019 us/op 1.00
fastMsgIdFn h32 xxhash / 1000 bytes 470.00 ns/op 442.00 ns/op 1.06
fastMsgIdFn h64 xxhash / 1000 bytes 573.00 ns/op 543.00 ns/op 1.06
fastMsgIdFn sha256 / 10000 bytes 104.72 us/op 106.13 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 2.0150 us/op 2.0130 us/op 1.00
fastMsgIdFn h64 xxhash / 10000 bytes 1.4440 us/op 1.4660 us/op 0.98
enrSubnets - fastDeserialize 64 bits 1.7420 us/op 1.5880 us/op 1.10
enrSubnets - ssz BitVector 64 bits 623.00 ns/op 616.00 ns/op 1.01
enrSubnets - fastDeserialize 4 bits 215.00 ns/op 186.00 ns/op 1.16
enrSubnets - ssz BitVector 4 bits 627.00 ns/op 554.00 ns/op 1.13
prioritizePeers score -10:0 att 32-0.1 sync 2-0 122.63 us/op 122.06 us/op 1.00
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 143.84 us/op 164.73 us/op 0.87
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 186.65 us/op 223.85 us/op 0.83
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 360.58 us/op 357.18 us/op 1.01
prioritizePeers score 0:0 att 64-1 sync 4-1 421.44 us/op 432.23 us/op 0.98
array of 16000 items push then shift 1.6713 us/op 1.6787 us/op 1.00
LinkedList of 16000 items push then shift 8.9580 ns/op 9.4060 ns/op 0.95
array of 16000 items push then pop 118.37 ns/op 112.67 ns/op 1.05
LinkedList of 16000 items push then pop 9.3790 ns/op 9.2890 ns/op 1.01
array of 24000 items push then shift 2.4698 us/op 2.4247 us/op 1.02
LinkedList of 24000 items push then shift 9.3680 ns/op 9.3360 ns/op 1.00
array of 24000 items push then pop 88.821 ns/op 93.997 ns/op 0.94
LinkedList of 24000 items push then pop 9.0930 ns/op 9.6070 ns/op 0.95
intersect bitArray bitLen 8 14.379 ns/op 13.643 ns/op 1.05
intersect array and set length 8 98.206 ns/op 89.972 ns/op 1.09
intersect bitArray bitLen 128 46.736 ns/op 45.375 ns/op 1.03
intersect array and set length 128 1.3320 us/op 1.2095 us/op 1.10
Buffer.concat 32 items 3.2500 us/op 2.7920 us/op 1.16
Uint8Array.set 32 items 2.9410 us/op 3.2290 us/op 0.91
pass gossip attestations to forkchoice per slot 2.8629 ms/op 4.3292 ms/op 0.66
computeDeltas 2.9807 ms/op 3.4600 ms/op 0.86
computeProposerBoostScoreFromBalances 1.8185 ms/op 1.8544 ms/op 0.98
altair processAttestation - 250000 vs - 7PWei normalcase 2.4911 ms/op 3.6537 ms/op 0.68
altair processAttestation - 250000 vs - 7PWei worstcase 3.4634 ms/op 4.8472 ms/op 0.71
altair processAttestation - setStatus - 1/6 committees join 142.17 us/op 149.99 us/op 0.95
altair processAttestation - setStatus - 1/3 committees join 278.92 us/op 291.33 us/op 0.96
altair processAttestation - setStatus - 1/2 committees join 373.25 us/op 378.31 us/op 0.99
altair processAttestation - setStatus - 2/3 committees join 469.76 us/op 473.33 us/op 0.99
altair processAttestation - setStatus - 4/5 committees join 641.23 us/op 664.41 us/op 0.97
altair processAttestation - setStatus - 100% committees join 736.42 us/op 796.16 us/op 0.92
altair processBlock - 250000 vs - 7PWei normalcase 16.317 ms/op 18.219 ms/op 0.90
altair processBlock - 250000 vs - 7PWei normalcase hashState 24.890 ms/op 30.515 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 52.485 ms/op 54.073 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase hashState 70.460 ms/op 82.015 ms/op 0.86
phase0 processBlock - 250000 vs - 7PWei normalcase 2.1758 ms/op 2.4686 ms/op 0.88
phase0 processBlock - 250000 vs - 7PWei worstcase 28.566 ms/op 32.434 ms/op 0.88
altair processEth1Data - 250000 vs - 7PWei normalcase 512.95 us/op 635.49 us/op 0.81
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 7.1150 us/op 12.362 us/op 0.58
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 20.047 us/op 34.271 us/op 0.58
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 8.9570 us/op 13.459 us/op 0.67
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.8380 us/op 10.506 us/op 0.65
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 80.996 us/op 113.88 us/op 0.71
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 645.34 us/op 681.38 us/op 0.95
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 889.72 us/op 926.53 us/op 0.96
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 882.78 us/op 924.30 us/op 0.96
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.3524 ms/op 3.0635 ms/op 0.77
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.5488 ms/op 1.6721 ms/op 0.93
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 4.2400 ms/op 5.3925 ms/op 0.79
Tree 40 250000 create 328.37 ms/op 539.92 ms/op 0.61
Tree 40 250000 get(125000) 185.66 ns/op 199.28 ns/op 0.93
Tree 40 250000 set(125000) 884.88 ns/op 1.2307 us/op 0.72
Tree 40 250000 toArray() 18.810 ms/op 24.345 ms/op 0.77
Tree 40 250000 iterate all - toArray() + loop 20.333 ms/op 24.592 ms/op 0.83
Tree 40 250000 iterate all - get(i) 69.630 ms/op 78.142 ms/op 0.89
MutableVector 250000 create 10.468 ms/op 12.097 ms/op 0.87
MutableVector 250000 get(125000) 6.3470 ns/op 6.7460 ns/op 0.94
MutableVector 250000 set(125000) 279.03 ns/op 324.86 ns/op 0.86
MutableVector 250000 toArray() 3.2850 ms/op 4.0662 ms/op 0.81
MutableVector 250000 iterate all - toArray() + loop 3.1650 ms/op 4.6978 ms/op 0.67
MutableVector 250000 iterate all - get(i) 1.5291 ms/op 1.5545 ms/op 0.98
Array 250000 create 2.5374 ms/op 4.6248 ms/op 0.55
Array 250000 clone - spread 1.1609 ms/op 1.3203 ms/op 0.88
Array 250000 get(125000) 0.56900 ns/op 0.62400 ns/op 0.91
Array 250000 set(125000) 0.64200 ns/op 0.68700 ns/op 0.93
Array 250000 iterate all - loop 106.02 us/op 107.68 us/op 0.98
effectiveBalanceIncrements clone Uint8Array 300000 32.135 us/op 49.720 us/op 0.65
effectiveBalanceIncrements clone MutableVector 300000 353.00 ns/op 351.00 ns/op 1.01
effectiveBalanceIncrements rw all Uint8Array 300000 166.89 us/op 176.72 us/op 0.94
effectiveBalanceIncrements rw all MutableVector 300000 81.381 ms/op 97.086 ms/op 0.84
phase0 afterProcessEpoch - 250000 vs - 7PWei 112.37 ms/op 119.17 ms/op 0.94
phase0 beforeProcessEpoch - 250000 vs - 7PWei 35.149 ms/op 40.726 ms/op 0.86
altair processEpoch - mainnet_e81889 299.52 ms/op 372.33 ms/op 0.80
mainnet_e81889 - altair beforeProcessEpoch 49.497 ms/op 77.723 ms/op 0.64
mainnet_e81889 - altair processJustificationAndFinalization 21.433 us/op 19.294 us/op 1.11
mainnet_e81889 - altair processInactivityUpdates 7.1959 ms/op 7.2639 ms/op 0.99
mainnet_e81889 - altair processRewardsAndPenalties 65.802 ms/op 59.349 ms/op 1.11
mainnet_e81889 - altair processRegistryUpdates 3.2200 us/op 3.6800 us/op 0.88
mainnet_e81889 - altair processSlashings 740.00 ns/op 705.00 ns/op 1.05
mainnet_e81889 - altair processEth1DataReset 582.00 ns/op 745.00 ns/op 0.78
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2707 ms/op 1.2854 ms/op 0.99
mainnet_e81889 - altair processSlashingsReset 5.0400 us/op 4.9040 us/op 1.03
mainnet_e81889 - altair processRandaoMixesReset 4.7930 us/op 5.6150 us/op 0.85
mainnet_e81889 - altair processHistoricalRootsUpdate 614.00 ns/op 1.2310 us/op 0.50
mainnet_e81889 - altair processParticipationFlagUpdates 2.5670 us/op 3.8530 us/op 0.67
mainnet_e81889 - altair processSyncCommitteeUpdates 946.00 ns/op 1.3170 us/op 0.72
mainnet_e81889 - altair afterProcessEpoch 128.40 ms/op 135.22 ms/op 0.95
phase0 processEpoch - mainnet_e58758 379.16 ms/op 425.87 ms/op 0.89
mainnet_e58758 - phase0 beforeProcessEpoch 145.67 ms/op 167.01 ms/op 0.87
mainnet_e58758 - phase0 processJustificationAndFinalization 19.732 us/op 28.432 us/op 0.69
mainnet_e58758 - phase0 processRewardsAndPenalties 61.491 ms/op 73.958 ms/op 0.83
mainnet_e58758 - phase0 processRegistryUpdates 10.994 us/op 10.065 us/op 1.09
mainnet_e58758 - phase0 processSlashings 618.00 ns/op 665.00 ns/op 0.93
mainnet_e58758 - phase0 processEth1DataReset 582.00 ns/op 611.00 ns/op 0.95
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0149 ms/op 1.3466 ms/op 0.75
mainnet_e58758 - phase0 processSlashingsReset 4.7890 us/op 4.2940 us/op 1.12
mainnet_e58758 - phase0 processRandaoMixesReset 4.8900 us/op 9.5120 us/op 0.51
mainnet_e58758 - phase0 processHistoricalRootsUpdate 888.00 ns/op 917.00 ns/op 0.97
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.4340 us/op 5.2430 us/op 0.85
mainnet_e58758 - phase0 afterProcessEpoch 98.912 ms/op 103.47 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2490 ms/op 1.3142 ms/op 0.95
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5952 ms/op 1.5712 ms/op 1.02
altair processInactivityUpdates - 250000 normalcase 21.105 ms/op 20.647 ms/op 1.02
altair processInactivityUpdates - 250000 worstcase 26.002 ms/op 27.286 ms/op 0.95
phase0 processRegistryUpdates - 250000 normalcase 7.8050 us/op 8.0800 us/op 0.97
phase0 processRegistryUpdates - 250000 badcase_full_deposits 278.37 us/op 315.32 us/op 0.88
phase0 processRegistryUpdates - 250000 worstcase 0.5 123.91 ms/op 144.90 ms/op 0.86
altair processRewardsAndPenalties - 250000 normalcase 67.704 ms/op 67.982 ms/op 1.00
altair processRewardsAndPenalties - 250000 worstcase 67.450 ms/op 69.971 ms/op 0.96
phase0 getAttestationDeltas - 250000 normalcase 6.9931 ms/op 8.4005 ms/op 0.83
phase0 getAttestationDeltas - 250000 worstcase 6.5988 ms/op 6.8726 ms/op 0.96
phase0 processSlashings - 250000 worstcase 3.4018 ms/op 3.7270 ms/op 0.91
altair processSyncCommitteeUpdates - 250000 176.75 ms/op 184.32 ms/op 0.96
BeaconState.hashTreeRoot - No change 272.00 ns/op 361.00 ns/op 0.75
BeaconState.hashTreeRoot - 1 full validator 53.187 us/op 53.475 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 481.16 us/op 537.93 us/op 0.89
BeaconState.hashTreeRoot - 512 full validator 5.6598 ms/op 5.7822 ms/op 0.98
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 61.439 us/op 64.626 us/op 0.95
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 894.16 us/op 955.42 us/op 0.94
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.451 ms/op 12.381 ms/op 0.92
BeaconState.hashTreeRoot - 1 balances 48.240 us/op 51.947 us/op 0.93
BeaconState.hashTreeRoot - 32 balances 467.74 us/op 459.23 us/op 1.02
BeaconState.hashTreeRoot - 512 balances 4.4314 ms/op 4.4465 ms/op 1.00
BeaconState.hashTreeRoot - 250000 balances 69.291 ms/op 77.429 ms/op 0.89
aggregationBits - 2048 els - zipIndexesInBitList 15.443 us/op 17.197 us/op 0.90
regular array get 100000 times 32.644 us/op 33.903 us/op 0.96
wrappedArray get 100000 times 32.685 us/op 33.138 us/op 0.99
arrayWithProxy get 100000 times 15.974 ms/op 16.339 ms/op 0.98
ssz.Root.equals 531.00 ns/op 617.00 ns/op 0.86
byteArrayEquals 535.00 ns/op 573.00 ns/op 0.93
shuffle list - 16384 els 6.8825 ms/op 6.9757 ms/op 0.99
shuffle list - 250000 els 101.02 ms/op 102.06 ms/op 0.99
processSlot - 1 slots 9.0090 us/op 9.1030 us/op 0.99
processSlot - 32 slots 1.3154 ms/op 1.4235 ms/op 0.92
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 35.750 ms/op 37.222 ms/op 0.96
getCommitteeAssignments - req 1 vs - 250000 vc 2.9147 ms/op 2.9323 ms/op 0.99
getCommitteeAssignments - req 100 vs - 250000 vc 4.2464 ms/op 4.1613 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4759 ms/op 4.5459 ms/op 0.98
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7600 ns/op 5.0800 ns/op 0.94
state getBlockRootAtSlot - 250000 vs - 7PWei 554.18 ns/op 686.52 ns/op 0.81
computeProposers - vc 250000 10.149 ms/op 11.042 ms/op 0.92
computeEpochShuffling - vc 250000 102.57 ms/op 104.52 ms/op 0.98
getNextSyncCommittee - vc 250000 175.53 ms/op 183.32 ms/op 0.96
computeSigningRoot for AttestationData 13.234 us/op 14.398 us/op 0.92
hash AttestationData serialized data then Buffer.toString(base64) 2.4998 us/op 2.5027 us/op 1.00
toHexString serialized data 1.0784 us/op 1.1599 us/op 0.93
Buffer.toString(base64) 337.00 ns/op 319.39 ns/op 1.06

by benchmarkbot/action

@dapplion dapplion enabled auto-merge (squash) May 2, 2023 04:16
Copy link
Member

@matthewkeil matthewkeil left a comment

Choose a reason for hiding this comment

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

Nice!! Just the ? about the unit test moving somewhere instead of getting deleted

@@ -43,36 +41,6 @@ describe("node api implementation", function () {
sinon.stub(networkStub, "localMultiaddrs").get(() => [multiaddr("/ip4/127.0.0.1/tcp/36000")]);
});

describe("getNetworkIdentity", function () {
Copy link
Member

Choose a reason for hiding this comment

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

Does this unit test need to be reimplemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API impl now just calls a function, a unit test for it would be pretty stupid, testing that function a calls function b

@dapplion dapplion merged commit da696c0 into unstable May 2, 2023
@dapplion dapplion deleted the dapplion/getNetworkIdentity branch May 2, 2023 04:31
@wemeetagain
Copy link
Member

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

3 participants