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

feat: check gas limit in header received from builder #7336

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Jan 7, 2025

Motivation

As per spec the builder must adhere to the preferred gas limit of the validator

The builder MUST build an execution payload whose gas_limit is equal to the gas_limit of the latest registration for pubkey, or as close as is possible under the consensus rules.

but currently we are not validating this anywhere and rely on honest builder behavior which is not great considering there are only two builder that produce most of the blocks.

Description

This PR adds a check the to builder flow that compares the expected gas limit against the target gas limit (ie. preferred gas limit of validator) and rejects the builder block in case there is a mismatch which will trigger the fallback to local block.

The expected gas limit is calculated based on this spec

def expected_gas_limit(parent_gas_limit, target_gas_limit):
  max_gas_limit_difference = (parent_gas_limit // 1024) - 1
  if target_gas_limit > parent_gas_limit:
    gas_diff = target_gas_limit - parent_gas_limit
    return parent_gas_limit + min(gas_diff, max_gas_limit_difference)
  else:
    gas_diff = parent_gas_limit - target_gas_limit
    return parent_gas_limit - min(gas_diff, max_gas_limit_difference)

I haven't found where this is defined but it's based on what other clients implement (eg. prysmaticlabs/prysm#14707 and Consensys/teku#8909) and makes sense considering gas limit checks in EIP-1559.

image

@nflaig nflaig force-pushed the nflaig/check-header-gas-limit branch from 587034f to c0308f9 Compare January 7, 2025 19:34
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.76%. Comparing base (18a0d68) to head (3f91ab5).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #7336   +/-   ##
=========================================
  Coverage     48.76%   48.76%           
=========================================
  Files           601      601           
  Lines         40243    40243           
  Branches       2067     2067           
=========================================
  Hits          19626    19626           
  Misses        20579    20579           
  Partials         38       38           

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: d127861 Previous: 18a0d68 Ratio
forkChoice updateHead vc 600000 bc 64 eq 300000 12.769 ms/op 54.706 ms/op 0.23
Full benchmark results
Benchmark suite Current: d127861 Previous: 18a0d68 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.6659 ms/op 1.1040 ms/op 1.51
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 51.153 us/op 47.211 us/op 1.08
BLS verify - blst 866.32 us/op 792.70 us/op 1.09
BLS verifyMultipleSignatures 3 - blst 1.3195 ms/op 1.2621 ms/op 1.05
BLS verifyMultipleSignatures 8 - blst 2.0480 ms/op 1.8084 ms/op 1.13
BLS verifyMultipleSignatures 32 - blst 4.4834 ms/op 5.0180 ms/op 0.89
BLS verifyMultipleSignatures 64 - blst 8.0483 ms/op 9.4633 ms/op 0.85
BLS verifyMultipleSignatures 128 - blst 16.405 ms/op 17.988 ms/op 0.91
BLS deserializing 10000 signatures 611.55 ms/op 734.03 ms/op 0.83
BLS deserializing 100000 signatures 6.1141 s/op 7.1874 s/op 0.85
BLS verifyMultipleSignatures - same message - 3 - blst 932.21 us/op 910.52 us/op 1.02
BLS verifyMultipleSignatures - same message - 8 - blst 1.0544 ms/op 999.57 us/op 1.05
BLS verifyMultipleSignatures - same message - 32 - blst 1.6745 ms/op 1.7200 ms/op 0.97
BLS verifyMultipleSignatures - same message - 64 - blst 2.4718 ms/op 2.6512 ms/op 0.93
BLS verifyMultipleSignatures - same message - 128 - blst 4.0191 ms/op 4.4681 ms/op 0.90
BLS aggregatePubkeys 32 - blst 18.139 us/op 20.493 us/op 0.89
BLS aggregatePubkeys 128 - blst 63.220 us/op 73.004 us/op 0.87
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 54.410 ms/op 58.541 ms/op 0.93
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 57.516 ms/op 50.429 ms/op 1.14
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 40.718 ms/op 42.456 ms/op 0.96
getSlashingsAndExits - default max 112.75 us/op 129.35 us/op 0.87
getSlashingsAndExits - 2k 495.48 us/op 392.83 us/op 1.26
proposeBlockBody type=full, size=empty 5.0506 ms/op 6.5200 ms/op 0.77
isKnown best case - 1 super set check 450.00 ns/op 298.00 ns/op 1.51
isKnown normal case - 2 super set checks 455.00 ns/op 312.00 ns/op 1.46
isKnown worse case - 16 super set checks 439.00 ns/op 278.00 ns/op 1.58
InMemoryCheckpointStateCache - add get delete 2.5630 us/op 3.1020 us/op 0.83
validate api signedAggregateAndProof - struct 1.4311 ms/op 1.4079 ms/op 1.02
validate gossip signedAggregateAndProof - struct 1.9444 ms/op 1.3852 ms/op 1.40
batch validate gossip attestation - vc 640000 - chunk 32 119.80 us/op 129.49 us/op 0.93
batch validate gossip attestation - vc 640000 - chunk 64 100.72 us/op 124.61 us/op 0.81
batch validate gossip attestation - vc 640000 - chunk 128 94.167 us/op 119.80 us/op 0.79
batch validate gossip attestation - vc 640000 - chunk 256 91.547 us/op 136.26 us/op 0.67
pickEth1Vote - no votes 883.25 us/op 1.6040 ms/op 0.55
pickEth1Vote - max votes 4.3455 ms/op 10.273 ms/op 0.42
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.8342 ms/op 21.005 ms/op 0.47
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.494 ms/op 29.523 ms/op 0.73
pickEth1Vote - Eth1Data fastSerialize value x2048 472.69 us/op 673.54 us/op 0.70
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.4429 ms/op 4.0605 ms/op 0.85
bytes32 toHexString 759.00 ns/op 773.00 ns/op 0.98
bytes32 Buffer.toString(hex) 496.00 ns/op 301.00 ns/op 1.65
bytes32 Buffer.toString(hex) from Uint8Array 762.00 ns/op 548.00 ns/op 1.39
bytes32 Buffer.toString(hex) + 0x 502.00 ns/op 305.00 ns/op 1.65
Object access 1 prop 0.37600 ns/op 0.21900 ns/op 1.72
Map access 1 prop 0.33600 ns/op 0.15500 ns/op 2.17
Object get x1000 5.8330 ns/op 7.2020 ns/op 0.81
Map get x1000 6.3200 ns/op 8.5130 ns/op 0.74
Object set x1000 27.635 ns/op 60.314 ns/op 0.46
Map set x1000 20.462 ns/op 40.622 ns/op 0.50
Return object 10000 times 0.31380 ns/op 0.35520 ns/op 0.88
Throw Error 10000 times 2.6913 us/op 3.9594 us/op 0.68
toHex 112.54 ns/op 197.22 ns/op 0.57
Buffer.from 103.88 ns/op 176.45 ns/op 0.59
shared Buffer 69.342 ns/op 108.70 ns/op 0.64
fastMsgIdFn sha256 / 200 bytes 2.0490 us/op 2.8720 us/op 0.71
fastMsgIdFn h32 xxhash / 200 bytes 420.00 ns/op 370.00 ns/op 1.14
fastMsgIdFn h64 xxhash / 200 bytes 455.00 ns/op 314.00 ns/op 1.45
fastMsgIdFn sha256 / 1000 bytes 7.2340 us/op 8.4200 us/op 0.86
fastMsgIdFn h32 xxhash / 1000 bytes 673.00 ns/op 512.00 ns/op 1.31
fastMsgIdFn h64 xxhash / 1000 bytes 631.00 ns/op 421.00 ns/op 1.50
fastMsgIdFn sha256 / 10000 bytes 50.556 us/op 73.741 us/op 0.69
fastMsgIdFn h32 xxhash / 10000 bytes 2.0430 us/op 2.1740 us/op 0.94
fastMsgIdFn h64 xxhash / 10000 bytes 1.4000 us/op 1.3840 us/op 1.01
send data - 1000 256B messages 16.746 ms/op 17.468 ms/op 0.96
send data - 1000 512B messages 17.213 ms/op 23.414 ms/op 0.74
send data - 1000 1024B messages 25.232 ms/op 32.408 ms/op 0.78
send data - 1000 1200B messages 28.075 ms/op 33.454 ms/op 0.84
send data - 1000 2048B messages 36.036 ms/op 40.143 ms/op 0.90
send data - 1000 4096B messages 28.213 ms/op 40.915 ms/op 0.69
send data - 1000 16384B messages 75.094 ms/op 87.057 ms/op 0.86
send data - 1000 65536B messages 413.30 ms/op 258.91 ms/op 1.60
enrSubnets - fastDeserialize 64 bits 1.3710 us/op 1.4450 us/op 0.95
enrSubnets - ssz BitVector 64 bits 661.00 ns/op 543.00 ns/op 1.22
enrSubnets - fastDeserialize 4 bits 404.00 ns/op 249.00 ns/op 1.62
enrSubnets - ssz BitVector 4 bits 697.00 ns/op 460.00 ns/op 1.52
prioritizePeers score -10:0 att 32-0.1 sync 2-0 168.40 us/op 172.08 us/op 0.98
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 195.74 us/op 196.04 us/op 1.00
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 263.13 us/op 250.96 us/op 1.05
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 421.05 us/op 452.34 us/op 0.93
prioritizePeers score 0:0 att 64-1 sync 4-1 509.05 us/op 741.52 us/op 0.69
array of 16000 items push then shift 1.3690 us/op 1.8877 us/op 0.73
LinkedList of 16000 items push then shift 7.6270 ns/op 9.5570 ns/op 0.80
array of 16000 items push then pop 128.34 ns/op 149.58 ns/op 0.86
LinkedList of 16000 items push then pop 6.7240 ns/op 9.6270 ns/op 0.70
array of 24000 items push then shift 2.0053 us/op 2.7987 us/op 0.72
LinkedList of 24000 items push then shift 7.3590 ns/op 9.7710 ns/op 0.75
array of 24000 items push then pop 162.58 ns/op 206.17 ns/op 0.79
LinkedList of 24000 items push then pop 6.8640 ns/op 9.4400 ns/op 0.73
intersect bitArray bitLen 8 5.6050 ns/op 7.7050 ns/op 0.73
intersect array and set length 8 38.529 ns/op 81.517 ns/op 0.47
intersect bitArray bitLen 128 26.788 ns/op 35.515 ns/op 0.75
intersect array and set length 128 626.25 ns/op 974.26 ns/op 0.64
bitArray.getTrueBitIndexes() bitLen 128 1.6520 us/op 2.2000 us/op 0.75
bitArray.getTrueBitIndexes() bitLen 248 2.5050 us/op 3.4210 us/op 0.73
bitArray.getTrueBitIndexes() bitLen 512 5.7230 us/op 6.9960 us/op 0.82
Buffer.concat 32 items 1.0390 us/op 1.0390 us/op 1.00
Uint8Array.set 32 items 2.3050 us/op 1.9080 us/op 1.21
Buffer.copy 3.1980 us/op 3.7130 us/op 0.86
Uint8Array.set - with subarray 3.5990 us/op 3.7970 us/op 0.95
Uint8Array.set - without subarray 1.7560 us/op 1.9480 us/op 0.90
getUint32 - dataview 461.00 ns/op 335.00 ns/op 1.38
getUint32 - manual 444.00 ns/op 290.00 ns/op 1.53
Set add up to 64 items then delete first 1.8570 us/op 3.1121 us/op 0.60
OrderedSet add up to 64 items then delete first 2.8311 us/op 4.5860 us/op 0.62
Set add up to 64 items then delete last 2.1469 us/op 3.5031 us/op 0.61
OrderedSet add up to 64 items then delete last 3.2436 us/op 5.1197 us/op 0.63
Set add up to 64 items then delete middle 2.1886 us/op 3.2713 us/op 0.67
OrderedSet add up to 64 items then delete middle 4.7534 us/op 6.9993 us/op 0.68
Set add up to 128 items then delete first 4.0711 us/op 7.6949 us/op 0.53
OrderedSet add up to 128 items then delete first 6.3493 us/op 11.991 us/op 0.53
Set add up to 128 items then delete last 3.9118 us/op 7.3426 us/op 0.53
OrderedSet add up to 128 items then delete last 6.0258 us/op 11.144 us/op 0.54
Set add up to 128 items then delete middle 3.9134 us/op 7.1830 us/op 0.54
OrderedSet add up to 128 items then delete middle 12.267 us/op 18.298 us/op 0.67
Set add up to 256 items then delete first 10.961 us/op 14.755 us/op 0.74
OrderedSet add up to 256 items then delete first 17.837 us/op 23.239 us/op 0.77
Set add up to 256 items then delete last 9.8601 us/op 14.654 us/op 0.67
OrderedSet add up to 256 items then delete last 16.452 us/op 22.452 us/op 0.73
Set add up to 256 items then delete middle 10.498 us/op 14.272 us/op 0.74
OrderedSet add up to 256 items then delete middle 39.057 us/op 56.682 us/op 0.69
transfer serialized Status (84 B) 3.3220 us/op 3.7240 us/op 0.89
copy serialized Status (84 B) 2.1520 us/op 1.8040 us/op 1.19
transfer serialized SignedVoluntaryExit (112 B) 3.7710 us/op 3.8880 us/op 0.97
copy serialized SignedVoluntaryExit (112 B) 2.2070 us/op 2.0090 us/op 1.10
transfer serialized ProposerSlashing (416 B) 4.5050 us/op 4.1870 us/op 1.08
copy serialized ProposerSlashing (416 B) 3.6560 us/op 2.7620 us/op 1.32
transfer serialized Attestation (485 B) 4.7780 us/op 4.4420 us/op 1.08
copy serialized Attestation (485 B) 2.5660 us/op 3.0550 us/op 0.84
transfer serialized AttesterSlashing (33232 B) 3.0370 us/op 4.1330 us/op 0.73
copy serialized AttesterSlashing (33232 B) 8.3030 us/op 11.656 us/op 0.71
transfer serialized Small SignedBeaconBlock (128000 B) 3.4520 us/op 5.5230 us/op 0.63
copy serialized Small SignedBeaconBlock (128000 B) 20.889 us/op 39.357 us/op 0.53
transfer serialized Avg SignedBeaconBlock (200000 B) 4.5480 us/op 6.6050 us/op 0.69
copy serialized Avg SignedBeaconBlock (200000 B) 21.444 us/op 49.477 us/op 0.43
transfer serialized BlobsSidecar (524380 B) 3.7050 us/op 7.0350 us/op 0.53
copy serialized BlobsSidecar (524380 B) 106.70 us/op 157.96 us/op 0.68
transfer serialized Big SignedBeaconBlock (1000000 B) 6.2580 us/op 8.6260 us/op 0.73
copy serialized Big SignedBeaconBlock (1000000 B) 161.62 us/op 256.58 us/op 0.63
pass gossip attestations to forkchoice per slot 2.9928 ms/op 3.4914 ms/op 0.86
forkChoice updateHead vc 100000 bc 64 eq 0 485.86 us/op 567.06 us/op 0.86
forkChoice updateHead vc 600000 bc 64 eq 0 6.8389 ms/op 6.2050 ms/op 1.10
forkChoice updateHead vc 1000000 bc 64 eq 0 5.2598 ms/op 9.0462 ms/op 0.58
forkChoice updateHead vc 600000 bc 320 eq 0 2.5873 ms/op 4.6535 ms/op 0.56
forkChoice updateHead vc 600000 bc 1200 eq 0 3.2606 ms/op 5.0855 ms/op 0.64
forkChoice updateHead vc 600000 bc 7200 eq 0 3.5183 ms/op 7.6865 ms/op 0.46
forkChoice updateHead vc 600000 bc 64 eq 1000 10.513 ms/op 16.702 ms/op 0.63
forkChoice updateHead vc 600000 bc 64 eq 10000 10.425 ms/op 12.679 ms/op 0.82
forkChoice updateHead vc 600000 bc 64 eq 300000 12.769 ms/op 54.706 ms/op 0.23
computeDeltas 500000 validators 300 proto nodes 4.6153 ms/op 5.6119 ms/op 0.82
computeDeltas 500000 validators 1200 proto nodes 4.7733 ms/op 5.2537 ms/op 0.91
computeDeltas 500000 validators 7200 proto nodes 3.9581 ms/op 8.6721 ms/op 0.46
computeDeltas 750000 validators 300 proto nodes 5.5673 ms/op 8.8509 ms/op 0.63
computeDeltas 750000 validators 1200 proto nodes 5.8202 ms/op 8.1025 ms/op 0.72
computeDeltas 750000 validators 7200 proto nodes 6.2361 ms/op 7.5593 ms/op 0.82
computeDeltas 1400000 validators 300 proto nodes 10.946 ms/op 12.782 ms/op 0.86
computeDeltas 1400000 validators 1200 proto nodes 10.216 ms/op 12.194 ms/op 0.84
computeDeltas 1400000 validators 7200 proto nodes 10.210 ms/op 13.799 ms/op 0.74
computeDeltas 2100000 validators 300 proto nodes 14.264 ms/op 21.314 ms/op 0.67
computeDeltas 2100000 validators 1200 proto nodes 13.739 ms/op 21.306 ms/op 0.64
computeDeltas 2100000 validators 7200 proto nodes 14.030 ms/op 19.749 ms/op 0.71
altair processAttestation - 250000 vs - 7PWei normalcase 1.7249 ms/op 3.1429 ms/op 0.55
altair processAttestation - 250000 vs - 7PWei worstcase 2.5834 ms/op 4.2468 ms/op 0.61
altair processAttestation - setStatus - 1/6 committees join 97.041 us/op 195.07 us/op 0.50
altair processAttestation - setStatus - 1/3 committees join 196.04 us/op 331.87 us/op 0.59
altair processAttestation - setStatus - 1/2 committees join 272.36 us/op 388.20 us/op 0.70
altair processAttestation - setStatus - 2/3 committees join 363.64 us/op 499.21 us/op 0.73
altair processAttestation - setStatus - 4/5 committees join 510.43 us/op 729.22 us/op 0.70
altair processAttestation - setStatus - 100% committees join 642.33 us/op 890.47 us/op 0.72
altair processBlock - 250000 vs - 7PWei normalcase 3.6570 ms/op 6.8430 ms/op 0.53
altair processBlock - 250000 vs - 7PWei normalcase hashState 25.102 ms/op 31.233 ms/op 0.80
altair processBlock - 250000 vs - 7PWei worstcase 35.310 ms/op 37.961 ms/op 0.93
altair processBlock - 250000 vs - 7PWei worstcase hashState 74.864 ms/op 78.791 ms/op 0.95
phase0 processBlock - 250000 vs - 7PWei normalcase 1.7929 ms/op 2.2133 ms/op 0.81
phase0 processBlock - 250000 vs - 7PWei worstcase 23.524 ms/op 24.012 ms/op 0.98
altair processEth1Data - 250000 vs - 7PWei normalcase 257.71 us/op 425.65 us/op 0.61
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 7.3120 us/op 6.7690 us/op 1.08
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 40.275 us/op 54.588 us/op 0.74
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 10.327 us/op 11.667 us/op 0.89
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 9.2970 us/op 7.6390 us/op 1.22
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 129.45 us/op 185.34 us/op 0.70
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.0090 ms/op 1.2444 ms/op 0.81
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.2798 ms/op 1.9692 ms/op 0.65
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.1808 ms/op 1.6513 ms/op 0.72
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.3623 ms/op 4.2397 ms/op 0.79
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.2798 ms/op 1.8969 ms/op 0.67
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 2.9639 ms/op 4.7207 ms/op 0.63
Tree 40 250000 create 229.30 ms/op 236.17 ms/op 0.97
Tree 40 250000 get(125000) 121.31 ns/op 174.61 ns/op 0.69
Tree 40 250000 set(125000) 613.88 ns/op 716.68 ns/op 0.86
Tree 40 250000 toArray() 18.355 ms/op 19.876 ms/op 0.92
Tree 40 250000 iterate all - toArray() + loop 17.948 ms/op 21.781 ms/op 0.82
Tree 40 250000 iterate all - get(i) 50.916 ms/op 58.009 ms/op 0.88
Array 250000 create 2.4335 ms/op 3.6614 ms/op 0.66
Array 250000 clone - spread 1.3578 ms/op 1.5433 ms/op 0.88
Array 250000 get(125000) 0.59900 ns/op 0.44300 ns/op 1.35
Array 250000 set(125000) 0.59000 ns/op 0.46500 ns/op 1.27
Array 250000 iterate all - loop 77.456 us/op 100.53 us/op 0.77
phase0 afterProcessEpoch - 250000 vs - 7PWei 42.314 ms/op 54.594 ms/op 0.78
Array.fill - length 1000000 2.6022 ms/op 3.8453 ms/op 0.68
Array push - length 1000000 13.972 ms/op 18.948 ms/op 0.74
Array.get 0.26397 ns/op 0.30015 ns/op 0.88
Uint8Array.get 0.34092 ns/op 0.46504 ns/op 0.73
phase0 beforeProcessEpoch - 250000 vs - 7PWei 16.618 ms/op 19.130 ms/op 0.87
altair processEpoch - mainnet_e81889 276.48 ms/op 298.37 ms/op 0.93
mainnet_e81889 - altair beforeProcessEpoch 18.601 ms/op 19.098 ms/op 0.97
mainnet_e81889 - altair processJustificationAndFinalization 16.775 us/op 15.133 us/op 1.11
mainnet_e81889 - altair processInactivityUpdates 4.6712 ms/op 5.5439 ms/op 0.84
mainnet_e81889 - altair processRewardsAndPenalties 52.211 ms/op 45.273 ms/op 1.15
mainnet_e81889 - altair processRegistryUpdates 3.2430 us/op 2.5690 us/op 1.26
mainnet_e81889 - altair processSlashings 973.00 ns/op 477.00 ns/op 2.04
mainnet_e81889 - altair processEth1DataReset 1.0920 us/op 556.00 ns/op 1.96
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.0379 ms/op 1.4729 ms/op 0.70
mainnet_e81889 - altair processSlashingsReset 3.3480 us/op 3.3310 us/op 1.01
mainnet_e81889 - altair processRandaoMixesReset 8.9110 us/op 6.3210 us/op 1.41
mainnet_e81889 - altair processHistoricalRootsUpdate 1.4920 us/op 680.00 ns/op 2.19
mainnet_e81889 - altair processParticipationFlagUpdates 2.5050 us/op 2.2480 us/op 1.11
mainnet_e81889 - altair processSyncCommitteeUpdates 1.4390 us/op 608.00 ns/op 2.37
mainnet_e81889 - altair afterProcessEpoch 44.667 ms/op 53.893 ms/op 0.83
capella processEpoch - mainnet_e217614 1.0807 s/op 1.0443 s/op 1.03
mainnet_e217614 - capella beforeProcessEpoch 82.615 ms/op 80.452 ms/op 1.03
mainnet_e217614 - capella processJustificationAndFinalization 17.531 us/op 17.341 us/op 1.01
mainnet_e217614 - capella processInactivityUpdates 15.459 ms/op 20.327 ms/op 0.76
mainnet_e217614 - capella processRewardsAndPenalties 244.63 ms/op 247.42 ms/op 0.99
mainnet_e217614 - capella processRegistryUpdates 22.287 us/op 18.912 us/op 1.18
mainnet_e217614 - capella processSlashings 1.0420 us/op 1.7500 us/op 0.60
mainnet_e217614 - capella processEth1DataReset 1.0380 us/op 819.00 ns/op 1.27
mainnet_e217614 - capella processEffectiveBalanceUpdates 16.399 ms/op 18.384 ms/op 0.89
mainnet_e217614 - capella processSlashingsReset 3.8180 us/op 8.3470 us/op 0.46
mainnet_e217614 - capella processRandaoMixesReset 11.095 us/op 6.6240 us/op 1.67
mainnet_e217614 - capella processHistoricalRootsUpdate 1.2480 us/op 883.00 ns/op 1.41
mainnet_e217614 - capella processParticipationFlagUpdates 2.5670 us/op 3.0620 us/op 0.84
mainnet_e217614 - capella afterProcessEpoch 110.68 ms/op 135.77 ms/op 0.82
phase0 processEpoch - mainnet_e58758 370.64 ms/op 356.94 ms/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 88.626 ms/op 104.34 ms/op 0.85
mainnet_e58758 - phase0 processJustificationAndFinalization 14.800 us/op 18.855 us/op 0.78
mainnet_e58758 - phase0 processRewardsAndPenalties 26.956 ms/op 22.626 ms/op 1.19
mainnet_e58758 - phase0 processRegistryUpdates 13.019 us/op 10.449 us/op 1.25
mainnet_e58758 - phase0 processSlashings 1.1680 us/op 559.00 ns/op 2.09
mainnet_e58758 - phase0 processEth1DataReset 947.00 ns/op 465.00 ns/op 2.04
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0021 ms/op 1.2448 ms/op 0.81
mainnet_e58758 - phase0 processSlashingsReset 2.9570 us/op 4.9140 us/op 0.60
mainnet_e58758 - phase0 processRandaoMixesReset 6.2590 us/op 6.5380 us/op 0.96
mainnet_e58758 - phase0 processHistoricalRootsUpdate 881.00 ns/op 850.00 ns/op 1.04
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.2820 us/op 4.0240 us/op 1.31
mainnet_e58758 - phase0 afterProcessEpoch 36.147 ms/op 45.942 ms/op 0.79
phase0 processEffectiveBalanceUpdates - 250000 normalcase 963.02 us/op 1.4330 ms/op 0.67
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.3650 ms/op 2.2870 ms/op 0.60
altair processInactivityUpdates - 250000 normalcase 16.858 ms/op 18.418 ms/op 0.92
altair processInactivityUpdates - 250000 worstcase 17.640 ms/op 18.220 ms/op 0.97
phase0 processRegistryUpdates - 250000 normalcase 9.5010 us/op 12.650 us/op 0.75
phase0 processRegistryUpdates - 250000 badcase_full_deposits 389.80 us/op 324.54 us/op 1.20
phase0 processRegistryUpdates - 250000 worstcase 0.5 81.854 ms/op 123.54 ms/op 0.66
altair processRewardsAndPenalties - 250000 normalcase 32.749 ms/op 40.173 ms/op 0.82
altair processRewardsAndPenalties - 250000 worstcase 35.441 ms/op 41.678 ms/op 0.85
phase0 getAttestationDeltas - 250000 normalcase 6.2237 ms/op 9.7855 ms/op 0.64
phase0 getAttestationDeltas - 250000 worstcase 6.3269 ms/op 8.1581 ms/op 0.78
phase0 processSlashings - 250000 worstcase 100.54 us/op 88.620 us/op 1.13
altair processSyncCommitteeUpdates - 250000 103.95 ms/op 136.98 ms/op 0.76
BeaconState.hashTreeRoot - No change 477.00 ns/op 270.00 ns/op 1.77
BeaconState.hashTreeRoot - 1 full validator 120.26 us/op 123.48 us/op 0.97
BeaconState.hashTreeRoot - 32 full validator 1.4857 ms/op 1.1997 ms/op 1.24
BeaconState.hashTreeRoot - 512 full validator 9.4211 ms/op 10.103 ms/op 0.93
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 107.36 us/op 119.19 us/op 0.90
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.3096 ms/op 1.5506 ms/op 1.49
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 19.161 ms/op 19.699 ms/op 0.97
BeaconState.hashTreeRoot - 1 balances 76.000 us/op 97.625 us/op 0.78
BeaconState.hashTreeRoot - 32 balances 660.72 us/op 874.22 us/op 0.76
BeaconState.hashTreeRoot - 512 balances 5.9406 ms/op 8.1950 ms/op 0.72
BeaconState.hashTreeRoot - 250000 balances 167.87 ms/op 170.69 ms/op 0.98
aggregationBits - 2048 els - zipIndexesInBitList 20.895 us/op 28.054 us/op 0.74
byteArrayEquals 32 49.894 ns/op 59.763 ns/op 0.83
Buffer.compare 32 16.064 ns/op 19.830 ns/op 0.81
byteArrayEquals 1024 1.2438 us/op 1.7725 us/op 0.70
Buffer.compare 1024 24.630 ns/op 29.274 ns/op 0.84
byteArrayEquals 16384 19.761 us/op 27.654 us/op 0.71
Buffer.compare 16384 205.10 ns/op 219.61 ns/op 0.93
byteArrayEquals 123687377 151.28 ms/op 209.90 ms/op 0.72
Buffer.compare 123687377 6.0667 ms/op 8.6221 ms/op 0.70
byteArrayEquals 32 - diff last byte 46.141 ns/op 56.255 ns/op 0.82
Buffer.compare 32 - diff last byte 15.995 ns/op 18.716 ns/op 0.85
byteArrayEquals 1024 - diff last byte 1.2283 us/op 1.6735 us/op 0.73
Buffer.compare 1024 - diff last byte 23.920 ns/op 26.127 ns/op 0.92
byteArrayEquals 16384 - diff last byte 19.498 us/op 26.551 us/op 0.73
Buffer.compare 16384 - diff last byte 195.09 ns/op 208.07 ns/op 0.94
byteArrayEquals 123687377 - diff last byte 150.14 ms/op 199.66 ms/op 0.75
Buffer.compare 123687377 - diff last byte 5.1557 ms/op 6.8407 ms/op 0.75
byteArrayEquals 32 - random bytes 4.9280 ns/op 5.2910 ns/op 0.93
Buffer.compare 32 - random bytes 17.500 ns/op 17.575 ns/op 1.00
byteArrayEquals 1024 - random bytes 5.1740 ns/op 5.2740 ns/op 0.98
Buffer.compare 1024 - random bytes 17.130 ns/op 17.678 ns/op 0.97
byteArrayEquals 16384 - random bytes 4.9110 ns/op 5.2980 ns/op 0.93
Buffer.compare 16384 - random bytes 16.749 ns/op 17.565 ns/op 0.95
byteArrayEquals 123687377 - random bytes 8.7200 ns/op 6.6900 ns/op 1.30
Buffer.compare 123687377 - random bytes 18.880 ns/op 18.880 ns/op 1.00
regular array get 100000 times 30.279 us/op 43.506 us/op 0.70
wrappedArray get 100000 times 30.227 us/op 35.321 us/op 0.86
arrayWithProxy get 100000 times 8.6409 ms/op 12.636 ms/op 0.68
ssz.Root.equals 41.799 ns/op 47.002 ns/op 0.89
byteArrayEquals 41.655 ns/op 46.838 ns/op 0.89
Buffer.compare 9.2510 ns/op 10.536 ns/op 0.88
processSlot - 1 slots 10.992 us/op 13.239 us/op 0.83
processSlot - 32 slots 2.4681 ms/op 2.9151 ms/op 0.85
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.628 ms/op 35.472 ms/op 1.06
getCommitteeAssignments - req 1 vs - 250000 vc 1.7802 ms/op 2.1735 ms/op 0.82
getCommitteeAssignments - req 100 vs - 250000 vc 3.5327 ms/op 4.2247 ms/op 0.84
getCommitteeAssignments - req 1000 vs - 250000 vc 3.8573 ms/op 4.5705 ms/op 0.84
findModifiedValidators - 10000 modified validators 231.06 ms/op 261.29 ms/op 0.88
findModifiedValidators - 1000 modified validators 151.55 ms/op 245.11 ms/op 0.62
findModifiedValidators - 100 modified validators 150.46 ms/op 195.84 ms/op 0.77
findModifiedValidators - 10 modified validators 172.83 ms/op 189.36 ms/op 0.91
findModifiedValidators - 1 modified validators 137.95 ms/op 177.98 ms/op 0.78
findModifiedValidators - no difference 148.71 ms/op 185.25 ms/op 0.80
compare ViewDUs 3.9943 s/op 3.3121 s/op 1.21
compare each validator Uint8Array 1.4206 s/op 1.8383 s/op 0.77
compare ViewDU to Uint8Array 901.41 ms/op 1.4073 s/op 0.64
migrate state 1000000 validators, 24 modified, 0 new 746.06 ms/op 967.85 ms/op 0.77
migrate state 1000000 validators, 1700 modified, 1000 new 900.36 ms/op 1.1327 s/op 0.79
migrate state 1000000 validators, 3400 modified, 2000 new 1.0602 s/op 1.2316 s/op 0.86
migrate state 1500000 validators, 24 modified, 0 new 613.05 ms/op 752.72 ms/op 0.81
migrate state 1500000 validators, 1700 modified, 1000 new 878.27 ms/op 1.2026 s/op 0.73
migrate state 1500000 validators, 3400 modified, 2000 new 1.0669 s/op 1.3114 s/op 0.81
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.1900 ns/op 5.5000 ns/op 1.13
state getBlockRootAtSlot - 250000 vs - 7PWei 989.65 ns/op 995.44 ns/op 0.99
computeProposers - vc 250000 6.1555 ms/op 8.2682 ms/op 0.74
computeEpochShuffling - vc 250000 35.473 ms/op 47.975 ms/op 0.74
getNextSyncCommittee - vc 250000 109.95 ms/op 148.10 ms/op 0.74
computeSigningRoot for AttestationData 23.688 us/op 25.963 us/op 0.91
hash AttestationData serialized data then Buffer.toString(base64) 1.1867 us/op 1.8524 us/op 0.64
toHexString serialized data 768.89 ns/op 1.2352 us/op 0.62
Buffer.toString(base64) 133.23 ns/op 230.95 ns/op 0.58
nodejs block root to RootHex using toHex 125.20 ns/op 181.53 ns/op 0.69
nodejs block root to RootHex using toRootHex 77.613 ns/op 113.03 ns/op 0.69
browser block root to RootHex using the deprecated toHexString 273.25 ns/op 304.67 ns/op 0.90
browser block root to RootHex using toHex 203.69 ns/op 253.53 ns/op 0.80
browser block root to RootHex using toRootHex 156.43 ns/op 198.02 ns/op 0.79

by benchmarkbot/action

@nflaig nflaig force-pushed the nflaig/check-header-gas-limit branch from c0308f9 to d317aef Compare January 7, 2025 21:25
@nflaig nflaig marked this pull request as ready for review January 7, 2025 21:40
@nflaig nflaig requested a review from a team as a code owner January 7, 2025 21:40
gasLimit: number;
};

export class ValidatorRegistrationCache {
Copy link
Member Author

Choose a reason for hiding this comment

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

might be able to combine this with BeaconProposerCache in the future but this requires apis to be consolidated first as proposed in ethereum/beacon-APIs#435

const parentGasLimit = (currentState as CachedBeaconStateBellatrix).latestExecutionPayloadHeader.gasLimit;
const expectedGasLimit = getExpectedGasLimit(parentGasLimit, targetGasLimit);

if (builderRes.header.gasLimit !== expectedGasLimit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think many builders/relays might have bugs over here initially.

we should relax it and make sure its between [parent limit, exected limit] or [expected limit, parent limit] interval and then warn if its not equal to expected

Copy link
Member Author

Choose a reason for hiding this comment

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

i think many builders/relays might have bugs over here initially.

Running this branch on Holesky right now but it's hard to validate if gas target is not moving

we should relax it and make sure its between [parent limit, exected limit] or [expected limit, parent limit]

Right so in this case we should definitely reject as the block would be invalid, we can relax for now and observe this for a while on mainnet, eventually we can enforce the strict check

@@ -128,8 +132,17 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
}
}

async registerValidator(registrations: bellatrix.SignedValidatorRegistrationV1[]): Promise<void> {
async registerValidator(epoch: Epoch, registrations: bellatrix.SignedValidatorRegistrationV1[]): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

is adding epoch to api standard spec now?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an internal method, the api call happens on L136 which does not need the epoch, we only need it to track registrations in our internal cache to be able to prune old records (similar to what we do for proposer cache).

I opted for supplying the epoch by the caller of registerValidator but it could also just use clock.currentEpoch

export function getExpectedGasLimit(parentGasLimit: number, targetGasLimit: number): number {
const maxGasLimitDifference = Math.max(Math.floor(parentGasLimit / gasLimitAdjustmentFactor) - 1, 0);

if (targetGasLimit > parentGasLimit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

good to see upper/lower taken care of

@nflaig nflaig added this to the v1.25.0 milestone Jan 9, 2025
@nflaig nflaig requested a review from g11tech January 10, 2025 13:25
@philknows philknows modified the milestones: v1.25.0, v1.26.0 Jan 10, 2025
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.

3 participants