Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Post v19 cleanup #5622

Merged
merged 4 commits into from
Oct 19, 2023
Merged

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Oct 19, 2023

Issue being fixed or feature implemented

Now that v19 is buried we can enforce basic bls scheme usage in governance and coinjoin and drop some extra code we used for backwards compatibility.

What was done?

pls see individual commits

How Has This Been Tested?

run tests, sync and mix on testnet

Breaking Changes

n/a

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@UdjinM6 UdjinM6 added this to the 20 milestone Oct 19, 2023
@PastaPastaPasta
Copy link
Member

What about something like below as well? Running both governance tests is happy, but I'm mildly concerned there's a potential deadlock somewhere

Subject: [PATCH] refactor: minimize cs_main locking for governance
---
Index: src/governance/object.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/governance/object.cpp b/src/governance/object.cpp
--- a/src/governance/object.cpp	(revision f557f0bc3ca1a5f5e72fda44ee94098ff137dd57)
+++ b/src/governance/object.cpp	(date 1697725020762)
@@ -449,7 +449,6 @@
 
 void CGovernanceObject::UpdateLocalValidity()
 {
-    AssertLockHeld(cs_main);
     // THIS DOES NOT CHECK COLLATERAL, THIS IS CHECKED UPON ORIGINAL ARRIVAL
     fCachedLocalValidity = IsValidLocally(strLocalValidityError, false);
 }
@@ -464,8 +463,6 @@
 
 bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const
 {
-    AssertLockHeld(cs_main);
-
     fMissingConfirmations = false;
 
     if (fUnparsable) {
@@ -537,14 +534,13 @@
 
 bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
 {
-    AssertLockHeld(cs_main);
-
     strError = "";
     fMissingConfirmations = false;
     uint256 nExpectedHash = GetHash();
 
     // RETRIEVE TRANSACTION IN QUESTION
     uint256 nBlockHash;
+    // Locks cs_main internally
     CTransactionRef txCollateral = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, nCollateralHash, Params().GetConsensus(), nBlockHash);
     if (!txCollateral) {
         strError = strprintf("Can't find collateral tx %s", nCollateralHash.ToString());
@@ -596,9 +592,9 @@
 
     // GET CONFIRMATIONS FOR TRANSACTION
 
-    AssertLockHeld(cs_main);
     int nConfirmationsIn = 0;
     if (nBlockHash != uint256()) {
+        LOCK(cs_main);
         const CBlockIndex* pindex = g_chainman.m_blockman.LookupBlockIndex(nBlockHash);
         if (pindex && ::ChainActive().Contains(pindex)) {
             nConfirmationsIn += ::ChainActive().Height() - pindex->nHeight + 1;
Index: src/governance/object.h
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/governance/object.h b/src/governance/object.h
--- a/src/governance/object.h	(revision f557f0bc3ca1a5f5e72fda44ee94098ff137dd57)
+++ b/src/governance/object.h	(date 1697725020758)
@@ -247,12 +247,12 @@
 
     // CORE OBJECT FUNCTIONS
 
-    bool IsValidLocally(std::string& strError, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+    bool IsValidLocally(std::string& strError, bool fCheckCollateral) const;
 
-    bool IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+    bool IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const;
 
     /// Check the collateral transaction for the budget proposal/finalized budget
-    bool IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+    bool IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const;
 
     void UpdateLocalValidity();
 

@UdjinM6
Copy link
Author

UdjinM6 commented Oct 19, 2023

@PastaPastaPasta but this patch doesn't drop any lock, it only drops thread safety checks...

@PastaPastaPasta
Copy link
Member

@PastaPastaPasta but this patch doesn't drop any lock, it only drops thread safety checks...

oh.. lol 🙈 give me a sec

Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, synced Testnet

@PastaPastaPasta
Copy link
Member

Take a look at: 5776b23

This passes tests at least; thoughts?

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK for squash merge; my patch is kinda unrelated

@PastaPastaPasta PastaPastaPasta merged commit 44055fb into dashpay:develop Oct 19, 2023
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants