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

Replace openssl/sha2 with a sha256 implementation #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

elichai
Copy link

@elichai elichai commented Sep 2, 2020

This is to remove openssl as a dependency, making this tool entirely free standing
the sha256 implementation is from libsecp256k1(https://github.com/bitcoin-core/secp256k1/blob/master/src/hash_impl.h) but I've adjusted it to the code style here.

There are no tests here, but I manually sampled a few transactions and blocks and verified that their hash matches what's in blockstream.info

There doesn't seem to be any performance difference as most of the work is in I/O:

Before:

$ time ./bitcoin-iterate -q && time ./bitcoin-iterate -q
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
                                                           
real    2m30.215s                     
user    0m1.315s                                         
sys     0m13.255s                                   
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
                                                           
real    2m28.074s                                                                                                     
user    0m1.322s                                                                                                      
sys     0m13.238s

After:

$ time ./bitcoin-iterate -q && time ./bitcoin-iterate -q                                                                                                                               
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
                                                                                                                      
real    2m30.056s                                                                                                     
user    0m1.401s                                                                                                      
sys     0m13.151s                                                                                                     
bitcoin-iterate: Skipped 4681563 at end of /home/elichai2/.bitcoin/blocks/blk02222.dat
                                                                                                                      
real    2m26.071s                                                                                                     
user    0m1.467s                                                                                                      
sys     0m13.074s                                                                                                     

This should resolve #16 and resolve #11

@renepickhardt
Copy link

this looks good to me but of course this is for @rustyrussell to decide. Did not expect that my issue would actually get a PR or any fix at all. Kind of only put it there if beginners use the code and google the error.

@elichai
Copy link
Author

elichai commented Sep 3, 2020

It took me 5-10 minutes of work, so why not,
And it's obviously fine if @rustyrussell decides to leave this as is (it still works great even after years)

@jsarenik
Copy link
Contributor

jsarenik commented Oct 7, 2020

Tested ACK 9ddef39 (processed all testnet3 blocks)

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.

Won't run on Mac OS OpenSSL not found
3 participants