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

Hash new types as specified in #284 #349

Merged
merged 8 commits into from
Jan 5, 2020

Conversation

dr-orlovsky
Copy link
Collaborator

@dr-orlovsky dr-orlovsky commented Nov 29, 2019

Progress report:

@dr-orlovsky dr-orlovsky changed the title [WIP] Hash new types as specified in #284 Hash new types as specified in #284 Nov 30, 2019
@dr-orlovsky dr-orlovsky reopened this Nov 30, 2019
@dr-orlovsky
Copy link
Collaborator Author

@apoelstra The PR is ready for a review; the build with rust 1.22 fails since rust compiler fails to recognise that FromHex use is actually used by the macro, and allow_unused does not work for this version (but works fine for the rest). I can't do anything with this false error...

@dpc
Copy link
Contributor

dpc commented Dec 6, 2019

Maybe make #![deny(unused_imports)] conditional on a feature , and turn that feature on travis builds of non-1.22.0 builds?

@apoelstra
Copy link
Member

I think we should just put allow(unused_imports) on hash_types.rs

Alternately, we could remove the deny line entirely; these are just a random collection of rust-0.6-era style lints which are handled today by better error messages and better coding conventions. But I don't like the warnings, even if they're only on 1.22.

@dr-orlovsky
Copy link
Collaborator Author

Everything works for now with allow(unused_imports) moved on hash_types mod in lib.rs. Also merged recent changes from the master.

@codecov-io
Copy link

codecov-io commented Dec 9, 2019

Codecov Report

Merging #349 into master will decrease coverage by 0.07%.
The diff coverage is 88.03%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #349      +/-   ##
=========================================
- Coverage   84.78%   84.7%   -0.08%     
=========================================
  Files          39      40       +1     
  Lines        7221    7680     +459     
=========================================
+ Hits         6122    6505     +383     
- Misses       1099    1175      +76
Impacted Files Coverage Δ
src/lib.rs 100% <ø> (ø) ⬆️
src/internal_macros.rs 59.47% <ø> (ø) ⬆️
src/network/message_filter.rs 100% <100%> (ø) ⬆️
src/util/contracthash.rs 78.5% <100%> (ø) ⬆️
src/util/address.rs 85.49% <100%> (-0.9%) ⬇️
src/network/message.rs 95.37% <100%> (+0.23%) ⬆️
src/util/bip143.rs 100% <100%> (ø) ⬆️
src/util/psbt/mod.rs 86.06% <100%> (ø) ⬆️
src/blockdata/block.rs 79.13% <100%> (+0.94%) ⬆️
src/util/bip32.rs 87.4% <100%> (+0.25%) ⬆️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2caebc...63d0194. Read the comment docs.

@apoelstra
Copy link
Member

Could you please clean up the history? Squash down fixup commits, remove merge commits, etc?

@dr-orlovsky dr-orlovsky force-pushed the hashtypes branch 2 times, most recently from 7e652b2 to d389aa5 Compare December 9, 2019 23:01
@dr-orlovsky
Copy link
Collaborator Author

I have tried to do my best in structuring my changes into logical structure of sequential commits plus the last two for rebasing master and resolving conflicts with the master

@dr-orlovsky dr-orlovsky force-pushed the hashtypes branch 2 times, most recently from 37ec3e6 to 2a3b089 Compare December 10, 2019 00:50
@apoelstra
Copy link
Member

Can you rebase instead of merging?

@dr-orlovsky
Copy link
Collaborator Author

I can, but when I did it it said about conflicts (even after rebasing), so I had to merge. Now I see that there are new conflicts...

@apoelstra
Copy link
Member

Right, if there are conflicts you need to fix the conflicts

@elichai
Copy link
Member

elichai commented Dec 10, 2019

If you prefer I don't mind helping with rebasing/fixing conflicts.
(all you'll need to do is tick the allow edits from maintainers)

src/blockdata/block.rs Outdated Show resolved Hide resolved
src/blockdata/block.rs Outdated Show resolved Hide resolved
src/blockdata/block.rs Show resolved Hide resolved
src/blockdata/constants.rs Show resolved Hide resolved
src/blockdata/transaction.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@dr-orlovsky
Copy link
Collaborator Author

Sorry for replying late, being out for our first client-side validation event we were doing in Milan. @elichai, thank you for your proposal, I will address @stevenroose review today with a new commit and will allow edits for maintainers - I am completelly missed with all this rebase vs merge + conflicts...

src/blockdata/block.rs Outdated Show resolved Hide resolved
@dr-orlovsky
Copy link
Collaborator Author

@apoelstra the command succeeds with all of the commits; so there is no change

@apoelstra
Copy link
Member

:( on the first commit, 4b1fb9970f6ce32977945440db8668e60f0ecff7, I get


error: unused imports: `FromHex`, `ToHex`
  --> src/hash_types.rs:22:52
   |
22 | use hashes::{sha256, sha256d, hash160, Hash, hex::{ToHex, FromHex}};
   |                                                    ^^^^^  ^^^^^^^
   |
note: lint level defined here
  --> src/lib.rs:44:9
   |
44 | #![deny(unused_imports)]
   |         ^^^^^^^^^^^^^^

Then on 985bfb70c58d9b82662155b3db0711ce31fbf402 I get many errors like

error[E0599]: no function or associated item named `from_hex` found for type `hash_types::XpubIdentifier` in the current scope
  --> src/hash_types.rs:48:1
   |
48 | hash_newtype!(XpubIdentifier, hash160::Hash, 20, doc="XpubIdentifier as defined in BIP-32.");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | |
   | function or associated item `from_hex` not found for this
   | function or associated item not found in `hash_types::XpubIdentifier`
   |
   = help: items from traits can only be used if the trait is in scope
   = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
           `use hashes::hex::FromHex;`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

@dr-orlovsky
Copy link
Collaborator Author

dr-orlovsky commented Dec 25, 2019

Very strange, what I get is:

rust-bitcoin % git rebase -x '~/.cargo/bin/cargo test && ~/.cargo/bin/cargo +1.22.0 test && ~/.cargo/bin/cargo test --features "use-serde rand"'
Executing: ~/.cargo/bin/cargo test && ~/.cargo/bin/cargo +1.22.0 test && ~/.cargo/bin/cargo test --features "use-serde rand"
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running target/debug/deps/bitcoin-bfc5fbd5ae8e345a

and after quite a lot of time I get

Successfully rebased and updated refs/heads/hashtypes.

rust-bitcoin % git status
On branch hashtypes
Your branch is up to date with 'origin/hashtypes'.

nothing to commit, working tree clean

What am I doing wrong?

PS. Sorry, figured that out myself, I have missed master suffix while I was copying the string. Now everything runs as in your output. Working on the fixes

@dr-orlovsky
Copy link
Collaborator Author

dr-orlovsky commented Dec 25, 2019

@apoelstra done. It is needed to reset Travis cache and re-run tests though.

@apoelstra
Copy link
Member

Great, thanks! I'm unlikely to get it done today on account of Christmas :)

@dr-orlovsky
Copy link
Collaborator Author

Sure, I am too celebrating the Winter Solstice and Solar Eclipse :)

@apoelstra
Copy link
Member

My rebase command still fails on the first three commits (at least) :(

One persistent error is

error: expected one of `,` or `as`, found `::`
  --> src/hash_types.rs:22:49
   |
22 | use hashes::{sha256, sha256d, hash160, Hash, hex::{ToHex, FromHex}};
   |                                                 ^^ expected one of `,` or `as` here

on 1.22.

@dr-orlovsky
Copy link
Collaborator Author

@apoelstra very strange, it could be that I had pushed a wrong version. Have re-done rebasing and double-checked, it seems to be fine now.

PS. Travis still fails due to its internal problem, needs to reset cache.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK. Thanks for the many revisions.

Copy link
Member

@elichai elichai left a comment

Choose a reason for hiding this comment

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

LGTM.
only logic change is the bitcoin_merkle_root, which looks ok

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.

7 participants