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

fix: update getPendingBalanceToWithdraw to work with uncommitted changes #7375

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Jan 19, 2025

Fixes devnet-5 issue

Jan-19 05:30:54.001[]                 info: Synced - slot: 19199 - head: 0xb612…f518 - exec-block: valid(16077 0x5a23…) - finalized: 0x2839…bb9d:597 - peers: 41
Jan-19 05:31:06.001[]                 info: Synced - slot: 19200 - head: 0x24e9…9b84 - exec-block: valid(16078 0x89e6…) - finalized: 0x5142…f40c:598 - peers: 41
Jan-19 05:31:12.288[network]          warn: Error receiving block slot=19201, peer=16Uiu2HAkxHheop9frWVri98J4bnncEbXH8R23y1wRGmCkvwHBzBA, code=BLOCK_ERROR_BEACON_CHAIN_ERROR, error=Must commit changes before reading all nodes
Error: Must commit changes before reading all nodes
    at ListCompositeTreeViewDU.populateAllNodes (/usr/app/node_modules/@chainsafe/ssz/src/viewDU/arrayComposite.ts:251:13)
    at ListCompositeTreeViewDU.getAllReadonly (/usr/app/node_modules/@chainsafe/ssz/src/viewDU/arrayComposite.ts:151:10)
    at getPendingBalanceToWithdraw (file:///usr/app/packages/state-transition/src/util/validator.ts:87:6)
    at processWithdrawalRequest (file:///usr/app/packages/state-transition/src/block/processWithdrawalRequest.ts:46:36)
    at processOperations (file:///usr/app/packages/state-transition/src/block/processOperations.ts:75:7)
    at processBlock (file:///usr/app/packages/state-transition/src/block/index.ts:61:3)
    at stateTransition (file:///usr/app/packages/state-transition/src/stateTransition.ts:106:3)
    at verifyBlocksStateTransitionOnly (file:///usr/app/packages/beacon-node/src/chain/blocks/verifyBlocksStateTransitionOnly.ts:46:23)
    at BeaconChain.verifyBlocksInEpoch (file:///usr/app/packages/beacon-node/src/chain/blocks/verifyBlock.ts:114:7)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
Jan-19 05:31:18.001[]                 info: Synced - slot: 19201 - head: (slot -1) 0x24e9…9b84 - exec-block: valid(16078 0x89e6…) - finalized: 0x5142…f40c:598 - peers: 41

which happened when processing block with two withdrawal requests.

See discord for more context.

@nflaig nflaig marked this pull request as ready for review January 19, 2025 21:15
@nflaig nflaig requested a review from a team as a code owner January 19, 2025 21:15
Copy link

codecov bot commented Jan 19, 2025

Codecov Report

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

Project coverage is 48.61%. Comparing base (06831cf) to head (bb00759).
Report is 2 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7375      +/-   ##
============================================
- Coverage     48.62%   48.61%   -0.01%     
============================================
  Files           603      603              
  Lines         40516    40520       +4     
  Branches       2071     2071              
============================================
  Hits          19700    19700              
- Misses        20778    20782       +4     
  Partials         38       38              

Copy link
Contributor

github-actions bot commented Jan 19, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 5252d32 Previous: 06831cf Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.6790 ms/op 1.7507 ms/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 47.807 us/op 46.950 us/op 1.02
BLS verify - blst 817.66 us/op 983.98 us/op 0.83
BLS verifyMultipleSignatures 3 - blst 1.1998 ms/op 1.2295 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst 1.6427 ms/op 1.8946 ms/op 0.87
BLS verifyMultipleSignatures 32 - blst 4.8627 ms/op 5.6728 ms/op 0.86
BLS verifyMultipleSignatures 64 - blst 9.0021 ms/op 11.067 ms/op 0.81
BLS verifyMultipleSignatures 128 - blst 17.015 ms/op 17.534 ms/op 0.97
BLS deserializing 10000 signatures 705.31 ms/op 696.53 ms/op 1.01
BLS deserializing 100000 signatures 7.0584 s/op 6.9720 s/op 1.01
BLS verifyMultipleSignatures - same message - 3 - blst 915.70 us/op 923.99 us/op 0.99
BLS verifyMultipleSignatures - same message - 8 - blst 999.61 us/op 1.1069 ms/op 0.90
BLS verifyMultipleSignatures - same message - 32 - blst 1.7118 ms/op 1.8766 ms/op 0.91
BLS verifyMultipleSignatures - same message - 64 - blst 2.6282 ms/op 2.6411 ms/op 1.00
BLS verifyMultipleSignatures - same message - 128 - blst 4.4329 ms/op 4.4469 ms/op 1.00
BLS aggregatePubkeys 32 - blst 20.340 us/op 19.903 us/op 1.02
BLS aggregatePubkeys 128 - blst 72.072 us/op 71.477 us/op 1.01
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 60.989 ms/op 61.814 ms/op 0.99
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 56.956 ms/op 59.550 ms/op 0.96
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 46.273 ms/op 49.640 ms/op 0.93
getSlashingsAndExits - default max 142.62 us/op 131.79 us/op 1.08
getSlashingsAndExits - 2k 518.99 us/op 434.87 us/op 1.19
proposeBlockBody type=full, size=empty 6.2370 ms/op 5.7538 ms/op 1.08
isKnown best case - 1 super set check 289.00 ns/op 269.00 ns/op 1.07
isKnown normal case - 2 super set checks 306.00 ns/op 258.00 ns/op 1.19
isKnown worse case - 16 super set checks 308.00 ns/op 259.00 ns/op 1.19
InMemoryCheckpointStateCache - add get delete 3.4120 us/op 2.5510 us/op 1.34
validate api signedAggregateAndProof - struct 1.4552 ms/op 1.4694 ms/op 0.99
validate gossip signedAggregateAndProof - struct 1.4815 ms/op 1.4483 ms/op 1.02
batch validate gossip attestation - vc 640000 - chunk 32 138.36 us/op 127.67 us/op 1.08
batch validate gossip attestation - vc 640000 - chunk 64 116.88 us/op 112.44 us/op 1.04
batch validate gossip attestation - vc 640000 - chunk 128 109.56 us/op 103.46 us/op 1.06
batch validate gossip attestation - vc 640000 - chunk 256 112.77 us/op 110.75 us/op 1.02
pickEth1Vote - no votes 1.2588 ms/op 1.0688 ms/op 1.18
pickEth1Vote - max votes 6.9946 ms/op 6.9442 ms/op 1.01
pickEth1Vote - Eth1Data hashTreeRoot value x2048 13.470 ms/op 20.736 ms/op 0.65
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.065 ms/op 25.418 ms/op 0.79
pickEth1Vote - Eth1Data fastSerialize value x2048 592.60 us/op 515.37 us/op 1.15
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.4764 ms/op 3.3694 ms/op 1.03
bytes32 toHexString 441.00 ns/op 440.00 ns/op 1.00
bytes32 Buffer.toString(hex) 254.00 ns/op 234.00 ns/op 1.09
bytes32 Buffer.toString(hex) from Uint8Array 407.00 ns/op 364.00 ns/op 1.12
bytes32 Buffer.toString(hex) + 0x 249.00 ns/op 235.00 ns/op 1.06
Object access 1 prop 0.14300 ns/op 0.12700 ns/op 1.13
Map access 1 prop 0.13100 ns/op 0.13000 ns/op 1.01
Object get x1000 6.1480 ns/op 5.7080 ns/op 1.08
Map get x1000 6.8940 ns/op 6.1850 ns/op 1.11
Object set x1000 35.457 ns/op 33.875 ns/op 1.05
Map set x1000 22.964 ns/op 23.656 ns/op 0.97
Return object 10000 times 0.30930 ns/op 0.29340 ns/op 1.05
Throw Error 10000 times 3.5433 us/op 3.3922 us/op 1.04
toHex 172.95 ns/op 174.14 ns/op 0.99
Buffer.from 165.24 ns/op 148.31 ns/op 1.11
shared Buffer 99.820 ns/op 101.62 ns/op 0.98
fastMsgIdFn sha256 / 200 bytes 2.4130 us/op 2.2980 us/op 1.05
fastMsgIdFn h32 xxhash / 200 bytes 268.00 ns/op 259.00 ns/op 1.03
fastMsgIdFn h64 xxhash / 200 bytes 296.00 ns/op 271.00 ns/op 1.09
fastMsgIdFn sha256 / 1000 bytes 8.2250 us/op 7.5540 us/op 1.09
fastMsgIdFn h32 xxhash / 1000 bytes 442.00 ns/op 396.00 ns/op 1.12
fastMsgIdFn h64 xxhash / 1000 bytes 374.00 ns/op 346.00 ns/op 1.08
fastMsgIdFn sha256 / 10000 bytes 66.085 us/op 64.768 us/op 1.02
fastMsgIdFn h32 xxhash / 10000 bytes 1.9420 us/op 1.8410 us/op 1.05
fastMsgIdFn h64 xxhash / 10000 bytes 1.2590 us/op 1.1980 us/op 1.05
send data - 1000 256B messages 12.391 ms/op 11.654 ms/op 1.06
send data - 1000 512B messages 19.812 ms/op 18.581 ms/op 1.07
send data - 1000 1024B messages 27.428 ms/op 25.561 ms/op 1.07
send data - 1000 1200B messages 26.136 ms/op 26.575 ms/op 0.98
send data - 1000 2048B messages 33.916 ms/op 33.108 ms/op 1.02
send data - 1000 4096B messages 25.503 ms/op 31.326 ms/op 0.81
send data - 1000 16384B messages 70.925 ms/op 73.747 ms/op 0.96
send data - 1000 65536B messages 227.53 ms/op 201.74 ms/op 1.13
enrSubnets - fastDeserialize 64 bits 1.0170 us/op 1.0680 us/op 0.95
enrSubnets - ssz BitVector 64 bits 371.00 ns/op 354.00 ns/op 1.05
enrSubnets - fastDeserialize 4 bits 158.00 ns/op 148.00 ns/op 1.07
enrSubnets - ssz BitVector 4 bits 360.00 ns/op 342.00 ns/op 1.05
prioritizePeers score -10:0 att 32-0.1 sync 2-0 133.22 us/op 143.77 us/op 0.93
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 151.93 us/op 180.15 us/op 0.84
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 228.60 us/op 239.65 us/op 0.95
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 405.58 us/op 395.31 us/op 1.03
prioritizePeers score 0:0 att 64-1 sync 4-1 522.34 us/op 523.13 us/op 1.00
array of 16000 items push then shift 1.6489 us/op 1.5830 us/op 1.04
LinkedList of 16000 items push then shift 7.5710 ns/op 6.9440 ns/op 1.09
array of 16000 items push then pop 118.90 ns/op 90.495 ns/op 1.31
LinkedList of 16000 items push then pop 6.9980 ns/op 6.8460 ns/op 1.02
array of 24000 items push then shift 2.4096 us/op 2.3390 us/op 1.03
LinkedList of 24000 items push then shift 7.1570 ns/op 6.9440 ns/op 1.03
array of 24000 items push then pop 124.35 ns/op 130.04 ns/op 0.96
LinkedList of 24000 items push then pop 6.8520 ns/op 7.1690 ns/op 0.96
intersect bitArray bitLen 8 6.4000 ns/op 6.5370 ns/op 0.98
intersect array and set length 8 43.036 ns/op 44.962 ns/op 0.96
intersect bitArray bitLen 128 29.603 ns/op 29.862 ns/op 0.99
intersect array and set length 128 649.97 ns/op 661.62 ns/op 0.98
bitArray.getTrueBitIndexes() bitLen 128 1.4040 us/op 1.4280 us/op 0.98
bitArray.getTrueBitIndexes() bitLen 248 2.1860 us/op 2.3110 us/op 0.95
bitArray.getTrueBitIndexes() bitLen 512 4.1610 us/op 4.5870 us/op 0.91
Buffer.concat 32 items 854.00 ns/op 855.00 ns/op 1.00
Uint8Array.set 32 items 1.9500 us/op 1.6460 us/op 1.18
Buffer.copy 2.5330 us/op 2.7200 us/op 0.93
Uint8Array.set - with subarray 2.3240 us/op 2.2170 us/op 1.05
Uint8Array.set - without subarray 1.7760 us/op 1.4700 us/op 1.21
getUint32 - dataview 223.00 ns/op 229.00 ns/op 0.97
getUint32 - manual 145.00 ns/op 153.00 ns/op 0.95
Set add up to 64 items then delete first 2.1265 us/op 2.1612 us/op 0.98
OrderedSet add up to 64 items then delete first 3.1531 us/op 3.2004 us/op 0.99
Set add up to 64 items then delete last 2.4476 us/op 2.4304 us/op 1.01
OrderedSet add up to 64 items then delete last 3.5812 us/op 3.5876 us/op 1.00
Set add up to 64 items then delete middle 2.4462 us/op 2.4918 us/op 0.98
OrderedSet add up to 64 items then delete middle 5.1542 us/op 5.1155 us/op 1.01
Set add up to 128 items then delete first 5.0731 us/op 5.1838 us/op 0.98
OrderedSet add up to 128 items then delete first 8.6381 us/op 7.5986 us/op 1.14
Set add up to 128 items then delete last 5.4426 us/op 4.8289 us/op 1.13
OrderedSet add up to 128 items then delete last 7.5708 us/op 7.2762 us/op 1.04
Set add up to 128 items then delete middle 5.1473 us/op 4.8385 us/op 1.06
OrderedSet add up to 128 items then delete middle 14.001 us/op 13.616 us/op 1.03
Set add up to 256 items then delete first 10.685 us/op 10.098 us/op 1.06
OrderedSet add up to 256 items then delete first 15.974 us/op 15.869 us/op 1.01
Set add up to 256 items then delete last 10.191 us/op 9.6884 us/op 1.05
OrderedSet add up to 256 items then delete last 16.407 us/op 14.538 us/op 1.13
Set add up to 256 items then delete middle 10.063 us/op 9.5623 us/op 1.05
OrderedSet add up to 256 items then delete middle 42.470 us/op 40.974 us/op 1.04
transfer serialized Status (84 B) 2.7020 us/op 2.5380 us/op 1.06
copy serialized Status (84 B) 1.4430 us/op 1.2440 us/op 1.16
transfer serialized SignedVoluntaryExit (112 B) 2.8790 us/op 2.5400 us/op 1.13
copy serialized SignedVoluntaryExit (112 B) 1.5630 us/op 1.2680 us/op 1.23
transfer serialized ProposerSlashing (416 B) 3.1900 us/op 2.6400 us/op 1.21
copy serialized ProposerSlashing (416 B) 1.7840 us/op 1.4000 us/op 1.27
transfer serialized Attestation (485 B) 2.5730 us/op 2.8490 us/op 0.90
copy serialized Attestation (485 B) 1.7710 us/op 1.9690 us/op 0.90
transfer serialized AttesterSlashing (33232 B) 3.0540 us/op 3.2910 us/op 0.93
copy serialized AttesterSlashing (33232 B) 4.9940 us/op 5.0310 us/op 0.99
transfer serialized Small SignedBeaconBlock (128000 B) 3.8480 us/op 4.4830 us/op 0.86
copy serialized Small SignedBeaconBlock (128000 B) 15.342 us/op 14.137 us/op 1.09
transfer serialized Avg SignedBeaconBlock (200000 B) 4.6610 us/op 4.8160 us/op 0.97
copy serialized Avg SignedBeaconBlock (200000 B) 20.505 us/op 19.553 us/op 1.05
transfer serialized BlobsSidecar (524380 B) 4.3280 us/op 4.0750 us/op 1.06
copy serialized BlobsSidecar (524380 B) 81.092 us/op 177.96 us/op 0.46
transfer serialized Big SignedBeaconBlock (1000000 B) 4.6340 us/op 4.3430 us/op 1.07
copy serialized Big SignedBeaconBlock (1000000 B) 159.33 us/op 150.86 us/op 1.06
pass gossip attestations to forkchoice per slot 2.8238 ms/op 2.7567 ms/op 1.02
forkChoice updateHead vc 100000 bc 64 eq 0 461.13 us/op 456.67 us/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 0 3.1451 ms/op 3.3429 ms/op 0.94
forkChoice updateHead vc 1000000 bc 64 eq 0 5.0956 ms/op 4.8417 ms/op 1.05
forkChoice updateHead vc 600000 bc 320 eq 0 3.1298 ms/op 2.8573 ms/op 1.10
forkChoice updateHead vc 600000 bc 1200 eq 0 2.8925 ms/op 2.8911 ms/op 1.00
forkChoice updateHead vc 600000 bc 7200 eq 0 3.9055 ms/op 3.6141 ms/op 1.08
forkChoice updateHead vc 600000 bc 64 eq 1000 10.669 ms/op 10.534 ms/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 10000 10.932 ms/op 10.486 ms/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 300000 13.873 ms/op 14.028 ms/op 0.99
computeDeltas 500000 validators 300 proto nodes 4.2921 ms/op 4.1342 ms/op 1.04
computeDeltas 500000 validators 1200 proto nodes 4.8557 ms/op 4.2797 ms/op 1.13
computeDeltas 500000 validators 7200 proto nodes 4.7515 ms/op 5.0443 ms/op 0.94
computeDeltas 750000 validators 300 proto nodes 7.2734 ms/op 6.4580 ms/op 1.13
computeDeltas 750000 validators 1200 proto nodes 6.8171 ms/op 6.4997 ms/op 1.05
computeDeltas 750000 validators 7200 proto nodes 6.3028 ms/op 6.6634 ms/op 0.95
computeDeltas 1400000 validators 300 proto nodes 11.965 ms/op 12.145 ms/op 0.99
computeDeltas 1400000 validators 1200 proto nodes 12.022 ms/op 12.664 ms/op 0.95
computeDeltas 1400000 validators 7200 proto nodes 11.729 ms/op 12.881 ms/op 0.91
computeDeltas 2100000 validators 300 proto nodes 17.274 ms/op 20.489 ms/op 0.84
computeDeltas 2100000 validators 1200 proto nodes 17.543 ms/op 19.227 ms/op 0.91
computeDeltas 2100000 validators 7200 proto nodes 16.946 ms/op 21.764 ms/op 0.78
altair processAttestation - 250000 vs - 7PWei normalcase 1.8052 ms/op 3.1560 ms/op 0.57
altair processAttestation - 250000 vs - 7PWei worstcase 2.6833 ms/op 3.9778 ms/op 0.67
altair processAttestation - setStatus - 1/6 committees join 120.30 us/op 152.67 us/op 0.79
altair processAttestation - setStatus - 1/3 committees join 233.15 us/op 285.59 us/op 0.82
altair processAttestation - setStatus - 1/2 committees join 324.01 us/op 387.68 us/op 0.84
altair processAttestation - setStatus - 2/3 committees join 430.40 us/op 517.32 us/op 0.83
altair processAttestation - setStatus - 4/5 committees join 573.59 us/op 691.87 us/op 0.83
altair processAttestation - setStatus - 100% committees join 678.81 us/op 764.08 us/op 0.89
altair processBlock - 250000 vs - 7PWei normalcase 4.1760 ms/op 5.2380 ms/op 0.80
altair processBlock - 250000 vs - 7PWei normalcase hashState 24.025 ms/op 29.182 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 34.177 ms/op 41.337 ms/op 0.83
altair processBlock - 250000 vs - 7PWei worstcase hashState 67.136 ms/op 87.230 ms/op 0.77
phase0 processBlock - 250000 vs - 7PWei normalcase 1.9890 ms/op 2.0467 ms/op 0.97
phase0 processBlock - 250000 vs - 7PWei worstcase 22.285 ms/op 26.573 ms/op 0.84
altair processEth1Data - 250000 vs - 7PWei normalcase 302.24 us/op 448.01 us/op 0.67
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.0960 us/op 11.277 us/op 0.81
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 64.759 us/op 58.652 us/op 1.10
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 16.926 us/op 23.448 us/op 0.72
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 12.064 us/op 11.999 us/op 1.01
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 184.47 us/op 229.13 us/op 0.81
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.5149 ms/op 1.9461 ms/op 0.78
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.8851 ms/op 2.1222 ms/op 0.89
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.0030 ms/op 1.9983 ms/op 1.00
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 5.0566 ms/op 6.2819 ms/op 0.80
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.8935 ms/op 2.0028 ms/op 0.95
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.4034 ms/op 6.0817 ms/op 0.72
Tree 40 250000 create 232.26 ms/op 280.07 ms/op 0.83
Tree 40 250000 get(125000) 158.14 ns/op 160.03 ns/op 0.99
Tree 40 250000 set(125000) 725.14 ns/op 702.79 ns/op 1.03
Tree 40 250000 toArray() 21.952 ms/op 21.092 ms/op 1.04
Tree 40 250000 iterate all - toArray() + loop 22.052 ms/op 20.966 ms/op 1.05
Tree 40 250000 iterate all - get(i) 59.516 ms/op 58.315 ms/op 1.02
Array 250000 create 4.1542 ms/op 3.8893 ms/op 1.07
Array 250000 clone - spread 1.5186 ms/op 1.4673 ms/op 1.03
Array 250000 get(125000) 0.43700 ns/op 0.43300 ns/op 1.01
Array 250000 set(125000) 0.46200 ns/op 0.46100 ns/op 1.00
Array 250000 iterate all - loop 101.61 us/op 103.87 us/op 0.98
phase0 afterProcessEpoch - 250000 vs - 7PWei 53.332 ms/op 52.860 ms/op 1.01
Array.fill - length 1000000 3.5893 ms/op 3.9239 ms/op 0.91
Array push - length 1000000 19.673 ms/op 21.329 ms/op 0.92
Array.get 0.29114 ns/op 0.28924 ns/op 1.01
Uint8Array.get 0.45173 ns/op 0.45635 ns/op 0.99
phase0 beforeProcessEpoch - 250000 vs - 7PWei 18.495 ms/op 21.419 ms/op 0.86
altair processEpoch - mainnet_e81889 307.66 ms/op 286.89 ms/op 1.07
mainnet_e81889 - altair beforeProcessEpoch 19.870 ms/op 18.919 ms/op 1.05
mainnet_e81889 - altair processJustificationAndFinalization 16.059 us/op 23.766 us/op 0.68
mainnet_e81889 - altair processInactivityUpdates 6.9054 ms/op 5.4120 ms/op 1.28
mainnet_e81889 - altair processRewardsAndPenalties 41.094 ms/op 53.390 ms/op 0.77
mainnet_e81889 - altair processRegistryUpdates 2.6290 us/op 4.2250 us/op 0.62
mainnet_e81889 - altair processSlashings 1.2500 us/op 626.00 ns/op 2.00
mainnet_e81889 - altair processEth1DataReset 1.2760 us/op 885.00 ns/op 1.44
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4607 ms/op 1.2921 ms/op 1.13
mainnet_e81889 - altair processSlashingsReset 4.3260 us/op 7.5750 us/op 0.57
mainnet_e81889 - altair processRandaoMixesReset 5.1250 us/op 8.0250 us/op 0.64
mainnet_e81889 - altair processHistoricalRootsUpdate 898.00 ns/op 938.00 ns/op 0.96
mainnet_e81889 - altair processParticipationFlagUpdates 2.5430 us/op 3.5730 us/op 0.71
mainnet_e81889 - altair processSyncCommitteeUpdates 1.3920 us/op 1.1900 us/op 1.17
mainnet_e81889 - altair afterProcessEpoch 51.957 ms/op 52.185 ms/op 1.00
capella processEpoch - mainnet_e217614 1.0344 s/op 1.0619 s/op 0.97
mainnet_e217614 - capella beforeProcessEpoch 70.898 ms/op 71.217 ms/op 1.00
mainnet_e217614 - capella processJustificationAndFinalization 12.034 us/op 17.484 us/op 0.69
mainnet_e217614 - capella processInactivityUpdates 17.352 ms/op 17.756 ms/op 0.98
mainnet_e217614 - capella processRewardsAndPenalties 207.81 ms/op 245.55 ms/op 0.85
mainnet_e217614 - capella processRegistryUpdates 15.619 us/op 22.987 us/op 0.68
mainnet_e217614 - capella processSlashings 552.00 ns/op 716.00 ns/op 0.77
mainnet_e217614 - capella processEth1DataReset 480.00 ns/op 601.00 ns/op 0.80
mainnet_e217614 - capella processEffectiveBalanceUpdates 14.939 ms/op 14.715 ms/op 1.02
mainnet_e217614 - capella processSlashingsReset 3.7170 us/op 5.6120 us/op 0.66
mainnet_e217614 - capella processRandaoMixesReset 5.2140 us/op 6.8050 us/op 0.77
mainnet_e217614 - capella processHistoricalRootsUpdate 764.00 ns/op 1.1240 us/op 0.68
mainnet_e217614 - capella processParticipationFlagUpdates 1.9790 us/op 1.9270 us/op 1.03
mainnet_e217614 - capella afterProcessEpoch 126.14 ms/op 123.12 ms/op 1.02
phase0 processEpoch - mainnet_e58758 270.48 ms/op 350.83 ms/op 0.77
mainnet_e58758 - phase0 beforeProcessEpoch 66.356 ms/op 81.401 ms/op 0.82
mainnet_e58758 - phase0 processJustificationAndFinalization 13.801 us/op 21.000 us/op 0.66
mainnet_e58758 - phase0 processRewardsAndPenalties 28.998 ms/op 31.468 ms/op 0.92
mainnet_e58758 - phase0 processRegistryUpdates 9.7430 us/op 12.887 us/op 0.76
mainnet_e58758 - phase0 processSlashings 521.00 ns/op 648.00 ns/op 0.80
mainnet_e58758 - phase0 processEth1DataReset 477.00 ns/op 559.00 ns/op 0.85
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1759 ms/op 1.4568 ms/op 0.81
mainnet_e58758 - phase0 processSlashingsReset 2.9650 us/op 3.2670 us/op 0.91
mainnet_e58758 - phase0 processRandaoMixesReset 4.0660 us/op 5.4580 us/op 0.74
mainnet_e58758 - phase0 processHistoricalRootsUpdate 549.00 ns/op 642.00 ns/op 0.86
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.5270 us/op 3.8330 us/op 1.18
mainnet_e58758 - phase0 afterProcessEpoch 44.832 ms/op 43.501 ms/op 1.03
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.4039 ms/op 2.1973 ms/op 0.64
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.9426 ms/op 2.7974 ms/op 0.69
altair processInactivityUpdates - 250000 normalcase 17.288 ms/op 20.705 ms/op 0.83
altair processInactivityUpdates - 250000 worstcase 16.590 ms/op 20.126 ms/op 0.82
phase0 processRegistryUpdates - 250000 normalcase 10.698 us/op 11.566 us/op 0.92
phase0 processRegistryUpdates - 250000 badcase_full_deposits 398.37 us/op 485.30 us/op 0.82
phase0 processRegistryUpdates - 250000 worstcase 0.5 120.90 ms/op 108.23 ms/op 1.12
altair processRewardsAndPenalties - 250000 normalcase 39.918 ms/op 39.966 ms/op 1.00
altair processRewardsAndPenalties - 250000 worstcase 38.395 ms/op 49.152 ms/op 0.78
phase0 getAttestationDeltas - 250000 normalcase 7.8283 ms/op 7.4544 ms/op 1.05
phase0 getAttestationDeltas - 250000 worstcase 7.8883 ms/op 6.9910 ms/op 1.13
phase0 processSlashings - 250000 worstcase 98.082 us/op 112.31 us/op 0.87
altair processSyncCommitteeUpdates - 250000 120.26 ms/op 120.03 ms/op 1.00
BeaconState.hashTreeRoot - No change 250.00 ns/op 265.00 ns/op 0.94
BeaconState.hashTreeRoot - 1 full validator 84.404 us/op 114.36 us/op 0.74
BeaconState.hashTreeRoot - 32 full validator 847.83 us/op 1.1875 ms/op 0.71
BeaconState.hashTreeRoot - 512 full validator 8.6280 ms/op 9.1215 ms/op 0.95
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 104.81 us/op 111.50 us/op 0.94
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.4219 ms/op 1.7457 ms/op 0.81
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 20.407 ms/op 19.844 ms/op 1.03
BeaconState.hashTreeRoot - 1 balances 99.067 us/op 101.91 us/op 0.97
BeaconState.hashTreeRoot - 32 balances 888.19 us/op 752.61 us/op 1.18
BeaconState.hashTreeRoot - 512 balances 8.4006 ms/op 6.9835 ms/op 1.20
BeaconState.hashTreeRoot - 250000 balances 160.70 ms/op 177.07 ms/op 0.91
aggregationBits - 2048 els - zipIndexesInBitList 24.812 us/op 24.421 us/op 1.02
byteArrayEquals 32 55.285 ns/op 53.382 ns/op 1.04
Buffer.compare 32 17.631 ns/op 17.055 ns/op 1.03
byteArrayEquals 1024 1.6083 us/op 1.5949 us/op 1.01
Buffer.compare 1024 26.351 ns/op 25.418 ns/op 1.04
byteArrayEquals 16384 25.598 us/op 25.274 us/op 1.01
Buffer.compare 16384 180.64 ns/op 192.47 ns/op 0.94
byteArrayEquals 123687377 190.67 ms/op 189.85 ms/op 1.00
Buffer.compare 123687377 6.6139 ms/op 6.7574 ms/op 0.98
byteArrayEquals 32 - diff last byte 52.557 ns/op 53.723 ns/op 0.98
Buffer.compare 32 - diff last byte 17.078 ns/op 18.233 ns/op 0.94
byteArrayEquals 1024 - diff last byte 1.5776 us/op 1.6103 us/op 0.98
Buffer.compare 1024 - diff last byte 26.070 ns/op 25.523 ns/op 1.02
byteArrayEquals 16384 - diff last byte 25.446 us/op 25.601 us/op 0.99
Buffer.compare 16384 - diff last byte 206.46 ns/op 194.22 ns/op 1.06
byteArrayEquals 123687377 - diff last byte 191.19 ms/op 193.49 ms/op 0.99
Buffer.compare 123687377 - diff last byte 7.0445 ms/op 6.3706 ms/op 1.11
byteArrayEquals 32 - random bytes 5.2780 ns/op 5.1410 ns/op 1.03
Buffer.compare 32 - random bytes 17.771 ns/op 17.104 ns/op 1.04
byteArrayEquals 1024 - random bytes 5.3390 ns/op 5.1330 ns/op 1.04
Buffer.compare 1024 - random bytes 18.007 ns/op 17.096 ns/op 1.05
byteArrayEquals 16384 - random bytes 5.2910 ns/op 5.1160 ns/op 1.03
Buffer.compare 16384 - random bytes 17.723 ns/op 17.117 ns/op 1.04
byteArrayEquals 123687377 - random bytes 6.7800 ns/op 6.4300 ns/op 1.05
Buffer.compare 123687377 - random bytes 20.320 ns/op 18.340 ns/op 1.11
regular array get 100000 times 38.752 us/op 32.877 us/op 1.18
wrappedArray get 100000 times 34.277 us/op 32.854 us/op 1.04
arrayWithProxy get 100000 times 13.196 ms/op 13.154 ms/op 1.00
ssz.Root.equals 47.464 ns/op 45.555 ns/op 1.04
byteArrayEquals 46.754 ns/op 45.045 ns/op 1.04
Buffer.compare 10.869 ns/op 10.242 ns/op 1.06
processSlot - 1 slots 14.860 us/op 13.959 us/op 1.06
processSlot - 32 slots 2.8113 ms/op 3.0562 ms/op 0.92
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.844 ms/op 39.411 ms/op 0.96
getCommitteeAssignments - req 1 vs - 250000 vc 2.2594 ms/op 2.1510 ms/op 1.05
getCommitteeAssignments - req 100 vs - 250000 vc 4.3854 ms/op 4.1608 ms/op 1.05
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6437 ms/op 4.6719 ms/op 0.99
findModifiedValidators - 10000 modified validators 291.90 ms/op 305.03 ms/op 0.96
findModifiedValidators - 1000 modified validators 205.42 ms/op 174.47 ms/op 1.18
findModifiedValidators - 100 modified validators 194.01 ms/op 169.30 ms/op 1.15
findModifiedValidators - 10 modified validators 157.67 ms/op 176.44 ms/op 0.89
findModifiedValidators - 1 modified validators 165.53 ms/op 158.91 ms/op 1.04
findModifiedValidators - no difference 169.82 ms/op 169.76 ms/op 1.00
compare ViewDUs 3.2687 s/op 3.3481 s/op 0.98
compare each validator Uint8Array 1.2763 s/op 1.6522 s/op 0.77
compare ViewDU to Uint8Array 1.1526 s/op 1.0330 s/op 1.12
migrate state 1000000 validators, 24 modified, 0 new 756.74 ms/op 747.44 ms/op 1.01
migrate state 1000000 validators, 1700 modified, 1000 new 882.26 ms/op 998.72 ms/op 0.88
migrate state 1000000 validators, 3400 modified, 2000 new 1.1215 s/op 1.2204 s/op 0.92
migrate state 1500000 validators, 24 modified, 0 new 718.03 ms/op 807.33 ms/op 0.89
migrate state 1500000 validators, 1700 modified, 1000 new 969.82 ms/op 1.1234 s/op 0.86
migrate state 1500000 validators, 3400 modified, 2000 new 1.2896 s/op 1.2723 s/op 1.01
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.1000 ns/op 4.9800 ns/op 1.02
state getBlockRootAtSlot - 250000 vs - 7PWei 664.25 ns/op 609.66 ns/op 1.09
computeProposers - vc 250000 7.6651 ms/op 8.8333 ms/op 0.87
computeEpochShuffling - vc 250000 43.934 ms/op 44.316 ms/op 0.99
getNextSyncCommittee - vc 250000 136.90 ms/op 143.98 ms/op 0.95
computeSigningRoot for AttestationData 27.557 us/op 26.277 us/op 1.05
hash AttestationData serialized data then Buffer.toString(base64) 1.6793 us/op 1.6902 us/op 0.99
toHexString serialized data 1.0126 us/op 1.0382 us/op 0.98
Buffer.toString(base64) 189.80 ns/op 208.97 ns/op 0.91
nodejs block root to RootHex using toHex 159.53 ns/op 184.02 ns/op 0.87
nodejs block root to RootHex using toRootHex 98.579 ns/op 97.967 ns/op 1.01
browser block root to RootHex using the deprecated toHexString 235.72 ns/op 240.76 ns/op 0.98
browser block root to RootHex using toHex 188.17 ns/op 183.96 ns/op 1.02
browser block root to RootHex using toRootHex 166.74 ns/op 172.11 ns/op 0.97

by benchmarkbot/action

@@ -76,6 +76,7 @@ export function processWithdrawalRequest(
withdrawableEpoch,
});
state.pendingPartialWithdrawals.push(pendingPartialWithdrawal);
state.pendingPartialWithdrawals.commit();
Copy link
Member

Choose a reason for hiding this comment

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

can we commit once across multiple withdrawal requests?
eg:

for (...) {
  processWithdrawalRequest(...);
}
state.pendingPartialWithdrawals.commit();

Copy link
Member Author

Choose a reason for hiding this comment

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

the problem is that we need to commit before we call getPendingBalanceToWithdraw

const pendingBalanceToWithdraw = getPendingBalanceToWithdraw(state, validatorIndex);

since this calls getAllReadonly

I am sure there is a better solution for this

Copy link
Member Author

Choose a reason for hiding this comment

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

so if we don't commit after we push the first withdrawal request the issue happens

Copy link
Contributor

Choose a reason for hiding this comment

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

@nflaig calling commit() at the middle of state transition is not great but this is a limitation at ssz side, we should be able to get all items without calling commit()

call state.pendingPartialWithdrawals.getAllReadonly() at the start of processWithdrawalRequest

then modify getPendingBalanceToWithdraw

let total = 0;
for (let i = 0; i < state.pendingPartialWithdrawals.length; i++) {
  const item = state.pendingPartialWithdrawals.get(i);
  if (item.validatorIndex === validatorIndex) {
    total += Number(item.amount);
  }
  
  return total;
}

performance should be the same, a unit test should help

Copy link
Member Author

@nflaig nflaig Jan 20, 2025

Choose a reason for hiding this comment

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

call state.pendingPartialWithdrawals.getAllReadonly() at the start of processWithdrawalRequest

I think this would result in the same error, we need to call it outside of this loop

for (const elWithdrawalRequest of bodyElectra.executionRequests.withdrawals) {
processWithdrawalRequest(fork, stateElectra, elWithdrawalRequest);
}

or we add something like cachedPendingPartialWithdrawals which is just a nomral array and we use that instead to check pending balance to withdraw

Copy link
Contributor

Choose a reason for hiding this comment

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

or we add something like cachedPendingPartialWithdrawals which is just a nomral array and we use that instead to check pending balance to withdraw

Yea I was thinking about something like this. And whenever state.pendingPartialWithdrawals gets updated during state transition, the cache needs to be updated manually as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

something like 582ead5 or you had somehting else in mind?

@nflaig
Copy link
Member Author

nflaig commented Jan 19, 2025

putting as draft for now until more testing is done

@nflaig nflaig marked this pull request as draft January 19, 2025 22:17
@nflaig nflaig marked this pull request as ready for review January 20, 2025 09:30
@nflaig nflaig changed the title fix: commit pending partial withdrawals after adding new entry fix: update getPendingBalanceToWithdraw to work with uncommitted pendingPartialWithdrawals Jan 20, 2025
@nflaig nflaig marked this pull request as draft January 20, 2025 12:54
@nflaig nflaig changed the title fix: update getPendingBalanceToWithdraw to work with uncommitted pendingPartialWithdrawals fix: update getPendingBalanceToWithdraw to work with uncommitted changes Jan 20, 2025
@nflaig nflaig marked this pull request as ready for review January 20, 2025 15:25
@wemeetagain wemeetagain merged commit 3eef8ea into unstable Jan 20, 2025
22 checks passed
@wemeetagain wemeetagain deleted the nflaig/fix-pending-partial-withdrawals branch January 20, 2025 21:30
wemeetagain pushed a commit that referenced this pull request Feb 3, 2025
…tation (#7419)

Since ChainSafe/ssz#456 it's possible to use
`getAllReadonly()` with uncommited changes. This PR essential reverts
changes done in #7375 as it
causes more memory allocation which is not ideal.
@wemeetagain
Copy link
Member

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

4 participants