nNextSweep
from being a static variable in LimitOrphans
to being a member of the TxOrphanage
class. This improves the stability of the txorphan
fuzz harness, as each orphanage (created every iteration) now has its own value for nNextSweep
.
txorphan
harness stability
#30186
nNextSweep
from being a static variable in LimitOrphans
to being a member of the TxOrphanage
class. This improves the stability of the txorphan
fuzz harness, as each orphanage (created every iteration) now has its own value for nNextSweep
.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For detailed information about the code coverage, see the test coverage report.
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
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.
106@@ -107,7 +107,7 @@ class TxOrphanage {
107 int EraseTxNoLock(const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
108
109 /** Timestamp for the next scheduled sweep of expired orphans */
110- NodeSeconds nNextSweep;
111+ NodeSeconds n_next_sweep;
m_
not n_
, see https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c
but passing on your Mac
The script shouldn’t be passing on macos. Otherwise, https://github.com/bitcoin/bitcoin/commit/b3122e167a023df18f67c4083bc72f78968874db doesn’t work as intended and should be fixed.
Seems like CI still doesn’t like it.
I tried this (no space after -i)
sed -i'' 's/nNextSweep/m_next_sweep/g' $(git grep -l 'nNextSweep')
and it didn’t work on Mac. Adding the -e
without .bak
creates new txorphanage
files with -e
appended to the end of them. Something like txorphanage.h-e
. Adding .bak
prevented that but CI isn’t accepting it.
and it didn’t work on Mac.
You’ll have to install and use gnu-sed on macos, or use Linux. If you don’t want to test locally and want to know the syntax without testing, you can look at previous examples via git log --grep='sed -i'
.
Though, I am not sure if a three line diff is worth a scripted diff, so an alternative would be to just squash everything down into a single commit.
104@@ -104,6 +105,9 @@ class TxOrphanage {
105
106 /** Erase an orphan by wtxid */
107 int EraseTxNoLock(const Wtxid& wtxid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex);
108+
109+ /** Timestamp for the next scheduled sweep of expired orphans */
110+ NodeSeconds m_next_sweep GUARDED_BY(m_mutex);
In any case, you are changing the code to leave the variable uninitialized. This is undefined behavior.
You can test this with valgrind, or msan.
I am not sure if a three line diff is worth a scripted diff
Just for context, I suggested it to marco as a learning exercise.
initialize variable
-BEGIN VERIFY SCRIPT-
sed -i 's/nNextSweep/m_next_sweep/g' $(git grep -l 'nNextSweep')
-END VERIFY SCRIPT-
fixing to match style
You’ll have to install and use gnu-sed on macos, or use Linux. If you don’t want to test locally and want to know the syntax without testing, you can look at previous examples via
git log --grep='sed -i'
.
I installed gnu-sed and used that locally. CI looks good now.