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

Initial packaging #3

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

Conversation

luke-jr
Copy link
Contributor

@luke-jr luke-jr commented Jul 21, 2016

This seems sufficient to get it up and building on x86_32 Gentoo. All tests pass (although these build scripts do not at this time build/run the tests).

@jonasschnelli
Copy link

No package 'libsecp256k1' found
Would adding libsecp256k1 as subtree make sense?

Or is installing libsecp256k1 be the way to go (is there a stable ABI / release from libsecp256k1?)

@luke-jr
Copy link
Contributor Author

luke-jr commented Jul 22, 2016

Subtrees are never proper packaging for libraries.

@voisine
Copy link
Member

voisine commented Jul 22, 2016

@luke-jr can you explain that one to me? Using a submodule lets you specify a specific commit to pull from the subtree, and it also lets you make sure it gets built from source. My perspective is that of a mobile app developer, so I'm probably not aware of all the downsides.

@jonasschnelli
Copy link

I think with proper packaging he means that he wants the capability to re-use a system wide installed library instead of using a static linked library included over a subtree.

IMO for the current stage where libsecp256k1 is in, a subtree seems to be fine.

utACK on this PR. I think it is very useful and probably save a lot of time for people trying to compile this "library"

@luke-jr
Copy link
Contributor Author

luke-jr commented Jul 22, 2016

@voisine If I am running Bitcoin Knots and BreadWallet on the same system, libsecp256k1 should only be loaded into memory once and shared between the two. This is accomplished with a single shared library that both projects link to.

Bitcoin Core currently uses a subtree to bundle libsecp256k1 because it is consensus-critical, but this is more of a necessary-evil than a good practice. BreadWallet-Core is not consensus-critical code, so it has no excuse to do such bundling.

@jonasschnelli
Copy link

jonasschnelli commented Jul 22, 2016

Tested ACK (together with system wide install of libsecp256k1 with enabled recovery module).

@jonasschnelli
Copy link

Although, tests didn't compile with make test.
I had to change a bit:

diff --git a/Makefile.am b/Makefile.am
index 13b26b2..f152be1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,3 +52,10 @@ pkgconfig_DATA = libbreadwallet-core.pc

 dist_noinst_SCRIPTS = autogen.sh
 dist_doc_DATA = LICENSE README.md
+
+noinst_PROGRAMS = test
+test_SOURCES = test.c
+test_CFLAGS = $(libbreadwallet_core_la_CFLAGS) $(libsecp256k1_CFLAGS) $(PTHREAD_CFLAGS)
+test_LDADD = libbreadwallet-core.la
+test_LDFLAGS = -static
+TESTS = test

@luke-jr
Copy link
Contributor Author

luke-jr commented Jul 22, 2016

Yes, as I said at the top, this doesn't include the test building. :)

Happy to add that commit if it works - can you do a git format-patch or push it somewhere?

@voisine
Copy link
Member

voisine commented Jul 22, 2016

@luke-jr Well, the benefit of dynamically linked libraries is reduced overall system memory usage. Is this the only one?

The disadvantages are less control over the specific version being linked, additional complexity of external dependencies in general, potential security issues since you don't necessarily know the circumstances under which the external library was built, etc...

For really large libraries I can see why you don't want multiple copies in memory, but this one is really small and really security critical, so I'm inclined to think the tradeoff isn't worth it.

My policy has always been to eliminate as many dependencies as possible. I even did a #include of secp256k1.c directly in BRKey.c so you don't have to do anything to build and link it. This also enforces keeping all references to it in one place.

@luke-jr
Copy link
Contributor Author

luke-jr commented Jul 22, 2016

No, there are numerous benefits to shared libraries, and generally all distros have a strict policy that mandates libraries must always be distributed in this manner and never bundled (eg, Gentoo, Debian, Fedora). Even the unusual cases (Mac and Windows) do the bundling by making it easy to include a shared library with the program's package.

Bundling doesn't eliminate dependencies, just obfuscates them.

@dgenr8
Copy link

dgenr8 commented Jul 22, 2016

I ran into trouble building a shared libsecp256k1 under cygwin, but thought I'd report that after fixing up the includes in BRKey.c and BRKey.h all tests passed after the following

git submodule init
git submodule update
cd secp256k1
./autogen.sh
./configure --enable-module-recovery
make
cd ..
gcc *.c secp256k1/src/libsecp256k1_la-secp256k1.o -lgmp -o test

@voisine
Copy link
Member

voisine commented Jul 23, 2016

Ok, I agree that bundling doesn't eliminate the dependency. Having tighter control over the dependencies you can't eliminate does still seem like a good idea.

It occurs to me that one negative issue with static linking is that the end user can't then update the library independently if a security issue is found, but also the converse is true, it's not as easy to enforce a specific patch level.

EBGToo pushed a commit that referenced this pull request Sep 29, 2018
EBGToo pushed a commit that referenced this pull request Sep 23, 2019
The FileService holds an RLP Coder and a file service is now called via multiple threads.  Hence TSAN issues have arisen.
EBGToo pushed a commit that referenced this pull request Oct 1, 2019
EBGToo pushed a commit that referenced this pull request Oct 2, 2019
CORE-606: Address TSAN #3; Improve EWM locking
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.

None yet

4 participants