@@ -9,6 +9,7 @@ use kzg::eip_4844::{BYTES_PER_BLOB, TRUSTED_SETUP_PATH};
9
9
10
10
use kzg_bench:: set_trusted_setup_dir;
11
11
use kzg_bench:: tests:: eip_4844:: { generate_random_blob_bytes, generate_random_field_element_bytes} ;
12
+ use rand:: random;
12
13
use rust_kzg_constantine:: mixed_kzg:: mixed_kzg_settings:: CttContext ;
13
14
14
15
fn bench_eip_4844_constantine_no_conv_ ( c : & mut Criterion ) {
@@ -23,104 +24,59 @@ fn bench_eip_4844_constantine_no_conv_(c: &mut Criterion) {
23
24
24
25
let commitments: Vec < [ u8 ; 48 ] > = blobs
25
26
. iter ( )
26
- . map ( |blob| ctx. ctx . blob_to_kzg_commitment ( blob) . unwrap ( ) )
27
+ . map ( |blob| ctx. blob_to_kzg_commitment ( blob) . unwrap ( ) )
27
28
. collect ( ) ;
28
29
29
30
let proofs: Vec < [ u8 ; 48 ] > = blobs
30
31
. iter ( )
31
32
. zip ( commitments. iter ( ) )
32
- . map ( |( blob, commitment) | ctx. ctx . compute_blob_kzg_proof ( blob, commitment) . unwrap ( ) )
33
+ . map ( |( blob, commitment) | ctx. compute_blob_kzg_proof ( blob, commitment) . unwrap ( ) )
33
34
. collect ( ) ;
34
35
35
36
let fields: Vec < [ u8 ; 32 ] > = ( 0 ..MAX_COUNT )
36
37
. map ( |_| generate_random_field_element_bytes ( & mut rng) )
37
38
. collect ( ) ;
38
39
39
40
c. bench_function ( "blob_to_kzg_commitment" , |b| {
40
- #[ cfg( feature = "parallel" ) ]
41
- b. iter ( || {
42
- ctx. ctx
43
- . blob_to_kzg_commitment_parallel ( & ctx. pool , blobs. first ( ) . unwrap ( ) )
44
- } ) ;
45
-
46
- #[ cfg( not( feature = "parallel" ) ) ]
47
- b. iter ( || ctx. ctx . blob_to_kzg_commitment ( blobs. first ( ) . unwrap ( ) ) ) ;
41
+ b. iter ( || ctx. blob_to_kzg_commitment ( blobs. first ( ) . unwrap ( ) ) ) ;
48
42
} ) ;
49
43
50
44
c. bench_function ( "compute_kzg_proof" , |b| {
51
- #[ cfg( feature = "parallel" ) ]
52
- b. iter ( || {
53
- ctx. ctx . compute_kzg_proof_parallel (
54
- & ctx. pool ,
55
- blobs. first ( ) . unwrap ( ) ,
56
- fields. first ( ) . unwrap ( ) ,
57
- )
58
- } ) ;
59
-
60
- #[ cfg( not( feature = "parallel" ) ) ]
61
- b. iter ( || {
62
- ctx. ctx
63
- . compute_kzg_proof ( blobs. first ( ) . unwrap ( ) , fields. first ( ) . unwrap ( ) )
64
- } ) ;
45
+ b. iter ( || ctx. compute_kzg_proof ( blobs. first ( ) . unwrap ( ) , fields. first ( ) . unwrap ( ) ) ) ;
65
46
} ) ;
66
47
67
48
c. bench_function ( "verify_kzg_proof" , |b| {
68
49
b. iter ( || {
69
- ctx. ctx
70
- . verify_kzg_proof (
71
- commitments. first ( ) . unwrap ( ) ,
72
- fields. first ( ) . unwrap ( ) ,
73
- fields. first ( ) . unwrap ( ) ,
74
- proofs. first ( ) . unwrap ( ) ,
75
- )
76
- . unwrap ( )
50
+ ctx. verify_kzg_proof (
51
+ commitments. first ( ) . unwrap ( ) ,
52
+ fields. first ( ) . unwrap ( ) ,
53
+ fields. first ( ) . unwrap ( ) ,
54
+ proofs. first ( ) . unwrap ( ) ,
55
+ )
56
+ . unwrap ( )
77
57
} )
78
58
} ) ;
79
59
80
60
c. bench_function ( "compute_blob_kzg_proof" , |b| {
81
- #[ cfg( feature = "parallel" ) ]
82
- b. iter ( || {
83
- ctx. ctx . compute_blob_kzg_proof_parallel (
84
- & ctx. pool ,
85
- blobs. first ( ) . unwrap ( ) ,
86
- commitments. first ( ) . unwrap ( ) ,
87
- )
88
- } ) ;
89
-
90
- #[ cfg( not( feature = "parallel" ) ) ]
91
61
b. iter ( || {
92
- ctx. ctx
93
- . compute_blob_kzg_proof ( blobs . first ( ) . unwrap ( ) , commitments . first ( ) . unwrap ( ) )
62
+ ctx. compute_blob_kzg_proof ( blobs . first ( ) . unwrap ( ) , commitments . first ( ) . unwrap ( ) )
63
+ . unwrap ( ) ;
94
64
} ) ;
95
65
} ) ;
96
66
97
67
c. bench_function ( "verify_blob_kzg_proof" , |b| {
98
- #[ cfg( feature = "parallel" ) ]
99
68
b. iter ( || {
100
- ctx. ctx
101
- . verify_blob_kzg_proof_parallel (
102
- & ctx. pool ,
103
- blobs. first ( ) . unwrap ( ) ,
104
- commitments. first ( ) . unwrap ( ) ,
105
- proofs. first ( ) . unwrap ( ) ,
106
- )
107
- . unwrap ( )
108
- } ) ;
109
-
110
- #[ cfg( not( feature = "parallel" ) ) ]
111
- b. iter ( || {
112
- ctx. ctx
113
- . verify_blob_kzg_proof (
114
- blobs. first ( ) . unwrap ( ) ,
115
- commitments. first ( ) . unwrap ( ) ,
116
- proofs. first ( ) . unwrap ( ) ,
117
- )
118
- . unwrap ( )
69
+ ctx. verify_blob_kzg_proof (
70
+ blobs. first ( ) . unwrap ( ) ,
71
+ commitments. first ( ) . unwrap ( ) ,
72
+ proofs. first ( ) . unwrap ( ) ,
73
+ )
74
+ . unwrap ( )
119
75
} ) ;
120
76
} ) ;
121
77
122
78
let mut group = c. benchmark_group ( "verify_blob_kzg_proof_batch" ) ;
123
- let rand_thing = [ 0u8 ; 32 ] ;
79
+ let rand_thing = random ( ) ;
124
80
for count in [ 1 , 2 , 4 , 8 , 16 , 32 , 64 ] {
125
81
group. throughput ( Throughput :: Elements ( count as u64 ) ) ;
126
82
group. bench_with_input ( BenchmarkId :: from_parameter ( count) , & count, |b, & count| {
@@ -137,26 +93,13 @@ fn bench_eip_4844_constantine_no_conv_(c: &mut Criterion) {
137
93
( blobs_subset, commitments_subset, proofs_subset)
138
94
} ,
139
95
|( blobs_subset, commitments_subset, proofs_subset) | {
140
- #[ cfg( feature = "parallel" ) ]
141
- ctx. ctx
142
- . verify_blob_kzg_proof_batch_parallel (
143
- & ctx. pool ,
144
- blobs_subset,
145
- commitments_subset,
146
- proofs_subset,
147
- & rand_thing,
148
- )
149
- . unwrap ( ) ;
150
-
151
- #[ cfg( not( feature = "parallel" ) ) ]
152
- ctx. ctx
153
- . verify_blob_kzg_proof_batch (
154
- blobs_subset,
155
- commitments_subset,
156
- proofs_subset,
157
- & rand_thing,
158
- )
159
- . unwrap ( ) ;
96
+ ctx. verify_blob_kzg_proof_batch (
97
+ blobs_subset,
98
+ commitments_subset,
99
+ proofs_subset,
100
+ & rand_thing,
101
+ )
102
+ . unwrap ( ) ;
160
103
} ,
161
104
BatchSize :: LargeInput ,
162
105
) ;
0 commit comments