@@ -96,6 +96,7 @@ void printUsage(const char* executable) {
9696 std::cout << " --avx2 use optimized Argon2 for AVX2 CPUs" << std::endl;
9797 std::cout << " --auto select the best options for the current CPU" << std::endl;
9898 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;
99100}
100101
101102struct MemoryException : public std ::exception {
@@ -113,7 +114,7 @@ struct DatasetAllocException : public MemoryException {
113114
114115using MineFunc = void (randomx_vm * vm, std::atomic<uint32_t > & atomicNonce, AtomicHash & result, uint32_t noncesCount, int thread, int cpuid);
115116
116- template <bool batch>
117+ template <bool batch, bool commit >
117118void mine (randomx_vm* vm, std::atomic<uint32_t >& atomicNonce, AtomicHash& result, uint32_t noncesCount, int thread, int cpuid = -1 ) {
118119 if (cpuid >= 0 ) {
119120 int rc = set_thread_affinity (cpuid);
@@ -138,6 +139,9 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
138139 }
139140 store32 (noncePtr, nonce);
140141 (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+ }
141145 result.xorWith (hash);
142146 if (!batch) {
143147 nonce = atomicNonce.fetch_add (1 );
@@ -146,7 +150,7 @@ void mine(randomx_vm* vm, std::atomic<uint32_t>& atomicNonce, AtomicHash& result
146150}
147151
148152int main (int argc, char ** argv) {
149- bool softAes, miningMode, verificationMode, help, largePages, jit, secure;
153+ bool softAes, miningMode, verificationMode, help, largePages, jit, secure, commit ;
150154 bool ssse3, avx2, autoFlags, noBatch;
151155 int noncesCount, threadCount, initThreadCount;
152156 uint64_t threadAffinity;
@@ -172,10 +176,11 @@ int main(int argc, char** argv) {
172176 readOption (" --avx2" , argc, argv, avx2);
173177 readOption (" --auto" , argc, argv, autoFlags);
174178 readOption (" --noBatch" , argc, argv, noBatch);
179+ readOption (" --commit" , argc, argv, commit);
175180
176181 store32 (&seed, seedValue);
177182
178- std::cout << " RandomX benchmark v1.1.11 " << std::endl;
183+ std::cout << " RandomX benchmark v1.1.12 " << std::endl;
179184
180185 if (help) {
181186 printUsage (argv[0 ]);
@@ -280,11 +285,24 @@ int main(int argc, char** argv) {
280285 MineFunc* func;
281286
282287 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+ }
284295 }
285296 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+ }
288306 }
289307
290308 std::cout << " Initializing" ;
@@ -376,7 +394,7 @@ int main(int argc, char** argv) {
376394 randomx_release_cache (cache);
377395 std::cout << " Calculated result: " ;
378396 result.print (std::cout);
379- if (noncesCount == 1000 && seedValue == 0 )
397+ if (noncesCount == 1000 && seedValue == 0 && !commit )
380398 std::cout << " Reference result: 10b649a3f15c7c7f88277812f2e74b337a0f20ce909af09199cccb960771cfa1" << std::endl;
381399 if (!miningMode) {
382400 std::cout << " Performance: " << 1000 * elapsed / noncesCount << " ms per hash" << std::endl;
0 commit comments