-
Notifications
You must be signed in to change notification settings - Fork 36.6k
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
libsecp256k1 integration #4312
libsecp256k1 integration #4312
Conversation
Seems to work here, but pulltester is unhappy :( |
Pulltester problem doesn't look too bad:
|
By the way, at least initially I would prefer it if --enable-libsecp256k1 was mutually incompatible with --enable-wallet. Ideally, there would be a way to remove the mining code too :) |
export -n LDFLAGS | ||
|
||
ac_configure_args="${ac_configure_args} --disable-shared --with-pic" | ||
AC_CONFIG_SUBDIRS([src/secp256k1]) |
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.
NACK, just pull in libsecp256k1 as a normal dependency. No subtree garbage necessary.
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.
Define "normal dependency"?
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.
Including it as subtree is better IMO. It leaves us control over the code (which is one of the reasons for moving away from OpenSSL in the first place!), and avoids that the person building it has to install a dependency that's pretty much unknown right now.
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.
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.
But something could be said that secp256k is in exactly the same spot as leveldb. It's critical to the consensus.
Sure, @sipa is upstream here which helps, but by including the code we avoid having to take version mismatches into account, for example. We test with one bitcoind-secp256k-leveldb combination and everyone will use that.
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.
There is plenty to be gained by modularising it. Other software can use bits.
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.
Other software can use libsecp256k1 regardless of whether we subtree it or not.
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.
Not quite, it will reside in memory twice.
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.
It's 30 kB of object code.
And 600 kB of precomputed data (which wouldn't be shared across processes anyway).
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'm pretty indifferent on the matter, I just hooked it up as requested. Either outcome is fine by me.
The pull-tester issue is actually a pretty nasty problem. I'm still debating which "fix" to use, I'll push something up soon. |
I get the following error with #!/bin/bash
PARALLELISM=6
./autogen.sh && ./configure --with-gui=qt5 --enable-libsecp256k1 --disable-wallet && make clean && make -j${PARALLELISM}
(Ubuntu 14.04 AMD64) |
Yes, this needs rebasing on top of #4277. |
rebased. I made a minimal change for @laanwj's error and squashed it into the first commit. |
Idea: call secp256k1_start from ECC_InitSanityCheck? That way, we don't spend the time for building the precomputation tables in bitcoin-cli... |
@sipa Good point, though I'm not sure the sanity check function is the best place. Something could be said that bitcoin-cli shouldn't be linking key.cpp at all. But that's an issue for another day :) |
Agree, I'm fine with an explicit initializer/finalizer as well, independent from the ecc check. And of course, bitcoin-cli shouldn't use key.cpp at all, but I don't know how far we're away from that. |
*** Error in `bitcoin/src/bitcoind': munmap_chunk(): invalid pointer: 0x0000000000a2e430 *** #0 0x00007ffff5d71f79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 |
See bitcoin-core/secp256k1#28 for a fix. |
@sipa Would you prefer that I sync and rebase this as these come up? Or leave it as-is with the understanding that a sync will be done before merge? |
@theuni Up to you. Constantly rebasing will take work, but may make some things easier to review. |
Needs rebase. |
Rebased. |
Could you add a print during runtime to display the fact that it is using libsecp256k1 similar to these others? Otherwise it is difficult to know which library you are using. |
@laanwj From the build-side, I think it's ok to merge. Up to @sipa on the readiness of the lib itself. Are you just worried about the (time) cost of rebasing this for build-system changes? If so, I can split it into 2 parts: Build-system changes that are useless without the 2nd part, and the actual secp and configure switch addition. We could merge the first now to prevent future rebasing, then do the 2nd whenever @sipa is happy. |
If there is a clear condition when the lib is ready we can wait for that, I just want to avoid keeping this open up to some arbitrary time. My belief at the start of this project was that secp256k1 was ready for experimental use in bitcoin core. So once the code review comments with regard to the integration are processed, and things are not obviously crashing or failing, I think we should aim to merge this. We can then periodically update the secp256k1 lib from upstream. Splitting it into two parts, a build system change and the rest, also sounds good to me. |
Ok, I'll split this into 2 PRs. The build-side can be merged, then the discussion can be about the readiness of secp256k1 itself. |
Split up. @laanwj You can pull as much of this one as you want whenever you're ready. It's a complete no-op without the lib itself and the configure option. The rest is here (on top of this PR) for reference: https://github.com/theuni/bitcoin/commits/secp256k1-integration-part2 |
Sorry for commenting late. If we want to merge for experimental use, fine by me. I'd like to make it disable wallet and mining when doing so, but perhaps people compiling from source could easily bypass that anyway. I do plan to change the API significantly at some point, but everything is functional now, and that won't be immediately. If we want to wait for something like an actual "release" of libsecp256k1... that may take a while, and the glue code would probably need to be different too. |
Will merge this after rebase. I definitely don't think we should wait for an actual "release" of libsecp256k1. The more testing it gets the better. |
Note: This is added to our existing automake targets rather than as a libtool-style lib. The switch to libtool-style targets can come later if it proves to not add any complications.
Rebased and ready for merge afaik. Otherwise, if you're ok with it as-is, I can just PR those once this one is merged. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4312_fda3fed18aedc4bfc8ccffe89d8d2cabb12677ab/ for binaries and test log. |
@sipa suggested I go ahead and PR this to get discussion going. It's his work, I've just integrated it into our build-system.
This was done in a few stages: