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));
|
LogPrintf("Running HushRandomXMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||||
|
|
||||||
// Search
|
// 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();
|
uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag;
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
uint32_t savebits;
|
||||||
|
int64_t nStart = GetTime();
|
||||||
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
savebits = pblock->nBits;
|
savebits = pblock->nBits;
|
||||||
HASHTarget = arith_uint256().SetCompact(savebits);
|
HASHTarget = arith_uint256().SetCompact(savebits);
|
||||||
roundrobin_delay = ROUNDROBIN_DELAY;
|
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
|
// 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);
|
snprintf(randomxKey, 81, "%08x%s%08x", ASSETCHAINS_MAGIC, SMART_CHAIN_SYMBOL, ASSETCHAINS_RPCPORT);
|
||||||
|
|
||||||
char randomxInput[80];
|
//char randomxInput[80];
|
||||||
sprintf(randomxInput, "%08x Extreme Privacy Hush Smart Chain %08x", ASSETCHAINS_MAGIC, ASSETCHAINS_MAGIC);
|
//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_flags flags = randomx_get_flags();
|
||||||
randomx_cache *randomxCache = randomx_alloc_cache(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: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
|
||||||
fprintf(stderr,"RandomXMiner: Mining_height=%u\n", Mining_height);
|
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) {
|
if( (Mining_height) < randomxInterval + randomxBlockLag) {
|
||||||
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
||||||
fprintf(stderr,"RandomXMiner: initialized cache with initial key\n");
|
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");
|
fprintf(stderr,"RandomXMiner: Cannot create RandomX VM, aborting!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"RandomXMiner: created VM\n");
|
// fprintf(stderr,"RandomXMiner: created VM\n");
|
||||||
|
|
||||||
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
|
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
|
||||||
fprintf(stderr,"RandomXMiner: calculated randomx hash\n");
|
fprintf(stderr,"RandomXMiner: calculated randomx hash\n");
|
||||||
|
|
||||||
randomx_destroy_vm(myVM);
|
randomx_destroy_vm(myVM);
|
||||||
fprintf(stderr,"RandomXMiner: destroyed VM\n");
|
// fprintf(stderr,"RandomXMiner: destroyed VM\n");
|
||||||
randomx_release_cache(randomxCache);
|
randomx_release_cache(randomxCache);
|
||||||
|
|
||||||
printf("RandomX Hash: ");
|
printf("RandomXMiner: randomxHash=");
|
||||||
for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) {
|
for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) {
|
||||||
printf("%02x", randomxHash[i] & 0xff);
|
printf("%02x", randomxHash[i] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
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 =
|
std::function<bool(std::vector<unsigned char>)> validBlock =
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
./src/hushd -ac_randomx_interval=10 -ac_randomx_lag=3 -ac_halving=20 -ac_algo=randomx -ac_name=RANDOMX9 -ac_private=1 -ac_blocktime=20 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1
|
./src/hushd -ac_randomx_interval=10 -ac_randomx_lag=3 -ac_halving=20 -ac_algo=randomx -ac_name=RANDOMX10 -ac_private=1 -ac_blocktime=20 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1
|
||||||
|
|
||||||
# to run via the debugger
|
# to run via the debugger
|
||||||
# type "run" when gdb prompt appears
|
# type "run" when gdb prompt appears
|
||||||
|
|||||||
Reference in New Issue
Block a user