Skip to content

Commit

Permalink
Add block hash to logdbhashes (#3117)
Browse files Browse the repository at this point in the history
* Add block hash to logdbhashes

* Only hash evm blocks

* Add evm block hash directly

* Add comments

* Make consolidatrewards note accurate

* More accurate notes

* Make keys consistent and clearer

---------

Co-authored-by: jouzo <[email protected]>
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent 8abe263 commit abc6a4f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/dfi/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3701,16 +3701,33 @@ UniValue logdbhashes(const JSONRPCRequest &request) {

// Get the current block height
const auto height = ::ChainActive().Height();
const auto blockHash = ::ChainActive().Tip()->GetBlockHash().ToString();


// Prepare result
UniValue result(UniValue::VOBJ);
result.pushKV("height", height);
result.pushKV("blockhash", blockHash);
// Note that this only guaranteed to be equal with other nodes
// if they didn't hit undo changes at different points.
// Other known instance that can cause this to differ:
// - consolidaterewards at different points if pre-static addresses are involved.
result.pushKV("dvmhash", hashHex);
result.pushKV("dvmhash_no_undo", hashHexNoUndo);
result.pushKV("dvmwithoutundohash", hashHexNoUndo);

auto res = XResultValueLogged(evm_try_get_latest_block_hash(result));
if (res) {
// Only available after EVM activation
// EVM block hash already is inclusive of all it's
// state, so we don't need to do the DVM shenangins.
auto evmBlockHash = uint256::FromByteArray(*res).GetHex();
result.pushKV("evmhash", evmBlockHash);
}

const auto evmHashHex = XResultValueLogged(evm_try_get_hash_db_state(result));
if (evmHashHex) {
result.pushKV("evmhash", std::string(*evmHashHex));
const auto evmDbNodeHashHex = XResultValueLogged(evm_try_get_hash_db_state(result));
if (evmDbNodeHashHex) {
// Note: This can vary from node to node unlike the rest.
result.pushKV("varhash_evmalldb", std::string(*evmDbNodeHashHex));
}

if (gArgs.GetBoolArg("-oceanarchive", DEFAULT_OCEAN_INDEXER_ENABLED) ||
Expand Down

0 comments on commit abc6a4f

Please sign in to comment.