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

Mev/Builder api integration #3969

Merged
merged 5 commits into from
Jul 1, 2022
Merged

Mev/Builder api integration #3969

merged 5 commits into from
Jul 1, 2022

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented May 4, 2022

Motivation
Reference: https://github.com/ethereum/execution-apis/pull/209/files

Dev TODOs

  • Refactored to use the new api set ( as well as including the engine merged tracker PRs and esm changes on latest unstable)
  • parallel block building of by the validaor using engine + builder
    - [ ] Choice logic to be included moving to a followup issue Followup tracker for MeV related pending issues/cleanup #4208

Dev Cleanup

  • Extract out the builder from the execution folder
  • Cleanup the blinded beacon block's handling in beacon-state-transition for building state root post block body fetch
  • API req/resp tests in the unit tests
  • gasLimit constant handling
  • validator builder.enabled option
  • fix tests

Tests with mergemock

  • Signature validation over new domain
    • of registerValidator
    • of submit blinded block
  • Register validator
  • Get payload header
  • submit blinded block and get payload
  • engine accepting the new payload
  • Successful post merge scenario

Tests with the full mev builder

  • Signature validation over new domain
    • of registerValidator
    • of submit blinded block
  • Register validator
  • Get payload header
  • submit blinded block and get payload
  • engine accepting the new payload
  • Successful post merge scenario

Mergemock/local testnet relay integration with merge-interop

- [ ] path needs to be figured out yet #4208

Old work

This PR integrates the builder api and consists broadly of 3 parts:

  • container types
  • Builder module
    • Options
      • builder.urls, builder.enabled
    • Json rpc setup It was decided to implement the api CL style
    • builder api setup
    • methods & types for
      • builder_registerValidatorV1
      • builder_getHeaderV1
      • builder_getPayloadV1
  • validator registration : send signed ValidatorRegistrationV1 in beacon proposer api which BN can propagate
  • perform builder_registerValidatorV1
  • NOTE: there is no fcU to be issued here, mev ecosystem is expected to take of this using their own nodes
  • on produce block perform builder_getHeaderV1 in parallel with fetching payload from engine while assembling body to get the ExecutionPayloadHeaderV1 and signed BuilderBidV1
  • for a BlindedSignedBeaconBlock and send builder_getPayloadV1 and get ExecutionPayloadV1 which can be used be combined with the signed BlindedBeaconBlock to form SignedBeaconBlock and propogated
  • Validator checks to confirm and decide fee recipient on BlindedSignedBeaconBlock is what is updated with it before signing it for the publish via builder_getPayloadV1

Closes #3953

UPDATE: integration/test SUCCESS with mergemock !!! 🥳 locally with some caveats

EL 65190: time="2022-05-16T17:31:23+05:30" level="info" msg="computed block from payload" blockHash="0xdcc802335d5f5919d3e76bf062a544ae7eeec2b6ece4ab4deb3645ea7c809da9" difficulty="0" extraData="" gasLimit="30000000" gasUsed="0" logsBloom="[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]" miner="0x0000000000000000000000000000000000000000" number="14" parentHash="0x14f76e1dedca806e74bec62596e0c0d34b2e2b2284306c5033a8c016932f7260" prevRandao="0x19404254604afb25269744cc999d21966f5476a78802ae0f2fb78f74ed1a1f01" receiptsRoot="0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" sha3Uncles="0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" stateRoot="0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45" timestamp="1652702483" transactionsRoot="0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
EL 65190: time="2022-05-16T17:31:23+05:30" level="info" msg="Imported new chain segment" blocks="1" dirty="0.00 B" elapsed="104.714µs" hash="0xdcc802335d5f5919d3e76bf062a544ae7eeec2b6ece4ab4deb3645ea7c809da9" mgas="0" mgasps="0" number="14" txs="0"
EL 65190: time="2022-05-16T17:31:23+05:30" level="info" msg="Executed payload" block_hash="0xdcc802335d5f5919d3e76bf062a544ae7eeec2b6ece4ab4deb3645ea7c809da9"
Eph 0/14 0.241[NODE-A]           info: > Block attestations slot=14, bits=1, inclDelay=1
Eph 0/14 0.241[VALI 0-31]        info: Published block slot=14, validator=0xa98e…1d99, graffiti=
EL 65190: time="2022-05-16T17:31:23+05:30" level="info" msg="Forkchoice updated" attributes="&{1652702485 0x4b75ecf2383e2bb573394d983975d282af5c9e26842f6cc3b235aa518a2111a6 0x0000000000000000000000000000000000000000}" finalized="0xccaf66b50e791f95d4b50bae4de28af9396824e7c29f99aeba19414fdf72673f" head="0xdcc802335d5f5919d3e76bf062a544ae7eeec2b6ece4ab4deb3645ea7c809da9" safe="0xdcc802335d5f5919d3e76bf062a544ae7eeec2b6ece4ab4deb3645ea7c809da9"
time="2022-05-16T17:31:23+05:30" level="info" msg="Preparing new payload" attributes="&{1652702485 0x4b75ecf2383e2bb573394d983975d282af5c9e26842f6cc3b235aa518a2111a6 0x0000000000000000000000000000000000000000}" payload_id="[0 0 0 0 0 0 0 15]"
Eph 0/14 0.349[VALI 0-31]        info: Published attestations slot=14, count=1
Eph 0/14 0.887[VALI 0-31]        info: Published SyncCommitteeMessage slot=14, count=32
Eph 0/14 1.000[NODE-A]           info: Synced - slot: 14 - head: 14 0x1f5d…7484 - execution: valid(0xdcc8…9da9) - finalized: 0x0000…0000:0 - peers: 0

Caveats

  1. Had to override the transactionsRoot i was getting with the self computed one (mentioned before that the transactionsRoot is not matching vs locally computed for empty transactions array)
  2. Running the test on mainnet preset, would be good if the mergemock can support minimal sync_commitee_bits is the variable thats plays spoils-sport while serializing/deserializing json requests
  3. Had to turn off the signature validations on mergemock's submit blinded blocks because i)transactionsRoot issue ii) the blinded beacon block's signature was required on domain, otherwise the full block reconstructed from the blinded beacon block + payload wasn't getting published/accepted

@codecov
Copy link

codecov bot commented May 4, 2022

Codecov Report

Merging #3969 (e23a3dd) into unstable (a987fa9) will not change coverage.
The diff coverage is n/a.

❗ Current head e23a3dd differs from pull request most recent head 9ff0629. Consider uploading reports for the commit 9ff0629 to get more accurate results

@@       Coverage Diff        @@
##   unstable   #3969   +/-   ##
================================
================================

@g11tech g11tech mentioned this pull request May 4, 2022
22 tasks
}),

// At the same time fetch any remaining unknown validator indices, then poll duties for those newIndices only
this.indicesService
.pollValidatorIndices()
.then((newIndices) => this.api.validator.prepareBeaconProposer(this.getProposerData(newIndices)))
.then((newIndices) => this.getProposerData(slot, newIndices))
.then((proposerData) => this.api.validator.prepareBeaconProposer(proposerData))
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point just use an async function instead of a then chain, for consistency with the rest of the codebase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modeled changes on the rebased function

@g11tech
Copy link
Contributor Author

g11tech commented May 10, 2022

thanks @dapplion for looking through ❤️, yes need to refactor as the bn <> boost interaction is now CL api style.

will incorporate the feedback once am able to successfully implement the flow 🙂

@g11tech g11tech force-pushed the g11tech/engine-prepare-fcus branch 2 times, most recently from 5752b9f to ef57bec Compare May 24, 2022 14:43
Base automatically changed from g11tech/engine-prepare-fcus to master May 24, 2022 19:20
@dapplion dapplion changed the base branch from master to unstable May 27, 2022 04:34
@twoeths
Copy link
Contributor

twoeths commented Jun 4, 2022

Builder spec was moved to https://github.com/ethereum/builder-specs

@g11tech g11tech force-pushed the g11tech/mev-integration branch 2 times, most recently from 67b6c5d to cbefe3d Compare June 5, 2022 09:57
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1405b1e Previous: 4d7852e Ratio
altair processAttestation - 250000 vs - 7PWei normalcase 4.3944 ms/op 2.6862 ms/op 1.64
altair processAttestation - 250000 vs - 7PWei worstcase 6.8766 ms/op 4.1439 ms/op 1.66
altair processAttestation - setStatus - 1/6 committees join 265.48 us/op 132.38 us/op 2.01
altair processAttestation - setStatus - 1/3 committees join 522.37 us/op 258.52 us/op 2.02
altair processAttestation - setStatus - 1/2 committees join 718.74 us/op 367.67 us/op 1.95
altair processAttestation - setStatus - 2/3 committees join 973.10 us/op 477.38 us/op 2.04
altair processAttestation - setStatus - 4/5 committees join 1.2870 ms/op 658.43 us/op 1.95
altair processAttestation - setStatus - 100% committees join 1.5449 ms/op 797.51 us/op 1.94
altair processBlock - 250000 vs - 7PWei normalcase 29.094 ms/op 21.893 ms/op 1.33
altair processBlock - 250000 vs - 7PWei normalcase hashState 38.901 ms/op 27.703 ms/op 1.40
altair processBlock - 250000 vs - 7PWei worstcase 100.40 ms/op 65.152 ms/op 1.54
altair processBlock - 250000 vs - 7PWei worstcase hashState 129.02 ms/op 79.516 ms/op 1.62
phase0 processBlock - 250000 vs - 7PWei normalcase 4.0838 ms/op 2.6196 ms/op 1.56
phase0 processBlock - 250000 vs - 7PWei worstcase 63.217 ms/op 38.265 ms/op 1.65
altair processEth1Data - 250000 vs - 7PWei normalcase 862.91 us/op 538.96 us/op 1.60
Tree 40 250000 create 967.65 ms/op 597.91 ms/op 1.62
Tree 40 250000 get(125000) 331.13 ns/op 197.55 ns/op 1.68
Tree 40 250000 set(125000) 3.5034 us/op 1.8063 us/op 1.94
Tree 40 250000 toArray() 36.024 ms/op 23.098 ms/op 1.56
Tree 40 250000 iterate all - toArray() + loop 41.501 ms/op 22.895 ms/op 1.81
Tree 40 250000 iterate all - get(i) 132.36 ms/op 84.973 ms/op 1.56
MutableVector 250000 create 15.695 ms/op 10.936 ms/op 1.44
MutableVector 250000 get(125000) 14.236 ns/op 7.7880 ns/op 1.83
MutableVector 250000 set(125000) 725.36 ns/op 468.03 ns/op 1.55
MutableVector 250000 toArray() 6.1720 ms/op 4.6470 ms/op 1.33
MutableVector 250000 iterate all - toArray() + loop 6.6553 ms/op 4.9893 ms/op 1.33
MutableVector 250000 iterate all - get(i) 3.5549 ms/op 1.9312 ms/op 1.84
Array 250000 create 5.9306 ms/op 3.7256 ms/op 1.59
Array 250000 clone - spread 3.1910 ms/op 1.7494 ms/op 1.82
Array 250000 get(125000) 1.5120 ns/op 0.90000 ns/op 1.68
Array 250000 set(125000) 1.5380 ns/op 0.90600 ns/op 1.70
Array 250000 iterate all - loop 146.33 us/op 114.10 us/op 1.28
effectiveBalanceIncrements clone Uint8Array 300000 259.15 us/op 97.590 us/op 2.66
effectiveBalanceIncrements clone MutableVector 300000 927.00 ns/op 504.00 ns/op 1.84
effectiveBalanceIncrements rw all Uint8Array 300000 305.23 us/op 176.99 us/op 1.72
effectiveBalanceIncrements rw all MutableVector 300000 224.60 ms/op 107.89 ms/op 2.08
phase0 afterProcessEpoch - 250000 vs - 7PWei 214.28 ms/op 146.40 ms/op 1.46
phase0 beforeProcessEpoch - 250000 vs - 7PWei 72.888 ms/op 46.220 ms/op 1.58
altair processEpoch - mainnet_e81889 631.96 ms/op 442.83 ms/op 1.43
mainnet_e81889 - altair beforeProcessEpoch 161.42 ms/op 64.006 ms/op 2.52
mainnet_e81889 - altair processJustificationAndFinalization 45.914 us/op 16.533 us/op 2.78
mainnet_e81889 - altair processInactivityUpdates 12.655 ms/op 7.5002 ms/op 1.69
mainnet_e81889 - altair processRewardsAndPenalties 145.47 ms/op 128.00 ms/op 1.14
mainnet_e81889 - altair processRegistryUpdates 8.8340 us/op 2.0830 us/op 4.24
mainnet_e81889 - altair processSlashings 2.3970 us/op 578.00 ns/op 4.15
mainnet_e81889 - altair processEth1DataReset 2.1420 us/op 576.00 ns/op 3.72
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.5328 ms/op 1.5989 ms/op 1.58
mainnet_e81889 - altair processSlashingsReset 12.541 us/op 4.4120 us/op 2.84
mainnet_e81889 - altair processRandaoMixesReset 13.445 us/op 3.6310 us/op 3.70
mainnet_e81889 - altair processHistoricalRootsUpdate 1.9310 us/op 568.00 ns/op 3.40
mainnet_e81889 - altair processParticipationFlagUpdates 6.7810 us/op 1.8390 us/op 3.69
mainnet_e81889 - altair processSyncCommitteeUpdates 1.8680 us/op 502.00 ns/op 3.72
mainnet_e81889 - altair afterProcessEpoch 215.66 ms/op 141.97 ms/op 1.52
phase0 processEpoch - mainnet_e58758 598.46 ms/op 364.22 ms/op 1.64
mainnet_e58758 - phase0 beforeProcessEpoch 227.70 ms/op 164.17 ms/op 1.39
mainnet_e58758 - phase0 processJustificationAndFinalization 36.500 us/op 13.972 us/op 2.61
mainnet_e58758 - phase0 processRewardsAndPenalties 77.307 ms/op 57.414 ms/op 1.35
mainnet_e58758 - phase0 processRegistryUpdates 19.629 us/op 6.9550 us/op 2.82
mainnet_e58758 - phase0 processSlashings 1.8190 us/op 496.00 ns/op 3.67
mainnet_e58758 - phase0 processEth1DataReset 2.0040 us/op 512.00 ns/op 3.91
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.3804 ms/op 1.3912 ms/op 1.71
mainnet_e58758 - phase0 processSlashingsReset 9.4220 us/op 3.4350 us/op 2.74
mainnet_e58758 - phase0 processRandaoMixesReset 14.419 us/op 3.8530 us/op 3.74
mainnet_e58758 - phase0 processHistoricalRootsUpdate 2.1900 us/op 586.00 ns/op 3.74
mainnet_e58758 - phase0 processParticipationRecordUpdates 12.896 us/op 3.1870 us/op 4.05
mainnet_e58758 - phase0 afterProcessEpoch 179.50 ms/op 135.45 ms/op 1.33
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.6426 ms/op 1.4558 ms/op 1.82
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.6002 ms/op 1.5652 ms/op 1.66
altair processInactivityUpdates - 250000 normalcase 31.997 ms/op 21.319 ms/op 1.50
altair processInactivityUpdates - 250000 worstcase 46.788 ms/op 24.226 ms/op 1.93
phase0 processRegistryUpdates - 250000 normalcase 16.406 us/op 5.4070 us/op 3.03
phase0 processRegistryUpdates - 250000 badcase_full_deposits 472.32 us/op 263.57 us/op 1.79
phase0 processRegistryUpdates - 250000 worstcase 0.5 229.80 ms/op 161.94 ms/op 1.42
altair processRewardsAndPenalties - 250000 normalcase 133.43 ms/op 92.433 ms/op 1.44
altair processRewardsAndPenalties - 250000 worstcase 124.12 ms/op 87.752 ms/op 1.41
phase0 getAttestationDeltas - 250000 normalcase 13.751 ms/op 8.6819 ms/op 1.58
phase0 getAttestationDeltas - 250000 worstcase 14.019 ms/op 8.6657 ms/op 1.62
phase0 processSlashings - 250000 worstcase 6.7497 ms/op 3.8256 ms/op 1.76
altair processSyncCommitteeUpdates - 250000 342.68 ms/op 210.77 ms/op 1.63
BeaconState.hashTreeRoot - No change 709.00 ns/op 451.00 ns/op 1.57
BeaconState.hashTreeRoot - 1 full validator 82.545 us/op 52.872 us/op 1.56
BeaconState.hashTreeRoot - 32 full validator 765.82 us/op 527.53 us/op 1.45
BeaconState.hashTreeRoot - 512 full validator 8.5623 ms/op 5.5318 ms/op 1.55
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 112.08 us/op 66.676 us/op 1.68
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.4609 ms/op 1.0829 ms/op 1.35
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 19.918 ms/op 11.824 ms/op 1.68
BeaconState.hashTreeRoot - 1 balances 80.444 us/op 54.497 us/op 1.48
BeaconState.hashTreeRoot - 32 balances 726.44 us/op 454.11 us/op 1.60
BeaconState.hashTreeRoot - 512 balances 7.5684 ms/op 4.1532 ms/op 1.82
BeaconState.hashTreeRoot - 250000 balances 111.95 ms/op 82.039 ms/op 1.36
aggregationBits - 2048 els - zipIndexesInBitList 34.374 us/op 20.413 us/op 1.68
regular array get 100000 times 58.807 us/op 43.392 us/op 1.36
wrappedArray get 100000 times 58.525 us/op 43.396 us/op 1.35
arrayWithProxy get 100000 times 35.738 ms/op 19.482 ms/op 1.83
ssz.Root.equals 634.00 ns/op 373.00 ns/op 1.70
byteArrayEquals 631.00 ns/op 387.00 ns/op 1.63
shuffle list - 16384 els 12.545 ms/op 8.2128 ms/op 1.53
shuffle list - 250000 els 181.29 ms/op 119.56 ms/op 1.52
processSlot - 1 slots 16.911 us/op 9.6830 us/op 1.75
processSlot - 32 slots 2.4232 ms/op 1.4550 ms/op 1.67
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 1.2374 ms/op 451.43 us/op 2.74
getCommitteeAssignments - req 1 vs - 250000 vc 5.6070 ms/op 3.9323 ms/op 1.43
getCommitteeAssignments - req 100 vs - 250000 vc 8.1047 ms/op 5.7452 ms/op 1.41
getCommitteeAssignments - req 1000 vs - 250000 vc 8.4555 ms/op 6.1036 ms/op 1.39
computeProposers - vc 250000 19.920 ms/op 13.593 ms/op 1.47
computeEpochShuffling - vc 250000 187.48 ms/op 121.93 ms/op 1.54
getNextSyncCommittee - vc 250000 333.18 ms/op 205.86 ms/op 1.62
pass gossip attestations to forkchoice per slot 3.6013 ms/op 4.2202 ms/op 0.85
computeDeltas 4.3124 ms/op 2.5047 ms/op 1.72
computeProposerBoostScoreFromBalances 932.56 us/op 580.62 us/op 1.61
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.2325 ms/op 1.6686 ms/op 1.34
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 87.015 us/op 58.844 us/op 1.48
BLS verify - blst-native 2.6810 ms/op 1.5528 ms/op 1.73
BLS verifyMultipleSignatures 3 - blst-native 5.5630 ms/op 3.1926 ms/op 1.74
BLS verifyMultipleSignatures 8 - blst-native 11.939 ms/op 6.9089 ms/op 1.73
BLS verifyMultipleSignatures 32 - blst-native 43.569 ms/op 25.066 ms/op 1.74
BLS aggregatePubkeys 32 - blst-native 60.496 us/op 38.499 us/op 1.57
BLS aggregatePubkeys 128 - blst-native 235.27 us/op 130.18 us/op 1.81
getAttestationsForBlock 72.393 ms/op 41.656 ms/op 1.74
isKnown best case - 1 super set check 565.00 ns/op 366.00 ns/op 1.54
isKnown normal case - 2 super set checks 541.00 ns/op 351.00 ns/op 1.54
isKnown worse case - 16 super set checks 541.00 ns/op 355.00 ns/op 1.52
CheckpointStateCache - add get delete 13.777 us/op 8.0780 us/op 1.71
validate gossip signedAggregateAndProof - struct 6.3576 ms/op 3.6026 ms/op 1.76
validate gossip attestation - struct 3.0181 ms/op 1.6946 ms/op 1.78
altair verifyImport mainnet_s3766816:31 8.6134 s/op 5.2169 s/op 1.65
pickEth1Vote - no votes 2.4384 ms/op 1.5287 ms/op 1.60
pickEth1Vote - max votes 26.545 ms/op 17.574 ms/op 1.51
pickEth1Vote - Eth1Data hashTreeRoot value x2048 14.980 ms/op 9.7668 ms/op 1.53
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 23.727 ms/op 16.622 ms/op 1.43
pickEth1Vote - Eth1Data fastSerialize value x2048 2.0833 ms/op 1.0802 ms/op 1.93
pickEth1Vote - Eth1Data fastSerialize tree x2048 14.319 ms/op 13.045 ms/op 1.10
bytes32 toHexString 1.1840 us/op 756.00 ns/op 1.57
bytes32 Buffer.toString(hex) 790.00 ns/op 527.00 ns/op 1.50
bytes32 Buffer.toString(hex) from Uint8Array 1.0690 us/op 717.00 ns/op 1.49
bytes32 Buffer.toString(hex) + 0x 788.00 ns/op 542.00 ns/op 1.45
Object access 1 prop 0.40200 ns/op 0.27600 ns/op 1.46
Map access 1 prop 0.39200 ns/op 0.24700 ns/op 1.59
Object get x1000 17.647 ns/op 7.8560 ns/op 2.25
Map get x1000 0.97800 ns/op 0.85500 ns/op 1.14
Object set x1000 103.76 ns/op 55.175 ns/op 1.88
Map set x1000 72.459 ns/op 35.879 ns/op 2.02
Return object 10000 times 0.42790 ns/op 0.31880 ns/op 1.34
Throw Error 10000 times 7.5043 us/op 4.3165 us/op 1.74
enrSubnets - fastDeserialize 64 bits 2.8010 us/op 1.9770 us/op 1.42
enrSubnets - ssz BitVector 64 bits 874.00 ns/op 585.00 ns/op 1.49
enrSubnets - fastDeserialize 4 bits 424.00 ns/op 352.00 ns/op 1.20
enrSubnets - ssz BitVector 4 bits 842.00 ns/op 651.00 ns/op 1.29
prioritizePeers score -10:0 att 32-0.1 sync 2-0 105.30 us/op 62.833 us/op 1.68
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 153.44 us/op 83.645 us/op 1.83
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 258.25 us/op 152.07 us/op 1.70
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 582.46 us/op 284.38 us/op 2.05
prioritizePeers score 0:0 att 64-1 sync 4-1 664.40 us/op 296.26 us/op 2.24
RateTracker 1000000 limit, 1 obj count per request 198.48 ns/op 132.08 ns/op 1.50
RateTracker 1000000 limit, 2 obj count per request 144.85 ns/op 94.243 ns/op 1.54
RateTracker 1000000 limit, 4 obj count per request 121.07 ns/op 76.031 ns/op 1.59
RateTracker 1000000 limit, 8 obj count per request 106.46 ns/op 67.507 ns/op 1.58
RateTracker with prune 4.6060 us/op 2.9520 us/op 1.56
array of 16000 items push then shift 5.3756 us/op 36.872 us/op 0.15
LinkedList of 16000 items push then shift 26.904 ns/op 12.740 ns/op 2.11
array of 16000 items push then pop 234.70 ns/op 160.50 ns/op 1.46
LinkedList of 16000 items push then pop 24.193 ns/op 10.695 ns/op 2.26
array of 24000 items push then shift 8.5960 us/op 56.133 us/op 0.15
LinkedList of 24000 items push then shift 29.148 ns/op 15.543 ns/op 1.88
array of 24000 items push then pop 205.26 ns/op 118.58 ns/op 1.73
LinkedList of 24000 items push then pop 23.104 ns/op 12.203 ns/op 1.89
intersect bitArray bitLen 8 12.621 ns/op 8.1000 ns/op 1.56
intersect array and set length 8 179.47 ns/op 98.082 ns/op 1.83
intersect bitArray bitLen 128 73.566 ns/op 41.256 ns/op 1.78
intersect array and set length 128 2.3345 us/op 1.2921 us/op 1.81

by benchmarkbot/action

@g11tech g11tech force-pushed the g11tech/mev-integration branch 3 times, most recently from 2e78e09 to 3608f31 Compare June 14, 2022 09:39
@g11tech
Copy link
Contributor Author

g11tech commented Jun 14, 2022

Update successful lodestar <> kiln builder
image

@g11tech
Copy link
Contributor Author

g11tech commented Jun 14, 2022

update: successful lodestar <> ropsten builder
image

@g11tech g11tech force-pushed the g11tech/mev-integration branch 2 times, most recently from 2b2ebfd to 9e57a7f Compare June 15, 2022 19:17
import {toHexString, byteArrayEquals} from "@chainsafe/ssz";
import {CachedBeaconStateBellatrix} from "../types.js";
import {getRandaoMix} from "../util/index.js";
import {ExecutionEngine} from "../util/executionEngine.js";
import {isMergeTransitionComplete} from "../util/bellatrix.js";

export function processExecutionPayload(
export function processExecutionPayload<T extends allForks.BlockType>(
type: T,
Copy link
Contributor

Choose a reason for hiding this comment

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

If would be nice if we can avoid having to pass this type everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed, now conditioned on the body's execution payload/header inspection of the block 👍


private registerValidator = async (epoch: Epoch): Promise<void> => {
if (epoch < this.config.BELLATRIX_FORK_EPOCH - 1) return;
this.getValidatorRegistrations(epoch, this.indicesService.getAllLocalIndices())
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have to register all validators for every epoch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because a validator registration might only be valid for 2 epochs on the builder, its just simpler to blindly register validator with them every epoch. 🤔

@g11tech g11tech force-pushed the g11tech/mev-integration branch 3 times, most recently from 6936a04 to 7bf6a82 Compare June 27, 2022 08:19
Comment on lines 35 to 36
const fullOrBlindedBody = ((block as bellatrix.BlindedBeaconBlock).body ??
(block as bellatrix.BeaconBlock).body) as allForks.FullOrBlindedBellatrixBeaconBlockBody;
Copy link
Member

Choose a reason for hiding this comment

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

Is this intended? It looks like without type assertions, this reads like block.body ?? block.body

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good eye @wemeetagain! thanks 🙂

): ISignatureSet {
const {config, epochCtx} = state;
const domain = state.config.getDomain(DOMAIN_BEACON_PROPOSER, signedBlock.message.slot);

// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const blockType = (signedBlock.message as bellatrix.BlindedBeaconBlock).body.executionPayloadHeader
? ssz.bellatrix.BlindedBeaconBlock
Copy link
Member

Choose a reason for hiding this comment

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

We should add the blinded variants to getForkTypes somehow.

Copy link
Contributor Author

@g11tech g11tech Jun 27, 2022

Choose a reason for hiding this comment

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

can I pick this in the followup ? Will add this to a followup issue tracker among few others i think.

@g11tech g11tech marked this pull request as ready for review June 27, 2022 19:00
@g11tech g11tech requested a review from a team as a code owner June 27, 2022 19:00
 * extract builder in its own folder space

 * fix engine path

 * rebase fixes

 * refactor the builder with latest beacon state transtion processing changes

 * fix the registration signature

 * make typescript happy

 * remove the early return

 * rebase fixes

 * gas limit option

 * builder enabling on validator, gaslimit and other refac

 * fixes

 * Rebase fixes with the api refac

 * some cleanup fixes

 * comment explaining the immediate registration call

 * use already defined batchItems

 * serialize the validator registration chunks

 * validate transactions root on payload response

 * removing the BlockType from global types and sandboxing it just inside block factory

 * make builder optional in dev validator setup

 * option builder with dev val init with keystores

 * add builder api test routes

 * fix validator tests

 * fix block assembly scripts

 * handle the mergemock customization

 * fix body extraction

 * remove linter superession for boolean expressions
@@ -46,10 +46,18 @@ export function processExecutionPayload(
// if executionEngine is null, executionEngine.onPayload MUST be called after running processBlock to get the
// correct randao mix. Since executionEngine will be an async call in most cases it is called afterwards to keep
// the state transition sync
if (executionEngine && !executionEngine.notifyNewPayload(payload)) {
if (
(payload as bellatrix.ExecutionPayload).transactions !== undefined &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless it looks really annoying this should be a type guard. Like

function isExecutionPayload(
  payload: bellatrix.ExecutionPayload | bellatrix.ExecutionPayloadBlinded
): payload is bellatrix.ExecutionPayload {
  return (payload as bellatrix.ExecutionPayload).transactions !== undefined
}

if (isExecutionPayload(payload) && !executionEngine.notifyNewPayload(payload as bellatrix.ExecutionPayload)) {
      throw Error("Invalid execution payload");
}

throw Error("Invalid execution payload");
}

const transactionsRoot =
(payload as bellatrix.ExecutionPayloadHeader).transactionsRoot ??
ssz.bellatrix.Transactions.hashTreeRoot((payload as bellatrix.ExecutionPayload).transactions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, use type guards

): ISignatureSet {
const {config, epochCtx} = state;
const domain = state.config.getDomain(DOMAIN_BEACON_PROPOSER, signedBlock.message.slot);

const blockType =
(signedBlock.message as bellatrix.BlindedBeaconBlock).body.executionPayloadHeader !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Use type guards

options?: {verifyStateRoot?: boolean; verifyProposer?: boolean; verifySignatures?: boolean},
metrics?: IBeaconStateTransitionMetrics | null
): CachedBeaconStateAllForks {
const {verifyStateRoot = true, verifyProposer = true, verifySignatures = true} = options || {};

const block = signedBlock.message;
const block = signedBlock.message as allForks.FullOrBlindedBeaconBlock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this casting necessary? If so why?

return (
isMergeTransitionComplete(state) ||
!ssz.bellatrix.ExecutionPayload.equals(body.executionPayload, ssz.bellatrix.ExecutionPayload.defaultValue())
((body as bellatrix.BlindedBeaconBlockBody).executionPayloadHeader !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Use type guards

@dapplion
Copy link
Contributor

I think we can have two directories named executionEngine and executionBuilder instead of both in the same execution dir. Less diff and there's always the opportunity to merge them once executionBuilder is final

Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

LGMT! @g11tech merging so be able to test live, let's keep iterating on it after the fact

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.

Mev Boost / flashbots integration tracker
4 participants