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

backport: Merge bitcoin#22507, 21464, 23050, 24367 #6099

Merged
merged 4 commits into from
Jan 15, 2025

Conversation

vijaydasmp
Copy link

bitcoin backports

@vijaydasmp vijaydasmp changed the title backport: backport: Merge bitcoin#22006, 22155, 22507, 22371 Jul 6, 2024
@vijaydasmp vijaydasmp force-pushed the bp23_100_1 branch 3 times, most recently from 9881474 to c50dd0a Compare July 19, 2024 15:48
Copy link

This pull request has conflicts, please rebase.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22006, 22155, 22507, 22371 backport: Merge bitcoin#22006, 22507, 22155, 22371 Jul 20, 2024
@vijaydasmp vijaydasmp force-pushed the bp23_100_1 branch 2 times, most recently from 7b66f1f to 0c23f20 Compare July 20, 2024 09:47
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22006, 22507, 22155, 22371 backport: Merge bitcoin#22006, 22507 Jul 20, 2024
Copy link

github-actions bot commented Aug 7, 2024

This pull request has conflicts, please rebase.

Copy link

github-actions bot commented Sep 4, 2024

This pull request has conflicts, please rebase.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22006, 22507 backport: Merge bitcoin#22507 Sep 6, 2024
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22507 backport: Merge bitcoin#22507, 21464, 23591, 24153, 23002, 22677, 23547, 23065, 23723, 23642 Sep 6, 2024
@vijaydasmp vijaydasmp force-pushed the bp23_100_1 branch 7 times, most recently from 04076d6 to a587c2b Compare September 8, 2024 12:21
Copy link

github-actions bot commented Oct 5, 2024

This pull request has conflicts, please rebase.

@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22507, 21464, 22677, 23065, 23642, 21679 backport: Merge bitcoin#22507, 21464, 23065 Nov 24, 2024
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22507, 21464, 23065 backport: Merge bitcoin#22507, 21464 Jan 2, 2025
@vijaydasmp vijaydasmp changed the title backport: Merge bitcoin#22507, 21464 backport: Merge bitcoin#22507, 21464, 23050, 24367 Jan 2, 2025
@vijaydasmp vijaydasmp marked this pull request as ready for review January 2, 2025 15:14
Copy link

coderabbitai bot commented Jan 2, 2025

empty for merge -pasta

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/txmempool.h (1)

678-698: Good clarity on parameter usage and documentation.
The updated documentation thoroughly describes how ancestor_size_limit and ancestor_count_limit are used in UpdateTransactionsFromBlock. Consider clarifying the behavior if these limits are zero or extremely high to avoid confusion.

src/validation.cpp (1)

366-368: Enhance mempool ancestor limit control

The addition of ancestor_size_limit and ancestor_count_limit parameters improves control over transaction ancestor limits during mempool updates after reorganization. These limits help prevent memory exhaustion from large transaction chains.

Consider adding validation to ensure the limits don't exceed system constraints, and document the expected ranges in comments.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5787c9 and e2db0fd.

📒 Files selected for processing (20)
  • contrib/guix/guix-build (1 hunks)
  • doc/developer-notes.md (2 hunks)
  • doc/release-process.md (1 hunks)
  • src/net.cpp (1 hunks)
  • src/node/miner.cpp (1 hunks)
  • src/qt/bitcoin.cpp (1 hunks)
  • src/qt/intro.cpp (1 hunks)
  • src/rpc/misc.cpp (1 hunks)
  • src/test/util_tests.cpp (1 hunks)
  • src/txdb.cpp (1 hunks)
  • src/txmempool.cpp (5 hunks)
  • src/txmempool.h (2 hunks)
  • src/validation.cpp (1 hunks)
  • src/wallet/rpcwallet.cpp (3 hunks)
  • test/functional/feature_txindex_compatibility.py (1 hunks)
  • test/functional/mempool_updatefromblock.py (1 hunks)
  • test/functional/rpc_decodescript.py (1 hunks)
  • test/functional/rpc_uptime.py (1 hunks)
  • test/functional/wallet_encryption.py (1 hunks)
  • test/util/test_runner.py (1 hunks)
✅ Files skipped from review due to trivial changes (14)
  • test/util/test_runner.py
  • src/txdb.cpp
  • src/node/miner.cpp
  • src/qt/intro.cpp
  • contrib/guix/guix-build
  • doc/developer-notes.md
  • src/net.cpp
  • test/functional/wallet_encryption.py
  • test/functional/rpc_decodescript.py
  • test/functional/feature_txindex_compatibility.py
  • src/qt/bitcoin.cpp
  • src/test/util_tests.cpp
  • src/rpc/misc.cpp
  • src/wallet/rpcwallet.cpp
🔇 Additional comments (9)
test/functional/rpc_uptime.py (1)

26-26: LGTM! Grammatical improvement in error message.

The change from "can not" to "cannot" improves the grammatical accuracy of the error message while maintaining the same semantic meaning.

Let's verify this matches Bitcoin's implementation:

✅ Verification successful

Error message standardization is consistent within the codebase

The verification shows that the error message "Mocktime cannot be negative" is consistently used in both the RPC implementation (src/rpc/misc.cpp) and its corresponding test (test/functional/rpc_uptime.py). The error message format follows the same pattern in both locations, ensuring internal consistency within the Dash codebase.

While we couldn't directly verify against Bitcoin's implementation, the change aligns with good coding practices by:

  1. Maintaining consistency between implementation and test
  2. Using proper grammar ("cannot" instead of "can not")
  3. Preserving the same error code (-8) and error handling pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error message matches Bitcoin's implementation
# Expected: The error message should be identical in both codebases

# Search for this error message in Bitcoin's codebase
rg -l "Mocktime cannot be negative" $(gh repo clone bitcoin/bitcoin --depth 1 2>/dev/null || echo "bitcoin")

Length of output: 152


Script:

#!/bin/bash
# Let's try searching in the current repository first to understand the context better
rg "Mocktime cannot be negative" -A 2 -B 2

Length of output: 658


Script:

#!/bin/bash
# Let's check the git history to see if this was indeed backported from Bitcoin
git log -n 5 --grep="cannot" --pretty=format:"%H %s" test/functional/rpc_uptime.py

Length of output: 0

src/txmempool.h (1)

840-871: Well-defined pre-/post-conditions for UpdateForDescendants.
The expanded docstring clearly outlines expectations for cachedDescendants and descendants_to_remove. Ensure edge cases (e.g., repeated removal requests, extremely large mempools) are handled gracefully.

src/txmempool.cpp (4)

127-129: Added parameters for ancestor limits.
Passing uint64_t ancestor_size_limit, ancestor_count_limit provides greater control. Verify that upstream calls handle invalid or zero values appropriately to avoid unexpected early removal of transactions.


166-171: Marked transactions for later removal, avoiding iterator invalidation.
This is a good approach to prevent invalid iterator usage. Confirm that follow-up calls remove these offending transactions in all scenarios to maintain a consistent mempool state.


Line range hint 177-228: Enhanced removal workflow for re-introduced transactions.
Using descendants_to_remove ensures that transactions exceeding ancestor limits after a block disconnection are removed in a separate pass. Verify that any reorg edge cases (e.g., chain tips toggling frequently) do not leave stale entries behind.


1481-1481: Refined log message in PrioritiseTransaction.
The logging now precisely indicates fee adjustments. This is consistent with related debug statements and improves clarity for debugging fee deltas in the mempool.

test/functional/mempool_updatefromblock.py (1)

20-20: Fine-tune ancestor count limit for test environment.
Adding -limitancestorcount=100 helps avoid unintentional errors when building large transaction graphs. Ensure that other tests setting conflicting ancestor limits don’t interfere with expected behaviors.

doc/release-process.md (1)

181-181: Improved commit message clarity.
Replacing “add detached sigs” with “Add attestations” more accurately describes the nature of the committed files. The instructions are now more intuitive and easier to follow for contributors.

src/validation.cpp (1)

368-368: Properly propagate ancestor limits to mempool updates

The ancestor limits are correctly passed through to UpdateTransactionsFromBlock, ensuring consistent application of the limits during reorganization.

Let's verify that these limits are properly enforced by checking the mempool code:

✅ Verification successful

Ancestor limits are properly enforced in mempool updates

The verification confirms that the ancestor limits are correctly propagated and enforced:

  1. UpdateTransactionsFromBlock passes the limits to UpdateForDescendants
  2. Inside UpdateForDescendants, transactions exceeding the limits are identified and added to descendants_to_remove
  3. These transactions are then removed from the mempool via removeRecursive

This ensures that after a block reorganization, any transaction in the mempool that would exceed the ancestor limits is properly removed, maintaining consistency with the ancestor limit policy.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check how UpdateTransactionsFromBlock uses the ancestor limits
ast-grep --pattern 'UpdateTransactionsFromBlock($_, $_, $_)'

Length of output: 228


Script:

#!/bin/bash
# Let's try a different approach to find the UpdateTransactionsFromBlock implementation
rg -U "UpdateTransactionsFromBlock.*\(" --type cpp

Length of output: 709


Script:

#!/bin/bash
# Let's check the implementation in txmempool.cpp to see how the limits are used
rg -A 20 "UpdateTransactionsFromBlock.*ancestor" src/txmempool.cpp

Length of output: 1222


Script:

#!/bin/bash
# Let's search for where these ancestor limits are actually used in the update process
rg -B 5 -A 15 "ancestor_size_limit|ancestor_count_limit" src/txmempool.cpp

Length of output: 3900

@UdjinM6
Copy link

UdjinM6 commented Jan 3, 2025

24367: missing changes in:

  • verifytxoutproof() help text (it's in src/rpc/txoutproof.cpp now)
  • CreateTransactionInternal() error message
  • test/functional/rpc_decodescript.py comment

Also, we don't have test/functional/wallet_timelock.py yet, so 24367 should be partial I guess

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Empty for git merge -pasta

laanwj and others added 4 commits January 8, 2025 13:19
….sigs repo

fafade9 doc: Adjust commit message template for the guix.sigs repo (MarcoFalke)

Pull request description:

  Seems to be the most common template used, so adjust this here, too.

ACKs for top commit:
  laanwj:
    ACK fafade9
  hebasto:
    re-ACK fafade9

Tree-SHA512: 20477d14ecfad94f3b28b94786a4c0d98df539360d0c1deefa94766064a7d0700c849e54d6b251f922e135fcfa964ada0c724090f7f92b459ea39f7c3ca8c65d
c5b36b1 Mempool Update Cut-Through Optimization (Jeremy Rubin)
c49daf9 [TESTS] Increase limitancestorcount in tournament RPC test to showcase improved algorithm (Jeremy Rubin)

Pull request description:

  Often when we're updating mempool entries we update entries that we ultimately end up removing the updated entries shortly thereafter. This patch makes it so that we filter for such entries a bit earlier in processing, which yields a mild improvement for these cases, and is negligible overhead otherwise.

  There's potential for a better -- but more sophisticated -- algorithm that can be used taking advantage of epochs, but I figured it is better to do something that is simple and works first and upgrade it later as the other epoch mempool work proceeds as it makes the patches for the epoch algorithm simpler to understand, so you can consider this as preparatory work. It could either go in now if it is not controversial, or we could wait until the other patch is ready to go.

ACKs for top commit:
  instagibbs:
    reACK c5b36b1
  sipa:
    utACK c5b36b1
  mzumsande:
    Code Review ACK c5b36b1

Tree-SHA512: 78b16864f77a637d8a68a65e23c019a9757d8b2243486728ef601d212ae482f6084cf8e69d810958c356f1803178046e4697207ba40d6d10529ca57de647fae6
…ce-versa

c17f554 Fix BlockAssembler::AddToBlock, CTxMemPool::PrioritiseTransaction logging (Jon Atack)

Pull request description:

  This is a tale of two fees, er, fee rates... indeed, one is misdescribed as a fee, and the other is incorrectly called a fee rate.

  From this review discussion: bitcoin#22689 (comment) (thanks to John Newbery).

ACKs for top commit:
  laanwj:
    Code review ACK c17f554

Tree-SHA512: 3d9df3209a72562c5f9bbf815923d5b089d04491b8d19caa2c04158c501b47ef01e47f1c32d89adcbaf3c6357329507f65b4bb2963214c3451bbfa61ac812530
…ixups from transifex translator feedback

4874269 Replace "can not" with "cannot" in docs, user messages, and tests (Jon Atack)
e670edd User-facing content fixups from transifex translator feedback (Jon Atack)

Pull request description:

  Closes bitcoin#24366.

ACKs for top commit:
  laanwj:
    Code review re-ACK 4874269
  hebasto:
    re-ACK 4874269, only suggested change since my previous [review](bitcoin#24367 (review)).

Tree-SHA512: 4dcdcb417251a413e65fab6070515e13a1267c8e0dbcf521386b842511391f24c84a0c2168fe13458c977682034466509bf2a3453719d4d94d3c568fd9f4adb4
@vijaydasmp
Copy link
Author

Hello @UdjinM6 , requesting review

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK 7972af9

@UdjinM6
Copy link

UdjinM6 commented Jan 9, 2025

Gitlab failure https://gitlab.com/dashpay/dash/-/jobs/8793673680 looks unrelated, restarted the job

@vijaydasmp
Copy link
Author

Hello @PastaPastaPasta @knst requesting review

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 7972af9

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.

5 participants