|
|
|
@ -110,6 +110,22 @@ private:
|
|
|
|
|
std::atomic<uint64_t> hash[4];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void generateAsm(int nonce) {
|
|
|
|
|
uint64_t hash[4];
|
|
|
|
|
unsigned char blockTemplate[] = {
|
|
|
|
|
0x07, 0x07, 0xf7, 0xa4, 0xf0, 0xd6, 0x05, 0xb3, 0x03, 0x26, 0x08, 0x16, 0xba, 0x3f, 0x10, 0x90, 0x2e, 0x1a, 0x14,
|
|
|
|
|
0x5a, 0xc5, 0xfa, 0xd3, 0xaa, 0x3a, 0xf6, 0xea, 0x44, 0xc1, 0x18, 0x69, 0xdc, 0x4f, 0x85, 0x3f, 0x00, 0x2b, 0x2e,
|
|
|
|
|
0xea, 0x00, 0x00, 0x00, 0x00, 0x77, 0xb2, 0x06, 0xa0, 0x2c, 0xa5, 0xb1, 0xd4, 0xce, 0x6b, 0xbf, 0xdf, 0x0a, 0xca,
|
|
|
|
|
0xc3, 0x8b, 0xde, 0xd3, 0x4d, 0x2d, 0xcd, 0xee, 0xf9, 0x5c, 0xd2, 0x0c, 0xef, 0xc1, 0x2f, 0x61, 0xd5, 0x61, 0x09
|
|
|
|
|
};
|
|
|
|
|
int* noncePtr = (int*)(blockTemplate + 39);
|
|
|
|
|
*noncePtr = nonce;
|
|
|
|
|
blake2b(hash, sizeof(hash), blockTemplate, sizeof(blockTemplate), nullptr, 0);
|
|
|
|
|
RandomX::AssemblyGeneratorX86 asmX86;
|
|
|
|
|
asmX86.generateProgram(hash);
|
|
|
|
|
asmX86.printCode(std::cout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mine(RandomX::VirtualMachine* vm, std::atomic<int>& atomicNonce, AtomicHash& result, int noncesCount, int thread) {
|
|
|
|
|
uint64_t hash[4];
|
|
|
|
|
unsigned char blockTemplate[] = {
|
|
|
|
@ -128,6 +144,7 @@ void mine(RandomX::VirtualMachine* vm, std::atomic<int>& atomicNonce, AtomicHash
|
|
|
|
|
int spIndex = ((uint8_t*)hash)[24] | ((((uint8_t*)hash)[25] & 63) << 8);
|
|
|
|
|
vm->initializeScratchpad(spIndex);
|
|
|
|
|
vm->initializeProgram(hash);
|
|
|
|
|
//dump((char*)((RandomX::CompiledVirtualMachine*)vm)->getProgram(), RandomX::CodeSize, "code-1337-jmp.txt");
|
|
|
|
|
vm->execute();
|
|
|
|
|
vm->getResult(hash);
|
|
|
|
|
result.xorWith(hash);
|
|
|
|
@ -150,6 +167,11 @@ int main(int argc, char** argv) {
|
|
|
|
|
readIntOption("--threads", argc, argv, threadCount, 1);
|
|
|
|
|
readIntOption("--nonces", argc, argv, programCount, 1000);
|
|
|
|
|
|
|
|
|
|
if (genAsm) {
|
|
|
|
|
generateAsm(programCount);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::atomic<int> atomicNonce(0);
|
|
|
|
|
AtomicHash result;
|
|
|
|
|
std::vector<RandomX::VirtualMachine*> vms;
|
|
|
|
|