I am modifying a cryptonote to transition over to PoW algo cryptonightv1 from cryptonightv0 and I am having a weird issue that I can't figure out...I'm starting to pull out my hair over this. I've studied the changes that Monero, Turtlecoin, Electroneum and Masari have done and implemented it on my own coin (which shares a similar code base to turtlecoin/original bcn) yet miners seem to be able to mine with either PoW algo now (cryptonightv0 or v1) instead of just v1, at least as far as I can tell when using a pool. The tests/hash_tests app verifies that the PoW algos work correctly as I have these functions here that test cn_slow_hash with a variant=0 (for v0) and then with variant=1 (for v1):
static void cn_slow_hash_0(const void *data, size_t length, char *hash) {
return cn_slow_hash(*context, data, length, *reinterpret_cast<chash *>(hash), 0);
}
static void cn_slow_hash_1(const void *data, size_t length, char *hash) {
return cn_slow_hash(*context, data, length, *reinterpret_cast<chash *>(hash), 1);
}
The tests pass so I know that the actual PoW algorithm is implemented correctly in the sense that when cn_variant 0 is passed to cn_slow_hash() that it retrieves the hash for cryptonightv0 and when cn_variant 1 is passed it retrieves the hash for cryptonightv1.
The issue I am having is that when I start a local test net or live test net, I can mine with a pool with xmr-stak-nvidia with the miner algo set to "cryptonight" or "monero7" regardless of what height I am at (if I have the pool set to cryptonight then cryptonight works, if I have it set to v1 then monero7 works). I've done all the appropriate upgrade height changes and the block's major version even changes yet the get_block_longhash function doesn't seem to run the appropriate cn_long_hash variant. Even if I manually set cn_variant to 1 for ALL heights the miners are STILL able to mine either PoW algo if the pool allows it. Here is what my get_block_longhash function has to supply the correct variant to the cn_slow_hash function:
const int cn_variant = b.majorVersion >= 5 ? b.majorVersion - 4 : 0;
cn_slow_hash(context, bd.data(), bd.size(), res, cn_variant);
So if the version is 5 or greater the cn_variant should equal 1. When I print the blocks they show that they are majorVersion 5, yet the old PoW algo is still working to mine blocks! Unless there is something wrong with my pool setup that is tricking me (https://github.com/dvandal/cryptonote-nodejs-pool/). Is there another way that I could test this without question to make sure it is swapping over to the new PoW correctly? I am running out of ideas because, like I said, even if I manually force cn_variant to be 1 without the ternary operator it doesn't fix the issue. What am I missing here? Any advice is GREATLY appreciated. I am so stuck right now.
EDIT: Am I not understanding this correctly? I just tried the pool with a different coin that is cryptonightv0 only, and it allowed me to mine with "monero7" in xmr-stak-nvidia and accepted the shares?