-
Notifications
You must be signed in to change notification settings - Fork 829
Implement Clone for SighashCache #4075
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
base: master
Are you sure you want to change the base?
Implement Clone for SighashCache #4075
Conversation
Pull Request Test Coverage Report for Build 13416368245Details
💛 - Coveralls |
Appears to be built on an outdated version of #4071. Please rebase on master (which should fix CI). |
Thanks for the contribution!
|
I"m getting merge commits on the tip of this now mate. You want to squash the whole thing down into a single patch and force push. Holla if you can't work it out - here to help. EDIT: Ignore that, the 'Benchmark SighashCache before adding Clone' as a separate patch is a good idea. Then perhaps the rest as a single patch. |
Thanks for the feedback @tcharding!
I'll get this sorted and push the changes soon. Let me know if anything else needs adjusting. Thanks for your patience! |
Implement Clone for SighashCache Benchmark SighashCache after adding Clone Trigger CI rebuild Update Cargo.lock with the latest dependencies Update dependencies and fix deprecated Txid usage Benchmark SighashCache before adding Clone Squashed changes: - Implement Clone for SighashCache - Benchmark SighashCache after adding Clone - Remove unnecessary CI rebuild commit - Remove Cargo.lock (not committed) - Update dependencies and fix deprecated Txid usage - General cleanup
fdc4783
to
ac0a472
Compare
@tcharding @apoelstra I have squashed all my commits (except the first one) as mentioned and rebased the branch on the latest master. But still some tests are failing. Could you help me understand if these failures are related to my changes or something upstream? Let me know if I need to make further adjustments. Apologies for any inconvenience caused, and thanks for your time! |
@BEULAHEVANJALIN I think it would simplify the process if you added Criterion in a different PR and focus on closing #4068 |
@@ -40,6 +40,7 @@ base64 = { version = "0.22.0", optional = true } | |||
# `bitcoinconsensus` version includes metadata which indicates the version of Core. Use `cargo tree` to see it. | |||
bitcoinconsensus = { version = "0.106.0", default-features = false, optional = true } | |||
serde = { version = "1.0.103", default-features = false, features = [ "derive", "alloc" ], optional = true } | |||
criterion = "0.5.1" |
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.
This should be a dev dependency. see bellow.
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 the update! Lemme try.
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.
I expected this PR to be a single line change - adding Clone
to the list of derives. The only other useful change in the PR I see is removing &mut
but that's not really related.
black_box(cloned_cache); | ||
}) | ||
}); | ||
} |
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.
This entire benchmark is meaningless. The first one benchmarks setting a few registers to zero/pointer, the second benchmarks doing nothing (passing a reference is not accessing; and even if it was, there's no point), the third one benchmarks cloning.
It's comparing apples to oranges. We don't need such a test. We never benchmark clone impls and I see no reason to believe we need to benchmark them here.
#[derive(Debug)] | ||
pub struct SighashCache<T: Borrow<Transaction>> { | ||
#[derive(Debug, Clone)] | ||
pub struct SighashCache<T: Borrow<Transaction> + Clone> { |
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.
That additional Clone
bound shouldn't be needed and it's harmful. The derive macro inserts its own and forcing it prevents &mut Transaction
from being used which specifically goes against the intent of BorrowMut
.
Fixes #4068
Summary
Clone
forSighashCache
Clone
Benchmark Results
Key Notes
Please verify correctness and confirm alignment with project goals.
Open to any feedback or further refinements.