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

alloc feature added, to gate unicode normalization #57

Conversation

michalkucharczyk
Copy link
Contributor

@michalkucharczyk michalkucharczyk commented Nov 2, 2023

This PR introduces the alloc feature.

The alloc is intended to use in no-std environments which are allowed to use alloc. New feature enables:

  • the unicode-normalization, and all related methods (parse_in,normalize_utf8_cow,parse,to_seed)
  • fn to_entropy() method as Vec is available in alloc,

Some formatting sneaked in, too.

Fix for #55.

@michalkucharczyk
Copy link
Contributor Author

Maybe I should introduce alloc feature and gate unicode-normalization and to_entropy with it?

@michalkucharczyk michalkucharczyk changed the title unicode_normalization enabled in no-std alloc feature added, to gate unicode normalization Nov 2, 2023
Cargo.toml Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@tcharding
Copy link
Member

Otherwise, looks good! Thanks.

@tcharding
Copy link
Member

Thanks for fixing it up! Can you squash the fixes into the patches that they fix please. We don't squash when merging so each patch should be correct on its own. Sorry for taking so long to get back to this.

@michalkucharczyk
Copy link
Contributor Author

I'd squash all the commits to the single one, and force push. @tcharding would that work for you?

@tcharding
Copy link
Member

Yep, that is fine for me.

@michalkucharczyk michalkucharczyk force-pushed the mku-unicode-normalization-in-no-std branch from e63f0b2 to 1372108 Compare November 13, 2023 08:37
@michalkucharczyk
Copy link
Contributor Author

@tcharding I've squashed all the patches into single one.

@benma
Copy link
Contributor

benma commented Nov 14, 2023

Thanks for the effort @michalkucharczyk. I started on the same before seeing this 🙈 here is the issue that should be referenced: #55

Please see #59 too which re-enables some unit tests that accidentally never ran - could be relevant.

@michalkucharczyk
Copy link
Contributor Author

Thanks for the effort @michalkucharczyk. I started on the same before seeing this 🙈 here is the issue that should be referenced: #55

Description updated.

Please see #59 too which re-enables some unit tests that accidentally never ran - could be relevant.

I've check the tests (with feature) locally: all of them are green. Let's keep features vs feature fix in #59.

Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK c62f91b

@tcharding
Copy link
Member

Thanks man!

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@michalkucharczyk michalkucharczyk force-pushed the mku-unicode-normalization-in-no-std branch from c62f91b to 9180d56 Compare February 1, 2024 11:15
@michalkucharczyk
Copy link
Contributor Author

@stevenroose thanks for review - all addressed. would appreciate your feedback again.

@michalkucharczyk michalkucharczyk force-pushed the mku-unicode-normalization-in-no-std branch from 9180d56 to eb35a97 Compare February 2, 2024 08:37
@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Feb 2, 2024 via email

@@ -49,7 +50,7 @@ zeroize = { version = "1.5", features = ["zeroize_derive"], optional = true }

# Unexported dependnecies
bitcoin_hashes = { version = ">=0.12, <=0.13", default-features = false }
unicode-normalization = { version = "=0.1.22", optional = true }
unicode-normalization = { version = "=0.1.22", default-features = false, optional = true }
Copy link
Member

Choose a reason for hiding this comment

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

Oh I did not notice before but I don't think this should be a fixed version? Should be version = "0.1.22".

Copy link
Collaborator

Choose a reason for hiding this comment

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

No then it will upgrade and this crate has repeatedly broken MSRV for some of my projects. It's an internal dep so the version used shouldn't matter. Luckily 0.1.22 now is over a year old and seems like he saturated the project too. Which is ok :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes it a bit hard to package on distributions though if dependencies get out of sync, one would have to patch the Cargo.toml file to allow other versions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I rekon we should handle MSRV breakage with pinning not in the manifest like this.

Cargo.toml Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
@tcharding
Copy link
Member

what is wrong with enabling it? if we are in std it shall be propagated there, right?

I think we are talking about "unicode-normalization" from "std", right? If its an optional dependency then it should be optional, if its enabled in "std" its not really optional.

@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Feb 2, 2024 via email

@tcharding
Copy link
Member

Oh I see. I'll ack this as is then and we can look at the features more closely later. Thanks for explaining.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK eb35a97

@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Feb 9, 2024

Is this failure: Continuous integration / Test - 1.41.1 toolchain something I should worry about? (btw: I see it is also failing for other commits).

@stevenroose
Copy link
Collaborator

stevenroose commented Feb 9, 2024

Can you rebase on master so that the MSRV build works? Thanks.

@stevenroose stevenroose mentioned this pull request Feb 9, 2024
This commit introduces the `alloc` feature.

The alloc feature is intended to use in no-std environments which are allowed to
use alloc. New feature enables:
- the unicode-normalization, and all related methods (parse_in,normalize_utf8_cow,parse,to_seed)
- to_entropy() method as Vec is available in alloc,
@michalkucharczyk michalkucharczyk force-pushed the mku-unicode-normalization-in-no-std branch from eb35a97 to 86353a5 Compare February 10, 2024 11:08
@michalkucharczyk
Copy link
Contributor Author

Can you rebase on master so that the MSRV build works? Thanks.

Done (force pushed).

@tcharding
Copy link
Member

@stevenroose can you kick CI please. On #64 as well.

@michalkucharczyk
Copy link
Contributor Author

any updates here?

github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Mar 11, 2024
This functionality is required for #1984.

This PR enables
[`sp-keyring`](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/substrate/primitives/keyring/src/sr25519.rs#L31-L40)
in `no-std` environments, allowing to generate the public key (e.g.
`AccountKeyring::Alice.public().to_ss58check()`), which can be later
used in the any of built-in [_runtime-genesis-config_
variant](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/polkadot/node/service/src/chain_spec.rs#L1066-L1073).


The proposal is as follows:
- expose [`core::Pair`
trait](https://github.com/paritytech/polkadot-sdk/blob/d6f15306282e3de848a09c9aa9cba6f95a7811f0/substrate/primitives/core/src/crypto.rs#L832)
in `no-std`,
- `full_crypto` feature enables `sign` method,
- `std` feature enables `generate_with_phrase` and `generate` methods
(randomness is required),
- All other functionality, currently gated by `full_crypto` will be
available unconditionally (`no-std`):
-- `from_string`
-- `from_string_with_seed`
-- `from seed`
-- `from_seed_slice`
-- `from_phrase`
-- `derive`
-- `verify`

---

Depends on rust-bitcoin/rust-bip39#57

---------

Co-authored-by: command-bot <>
Co-authored-by: Davide Galassi <[email protected]>
github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Mar 12, 2024
This functionality is required for #1984.

This PR enables
[`sp-keyring`](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/substrate/primitives/keyring/src/sr25519.rs#L31-L40)
in `no-std` environments, allowing to generate the public key (e.g.
`AccountKeyring::Alice.public().to_ss58check()`), which can be later
used in the any of built-in [_runtime-genesis-config_
variant](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/polkadot/node/service/src/chain_spec.rs#L1066-L1073).


The proposal is as follows:
- expose [`core::Pair`
trait](https://github.com/paritytech/polkadot-sdk/blob/d6f15306282e3de848a09c9aa9cba6f95a7811f0/substrate/primitives/core/src/crypto.rs#L832)
in `no-std`,
- `full_crypto` feature enables `sign` method,
- `std` feature enables `generate_with_phrase` and `generate` methods
(randomness is required),
- All other functionality, currently gated by `full_crypto` will be
available unconditionally (`no-std`):
-- `from_string`
-- `from_string_with_seed`
-- `from seed`
-- `from_seed_slice`
-- `from_phrase`
-- `derive`
-- `verify`

---

Depends on rust-bitcoin/rust-bip39#57

---------

Co-authored-by: command-bot <>
Co-authored-by: Davide Galassi <[email protected]>
dharjeezy pushed a commit to dharjeezy/polkadot-sdk that referenced this pull request Mar 24, 2024
This functionality is required for paritytech#1984.

This PR enables
[`sp-keyring`](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/substrate/primitives/keyring/src/sr25519.rs#L31-L40)
in `no-std` environments, allowing to generate the public key (e.g.
`AccountKeyring::Alice.public().to_ss58check()`), which can be later
used in the any of built-in [_runtime-genesis-config_
variant](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/polkadot/node/service/src/chain_spec.rs#L1066-L1073).


The proposal is as follows:
- expose [`core::Pair`
trait](https://github.com/paritytech/polkadot-sdk/blob/d6f15306282e3de848a09c9aa9cba6f95a7811f0/substrate/primitives/core/src/crypto.rs#L832)
in `no-std`,
- `full_crypto` feature enables `sign` method,
- `std` feature enables `generate_with_phrase` and `generate` methods
(randomness is required),
- All other functionality, currently gated by `full_crypto` will be
available unconditionally (`no-std`):
-- `from_string`
-- `from_string_with_seed`
-- `from seed`
-- `from_seed_slice`
-- `from_phrase`
-- `derive`
-- `verify`

---

Depends on rust-bitcoin/rust-bip39#57

---------

Co-authored-by: command-bot <>
Co-authored-by: Davide Galassi <[email protected]>
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this pull request Mar 25, 2024
This functionality is required for paritytech#1984.

This PR enables
[`sp-keyring`](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/substrate/primitives/keyring/src/sr25519.rs#L31-L40)
in `no-std` environments, allowing to generate the public key (e.g.
`AccountKeyring::Alice.public().to_ss58check()`), which can be later
used in the any of built-in [_runtime-genesis-config_
variant](https://github.com/paritytech/polkadot-sdk/blob/21d36b7b4229c4d5225944f197918cde23fda4ea/polkadot/node/service/src/chain_spec.rs#L1066-L1073).


The proposal is as follows:
- expose [`core::Pair`
trait](https://github.com/paritytech/polkadot-sdk/blob/d6f15306282e3de848a09c9aa9cba6f95a7811f0/substrate/primitives/core/src/crypto.rs#L832)
in `no-std`,
- `full_crypto` feature enables `sign` method,
- `std` feature enables `generate_with_phrase` and `generate` methods
(randomness is required),
- All other functionality, currently gated by `full_crypto` will be
available unconditionally (`no-std`):
-- `from_string`
-- `from_string_with_seed`
-- `from seed`
-- `from_seed_slice`
-- `from_phrase`
-- `derive`
-- `verify`

---

Depends on rust-bitcoin/rust-bip39#57

---------

Co-authored-by: command-bot <>
Co-authored-by: Davide Galassi <[email protected]>
@stevenroose stevenroose merged commit 6f6ec34 into rust-bitcoin:master Mar 28, 2024
@michalkucharczyk michalkucharczyk mentioned this pull request Mar 28, 2024
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.

5 participants