From 6541b7645c55e6d4980d9ce4e015e643c2faf21e Mon Sep 17 00:00:00 2001 From: jouzo Date: Tue, 14 Nov 2023 10:10:03 +0100 Subject: [PATCH 1/3] Invalidate EVM block if exists --- src/validation.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 627c05fb68..0de24ec142 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3809,7 +3809,11 @@ bool CChainState::DisconnectTip(CValidationState &state, mnview.GetHistoryWriters().DiscardDB(); return error("DisconnectTip(): DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString()); } - XResultThrowOnErr(evm_try_disconnect_latest_block(result)); + + if (auto res = pcustomcsview->GetVMDomainBlockEdge(VMDomainEdge::DVMToEVM, pindexDelete->GetBlockHash().ToString())) { + XResultThrowOnErr(evm_try_disconnect_latest_block(result)); + } + bool flushed = view.Flush() && mnview.Flush(); assert(flushed); mnview.GetHistoryWriters().FlushDB(); From c1a420e6f6c6d4cac9a8b6969a288c6e3146c582 Mon Sep 17 00:00:00 2001 From: jouzo Date: Tue, 14 Nov 2023 10:23:34 +0100 Subject: [PATCH 2/3] Fix lint --- src/validation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 0de24ec142..2223146dc3 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3810,7 +3810,8 @@ bool CChainState::DisconnectTip(CValidationState &state, return error("DisconnectTip(): DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString()); } - if (auto res = pcustomcsview->GetVMDomainBlockEdge(VMDomainEdge::DVMToEVM, pindexDelete->GetBlockHash().ToString())) { + if (auto res = + pcustomcsview->GetVMDomainBlockEdge(VMDomainEdge::DVMToEVM, pindexDelete->GetBlockHash().ToString())) { XResultThrowOnErr(evm_try_disconnect_latest_block(result)); } From 9d11fa28b8b0ff39d50f1b0d2e1b97dbfe353cbf Mon Sep 17 00:00:00 2001 From: jouzo Date: Wed, 15 Nov 2023 10:31:16 +0100 Subject: [PATCH 3/3] Use XVM::TryFrom --- src/validation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 2223146dc3..ae897f6896 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3810,8 +3810,7 @@ bool CChainState::DisconnectTip(CValidationState &state, return error("DisconnectTip(): DisconnectBlock %s failed", pindexDelete->GetBlockHash().ToString()); } - if (auto res = - pcustomcsview->GetVMDomainBlockEdge(VMDomainEdge::DVMToEVM, pindexDelete->GetBlockHash().ToString())) { + if (XVM::TryFrom(block.vtx[0]->vout[1].scriptPubKey)) { XResultThrowOnErr(evm_try_disconnect_latest_block(result)); }