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

fix: improve jsonRPC error UX for eth1 + execution #5949

Merged
merged 10 commits into from
Sep 29, 2023
Merged

Conversation

nazarhussain
Copy link
Contributor

Motivation

Manage the state transition for the eth1 provider to log the errors with right context.

Description

  • Refactor the JSONRPCClient to allow events
  • Updated the Execution Engine to use the events of rpc client
  • Used the same pattern for the Eth1Provider as well

Closes #4348

Steps to test or reproduce

  • Run all tests

@nazarhussain nazarhussain self-assigned this Sep 11, 2023
@nazarhussain nazarhussain changed the title fixes: improve jsonRPC error UX for eth1 + execution fix: improve jsonRPC error UX for eth1 + execution Sep 11, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 42c3da2 Previous: 1397834 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 956.55 us/op 828.51 us/op 1.15
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 94.352 us/op 128.68 us/op 0.73
BLS verify - blst-native 1.4275 ms/op 1.5866 ms/op 0.90
BLS verifyMultipleSignatures 3 - blst-native 3.0016 ms/op 3.0682 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst-native 6.4597 ms/op 6.7124 ms/op 0.96
BLS verifyMultipleSignatures 32 - blst-native 23.351 ms/op 23.545 ms/op 0.99
BLS verifyMultipleSignatures 64 - blst-native 45.758 ms/op 45.354 ms/op 1.01
BLS verifyMultipleSignatures 128 - blst-native 92.665 ms/op 95.974 ms/op 0.97
BLS deserializing 10000 signatures 936.34 ms/op 946.52 ms/op 0.99
BLS deserializing 100000 signatures 9.5931 s/op 9.7745 s/op 0.98
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.5236 ms/op 1.5306 ms/op 1.00
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.6686 ms/op 1.6814 ms/op 0.99
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.5213 ms/op 2.7240 ms/op 0.93
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.7015 ms/op 3.8760 ms/op 0.95
BLS verifyMultipleSignatures - same message - 128 - blst-native 6.2723 ms/op 6.9272 ms/op 0.91
BLS aggregatePubkeys 32 - blst-native 27.938 us/op 30.980 us/op 0.90
BLS aggregatePubkeys 128 - blst-native 118.09 us/op 115.05 us/op 1.03
getAttestationsForBlock 51.147 ms/op 105.10 ms/op 0.49
isKnown best case - 1 super set check 536.00 ns/op 1.0820 us/op 0.50
isKnown normal case - 2 super set checks 548.00 ns/op 944.00 ns/op 0.58
isKnown worse case - 16 super set checks 513.00 ns/op 923.00 ns/op 0.56
CheckpointStateCache - add get delete 6.3770 us/op 10.801 us/op 0.59
validate api signedAggregateAndProof - struct 3.1849 ms/op 3.4226 ms/op 0.93
validate gossip signedAggregateAndProof - struct 3.0767 ms/op 3.3552 ms/op 0.92
validate gossip attestation - vc 640000 1.4455 ms/op 1.5228 ms/op 0.95
batch validate gossip attestation - vc 640000 - chunk 32 181.64 us/op 221.22 us/op 0.82
batch validate gossip attestation - vc 640000 - chunk 64 176.41 us/op 183.34 us/op 0.96
batch validate gossip attestation - vc 640000 - chunk 128 156.62 us/op 165.57 us/op 0.95
batch validate gossip attestation - vc 640000 - chunk 256 144.89 us/op 144.67 us/op 1.00
pickEth1Vote - no votes 1.2876 ms/op 1.3427 ms/op 0.96
pickEth1Vote - max votes 11.135 ms/op 10.995 ms/op 1.01
pickEth1Vote - Eth1Data hashTreeRoot value x2048 19.505 ms/op 18.569 ms/op 1.05
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 34.369 ms/op 27.534 ms/op 1.25
pickEth1Vote - Eth1Data fastSerialize value x2048 650.87 us/op 691.28 us/op 0.94
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.2454 ms/op 8.2330 ms/op 1.00
bytes32 toHexString 596.00 ns/op 631.00 ns/op 0.94
bytes32 Buffer.toString(hex) 321.00 ns/op 310.00 ns/op 1.04
bytes32 Buffer.toString(hex) from Uint8Array 511.00 ns/op 555.00 ns/op 0.92
bytes32 Buffer.toString(hex) + 0x 325.00 ns/op 326.00 ns/op 1.00
Object access 1 prop 0.17300 ns/op 0.20600 ns/op 0.84
Map access 1 prop 0.16000 ns/op 0.15400 ns/op 1.04
Object get x1000 8.0740 ns/op 7.9840 ns/op 1.01
Map get x1000 0.58700 ns/op 0.67400 ns/op 0.87
Object set x1000 59.547 ns/op 65.025 ns/op 0.92
Map set x1000 48.195 ns/op 49.129 ns/op 0.98
Return object 10000 times 0.26280 ns/op 0.25030 ns/op 1.05
Throw Error 10000 times 3.9917 us/op 3.9370 us/op 1.01
fastMsgIdFn sha256 / 200 bytes 3.4750 us/op 3.4240 us/op 1.01
fastMsgIdFn h32 xxhash / 200 bytes 323.00 ns/op 325.00 ns/op 0.99
fastMsgIdFn h64 xxhash / 200 bytes 384.00 ns/op 378.00 ns/op 1.02
fastMsgIdFn sha256 / 1000 bytes 12.620 us/op 11.672 us/op 1.08
fastMsgIdFn h32 xxhash / 1000 bytes 454.00 ns/op 454.00 ns/op 1.00
fastMsgIdFn h64 xxhash / 1000 bytes 457.00 ns/op 450.00 ns/op 1.02
fastMsgIdFn sha256 / 10000 bytes 109.39 us/op 106.62 us/op 1.03
fastMsgIdFn h32 xxhash / 10000 bytes 2.1890 us/op 2.0450 us/op 1.07
fastMsgIdFn h64 xxhash / 10000 bytes 1.5070 us/op 1.4150 us/op 1.07
send data - 1000 256B messages 21.551 ms/op 21.634 ms/op 1.00
send data - 1000 512B messages 28.355 ms/op 29.872 ms/op 0.95
send data - 1000 1024B messages 44.755 ms/op 45.085 ms/op 0.99
send data - 1000 1200B messages 33.598 ms/op 34.476 ms/op 0.97
send data - 1000 2048B messages 33.709 ms/op 39.902 ms/op 0.84
send data - 1000 4096B messages 35.675 ms/op 39.309 ms/op 0.91
send data - 1000 16384B messages 93.416 ms/op 80.061 ms/op 1.17
send data - 1000 65536B messages 319.28 ms/op 297.29 ms/op 1.07
enrSubnets - fastDeserialize 64 bits 1.4510 us/op 1.3630 us/op 1.06
enrSubnets - ssz BitVector 64 bits 597.00 ns/op 483.00 ns/op 1.24
enrSubnets - fastDeserialize 4 bits 198.00 ns/op 194.00 ns/op 1.02
enrSubnets - ssz BitVector 4 bits 541.00 ns/op 457.00 ns/op 1.18
prioritizePeers score -10:0 att 32-0.1 sync 2-0 140.52 us/op 114.67 us/op 1.23
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 155.55 us/op 139.84 us/op 1.11
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 202.05 us/op 194.59 us/op 1.04
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 354.87 us/op 341.80 us/op 1.04
prioritizePeers score 0:0 att 64-1 sync 4-1 466.81 us/op 372.49 us/op 1.25
array of 16000 items push then shift 1.8668 us/op 1.7216 us/op 1.08
LinkedList of 16000 items push then shift 10.301 ns/op 10.233 ns/op 1.01
array of 16000 items push then pop 109.13 ns/op 112.72 ns/op 0.97
LinkedList of 16000 items push then pop 11.591 ns/op 9.7800 ns/op 1.19
array of 24000 items push then shift 2.8983 us/op 2.4651 us/op 1.18
LinkedList of 24000 items push then shift 10.831 ns/op 10.731 ns/op 1.01
array of 24000 items push then pop 154.29 ns/op 167.62 ns/op 0.92
LinkedList of 24000 items push then pop 9.3700 ns/op 10.111 ns/op 0.93
intersect bitArray bitLen 8 7.2560 ns/op 6.8320 ns/op 1.06
intersect array and set length 8 66.173 ns/op 72.088 ns/op 0.92
intersect bitArray bitLen 128 35.610 ns/op 33.380 ns/op 1.07
intersect array and set length 128 922.16 ns/op 950.42 ns/op 0.97
bitArray.getTrueBitIndexes() bitLen 128 1.7320 us/op 1.7040 us/op 1.02
bitArray.getTrueBitIndexes() bitLen 248 2.7310 us/op 3.0530 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 512 5.5950 us/op 6.2470 us/op 0.90
Buffer.concat 32 items 1.0730 us/op 1.0450 us/op 1.03
Uint8Array.set 32 items 2.8810 us/op 2.0830 us/op 1.38
Set add up to 64 items then delete first 4.8900 us/op 4.7453 us/op 1.03
OrderedSet add up to 64 items then delete first 6.3937 us/op 6.0750 us/op 1.05
Set add up to 64 items then delete last 5.2476 us/op 5.1108 us/op 1.03
OrderedSet add up to 64 items then delete last 6.8228 us/op 5.8796 us/op 1.16
Set add up to 64 items then delete middle 5.2226 us/op 4.9476 us/op 1.06
OrderedSet add up to 64 items then delete middle 8.1910 us/op 7.6051 us/op 1.08
Set add up to 128 items then delete first 10.695 us/op 10.356 us/op 1.03
OrderedSet add up to 128 items then delete first 14.438 us/op 13.891 us/op 1.04
Set add up to 128 items then delete last 10.110 us/op 10.195 us/op 0.99
OrderedSet add up to 128 items then delete last 13.852 us/op 13.721 us/op 1.01
Set add up to 128 items then delete middle 10.280 us/op 10.188 us/op 1.01
OrderedSet add up to 128 items then delete middle 19.670 us/op 18.833 us/op 1.04
Set add up to 256 items then delete first 20.816 us/op 20.752 us/op 1.00
OrderedSet add up to 256 items then delete first 28.085 us/op 27.985 us/op 1.00
Set add up to 256 items then delete last 20.818 us/op 20.300 us/op 1.03
OrderedSet add up to 256 items then delete last 27.180 us/op 27.826 us/op 0.98
Set add up to 256 items then delete middle 20.664 us/op 20.253 us/op 1.02
OrderedSet add up to 256 items then delete middle 51.502 us/op 50.698 us/op 1.02
transfer serialized Status (84 B) 1.9210 us/op 2.0880 us/op 0.92
copy serialized Status (84 B) 1.6950 us/op 1.7470 us/op 0.97
transfer serialized SignedVoluntaryExit (112 B) 2.0170 us/op 2.0630 us/op 0.98
copy serialized SignedVoluntaryExit (112 B) 1.7560 us/op 1.7230 us/op 1.02
transfer serialized ProposerSlashing (416 B) 2.3630 us/op 2.4110 us/op 0.98
copy serialized ProposerSlashing (416 B) 3.2110 us/op 2.6710 us/op 1.20
transfer serialized Attestation (485 B) 3.7300 us/op 2.4080 us/op 1.55
copy serialized Attestation (485 B) 3.2850 us/op 2.4490 us/op 1.34
transfer serialized AttesterSlashing (33232 B) 2.6360 us/op 2.6500 us/op 0.99
copy serialized AttesterSlashing (33232 B) 8.6760 us/op 9.3130 us/op 0.93
transfer serialized Small SignedBeaconBlock (128000 B) 3.4680 us/op 3.1820 us/op 1.09
copy serialized Small SignedBeaconBlock (128000 B) 18.191 us/op 22.289 us/op 0.82
transfer serialized Avg SignedBeaconBlock (200000 B) 3.3110 us/op 3.2040 us/op 1.03
copy serialized Avg SignedBeaconBlock (200000 B) 28.069 us/op 33.244 us/op 0.84
transfer serialized BlobsSidecar (524380 B) 3.8030 us/op 4.1740 us/op 0.91
copy serialized BlobsSidecar (524380 B) 106.91 us/op 164.49 us/op 0.65
transfer serialized Big SignedBeaconBlock (1000000 B) 4.2400 us/op 5.4120 us/op 0.78
copy serialized Big SignedBeaconBlock (1000000 B) 187.74 us/op 192.39 us/op 0.98
pass gossip attestations to forkchoice per slot 4.0838 ms/op 4.5761 ms/op 0.89
forkChoice updateHead vc 100000 bc 64 eq 0 711.10 us/op 756.51 us/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 0 5.9757 ms/op 5.2527 ms/op 1.14
forkChoice updateHead vc 1000000 bc 64 eq 0 9.2330 ms/op 8.4244 ms/op 1.10
forkChoice updateHead vc 600000 bc 320 eq 0 4.9506 ms/op 5.3494 ms/op 0.93
forkChoice updateHead vc 600000 bc 1200 eq 0 5.5648 ms/op 4.7779 ms/op 1.16
forkChoice updateHead vc 600000 bc 7200 eq 0 5.7314 ms/op 6.0353 ms/op 0.95
forkChoice updateHead vc 600000 bc 64 eq 1000 13.141 ms/op 11.952 ms/op 1.10
forkChoice updateHead vc 600000 bc 64 eq 10000 14.351 ms/op 13.228 ms/op 1.08
forkChoice updateHead vc 600000 bc 64 eq 300000 27.591 ms/op 27.170 ms/op 1.02
computeDeltas 500000 validators 300 proto nodes 7.2249 ms/op 6.9671 ms/op 1.04
computeDeltas 500000 validators 1200 proto nodes 7.3282 ms/op 6.9986 ms/op 1.05
computeDeltas 500000 validators 7200 proto nodes 8.1090 ms/op 6.8772 ms/op 1.18
computeDeltas 750000 validators 300 proto nodes 12.373 ms/op 10.049 ms/op 1.23
computeDeltas 750000 validators 1200 proto nodes 12.132 ms/op 10.003 ms/op 1.21
computeDeltas 750000 validators 7200 proto nodes 12.886 ms/op 10.168 ms/op 1.27
computeDeltas 1400000 validators 300 proto nodes 20.645 ms/op 20.538 ms/op 1.01
computeDeltas 1400000 validators 1200 proto nodes 19.545 ms/op 20.998 ms/op 0.93
computeDeltas 1400000 validators 7200 proto nodes 20.244 ms/op 21.379 ms/op 0.95
computeDeltas 2100000 validators 300 proto nodes 29.905 ms/op 29.434 ms/op 1.02
computeDeltas 2100000 validators 1200 proto nodes 28.893 ms/op 29.961 ms/op 0.96
computeDeltas 2100000 validators 7200 proto nodes 30.217 ms/op 29.121 ms/op 1.04
computeProposerBoostScoreFromBalances 500000 validators 3.4118 ms/op 3.6451 ms/op 0.94
computeProposerBoostScoreFromBalances 750000 validators 3.5100 ms/op 3.7563 ms/op 0.93
computeProposerBoostScoreFromBalances 1400000 validators 3.4925 ms/op 3.7417 ms/op 0.93
computeProposerBoostScoreFromBalances 2100000 validators 3.8561 ms/op 3.6235 ms/op 1.06
altair processAttestation - 250000 vs - 7PWei normalcase 4.3453 ms/op 3.1421 ms/op 1.38
altair processAttestation - 250000 vs - 7PWei worstcase 4.8232 ms/op 4.3240 ms/op 1.12
altair processAttestation - setStatus - 1/6 committees join 208.29 us/op 224.94 us/op 0.93
altair processAttestation - setStatus - 1/3 committees join 388.16 us/op 353.56 us/op 1.10
altair processAttestation - setStatus - 1/2 committees join 588.00 us/op 515.41 us/op 1.14
altair processAttestation - setStatus - 2/3 committees join 774.26 us/op 635.66 us/op 1.22
altair processAttestation - setStatus - 4/5 committees join 1.0133 ms/op 907.56 us/op 1.12
altair processAttestation - setStatus - 100% committees join 1.0537 ms/op 1.0572 ms/op 1.00
altair processBlock - 250000 vs - 7PWei normalcase 10.765 ms/op 9.6032 ms/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase hashState 34.155 ms/op 37.180 ms/op 0.92
altair processBlock - 250000 vs - 7PWei worstcase 41.975 ms/op 49.435 ms/op 0.85
altair processBlock - 250000 vs - 7PWei worstcase hashState 95.423 ms/op 122.50 ms/op 0.78
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2644 ms/op 3.7449 ms/op 0.87
phase0 processBlock - 250000 vs - 7PWei worstcase 36.909 ms/op 35.576 ms/op 1.04
altair processEth1Data - 250000 vs - 7PWei normalcase 712.58 us/op 671.65 us/op 1.06
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 24.942 us/op 16.589 us/op 1.50
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 76.563 us/op 83.131 us/op 0.92
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 35.407 us/op 31.937 us/op 1.11
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 27.697 us/op 18.251 us/op 1.52
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 238.85 us/op 200.24 us/op 1.19
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.5108 ms/op 1.8173 ms/op 0.83
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.8654 ms/op 1.8878 ms/op 0.99
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.1903 ms/op 1.8931 ms/op 1.16
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.3599 ms/op 4.7054 ms/op 0.93
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.4966 ms/op 3.5388 ms/op 0.99
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.9498 ms/op 8.6424 ms/op 0.80
Tree 40 250000 create 553.18 ms/op 612.16 ms/op 0.90
Tree 40 250000 get(125000) 238.15 ns/op 256.78 ns/op 0.93
Tree 40 250000 set(125000) 1.8626 us/op 2.7537 us/op 0.68
Tree 40 250000 toArray() 34.364 ms/op 31.202 ms/op 1.10
Tree 40 250000 iterate all - toArray() + loop 31.176 ms/op 29.589 ms/op 1.05
Tree 40 250000 iterate all - get(i) 86.138 ms/op 90.211 ms/op 0.95
MutableVector 250000 create 17.581 ms/op 12.321 ms/op 1.43
MutableVector 250000 get(125000) 7.4680 ns/op 7.1340 ns/op 1.05
MutableVector 250000 set(125000) 366.15 ns/op 286.53 ns/op 1.28
MutableVector 250000 toArray() 4.9045 ms/op 4.1770 ms/op 1.17
MutableVector 250000 iterate all - toArray() + loop 4.6649 ms/op 3.5924 ms/op 1.30
MutableVector 250000 iterate all - get(i) 1.6074 ms/op 1.6053 ms/op 1.00
Array 250000 create 5.1297 ms/op 3.6538 ms/op 1.40
Array 250000 clone - spread 2.6008 ms/op 1.1270 ms/op 2.31
Array 250000 get(125000) 1.0250 ns/op 0.53500 ns/op 1.92
Array 250000 set(125000) 2.2670 ns/op 0.59500 ns/op 3.81
Array 250000 iterate all - loop 114.70 us/op 114.58 us/op 1.00
effectiveBalanceIncrements clone Uint8Array 300000 93.264 us/op 43.954 us/op 2.12
effectiveBalanceIncrements clone MutableVector 300000 639.00 ns/op 261.00 ns/op 2.45
effectiveBalanceIncrements rw all Uint8Array 300000 202.84 us/op 180.53 us/op 1.12
effectiveBalanceIncrements rw all MutableVector 300000 273.70 ms/op 87.111 ms/op 3.14
phase0 afterProcessEpoch - 250000 vs - 7PWei 143.98 ms/op 117.62 ms/op 1.22
phase0 beforeProcessEpoch - 250000 vs - 7PWei 69.077 ms/op 45.211 ms/op 1.53
altair processEpoch - mainnet_e81889 709.42 ms/op 539.26 ms/op 1.32
mainnet_e81889 - altair beforeProcessEpoch 116.34 ms/op 73.030 ms/op 1.59
mainnet_e81889 - altair processJustificationAndFinalization 33.959 us/op 26.734 us/op 1.27
mainnet_e81889 - altair processInactivityUpdates 16.161 ms/op 9.2618 ms/op 1.74
mainnet_e81889 - altair processRewardsAndPenalties 86.413 ms/op 72.098 ms/op 1.20
mainnet_e81889 - altair processRegistryUpdates 5.4670 us/op 3.5140 us/op 1.56
mainnet_e81889 - altair processSlashings 1.5070 us/op 483.00 ns/op 3.12
mainnet_e81889 - altair processEth1DataReset 1.0390 us/op 616.00 ns/op 1.69
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.4176 ms/op 1.2717 ms/op 1.90
mainnet_e81889 - altair processSlashingsReset 7.1220 us/op 3.0380 us/op 2.34
mainnet_e81889 - altair processRandaoMixesReset 9.9430 us/op 5.4130 us/op 1.84
mainnet_e81889 - altair processHistoricalRootsUpdate 1.5780 us/op 675.00 ns/op 2.34
mainnet_e81889 - altair processParticipationFlagUpdates 6.1850 us/op 2.1690 us/op 2.85
mainnet_e81889 - altair processSyncCommitteeUpdates 2.2930 us/op 566.00 ns/op 4.05
mainnet_e81889 - altair afterProcessEpoch 162.94 ms/op 127.72 ms/op 1.28
capella processEpoch - mainnet_e217614 1.7762 s/op 1.4948 s/op 1.19
mainnet_e217614 - capella beforeProcessEpoch 303.08 ms/op 248.44 ms/op 1.22
mainnet_e217614 - capella processJustificationAndFinalization 23.054 us/op 13.190 us/op 1.75
mainnet_e217614 - capella processInactivityUpdates 25.861 ms/op 20.880 ms/op 1.24
mainnet_e217614 - capella processRewardsAndPenalties 326.34 ms/op 267.86 ms/op 1.22
mainnet_e217614 - capella processRegistryUpdates 32.078 us/op 21.471 us/op 1.49
mainnet_e217614 - capella processSlashings 937.00 ns/op 488.00 ns/op 1.92
mainnet_e217614 - capella processEth1DataReset 1.0240 us/op 686.00 ns/op 1.49
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.4750 ms/op 4.1244 ms/op 1.09
mainnet_e217614 - capella processSlashingsReset 3.4320 us/op 2.6250 us/op 1.31
mainnet_e217614 - capella processRandaoMixesReset 5.7770 us/op 3.8080 us/op 1.52
mainnet_e217614 - capella processHistoricalRootsUpdate 1.3320 us/op 820.00 ns/op 1.62
mainnet_e217614 - capella processParticipationFlagUpdates 4.6510 us/op 3.5180 us/op 1.32
mainnet_e217614 - capella afterProcessEpoch 324.79 ms/op 305.07 ms/op 1.06
phase0 processEpoch - mainnet_e58758 536.14 ms/op 457.66 ms/op 1.17
mainnet_e58758 - phase0 beforeProcessEpoch 140.67 ms/op 105.88 ms/op 1.33
mainnet_e58758 - phase0 processJustificationAndFinalization 17.336 us/op 24.355 us/op 0.71
mainnet_e58758 - phase0 processRewardsAndPenalties 56.109 ms/op 50.684 ms/op 1.11
mainnet_e58758 - phase0 processRegistryUpdates 16.798 us/op 10.551 us/op 1.59
mainnet_e58758 - phase0 processSlashings 1.2260 us/op 602.00 ns/op 2.04
mainnet_e58758 - phase0 processEth1DataReset 887.00 ns/op 593.00 ns/op 1.50
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.3920 ms/op 1.0484 ms/op 1.33
mainnet_e58758 - phase0 processSlashingsReset 5.7110 us/op 3.5800 us/op 1.60
mainnet_e58758 - phase0 processRandaoMixesReset 7.8860 us/op 5.7860 us/op 1.36
mainnet_e58758 - phase0 processHistoricalRootsUpdate 938.00 ns/op 405.00 ns/op 2.32
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.1840 us/op 4.0090 us/op 1.29
mainnet_e58758 - phase0 afterProcessEpoch 122.26 ms/op 106.61 ms/op 1.15
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3739 ms/op 1.2626 ms/op 1.09
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.0092 ms/op 1.9395 ms/op 1.04
altair processInactivityUpdates - 250000 normalcase 24.756 ms/op 22.712 ms/op 1.09
altair processInactivityUpdates - 250000 worstcase 25.796 ms/op 21.091 ms/op 1.22
phase0 processRegistryUpdates - 250000 normalcase 19.880 us/op 9.6820 us/op 2.05
phase0 processRegistryUpdates - 250000 badcase_full_deposits 584.70 us/op 340.64 us/op 1.72
phase0 processRegistryUpdates - 250000 worstcase 0.5 201.48 ms/op 129.89 ms/op 1.55
altair processRewardsAndPenalties - 250000 normalcase 73.790 ms/op 65.411 ms/op 1.13
altair processRewardsAndPenalties - 250000 worstcase 71.108 ms/op 64.909 ms/op 1.10
phase0 getAttestationDeltas - 250000 normalcase 11.211 ms/op 9.5013 ms/op 1.18
phase0 getAttestationDeltas - 250000 worstcase 11.961 ms/op 9.5946 ms/op 1.25
phase0 processSlashings - 250000 worstcase 3.8599 ms/op 2.5712 ms/op 1.50
altair processSyncCommitteeUpdates - 250000 183.32 ms/op 153.09 ms/op 1.20
BeaconState.hashTreeRoot - No change 671.00 ns/op 385.00 ns/op 1.74
BeaconState.hashTreeRoot - 1 full validator 220.27 us/op 177.07 us/op 1.24
BeaconState.hashTreeRoot - 32 full validator 1.9511 ms/op 1.8060 ms/op 1.08
BeaconState.hashTreeRoot - 512 full validator 22.795 ms/op 13.170 ms/op 1.73
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 259.00 us/op 147.54 us/op 1.76
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.9132 ms/op 1.9974 ms/op 1.46
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 49.547 ms/op 33.619 ms/op 1.47
BeaconState.hashTreeRoot - 1 balances 207.20 us/op 125.59 us/op 1.65
BeaconState.hashTreeRoot - 32 balances 1.6619 ms/op 1.1438 ms/op 1.45
BeaconState.hashTreeRoot - 512 balances 13.812 ms/op 9.7644 ms/op 1.41
BeaconState.hashTreeRoot - 250000 balances 248.39 ms/op 177.21 ms/op 1.40
aggregationBits - 2048 els - zipIndexesInBitList 25.336 us/op 15.743 us/op 1.61
regular array get 100000 times 46.249 us/op 43.631 us/op 1.06
wrappedArray get 100000 times 36.988 us/op 33.569 us/op 1.10
arrayWithProxy get 100000 times 16.163 ms/op 15.936 ms/op 1.01
ssz.Root.equals 342.00 ns/op 224.00 ns/op 1.53
byteArrayEquals 310.00 ns/op 221.00 ns/op 1.40
shuffle list - 16384 els 8.2372 ms/op 7.1860 ms/op 1.15
shuffle list - 250000 els 118.61 ms/op 106.29 ms/op 1.12
processSlot - 1 slots 23.227 us/op 16.702 us/op 1.39
processSlot - 32 slots 4.5856 ms/op 4.1911 ms/op 1.09
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 55.658 ms/op 61.869 ms/op 0.90
getCommitteeAssignments - req 1 vs - 250000 vc 2.8220 ms/op 2.6481 ms/op 1.07
getCommitteeAssignments - req 100 vs - 250000 vc 3.8892 ms/op 3.8053 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 4.1885 ms/op 4.2163 ms/op 0.99
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.3400 ns/op 5.1500 ns/op 1.04
state getBlockRootAtSlot - 250000 vs - 7PWei 626.49 ns/op 725.73 ns/op 0.86
computeProposers - vc 250000 9.8490 ms/op 9.7152 ms/op 1.01
computeEpochShuffling - vc 250000 116.81 ms/op 109.02 ms/op 1.07
getNextSyncCommittee - vc 250000 162.28 ms/op 164.06 ms/op 0.99
computeSigningRoot for AttestationData 25.493 us/op 29.969 us/op 0.85
hash AttestationData serialized data then Buffer.toString(base64) 2.4524 us/op 2.4455 us/op 1.00
toHexString serialized data 1.1642 us/op 1.2606 us/op 0.92
Buffer.toString(base64) 259.16 ns/op 240.19 ns/op 1.08

by benchmarkbot/action

@nazarhussain nazarhussain marked this pull request as ready for review September 21, 2023 10:42
@nazarhussain nazarhussain requested a review from a team as a code owner September 21, 2023 10:42
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

overall looks really good to me ❤️
could you generate some example logs by testing a few scenarios and how how they look before i approve

@nazarhussain
Copy link
Contributor Author

The log format does not change. it still shows the error exactly like before.

Sep-28 11:36:04.057[eth1]            error: Error updating eth1 chain cache  Request to https://lodestar-mainnetrpc.chainsafe.i failed, reason: getaddrinfo ENOTFOUND 

The only change would be the error will be shown once connection have any issue.

@g11tech
Copy link
Contributor

g11tech commented Sep 28, 2023

can we have the "eth1 communication restored/online" etc kind of messages like how you did in the engine when state changes

@nazarhussain
Copy link
Contributor Author

nazarhussain commented Sep 28, 2023

Sep-28 15:40:16.247[eth1]            error: Eth1Provider faced error state=OFFLINE, lastErrorAt=undefined Request to http://0.0.0.0:8080 failed, reason: connect ECONNREFUSED 0.0.0.0:8080
Sep-28 15:40:27.889[eth1]             info: Eth1Provider is back online oldState=OFFLINE, newState=ONLINE

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

lgtm! great cleanup ❤️ and hopefully clean UX

@g11tech g11tech merged commit 3cfa9cd into unstable Sep 29, 2023
15 checks passed
@g11tech g11tech deleted the nh/4348-eth1-error branch September 29, 2023 17:17
}

private async fetchJson<R, T = unknown>(json: T, opts?: ReqOpts): Promise<R> {
if (this.urls.length === 0) throw Error("No url provided");
Copy link
Member

Choose a reason for hiding this comment

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

I previously removed a similar check like this in #5884 as we already check the URLs in the constructor

if (urls.length === 0) {
throw Error("No urls provided to JsonRpcHttpClient");
}

I don't think this error is reachable but if it is we should make sure to validate the URLs earlier.

@@ -35,3 +36,29 @@ describe("waitFor", () => {
await expect(waitFor(() => true, {interval, timeout, signal: controller.signal})).to.be.rejectedWith(ErrorAborted);
});
});

describe("waitForElapsedTime", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Test case name does not match function name, looks like this was missed during renaming

@wemeetagain
Copy link
Member

🎉 This PR is included in v1.12.0 🎉

Comment on lines +184 to -183
// only log error if state switched from online to some other state
} else if (!isErrorAborted(e)) {
this.logger.error("Error updating eth1 chain cache", {}, e as Error);
Copy link
Member

@nflaig nflaig Feb 17, 2024

Choose a reason for hiding this comment

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

@nazarhussain can you please explain this change, does the comment relate to the removed log?

And is the log on line 183 supposed to be replaced by the error log added in the eth1 provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this log line should be replaced with eth1Provider error handling, but because we log the error once per minute so it could be the case you don't see the errors often.

}

if (this.state !== Eth1ProviderState.ONLINE) {
if (isOneMinutePassed()) {
Copy link
Member

Choose a reason for hiding this comment

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

@nazarhussain can you please explain how this should behave

  1. should it invoke the error log at most once a minute
  2. or should it just invoke the error log once and never again, until there is a period of 1 minute where there are no errors?

See issue reported on discord, we are not actually printing out any errors and just spam the logs with info: Eth1Provider is back online oldState=ERROR, newState=ONLINE.

I pushed a few changes that might partially solve this by fixing createElapsedTimeTracker function, see unstable...nflaig/eth1-error-logging

Copy link
Member

Choose a reason for hiding this comment

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

Another issue was reported to this, see discord. Does not seem to happen if EL is still synincing but needs more investigation as they use openexecution and not directly connect to EL client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When ever JsonRpcHttpClient encounter an error, it bubbles up to this function. We log the the error once per minute because once the rpc encounter error it's usually because the RPC node is offline or some other issue then it's stay that way very long we end up tons of error logs with same error.

Copy link
Member

Choose a reason for hiding this comment

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

We log the the error once per minute

that's what it should do but the function has a bug, fixed in unstable...nflaig/eth1-error-logging

The other issue I see is how we do the status logging, as single failed request will set the status to ERROR while a single success request sets it to ONLINE.

If some request succeed and some fail which is the cause if nethermind can't serve historical logs but it can serve other requests then what ends up happning is that the logs are spammed with

info: Eth1Provider is back online oldState=ERROR, newState=ONLINE.

It more of an issue of the intended behavior vs. the acutal behavior, if we fix the implementation it should be fine. I added more details in the issue #6469.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went over the discussions I had for it's implementation, that was the inspiration or this change:

also maybe every minute log the error message as well if the eth1 is still down ... ( i.e. if we make the request and its still error and the last error display message > 60 seconds , log the message and update last error display time)

So yes there is a bug in the implementation, but not in the createElapsedTimeTracker. That one seems to be good as what is intended for, it's just tracking time since first invocation.

For eth1 provider we should do via rate limiting helpers for rate limit error per minute.

@nflaig nflaig mentioned this pull request Feb 22, 2024
2 tasks
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.

Improve jsonRPC error UX for eth1 + execution
4 participants