-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc, refactor: Avoid duplicate set lookup in gettxoutproof #19847
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
Conversation
ac2bb14
to
9542e05
Compare
ACK 9542e05 |
could also test empty array? |
@MarcoFalke you mean to change from
to
|
I've taken your test and my test suggestion and added them to #19922 (another pull reworking the test a bit) |
faf251d test: gettxoutproof duplicate txid (João Barbosa) faf5eb4 test: Test empty array in gettxoutproof (MarcoFalke) fa56e86 test: Run rpc_txoutproof.py even with wallet disabled (MarcoFalke) faba790 test: MiniWallet: Default fee_rate in send_self_transfer, Pass in utxo_to_spend (MarcoFalke) fa65a11 test: bugfix: Actually pick largest utxo (MarcoFalke) Pull request description: Run the consensus test even when the wallet was not compiled. Also: * Minor bugfix in MiniWallet * Two new test cases (one cherry-picked from #19847) ACKs for top commit: jnewbery: utACK faf251d. Thanks Marco! kristapsk: ACK faf251d Tree-SHA512: a5ab33695c88cfb3c369021d4506069c08ce298e24e891db55159130693ed3817444c72f6aad3f472235aa4597b2c601010af714411c2ec8ad9c2d2e0b00ecbc
…abled faf251d test: gettxoutproof duplicate txid (João Barbosa) faf5eb4 test: Test empty array in gettxoutproof (MarcoFalke) fa56e86 test: Run rpc_txoutproof.py even with wallet disabled (MarcoFalke) faba790 test: MiniWallet: Default fee_rate in send_self_transfer, Pass in utxo_to_spend (MarcoFalke) fa65a11 test: bugfix: Actually pick largest utxo (MarcoFalke) Pull request description: Run the consensus test even when the wallet was not compiled. Also: * Minor bugfix in MiniWallet * Two new test cases (one cherry-picked from bitcoin#19847) ACKs for top commit: jnewbery: utACK faf251d. Thanks Marco! kristapsk: ACK faf251d Tree-SHA512: a5ab33695c88cfb3c369021d4506069c08ce298e24e891db55159130693ed3817444c72f6aad3f472235aa4597b2c601010af714411c2ec8ad9c2d2e0b00ecbc
9542e05
to
c4d8377
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review ACK c4d8377 🧾
Not sure if this refactor is worth it. Unless you fix the error string for #19847 (comment) I don't think this code needs to be touched. |
@MarcoFalke done. |
1af04b5
to
63ed27a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
63ed27a
to
52fc399
Compare
nice small optimization! |
@@ -287,7 +283,7 @@ static RPCHelpMan gettxoutproof() | |||
LOCK(cs_main); | |||
|
|||
if (pblockindex == nullptr) { | |||
const CTransactionRef tx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, oneTxid, Params().GetConsensus(), hashBlock); | |||
const CTransactionRef tx = GetTransaction(/* block_index */ nullptr, /* mempool */ nullptr, *setTxids.begin(), Params().GetConsensus(), hashBlock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in commit 73dc19a:
Just for future reference, this is reading uninitialized memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Care to explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::set::begin will return the end interator if the set is empty.
Dereferencing the end pointer is accessing uninitialized memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, would you check !setTxids.empty()
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bug only exists in commit 73dc19a , which can't be modified because it is already merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting @MarcoFalke.
I guess this needs for a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is fixed in the 2nd commit 52fc399. It should have been the 1st commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I got it. An intermediate commit had this uninitialized memory access. No need for action.
…txoutproof 52fc399 rpc: Reject empty txids in gettxoutproof (João Barbosa) 73dc19a rpc, refactor: Avoid duplicate set lookup in gettxoutproof (João Barbosa) Pull request description: ACKs for top commit: jonasschnelli: code review ACK 52fc399 Tree-SHA512: 76b18e5235e8b2d394685515a4a60335666eeb0f6b31c1d397f7db2fbe681bc817b8cd3e8f6708b9dacd6113e4e1d94837072cae27834b8a1a22d2717db8191e
No description provided.