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

Add capella hardfork and types #4568

Merged
merged 3 commits into from Oct 2, 2022
Merged

Add capella hardfork and types #4568

merged 3 commits into from Oct 2, 2022

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Sep 19, 2022

Add capella hardfork and types
Dependent on

Part of

@g11tech g11tech requested a review from a team as a code owner September 19, 2022 17:19
@g11tech g11tech changed the base branch from g11tech/blinded-forks to unstable September 19, 2022 17:19
@g11tech g11tech marked this pull request as draft September 19, 2022 17:20
@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: ac67bb1 Previous: fd8e335 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.1027 ms/op 2.1053 ms/op 1.00
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 71.941 us/op 71.008 us/op 1.01
BLS verify - blst-native 1.8563 ms/op 1.9182 ms/op 0.97
BLS verifyMultipleSignatures 3 - blst-native 3.8071 ms/op 4.0199 ms/op 0.95
BLS verifyMultipleSignatures 8 - blst-native 8.1860 ms/op 8.6175 ms/op 0.95
BLS verifyMultipleSignatures 32 - blst-native 29.663 ms/op 29.900 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 39.131 us/op 38.948 us/op 1.00
BLS aggregatePubkeys 128 - blst-native 152.89 us/op 159.21 us/op 0.96
getAttestationsForBlock 86.399 ms/op 94.012 ms/op 0.92
isKnown best case - 1 super set check 436.00 ns/op 437.00 ns/op 1.00
isKnown normal case - 2 super set checks 429.00 ns/op 412.00 ns/op 1.04
isKnown worse case - 16 super set checks 424.00 ns/op 416.00 ns/op 1.02
CheckpointStateCache - add get delete 8.5900 us/op 9.4750 us/op 0.91
validate gossip signedAggregateAndProof - struct 4.2669 ms/op 4.3962 ms/op 0.97
validate gossip attestation - struct 2.0308 ms/op 2.1398 ms/op 0.95
pickEth1Vote - no votes 2.1637 ms/op 2.2435 ms/op 0.96
pickEth1Vote - max votes 19.409 ms/op 18.706 ms/op 1.04
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.970 ms/op 11.886 ms/op 0.92
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.140 ms/op 19.559 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize value x2048 1.5289 ms/op 1.4902 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize tree x2048 13.524 ms/op 13.780 ms/op 0.98
bytes32 toHexString 1.0220 us/op 1.0510 us/op 0.97
bytes32 Buffer.toString(hex) 699.00 ns/op 706.00 ns/op 0.99
bytes32 Buffer.toString(hex) from Uint8Array 955.00 ns/op 936.00 ns/op 1.02
bytes32 Buffer.toString(hex) + 0x 714.00 ns/op 636.00 ns/op 1.12
Object access 1 prop 0.35400 ns/op 0.32800 ns/op 1.08
Map access 1 prop 0.29600 ns/op 0.30000 ns/op 0.99
Object get x1000 17.524 ns/op 15.918 ns/op 1.10
Map get x1000 0.98300 ns/op 0.87000 ns/op 1.13
Object set x1000 121.80 ns/op 99.581 ns/op 1.22
Map set x1000 76.751 ns/op 66.585 ns/op 1.15
Return object 10000 times 0.37720 ns/op 0.36750 ns/op 1.03
Throw Error 10000 times 5.9747 us/op 6.8930 us/op 0.87
enrSubnets - fastDeserialize 64 bits 2.5900 us/op 2.5590 us/op 1.01
enrSubnets - ssz BitVector 64 bits 727.00 ns/op 693.00 ns/op 1.05
enrSubnets - fastDeserialize 4 bits 387.00 ns/op 352.00 ns/op 1.10
enrSubnets - ssz BitVector 4 bits 755.00 ns/op 653.00 ns/op 1.16
prioritizePeers score -10:0 att 32-0.1 sync 2-0 94.004 us/op 95.063 us/op 0.99
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 123.11 us/op 141.10 us/op 0.87
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 209.82 us/op 238.09 us/op 0.88
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 445.55 us/op 469.67 us/op 0.95
prioritizePeers score 0:0 att 64-1 sync 4-1 456.40 us/op 475.82 us/op 0.96
RateTracker 1000000 limit, 1 obj count per request 182.87 ns/op 164.49 ns/op 1.11
RateTracker 1000000 limit, 2 obj count per request 136.69 ns/op 123.46 ns/op 1.11
RateTracker 1000000 limit, 4 obj count per request 113.68 ns/op 104.68 ns/op 1.09
RateTracker 1000000 limit, 8 obj count per request 103.69 ns/op 92.408 ns/op 1.12
RateTracker with prune 4.1180 us/op 4.2700 us/op 0.96
array of 16000 items push then shift 3.1341 us/op 4.5058 us/op 0.70
LinkedList of 16000 items push then shift 17.249 ns/op 16.882 ns/op 1.02
array of 16000 items push then pop 233.81 ns/op 212.73 ns/op 1.10
LinkedList of 16000 items push then pop 16.293 ns/op 16.201 ns/op 1.01
array of 24000 items push then shift 4.5428 us/op 6.7287 us/op 0.68
LinkedList of 24000 items push then shift 19.859 ns/op 17.366 ns/op 1.14
array of 24000 items push then pop 208.60 ns/op 228.20 ns/op 0.91
LinkedList of 24000 items push then pop 17.831 ns/op 16.313 ns/op 1.09
intersect bitArray bitLen 8 11.754 ns/op 10.632 ns/op 1.11
intersect array and set length 8 164.61 ns/op 162.46 ns/op 1.01
intersect bitArray bitLen 128 61.982 ns/op 60.167 ns/op 1.03
intersect array and set length 128 2.3877 us/op 2.0027 us/op 1.19
Buffer.concat 32 items 2.2290 ns/op 2.0070 ns/op 1.11
pass gossip attestations to forkchoice per slot 3.1591 ms/op 3.4069 ms/op 0.93
computeDeltas 3.2874 ms/op 3.7056 ms/op 0.89
computeProposerBoostScoreFromBalances 907.43 us/op 755.33 us/op 1.20
altair processAttestation - 250000 vs - 7PWei normalcase 3.4607 ms/op 4.5200 ms/op 0.77
altair processAttestation - 250000 vs - 7PWei worstcase 5.5853 ms/op 6.1768 ms/op 0.90
altair processAttestation - setStatus - 1/6 committees join 219.95 us/op 254.59 us/op 0.86
altair processAttestation - setStatus - 1/3 committees join 413.99 us/op 447.04 us/op 0.93
altair processAttestation - setStatus - 1/2 committees join 587.31 us/op 596.71 us/op 0.98
altair processAttestation - setStatus - 2/3 committees join 754.47 us/op 864.70 us/op 0.87
altair processAttestation - setStatus - 4/5 committees join 1.0346 ms/op 1.0846 ms/op 0.95
altair processAttestation - setStatus - 100% committees join 1.2386 ms/op 1.2786 ms/op 0.97
altair processBlock - 250000 vs - 7PWei normalcase 26.978 ms/op 27.676 ms/op 0.97
altair processBlock - 250000 vs - 7PWei normalcase hashState 40.559 ms/op 42.615 ms/op 0.95
altair processBlock - 250000 vs - 7PWei worstcase 79.391 ms/op 77.641 ms/op 1.02
altair processBlock - 250000 vs - 7PWei worstcase hashState 95.970 ms/op 110.67 ms/op 0.87
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2448 ms/op 3.8516 ms/op 0.84
phase0 processBlock - 250000 vs - 7PWei worstcase 45.497 ms/op 48.038 ms/op 0.95
altair processEth1Data - 250000 vs - 7PWei normalcase 751.52 us/op 937.05 us/op 0.80
Tree 40 250000 create 802.86 ms/op 727.71 ms/op 1.10
Tree 40 250000 get(125000) 290.83 ns/op 271.73 ns/op 1.07
Tree 40 250000 set(125000) 2.4188 us/op 2.3897 us/op 1.01
Tree 40 250000 toArray() 32.037 ms/op 33.452 ms/op 0.96
Tree 40 250000 iterate all - toArray() + loop 32.134 ms/op 33.854 ms/op 0.95
Tree 40 250000 iterate all - get(i) 111.61 ms/op 115.97 ms/op 0.96
MutableVector 250000 create 14.943 ms/op 17.070 ms/op 0.88
MutableVector 250000 get(125000) 15.086 ns/op 12.387 ns/op 1.22
MutableVector 250000 set(125000) 627.01 ns/op 743.94 ns/op 0.84
MutableVector 250000 toArray() 7.3704 ms/op 6.8728 ms/op 1.07
MutableVector 250000 iterate all - toArray() + loop 7.6210 ms/op 6.6127 ms/op 1.15
MutableVector 250000 iterate all - get(i) 3.3185 ms/op 3.6767 ms/op 0.90
Array 250000 create 6.8546 ms/op 6.5225 ms/op 1.05
Array 250000 clone - spread 2.9031 ms/op 4.1642 ms/op 0.70
Array 250000 get(125000) 1.0950 ns/op 1.5630 ns/op 0.70
Array 250000 set(125000) 1.1040 ns/op 1.6130 ns/op 0.68
Array 250000 iterate all - loop 167.95 us/op 123.30 us/op 1.36
effectiveBalanceIncrements clone Uint8Array 300000 70.623 us/op 200.59 us/op 0.35
effectiveBalanceIncrements clone MutableVector 300000 717.00 ns/op 691.00 ns/op 1.04
effectiveBalanceIncrements rw all Uint8Array 300000 252.47 us/op 242.56 us/op 1.04
effectiveBalanceIncrements rw all MutableVector 300000 175.56 ms/op 177.85 ms/op 0.99
phase0 afterProcessEpoch - 250000 vs - 7PWei 194.85 ms/op 165.11 ms/op 1.18
phase0 beforeProcessEpoch - 250000 vs - 7PWei 72.619 ms/op 69.601 ms/op 1.04
altair processEpoch - mainnet_e81889 582.49 ms/op 557.61 ms/op 1.04
mainnet_e81889 - altair beforeProcessEpoch 144.87 ms/op 152.55 ms/op 0.95
mainnet_e81889 - altair processJustificationAndFinalization 27.087 us/op 64.080 us/op 0.42
mainnet_e81889 - altair processInactivityUpdates 10.225 ms/op 9.8942 ms/op 1.03
mainnet_e81889 - altair processRewardsAndPenalties 90.426 ms/op 95.865 ms/op 0.94
mainnet_e81889 - altair processRegistryUpdates 4.9650 us/op 14.358 us/op 0.35
mainnet_e81889 - altair processSlashings 883.00 ns/op 3.8690 us/op 0.23
mainnet_e81889 - altair processEth1DataReset 1.3160 us/op 4.3300 us/op 0.30
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.4882 ms/op 2.1014 ms/op 1.18
mainnet_e81889 - altair processSlashingsReset 8.9210 us/op 26.327 us/op 0.34
mainnet_e81889 - altair processRandaoMixesReset 7.5340 us/op 26.834 us/op 0.28
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0200 us/op 4.2210 us/op 0.24
mainnet_e81889 - altair processParticipationFlagUpdates 4.0600 us/op 15.046 us/op 0.27
mainnet_e81889 - altair processSyncCommitteeUpdates 1.1190 us/op 3.5700 us/op 0.31
mainnet_e81889 - altair afterProcessEpoch 192.75 ms/op 176.14 ms/op 1.09
phase0 processEpoch - mainnet_e58758 518.77 ms/op 520.30 ms/op 1.00
mainnet_e58758 - phase0 beforeProcessEpoch 228.40 ms/op 232.77 ms/op 0.98
mainnet_e58758 - phase0 processJustificationAndFinalization 25.765 us/op 61.176 us/op 0.42
mainnet_e58758 - phase0 processRewardsAndPenalties 137.57 ms/op 142.88 ms/op 0.96
mainnet_e58758 - phase0 processRegistryUpdates 13.818 us/op 32.989 us/op 0.42
mainnet_e58758 - phase0 processSlashings 1.0200 us/op 3.1600 us/op 0.32
mainnet_e58758 - phase0 processEth1DataReset 1.0040 us/op 3.6220 us/op 0.28
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.2018 ms/op 1.9563 ms/op 1.13
mainnet_e58758 - phase0 processSlashingsReset 5.9700 us/op 13.425 us/op 0.44
mainnet_e58758 - phase0 processRandaoMixesReset 7.4300 us/op 25.836 us/op 0.29
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.1750 us/op 4.1650 us/op 0.28
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.4250 us/op 23.535 us/op 0.27
mainnet_e58758 - phase0 afterProcessEpoch 157.52 ms/op 149.72 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.6299 ms/op 2.0507 ms/op 1.28
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.5534 ms/op 2.6758 ms/op 1.33
altair processInactivityUpdates - 250000 normalcase 39.180 ms/op 45.441 ms/op 0.86
altair processInactivityUpdates - 250000 worstcase 36.119 ms/op 56.453 ms/op 0.64
phase0 processRegistryUpdates - 250000 normalcase 11.152 us/op 26.806 us/op 0.42
phase0 processRegistryUpdates - 250000 badcase_full_deposits 542.61 us/op 445.25 us/op 1.22
phase0 processRegistryUpdates - 250000 worstcase 0.5 207.10 ms/op 254.27 ms/op 0.81
altair processRewardsAndPenalties - 250000 normalcase 88.382 ms/op 135.74 ms/op 0.65
altair processRewardsAndPenalties - 250000 worstcase 115.51 ms/op 88.725 ms/op 1.30
phase0 getAttestationDeltas - 250000 normalcase 12.637 ms/op 12.589 ms/op 1.00
phase0 getAttestationDeltas - 250000 worstcase 12.866 ms/op 13.696 ms/op 0.94
phase0 processSlashings - 250000 worstcase 5.4334 ms/op 5.2926 ms/op 1.03
altair processSyncCommitteeUpdates - 250000 274.87 ms/op 292.97 ms/op 0.94
BeaconState.hashTreeRoot - No change 497.00 ns/op 531.00 ns/op 0.94
BeaconState.hashTreeRoot - 1 full validator 64.489 us/op 67.877 us/op 0.95
BeaconState.hashTreeRoot - 32 full validator 616.77 us/op 847.29 us/op 0.73
BeaconState.hashTreeRoot - 512 full validator 6.5022 ms/op 6.8674 ms/op 0.95
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 77.792 us/op 84.350 us/op 0.92
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.1849 ms/op 1.2740 ms/op 0.93
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.323 ms/op 16.080 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 58.621 us/op 70.387 us/op 0.83
BeaconState.hashTreeRoot - 32 balances 582.97 us/op 620.83 us/op 0.94
BeaconState.hashTreeRoot - 512 balances 5.5096 ms/op 5.8802 ms/op 0.94
BeaconState.hashTreeRoot - 250000 balances 91.684 ms/op 96.995 ms/op 0.95
aggregationBits - 2048 els - zipIndexesInBitList 33.641 us/op 29.152 us/op 1.15
regular array get 100000 times 67.402 us/op 48.500 us/op 1.39
wrappedArray get 100000 times 67.381 us/op 49.849 us/op 1.35
arrayWithProxy get 100000 times 29.289 ms/op 29.262 ms/op 1.00
ssz.Root.equals 498.00 ns/op 524.00 ns/op 0.95
byteArrayEquals 465.00 ns/op 519.00 ns/op 0.90
shuffle list - 16384 els 11.094 ms/op 11.679 ms/op 0.95
shuffle list - 250000 els 163.68 ms/op 144.16 ms/op 1.14
processSlot - 1 slots 13.854 us/op 12.931 us/op 1.07
processSlot - 32 slots 1.6944 ms/op 1.9784 ms/op 0.86
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 389.08 us/op 372.21 us/op 1.05
getCommitteeAssignments - req 1 vs - 250000 vc 5.2684 ms/op 4.6527 ms/op 1.13
getCommitteeAssignments - req 100 vs - 250000 vc 7.3272 ms/op 6.7033 ms/op 1.09
getCommitteeAssignments - req 1000 vs - 250000 vc 7.7673 ms/op 6.7332 ms/op 1.15
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 9.2900 ns/op 8.5100 ns/op 1.09
state getBlockRootAtSlot - 250000 vs - 7PWei 1.0477 us/op 1.2590 us/op 0.83
computeProposers - vc 250000 16.318 ms/op 16.538 ms/op 0.99
computeEpochShuffling - vc 250000 166.09 ms/op 146.49 ms/op 1.13
getNextSyncCommittee - vc 250000 268.35 ms/op 299.83 ms/op 0.89

by benchmarkbot/action

@g11tech g11tech force-pushed the g11tech/capella-fork branch 2 times, most recently from c850ac5 to 5161b99 Compare September 20, 2022 10:36
@@ -36,6 +36,9 @@ export const chainConfig: IChainConfig = {
// Bellatrix
BELLATRIX_FORK_VERSION: b("0x02000000"),
BELLATRIX_FORK_EPOCH: 144896, // Sept 6, 2022, 11:34:47am UTC
// Capella
CAPELLA_FORK_VERSION: b("0x03000000"),
CAPELLA_FORK_EPOCH: Infinity,
// Sharding
SHARDING_FORK_VERSION: b("0x03000000"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not have the same fork_version

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove, SHARDING_* fields, no longer in upstream spec

Copy link
Contributor Author

@g11tech g11tech Sep 20, 2022

Choose a reason for hiding this comment

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

should i rename them to EIP4844 something, thats what the new spec calls them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebased/removed

},
altair: {
BeaconBlockBody: altair.BeaconBlockBody,
BeaconBlock: altair.BeaconBlock,
SignedBeaconBlock: altair.SignedBeaconBlock,
BeaconState: altair.BeaconState,
Metadata: altair.Metadata,
// Not used in altair but added for type consitency
ExecutionPayload: bellatrix.ExecutionPayload,
ExecutionPayloadHeader: bellatrix.ExecutionPayloadHeader,
Copy link
Contributor

Choose a reason for hiding this comment

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

to be dropped after rebase right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i plan to move them to a separate allTypesExecution as some fork based usage is there

@g11tech g11tech marked this pull request as ready for review September 20, 2022 17:20
@g11tech g11tech enabled auto-merge (squash) September 20, 2022 20:02
withdrawableEpoch: FAR_FUTURE_EPOCH,
effectiveBalance,
slashed: false,
fullyWithdrawnEpoch: FAR_FUTURE_EPOCH,
Copy link
Contributor

Choose a reason for hiding this comment

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

Note, this property is likely to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awesome, will simplify processing deposits back to original, will comment it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dapplion should i remove this fullyWithdrawnEpoch from here ?

 * handle capella state upgrade case

 * fix more spec tests

 * lint params

 * add the new domain for constants check

 * rebase fixes

// Union at the TreeViewDU level
// - Works well as function argument and as generic type for allForks functions
//
// Quasy equivalent to
// CompositeViewDU<typeof ssz.phase0.BeaconState | typeof ssz.altair.BeaconState | typeof ssz.bellatrix.BeaconState>
export type BeaconStateAllForks = BeaconStatePhase0 | BeaconStateAltair | BeaconStateBellatrix;
export type BeaconStateAllForks = BeaconStatePhase0 | BeaconStateAltair | BeaconStateBellatrix | BeaconStateCapella;
export type BeaconStateExecutions = BeaconStateBellatrix | BeaconStateCapella;
Copy link
Member

Choose a reason for hiding this comment

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

Might call this BeaconStatePostMerge (somehow easier than post-bellatrix) or BeaconStateWithExecution or BeaconStateWithEL. 🤷

We're probably going to have more types of beacon states over time with different capabilities, so maybe we can figure out a naming convention that can suit.

Just brainstorming:
Naming after fork:
BeaconStatePostB - beacon states bellatrix and after
BeaconStatePostC - beacon states capella and after

or
postBellatrix.BeaconState, postCapella.BeaconState

Naming by capability:
BeaconStateWithExecution - beacon states bellatrix and after
BeaconStateWithWithdrawals - beacon states capella and after

thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i like capability idea since that makes code more intutive 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Both BeaconStatePostBellatrix or BeaconStateWithExecution sound good

@g11tech g11tech merged commit c9f07a4 into unstable Oct 2, 2022
@g11tech g11tech deleted the g11tech/capella-fork branch October 2, 2022 16:58
@dapplion dapplion added the spec-capella 🦉 Issues targeting the Capella spec version label Nov 18, 2022
@dapplion dapplion mentioned this pull request Nov 27, 2022
7 tasks
@dapplion dapplion mentioned this pull request Jan 4, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec-capella 🦉 Issues targeting the Capella spec version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants