From 953b6781e5c6e5bc1b8de2a5b9d6af6fe1a84452 Mon Sep 17 00:00:00 2001 From: Monkins1010 Date: Fri, 30 Jan 2026 19:01:01 +0000 Subject: [PATCH] Add window for submitacceptednoatirzation starting from first submission. --- src/pbaas/notarization.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pbaas/notarization.cpp b/src/pbaas/notarization.cpp index 2bdd7818c72..1a5db6d7dd4 100755 --- a/src/pbaas/notarization.cpp +++ b/src/pbaas/notarization.cpp @@ -9843,16 +9843,28 @@ std::vector CPBaaSNotarization::SubmitFinalizedNotarizations(const CRPC // to prevent funds loss, sort notaries and make sure we are in the top 2 before we try to submit if (amWitness) { + // Each notary gets a window of 4 blocks to submit their notarization. + // This prevents multiple notaries from submitting due to propagation delays on Ethereum. + // The window starts from when the notarization was confirmed on this chain, ensuring + // the first notary has a full window from the moment submission becomes possible. + static const uint32_t NOTARY_SUBMISSION_WINDOW_BLOCKS = 4; + uint32_t confirmedHeight = pfirstProofIdxIt->second->GetHeight(); + uint32_t windowNumber = (nHeight >= confirmedHeight) ? + (nHeight - confirmedHeight) / NOTARY_SUBMISSION_WINDOW_BLOCKS : 0; + CNativeHashWriter hw; - hw << nHeight; + hw << confirmedHeight; + hw << windowNumber; uint256 prHash = hw.GetHash(); std::vector notaryVec = externalSystem.chainDefinition.notaries; auto prandom = std::minstd_rand0(UintToArith256(prHash).GetLow64()); shuffle(notaryVec.begin(), notaryVec.end(), prandom); if (notaryVec[0] != VERUS_NOTARYID) { - LogPrintf("skipping notarization submission - was not selected for submission lottery (%s selected)\n", EncodeDestination(CIdentityID(notaryVec[0])).c_str()); - printf("skipping notarization submission - was not selected for submission lottery (%s selected)\n", EncodeDestination(CIdentityID(notaryVec[0])).c_str()); + LogPrintf("skipping notarization submission - was not selected for submission lottery (%s selected, window %u from confirmed height %u)\n", + EncodeDestination(CIdentityID(notaryVec[0])).c_str(), windowNumber, confirmedHeight); + printf("skipping notarization submission - was not selected for submission lottery (%s selected, window %u from confirmed height %u)\n", + EncodeDestination(CIdentityID(notaryVec[0])).c_str(), windowNumber, confirmedHeight); return retVal; } }