MoneroOcean / node-cryptonight-hashing

Cryptonight hashing functions for node.js
27 stars 111 forks source link

Support multiple RandomX variants #32

Closed jagerman closed 5 years ago

jagerman commented 5 years ago

This replaces the RandomWOW support with a copy of xmrig's RandomX support (from the upcoming evo branch) which supports multiple configurations at runtime.

This replaces the "random_wow" algorithm with a "randomx" algorithm that takes variants (like the cryptonight algorithms). Variant 0 (the default when specifying no variant) is Monero's RandomX; variants 17 and 18 (using xmrig's variant values) are the RandomWOW and RandomXL (Loki) variants.

Fixes #31

MoneroOcean commented 5 years ago

Thank you! Will look into this today.

MoneroOcean commented 5 years ago

I see a huge amount of work done here. Thank you again.

MoneroOcean commented 5 years ago

Is this possible to improve switching time between different RX variants?

multiHashing.randomx(input, Buffer.from('000000000000000100000000000000000000000f000000042000000000000000', 'hex'), 17);
multiHashing.randomx(input, Buffer.from('000000000000000100000000000000000000000f000000042000000000000000', 'hex'), 18);

Takes ages to execute if we put this in loop.

MoneroOcean commented 5 years ago

Maybe do not use RANDOMX_FLAG_JIT to lower memory usage and use separate caches for each RX variant?

MoneroOcean commented 5 years ago

OK, looks like removing RANDOMX_FLAG_JIT is not a good idea for perf. So it seems your solution is actually the best one unless user will want rapid switches between RX variants.

MoneroOcean commented 5 years ago

Turns out that this switch performance can be still improved by storing cache/vm separately for each RX variant. Will going to accept your pull request (thank you again) and will apply extra patches/tests on top of it.