Use the current block template as randomxInput
This commit is contained in:
@@ -1157,8 +1157,10 @@ void static RandomXMiner()
|
||||
LogPrintf("Running HushRandomXMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
|
||||
// Search
|
||||
uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime();
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag;
|
||||
uint32_t savebits;
|
||||
int64_t nStart = GetTime();
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
savebits = pblock->nBits;
|
||||
HASHTarget = arith_uint256().SetCompact(savebits);
|
||||
roundrobin_delay = ROUNDROBIN_DELAY;
|
||||
@@ -1184,10 +1186,16 @@ void static RandomXMiner()
|
||||
// since magic is 4 bytes, rpc port is 4 bytes and smart chain symbol must be at least 1 character long
|
||||
snprintf(randomxKey, 81, "%08x%s%08x", ASSETCHAINS_MAGIC, SMART_CHAIN_SYMBOL, ASSETCHAINS_RPCPORT);
|
||||
|
||||
char randomxInput[80];
|
||||
sprintf(randomxInput, "%08x Extreme Privacy Hush Smart Chain %08x", ASSETCHAINS_MAGIC, ASSETCHAINS_MAGIC);
|
||||
//char randomxInput[80];
|
||||
//std::string randomxInput;
|
||||
//sprintf(randomxInput, "%08x Extreme Privacy Hush Smart Chain %08x", ASSETCHAINS_MAGIC, ASSETCHAINS_MAGIC);
|
||||
|
||||
fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput=%s\n", randomxKey, randomxInput);
|
||||
CDataStream randomxInput(SER_NETWORK, PROTOCOL_VERSION);
|
||||
// Use the current block as randomx input
|
||||
randomxInput << pblocktemplate->block;
|
||||
|
||||
std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n";
|
||||
fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput.size=%lu\n", randomxKey, randomxInput.size() ); //randomxInput);
|
||||
|
||||
randomx_flags flags = randomx_get_flags();
|
||||
randomx_cache *randomxCache = randomx_alloc_cache(flags);
|
||||
@@ -1206,7 +1214,7 @@ void static RandomXMiner()
|
||||
|
||||
fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
|
||||
fprintf(stderr,"RandomXMiner: Mining_height=%u\n", Mining_height);
|
||||
// Use the initial key at the start of the chain
|
||||
// Use the initial key at the start of the chain, until the first key block
|
||||
if( (Mining_height) < randomxInterval + randomxBlockLag) {
|
||||
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
||||
fprintf(stderr,"RandomXMiner: initialized cache with initial key\n");
|
||||
@@ -1229,22 +1237,22 @@ void static RandomXMiner()
|
||||
fprintf(stderr,"RandomXMiner: Cannot create RandomX VM, aborting!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,"RandomXMiner: created VM\n");
|
||||
// fprintf(stderr,"RandomXMiner: created VM\n");
|
||||
|
||||
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
|
||||
fprintf(stderr,"RandomXMiner: calculated randomx hash\n");
|
||||
|
||||
randomx_destroy_vm(myVM);
|
||||
fprintf(stderr,"RandomXMiner: destroyed VM\n");
|
||||
// fprintf(stderr,"RandomXMiner: destroyed VM\n");
|
||||
randomx_release_cache(randomxCache);
|
||||
|
||||
printf("RandomX Hash: ");
|
||||
printf("RandomXMiner: randomxHash=");
|
||||
for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) {
|
||||
printf("%02x", randomxHash[i] & 0xff);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
// TODO: use randomx hash to build a block
|
||||
// Use randomx hash to build a valid block
|
||||
|
||||
std::function<bool(std::vector<unsigned char>)> validBlock =
|
||||
#ifdef ENABLE_WALLET
|
||||
|
||||
Reference in New Issue
Block a user