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: update correlation penalty computation #7071

Merged
merged 7 commits into from
Sep 30, 2024
Merged

Conversation

ensi321
Copy link
Contributor

@ensi321 ensi321 commented Sep 6, 2024

ethereum/consensus-specs#3882 proposes to reformat slashing penalty calculation due to overflow issue.

Lodestar does not have such issue as we've already been tracking everything in increments.

This PR restyle the calculation to be more in line with the spec.

Although spec change supposedly will be live for devnet-4, we can make the code change now for devnet-3 since no functional difference.

@ensi321 ensi321 requested a review from a team as a code owner September 6, 2024 22:20
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 48.93%. Comparing base (ad4ec77) to head (8d60623).
Report is 9 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7071      +/-   ##
============================================
- Coverage     50.82%   48.93%   -1.90%     
============================================
  Files           597      597              
  Lines         39789    39809      +20     
  Branches       2059     2055       -4     
============================================
- Hits          20224    19481     -743     
- Misses        19565    20287     +722     
- Partials          0       41      +41     

Copy link
Contributor

github-actions bot commented Sep 6, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1e23466 Previous: 58dea75 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.0492 ms/op 3.4641 ms/op 0.59
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 56.476 us/op 96.914 us/op 0.58
BLS verify - blst 909.10 us/op 1.1456 ms/op 0.79
BLS verifyMultipleSignatures 3 - blst 1.2577 ms/op 1.6850 ms/op 0.75
BLS verifyMultipleSignatures 8 - blst 2.0492 ms/op 2.8165 ms/op 0.73
BLS verifyMultipleSignatures 32 - blst 5.9997 ms/op 7.6711 ms/op 0.78
BLS verifyMultipleSignatures 64 - blst 10.897 ms/op 12.288 ms/op 0.89
BLS verifyMultipleSignatures 128 - blst 17.415 ms/op 22.280 ms/op 0.78
BLS deserializing 10000 signatures 688.39 ms/op 733.35 ms/op 0.94
BLS deserializing 100000 signatures 6.9420 s/op 7.0729 s/op 0.98
BLS verifyMultipleSignatures - same message - 3 - blst 1.0671 ms/op 1.1058 ms/op 0.97
BLS verifyMultipleSignatures - same message - 8 - blst 1.2747 ms/op 1.1093 ms/op 1.15
BLS verifyMultipleSignatures - same message - 32 - blst 2.0110 ms/op 1.7730 ms/op 1.13
BLS verifyMultipleSignatures - same message - 64 - blst 2.8194 ms/op 2.7153 ms/op 1.04
BLS verifyMultipleSignatures - same message - 128 - blst 4.5579 ms/op 4.5985 ms/op 0.99
BLS aggregatePubkeys 32 - blst 20.612 us/op 20.744 us/op 0.99
BLS aggregatePubkeys 128 - blst 71.753 us/op 73.199 us/op 0.98
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 82.177 ms/op 75.150 ms/op 1.09
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 76.234 ms/op 71.839 ms/op 1.06
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 39.858 ms/op 39.127 ms/op 1.02
getSlashingsAndExits - default max 123.59 us/op 105.40 us/op 1.17
getSlashingsAndExits - 2k 291.96 us/op 316.99 us/op 0.92
proposeBlockBody type=full, size=empty 5.8615 ms/op 5.8956 ms/op 0.99
isKnown best case - 1 super set check 355.00 ns/op 348.00 ns/op 1.02
isKnown normal case - 2 super set checks 347.00 ns/op 434.00 ns/op 0.80
isKnown worse case - 16 super set checks 296.00 ns/op 324.00 ns/op 0.91
InMemoryCheckpointStateCache - add get delete 2.6760 us/op 3.0960 us/op 0.86
updateUnfinalizedPubkeys - updating 10 pubkeys 1.3737 ms/op 1.1866 ms/op 1.16
updateUnfinalizedPubkeys - updating 100 pubkeys 3.8106 ms/op 4.3288 ms/op 0.88
updateUnfinalizedPubkeys - updating 1000 pubkeys 54.109 ms/op 54.689 ms/op 0.99
validate api signedAggregateAndProof - struct 1.4735 ms/op 1.6382 ms/op 0.90
validate gossip signedAggregateAndProof - struct 1.4580 ms/op 1.4789 ms/op 0.99
validate gossip attestation - vc 640000 1.0713 ms/op 1.0656 ms/op 1.01
batch validate gossip attestation - vc 640000 - chunk 32 140.73 us/op 140.90 us/op 1.00
batch validate gossip attestation - vc 640000 - chunk 64 130.11 us/op 119.42 us/op 1.09
batch validate gossip attestation - vc 640000 - chunk 128 114.87 us/op 104.55 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 256 119.89 us/op 103.83 us/op 1.15
pickEth1Vote - no votes 1.0610 ms/op 1.1348 ms/op 0.93
pickEth1Vote - max votes 6.2444 ms/op 6.3956 ms/op 0.98
pickEth1Vote - Eth1Data hashTreeRoot value x2048 14.469 ms/op 11.742 ms/op 1.23
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.883 ms/op 18.063 ms/op 1.21
pickEth1Vote - Eth1Data fastSerialize value x2048 506.02 us/op 457.13 us/op 1.11
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.4268 ms/op 3.8532 ms/op 0.89
bytes32 toHexString 430.00 ns/op 422.00 ns/op 1.02
bytes32 Buffer.toString(hex) 265.00 ns/op 253.00 ns/op 1.05
bytes32 Buffer.toString(hex) from Uint8Array 378.00 ns/op 366.00 ns/op 1.03
bytes32 Buffer.toString(hex) + 0x 261.00 ns/op 250.00 ns/op 1.04
Object access 1 prop 0.13100 ns/op 0.13600 ns/op 0.96
Map access 1 prop 0.13000 ns/op 0.13000 ns/op 1.00
Object get x1000 5.7330 ns/op 6.0890 ns/op 0.94
Map get x1000 6.2290 ns/op 6.6060 ns/op 0.94
Object set x1000 30.561 ns/op 32.265 ns/op 0.95
Map set x1000 22.353 ns/op 21.712 ns/op 1.03
Return object 10000 times 0.28080 ns/op 0.28540 ns/op 0.98
Throw Error 10000 times 3.2216 us/op 3.2990 us/op 0.98
toHex 158.29 ns/op 140.87 ns/op 1.12
Buffer.from 136.42 ns/op 130.49 ns/op 1.05
shared Buffer 105.54 ns/op 82.879 ns/op 1.27
fastMsgIdFn sha256 / 200 bytes 2.1950 us/op 2.2230 us/op 0.99
fastMsgIdFn h32 xxhash / 200 bytes 225.00 ns/op 223.00 ns/op 1.01
fastMsgIdFn h64 xxhash / 200 bytes 266.00 ns/op 274.00 ns/op 0.97
fastMsgIdFn sha256 / 1000 bytes 7.2620 us/op 7.3590 us/op 0.99
fastMsgIdFn h32 xxhash / 1000 bytes 354.00 ns/op 358.00 ns/op 0.99
fastMsgIdFn h64 xxhash / 1000 bytes 344.00 ns/op 341.00 ns/op 1.01
fastMsgIdFn sha256 / 10000 bytes 63.780 us/op 63.683 us/op 1.00
fastMsgIdFn h32 xxhash / 10000 bytes 1.8290 us/op 1.8130 us/op 1.01
fastMsgIdFn h64 xxhash / 10000 bytes 1.2150 us/op 1.1880 us/op 1.02
send data - 1000 256B messages 12.072 ms/op 12.176 ms/op 0.99
send data - 1000 512B messages 16.459 ms/op 16.773 ms/op 0.98
send data - 1000 1024B messages 27.805 ms/op 27.358 ms/op 1.02
send data - 1000 1200B messages 27.616 ms/op 26.095 ms/op 1.06
send data - 1000 2048B messages 31.886 ms/op 33.843 ms/op 0.94
send data - 1000 4096B messages 31.888 ms/op 32.562 ms/op 0.98
send data - 1000 16384B messages 72.879 ms/op 72.001 ms/op 1.01
send data - 1000 65536B messages 200.34 ms/op 217.49 ms/op 0.92
enrSubnets - fastDeserialize 64 bits 1.0090 us/op 1.0530 us/op 0.96
enrSubnets - ssz BitVector 64 bits 344.00 ns/op 349.00 ns/op 0.99
enrSubnets - fastDeserialize 4 bits 146.00 ns/op 150.00 ns/op 0.97
enrSubnets - ssz BitVector 4 bits 349.00 ns/op 354.00 ns/op 0.99
prioritizePeers score -10:0 att 32-0.1 sync 2-0 149.23 us/op 152.79 us/op 0.98
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 198.94 us/op 185.66 us/op 1.07
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 359.68 us/op 288.77 us/op 1.25
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 588.27 us/op 534.99 us/op 1.10
prioritizePeers score 0:0 att 64-1 sync 4-1 910.56 us/op 832.73 us/op 1.09
array of 16000 items push then shift 1.5380 us/op 1.6845 us/op 0.91
LinkedList of 16000 items push then shift 6.6960 ns/op 7.5500 ns/op 0.89
array of 16000 items push then pop 93.343 ns/op 131.38 ns/op 0.71
LinkedList of 16000 items push then pop 6.6260 ns/op 7.4380 ns/op 0.89
array of 24000 items push then shift 2.2595 us/op 2.5320 us/op 0.89
LinkedList of 24000 items push then shift 6.6920 ns/op 7.5520 ns/op 0.89
array of 24000 items push then pop 121.68 ns/op 189.31 ns/op 0.64
LinkedList of 24000 items push then pop 6.7680 ns/op 7.7620 ns/op 0.87
intersect bitArray bitLen 8 6.0680 ns/op 6.7520 ns/op 0.90
intersect array and set length 8 42.268 ns/op 49.509 ns/op 0.85
intersect bitArray bitLen 128 28.398 ns/op 29.966 ns/op 0.95
intersect array and set length 128 625.57 ns/op 714.38 ns/op 0.88
bitArray.getTrueBitIndexes() bitLen 128 2.1350 us/op 2.5650 us/op 0.83
bitArray.getTrueBitIndexes() bitLen 248 3.6240 us/op 3.6260 us/op 1.00
bitArray.getTrueBitIndexes() bitLen 512 9.0180 us/op 7.4620 us/op 1.21
Buffer.concat 32 items 1.0100 us/op 866.00 ns/op 1.17
Uint8Array.set 32 items 1.8700 us/op 1.2910 us/op 1.45
Buffer.copy 1.9000 us/op 1.5410 us/op 1.23
Uint8Array.set - with subarray 2.7530 us/op 2.3450 us/op 1.17
Uint8Array.set - without subarray 1.5590 us/op 1.2850 us/op 1.21
getUint32 - dataview 231.00 ns/op 238.00 ns/op 0.97
getUint32 - manual 145.00 ns/op 159.00 ns/op 0.91
Set add up to 64 items then delete first 2.1219 us/op 2.2865 us/op 0.93
OrderedSet add up to 64 items then delete first 3.1754 us/op 3.4078 us/op 0.93
Set add up to 64 items then delete last 2.4192 us/op 2.6644 us/op 0.91
OrderedSet add up to 64 items then delete last 3.5269 us/op 4.1125 us/op 0.86
Set add up to 64 items then delete middle 2.4347 us/op 2.5648 us/op 0.95
OrderedSet add up to 64 items then delete middle 5.0493 us/op 5.3141 us/op 0.95
Set add up to 128 items then delete first 5.0103 us/op 5.5097 us/op 0.91
OrderedSet add up to 128 items then delete first 7.7169 us/op 7.5104 us/op 1.03
Set add up to 128 items then delete last 4.7791 us/op 5.1058 us/op 0.94
OrderedSet add up to 128 items then delete last 7.1349 us/op 8.0682 us/op 0.88
Set add up to 128 items then delete middle 4.7222 us/op 5.0650 us/op 0.93
OrderedSet add up to 128 items then delete middle 13.325 us/op 13.850 us/op 0.96
Set add up to 256 items then delete first 9.9076 us/op 10.181 us/op 0.97
OrderedSet add up to 256 items then delete first 15.877 us/op 15.363 us/op 1.03
Set add up to 256 items then delete last 9.5156 us/op 10.116 us/op 0.94
OrderedSet add up to 256 items then delete last 14.105 us/op 15.919 us/op 0.89
Set add up to 256 items then delete middle 9.3474 us/op 10.074 us/op 0.93
OrderedSet add up to 256 items then delete middle 40.558 us/op 41.537 us/op 0.98
transfer serialized Status (84 B) 1.4900 us/op 1.3330 us/op 1.12
copy serialized Status (84 B) 1.2760 us/op 1.2740 us/op 1.00
transfer serialized SignedVoluntaryExit (112 B) 1.7880 us/op 1.7830 us/op 1.00
copy serialized SignedVoluntaryExit (112 B) 1.3310 us/op 1.4150 us/op 0.94
transfer serialized ProposerSlashing (416 B) 2.1640 us/op 2.3940 us/op 0.90
copy serialized ProposerSlashing (416 B) 2.3010 us/op 1.6010 us/op 1.44
transfer serialized Attestation (485 B) 2.7350 us/op 1.6180 us/op 1.69
copy serialized Attestation (485 B) 1.8730 us/op 1.4140 us/op 1.32
transfer serialized AttesterSlashing (33232 B) 2.1240 us/op 1.9260 us/op 1.10
copy serialized AttesterSlashing (33232 B) 4.5370 us/op 4.9680 us/op 0.91
transfer serialized Small SignedBeaconBlock (128000 B) 2.7390 us/op 2.2510 us/op 1.22
copy serialized Small SignedBeaconBlock (128000 B) 13.172 us/op 15.456 us/op 0.85
transfer serialized Avg SignedBeaconBlock (200000 B) 3.6530 us/op 2.6060 us/op 1.40
copy serialized Avg SignedBeaconBlock (200000 B) 20.034 us/op 20.714 us/op 0.97
transfer serialized BlobsSidecar (524380 B) 2.8770 us/op 2.3110 us/op 1.24
copy serialized BlobsSidecar (524380 B) 78.609 us/op 90.457 us/op 0.87
transfer serialized Big SignedBeaconBlock (1000000 B) 2.7320 us/op 2.7040 us/op 1.01
copy serialized Big SignedBeaconBlock (1000000 B) 134.17 us/op 160.20 us/op 0.84
pass gossip attestations to forkchoice per slot 2.8468 ms/op 2.8469 ms/op 1.00
forkChoice updateHead vc 100000 bc 64 eq 0 501.90 us/op 497.39 us/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 0 3.5207 ms/op 3.2863 ms/op 1.07
forkChoice updateHead vc 1000000 bc 64 eq 0 5.4918 ms/op 5.4644 ms/op 1.01
forkChoice updateHead vc 600000 bc 320 eq 0 3.1484 ms/op 3.0905 ms/op 1.02
forkChoice updateHead vc 600000 bc 1200 eq 0 3.1316 ms/op 3.0619 ms/op 1.02
forkChoice updateHead vc 600000 bc 7200 eq 0 3.5060 ms/op 3.5922 ms/op 0.98
forkChoice updateHead vc 600000 bc 64 eq 1000 10.916 ms/op 10.712 ms/op 1.02
forkChoice updateHead vc 600000 bc 64 eq 10000 10.800 ms/op 10.687 ms/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 300000 14.205 ms/op 13.875 ms/op 1.02
computeDeltas 500000 validators 300 proto nodes 3.7472 ms/op 3.7187 ms/op 1.01
computeDeltas 500000 validators 1200 proto nodes 3.7448 ms/op 3.7028 ms/op 1.01
computeDeltas 500000 validators 7200 proto nodes 3.9365 ms/op 3.7809 ms/op 1.04
computeDeltas 750000 validators 300 proto nodes 5.2953 ms/op 5.3661 ms/op 0.99
computeDeltas 750000 validators 1200 proto nodes 5.3389 ms/op 5.6899 ms/op 0.94
computeDeltas 750000 validators 7200 proto nodes 5.3162 ms/op 5.4979 ms/op 0.97
computeDeltas 1400000 validators 300 proto nodes 10.011 ms/op 10.580 ms/op 0.95
computeDeltas 1400000 validators 1200 proto nodes 10.218 ms/op 10.168 ms/op 1.00
computeDeltas 1400000 validators 7200 proto nodes 9.8198 ms/op 10.281 ms/op 0.96
computeDeltas 2100000 validators 300 proto nodes 15.083 ms/op 14.921 ms/op 1.01
computeDeltas 2100000 validators 1200 proto nodes 14.593 ms/op 14.695 ms/op 0.99
computeDeltas 2100000 validators 7200 proto nodes 15.246 ms/op 15.283 ms/op 1.00
altair processAttestation - 250000 vs - 7PWei normalcase 1.6481 ms/op 1.7440 ms/op 0.95
altair processAttestation - 250000 vs - 7PWei worstcase 2.5374 ms/op 2.5817 ms/op 0.98
altair processAttestation - setStatus - 1/6 committees join 89.069 us/op 88.270 us/op 1.01
altair processAttestation - setStatus - 1/3 committees join 175.33 us/op 167.64 us/op 1.05
altair processAttestation - setStatus - 1/2 committees join 248.76 us/op 238.16 us/op 1.04
altair processAttestation - setStatus - 2/3 committees join 328.23 us/op 316.20 us/op 1.04
altair processAttestation - setStatus - 4/5 committees join 467.96 us/op 457.58 us/op 1.02
altair processAttestation - setStatus - 100% committees join 562.62 us/op 543.20 us/op 1.04
altair processBlock - 250000 vs - 7PWei normalcase 5.4914 ms/op 4.6327 ms/op 1.19
altair processBlock - 250000 vs - 7PWei normalcase hashState 27.413 ms/op 33.460 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 41.284 ms/op 45.251 ms/op 0.91
altair processBlock - 250000 vs - 7PWei worstcase hashState 77.905 ms/op 88.554 ms/op 0.88
phase0 processBlock - 250000 vs - 7PWei normalcase 2.3055 ms/op 2.3756 ms/op 0.97
phase0 processBlock - 250000 vs - 7PWei worstcase 29.270 ms/op 26.693 ms/op 1.10
altair processEth1Data - 250000 vs - 7PWei normalcase 414.76 us/op 298.35 us/op 1.39
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 7.4740 us/op 7.4760 us/op 1.00
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 50.934 us/op 42.886 us/op 1.19
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 13.081 us/op 11.845 us/op 1.10
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 7.6130 us/op 8.0560 us/op 0.95
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 186.82 us/op 174.97 us/op 1.07
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.3226 ms/op 942.60 us/op 1.40
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.5395 ms/op 1.9667 ms/op 0.78
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.9699 ms/op 2.7584 ms/op 0.71
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.3587 ms/op 3.5176 ms/op 1.24
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.9404 ms/op 2.7510 ms/op 0.71
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.0592 ms/op 3.5171 ms/op 1.15
Tree 40 250000 create 284.79 ms/op 215.77 ms/op 1.32
Tree 40 250000 get(125000) 167.89 ns/op 147.11 ns/op 1.14
Tree 40 250000 set(125000) 1.0387 us/op 656.20 ns/op 1.58
Tree 40 250000 toArray() 21.941 ms/op 15.164 ms/op 1.45
Tree 40 250000 iterate all - toArray() + loop 21.449 ms/op 15.204 ms/op 1.41
Tree 40 250000 iterate all - get(i) 65.502 ms/op 53.904 ms/op 1.22
Array 250000 create 4.1225 ms/op 2.8374 ms/op 1.45
Array 250000 clone - spread 1.7066 ms/op 1.4919 ms/op 1.14
Array 250000 get(125000) 0.45700 ns/op 0.42000 ns/op 1.09
Array 250000 set(125000) 0.47900 ns/op 0.42800 ns/op 1.12
Array 250000 iterate all - loop 87.050 us/op 91.296 us/op 0.95
phase0 afterProcessEpoch - 250000 vs - 7PWei 93.224 ms/op 87.967 ms/op 1.06
Array.fill - length 1000000 4.3861 ms/op 3.5934 ms/op 1.22
Array push - length 1000000 21.848 ms/op 16.999 ms/op 1.29
Array.get 0.30481 ns/op 0.29135 ns/op 1.05
Uint8Array.get 0.46901 ns/op 0.44905 ns/op 1.04
phase0 beforeProcessEpoch - 250000 vs - 7PWei 21.759 ms/op 18.584 ms/op 1.17
altair processEpoch - mainnet_e81889 341.44 ms/op 353.86 ms/op 0.96
mainnet_e81889 - altair beforeProcessEpoch 21.702 ms/op 19.113 ms/op 1.14
mainnet_e81889 - altair processJustificationAndFinalization 13.870 us/op 18.998 us/op 0.73
mainnet_e81889 - altair processInactivityUpdates 6.4204 ms/op 5.0625 ms/op 1.27
mainnet_e81889 - altair processRewardsAndPenalties 51.677 ms/op 58.326 ms/op 0.89
mainnet_e81889 - altair processRegistryUpdates 2.1130 us/op 2.8420 us/op 0.74
mainnet_e81889 - altair processSlashings 481.00 ns/op 561.00 ns/op 0.86
mainnet_e81889 - altair processEth1DataReset 356.00 ns/op 319.00 ns/op 1.12
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.3332 ms/op 1.9400 ms/op 1.20
mainnet_e81889 - altair processSlashingsReset 3.6780 us/op 4.3160 us/op 0.85
mainnet_e81889 - altair processRandaoMixesReset 4.5440 us/op 5.0700 us/op 0.90
mainnet_e81889 - altair processHistoricalRootsUpdate 528.00 ns/op 662.00 ns/op 0.80
mainnet_e81889 - altair processParticipationFlagUpdates 2.2510 us/op 3.0010 us/op 0.75
mainnet_e81889 - altair processSyncCommitteeUpdates 766.00 ns/op 794.00 ns/op 0.96
mainnet_e81889 - altair afterProcessEpoch 108.02 ms/op 92.860 ms/op 1.16
capella processEpoch - mainnet_e217614 1.5162 s/op 1.3211 s/op 1.15
mainnet_e217614 - capella beforeProcessEpoch 101.22 ms/op 71.923 ms/op 1.41
mainnet_e217614 - capella processJustificationAndFinalization 28.620 us/op 19.873 us/op 1.44
mainnet_e217614 - capella processInactivityUpdates 21.525 ms/op 17.773 ms/op 1.21
mainnet_e217614 - capella processRewardsAndPenalties 305.12 ms/op 253.87 ms/op 1.20
mainnet_e217614 - capella processRegistryUpdates 21.692 us/op 13.450 us/op 1.61
mainnet_e217614 - capella processSlashings 920.00 ns/op 434.00 ns/op 2.12
mainnet_e217614 - capella processEth1DataReset 442.00 ns/op 352.00 ns/op 1.26
mainnet_e217614 - capella processEffectiveBalanceUpdates 18.650 ms/op 14.817 ms/op 1.26
mainnet_e217614 - capella processSlashingsReset 5.5560 us/op 3.4770 us/op 1.60
mainnet_e217614 - capella processRandaoMixesReset 12.430 us/op 4.4930 us/op 2.77
mainnet_e217614 - capella processHistoricalRootsUpdate 1.5940 us/op 606.00 ns/op 2.63
mainnet_e217614 - capella processParticipationFlagUpdates 5.2360 us/op 1.6670 us/op 3.14
mainnet_e217614 - capella afterProcessEpoch 303.17 ms/op 245.71 ms/op 1.23
phase0 processEpoch - mainnet_e58758 527.02 ms/op 397.76 ms/op 1.32
mainnet_e58758 - phase0 beforeProcessEpoch 121.34 ms/op 80.200 ms/op 1.51
mainnet_e58758 - phase0 processJustificationAndFinalization 25.764 us/op 17.160 us/op 1.50
mainnet_e58758 - phase0 processRewardsAndPenalties 35.657 ms/op 33.490 ms/op 1.06
mainnet_e58758 - phase0 processRegistryUpdates 14.568 us/op 8.4140 us/op 1.73
mainnet_e58758 - phase0 processSlashings 808.00 ns/op 325.00 ns/op 2.49
mainnet_e58758 - phase0 processEth1DataReset 857.00 ns/op 328.00 ns/op 2.61
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.6089 ms/op 1.4016 ms/op 1.15
mainnet_e58758 - phase0 processSlashingsReset 8.0430 us/op 2.7340 us/op 2.94
mainnet_e58758 - phase0 processRandaoMixesReset 11.148 us/op 4.3950 us/op 2.54
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.5280 us/op 382.00 ns/op 4.00
mainnet_e58758 - phase0 processParticipationRecordUpdates 10.726 us/op 3.2550 us/op 3.30
mainnet_e58758 - phase0 afterProcessEpoch 98.236 ms/op 82.619 ms/op 1.19
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.3392 ms/op 1.4309 ms/op 1.63
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.8539 ms/op 3.0931 ms/op 1.25
altair processInactivityUpdates - 250000 normalcase 27.263 ms/op 19.422 ms/op 1.40
altair processInactivityUpdates - 250000 worstcase 24.012 ms/op 20.582 ms/op 1.17
phase0 processRegistryUpdates - 250000 normalcase 13.580 us/op 8.4750 us/op 1.60
phase0 processRegistryUpdates - 250000 badcase_full_deposits 432.46 us/op 347.69 us/op 1.24
phase0 processRegistryUpdates - 250000 worstcase 0.5 159.54 ms/op 141.52 ms/op 1.13
altair processRewardsAndPenalties - 250000 normalcase 42.362 ms/op 44.269 ms/op 0.96
altair processRewardsAndPenalties - 250000 worstcase 48.545 ms/op 38.944 ms/op 1.25
phase0 getAttestationDeltas - 250000 normalcase 10.794 ms/op 8.1387 ms/op 1.33
phase0 getAttestationDeltas - 250000 worstcase 10.567 ms/op 9.3490 ms/op 1.13
phase0 processSlashings - 250000 worstcase 119.86 us/op 106.42 us/op 1.13
altair processSyncCommitteeUpdates - 250000 148.56 ms/op 131.52 ms/op 1.13
BeaconState.hashTreeRoot - No change 252.00 ns/op 230.00 ns/op 1.10
BeaconState.hashTreeRoot - 1 full validator 118.03 us/op 108.92 us/op 1.08
BeaconState.hashTreeRoot - 32 full validator 1.2184 ms/op 1.4174 ms/op 0.86
BeaconState.hashTreeRoot - 512 full validator 15.594 ms/op 13.159 ms/op 1.19
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 162.61 us/op 114.59 us/op 1.42
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.6220 ms/op 1.5124 ms/op 1.73
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 32.189 ms/op 21.980 ms/op 1.46
BeaconState.hashTreeRoot - 1 balances 129.03 us/op 84.182 us/op 1.53
BeaconState.hashTreeRoot - 32 balances 1.0559 ms/op 739.15 us/op 1.43
BeaconState.hashTreeRoot - 512 balances 10.251 ms/op 8.0124 ms/op 1.28
BeaconState.hashTreeRoot - 250000 balances 205.35 ms/op 164.40 ms/op 1.25
aggregationBits - 2048 els - zipIndexesInBitList 29.744 us/op 30.100 us/op 0.99
byteArrayEquals 32 57.143 ns/op 54.478 ns/op 1.05
Buffer.compare 32 18.307 ns/op 17.353 ns/op 1.05
byteArrayEquals 1024 1.6426 us/op 1.6141 us/op 1.02
Buffer.compare 1024 26.636 ns/op 25.077 ns/op 1.06
byteArrayEquals 16384 25.820 us/op 25.921 us/op 1.00
Buffer.compare 16384 189.70 ns/op 209.78 ns/op 0.90
byteArrayEquals 123687377 195.77 ms/op 195.42 ms/op 1.00
Buffer.compare 123687377 7.0527 ms/op 9.9501 ms/op 0.71
byteArrayEquals 32 - diff last byte 51.964 ns/op 53.136 ns/op 0.98
Buffer.compare 32 - diff last byte 16.880 ns/op 17.267 ns/op 0.98
byteArrayEquals 1024 - diff last byte 1.5589 us/op 1.5952 us/op 0.98
Buffer.compare 1024 - diff last byte 33.154 ns/op 26.083 ns/op 1.27
byteArrayEquals 16384 - diff last byte 24.894 us/op 25.435 us/op 0.98
Buffer.compare 16384 - diff last byte 184.57 ns/op 177.04 ns/op 1.04
byteArrayEquals 123687377 - diff last byte 191.71 ms/op 191.89 ms/op 1.00
Buffer.compare 123687377 - diff last byte 6.8660 ms/op 7.8339 ms/op 0.88
byteArrayEquals 32 - random bytes 5.1360 ns/op 5.3190 ns/op 0.97
Buffer.compare 32 - random bytes 17.123 ns/op 17.985 ns/op 0.95
byteArrayEquals 1024 - random bytes 5.2340 ns/op 5.3290 ns/op 0.98
Buffer.compare 1024 - random bytes 17.312 ns/op 17.784 ns/op 0.97
byteArrayEquals 16384 - random bytes 5.2690 ns/op 5.3270 ns/op 0.99
Buffer.compare 16384 - random bytes 17.248 ns/op 17.922 ns/op 0.96
byteArrayEquals 123687377 - random bytes 6.5700 ns/op 6.6100 ns/op 0.99
Buffer.compare 123687377 - random bytes 18.800 ns/op 19.170 ns/op 0.98
regular array get 100000 times 34.039 us/op 40.443 us/op 0.84
wrappedArray get 100000 times 36.763 us/op 33.630 us/op 1.09
arrayWithProxy get 100000 times 13.321 ms/op 13.632 ms/op 0.98
ssz.Root.equals 46.222 ns/op 46.715 ns/op 0.99
byteArrayEquals 45.544 ns/op 45.762 ns/op 1.00
Buffer.compare 10.476 ns/op 10.599 ns/op 0.99
shuffle list - 16384 els 6.2604 ms/op 6.5100 ms/op 0.96
shuffle list - 250000 els 92.142 ms/op 94.495 ms/op 0.98
processSlot - 1 slots 13.856 us/op 13.093 us/op 1.06
processSlot - 32 slots 3.6484 ms/op 2.5299 ms/op 1.44
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 39.935 ms/op 38.706 ms/op 1.03
getCommitteeAssignments - req 1 vs - 250000 vc 2.1310 ms/op 2.1080 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 4.1805 ms/op 4.2037 ms/op 0.99
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4651 ms/op 4.4874 ms/op 1.00
findModifiedValidators - 10000 modified validators 270.71 ms/op 293.97 ms/op 0.92
findModifiedValidators - 1000 modified validators 177.98 ms/op 205.12 ms/op 0.87
findModifiedValidators - 100 modified validators 182.01 ms/op 225.05 ms/op 0.81
findModifiedValidators - 10 modified validators 157.31 ms/op 176.23 ms/op 0.89
findModifiedValidators - 1 modified validators 142.10 ms/op 197.87 ms/op 0.72
findModifiedValidators - no difference 187.05 ms/op 185.17 ms/op 1.01
compare ViewDUs 3.0007 s/op 3.3062 s/op 0.91
compare each validator Uint8Array 1.1966 s/op 1.2888 s/op 0.93
compare ViewDU to Uint8Array 1.1138 s/op 975.08 ms/op 1.14
migrate state 1000000 validators, 24 modified, 0 new 925.82 ms/op 862.83 ms/op 1.07
migrate state 1000000 validators, 1700 modified, 1000 new 1.1273 s/op 1.1809 s/op 0.95
migrate state 1000000 validators, 3400 modified, 2000 new 1.4697 s/op 1.3479 s/op 1.09
migrate state 1500000 validators, 24 modified, 0 new 1.0404 s/op 946.58 ms/op 1.10
migrate state 1500000 validators, 1700 modified, 1000 new 1.3062 s/op 1.1683 s/op 1.12
migrate state 1500000 validators, 3400 modified, 2000 new 1.5601 s/op 1.4081 s/op 1.11
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.0100 ns/op 4.8600 ns/op 1.03
state getBlockRootAtSlot - 250000 vs - 7PWei 793.96 ns/op 529.48 ns/op 1.50
computeProposers - vc 250000 8.6396 ms/op 8.0257 ms/op 1.08
computeEpochShuffling - vc 250000 98.619 ms/op 97.262 ms/op 1.01
getNextSyncCommittee - vc 250000 136.59 ms/op 142.39 ms/op 0.96
computeSigningRoot for AttestationData 24.941 us/op 28.009 us/op 0.89
hash AttestationData serialized data then Buffer.toString(base64) 1.7172 us/op 1.6133 us/op 1.06
toHexString serialized data 1.0555 us/op 1.0295 us/op 1.03
Buffer.toString(base64) 220.93 ns/op 205.18 ns/op 1.08
nodejs block root to RootHex using toHex 189.30 ns/op 149.15 ns/op 1.27
nodejs block root to RootHex using toRootHex 131.25 ns/op 98.287 ns/op 1.34
browser block root to RootHex using the deprecated toHexString 297.83 ns/op 274.82 ns/op 1.08
browser block root to RootHex using toHex 229.30 ns/op 210.78 ns/op 1.09
browser block root to RootHex using toRootHex 181.07 ns/op 174.99 ns/op 1.03

by benchmarkbot/action

@wemeetagain
Copy link
Member

spec tests failing

@ensi321 ensi321 marked this pull request as draft September 9, 2024 22:06
@ensi321 ensi321 changed the title feat: restyle slashing penalty calculation feat: update correlation penalty computation Sep 9, 2024
@ensi321
Copy link
Contributor Author

ensi321 commented Sep 9, 2024

spec tests failing

New slashing penalty calculation preserves every digit in gwei whereas old calculation is rounded to the nearest 1ETH. So this change doesn't retrofit pre-electra forks and will need to wait for next release of spec test in order to test the correctness of this PR.

Will convert to draft for now

@ensi321 ensi321 marked this pull request as ready for review September 26, 2024 22:15
const penalties: number[] = [];

const penaltiesByEffectiveBalanceIncrement = new Map<number, number>();
for (const index of cache.indicesToSlash) {
const effectiveBalanceIncrement = effectiveBalanceIncrements[index];
let penalty = penaltiesByEffectiveBalanceIncrement.get(effectiveBalanceIncrement);
if (penalty === undefined) {
const penaltyNumeratorByIncrement = effectiveBalanceIncrement * adjustedTotalSlashingBalanceByIncrement;
penalty = Math.floor(penaltyNumeratorByIncrement / totalBalanceByIncrement) * increment;
if (fork < ForkSeq.electra) {
Copy link
Member

Choose a reason for hiding this comment

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

any reason why the check is reversed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any reason why the check is reversed here?

No particular reason. I don't think there is a convention for fork check to be >= ForkSeq.electra vs < ForkSeq.electra.

Several places use < see:

@twoeths twoeths merged commit d69d809 into unstable Sep 30, 2024
20 checks passed
@twoeths twoeths deleted the nc/slashing-calculation branch September 30, 2024 02:58
philknows pushed a commit that referenced this pull request Oct 18, 2024
* Update slashing calculation to be more aligned with spec style

* Update calculation

* Lint

* Fix rounding issue

* Update calculation

* Enable slashing spec test

* lint
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.

4 participants