-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Clean up configuration in gen_context #918
Clean up configuration in gen_context #918
Conversation
I just noticed that if we're going to do this, then edit: I'd still be happy to hear comments on the above plans. |
The problem here really stems from the fact that we have two classes of configuration options:
The latter has to be identical for the real build and gen_context, but the former cannot be (because gen_context needs to be built natively, while the main build may be cross-compiled). Random thought: what about replacing gen_context with a Python script? We have some experience with Python code for EC arithmetic already, it'd be more than performant enough for this purpose, constant-timeness is not a concern, and the result would still be subject to all tests of the resulting build (though we way want to add a test that is designed to access all table entries). That would avoid all complications the current build system has that result from cross-compilation. Other than that... it feels a bit strange to treat this ECMULT_GEN_PREC_BITS configuration for gen_context different from everything else, but I don't see a better solution. Another vague thought: I think we should aim for having the library not requiring any |
Interesting observation. It may be a good idea to split these options into two sections or two files.
Our current code comes with a lot of autotools complexity and can be annoying for the user when it comes to cross-compilation but the approach is pretty solid nowadays. I'm not convinced that a build dependency on Python will be less annoying on average. But isn't the real solution here to simply add the generated files to the repo, ideally for all supported values of
All of this is not an issue. If we care, we can restrict the constant to be 2 or 4. Nobody will need 8 and we anyway want to make the test matrix smaller.
Yeah it's not elegant but it would work.
Right, as I said above, we're almost there for a basic config. The only missing thing is defaults for the two tweak values of |
@real-or-random With #693 the number of possible configurations for the ecmult_gen table will go up a lot though, and in some cases even pretty big ones may be reasonable to use there. Also if we'd want to provide a mode where the ecmult table is precomputed, perhaps it is not desirable that all its code is checked in? A possibility perhaps is shipping the precomputed tables for the default configuration in the repository, and use a runtime created one for others (either through native-compiled code, or Python generated code). |
Oh I always forget about this PR.
That sounds very reasonable, and we can still see if we want to ship just one file for a single configuration or more. The precomputed files are probably still smaller than any installation of Python or a native compiler. Let me still update this PR as planned. What do other people think about the current approach vs Python? |
c74b874
to
a1d83a8
Compare
Before this commit, gen_context.c both included libsecp256k1-config.h and basic-config.h: The former only to obtain ECMULT_GEN_PREC_BITS and the latter to obtain a basic working configuration to be able to use the library. This was inelegant and confusing: It meant that basic-config.h needs to #undef all the macros defined in libsecp256k1-config.h. Moreover, it meant that basic-config.h cannot define ECMULT_GEN_PREC_BITS, essentially making this file specific for use in gen_context.c. After this commit, gen_context.c include only libsecp256k1-config.h. basic-config.h is not necessary anymore for the modules used in gen_context.c because 79f1f7a made the preprocessor detect all the relevant config options. On the way, we remove an unused #define in basic-config.h.
set ECMULT_GEN_PREC_BITS to the "auto" value of 4 in basic_config.h, so libsecp can be used without autoconf
71d76d1
to
0706796
Compare
I fixed this and edited the initial comment. |
utACK 0706796 The switch to Python if desired can always be done later. |
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.
Nice clean up.
We keep the file and it can help users to facilitate non-autotools builds.
How about removing the USE_BASIC_CONFIG ifdef which seems to have no use? Generally, the "we take a step back plan" sounds like a good solution to #622 to me.
ACK mod nit
I think if we keep the file for now, then we should keep this ifdef for now to avoid touching the "API". Some people may define the macro conditionally. We'll probably remove the file later but then at least we interrupt the compile process of users only once then. |
@sipa said somehere else:
This sounds very reasonable to me. |
Haha, okay. |
I know I said this on IRC-- but I see it's not here. The configurations there shouldn't go up: It's not a good use of resources to test a large number of configurations and 99.999999% of users will have no more idea how to set these things than we do. Instead, there should be a small number of exposed configurations (like small, medium, large) just for protecting the sanity of the user and the testability of the software -- and as a side effect it keeps the shipped configurations manageable. |
@gmaxwell I mean: the number of supportable configurations goes up, if we keep things through the same kind of set-the-individual-tunables-via-./configure interface. I fully agree we should independently (with or without multicomb), change that to a small/medium/large interface. |
gen_context: Don't include basic-config.h
Before this commit, gen_context.c both included libsecp256k1-config.h
and basic-config.h: The former only to obtain ECMULT_GEN_PREC_BITS
and the latter to obtain a basic working configuration to be able to
use the library.
This was inelegant and confusing: It meant that basic-config.h needs
to #undef all the macros defined in libsecp256k1-config.h. Moreover,
it meant that basic-config.h cannot define ECMULT_GEN_PREC_BITS,
essentially making this file specific for use in gen_context.c.
After this commit, gen_context.c include only libsecp256k1-config.h.
basic-config.h is not necessary anymore for the modules used in
gen_context.c because 79f1f7a made the preprocessor detect all the
relevant config options.
On the way, we remove an unused #define in basic-config.h.
This now cherrypicks 71d76d1 from #918.
After this PR, basic-config.h is unused. We could simply remove it. But with the goal of improving non-autotools (#622) in mind, I don't think that's the best approach. Here are better options:
ECMULT_WINDOW_SIZE
andECMULT_GEN_PREC_BITS
are not defined. So I suggest we define default values for those in the corresponding files. Then the library would be cleanly without any necessary config.