@@ -96,6 +96,7 @@ void printUsage(const char* executable) {
96
96
std::cout << " --avx2 use optimized Argon2 for AVX2 CPUs" << std::endl;
97
97
std::cout << " --auto select the best options for the current CPU" << std::endl;
98
98
std::cout << " --noBatch calculate hashes one by one (default: batch)" << std::endl;
99
+ std::cout << " --commit calculate commitments instead of hashes (default: hashes)" << std::endl;
99
100
}
100
101
101
102
struct MemoryException : public std ::exception {
@@ -113,7 +114,7 @@ struct DatasetAllocException : public MemoryException {
113
114
114
115
using MineFunc = void (randomx_vm * vm, std::atomic<uint32_t > & atomicNonce, AtomicHash & result, uint32_t noncesCount, int thread, int cpuid);
115
116
116
- template <bool batch>
117
+ template <bool batch, bool commit >
117
118
void mine (randomx_vm* vm, std::atomic<uint32_t >& atomicNonce, AtomicHash& result, uint32_t noncesCount, int thread, int cpuid = -1 ) {
118
119
if (cpuid >= 0 ) {
119
120
int rc = set_thread_affinity (cpuid);
@@ -138,6 +139,9 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
138
139
}
139
140
store32 (noncePtr, nonce);
140
141
(batch ? randomx_calculate_hash_next : randomx_calculate_hash)(vm, blockTemplate, sizeof (blockTemplate), &hash);
142
+ if (commit) {
143
+ randomx_calculate_commitment (blockTemplate, sizeof (blockTemplate), &hash, &hash);
144
+ }
141
145
result.xorWith (hash);
142
146
if (!batch) {
143
147
nonce = atomicNonce.fetch_add (1 );
@@ -146,7 +150,7 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
146
150
}
147
151
148
152
int main (int argc, char ** argv) {
149
- bool softAes, miningMode, verificationMode, help, largePages, jit, secure;
153
+ bool softAes, miningMode, verificationMode, help, largePages, jit, secure, commit ;
150
154
bool ssse3, avx2, autoFlags, noBatch;
151
155
int noncesCount, threadCount, initThreadCount;
152
156
uint64_t threadAffinity;
@@ -172,10 +176,11 @@ int main(int argc, char** argv) {
172
176
readOption (" --avx2" , argc, argv, avx2);
173
177
readOption (" --auto" , argc, argv, autoFlags);
174
178
readOption (" --noBatch" , argc, argv, noBatch);
179
+ readOption (" --commit" , argc, argv, commit);
175
180
176
181
store32 (&seed, seedValue);
177
182
178
- std::cout << " RandomX benchmark v1.1.11 " << std::endl;
183
+ std::cout << " RandomX benchmark v1.1.12 " << std::endl;
179
184
180
185
if (help) {
181
186
printUsage (argv[0 ]);
@@ -280,11 +285,24 @@ int main(int argc, char** argv) {
280
285
MineFunc* func;
281
286
282
287
if (noBatch) {
283
- func = &mine<false >;
288
+ if (commit) {
289
+ std::cout << " - hash commitments" << std::endl;
290
+ func = &mine<false , true >;
291
+ }
292
+ else {
293
+ func = &mine<false , false >;
294
+ }
284
295
}
285
296
else {
286
- func = &mine<true >;
287
- std::cout << " - batch mode" << std::endl;
297
+ if (commit) {
298
+ // TODO: support batch mode with commitments
299
+ std::cout << " - hash commitments" << std::endl;
300
+ func = &mine<false , true >;
301
+ }
302
+ else {
303
+ std::cout << " - batch mode" << std::endl;
304
+ func = &mine<true , false >;
305
+ }
288
306
}
289
307
290
308
std::cout << " Initializing" ;
@@ -376,7 +394,7 @@ int main(int argc, char** argv) {
376
394
randomx_release_cache (cache);
377
395
std::cout << " Calculated result: " ;
378
396
result.print (std::cout);
379
- if (noncesCount == 1000 && seedValue == 0 )
397
+ if (noncesCount == 1000 && seedValue == 0 && !commit )
380
398
std::cout << " Reference result: 10b649a3f15c7c7f88277812f2e74b337a0f20ce909af09199cccb960771cfa1" << std::endl;
381
399
if (!miningMode) {
382
400
std::cout << " Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl;
0 commit comments