From d159556c6657ec78d619febbc975a405f3ab24ec Mon Sep 17 00:00:00 2001 From: jouzo <15011228+Jouzo@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:39:59 +0000 Subject: [PATCH] Add evm block hash directly --- lib/ain-evm/src/storage/block_store.rs | 2 +- src/dfi/rpc_accounts.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/ain-evm/src/storage/block_store.rs b/lib/ain-evm/src/storage/block_store.rs index 5497a9089d..b6cf09679e 100644 --- a/lib/ain-evm/src/storage/block_store.rs +++ b/lib/ain-evm/src/storage/block_store.rs @@ -56,7 +56,7 @@ impl BlockStore { } pub fn hash_db_state(&self) -> Result { - Ok(self.0.hash_db_state(&[columns::Blocks::NAME])?) + Ok(self.0.hash_db_state(&COLUMN_NAMES)?) } } diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index c7af2b55c6..04fbf55632 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -3703,6 +3703,7 @@ 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); @@ -3710,9 +3711,16 @@ UniValue logdbhashes(const JSONRPCRequest &request) { 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) ||