Skip to content

Commit

Permalink
Add evm block hash directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouzo committed Nov 11, 2024
1 parent 720c499 commit d159556
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ain-evm/src/storage/block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl BlockStore {
}

pub fn hash_db_state(&self) -> Result<String> {
Ok(self.0.hash_db_state(&[columns::Blocks::NAME])?)
Ok(self.0.hash_db_state(&COLUMN_NAMES)?)
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/dfi/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3703,16 +3703,24 @@ UniValue logdbhashes(const JSONRPCRequest &request) {
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);
result.pushKV("dvmhash", hashHex);
result.pushKV("dvmhash_no_undo", hashHexNoUndo);

const auto evmHashHex = XResultValueLogged(evm_try_get_hash_db_state(result));
if (evmHashHex) {
result.pushKV("evm_db_node_hash", std::string(*evmHashHex));
auto res = XResultValueLogged(evm_try_get_latest_block_hash(result));
if (res) {
// Only available after EVM activation
auto evmBlockHash = uint256::FromByteArray(*res).GetHex();
result.pushKV("evmhash", evmBlockHash);
}

const auto evmDbNodeHashHex = XResultValueLogged(evm_try_get_hash_db_state(result));
if (evmDbNodeHashHex) {
result.pushKV("evm_db_node_hash", std::string(*evmDbNodeHashHex));
}

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

0 comments on commit d159556

Please sign in to comment.