From 436af8d0608a7a9eb44a466d1b6882ca8b2277e2 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 25 Aug 2022 21:58:06 -0700 Subject: [PATCH 1/2] Enforce notary chain requirement only when in sync --- src/pbaas/notarization.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pbaas/notarization.cpp b/src/pbaas/notarization.cpp index 7d57d57a7ea..31bea519471 100644 --- a/src/pbaas/notarization.cpp +++ b/src/pbaas/notarization.cpp @@ -4937,6 +4937,10 @@ bool PreCheckFinalizeNotarization(const CTransaction &tx, int32_t outNum, CValid if (p.evalCode == EVAL_EARNEDNOTARIZATION && !ConnectedChains.notarySystems.count(notarization.currencyID)) { + if (!haveFullChain) + { + return true; + } return state.Error("Earned notarizations are only valid for notary systems"); } From d823b3fca8d5f7b91dff29bd66dcbcba0f8ad57e Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 25 Aug 2022 22:19:45 -0700 Subject: [PATCH 2/2] Premature vETH bridge notarization reject fix --- src/init.cpp | 2 +- src/main.cpp | 10 +++++----- src/miner.cpp | 2 +- src/pbaas/pbaas.cpp | 6 +++--- src/pbaas/pbaas.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 0c1c87093ec..9310dfeab90 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1831,7 +1831,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) { // until we have connected to the ETH bridge, after PBaaS has launched, we check each block to see if there is now an // ETH bridge defined - ConnectedChains.ConfigureEthBridge(); + ConnectedChains.ConfigureEthBridge(true); } CChainNotarizationData cnd; diff --git a/src/main.cpp b/src/main.cpp index 482b43d1819..4e9b526d539 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3572,6 +3572,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin SetMaxScriptElementSize(nHeight); + if (CConstVerusSolutionVector::GetVersionByHeight(nHeight) >= CActivationHeight::ACTIVATE_PBAAS) + { + ConnectedChains.ConfigureEthBridge(); + } + bool fExpensiveChecks = true; if (fCheckpointsEnabled) { CBlockIndex *pindexLastCheckpoint = Checkpoints::GetLastCheckpoint(chainparams.Checkpoints()); @@ -6683,11 +6688,6 @@ bool ProcessNewBlock(bool from_miner, int32_t height, CValidationState &state, c SetMaxScriptElementSize(nHeight + 1); - if (CConstVerusSolutionVector::GetVersionByHeight(nHeight) >= CActivationHeight::ACTIVATE_PBAAS) - { - ConnectedChains.ConfigureEthBridge(); - } - return true; } diff --git a/src/miner.cpp b/src/miner.cpp index 50477d5c2e8..6e29d167d45 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1813,7 +1813,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const std::vecto } else { - notaryConnected = ConnectedChains.ConfigureEthBridge(); + notaryConnected = ConnectedChains.ConfigureEthBridge(true); } } diff --git a/src/pbaas/pbaas.cpp b/src/pbaas/pbaas.cpp index 3c5516ac95c..410f2bd3dde 100644 --- a/src/pbaas/pbaas.cpp +++ b/src/pbaas/pbaas.cpp @@ -3381,7 +3381,7 @@ bool CConnectedChains::IsNotaryAvailable(bool callToCheck) CheckVerusPBaaSAvailable(); } -bool CConnectedChains::ConfigureEthBridge() +bool CConnectedChains::ConfigureEthBridge(bool callToCheck) { // first time through, we initialize the VETH gateway config file if (!_IsVerusActive()) @@ -3395,7 +3395,7 @@ bool CConnectedChains::ConfigureEthBridge() LOCK(cs_main); if (FirstNotaryChain().IsValid()) { - return IsNotaryAvailable(true); + return IsNotaryAvailable(callToCheck); } CRPCChainData vethNotaryChain; @@ -3437,7 +3437,7 @@ bool CConnectedChains::ConfigureEthBridge() cnd.vtx.size() ? cnd.vtx[cnd.forks[cnd.bestChain].back()].second : CPBaaSNotarization(), CNotarySystemInfo::TYPE_ETH, CNotarySystemInfo::VERSION_CURRENT))); - return IsNotaryAvailable(true); + return IsNotaryAvailable(callToCheck); } } return false; diff --git a/src/pbaas/pbaas.h b/src/pbaas/pbaas.h index 511242d615f..1bb2a92f6c1 100644 --- a/src/pbaas/pbaas.h +++ b/src/pbaas/pbaas.h @@ -988,7 +988,7 @@ class CConnectedChains bool CheckVerusPBaaSAvailable(); // may use RPC to call Verus bool IsVerusPBaaSAvailable(); bool IsNotaryAvailable(bool callToCheck=false); - bool ConfigureEthBridge(); + bool ConfigureEthBridge(bool callToCheck=false); std::vector GetMergeMinedChains() {