jtgrassie / monero-pool

A Monero mining pool server written in C
BSD 3-Clause "New" or "Revised" License
344 stars 121 forks source link

Will not compile - rx_slow_hash has changed #130

Closed 88plug closed 1 year ago

88plug commented 1 year ago

Current build error with latest release version of monero 0.18

Creating object file for src/xmr...
Creating object file for src/bstack...
Creating object file for src/forkoff...
g++ -Wp,-MMD,build/release/src/xmr.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wno-reorder -maes -fPIC -std=c++11 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include \
  -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX \
  -c src/xmr.cpp -o build/release/src/xmr.o
gcc -Wp,-MMD,build/release/src/bstack.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/bstack.c -o build/release/src/bstack.o
gcc -Wp,-MMD,build/release/src/forkoff.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/forkoff.c -o build/release/src/forkoff.o
Creating object file for src/growbag...
gcc -Wp,-MMD,build/release/src/growbag.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/growbag.c -o build/release/src/growbag.o
Creating object file for src/util...
Creating object file for src/pool...
gcc -Wp,-MMD,build/release/src/pool.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/pool.c -o build/release/src/pool.o
Creating object file for src/webui...
gcc -Wp,-MMD,build/release/src/util.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/util.c -o build/release/src/util.o
gcc -Wp,-MMD,build/release/src/webui.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c src/webui.c -o build/release/src/webui.o
Creating object file for rxi/log/src/log...
gcc -Wp,-MMD,build/release/rxi/log/src/log.dd -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3 \
  -Isrc -Idata -Irxi/log/src -I/monero/src -I/monero/external -I/monero/external/easylogging++ -I/monero/contrib/epee/include -I/opt/local/include -I/usr/local/include -pthread -I/usr/include/json-c \
  -D_GNU_SOURCE -DAUTO_INITIALIZE_EASYLOGGINGPP -DLOG_USE_COLOR -DHAVE_RX -c rxi/log/src/log.c -o build/release/rxi/log/src/log.o
Creating object file for src/webui-embed...
xxd -i src/webui-embed.html | sed -e 's/src_//' -e 's/embed_//' > build/release/src/webui-embed.c
gcc -W -Wall -Wno-unused-parameter -Wuninitialized -Wbad-function-cast -maes -fPIC -std=c99 -O3  -c build/release/src/webui-embed.c -o build/release/src/webui-embed.o
src/pool.c: In function 'response_to_block':
src/pool.c:1599:5: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 1599 |     strncpy(block->hash, json_object_get_string(hash), 64);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c:1600:5: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 1600 |     strncpy(block->prev_hash, json_object_get_string(prev_hash), 64);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'response_to_block_template',
    inlined from 'rpc_on_block_template' at src/pool.c:1827:5:
src/pool.c:1567:5: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 1567 |     strncpy(block_template->prev_hash, json_object_get_string(prev_hash), 64);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c:1579:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 1579 |         strncpy(block_template->seed_hash,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1580 |                 json_object_get_string(seed_hash), 64);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c:1581:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 1581 |         strncpy(block_template->next_seed_hash,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1582 |                 json_object_get_string(next_seed_hash), 64);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c: In function 'miner_on_submit':
src/pool.c:3528:9: warning: 'strncpy' output may be truncated copying 127 bytes from a string of length 127 [-Wstringop-truncation]
 3528 |         strncpy(share.address, client->address, sizeof(share.address)-1);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'miner_on_block_template',
    inlined from 'miner_on_read' at src/pool.c:3616:13:
src/pool.c:3210:5: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 3210 |     strncpy(job->miner_template->prev_hash,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3211 |             json_object_get_string(prev_hash), 64);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c:3222:9: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 3222 |         strncpy(job->miner_template->seed_hash,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3223 |                 json_object_get_string(seed_hash), 64);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c:3226:13: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
 3226 |             strncpy(job->miner_template->next_seed_hash, nsh, 64);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/pool.c: In function 'main':
src/pool.c:4690:5: warning: 'strncpy' output may be truncated copying 255 bytes from a string of length 255 [-Wstringop-truncation]
 4690 |     strncpy(uic.listen, config.webui_listen, sizeof(uic.listen)-1);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/xmr.cpp: In function 'void get_rx_hash(const unsigned char*, size_t, unsigned char*, const unsigned char*, uint64_t)':
src/xmr.cpp:156:18: error: invalid conversion from 'uint64_t' {aka 'long unsigned int'} to 'const char*' [-fpermissive]
  156 |     rx_slow_hash(height, seed_height, (const char*)seed_hash,
      |                  ^~~~~~
      |                  |
      |                  uint64_t {aka long unsigned int}
src/xmr.cpp:156:26: error: invalid conversion from 'uint64_t' {aka 'long unsigned int'} to 'const void*' [-fpermissive]
  156 |     rx_slow_hash(height, seed_height, (const char*)seed_hash,
      |                          ^~~~~~~~~~~
      |                          |
      |                          uint64_t {aka long unsigned int}
src/xmr.cpp:156:39: error: invalid conversion from 'const char*' to 'size_t' {aka 'long unsigned int'} [-fpermissive]
  156 |     rx_slow_hash(height, seed_height, (const char*)seed_hash,
      |                                       ^~~~~~~~~~~~~~~~~~~~~~
      |                                       |
      |                                       const char*
src/xmr.cpp:157:13: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
  157 |             (const char*)input, in_size, (char*)output, miners, 0);
      |             ^~~~~~~~~~~~~~~~~~
      |             |
      |             const char*
src/xmr.cpp:157:66: error: too many arguments to function 'void crypto::rx_slow_hash(const char*, const void*, size_t, char*)'
  157 |             (const char*)input, in_size, (char*)output, miners, 0);
      |                                                                  ^
In file included from /monero/src/crypto/hash.h:44,
                 from /monero/src/crypto/chacha.h:44,
                 from /monero/src/serialization/crypto.h:37,
                 from /monero/src/cryptonote_basic/cryptonote_basic.h:44,
                 from src/xmr.cpp:38:
/monero/src/crypto/hash-ops.h:102:6: note: declared here
  102 | void rx_slow_hash(const char *seedhash, const void *data, size_t length, char *result_hash);
      |      ^~~~~~~~~~~~
make: *** [Makefile:186: build/release/src/xmr.o] Error 1

With more research this is caused by a change 2 weeks ago to rx_slow_hash. https://github.com/monero-project/monero/commit/dab7d01dc0357a926993e5205d02a063b6bdcda0

 Refactored rx-slow-hash.c

- Straight-forward call interface: `void rx_slow_hash(const char *seedhash, const void *data, size_t length, char *result_hash)`
- Consensus chain seed hash is now updated by calling `rx_set_main_seedhash` whenever a block is added/removed or a reorg happens
- `rx_slow_hash` will compute correct hash no matter if `rx_set_main_seedhash` was called or not (the only difference is performance)
- New environment variable `MONERO_RANDOMX_FULL_MEM` to force use the full dataset for PoW verification (faster block verification)
- When dataset is used for PoW verification, dataset updates don't stall other threads (verification is done in light mode then)
- When mining is running, PoW checks now also use dataset for faster verification

Solution appears to be to update /src/xmr.cpp with the new function format.

jtgrassie commented 1 year ago

The most recent Monero release tag is v0.18.1.2, which the pool builds fine against. When the next Monero release is tagged, I will merge branch next to master.