try to initialize rx_vm if null
This commit is contained in:
parent
e22bab9bae
commit
da8368a88d
95
src/page.h
95
src/page.h
|
@ -1238,58 +1238,6 @@ show_block(uint64_t _blk_height)
|
||||||
= core_storage->get_db().get_block_difficulty(_blk_height);
|
= core_storage->get_db().get_block_difficulty(_blk_height);
|
||||||
|
|
||||||
|
|
||||||
uint64_t seed_height;
|
|
||||||
|
|
||||||
rx_needhash(_blk_height, &seed_height);
|
|
||||||
cout << "seed_height: " << seed_height << '\n';
|
|
||||||
|
|
||||||
rx_seedhash(seed_height, blk_hash.data, 0);
|
|
||||||
|
|
||||||
blobdata bd = get_block_hashing_blob(blk);
|
|
||||||
|
|
||||||
crypto::hash res;
|
|
||||||
|
|
||||||
//cout << pod_to_hex(blk_hash) << endl;
|
|
||||||
|
|
||||||
rx_slow_hash(bd.data(), bd.size(), res.data, 0);
|
|
||||||
|
|
||||||
cout << "pow: " << pod_to_hex(res) << endl;
|
|
||||||
|
|
||||||
cout << bool {rx_vm} << endl;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// based on randomx calculate hash
|
|
||||||
// the hash is seed used to generated scrachtpad and program
|
|
||||||
alignas(16) uint64_t tempHash[8];
|
|
||||||
blake2b(tempHash, sizeof(tempHash), bd.data(), bd.size(), nullptr, 0);
|
|
||||||
|
|
||||||
rx_vm->initScratchpad(&tempHash);
|
|
||||||
rx_vm->resetRoundingMode();
|
|
||||||
|
|
||||||
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain) {
|
|
||||||
rx_vm->run(&tempHash);
|
|
||||||
blake2b(tempHash, sizeof(tempHash),
|
|
||||||
rx_vm->getRegisterFile(),
|
|
||||||
sizeof(randomx::RegisterFile), nullptr, 0);
|
|
||||||
}
|
|
||||||
rx_vm->run(&tempHash);
|
|
||||||
|
|
||||||
crypto::hash res2;
|
|
||||||
rx_vm->getFinalResult(res2.data, RANDOMX_HASH_SIZE);
|
|
||||||
|
|
||||||
cout << "pow2: " << pod_to_hex(res2) << endl;
|
|
||||||
|
|
||||||
std::cout << "\nddddd\n\n";
|
|
||||||
std::cout << rx_vm->getProgram();
|
|
||||||
|
|
||||||
randomx::Program* prg
|
|
||||||
= reinterpret_cast<randomx::Program*>(
|
|
||||||
reinterpret_cast<char*>(rx_vm) + 64);
|
|
||||||
|
|
||||||
std::cout << "\nddddd\n\n";
|
|
||||||
cout << *prg << endl;
|
|
||||||
|
|
||||||
mstch::map context {
|
mstch::map context {
|
||||||
{"testnet" , testnet},
|
{"testnet" , testnet},
|
||||||
{"stagenet" , stagenet},
|
{"stagenet" , stagenet},
|
||||||
|
@ -7188,33 +7136,23 @@ get_randomx_code(uint64_t blk_height,
|
||||||
{
|
{
|
||||||
vector<std::pair<string, string>> rx_code;
|
vector<std::pair<string, string>> rx_code;
|
||||||
|
|
||||||
uint64_t seed_height;
|
|
||||||
|
|
||||||
rx_needhash(blk_height, &seed_height);
|
|
||||||
|
|
||||||
//cout << "seed_height: " << seed_height << '\n';
|
|
||||||
|
|
||||||
rx_seedhash(seed_height, blk_hash.data, 0);
|
|
||||||
|
|
||||||
blobdata bd = get_block_hashing_blob(blk);
|
blobdata bd = get_block_hashing_blob(blk);
|
||||||
|
|
||||||
crypto::hash res;
|
|
||||||
|
|
||||||
//cout << pod_to_hex(blk_hash) << endl;
|
|
||||||
|
|
||||||
//rx_slow_hash(bd.data(), bd.size(), res.data, 0);
|
|
||||||
|
|
||||||
//cout << "pow: " << pod_to_hex(res) << endl;
|
|
||||||
|
|
||||||
//cout << bool {rx_vm} << endl;
|
|
||||||
//
|
|
||||||
if (!rx_vm)
|
if (!rx_vm)
|
||||||
{
|
{
|
||||||
cerr << "rx_vm is null\n";
|
// this will create rx_vm instance if one
|
||||||
return rx_code;
|
// does not exist
|
||||||
|
get_block_longhash(core_storage, blk, blk_height, 0);
|
||||||
|
|
||||||
|
if (!rx_vm)
|
||||||
|
{
|
||||||
|
cerr << "rx_vm is still null!";
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// based on randomx calculate hash
|
|
||||||
|
// based on randomx calculate hash
|
||||||
// the hash is seed used to generated scrachtpad and program
|
// the hash is seed used to generated scrachtpad and program
|
||||||
alignas(16) uint64_t tempHash[8];
|
alignas(16) uint64_t tempHash[8];
|
||||||
blake2b(tempHash, sizeof(tempHash), bd.data(), bd.size(), nullptr, 0);
|
blake2b(tempHash, sizeof(tempHash), bd.data(), bd.size(), nullptr, 0);
|
||||||
|
@ -7222,6 +7160,11 @@ get_randomx_code(uint64_t blk_height,
|
||||||
rx_vm->initScratchpad(&tempHash);
|
rx_vm->initScratchpad(&tempHash);
|
||||||
rx_vm->resetRoundingMode();
|
rx_vm->resetRoundingMode();
|
||||||
|
|
||||||
|
// randomx::Program* prg
|
||||||
|
// = reinterpret_cast<randomx::Program*>(
|
||||||
|
// reinterpret_cast<char*>(rx_vm) + 64);
|
||||||
|
|
||||||
|
|
||||||
randomx::Program prg;
|
randomx::Program prg;
|
||||||
|
|
||||||
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain)
|
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain)
|
||||||
|
@ -7257,10 +7200,10 @@ get_randomx_code(uint64_t blk_height,
|
||||||
|
|
||||||
rx_code.emplace_back(ss.str(), ss2.str());
|
rx_code.emplace_back(ss.str(), ss2.str());
|
||||||
|
|
||||||
crypto::hash res2;
|
// crypto::hash res2;
|
||||||
rx_vm->getFinalResult(res2.data, RANDOMX_HASH_SIZE);
|
// rx_vm->getFinalResult(res2.data, RANDOMX_HASH_SIZE);
|
||||||
|
|
||||||
cout << "pow2: " << pod_to_hex(res2) << endl;
|
// cout << "pow2: " << pod_to_hex(res2) << endl;
|
||||||
|
|
||||||
return rx_code;
|
return rx_code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<H4>Block hash (height): {{blk_hash}} ({{blk_height}})</H4>
|
<H4>Block hash (height): {{blk_hash}} ({{blk_height}})</H4>
|
||||||
|
@ -27,8 +26,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{{/rx_codes}}
|
{{/rx_codes}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue