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: compact multiproof #292

Merged
merged 7 commits into from
Jan 6, 2023
Merged

feat: compact multiproof #292

merged 7 commits into from
Jan 6, 2023

Conversation

wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented Dec 16, 2022

Motivation

We want to support serving dynamic state/block multiproofs in Lodestar. The current approach is to request a proof as a list of "paths" into the state. Eg: [ ["validators", 1000, "exitEpoch"], ["slot"] ]. These paths are converted into generalized indices, which are then used as input in this library to create a proof.

This works for prototyping but it has several drawbacks.

First is that it is far from succinct as far as what's sent over the wire. Generally its just inefficient to send the textual representation of the requested items, even though it's convenient for human readability. There's also a lot of duplication when nested siblings are requested.

There's also a larger burden on the proof server, with more work to perform, and more that can go wrong. The paths must be validated (and in lodestar's case, converted to camel case). The paths must be converted into generalized indices. The helper indices must be calculated. All indices must be sorted for efficient traversal through the tree. And only then can the proof be generated.

In the longer term, we'd like a format that's more succinct and more performant for proof servers.

This is one such format. With this format, the request is in the form of a "proof descriptor", a bitstring, that describes the shape of the requested proof.
Not only is this very efficient over the wire, it also removes the vast majority of preprocessing work required by the proof server.

The proof descriptor only requires 2 bits per node included in the proof.
And the server only needs to validate the descriptor and can immediately generate the proof.

Description

Implementation of the proof format described in ethereum/consensus-specs#3148

See:

Results from the benchmarks:

    ✓ multiproof - depth 15, 1 requested leaves                           86445.37 ops/s    11.56800 us/op        -      60909 runs  0.809 s
    ✓ tree offset multiproof - depth 15, 1 requested leaves               38801.80 ops/s    25.77200 us/op        -      36924 runs   1.01 s
    ✓ compact multiproof - depth 15, 1 requested leaves                   205549.8 ops/s    4.865000 us/op        -      83819 runs   1.31 s

    ✓ multiproof - depth 15, 4 requested leaves                           23612.75 ops/s    42.35000 us/op        -      63635 runs   2.96 s
    ✓ tree offset multiproof - depth 15, 4 requested leaves               17984.96 ops/s    55.60200 us/op        -      18659 runs   1.11 s
    ✓ compact multiproof - depth 15, 4 requested leaves                   130293.2 ops/s    7.675000 us/op        -      19724 runs  0.808 s

@wemeetagain wemeetagain requested a review from a team as a code owner December 16, 2022 15:01
@render
Copy link

render bot commented Dec 16, 2022

@github-actions
Copy link

github-actions bot commented Dec 16, 2022

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 7f3286f Previous: 3827c01 Ratio
Copy Uint8Array 100000 slice arrayBuffer 365.58 us/op 88.178 us/op 4.15
Full benchmark results
Benchmark suite Current: 7f3286f Previous: 3827c01 Ratio
digestTwoHashObjects 50023 times 69.381 ms/op 68.925 ms/op 1.01
digest64 50023 times 72.317 ms/op 71.070 ms/op 1.02
digest 50023 times 72.034 ms/op 71.145 ms/op 1.01
input length 32 1.7640 us/op 1.7790 us/op 0.99
input length 64 1.8990 us/op 1.8060 us/op 1.05
input length 128 3.3330 us/op 3.2880 us/op 1.01
input length 256 4.9270 us/op 4.8930 us/op 1.01
input length 512 8.1840 us/op 8.0600 us/op 1.02
input length 1024 16.014 us/op 15.707 us/op 1.02
digest 1000000 times 1.2405 s/op 1.1386 s/op 1.09
hashObjectToByteArray 50023 times 2.8442 ms/op 1.9145 ms/op 1.49
byteArrayToHashObject 50023 times 3.5598 ms/op 2.1266 ms/op 1.67
getGindicesAtDepth 7.5110 us/op 5.3910 us/op 1.39
iterateAtDepth 15.166 us/op 11.112 us/op 1.36
getGindexBits 697.00 ns/op 545.00 ns/op 1.28
gindexIterator 1.5510 us/op 1.2900 us/op 1.20
hash 2 Uint8Array 2250026 times 3.3479 s/op 3.2779 s/op 1.02
hashTwoObjects 2250026 times 3.1199 s/op 3.1181 s/op 1.00
getNodeH() x7812.5 avg hindex 28.655 us/op 20.811 us/op 1.38
getNodeH() x7812.5 index 0 10.068 us/op 6.6980 us/op 1.50
getNodeH() x7812.5 index 7 10.070 us/op 6.6780 us/op 1.51
getNodeH() x7812.5 index 7 with key array 10.075 us/op 6.6780 us/op 1.51
new LeafNode() x7812.5 382.84 us/op 299.21 us/op 1.28
multiproof - depth 15, 1 requested leaves 17.089 us/op
tree offset multiproof - depth 15, 1 requested leaves 41.607 us/op
compact multiproof - depth 15, 1 requested leaves 9.1720 us/op
multiproof - depth 15, 2 requested leaves 25.570 us/op
tree offset multiproof - depth 15, 2 requested leaves 43.099 us/op
compact multiproof - depth 15, 2 requested leaves 4.4100 us/op
multiproof - depth 15, 3 requested leaves 33.041 us/op
tree offset multiproof - depth 15, 3 requested leaves 55.964 us/op
compact multiproof - depth 15, 3 requested leaves 10.171 us/op
multiproof - depth 15, 4 requested leaves 44.197 us/op
tree offset multiproof - depth 15, 4 requested leaves 72.156 us/op
compact multiproof - depth 15, 4 requested leaves 11.207 us/op
packedRootsBytesToLeafNodes bytes 4000 offset 0 4.5100 us/op 3.0240 us/op 1.49
packedRootsBytesToLeafNodes bytes 4000 offset 1 4.3580 us/op 2.7500 us/op 1.58
packedRootsBytesToLeafNodes bytes 4000 offset 2 4.3540 us/op 2.7320 us/op 1.59
packedRootsBytesToLeafNodes bytes 4000 offset 3 4.4330 us/op 2.7080 us/op 1.64
subtreeFillToContents depth 40 count 250000 87.522 ms/op 59.971 ms/op 1.46
setRoot - gindexBitstring 19.612 ms/op 14.169 ms/op 1.38
setRoot - gindex 17.214 ms/op 15.370 ms/op 1.12
getRoot - gindexBitstring 4.0352 ms/op 2.6877 ms/op 1.50
getRoot - gindex 5.0341 ms/op 4.0390 ms/op 1.25
getHashObject then setHashObject 22.206 ms/op 16.099 ms/op 1.38
setNodeWithFn 16.647 ms/op 15.304 ms/op 1.09
getNodeAtDepth depth 0 x100000 2.6838 ms/op 1.6302 ms/op 1.65
setNodeAtDepth depth 0 x100000 5.1718 ms/op 3.9456 ms/op 1.31
getNodesAtDepth depth 0 x100000 2.3647 ms/op 1.4113 ms/op 1.68
setNodesAtDepth depth 0 x100000 2.9282 ms/op 1.9585 ms/op 1.50
getNodeAtDepth depth 1 x100000 2.8268 ms/op 1.7233 ms/op 1.64
setNodeAtDepth depth 1 x100000 11.849 ms/op 8.9048 ms/op 1.33
getNodesAtDepth depth 1 x100000 2.3996 ms/op 1.5924 ms/op 1.51
setNodesAtDepth depth 1 x100000 10.004 ms/op 6.8057 ms/op 1.47
getNodeAtDepth depth 2 x100000 3.4218 ms/op 2.1817 ms/op 1.57
setNodeAtDepth depth 2 x100000 19.214 ms/op 14.901 ms/op 1.29
getNodesAtDepth depth 2 x100000 34.459 ms/op 27.747 ms/op 1.24
setNodesAtDepth depth 2 x100000 24.925 ms/op 23.560 ms/op 1.06
tree.getNodesAtDepth - gindexes 11.251 ms/op 7.7296 ms/op 1.46
tree.getNodesAtDepth - push all nodes 3.3311 ms/op 2.9937 ms/op 1.11
tree.getNodesAtDepth - navigation 202.85 us/op 201.33 us/op 1.01
tree.setNodesAtDepth - indexes 738.01 us/op 552.48 us/op 1.34
set at depth 8 943.00 ns/op 749.00 ns/op 1.26
set at depth 16 1.0870 us/op 1.0760 us/op 1.01
set at depth 32 2.1770 us/op 1.6850 us/op 1.29
iterateNodesAtDepth 8 256 30.833 us/op 19.198 us/op 1.61
getNodesAtDepth 8 256 7.6460 us/op 4.6400 us/op 1.65
iterateNodesAtDepth 16 65536 8.3787 ms/op 5.5466 ms/op 1.51
getNodesAtDepth 16 65536 2.9177 ms/op 2.1179 ms/op 1.38
iterateNodesAtDepth 32 250000 28.917 ms/op 19.903 ms/op 1.45
getNodesAtDepth 32 250000 9.1201 ms/op 5.4644 ms/op 1.67
iterateNodesAtDepth 40 250000 29.084 ms/op 19.918 ms/op 1.46
getNodesAtDepth 40 250000 8.9824 ms/op 5.5201 ms/op 1.63
250k validators 3.7062 s/op 3.3535 s/op 1.11
bitlist bytes to struct (120,90) 1.3510 us/op 1.0950 us/op 1.23
bitlist bytes to tree (120,90) 5.8130 us/op 4.5570 us/op 1.28
bitlist bytes to struct (2048,2048) 2.6500 us/op 1.8890 us/op 1.40
bitlist bytes to tree (2048,2048) 7.4550 us/op 6.0480 us/op 1.23
ByteListType - deserialize 21.825 ms/op 15.802 ms/op 1.38
BasicListType - deserialize 27.639 ms/op 14.388 ms/op 1.92
ByteListType - serialize 21.330 ms/op 15.635 ms/op 1.36
BasicListType - serialize 24.778 ms/op 17.019 ms/op 1.46
BasicListType - tree_convertToStruct 57.683 ms/op 35.988 ms/op 1.60
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 7.7310 ms/op 4.6030 ms/op 1.68
List[uint8, 68719476736] len 300000 ViewDU.get(i) 7.9861 ms/op 4.5288 ms/op 1.76
Array.push len 300000 empty Array - number 10.599 ms/op 7.8369 ms/op 1.35
Array.set len 300000 from new Array - number 2.9729 ms/op 2.0188 ms/op 1.47
Array.set len 300000 - number 9.1734 ms/op 6.4747 ms/op 1.42
Uint8Array.set len 300000 308.25 us/op 234.71 us/op 1.31
Uint32Array.set len 300000 481.30 us/op 298.41 us/op 1.61
Container({a: uint8, b: uint8}) getViewDU x300000 38.216 ms/op 30.255 ms/op 1.26
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 15.463 ms/op 12.252 ms/op 1.26
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 450.35 ms/op 328.79 ms/op 1.37
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 579.29 ms/op 392.10 ms/op 1.48
List(Container) len 300000 ViewDU.get(i) 15.148 ms/op 8.9700 ms/op 1.69
List(Container) len 300000 ViewDU.getReadonly(i) 15.555 ms/op 8.5418 ms/op 1.82
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 67.130 ms/op 38.515 ms/op 1.74
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 9.7085 ms/op 6.6001 ms/op 1.47
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 12.489 ms/op 8.4549 ms/op 1.48
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 12.579 ms/op 8.2243 ms/op 1.53
Array.push len 300000 empty Array - object 9.5360 ms/op 7.2494 ms/op 1.32
Array.set len 300000 from new Array - object 3.4756 ms/op 2.4395 ms/op 1.42
Array.set len 300000 - object 9.8818 ms/op 7.0712 ms/op 1.40
cachePermanentRootStruct no cache 14.702 us/op 13.058 us/op 1.13
cachePermanentRootStruct with cache 363.00 ns/op 278.00 ns/op 1.31
epochParticipation len 250000 rws 7813 3.9025 ms/op 3.0660 ms/op 1.27
deserialize Attestation - tree 5.3270 us/op 4.1150 us/op 1.29
deserialize Attestation - struct 3.6230 us/op 2.8120 us/op 1.29
deserialize SignedAggregateAndProof - tree 6.8730 us/op 5.3140 us/op 1.29
deserialize SignedAggregateAndProof - struct 5.7390 us/op 4.4430 us/op 1.29
deserialize SyncCommitteeMessage - tree 1.8320 us/op 1.6290 us/op 1.12
deserialize SyncCommitteeMessage - struct 2.1900 us/op 1.7340 us/op 1.26
deserialize SignedContributionAndProof - tree 3.4290 us/op 2.7760 us/op 1.24
deserialize SignedContributionAndProof - struct 5.0250 us/op 3.7240 us/op 1.35
deserialize SignedBeaconBlock - tree 390.68 us/op 292.74 us/op 1.33
deserialize SignedBeaconBlock - struct 254.76 us/op 186.80 us/op 1.36
BeaconState vc 300000 - deserialize tree 1.1778 s/op 766.16 ms/op 1.54
BeaconState vc 300000 - serialize tree 324.14 ms/op 233.61 ms/op 1.39
BeaconState.historicalRoots vc 300000 - deserialize tree 1.7470 us/op 1.4380 us/op 1.21
BeaconState.historicalRoots vc 300000 - serialize tree 1.7450 us/op 1.4630 us/op 1.19
BeaconState.validators vc 300000 - deserialize tree 1.1286 s/op 799.94 ms/op 1.41
BeaconState.validators vc 300000 - serialize tree 309.44 ms/op 197.61 ms/op 1.57
BeaconState.balances vc 300000 - deserialize tree 45.801 ms/op 34.743 ms/op 1.32
BeaconState.balances vc 300000 - serialize tree 7.2870 ms/op 3.4215 ms/op 2.13
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 884.83 us/op 452.78 us/op 1.95
BeaconState.previousEpochParticipation vc 300000 - serialize tree 532.63 us/op 340.49 us/op 1.56
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 887.01 us/op 443.33 us/op 2.00
BeaconState.currentEpochParticipation vc 300000 - serialize tree 530.51 us/op 330.21 us/op 1.61
BeaconState.inactivityScores vc 300000 - deserialize tree 43.837 ms/op 29.382 ms/op 1.49
BeaconState.inactivityScores vc 300000 - serialize tree 7.8690 ms/op 3.4932 ms/op 2.25
hashTreeRoot Attestation - struct 55.478 us/op 39.579 us/op 1.40
hashTreeRoot Attestation - tree 38.447 us/op 29.644 us/op 1.30
hashTreeRoot SignedAggregateAndProof - struct 79.630 us/op 61.759 us/op 1.29
hashTreeRoot SignedAggregateAndProof - tree 45.745 us/op 43.120 us/op 1.06
hashTreeRoot SyncCommitteeMessage - struct 18.726 us/op 13.391 us/op 1.40
hashTreeRoot SyncCommitteeMessage - tree 9.8270 us/op 9.5530 us/op 1.03
hashTreeRoot SignedContributionAndProof - struct 51.799 us/op 37.782 us/op 1.37
hashTreeRoot SignedContributionAndProof - tree 35.490 us/op 29.775 us/op 1.19
hashTreeRoot SignedBeaconBlock - struct 4.3781 ms/op 3.3230 ms/op 1.32
hashTreeRoot SignedBeaconBlock - tree 2.6281 ms/op 2.5657 ms/op 1.02
hashTreeRoot Validator - struct 22.002 us/op 18.342 us/op 1.20
hashTreeRoot Validator - tree 18.413 us/op 16.208 us/op 1.14
BeaconState vc 300000 - hashTreeRoot tree 5.9144 s/op 5.3286 s/op 1.11
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 2.2460 us/op 2.1690 us/op 1.04
BeaconState.validators vc 300000 - hashTreeRoot tree 5.6708 s/op 5.0600 s/op 1.12
BeaconState.balances vc 300000 - hashTreeRoot tree 144.23 ms/op 132.52 ms/op 1.09
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 14.520 ms/op 13.893 ms/op 1.05
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 14.367 ms/op 13.961 ms/op 1.03
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 142.50 ms/op 141.04 ms/op 1.01
hash64 x18 31.029 us/op 27.808 us/op 1.12
hashTwoObjects x18 28.969 us/op 27.105 us/op 1.07
hash64 x1740 2.7250 ms/op 2.6305 ms/op 1.04
hashTwoObjects x1740 2.6920 ms/op 2.6075 ms/op 1.03
hash64 x2700000 4.2480 s/op 4.0696 s/op 1.04
hashTwoObjects x2700000 4.1787 s/op 4.0423 s/op 1.03
get_exitEpoch - ContainerType 555.00 ns/op 445.00 ns/op 1.25
get_exitEpoch - ContainerNodeStructType 462.00 ns/op 376.00 ns/op 1.23
set_exitEpoch - ContainerType 499.00 ns/op 438.00 ns/op 1.14
set_exitEpoch - ContainerNodeStructType 369.00 ns/op 401.00 ns/op 0.92
get_pubkey - ContainerType 1.7980 us/op 1.5990 us/op 1.12
get_pubkey - ContainerNodeStructType 349.00 ns/op 288.00 ns/op 1.21
hashTreeRoot - ContainerType 557.00 ns/op 454.00 ns/op 1.23
hashTreeRoot - ContainerNodeStructType 615.00 ns/op 509.00 ns/op 1.21
createProof - ContainerType 7.6120 us/op 6.7420 us/op 1.13
createProof - ContainerNodeStructType 41.255 us/op 33.656 us/op 1.23
serialize - ContainerType 3.7980 us/op 2.8490 us/op 1.33
serialize - ContainerNodeStructType 2.8290 us/op 2.2840 us/op 1.24
set_exitEpoch_and_hashTreeRoot - ContainerType 6.8720 us/op 6.1570 us/op 1.12
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 19.425 us/op 17.087 us/op 1.14
Array - for of 20.202 us/op 6.8850 us/op 2.93
Array - for(;;) 18.667 us/op 6.4890 us/op 2.88
basicListValue.readonlyValuesArray() 6.5802 ms/op 4.2707 ms/op 1.54
basicListValue.readonlyValuesArray() + loop all 6.9480 ms/op 4.3548 ms/op 1.60
compositeListValue.readonlyValuesArray() 67.282 ms/op 31.718 ms/op 2.12
compositeListValue.readonlyValuesArray() + loop all 59.023 ms/op 31.377 ms/op 1.88
Number64UintType - get balances list 6.6654 ms/op 5.4200 ms/op 1.23
Number64UintType - set balances list 16.435 ms/op 13.947 ms/op 1.18
Number64UintType - get and increase 10 then set 70.487 ms/op 50.297 ms/op 1.40
Number64UintType - increase 10 using applyDelta 30.301 ms/op 21.012 ms/op 1.44
Number64UintType - increase 10 using applyDeltaInBatch 28.733 ms/op 21.168 ms/op 1.36
tree_newTreeFromUint64Deltas 31.580 ms/op 22.856 ms/op 1.38
unsafeUint8ArrayToTree 57.632 ms/op 38.189 ms/op 1.51
bitLength(50) 350.00 ns/op 287.00 ns/op 1.22
bitLengthStr(50) 428.00 ns/op 295.00 ns/op 1.45
bitLength(8000) 355.00 ns/op 283.00 ns/op 1.25
bitLengthStr(8000) 579.00 ns/op 351.00 ns/op 1.65
bitLength(250000) 347.00 ns/op 275.00 ns/op 1.26
bitLengthStr(250000) 692.00 ns/op 416.00 ns/op 1.66
floor - Math.floor (53) 0.80500 ns/op 0.60262 ns/op 1.34
floor - << 0 (53) 0.80446 ns/op 0.60250 ns/op 1.34
floor - Math.floor (512) 0.80417 ns/op 0.60245 ns/op 1.33
floor - << 0 (512) 0.80294 ns/op 0.60252 ns/op 1.33
fnIf(0) 3.2162 ns/op 2.0079 ns/op 1.60
fnSwitch(0) 6.0282 ns/op 3.2910 ns/op 1.83
fnObj(0) 0.80444 ns/op 0.60245 ns/op 1.34
fnArr(0) 0.80393 ns/op 0.60256 ns/op 1.33
fnIf(4) 5.2255 ns/op 3.0684 ns/op 1.70
fnSwitch(4) 6.0281 ns/op 3.3023 ns/op 1.83
fnObj(4) 0.80325 ns/op 0.60246 ns/op 1.33
fnArr(4) 0.80408 ns/op 0.60246 ns/op 1.33
fnIf(9) 7.9883 ns/op 5.2231 ns/op 1.53
fnSwitch(9) 6.0309 ns/op 3.2846 ns/op 1.84
fnObj(9) 0.80441 ns/op 0.60259 ns/op 1.33
fnArr(9) 0.80422 ns/op 0.60263 ns/op 1.33
Container {a,b,vec} - as struct x100000 80.854 us/op 60.469 us/op 1.34
Container {a,b,vec} - as tree x100000 1.0036 ms/op 509.75 us/op 1.97
Container {a,vec,b} - as struct x100000 121.11 us/op 120.71 us/op 1.00
Container {a,vec,b} - as tree x100000 1.0842 ms/op 552.74 us/op 1.96
get 2 props x1000000 - rawObject 401.95 us/op 401.80 us/op 1.00
get 2 props x1000000 - proxy 161.04 ms/op 90.607 ms/op 1.78
get 2 props x1000000 - customObj 402.37 us/op 401.74 us/op 1.00
Simple object binary -> struct 1.0960 us/op 743.00 ns/op 1.48
Simple object binary -> tree_backed 3.1550 us/op 2.3040 us/op 1.37
Simple object struct -> tree_backed 4.2270 us/op 2.9940 us/op 1.41
Simple object tree_backed -> struct 3.6460 us/op 2.6050 us/op 1.40
Simple object struct -> binary 1.7790 us/op 1.3690 us/op 1.30
Simple object tree_backed -> binary 3.1890 us/op 2.3450 us/op 1.36
aggregationBits binary -> struct 1.0110 us/op 649.00 ns/op 1.56
aggregationBits binary -> tree_backed 4.4200 us/op 3.0920 us/op 1.43
aggregationBits struct -> tree_backed 5.2840 us/op 3.6840 us/op 1.43
aggregationBits tree_backed -> struct 2.1880 us/op 1.4820 us/op 1.48
aggregationBits struct -> binary 1.5320 us/op 1.0960 us/op 1.40
aggregationBits tree_backed -> binary 1.8700 us/op 1.4060 us/op 1.33
List(uint8) 100000 binary -> struct 2.3158 ms/op 1.6166 ms/op 1.43
List(uint8) 100000 binary -> tree_backed 183.96 us/op 123.91 us/op 1.48
List(uint8) 100000 struct -> tree_backed 2.5542 ms/op 1.6346 ms/op 1.56
List(uint8) 100000 tree_backed -> struct 1.8262 ms/op 1.1448 ms/op 1.60
List(uint8) 100000 struct -> binary 2.3192 ms/op 1.4833 ms/op 1.56
List(uint8) 100000 tree_backed -> binary 171.92 us/op 92.620 us/op 1.86
List(uint64Number) 100000 binary -> struct 2.0225 ms/op 1.4876 ms/op 1.36
List(uint64Number) 100000 binary -> tree_backed 6.5783 ms/op 4.4518 ms/op 1.48
List(uint64Number) 100000 struct -> tree_backed 9.8067 ms/op 5.4623 ms/op 1.80
List(uint64Number) 100000 tree_backed -> struct 3.6799 ms/op 2.4961 ms/op 1.47
List(uint64Number) 100000 struct -> binary 2.6761 ms/op 1.8293 ms/op 1.46
List(uint64Number) 100000 tree_backed -> binary 1.8995 ms/op 1.1315 ms/op 1.68
List(Uint64Bigint) 100000 binary -> struct 6.5409 ms/op 4.2967 ms/op 1.52
List(Uint64Bigint) 100000 binary -> tree_backed 6.4817 ms/op 4.2466 ms/op 1.53
List(Uint64Bigint) 100000 struct -> tree_backed 11.201 ms/op 7.6683 ms/op 1.46
List(Uint64Bigint) 100000 tree_backed -> struct 8.6045 ms/op 5.3639 ms/op 1.60
List(Uint64Bigint) 100000 struct -> binary 3.8632 ms/op 2.5965 ms/op 1.49
List(Uint64Bigint) 100000 tree_backed -> binary 2.0926 ms/op 1.0778 ms/op 1.94
Vector(Root) 100000 binary -> struct 67.403 ms/op 43.734 ms/op 1.54
Vector(Root) 100000 binary -> tree_backed 63.865 ms/op 37.478 ms/op 1.70
Vector(Root) 100000 struct -> tree_backed 77.922 ms/op 53.458 ms/op 1.46
Vector(Root) 100000 tree_backed -> struct 88.208 ms/op 59.620 ms/op 1.48
Vector(Root) 100000 struct -> binary 3.8549 ms/op 2.5082 ms/op 1.54
Vector(Root) 100000 tree_backed -> binary 16.794 ms/op 10.780 ms/op 1.56
List(Validator) 100000 binary -> struct 226.76 ms/op 155.31 ms/op 1.46
List(Validator) 100000 binary -> tree_backed 604.32 ms/op 418.05 ms/op 1.45
List(Validator) 100000 struct -> tree_backed 645.87 ms/op 444.36 ms/op 1.45
List(Validator) 100000 tree_backed -> struct 388.61 ms/op 255.34 ms/op 1.52
List(Validator) 100000 struct -> binary 56.861 ms/op 40.534 ms/op 1.40
List(Validator) 100000 tree_backed -> binary 179.25 ms/op 106.27 ms/op 1.69
List(Validator-NS) 100000 binary -> struct 246.33 ms/op 156.12 ms/op 1.58
List(Validator-NS) 100000 binary -> tree_backed 315.08 ms/op 218.43 ms/op 1.44
List(Validator-NS) 100000 struct -> tree_backed 397.85 ms/op 275.02 ms/op 1.45
List(Validator-NS) 100000 tree_backed -> struct 339.68 ms/op 231.04 ms/op 1.47
List(Validator-NS) 100000 struct -> binary 57.858 ms/op 42.179 ms/op 1.37
List(Validator-NS) 100000 tree_backed -> binary 69.438 ms/op 47.783 ms/op 1.45
get epochStatuses - MutableVector 144.74 us/op 99.716 us/op 1.45
get epochStatuses - ViewDU 334.54 us/op 289.61 us/op 1.16
set epochStatuses - ListTreeView 2.4963 ms/op 1.8332 ms/op 1.36
set epochStatuses - ListTreeView - set() 742.37 us/op 599.40 us/op 1.24
set epochStatuses - ListTreeView - commit() 825.23 us/op 538.69 us/op 1.53
bitstring 891.66 ns/op 925.38 ns/op 0.96
bit mask 16.185 ns/op 14.495 ns/op 1.12
struct - increase slot to 1000000 2.6015 ms/op 1.9066 ms/op 1.36
UintNumberType - increase slot to 1000000 57.602 ms/op 36.724 ms/op 1.57
UintBigintType - increase slot to 1000000 743.45 ms/op 546.15 ms/op 1.36
UintBigint8 x 100000 tree_deserialize 7.5463 ms/op 5.9588 ms/op 1.27
UintBigint8 x 100000 tree_serialize 2.3890 ms/op 1.4475 ms/op 1.65
UintBigint16 x 100000 tree_deserialize 6.9762 ms/op 5.9895 ms/op 1.16
UintBigint16 x 100000 tree_serialize 2.6670 ms/op 1.4680 ms/op 1.82
UintBigint32 x 100000 tree_deserialize 8.9576 ms/op 6.0984 ms/op 1.47
UintBigint32 x 100000 tree_serialize 2.4337 ms/op 1.4937 ms/op 1.63
UintBigint64 x 100000 tree_deserialize 11.085 ms/op 6.7938 ms/op 1.63
UintBigint64 x 100000 tree_serialize 3.1769 ms/op 1.9421 ms/op 1.64
UintBigint8 x 100000 value_deserialize 1.0378 ms/op 547.97 us/op 1.89
UintBigint8 x 100000 value_serialize 1.4375 ms/op 793.54 us/op 1.81
UintBigint16 x 100000 value_deserialize 1.1048 ms/op 601.16 us/op 1.84
UintBigint16 x 100000 value_serialize 1.6222 ms/op 873.24 us/op 1.86
UintBigint32 x 100000 value_deserialize 1.0094 ms/op 545.07 us/op 1.85
UintBigint32 x 100000 value_serialize 1.6577 ms/op 830.12 us/op 2.00
UintBigint64 x 100000 value_deserialize 1.1082 ms/op 605.13 us/op 1.83
UintBigint64 x 100000 value_serialize 1.8828 ms/op 1.0870 ms/op 1.73
UintBigint8 x 100000 deserialize 8.4837 ms/op 5.7161 ms/op 1.48
UintBigint8 x 100000 serialize 3.2970 ms/op 1.9719 ms/op 1.67
UintBigint16 x 100000 deserialize 8.8331 ms/op 5.7836 ms/op 1.53
UintBigint16 x 100000 serialize 3.0191 ms/op 2.0338 ms/op 1.48
UintBigint32 x 100000 deserialize 10.185 ms/op 6.8827 ms/op 1.48
UintBigint32 x 100000 serialize 5.2841 ms/op 3.6233 ms/op 1.46
UintBigint64 x 100000 deserialize 6.4496 ms/op 4.5472 ms/op 1.42
UintBigint64 x 100000 serialize 2.8913 ms/op 1.8719 ms/op 1.54
UintBigint128 x 100000 deserialize 10.291 ms/op 7.0155 ms/op 1.47
UintBigint128 x 100000 serialize 34.038 ms/op 21.263 ms/op 1.60
UintBigint256 x 100000 deserialize 18.938 ms/op 13.105 ms/op 1.45
UintBigint256 x 100000 serialize 102.18 ms/op 62.866 ms/op 1.63
Slice from Uint8Array x25000 2.0282 ms/op 1.3071 ms/op 1.55
Slice from ArrayBuffer x25000 34.101 ms/op 23.999 ms/op 1.42
Slice from ArrayBuffer x25000 + new Uint8Array 37.628 ms/op 24.204 ms/op 1.55
Copy Uint8Array 100000 iterate 1.7516 ms/op 1.0355 ms/op 1.69
Copy Uint8Array 100000 slice 172.35 us/op 87.685 us/op 1.97
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 172.95 us/op 87.904 us/op 1.97
Copy Buffer 100000 Uint8Array.prototype.slice.call 172.34 us/op 89.300 us/op 1.93
Copy Uint8Array 100000 slice + set 398.65 us/op 190.22 us/op 2.10
Copy Uint8Array 100000 subarray + set 172.80 us/op 92.248 us/op 1.87
Copy Uint8Array 100000 slice arrayBuffer 365.58 us/op 88.178 us/op 4.15
Uint64 deserialize 100000 - iterate Uint8Array 2.6249 ms/op 1.9728 ms/op 1.33
Uint64 deserialize 100000 - by Uint32A 2.4333 ms/op 1.9491 ms/op 1.25
Uint64 deserialize 100000 - by DataView.getUint32 x2 2.6749 ms/op 1.9030 ms/op 1.41
Uint64 deserialize 100000 - by DataView.getBigUint64 8.0753 ms/op 5.7308 ms/op 1.41
Uint64 deserialize 100000 - by byte 82.343 ms/op 72.583 ms/op 1.13

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.

Overall looks good! Haven't asserted correctness against the spec. Minor comment

packages/persistent-merkle-tree/src/proof/compactMulti.ts Outdated Show resolved Hide resolved
wemeetagain and others added 2 commits December 19, 2022 08:54
Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>
@wemeetagain wemeetagain changed the title Compact multiproof feat: compact multiproof Jan 6, 2023
@wemeetagain wemeetagain merged commit 5f1ea99 into master Jan 6, 2023
@wemeetagain wemeetagain deleted the cayman/dynamic-multiproof branch January 6, 2023 21:50
@github-actions github-actions bot mentioned this pull request Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants