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: add support for eth_estimateGas #5521

Merged
merged 4 commits into from
May 26, 2023
Merged

Conversation

nazarhussain
Copy link
Contributor

Motivation

Make a feature full prover package.

Description

Add support for eth_estimateGas.

Relates #4261

Steps to test or reproduce

  • Run all tests

@nazarhussain nazarhussain requested a review from a team as a code owner May 22, 2023 18:59
@nazarhussain nazarhussain self-assigned this May 22, 2023
@nazarhussain nazarhussain changed the title Add support for eth_estimateGas feat: add support for eth_estimateGas May 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: a64ab8f Previous: 118f7b9 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 785.04 us/op 645.00 us/op 1.22
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.768 us/op 50.532 us/op 0.93
BLS verify - blst-native 1.2326 ms/op 1.2417 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.4951 ms/op 2.5166 ms/op 0.99
BLS verifyMultipleSignatures 8 - blst-native 5.3502 ms/op 5.4125 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 19.776 ms/op 19.570 ms/op 1.01
BLS aggregatePubkeys 32 - blst-native 26.520 us/op 26.032 us/op 1.02
BLS aggregatePubkeys 128 - blst-native 103.03 us/op 102.21 us/op 1.01
getAttestationsForBlock 62.342 ms/op 56.477 ms/op 1.10
isKnown best case - 1 super set check 256.00 ns/op 266.00 ns/op 0.96
isKnown normal case - 2 super set checks 256.00 ns/op 252.00 ns/op 1.02
isKnown worse case - 16 super set checks 253.00 ns/op 246.00 ns/op 1.03
CheckpointStateCache - add get delete 5.6940 us/op 5.4830 us/op 1.04
validate gossip signedAggregateAndProof - struct 2.8322 ms/op 2.8301 ms/op 1.00
validate gossip attestation - struct 1.3501 ms/op 1.3854 ms/op 0.97
pickEth1Vote - no votes 1.3618 ms/op 1.2989 ms/op 1.05
pickEth1Vote - max votes 10.274 ms/op 10.221 ms/op 1.01
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.222 ms/op 9.2327 ms/op 1.11
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 19.256 ms/op 14.044 ms/op 1.37
pickEth1Vote - Eth1Data fastSerialize value x2048 693.47 us/op 659.13 us/op 1.05
pickEth1Vote - Eth1Data fastSerialize tree x2048 9.2814 ms/op 4.7311 ms/op 1.96
bytes32 toHexString 529.00 ns/op 523.00 ns/op 1.01
bytes32 Buffer.toString(hex) 414.00 ns/op 347.00 ns/op 1.19
bytes32 Buffer.toString(hex) from Uint8Array 607.00 ns/op 595.00 ns/op 1.02
bytes32 Buffer.toString(hex) + 0x 393.00 ns/op 372.00 ns/op 1.06
Object access 1 prop 0.18900 ns/op 0.19000 ns/op 0.99
Map access 1 prop 0.16900 ns/op 0.16600 ns/op 1.02
Object get x1000 6.9360 ns/op 6.6520 ns/op 1.04
Map get x1000 0.65600 ns/op 0.60800 ns/op 1.08
Object set x1000 59.323 ns/op 53.862 ns/op 1.10
Map set x1000 52.520 ns/op 44.386 ns/op 1.18
Return object 10000 times 0.24360 ns/op 0.24400 ns/op 1.00
Throw Error 10000 times 4.5617 us/op 4.3004 us/op 1.06
fastMsgIdFn sha256 / 200 bytes 3.6240 us/op 3.5640 us/op 1.02
fastMsgIdFn h32 xxhash / 200 bytes 304.00 ns/op 300.00 ns/op 1.01
fastMsgIdFn h64 xxhash / 200 bytes 452.00 ns/op 420.00 ns/op 1.08
fastMsgIdFn sha256 / 1000 bytes 12.161 us/op 12.018 us/op 1.01
fastMsgIdFn h32 xxhash / 1000 bytes 450.00 ns/op 414.00 ns/op 1.09
fastMsgIdFn h64 xxhash / 1000 bytes 527.00 ns/op 492.00 ns/op 1.07
fastMsgIdFn sha256 / 10000 bytes 106.53 us/op 104.83 us/op 1.02
fastMsgIdFn h32 xxhash / 10000 bytes 2.0270 us/op 1.9510 us/op 1.04
fastMsgIdFn h64 xxhash / 10000 bytes 1.4960 us/op 1.4330 us/op 1.04
enrSubnets - fastDeserialize 64 bits 1.4750 us/op 1.3990 us/op 1.05
enrSubnets - ssz BitVector 64 bits 609.00 ns/op 526.00 ns/op 1.16
enrSubnets - fastDeserialize 4 bits 196.00 ns/op 190.00 ns/op 1.03
enrSubnets - ssz BitVector 4 bits 581.00 ns/op 539.00 ns/op 1.08
prioritizePeers score -10:0 att 32-0.1 sync 2-0 117.30 us/op 117.97 us/op 0.99
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 163.31 us/op 142.14 us/op 1.15
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 220.58 us/op 187.01 us/op 1.18
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 322.00 us/op 340.68 us/op 0.95
prioritizePeers score 0:0 att 64-1 sync 4-1 409.14 us/op 394.25 us/op 1.04
array of 16000 items push then shift 1.6966 us/op 1.6654 us/op 1.02
LinkedList of 16000 items push then shift 9.1000 ns/op 9.0300 ns/op 1.01
array of 16000 items push then pop 97.768 ns/op 111.08 ns/op 0.88
LinkedList of 16000 items push then pop 8.7080 ns/op 8.8840 ns/op 0.98
array of 24000 items push then shift 2.4209 us/op 2.4288 us/op 1.00
LinkedList of 24000 items push then shift 10.248 ns/op 9.2030 ns/op 1.11
array of 24000 items push then pop 78.802 ns/op 88.281 ns/op 0.89
LinkedList of 24000 items push then pop 8.8740 ns/op 8.9620 ns/op 0.99
intersect bitArray bitLen 8 13.542 ns/op 13.851 ns/op 0.98
intersect array and set length 8 85.786 ns/op 101.97 ns/op 0.84
intersect bitArray bitLen 128 45.039 ns/op 45.646 ns/op 0.99
intersect array and set length 128 1.0950 us/op 1.1651 us/op 0.94
Buffer.concat 32 items 2.7750 us/op 3.1870 us/op 0.87
Uint8Array.set 32 items 3.0980 us/op 3.2070 us/op 0.97
pass gossip attestations to forkchoice per slot 2.3548 ms/op 2.9799 ms/op 0.79
computeDeltas 3.4903 ms/op 3.1512 ms/op 1.11
computeProposerBoostScoreFromBalances 1.8207 ms/op 1.8154 ms/op 1.00
altair processAttestation - 250000 vs - 7PWei normalcase 2.3699 ms/op 2.2126 ms/op 1.07
altair processAttestation - 250000 vs - 7PWei worstcase 3.4722 ms/op 4.3670 ms/op 0.80
altair processAttestation - setStatus - 1/6 committees join 145.32 us/op 145.24 us/op 1.00
altair processAttestation - setStatus - 1/3 committees join 293.30 us/op 293.89 us/op 1.00
altair processAttestation - setStatus - 1/2 committees join 380.04 us/op 437.64 us/op 0.87
altair processAttestation - setStatus - 2/3 committees join 488.01 us/op 478.63 us/op 1.02
altair processAttestation - setStatus - 4/5 committees join 667.17 us/op 674.80 us/op 0.99
altair processAttestation - setStatus - 100% committees join 804.42 us/op 811.27 us/op 0.99
altair processBlock - 250000 vs - 7PWei normalcase 18.462 ms/op 17.025 ms/op 1.08
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.894 ms/op 25.174 ms/op 1.19
altair processBlock - 250000 vs - 7PWei worstcase 54.340 ms/op 54.334 ms/op 1.00
altair processBlock - 250000 vs - 7PWei worstcase hashState 76.448 ms/op 71.365 ms/op 1.07
phase0 processBlock - 250000 vs - 7PWei normalcase 2.0303 ms/op 2.3557 ms/op 0.86
phase0 processBlock - 250000 vs - 7PWei worstcase 29.462 ms/op 32.155 ms/op 0.92
altair processEth1Data - 250000 vs - 7PWei normalcase 500.12 us/op 637.63 us/op 0.78
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 7.9270 us/op 11.562 us/op 0.69
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 27.188 us/op 25.363 us/op 1.07
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 10.574 us/op 10.313 us/op 1.03
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 9.4870 us/op 8.1230 us/op 1.17
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 111.83 us/op 104.22 us/op 1.07
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 812.76 us/op 714.23 us/op 1.14
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.3120 ms/op 914.93 us/op 1.43
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.0196 ms/op 913.89 us/op 1.12
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.6517 ms/op 2.3729 ms/op 1.12
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.9075 ms/op 1.7319 ms/op 1.10
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.1024 ms/op 4.0726 ms/op 1.01
Tree 40 250000 create 383.30 ms/op 334.38 ms/op 1.15
Tree 40 250000 get(125000) 196.33 ns/op 192.04 ns/op 1.02
Tree 40 250000 set(125000) 1.0243 us/op 1.0172 us/op 1.01
Tree 40 250000 toArray() 22.491 ms/op 19.596 ms/op 1.15
Tree 40 250000 iterate all - toArray() + loop 22.470 ms/op 21.307 ms/op 1.05
Tree 40 250000 iterate all - get(i) 76.970 ms/op 73.294 ms/op 1.05
MutableVector 250000 create 12.986 ms/op 10.540 ms/op 1.23
MutableVector 250000 get(125000) 6.6590 ns/op 7.2430 ns/op 0.92
MutableVector 250000 set(125000) 342.16 ns/op 256.46 ns/op 1.33
MutableVector 250000 toArray() 3.8667 ms/op 2.7603 ms/op 1.40
MutableVector 250000 iterate all - toArray() + loop 4.3039 ms/op 3.0665 ms/op 1.40
MutableVector 250000 iterate all - get(i) 1.5685 ms/op 1.7405 ms/op 0.90
Array 250000 create 3.8094 ms/op 2.7465 ms/op 1.39
Array 250000 clone - spread 1.2888 ms/op 1.1835 ms/op 1.09
Array 250000 get(125000) 0.58900 ns/op 0.58400 ns/op 1.01
Array 250000 set(125000) 0.66200 ns/op 0.66300 ns/op 1.00
Array 250000 iterate all - loop 89.797 us/op 88.404 us/op 1.02
effectiveBalanceIncrements clone Uint8Array 300000 33.818 us/op 35.693 us/op 0.95
effectiveBalanceIncrements clone MutableVector 300000 336.00 ns/op 400.00 ns/op 0.84
effectiveBalanceIncrements rw all Uint8Array 300000 172.29 us/op 169.43 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 84.175 ms/op 92.619 ms/op 0.91
phase0 afterProcessEpoch - 250000 vs - 7PWei 116.89 ms/op 117.10 ms/op 1.00
phase0 beforeProcessEpoch - 250000 vs - 7PWei 34.567 ms/op 41.452 ms/op 0.83
altair processEpoch - mainnet_e81889 349.62 ms/op 358.35 ms/op 0.98
mainnet_e81889 - altair beforeProcessEpoch 74.084 ms/op 89.756 ms/op 0.83
mainnet_e81889 - altair processJustificationAndFinalization 27.618 us/op 27.113 us/op 1.02
mainnet_e81889 - altair processInactivityUpdates 5.6149 ms/op 7.0442 ms/op 0.80
mainnet_e81889 - altair processRewardsAndPenalties 80.741 ms/op 64.241 ms/op 1.26
mainnet_e81889 - altair processRegistryUpdates 3.1970 us/op 4.7590 us/op 0.67
mainnet_e81889 - altair processSlashings 956.00 ns/op 988.00 ns/op 0.97
mainnet_e81889 - altair processEth1DataReset 872.00 ns/op 923.00 ns/op 0.94
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.3998 ms/op 1.4421 ms/op 1.66
mainnet_e81889 - altair processSlashingsReset 8.3130 us/op 8.1150 us/op 1.02
mainnet_e81889 - altair processRandaoMixesReset 6.9090 us/op 9.3650 us/op 0.74
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0770 us/op 1.8020 us/op 0.60
mainnet_e81889 - altair processParticipationFlagUpdates 3.3640 us/op 5.0800 us/op 0.66
mainnet_e81889 - altair processSyncCommitteeUpdates 891.00 ns/op 1.5570 us/op 0.57
mainnet_e81889 - altair afterProcessEpoch 130.86 ms/op 131.72 ms/op 0.99
phase0 processEpoch - mainnet_e58758 389.23 ms/op 432.50 ms/op 0.90
mainnet_e58758 - phase0 beforeProcessEpoch 147.72 ms/op 139.47 ms/op 1.06
mainnet_e58758 - phase0 processJustificationAndFinalization 17.369 us/op 27.554 us/op 0.63
mainnet_e58758 - phase0 processRewardsAndPenalties 71.755 ms/op 79.418 ms/op 0.90
mainnet_e58758 - phase0 processRegistryUpdates 12.842 us/op 15.474 us/op 0.83
mainnet_e58758 - phase0 processSlashings 774.00 ns/op 1.3260 us/op 0.58
mainnet_e58758 - phase0 processEth1DataReset 541.00 ns/op 1.3740 us/op 0.39
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.2405 ms/op 1.9462 ms/op 0.64
mainnet_e58758 - phase0 processSlashingsReset 5.1690 us/op 7.9220 us/op 0.65
mainnet_e58758 - phase0 processRandaoMixesReset 5.9650 us/op 11.320 us/op 0.53
mainnet_e58758 - phase0 processHistoricalRootsUpdate 819.00 ns/op 1.8220 us/op 0.45
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.8890 us/op 10.043 us/op 0.39
mainnet_e58758 - phase0 afterProcessEpoch 102.19 ms/op 124.61 ms/op 0.82
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2917 ms/op 2.1224 ms/op 0.61
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.1534 ms/op 3.4400 ms/op 0.63
altair processInactivityUpdates - 250000 normalcase 29.359 ms/op 31.842 ms/op 0.92
altair processInactivityUpdates - 250000 worstcase 30.801 ms/op 30.279 ms/op 1.02
phase0 processRegistryUpdates - 250000 normalcase 7.6610 us/op 8.4670 us/op 0.90
phase0 processRegistryUpdates - 250000 badcase_full_deposits 330.93 us/op 294.33 us/op 1.12
phase0 processRegistryUpdates - 250000 worstcase 0.5 141.75 ms/op 112.04 ms/op 1.27
altair processRewardsAndPenalties - 250000 normalcase 71.729 ms/op 64.931 ms/op 1.10
altair processRewardsAndPenalties - 250000 worstcase 75.074 ms/op 69.922 ms/op 1.07
phase0 getAttestationDeltas - 250000 normalcase 8.2800 ms/op 9.3365 ms/op 0.89
phase0 getAttestationDeltas - 250000 worstcase 7.0911 ms/op 7.2126 ms/op 0.98
phase0 processSlashings - 250000 worstcase 3.5463 ms/op 3.9329 ms/op 0.90
altair processSyncCommitteeUpdates - 250000 182.53 ms/op 196.25 ms/op 0.93
BeaconState.hashTreeRoot - No change 353.00 ns/op 301.00 ns/op 1.17
BeaconState.hashTreeRoot - 1 full validator 57.684 us/op 54.889 us/op 1.05
BeaconState.hashTreeRoot - 32 full validator 566.98 us/op 567.99 us/op 1.00
BeaconState.hashTreeRoot - 512 full validator 5.9002 ms/op 5.5610 ms/op 1.06
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 72.508 us/op 66.016 us/op 1.10
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 989.61 us/op 1.0342 ms/op 0.96
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 13.986 ms/op 12.983 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 51.299 us/op 52.538 us/op 0.98
BeaconState.hashTreeRoot - 32 balances 466.91 us/op 504.39 us/op 0.93
BeaconState.hashTreeRoot - 512 balances 4.9866 ms/op 4.5113 ms/op 1.11
BeaconState.hashTreeRoot - 250000 balances 76.951 ms/op 76.428 ms/op 1.01
aggregationBits - 2048 els - zipIndexesInBitList 19.022 us/op 19.541 us/op 0.97
regular array get 100000 times 34.378 us/op 34.227 us/op 1.00
wrappedArray get 100000 times 45.153 us/op 34.320 us/op 1.32
arrayWithProxy get 100000 times 17.574 ms/op 18.737 ms/op 0.94
ssz.Root.equals 591.00 ns/op 606.00 ns/op 0.98
byteArrayEquals 583.00 ns/op 607.00 ns/op 0.96
shuffle list - 16384 els 7.2840 ms/op 7.5681 ms/op 0.96
shuffle list - 250000 els 106.71 ms/op 109.07 ms/op 0.98
processSlot - 1 slots 9.1410 us/op 10.575 us/op 0.86
processSlot - 32 slots 1.6044 ms/op 1.5087 ms/op 1.06
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 38.073 ms/op 40.281 ms/op 0.95
getCommitteeAssignments - req 1 vs - 250000 vc 3.0212 ms/op 3.3873 ms/op 0.89
getCommitteeAssignments - req 100 vs - 250000 vc 4.3041 ms/op 4.7433 ms/op 0.91
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6370 ms/op 5.1628 ms/op 0.90
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.3500 ns/op 5.8700 ns/op 0.91
state getBlockRootAtSlot - 250000 vs - 7PWei 942.50 ns/op 1.1918 us/op 0.79
computeProposers - vc 250000 12.282 ms/op 12.115 ms/op 1.01
computeEpochShuffling - vc 250000 112.65 ms/op 109.50 ms/op 1.03
getNextSyncCommittee - vc 250000 202.78 ms/op 198.08 ms/op 1.02
computeSigningRoot for AttestationData 15.784 us/op 14.754 us/op 1.07
hash AttestationData serialized data then Buffer.toString(base64) 2.7148 us/op 2.6448 us/op 1.03
toHexString serialized data 1.6503 us/op 1.1899 us/op 1.39
Buffer.toString(base64) 395.41 ns/op 375.61 ns/op 1.05

by benchmarkbot/action

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.

Looks great! Thanks for the fast progress

The fixtures from packages/prover/test/fixtures/mainnet/eth_estimateGas_contract_call.json are generated with data from existing networks or random txs?

@nazarhussain
Copy link
Contributor Author

@dapplion All fixtures are generated form real network. There is a file generate_fixtures.ts which perform that logic.

@nazarhussain nazarhussain merged commit 0207d66 into unstable May 26, 2023
@nazarhussain nazarhussain deleted the nh/prover-estimate-gas branch May 26, 2023 10:58
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.9.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants