Skip to content

Conversation

jamesob
Copy link
Contributor

@jamesob jamesob commented May 3, 2019

This is part of the assumeutxo project:

Parent PR: #15606
Issue: #15605
Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal


This change refactors the chainActive reference into a ::ChainActive() call. It also distinguishes CChainState's CChain data member as m_chain instead of the current chainActive, which makes it easily confused with the global data.

The active chain must be obtained via function because its reference will be swapped at some point during runtime after loading a UTXO snapshot.

This change, though lengthy, should be pretty easy to review since most of it is contained within a scripted-diff. Once merged, the parent PR should be easier to review.

jamesob added 2 commits May 3, 2019 14:38
This can't be a scripted-diff due to the confusion of the global
chainActive and the CChainState member of the same name.

This specific rename makes the following chainActive -> ::ChainActive() diff
scriptable.
in preparation for the following scripted-diff commit.
@maflcko
Copy link
Member

maflcko commented May 3, 2019

You might have to put the files after sed?

sed ...foobar.. $(git grep -l "chainActive" | grep -E '(h|cpp)$')

jamesob added 2 commits May 3, 2019 15:02
Though at the moment ChainActive() simply references `g_chainstate.m_chain`,
doing this change now clears the way for multiple chainstate usage and allows
us to script the diff.

-BEGIN VERIFY SCRIPT-
git grep -l "chainActive" | grep -E '(h|cpp)$' | xargs sed -i '/chainActive =/b; /extern CChain& chainActive/b; s/\(::\)\{0,1\}chainActive/::ChainActive()/g'
-END VERIFY SCRIPT-
@jamesob jamesob force-pushed the 2019-05-au-chainactive branch from 8e39159 to 486c1ee Compare May 3, 2019 19:03
@jamesob
Copy link
Contributor Author

jamesob commented May 3, 2019

Oops, missed an xargs. Thanks @MarcoFalke.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 3, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15946 (Allow maintaining the blockfilterindex when using prune by jonasschnelli)
  • #15933 (Make chain state immutable outside of validation by MarcoFalke)
  • #15931 (Remove GetDepthInMainChain dependency on locked chain interface by ariard)
  • #15855 ([refactor] interfaces: Add missing LockAnnotation for cs_main by MarcoFalke)
  • #14193 (validation: Add missing mempool locks by MarcoFalke)
  • #13713 (Ignore new blocks when -stopatheight target has been reached by jonasschnelli)
  • #13582 (Extract AppInitLoadBlockIndex from AppInitMain by Empact)
  • #13045 ([p2p] getblock for 1-block reorgs in response to compact block message by instagibbs)
  • #9381 (Remove CWalletTx merging logic from AddToWallet by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@Sjors
Copy link
Member

Sjors commented May 4, 2019

utACK 486c1ee

@practicalswift
Copy link
Contributor

@jamesob Should ::ChainActive() be annotated EXCLUSIVE_LOCKS_REQUIRED(cs_main)?

@maflcko
Copy link
Member

maflcko commented May 6, 2019

@practicalswift No, I don't think that compiles right now

@promag
Copy link
Contributor

promag commented May 6, 2019

utACK 486c1ee.

@practicalswift
Copy link
Contributor

utACK 486c1ee

@maflcko
Copy link
Member

maflcko commented May 6, 2019

This will be merged tomorrow unless there are objections

@maflcko maflcko merged commit 486c1ee into bitcoin:master May 7, 2019
maflcko pushed a commit that referenced this pull request May 7, 2019
486c1ee refactoring: remove unused chainActive (James O'Beirne)
631940a scripted-diff: replace chainActive -> ::ChainActive() (James O'Beirne)
a3a6090 refactoring: introduce unused ChainActive() (James O'Beirne)
1b6e6fc rename: CChainState.chainActive -> m_chain (James O'Beirne)

Pull request description:

  This is part of the assumeutxo project:

  Parent PR: #15606
  Issue: #15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal

  ---

  This change refactors the `chainActive` reference into a `::ChainActive()` call. It also distinguishes `CChainState`'s `CChain` data member as `m_chain` instead of the current `chainActive`, which makes it easily confused with the global data.

  The active chain must be obtained via function because its reference will be swapped at some point during runtime after loading a UTXO snapshot.

  This change, though lengthy, should be pretty easy to review since most of it is contained within a scripted-diff. Once merged, the parent PR should be easier to review.

ACKs for commit 486c1e:
  Sjors:
    utACK 486c1ee
  promag:
    utACK 486c1ee.
  practicalswift:
    utACK 486c1ee

Tree-SHA512: 06ed8f9e77f2d25fc9bea0ba86436d80dbbce90a1e8be23e37ec4eeb26060483e60b4a5c4fba679cb1867f61e3921c24abeb9cabdfb4d0a9b1c4ddd77b17456a
@morcos
Copy link
Contributor

morcos commented May 7, 2019

@jamesob Can you clean up the comments/help text that got modified by the scripted diff?

@jamesob
Copy link
Contributor Author

jamesob commented May 7, 2019

@morcos are you saying change the "::ChainActive()" back to something else in comments? Personally I don't mind them that way (since the old comments referred to a particular symbol, i.e. "chainActive"). What were you thinking in terms of a replacement?

@morcos
Copy link
Contributor

morcos commented May 7, 2019

discussed offline, i guess the comments aren't bad, the help text bugs me slightly, but not sure i have a better solution...

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 7, 2019
486c1ee refactoring: remove unused chainActive (James O'Beirne)
631940a scripted-diff: replace chainActive -> ::ChainActive() (James O'Beirne)
a3a6090 refactoring: introduce unused ChainActive() (James O'Beirne)
1b6e6fc rename: CChainState.chainActive -> m_chain (James O'Beirne)

Pull request description:

  This is part of the assumeutxo project:

  Parent PR: bitcoin#15606
  Issue: bitcoin#15605
  Specification: https://github.com/jamesob/assumeutxo-docs/tree/2019-04-proposal/proposal

  ---

  This change refactors the `chainActive` reference into a `::ChainActive()` call. It also distinguishes `CChainState`'s `CChain` data member as `m_chain` instead of the current `chainActive`, which makes it easily confused with the global data.

  The active chain must be obtained via function because its reference will be swapped at some point during runtime after loading a UTXO snapshot.

  This change, though lengthy, should be pretty easy to review since most of it is contained within a scripted-diff. Once merged, the parent PR should be easier to review.

ACKs for commit 486c1e:
  Sjors:
    utACK 486c1ee
  promag:
    utACK 486c1ee.
  practicalswift:
    utACK 486c1ee

Tree-SHA512: 06ed8f9e77f2d25fc9bea0ba86436d80dbbce90a1e8be23e37ec4eeb26060483e60b4a5c4fba679cb1867f61e3921c24abeb9cabdfb4d0a9b1c4ddd77b17456a
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Mar 2, 2020
Summary:
Though at the moment ChainActive() simply references `g_chainstate.m_chain`,
doing this change now clears the way for multiple chainstate usage and allows
us to script the diff.

-BEGIN VERIFY SCRIPT-
`git grep -l "chainActive" | grep -E '(h|cpp)$' | xargs sed -i '/chainActive =/b; /extern CChain& chainActive/b; s/\(::\)\{0,1\}chainActive/::ChainActive()/g'`
-END VERIFY SCRIPT-

Depends on D5056

Partial backport of Core [[bitcoin/bitcoin#15948 | PR15948]]
bitcoin/bitcoin@631940a
bitcoin/bitcoin@486c1ee

Test Plan:
    ninja check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5373
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request May 19, 2020
Summary:
Though at the moment ChainActive() simply references `g_chainstate.m_chain`,
doing this change now clears the way for multiple chainstate usage and allows
us to script the diff.

-BEGIN VERIFY SCRIPT-
`git grep -l "chainActive" | grep -E '(h|cpp)$' | xargs sed -i '/chainActive =/b; /extern CChain& chainActive/b; s/\(::\)\{0,1\}chainActive/::ChainActive()/g'`
-END VERIFY SCRIPT-

Depends on D5056

Partial backport of Core [[bitcoin/bitcoin#15948 | PR15948]]
bitcoin/bitcoin@631940a
bitcoin/bitcoin@486c1ee

Test Plan:
    ninja check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5373
@jamesob jamesob mentioned this pull request Aug 5, 2021
18 tasks
kwvg added a commit to kwvg/dash that referenced this pull request Oct 9, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Oct 10, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Oct 16, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Oct 16, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Oct 16, 2021
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
kwvg added a commit to kwvg/dash that referenced this pull request Oct 21, 2021
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
kwvg added a commit to kwvg/dash that referenced this pull request Oct 22, 2021
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
PastaPastaPasta added a commit to dashpay/dash that referenced this pull request Oct 23, 2021
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants