SChernykh/p2pool

`--light-mode` question

hinto-janai opened this issue · 1 comments

Just making sure: for non-mining P2Pools, is using --light-mode to use just the cache for verification but not have the whole dataset in memory ideal?

p2pool/src/pow_hash.cpp

Lines 48 to 75 in 1439609

if (m_pool && !m_pool->params().m_lightMode) {
m_dataset = randomx_alloc_dataset(RANDOMX_FLAG_LARGE_PAGES);
if (!m_dataset) {
LOGWARN(1, "couldn't allocate RandomX dataset using large pages");
m_dataset = randomx_alloc_dataset(RANDOMX_FLAG_DEFAULT);
if (!m_dataset) {
LOGERR(1, "couldn't allocate RandomX dataset");
}
}
if (m_dataset) {
memory_allocated += RANDOMX_DATASET_BASE_SIZE + RANDOMX_DATASET_EXTRA_SIZE;
}
}
const randomx_flags flags = randomx_get_flags();
for (size_t i = 0; i < array_size(&RandomX_Hasher::m_cache); ++i) {
m_cache[i] = randomx_alloc_cache(flags | RANDOMX_FLAG_LARGE_PAGES);
if (!m_cache[i]) {
LOGWARN(1, "couldn't allocate RandomX cache using large pages");
m_cache[i] = randomx_alloc_cache(flags);
if (!m_cache[i]) {
LOGERR(1, "couldn't allocate RandomX cache, aborting");
PANIC_STOP();
}
}
memory_allocated += RANDOMX_ARGON_MEMORY * 1024;
}

i.e, --light-mode skips the first block for dataset allocation, but the cache always gets allocated, which is all we need for hash verification?

Yes, this is exactly what it does. --light-mode disables dataset allocation, but RandomX hashes can still be checked.