Skip to content

Use state dialed to attestation target epoch#4849

Merged
wemeetagain merged 1 commit intounstablefrom
dapplion/fix-validateGossipAttestation
Dec 5, 2022
Merged

Use state dialed to attestation target epoch#4849
wemeetagain merged 1 commit intounstablefrom
dapplion/fix-validateGossipAttestation

Conversation

@dapplion
Copy link
Contributor

@dapplion dapplion commented Dec 5, 2022

Motivation

In practice this can only affect attestation verification if there's a full epoch of missed slots, or the first slot of a new fork is missed. It showed up in testing because a block processing error caused the first block of eip-4844 fork to be missed.

Description

  • Use state dialed to attestation target epoch

@dapplion dapplion requested a review from a team as a code owner December 5, 2022 09:03
@wemeetagain wemeetagain closed this Dec 5, 2022
@wemeetagain wemeetagain reopened this Dec 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: fd31a4b Previous: 337f2fc Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.7884 ms/op 2.4806 ms/op 0.72
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 63.070 us/op 91.411 us/op 0.69
BLS verify - blst-native 2.1756 ms/op 2.2266 ms/op 0.98
BLS verifyMultipleSignatures 3 - blst-native 4.4910 ms/op 4.5786 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst-native 9.7167 ms/op 9.8580 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 35.343 ms/op 36.031 ms/op 0.98
BLS aggregatePubkeys 32 - blst-native 46.544 us/op 47.103 us/op 0.99
BLS aggregatePubkeys 128 - blst-native 182.16 us/op 183.99 us/op 0.99
getAttestationsForBlock 78.892 ms/op 113.93 ms/op 0.69
isKnown best case - 1 super set check 462.00 ns/op 514.00 ns/op 0.90
isKnown normal case - 2 super set checks 452.00 ns/op 500.00 ns/op 0.90
isKnown worse case - 16 super set checks 450.00 ns/op 501.00 ns/op 0.90
CheckpointStateCache - add get delete 8.8260 us/op 11.109 us/op 0.79
validate gossip signedAggregateAndProof - struct 5.0339 ms/op 5.2257 ms/op 0.96
validate gossip attestation - struct 2.3745 ms/op 2.4369 ms/op 0.97
pickEth1Vote - no votes 2.2884 ms/op 2.7428 ms/op 0.83
pickEth1Vote - max votes 18.788 ms/op 25.480 ms/op 0.74
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.484 ms/op 13.943 ms/op 0.90
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.704 ms/op 25.625 ms/op 0.81
pickEth1Vote - Eth1Data fastSerialize value x2048 1.4424 ms/op 1.8540 ms/op 0.78
pickEth1Vote - Eth1Data fastSerialize tree x2048 12.075 ms/op 17.300 ms/op 0.70
bytes32 toHexString 929.00 ns/op 1.3570 us/op 0.68
bytes32 Buffer.toString(hex) 765.00 ns/op 827.00 ns/op 0.93
bytes32 Buffer.toString(hex) from Uint8Array 1.0110 us/op 1.1690 us/op 0.86
bytes32 Buffer.toString(hex) + 0x 796.00 ns/op 830.00 ns/op 0.96
Object access 1 prop 0.35200 ns/op 0.46400 ns/op 0.76
Map access 1 prop 0.31100 ns/op 0.35300 ns/op 0.88
Object get x1000 11.087 ns/op 20.951 ns/op 0.53
Map get x1000 1.0460 ns/op 1.2030 ns/op 0.87
Object set x1000 71.894 ns/op 144.35 ns/op 0.50
Map set x1000 47.094 ns/op 88.747 ns/op 0.53
Return object 10000 times 0.43270 ns/op 0.44680 ns/op 0.97
Throw Error 10000 times 5.9605 us/op 7.1266 us/op 0.84
fastMsgIdFn sha256 / 200 bytes 4.8930 us/op 5.0520 us/op 0.97
fastMsgIdFn h32 xxhash / 200 bytes 558.00 ns/op 682.00 ns/op 0.82
fastMsgIdFn h64 xxhash / 200 bytes 815.00 ns/op 892.00 ns/op 0.91
fastMsgIdFn sha256 / 1000 bytes 15.359 us/op 15.718 us/op 0.98
fastMsgIdFn h32 xxhash / 1000 bytes 736.00 ns/op 877.00 ns/op 0.84
fastMsgIdFn h64 xxhash / 1000 bytes 858.00 ns/op 1.0640 us/op 0.81
fastMsgIdFn sha256 / 10000 bytes 133.79 us/op 134.50 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 2.6550 us/op 2.7980 us/op 0.95
fastMsgIdFn h64 xxhash / 10000 bytes 1.9340 us/op 2.2010 us/op 0.88
enrSubnets - fastDeserialize 64 bits 2.7380 us/op 3.5010 us/op 0.78
enrSubnets - ssz BitVector 64 bits 780.00 ns/op 959.00 ns/op 0.81
enrSubnets - fastDeserialize 4 bits 381.00 ns/op 505.00 ns/op 0.75
enrSubnets - ssz BitVector 4 bits 835.00 ns/op 965.00 ns/op 0.87
prioritizePeers score -10:0 att 32-0.1 sync 2-0 89.616 us/op 116.89 us/op 0.77
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 120.24 us/op 146.15 us/op 0.82
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 196.68 us/op 262.12 us/op 0.75
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 402.74 us/op 553.11 us/op 0.73
prioritizePeers score 0:0 att 64-1 sync 4-1 442.35 us/op 546.80 us/op 0.81
RateTracker 1000000 limit, 1 obj count per request 189.58 ns/op 229.35 ns/op 0.83
RateTracker 1000000 limit, 2 obj count per request 139.00 ns/op 171.71 ns/op 0.81
RateTracker 1000000 limit, 4 obj count per request 112.01 ns/op 150.53 ns/op 0.74
RateTracker 1000000 limit, 8 obj count per request 98.296 ns/op 131.16 ns/op 0.75
RateTracker with prune 3.7990 us/op 5.5330 us/op 0.69
array of 16000 items push then shift 51.598 us/op 3.2807 us/op 15.73
LinkedList of 16000 items push then shift 12.324 ns/op 19.938 ns/op 0.62
array of 16000 items push then pop 204.72 ns/op 267.73 ns/op 0.76
LinkedList of 16000 items push then pop 12.522 ns/op 19.160 ns/op 0.65
array of 24000 items push then shift 77.374 us/op 4.7001 us/op 16.46
LinkedList of 24000 items push then shift 12.342 ns/op 23.467 ns/op 0.53
array of 24000 items push then pop 190.88 ns/op 249.16 ns/op 0.77
LinkedList of 24000 items push then pop 12.113 ns/op 20.618 ns/op 0.59
intersect bitArray bitLen 8 10.668 ns/op 13.670 ns/op 0.78
intersect array and set length 8 132.30 ns/op 205.46 ns/op 0.64
intersect bitArray bitLen 128 57.950 ns/op 85.884 ns/op 0.67
intersect array and set length 128 1.7417 us/op 2.7100 us/op 0.64
Buffer.concat 32 items 1.8210 ns/op 2.3110 ns/op 0.79
pass gossip attestations to forkchoice per slot 3.6272 ms/op 4.8434 ms/op 0.75
computeDeltas 4.6930 ms/op 7.1264 ms/op 0.66
computeProposerBoostScoreFromBalances 803.88 us/op 1.1009 ms/op 0.73
altair processAttestation - 250000 vs - 7PWei normalcase 3.2931 ms/op 4.7863 ms/op 0.69
altair processAttestation - 250000 vs - 7PWei worstcase 5.2489 ms/op 7.0351 ms/op 0.75
altair processAttestation - setStatus - 1/6 committees join 182.98 us/op 241.83 us/op 0.76
altair processAttestation - setStatus - 1/3 committees join 353.12 us/op 468.08 us/op 0.75
altair processAttestation - setStatus - 1/2 committees join 507.96 us/op 673.93 us/op 0.75
altair processAttestation - setStatus - 2/3 committees join 665.93 us/op 871.26 us/op 0.76
altair processAttestation - setStatus - 4/5 committees join 930.96 us/op 1.2113 ms/op 0.77
altair processAttestation - setStatus - 100% committees join 1.1295 ms/op 1.3944 ms/op 0.81
altair processBlock - 250000 vs - 7PWei normalcase 27.257 ms/op 33.038 ms/op 0.83
altair processBlock - 250000 vs - 7PWei normalcase hashState 35.483 ms/op 45.173 ms/op 0.79
altair processBlock - 250000 vs - 7PWei worstcase 81.859 ms/op 95.901 ms/op 0.85
altair processBlock - 250000 vs - 7PWei worstcase hashState 108.37 ms/op 115.41 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2192 ms/op 4.4010 ms/op 0.73
phase0 processBlock - 250000 vs - 7PWei worstcase 50.500 ms/op 55.636 ms/op 0.91
altair processEth1Data - 250000 vs - 7PWei normalcase 710.97 us/op 1.0622 ms/op 0.67
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 6.7380 us/op 11.467 us/op 0.59
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 20.936 us/op 30.190 us/op 0.69
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 11.831 us/op 16.437 us/op 0.72
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 9.7150 us/op 13.598 us/op 0.71
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 86.427 us/op 128.67 us/op 0.67
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 932.26 us/op 1.3103 ms/op 0.71
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 141069 11.419 ms/op 17.198 ms/op 0.66
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 250000 21.313 ms/op 29.885 ms/op 0.71
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 250000 69.639 ms/op 99.533 ms/op 0.70
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 250000 36.124 ms/op 57.888 ms/op 0.62
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 250000 117.23 ms/op 159.51 ms/op 0.73
Tree 40 250000 create 690.16 ms/op 955.24 ms/op 0.72
Tree 40 250000 get(125000) 239.04 ns/op 344.95 ns/op 0.69
Tree 40 250000 set(125000) 2.2949 us/op 2.8558 us/op 0.80
Tree 40 250000 toArray() 27.337 ms/op 36.172 ms/op 0.76
Tree 40 250000 iterate all - toArray() + loop 27.929 ms/op 36.925 ms/op 0.76
Tree 40 250000 iterate all - get(i) 113.12 ms/op 131.24 ms/op 0.86
MutableVector 250000 create 14.565 ms/op 18.383 ms/op 0.79
MutableVector 250000 get(125000) 11.121 ns/op 18.104 ns/op 0.61
MutableVector 250000 set(125000) 596.25 ns/op 823.19 ns/op 0.72
MutableVector 250000 toArray() 5.9785 ms/op 8.7494 ms/op 0.68
MutableVector 250000 iterate all - toArray() + loop 6.0982 ms/op 9.0344 ms/op 0.67
MutableVector 250000 iterate all - get(i) 2.7987 ms/op 4.1771 ms/op 0.67
Array 250000 create 5.8774 ms/op 8.1732 ms/op 0.72
Array 250000 clone - spread 2.5976 ms/op 4.6038 ms/op 0.56
Array 250000 get(125000) 1.1520 ns/op 2.0290 ns/op 0.57
Array 250000 set(125000) 1.1350 ns/op 1.9640 ns/op 0.58
Array 250000 iterate all - loop 150.90 us/op 200.84 us/op 0.75
effectiveBalanceIncrements clone Uint8Array 300000 165.45 us/op 114.09 us/op 1.45
effectiveBalanceIncrements clone MutableVector 300000 705.00 ns/op 1.5850 us/op 0.44
effectiveBalanceIncrements rw all Uint8Array 300000 247.53 us/op 303.07 us/op 0.82
effectiveBalanceIncrements rw all MutableVector 300000 140.68 ms/op 288.97 ms/op 0.49
phase0 afterProcessEpoch - 250000 vs - 7PWei 186.77 ms/op 215.47 ms/op 0.87
phase0 beforeProcessEpoch - 250000 vs - 7PWei 59.645 ms/op 79.367 ms/op 0.75
altair processEpoch - mainnet_e81889 572.38 ms/op 594.71 ms/op 0.96
mainnet_e81889 - altair beforeProcessEpoch 122.00 ms/op 160.87 ms/op 0.76
mainnet_e81889 - altair processJustificationAndFinalization 16.980 us/op 27.162 us/op 0.63
mainnet_e81889 - altair processInactivityUpdates 8.8649 ms/op 13.238 ms/op 0.67
mainnet_e81889 - altair processRewardsAndPenalties 125.27 ms/op 108.95 ms/op 1.15
mainnet_e81889 - altair processRegistryUpdates 3.6550 us/op 9.1080 us/op 0.40
mainnet_e81889 - altair processSlashings 774.00 ns/op 1.4870 us/op 0.52
mainnet_e81889 - altair processEth1DataReset 860.00 ns/op 1.8480 us/op 0.47
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.2427 ms/op 2.8938 ms/op 0.77
mainnet_e81889 - altair processSlashingsReset 6.4640 us/op 12.595 us/op 0.51
mainnet_e81889 - altair processRandaoMixesReset 5.7610 us/op 11.015 us/op 0.52
mainnet_e81889 - altair processHistoricalRootsUpdate 1.5020 us/op 2.0450 us/op 0.73
mainnet_e81889 - altair processParticipationFlagUpdates 2.8140 us/op 7.1930 us/op 0.39
mainnet_e81889 - altair processSyncCommitteeUpdates 682.00 ns/op 1.5530 us/op 0.44
mainnet_e81889 - altair afterProcessEpoch 219.92 ms/op 235.37 ms/op 0.93
phase0 processEpoch - mainnet_e58758 627.17 ms/op 691.35 ms/op 0.91
mainnet_e58758 - phase0 beforeProcessEpoch 225.74 ms/op 235.91 ms/op 0.96
mainnet_e58758 - phase0 processJustificationAndFinalization 21.158 us/op 26.352 us/op 0.80
mainnet_e58758 - phase0 processRewardsAndPenalties 125.34 ms/op 94.537 ms/op 1.33
mainnet_e58758 - phase0 processRegistryUpdates 10.048 us/op 16.067 us/op 0.63
mainnet_e58758 - phase0 processSlashings 766.00 ns/op 1.6580 us/op 0.46
mainnet_e58758 - phase0 processEth1DataReset 873.00 ns/op 1.7160 us/op 0.51
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.0019 ms/op 2.4006 ms/op 0.83
mainnet_e58758 - phase0 processSlashingsReset 5.8020 us/op 8.0980 us/op 0.72
mainnet_e58758 - phase0 processRandaoMixesReset 5.4700 us/op 10.858 us/op 0.50
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.0790 us/op 2.1240 us/op 0.51
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.2740 us/op 10.485 us/op 0.41
mainnet_e58758 - phase0 afterProcessEpoch 163.31 ms/op 187.17 ms/op 0.87
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.9988 ms/op 3.0377 ms/op 0.66
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.3336 ms/op 4.2684 ms/op 0.55
altair processInactivityUpdates - 250000 normalcase 54.696 ms/op 49.588 ms/op 1.10
altair processInactivityUpdates - 250000 worstcase 54.007 ms/op 59.751 ms/op 0.90
phase0 processRegistryUpdates - 250000 normalcase 8.9340 us/op 14.407 us/op 0.62
phase0 processRegistryUpdates - 250000 badcase_full_deposits 445.70 us/op 521.45 us/op 0.85
phase0 processRegistryUpdates - 250000 worstcase 0.5 226.81 ms/op 250.93 ms/op 0.90
altair processRewardsAndPenalties - 250000 normalcase 135.42 ms/op 136.45 ms/op 0.99
altair processRewardsAndPenalties - 250000 worstcase 139.68 ms/op 149.51 ms/op 0.93
phase0 getAttestationDeltas - 250000 normalcase 11.946 ms/op 14.867 ms/op 0.80
phase0 getAttestationDeltas - 250000 worstcase 11.775 ms/op 15.418 ms/op 0.76
phase0 processSlashings - 250000 worstcase 6.0773 ms/op 6.8792 ms/op 0.88
altair processSyncCommitteeUpdates - 250000 289.45 ms/op 332.46 ms/op 0.87
BeaconState.hashTreeRoot - No change 544.00 ns/op 557.00 ns/op 0.98
BeaconState.hashTreeRoot - 1 full validator 70.562 us/op 77.548 us/op 0.91
BeaconState.hashTreeRoot - 32 full validator 841.06 us/op 773.48 us/op 1.09
BeaconState.hashTreeRoot - 512 full validator 6.8591 ms/op 7.2851 ms/op 0.94
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 90.571 us/op 94.970 us/op 0.95
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2458 ms/op 1.3832 ms/op 0.90
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.952 ms/op 18.612 ms/op 0.96
BeaconState.hashTreeRoot - 1 balances 70.378 us/op 70.516 us/op 1.00
BeaconState.hashTreeRoot - 32 balances 631.08 us/op 837.07 us/op 0.75
BeaconState.hashTreeRoot - 512 balances 7.1608 ms/op 6.8730 ms/op 1.04
BeaconState.hashTreeRoot - 250000 balances 110.89 ms/op 100.87 ms/op 1.10
aggregationBits - 2048 els - zipIndexesInBitList 286.24 us/op 35.906 us/op 7.97
regular array get 100000 times 63.202 us/op 80.401 us/op 0.79
wrappedArray get 100000 times 63.409 us/op 77.846 us/op 0.81
arrayWithProxy get 100000 times 26.742 ms/op 32.946 ms/op 0.81
ssz.Root.equals 449.00 ns/op 597.00 ns/op 0.75
byteArrayEquals 445.00 ns/op 584.00 ns/op 0.76
shuffle list - 16384 els 11.248 ms/op 13.040 ms/op 0.86
shuffle list - 250000 els 166.36 ms/op 192.90 ms/op 0.86
processSlot - 1 slots 14.804 us/op 15.000 us/op 0.99
processSlot - 32 slots 1.9160 ms/op 2.1524 ms/op 0.89
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 439.29 us/op 479.01 us/op 0.92
getCommitteeAssignments - req 1 vs - 250000 vc 5.4208 ms/op 6.2777 ms/op 0.86
getCommitteeAssignments - req 100 vs - 250000 vc 8.0406 ms/op 8.7848 ms/op 0.92
getCommitteeAssignments - req 1000 vs - 250000 vc 8.5649 ms/op 9.2910 ms/op 0.92
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 7.8600 ns/op 11.820 ns/op 0.66
state getBlockRootAtSlot - 250000 vs - 7PWei 976.84 ns/op 1.4203 us/op 0.69
computeProposers - vc 250000 16.928 ms/op 20.220 ms/op 0.84
computeEpochShuffling - vc 250000 174.90 ms/op 195.18 ms/op 0.90
getNextSyncCommittee - vc 250000 284.05 ms/op 335.16 ms/op 0.85

by benchmarkbot/action

error: e as Error,
});
});
// TODO: Must be a state in the same chain as attHeadBlock, but dialed to target.epoch
Copy link
Member

Choose a reason for hiding this comment

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

I think we verify elsewhere that attHead is a descendant of the target

@wemeetagain wemeetagain merged commit b6032c5 into unstable Dec 5, 2022
@wemeetagain wemeetagain deleted the dapplion/fix-validateGossipAttestation branch December 5, 2022 20:49
twoeths added a commit that referenced this pull request Dec 12, 2022
wemeetagain pushed a commit that referenced this pull request Dec 12, 2022
* Revert "Use state dialed to attestation target epoch (#4849)"

This reverts commit b6032c5.

* Add more comments

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

2 participants