mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
asm x86 added
This commit is contained in:
parent
b7ad51e228
commit
e22bab9bae
2 changed files with 56 additions and 17 deletions
40
src/page.h
40
src/page.h
|
@ -16,6 +16,7 @@
|
||||||
#include "virtual_machine.hpp"
|
#include "virtual_machine.hpp"
|
||||||
#include "program.hpp"
|
#include "program.hpp"
|
||||||
#include "aes_hash.hpp"
|
#include "aes_hash.hpp"
|
||||||
|
#include "assembly_generator_x86.hpp"
|
||||||
|
|
||||||
#include "../gen/version.h"
|
#include "../gen/version.h"
|
||||||
|
|
||||||
|
@ -1440,7 +1441,7 @@ show_randomx(uint64_t _blk_height)
|
||||||
string blk_hash_str = pod_to_hex(blk_hash);
|
string blk_hash_str = pod_to_hex(blk_hash);
|
||||||
|
|
||||||
|
|
||||||
vector<string> rx_code = get_randomx_code(_blk_height,
|
auto rx_code = get_randomx_code(_blk_height,
|
||||||
blk, blk_hash);
|
blk, blk_hash);
|
||||||
|
|
||||||
mstch::array rx_code_str = mstch::array{};
|
mstch::array rx_code_str = mstch::array{};
|
||||||
|
@ -1451,7 +1452,8 @@ show_randomx(uint64_t _blk_height)
|
||||||
rx_code_str.push_back(
|
rx_code_str.push_back(
|
||||||
mstch::map {
|
mstch::map {
|
||||||
{"rx_code_idx", code_idx++},
|
{"rx_code_idx", code_idx++},
|
||||||
{"rx_code", std::move(rxc)}
|
{"rx_code", std::move(rxc.first)},
|
||||||
|
{"rx_code_asm", std::move(rxc.second)}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7179,12 +7181,12 @@ get_tx(string const& tx_hash_str,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string>
|
vector<std::pair<string, string>>
|
||||||
get_randomx_code(uint64_t blk_height,
|
get_randomx_code(uint64_t blk_height,
|
||||||
block const& blk,
|
block const& blk,
|
||||||
crypto::hash const& blk_hash)
|
crypto::hash const& blk_hash)
|
||||||
{
|
{
|
||||||
vector<string> rx_code;
|
vector<std::pair<string, string>> rx_code;
|
||||||
|
|
||||||
uint64_t seed_height;
|
uint64_t seed_height;
|
||||||
|
|
||||||
|
@ -7220,6 +7222,8 @@ get_randomx_code(uint64_t blk_height,
|
||||||
rx_vm->initScratchpad(&tempHash);
|
rx_vm->initScratchpad(&tempHash);
|
||||||
rx_vm->resetRoundingMode();
|
rx_vm->resetRoundingMode();
|
||||||
|
|
||||||
|
randomx::Program prg;
|
||||||
|
|
||||||
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain)
|
for (int chain = 0; chain < RANDOMX_PROGRAM_COUNT - 1; ++chain)
|
||||||
{
|
{
|
||||||
rx_vm->run(&tempHash);
|
rx_vm->run(&tempHash);
|
||||||
|
@ -7227,15 +7231,31 @@ get_randomx_code(uint64_t blk_height,
|
||||||
rx_vm->getRegisterFile(),
|
rx_vm->getRegisterFile(),
|
||||||
sizeof(randomx::RegisterFile), nullptr, 0);
|
sizeof(randomx::RegisterFile), nullptr, 0);
|
||||||
|
|
||||||
stringstream ss;
|
prg = *(rx_vm->getProgram());
|
||||||
ss << rx_vm->getProgram();
|
|
||||||
rx_code.push_back(ss.str());
|
stringstream ss, ss2;
|
||||||
|
ss << prg;
|
||||||
|
|
||||||
|
|
||||||
|
randomx::AssemblyGeneratorX86 asmX86;
|
||||||
|
asmX86.generateProgram(prg);
|
||||||
|
asmX86.printCode(ss2);
|
||||||
|
|
||||||
|
rx_code.emplace_back(ss.str(), ss2.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
rx_vm->run(&tempHash);
|
rx_vm->run(&tempHash);
|
||||||
stringstream ss;
|
|
||||||
ss << rx_vm->getProgram();
|
prg = *(rx_vm->getProgram());
|
||||||
rx_code.push_back(ss.str());
|
|
||||||
|
stringstream ss, ss2;
|
||||||
|
ss << prg;
|
||||||
|
|
||||||
|
randomx::AssemblyGeneratorX86 asmX86;
|
||||||
|
asmX86.generateProgram(prg);
|
||||||
|
asmX86.printCode(ss2);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
|
@ -2,14 +2,33 @@
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<H4>Block hash (height): {{blk_hash}} ({{blk_height}})</H4>
|
<H4>Block hash (height): {{blk_hash}} ({{blk_height}})</H4>
|
||||||
<h3>Recalculated {{pow}}</h3>
|
<h4>
|
||||||
|
Eight RandomX and correspoding assembly x86 programs used
|
||||||
|
to calcualte PoW hash of the block
|
||||||
|
</h4>
|
||||||
|
|
||||||
<h3>RandomX source code</h3>
|
{{#rx_codes}}
|
||||||
<div class="center" style="width:90%">
|
<h3> Program #{{rx_code_idx}}</h3>
|
||||||
{{#rx_codes}}
|
<table class="center" style="width: 50%; margin-top:10px">
|
||||||
<h4>Source code #{{rx_code_idx}}</h4>
|
<tr>
|
||||||
|
<td style="text-align: left;">RandomX code</td>
|
||||||
|
<td style="text-align: left;">ASM x86</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: left;vertical-align: top;">
|
||||||
<pre>{{rx_code}}</pre>
|
<pre>{{rx_code}}</pre>
|
||||||
{{/rx_codes}}
|
</td>
|
||||||
</div>
|
<td style="text-align: left;vertical-align: top;">
|
||||||
|
<pre>{{rx_code_asm}}</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{{/rx_codes}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue