Skip to content

feat: prune invalid SSZ objects - #5388

Merged
dapplion merged 6 commits into
unstablefrom
acuarica/prune-invalid-ssz-objects
Jun 1, 2023
Merged

feat: prune invalid SSZ objects#5388
dapplion merged 6 commits into
unstablefrom
acuarica/prune-invalid-ssz-objects

Conversation

@acuarica

@acuarica acuarica commented Apr 19, 2023

Copy link
Copy Markdown
Contributor

Motivation

This PR closes #4420. That is, it allows the user to prune old invalidSszObjects after a specified number of days.

Description

This PR adds a new CLI hidden option --persistInvalidSszObjectsRetention only applicable to beacon command. It works in conjunction with --chain.persistInvalidSszObjects and --persistInvalidSszObjectsDir.

When --chain.persistInvalidSszObjects is enabled, pruning is activated by default. However, you can disable it with --persistInvalidSszObjectsRetention 0

If --persistInvalidSszObjectsRetention is not specified, the retention period for invalid SSZ objects defaults to 7 days.

The application prunes invalid SSZ objects during start up and every hour.

Steps to test or reproduce

git checkout acuarica/prune-invalid-ssz-objects
lodestar beacon --persistInvalidSszObjectsRetention 14

@CLAassistant

CLAassistant commented Apr 19, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@acuarica
acuarica marked this pull request as ready for review April 19, 2023 15:20
@acuarica
acuarica requested a review from a team as a code owner April 19, 2023 15:20
@github-actions

github-actions Bot commented Apr 19, 2023

Copy link
Copy Markdown
Contributor

Performance Report

鉁旓笍 no performance regression detected

Full benchmark results
Benchmark suite Current: 385605c Previous: 722ccb6 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 729.79 us/op 728.86 us/op 1.00
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 43.367 us/op 44.628 us/op 0.97
BLS verify - blst-native 1.1755 ms/op 1.2393 ms/op 0.95
BLS verifyMultipleSignatures 3 - blst-native 2.3744 ms/op 2.4856 ms/op 0.96
BLS verifyMultipleSignatures 8 - blst-native 5.0927 ms/op 5.2215 ms/op 0.98
BLS verifyMultipleSignatures 32 - blst-native 18.430 ms/op 18.989 ms/op 0.97
BLS aggregatePubkeys 32 - blst-native 24.602 us/op 25.306 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 96.531 us/op 97.992 us/op 0.99
getAttestationsForBlock 51.361 ms/op 52.652 ms/op 0.98
isKnown best case - 1 super set check 252.00 ns/op 246.00 ns/op 1.02
isKnown normal case - 2 super set checks 246.00 ns/op 243.00 ns/op 1.01
isKnown worse case - 16 super set checks 247.00 ns/op 236.00 ns/op 1.05
CheckpointStateCache - add get delete 4.6850 us/op 4.8330 us/op 0.97
validate gossip signedAggregateAndProof - struct 2.6628 ms/op 2.7694 ms/op 0.96
validate gossip attestation - struct 1.2673 ms/op 1.2943 ms/op 0.98
pickEth1Vote - no votes 1.1786 ms/op 1.2253 ms/op 0.96
pickEth1Vote - max votes 10.567 ms/op 10.521 ms/op 1.00
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.5940 ms/op 8.7481 ms/op 0.98
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.572 ms/op 14.249 ms/op 1.02
pickEth1Vote - Eth1Data fastSerialize value x2048 620.86 us/op 624.69 us/op 0.99
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.5091 ms/op 7.2239 ms/op 1.04
bytes32 toHexString 476.00 ns/op 500.00 ns/op 0.95
bytes32 Buffer.toString(hex) 343.00 ns/op 346.00 ns/op 0.99
bytes32 Buffer.toString(hex) from Uint8Array 539.00 ns/op 545.00 ns/op 0.99
bytes32 Buffer.toString(hex) + 0x 342.00 ns/op 344.00 ns/op 0.99
Object access 1 prop 0.15800 ns/op 0.16200 ns/op 0.98
Map access 1 prop 0.15500 ns/op 0.16100 ns/op 0.96
Object get x1000 6.4980 ns/op 6.4650 ns/op 1.01
Map get x1000 0.59000 ns/op 0.62500 ns/op 0.94
Object set x1000 50.816 ns/op 51.659 ns/op 0.98
Map set x1000 43.031 ns/op 43.017 ns/op 1.00
Return object 10000 times 0.23050 ns/op 0.23390 ns/op 0.99
Throw Error 10000 times 4.0624 us/op 4.1446 us/op 0.98
fastMsgIdFn sha256 / 200 bytes 3.3610 us/op 3.3970 us/op 0.99
fastMsgIdFn h32 xxhash / 200 bytes 274.00 ns/op 277.00 ns/op 0.99
fastMsgIdFn h64 xxhash / 200 bytes 388.00 ns/op 398.00 ns/op 0.97
fastMsgIdFn sha256 / 1000 bytes 11.452 us/op 11.471 us/op 1.00
fastMsgIdFn h32 xxhash / 1000 bytes 398.00 ns/op 406.00 ns/op 0.98
fastMsgIdFn h64 xxhash / 1000 bytes 459.00 ns/op 458.00 ns/op 1.00
fastMsgIdFn sha256 / 10000 bytes 101.86 us/op 102.70 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 1.8900 us/op 1.9060 us/op 0.99
fastMsgIdFn h64 xxhash / 10000 bytes 1.3520 us/op 1.3530 us/op 1.00
enrSubnets - fastDeserialize 64 bits 1.2570 us/op 1.2600 us/op 1.00
enrSubnets - ssz BitVector 64 bits 491.00 ns/op 489.00 ns/op 1.00
enrSubnets - fastDeserialize 4 bits 173.00 ns/op 172.00 ns/op 1.01
enrSubnets - ssz BitVector 4 bits 497.00 ns/op 493.00 ns/op 1.01
prioritizePeers score -10:0 att 32-0.1 sync 2-0 103.43 us/op 103.95 us/op 0.99
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 130.97 us/op 129.53 us/op 1.01
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 166.91 us/op 165.79 us/op 1.01
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 297.81 us/op 298.82 us/op 1.00
prioritizePeers score 0:0 att 64-1 sync 4-1 355.54 us/op 360.98 us/op 0.98
array of 16000 items push then shift 1.5363 us/op 1.6580 us/op 0.93
LinkedList of 16000 items push then shift 8.4020 ns/op 8.8210 ns/op 0.95
array of 16000 items push then pop 82.342 ns/op 82.299 ns/op 1.00
LinkedList of 16000 items push then pop 8.3650 ns/op 8.6370 ns/op 0.97
array of 24000 items push then shift 2.3344 us/op 2.3924 us/op 0.98
LinkedList of 24000 items push then shift 8.6080 ns/op 8.6950 ns/op 0.99
array of 24000 items push then pop 74.353 ns/op 83.976 ns/op 0.89
LinkedList of 24000 items push then pop 8.3000 ns/op 8.4630 ns/op 0.98
intersect bitArray bitLen 8 12.995 ns/op 13.113 ns/op 0.99
intersect array and set length 8 75.769 ns/op 73.888 ns/op 1.03
intersect bitArray bitLen 128 43.276 ns/op 43.466 ns/op 1.00
intersect array and set length 128 1.0282 us/op 1.0228 us/op 1.01
Buffer.concat 32 items 2.7770 us/op 2.5800 us/op 1.08
Uint8Array.set 32 items 2.8000 us/op 2.4500 us/op 1.14
transfer serialized Status (84 B) 1.9180 us/op 1.9770 us/op 0.97
copy serialized Status (84 B) 1.7370 us/op 1.6750 us/op 1.04
transfer serialized SignedVoluntaryExit (112 B) 2.0980 us/op 2.0540 us/op 1.02
copy serialized SignedVoluntaryExit (112 B) 1.7680 us/op 1.7110 us/op 1.03
transfer serialized ProposerSlashing (416 B) 2.7380 us/op 2.2000 us/op 1.24
copy serialized ProposerSlashing (416 B) 2.8830 us/op 2.2950 us/op 1.26
transfer serialized Attestation (485 B) 2.7470 us/op 2.5990 us/op 1.06
copy serialized Attestation (485 B) 2.9890 us/op 2.2450 us/op 1.33
transfer serialized AttesterSlashing (33232 B) 2.8930 us/op 2.6760 us/op 1.08
copy serialized AttesterSlashing (33232 B) 6.0690 us/op 5.7680 us/op 1.05
transfer serialized Small SignedBeaconBlock (128000 B) 3.1190 us/op 3.0380 us/op 1.03
copy serialized Small SignedBeaconBlock (128000 B) 13.006 us/op 15.382 us/op 0.85
transfer serialized Avg SignedBeaconBlock (200000 B) 3.6000 us/op 3.2850 us/op 1.10
copy serialized Avg SignedBeaconBlock (200000 B) 56.563 us/op 22.363 us/op 2.53
transfer serialized BlobsSidecar (524380 B) 3.3280 us/op 3.1010 us/op 1.07
copy serialized BlobsSidecar (524380 B) 123.95 us/op 68.216 us/op 1.82
transfer serialized Big SignedBeaconBlock (1000000 B) 3.3330 us/op 3.1320 us/op 1.06
copy serialized Big SignedBeaconBlock (1000000 B) 241.83 us/op 297.08 us/op 0.81
pass gossip attestations to forkchoice per slot 2.1959 ms/op 2.2307 ms/op 0.98
computeDeltas 3.4692 ms/op 3.6547 ms/op 0.95
computeProposerBoostScoreFromBalances 1.7642 ms/op 1.7405 ms/op 1.01
altair processAttestation - 250000 vs - 7PWei normalcase 2.1396 ms/op 2.0971 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei worstcase 3.2366 ms/op 3.2743 ms/op 0.99
altair processAttestation - setStatus - 1/6 committees join 135.39 us/op 143.99 us/op 0.94
altair processAttestation - setStatus - 1/3 committees join 268.98 us/op 274.56 us/op 0.98
altair processAttestation - setStatus - 1/2 committees join 355.92 us/op 372.71 us/op 0.95
altair processAttestation - setStatus - 2/3 committees join 455.50 us/op 477.13 us/op 0.95
altair processAttestation - setStatus - 4/5 committees join 634.38 us/op 662.58 us/op 0.96
altair processAttestation - setStatus - 100% committees join 744.76 us/op 773.64 us/op 0.96
altair processBlock - 250000 vs - 7PWei normalcase 18.215 ms/op 16.286 ms/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase hashState 27.440 ms/op 25.223 ms/op 1.09
altair processBlock - 250000 vs - 7PWei worstcase 49.396 ms/op 49.227 ms/op 1.00
altair processBlock - 250000 vs - 7PWei worstcase hashState 66.502 ms/op 67.754 ms/op 0.98
phase0 processBlock - 250000 vs - 7PWei normalcase 2.0366 ms/op 2.3432 ms/op 0.87
phase0 processBlock - 250000 vs - 7PWei worstcase 27.490 ms/op 31.834 ms/op 0.86
altair processEth1Data - 250000 vs - 7PWei normalcase 501.53 us/op 525.12 us/op 0.96
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 6.9610 us/op 8.1860 us/op 0.85
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 19.822 us/op 23.616 us/op 0.84
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 8.5770 us/op 11.117 us/op 0.77
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.5540 us/op 7.1780 us/op 0.91
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 75.328 us/op 115.45 us/op 0.65
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 595.55 us/op 666.30 us/op 0.89
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 873.08 us/op 912.03 us/op 0.96
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 844.21 us/op 883.89 us/op 0.96
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.1635 ms/op 2.2979 ms/op 0.94
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.4774 ms/op 1.7202 ms/op 0.86
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.7036 ms/op 4.4563 ms/op 0.83
Tree 40 250000 create 296.90 ms/op 309.69 ms/op 0.96
Tree 40 250000 get(125000) 181.05 ns/op 195.49 ns/op 0.93
Tree 40 250000 set(125000) 904.27 ns/op 949.53 ns/op 0.95
Tree 40 250000 toArray() 17.099 ms/op 19.376 ms/op 0.88
Tree 40 250000 iterate all - toArray() + loop 17.381 ms/op 19.049 ms/op 0.91
Tree 40 250000 iterate all - get(i) 64.225 ms/op 71.047 ms/op 0.90
MutableVector 250000 create 9.6463 ms/op 11.487 ms/op 0.84
MutableVector 250000 get(125000) 6.1230 ns/op 6.6030 ns/op 0.93
MutableVector 250000 set(125000) 234.31 ns/op 261.81 ns/op 0.89
MutableVector 250000 toArray() 2.6387 ms/op 2.8325 ms/op 0.93
MutableVector 250000 iterate all - toArray() + loop 2.6718 ms/op 3.0134 ms/op 0.89
MutableVector 250000 iterate all - get(i) 1.4522 ms/op 1.5208 ms/op 0.95
Array 250000 create 2.4378 ms/op 2.7270 ms/op 0.89
Array 250000 clone - spread 1.1130 ms/op 1.2463 ms/op 0.89
Array 250000 get(125000) 0.54200 ns/op 0.61300 ns/op 0.88
Array 250000 set(125000) 0.61200 ns/op 0.67900 ns/op 0.90
Array 250000 iterate all - loop 78.313 us/op 83.382 us/op 0.94
effectiveBalanceIncrements clone Uint8Array 300000 27.283 us/op 30.448 us/op 0.90
effectiveBalanceIncrements clone MutableVector 300000 347.00 ns/op 384.00 ns/op 0.90
effectiveBalanceIncrements rw all Uint8Array 300000 160.34 us/op 169.56 us/op 0.95
effectiveBalanceIncrements rw all MutableVector 300000 76.702 ms/op 85.856 ms/op 0.89
phase0 afterProcessEpoch - 250000 vs - 7PWei 110.15 ms/op 113.04 ms/op 0.97
phase0 beforeProcessEpoch - 250000 vs - 7PWei 40.921 ms/op 41.678 ms/op 0.98
altair processEpoch - mainnet_e81889 316.45 ms/op 327.58 ms/op 0.97
mainnet_e81889 - altair beforeProcessEpoch 50.555 ms/op 51.725 ms/op 0.98
mainnet_e81889 - altair processJustificationAndFinalization 16.334 us/op 18.343 us/op 0.89
mainnet_e81889 - altair processInactivityUpdates 5.2242 ms/op 5.5663 ms/op 0.94
mainnet_e81889 - altair processRewardsAndPenalties 69.151 ms/op 65.967 ms/op 1.05
mainnet_e81889 - altair processRegistryUpdates 2.6270 us/op 3.5820 us/op 0.73
mainnet_e81889 - altair processSlashings 461.00 ns/op 572.00 ns/op 0.81
mainnet_e81889 - altair processEth1DataReset 597.00 ns/op 528.00 ns/op 1.13
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2447 ms/op 1.2160 ms/op 1.02
mainnet_e81889 - altair processSlashingsReset 4.2500 us/op 5.0430 us/op 0.84
mainnet_e81889 - altair processRandaoMixesReset 5.0440 us/op 4.7260 us/op 1.07
mainnet_e81889 - altair processHistoricalRootsUpdate 721.00 ns/op 574.00 ns/op 1.26
mainnet_e81889 - altair processParticipationFlagUpdates 2.8880 us/op 2.3030 us/op 1.25
mainnet_e81889 - altair processSyncCommitteeUpdates 500.00 ns/op 504.00 ns/op 0.99
mainnet_e81889 - altair afterProcessEpoch 125.20 ms/op 117.97 ms/op 1.06
phase0 processEpoch - mainnet_e58758 370.06 ms/op 317.63 ms/op 1.17
mainnet_e58758 - phase0 beforeProcessEpoch 147.41 ms/op 124.62 ms/op 1.18
mainnet_e58758 - phase0 processJustificationAndFinalization 17.822 us/op 16.125 us/op 1.11
mainnet_e58758 - phase0 processRewardsAndPenalties 63.810 ms/op 54.714 ms/op 1.17
mainnet_e58758 - phase0 processRegistryUpdates 8.0980 us/op 7.5570 us/op 1.07
mainnet_e58758 - phase0 processSlashings 979.00 ns/op 506.00 ns/op 1.93
mainnet_e58758 - phase0 processEth1DataReset 571.00 ns/op 550.00 ns/op 1.04
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.3357 ms/op 993.96 us/op 1.34
mainnet_e58758 - phase0 processSlashingsReset 4.5370 us/op 2.8370 us/op 1.60
mainnet_e58758 - phase0 processRandaoMixesReset 9.7820 us/op 4.5690 us/op 2.14
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.2570 us/op 603.00 ns/op 2.08
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.9780 us/op 3.7570 us/op 1.32
mainnet_e58758 - phase0 afterProcessEpoch 104.12 ms/op 97.232 ms/op 1.07
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3250 ms/op 1.2597 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5267 ms/op 1.4353 ms/op 1.06
altair processInactivityUpdates - 250000 normalcase 30.601 ms/op 20.523 ms/op 1.49
altair processInactivityUpdates - 250000 worstcase 29.185 ms/op 22.327 ms/op 1.31
phase0 processRegistryUpdates - 250000 normalcase 12.617 us/op 7.2200 us/op 1.75
phase0 processRegistryUpdates - 250000 badcase_full_deposits 297.30 us/op 241.23 us/op 1.23
phase0 processRegistryUpdates - 250000 worstcase 0.5 162.32 ms/op 114.28 ms/op 1.42
altair processRewardsAndPenalties - 250000 normalcase 75.202 ms/op 54.361 ms/op 1.38
altair processRewardsAndPenalties - 250000 worstcase 82.085 ms/op 60.451 ms/op 1.36
phase0 getAttestationDeltas - 250000 normalcase 11.573 ms/op 6.4935 ms/op 1.78
phase0 getAttestationDeltas - 250000 worstcase 10.275 ms/op 6.3958 ms/op 1.61
phase0 processSlashings - 250000 worstcase 4.0159 ms/op 3.5975 ms/op 1.12
altair processSyncCommitteeUpdates - 250000 186.91 ms/op 168.30 ms/op 1.11
BeaconState.hashTreeRoot - No change 355.00 ns/op 265.00 ns/op 1.34
BeaconState.hashTreeRoot - 1 full validator 53.490 us/op 50.956 us/op 1.05
BeaconState.hashTreeRoot - 32 full validator 590.62 us/op 502.57 us/op 1.18
BeaconState.hashTreeRoot - 512 full validator 5.5278 ms/op 4.9597 ms/op 1.11
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 67.795 us/op 60.772 us/op 1.12
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 915.46 us/op 873.71 us/op 1.05
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.352 ms/op 11.262 ms/op 1.19
BeaconState.hashTreeRoot - 1 balances 58.187 us/op 46.080 us/op 1.26
BeaconState.hashTreeRoot - 32 balances 466.33 us/op 474.18 us/op 0.98
BeaconState.hashTreeRoot - 512 balances 4.7136 ms/op 4.1359 ms/op 1.14
BeaconState.hashTreeRoot - 250000 balances 76.389 ms/op 72.599 ms/op 1.05
aggregationBits - 2048 els - zipIndexesInBitList 18.862 us/op 15.570 us/op 1.21
regular array get 100000 times 44.990 us/op 32.326 us/op 1.39
wrappedArray get 100000 times 33.550 us/op 32.232 us/op 1.04
arrayWithProxy get 100000 times 17.157 ms/op 15.601 ms/op 1.10
ssz.Root.equals 569.00 ns/op 537.00 ns/op 1.06
byteArrayEquals 545.00 ns/op 529.00 ns/op 1.03
shuffle list - 16384 els 7.0885 ms/op 6.7324 ms/op 1.05
shuffle list - 250000 els 102.85 ms/op 98.356 ms/op 1.05
processSlot - 1 slots 8.5250 us/op 8.7520 us/op 0.97
processSlot - 32 slots 1.3385 ms/op 1.3359 ms/op 1.00
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 36.186 ms/op 33.308 ms/op 1.09
getCommitteeAssignments - req 1 vs - 250000 vc 2.9242 ms/op 2.8824 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 4.1450 ms/op 4.0952 ms/op 1.01
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5110 ms/op 4.5345 ms/op 0.99
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.8300 ns/op 4.5700 ns/op 1.06
state getBlockRootAtSlot - 250000 vs - 7PWei 572.46 ns/op 907.60 ns/op 0.63
computeProposers - vc 250000 10.295 ms/op 10.290 ms/op 1.00
computeEpochShuffling - vc 250000 103.43 ms/op 103.70 ms/op 1.00
getNextSyncCommittee - vc 250000 173.35 ms/op 182.63 ms/op 0.95
computeSigningRoot for AttestationData 13.450 us/op 13.310 us/op 1.01
hash AttestationData serialized data then Buffer.toString(base64) 2.4390 us/op 2.3731 us/op 1.03
toHexString serialized data 1.0793 us/op 1.0702 us/op 1.01
Buffer.toString(base64) 315.83 ns/op 319.05 ns/op 0.99

by benchmarkbot/action

Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
@acuarica

Copy link
Copy Markdown
Contributor Author

Hey @wemeetagain, thanks for your comments. I addressed all of them and left a question.

@dapplion dapplion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good start! Main comment about moving code to CLI package

Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/node/nodejs.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated
Comment thread packages/beacon-node/src/chain/chain.ts Outdated

@nflaig nflaig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some basic unit tests for this would be good to make sure files are deleted correctly and errors are handled

Comment thread packages/beacon-node/src/node/nodejs.ts Outdated
@dapplion
dapplion force-pushed the acuarica/prune-invalid-ssz-objects branch from 189dd50 to d17f200 Compare May 29, 2023 12:54
@dapplion dapplion changed the title Prune invalid SSZ objects feat: prune invalid SSZ objects May 29, 2023
@dapplion

Copy link
Copy Markdown
Contributor

Redone, now with code in beacon handler only

// dev debug option to have access to the BN instance
if (args.attachToGlobalThis) {
(globalThis as unknown as {bn: BeaconNode}).bn = node;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added comment and this section of code is getting crowded

@dapplion
dapplion force-pushed the acuarica/prune-invalid-ssz-objects branch from d17f200 to 9d800ef Compare May 29, 2023 12:57
dapplion
dapplion previously approved these changes May 29, 2023
Comment thread packages/cli/src/cmds/beacon/handler.ts
@nflaig
nflaig force-pushed the acuarica/prune-invalid-ssz-objects branch from 639c878 to d1215f2 Compare May 29, 2023 19:34
nflaig
nflaig previously approved these changes May 29, 2023
if (stat.isDirectory()) {
pruneOldFilesInDir(entryPath, maxAgeMs);
} else if (stat.isFile()) {
if (Date.now() - stat.mtimeMs > maxAgeMs) {

@nflaig nflaig May 29, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changed from cTimeMs to mtimeMs as can't manipulate creation time from within Nodejs which makes it hard to test.

I am not sure what is technically more correct. Currently, it should not matter for ssz objects because I would assume those are just written once and not modified.

For more general purpose, I would not consider a file which was just recently modified "old" so might be anyways better to use mTimeMs

Comment thread packages/cli/src/cmds/beacon/handler.ts
@nflaig
nflaig force-pushed the acuarica/prune-invalid-ssz-objects branch 2 times, most recently from 17c6fce to 9380aa6 Compare May 29, 2023 19:44
@nflaig
nflaig force-pushed the acuarica/prune-invalid-ssz-objects branch from 9380aa6 to dd671c5 Compare May 29, 2023 19:51
@dapplion
dapplion dismissed wemeetagain鈥檚 stale review June 1, 2023 07:43

Changes addressed

@dapplion
dapplion merged commit e2e5417 into unstable Jun 1, 2023
@dapplion
dapplion deleted the acuarica/prune-invalid-ssz-objects branch June 1, 2023 07:43
@wemeetagain

Copy link
Copy Markdown
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.

Prune old invalidSszObjects every some interval

5 participants