Skip to content

Add support for eth_getTransactionCount to prover - #5338

Merged
nazarhussain merged 2 commits into
unstablefrom
nh/web3-calls
Apr 5, 2023
Merged

Add support for eth_getTransactionCount to prover#5338
nazarhussain merged 2 commits into
unstablefrom
nh/web3-calls

Conversation

@nazarhussain

Copy link
Copy Markdown
Contributor

Motivation

Add support for web3 method eth_getTransactionCount

Description

Add support for web3 method eth_getTransactionCount

Partially: #4706

Steps to test or reproduce

Run all tests.

@nazarhussain
nazarhussain requested a review from a team as a code owner April 4, 2023 10:30
@github-actions

github-actions Bot commented Apr 4, 2023

Copy link
Copy Markdown
Contributor

Performance Report

鉁旓笍 no performance regression detected

Full benchmark results
Benchmark suite Current: 442b7e9 Previous: 887064d Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 848.06 us/op 712.14 us/op 1.19
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.008 us/op 48.253 us/op 0.95
BLS verify - blst-native 1.2047 ms/op 1.2805 ms/op 0.94
BLS verifyMultipleSignatures 3 - blst-native 2.4455 ms/op 2.5904 ms/op 0.94
BLS verifyMultipleSignatures 8 - blst-native 5.4739 ms/op 5.6022 ms/op 0.98
BLS verifyMultipleSignatures 32 - blst-native 19.049 ms/op 20.067 ms/op 0.95
BLS aggregatePubkeys 32 - blst-native 25.862 us/op 26.881 us/op 0.96
BLS aggregatePubkeys 128 - blst-native 99.770 us/op 104.50 us/op 0.95
getAttestationsForBlock 62.994 ms/op 63.909 ms/op 0.99
isKnown best case - 1 super set check 259.00 ns/op 267.00 ns/op 0.97
isKnown normal case - 2 super set checks 250.00 ns/op 264.00 ns/op 0.95
isKnown worse case - 16 super set checks 250.00 ns/op 262.00 ns/op 0.95
CheckpointStateCache - add get delete 4.8550 us/op 5.2480 us/op 0.93
validate gossip signedAggregateAndProof - struct 2.7453 ms/op 2.8761 ms/op 0.95
validate gossip attestation - struct 1.3108 ms/op 1.3859 ms/op 0.95
pickEth1Vote - no votes 1.2298 ms/op 1.3652 ms/op 0.90
pickEth1Vote - max votes 10.857 ms/op 11.775 ms/op 0.92
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.6330 ms/op 9.4674 ms/op 0.91
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 18.868 ms/op 17.344 ms/op 1.09
pickEth1Vote - Eth1Data fastSerialize value x2048 621.24 us/op 729.57 us/op 0.85
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.3011 ms/op 5.0493 ms/op 1.64
bytes32 toHexString 486.00 ns/op 527.00 ns/op 0.92
bytes32 Buffer.toString(hex) 346.00 ns/op 406.00 ns/op 0.85
bytes32 Buffer.toString(hex) from Uint8Array 559.00 ns/op 633.00 ns/op 0.88
bytes32 Buffer.toString(hex) + 0x 349.00 ns/op 410.00 ns/op 0.85
Object access 1 prop 0.17000 ns/op 0.18500 ns/op 0.92
Map access 1 prop 0.16700 ns/op 0.17100 ns/op 0.98
Object get x1000 6.4270 ns/op 7.0420 ns/op 0.91
Map get x1000 0.55900 ns/op 0.65400 ns/op 0.85
Object set x1000 50.619 ns/op 57.238 ns/op 0.88
Map set x1000 42.195 ns/op 47.788 ns/op 0.88
Return object 10000 times 0.22830 ns/op 0.24970 ns/op 0.91
Throw Error 10000 times 4.1905 us/op 4.4459 us/op 0.94
fastMsgIdFn sha256 / 200 bytes 3.3630 us/op 3.6310 us/op 0.93
fastMsgIdFn h32 xxhash / 200 bytes 279.00 ns/op 296.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 200 bytes 387.00 ns/op 423.00 ns/op 0.91
fastMsgIdFn sha256 / 1000 bytes 11.265 us/op 12.310 us/op 0.92
fastMsgIdFn h32 xxhash / 1000 bytes 403.00 ns/op 434.00 ns/op 0.93
fastMsgIdFn h64 xxhash / 1000 bytes 458.00 ns/op 492.00 ns/op 0.93
fastMsgIdFn sha256 / 10000 bytes 100.93 us/op 109.31 us/op 0.92
fastMsgIdFn h32 xxhash / 10000 bytes 1.8420 us/op 2.0210 us/op 0.91
fastMsgIdFn h64 xxhash / 10000 bytes 1.3110 us/op 1.4360 us/op 0.91
enrSubnets - fastDeserialize 64 bits 1.2410 us/op 1.3600 us/op 0.91
enrSubnets - ssz BitVector 64 bits 500.00 ns/op 513.00 ns/op 0.97
enrSubnets - fastDeserialize 4 bits 170.00 ns/op 184.00 ns/op 0.92
enrSubnets - ssz BitVector 4 bits 491.00 ns/op 522.00 ns/op 0.94
prioritizePeers score -10:0 att 32-0.1 sync 2-0 105.93 us/op 125.68 us/op 0.84
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 150.92 us/op 160.60 us/op 0.94
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 164.42 us/op 191.84 us/op 0.86
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 297.04 us/op 353.40 us/op 0.84
prioritizePeers score 0:0 att 64-1 sync 4-1 360.23 us/op 428.13 us/op 0.84
array of 16000 items push then shift 1.6056 us/op 1.7035 us/op 0.94
LinkedList of 16000 items push then shift 8.7950 ns/op 9.1510 ns/op 0.96
array of 16000 items push then pop 80.666 ns/op 120.59 ns/op 0.67
LinkedList of 16000 items push then pop 8.1220 ns/op 9.0210 ns/op 0.90
array of 24000 items push then shift 2.2372 us/op 2.4093 us/op 0.93
LinkedList of 24000 items push then shift 9.3540 ns/op 9.5340 ns/op 0.98
array of 24000 items push then pop 74.774 ns/op 86.208 ns/op 0.87
LinkedList of 24000 items push then pop 11.238 ns/op 10.009 ns/op 1.12
intersect bitArray bitLen 8 13.075 ns/op 14.345 ns/op 0.91
intersect array and set length 8 73.721 ns/op 89.620 ns/op 0.82
intersect bitArray bitLen 128 43.578 ns/op 45.589 ns/op 0.96
intersect array and set length 128 1.0221 us/op 1.2351 us/op 0.83
Buffer.concat 32 items 2.5960 us/op 2.8380 us/op 0.91
Uint8Array.set 32 items 3.1250 us/op 2.8230 us/op 1.11
pass gossip attestations to forkchoice per slot 3.0030 ms/op 3.1412 ms/op 0.96
computeDeltas 4.2252 ms/op 3.0552 ms/op 1.38
computeProposerBoostScoreFromBalances 1.7610 ms/op 1.8214 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei normalcase 2.2038 ms/op 2.4099 ms/op 0.91
altair processAttestation - 250000 vs - 7PWei worstcase 3.8868 ms/op 3.6556 ms/op 1.06
altair processAttestation - setStatus - 1/6 committees join 143.42 us/op 152.07 us/op 0.94
altair processAttestation - setStatus - 1/3 committees join 281.78 us/op 294.76 us/op 0.96
altair processAttestation - setStatus - 1/2 committees join 374.76 us/op 389.02 us/op 0.96
altair processAttestation - setStatus - 2/3 committees join 465.85 us/op 485.74 us/op 0.96
altair processAttestation - setStatus - 4/5 committees join 667.12 us/op 678.43 us/op 0.98
altair processAttestation - setStatus - 100% committees join 773.25 us/op 825.50 us/op 0.94
altair processBlock - 250000 vs - 7PWei normalcase 19.270 ms/op 19.148 ms/op 1.01
altair processBlock - 250000 vs - 7PWei normalcase hashState 27.742 ms/op 27.580 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase 53.974 ms/op 53.271 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase hashState 75.915 ms/op 81.103 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei normalcase 2.2096 ms/op 2.2785 ms/op 0.97
phase0 processBlock - 250000 vs - 7PWei worstcase 30.277 ms/op 32.269 ms/op 0.94
altair processEth1Data - 250000 vs - 7PWei normalcase 477.10 us/op 569.72 us/op 0.84
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 9.3480 us/op 8.1840 us/op 1.14
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 31.232 us/op 24.184 us/op 1.29
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 13.013 us/op 10.506 us/op 1.24
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.1710 us/op 8.1060 us/op 0.76
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 122.92 us/op 101.08 us/op 1.22
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 1.2289 ms/op 782.86 us/op 1.57
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 1.6525 ms/op 1.0940 ms/op 1.51
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.6193 ms/op 1.0286 ms/op 1.57
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.1918 ms/op 2.4923 ms/op 0.88
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 2.5421 ms/op 1.8486 ms/op 1.38
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.8443 ms/op 4.3451 ms/op 0.88
Tree 40 250000 create 294.95 ms/op 356.20 ms/op 0.83
Tree 40 250000 get(125000) 181.08 ns/op 201.81 ns/op 0.90
Tree 40 250000 set(125000) 912.26 ns/op 1.0450 us/op 0.87
Tree 40 250000 toArray() 17.637 ms/op 23.136 ms/op 0.76
Tree 40 250000 iterate all - toArray() + loop 18.629 ms/op 22.687 ms/op 0.82
Tree 40 250000 iterate all - get(i) 73.008 ms/op 77.367 ms/op 0.94
MutableVector 250000 create 13.542 ms/op 12.825 ms/op 1.06
MutableVector 250000 get(125000) 6.4380 ns/op 6.7190 ns/op 0.96
MutableVector 250000 set(125000) 244.18 ns/op 309.38 ns/op 0.79
MutableVector 250000 toArray() 2.7416 ms/op 4.1861 ms/op 0.65
MutableVector 250000 iterate all - toArray() + loop 2.8770 ms/op 3.4936 ms/op 0.82
MutableVector 250000 iterate all - get(i) 1.4746 ms/op 1.6534 ms/op 0.89
Array 250000 create 2.5257 ms/op 2.6802 ms/op 0.94
Array 250000 clone - spread 1.0883 ms/op 1.1486 ms/op 0.95
Array 250000 get(125000) 0.53000 ns/op 0.58900 ns/op 0.90
Array 250000 set(125000) 0.61200 ns/op 0.75800 ns/op 0.81
Array 250000 iterate all - loop 79.633 us/op 87.714 us/op 0.91
effectiveBalanceIncrements clone Uint8Array 300000 24.687 us/op 29.076 us/op 0.85
effectiveBalanceIncrements clone MutableVector 300000 337.00 ns/op 367.00 ns/op 0.92
effectiveBalanceIncrements rw all Uint8Array 300000 162.97 us/op 181.37 us/op 0.90
effectiveBalanceIncrements rw all MutableVector 300000 76.395 ms/op 85.554 ms/op 0.89
phase0 afterProcessEpoch - 250000 vs - 7PWei 112.24 ms/op 123.74 ms/op 0.91
phase0 beforeProcessEpoch - 250000 vs - 7PWei 47.657 ms/op 46.073 ms/op 1.03
altair processEpoch - mainnet_e81889 355.42 ms/op 362.31 ms/op 0.98
mainnet_e81889 - altair beforeProcessEpoch 64.420 ms/op 70.354 ms/op 0.92
mainnet_e81889 - altair processJustificationAndFinalization 27.172 us/op 17.024 us/op 1.60
mainnet_e81889 - altair processInactivityUpdates 5.2537 ms/op 6.0316 ms/op 0.87
mainnet_e81889 - altair processRewardsAndPenalties 82.862 ms/op 73.643 ms/op 1.13
mainnet_e81889 - altair processRegistryUpdates 3.5790 us/op 3.1720 us/op 1.13
mainnet_e81889 - altair processSlashings 550.00 ns/op 574.00 ns/op 0.96
mainnet_e81889 - altair processEth1DataReset 785.00 ns/op 537.00 ns/op 1.46
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.1232 ms/op 1.5547 ms/op 1.37
mainnet_e81889 - altair processSlashingsReset 7.9960 us/op 4.0560 us/op 1.97
mainnet_e81889 - altair processRandaoMixesReset 7.5240 us/op 5.0050 us/op 1.50
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0650 us/op 674.00 ns/op 1.58
mainnet_e81889 - altair processParticipationFlagUpdates 3.8950 us/op 3.3510 us/op 1.16
mainnet_e81889 - altair processSyncCommitteeUpdates 1.6240 us/op 670.00 ns/op 2.42
mainnet_e81889 - altair afterProcessEpoch 130.16 ms/op 135.77 ms/op 0.96
phase0 processEpoch - mainnet_e58758 411.00 ms/op 360.87 ms/op 1.14
mainnet_e58758 - phase0 beforeProcessEpoch 154.78 ms/op 132.24 ms/op 1.17
mainnet_e58758 - phase0 processJustificationAndFinalization 27.749 us/op 20.122 us/op 1.38
mainnet_e58758 - phase0 processRewardsAndPenalties 78.605 ms/op 55.790 ms/op 1.41
mainnet_e58758 - phase0 processRegistryUpdates 7.9390 us/op 7.8680 us/op 1.01
mainnet_e58758 - phase0 processSlashings 720.00 ns/op 506.00 ns/op 1.42
mainnet_e58758 - phase0 processEth1DataReset 755.00 ns/op 649.00 ns/op 1.16
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.8701 ms/op 1.2743 ms/op 1.47
mainnet_e58758 - phase0 processSlashingsReset 5.3310 us/op 8.4360 us/op 0.63
mainnet_e58758 - phase0 processRandaoMixesReset 7.4180 us/op 4.6350 us/op 1.60
mainnet_e58758 - phase0 processHistoricalRootsUpdate 847.00 ns/op 646.00 ns/op 1.31
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.2980 us/op 4.5720 us/op 1.38
mainnet_e58758 - phase0 afterProcessEpoch 94.774 ms/op 103.58 ms/op 0.91
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.1087 ms/op 1.2948 ms/op 0.86
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.7829 ms/op 1.8965 ms/op 1.47
altair processInactivityUpdates - 250000 normalcase 28.898 ms/op 30.135 ms/op 0.96
altair processInactivityUpdates - 250000 worstcase 30.240 ms/op 29.593 ms/op 1.02
phase0 processRegistryUpdates - 250000 normalcase 11.033 us/op 7.8350 us/op 1.41
phase0 processRegistryUpdates - 250000 badcase_full_deposits 354.16 us/op 333.98 us/op 1.06
phase0 processRegistryUpdates - 250000 worstcase 0.5 131.61 ms/op 130.12 ms/op 1.01
altair processRewardsAndPenalties - 250000 normalcase 68.472 ms/op 71.283 ms/op 0.96
altair processRewardsAndPenalties - 250000 worstcase 72.442 ms/op 73.677 ms/op 0.98
phase0 getAttestationDeltas - 250000 normalcase 6.7663 ms/op 7.0390 ms/op 0.96
phase0 getAttestationDeltas - 250000 worstcase 6.9505 ms/op 7.5930 ms/op 0.92
phase0 processSlashings - 250000 worstcase 3.6758 ms/op 3.9278 ms/op 0.94
altair processSyncCommitteeUpdates - 250000 183.88 ms/op 193.74 ms/op 0.95
BeaconState.hashTreeRoot - No change 264.00 ns/op 372.00 ns/op 0.71
BeaconState.hashTreeRoot - 1 full validator 59.056 us/op 55.501 us/op 1.06
BeaconState.hashTreeRoot - 32 full validator 686.38 us/op 600.46 us/op 1.14
BeaconState.hashTreeRoot - 512 full validator 6.3483 ms/op 6.1384 ms/op 1.03
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 65.905 us/op 74.469 us/op 0.88
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 960.69 us/op 1.0545 ms/op 0.91
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.834 ms/op 12.766 ms/op 1.01
BeaconState.hashTreeRoot - 1 balances 52.664 us/op 56.010 us/op 0.94
BeaconState.hashTreeRoot - 32 balances 487.65 us/op 512.47 us/op 0.95
BeaconState.hashTreeRoot - 512 balances 4.8527 ms/op 5.1991 ms/op 0.93
BeaconState.hashTreeRoot - 250000 balances 83.877 ms/op 83.488 ms/op 1.00
aggregationBits - 2048 els - zipIndexesInBitList 16.586 us/op 17.529 us/op 0.95
regular array get 100000 times 33.206 us/op 35.390 us/op 0.94
wrappedArray get 100000 times 41.958 us/op 35.367 us/op 1.19
arrayWithProxy get 100000 times 16.607 ms/op 18.250 ms/op 0.91
ssz.Root.equals 559.00 ns/op 632.00 ns/op 0.88
byteArrayEquals 554.00 ns/op 564.00 ns/op 0.98
shuffle list - 16384 els 6.9948 ms/op 7.2296 ms/op 0.97
shuffle list - 250000 els 103.37 ms/op 105.87 ms/op 0.98
processSlot - 1 slots 8.4550 us/op 9.1240 us/op 0.93
processSlot - 32 slots 1.3416 ms/op 1.4628 ms/op 0.92
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 38.701 ms/op 40.710 ms/op 0.95
getCommitteeAssignments - req 1 vs - 250000 vc 2.9452 ms/op 3.0902 ms/op 0.95
getCommitteeAssignments - req 100 vs - 250000 vc 4.1604 ms/op 4.3764 ms/op 0.95
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6902 ms/op 4.6727 ms/op 1.00
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.8600 ns/op 4.9700 ns/op 0.98
state getBlockRootAtSlot - 250000 vs - 7PWei 622.71 ns/op 650.80 ns/op 0.96
computeProposers - vc 250000 11.071 ms/op 11.174 ms/op 0.99
computeEpochShuffling - vc 250000 105.37 ms/op 112.71 ms/op 0.93
getNextSyncCommittee - vc 250000 174.25 ms/op 186.45 ms/op 0.93

by benchmarkbot/action


if (verifiedHandler !== undefined) {
logger.verbose("Verified request handler found", {method: payload.method});
return verifiedHandler({payload, handler, proofProvider, logger});

Check failure

Code scanning / CodeQL

Unvalidated dynamic method call

Invocation of method with [user-controlled](1) name may dispatch to unexpected target and cause an exception.
import {generateRPCResponseForPayload, generateUnverifiedResponseForPayload} from "../utils/json_rpc.js";

// eslint-disable-next-line @typescript-eslint/naming-convention
export const eth_getTransactionCount: ELVerifiedRequestHandler<

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@nazarhussain since it shares most of the steps from ethGetBalance, can we refactor to use a common method? could be in a separate PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure will refactor in upcoming PRs.

@nazarhussain
nazarhussain merged commit 9d459af into unstable Apr 5, 2023
@nazarhussain
nazarhussain deleted the nh/web3-calls branch April 5, 2023 11:04
@wemeetagain

Copy link
Copy Markdown
Member

馃帀 This PR is included in v1.8.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.

4 participants