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

Enable build with global context less secure #387

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Jan 27, 2022

Currently the following build command fails:

cargo build --no-default-features --features=global-context-less-secure
  • The first two patches are benign refactorings.
  • Patch 3 adds an implementation of Debug using bitcoin_hashes::sha256 as the hasher as well as a fallback implementation. Please review carefully.
  • Patch 4 adds global-context-less-secure to the test features matrix

We should use `Deref` from `core` since it is available there.
When building with --no-default-features the compiler emits:

  warning: unused import: `mem`

The call site is feature gated so we either need to feature gate the
import or use a fully qualified path. Since 'core' is quite short elect
to use the fully qualified path.
Currently we cannot build cleanly with `--no-default-features`.

The `Debug` implementation for secrets is feature gated on `std` because
it uses a hasher from `std`. If `bitcoin_hashes` is enabled we can use
it for hashing. If neither `std` nor `bitcoin_hashes` is enabled fall
back to outputting:

   <secret requires std or bitcoin_hashes feature to display>
Currently this command fails:

 cargo build --no-default-features --features=global-context-less-secure

All features should be able to be built individually, this is currently
not the case with `global-context-less-secure`.

Enable `std` if `global-context-less-secure` is enabled (because `Once`
only comes from `std`, not available in `core`).

Add `global-context-less-secure` to the features test array in
`contrib/test.sh`.

With this applied the build command above runs successfully.
@@ -27,7 +27,7 @@ rand-std = ["rand/std"]
recovery = ["secp256k1-sys/recovery"]
lowmemory = ["secp256k1-sys/lowmemory"]
global-context = ["std", "rand-std", "global-context-less-secure"]
global-context-less-secure = []
global-context-less-secure = ["std"]
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather we actually fix the build rather than depend on std (see conversation at #359 for one way to do this). The reason for global-context-less-secure, in part, is that we want to support global-context without the rand dependency, in part for platforms where we can't use rand. There are some platforms (like wasm, specifically), where we can technically build without no-std, but where we may not actually have an actual std environment to call, relying on LTO to remove the calls that we can't make.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, I'm off for the next few days. I'll convert this to draft and re-spin when I'm back. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I have read that link I think this whole PR should be closed.

@tcharding tcharding marked this pull request as draft January 27, 2022 08:17
@tcharding tcharding closed this Jan 31, 2022
@tcharding tcharding deleted the enable-build-with-global-context-less-secure branch January 31, 2022 03:57
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

2 participants