-
Notifications
You must be signed in to change notification settings - Fork 764
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
keyring
: remove lazy_static
public keys hash maps
#2387
keyring
: remove lazy_static
public keys hash maps
#2387
Conversation
keyring
: remove lazy_static
public hash mapskeyring
: remove lazy_static
public keys hash maps
This comment was marked as off-topic.
This comment was marked as off-topic.
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.
The code obviously works. There is not much to say about it.
The only thing that I still don't like (but maybe is subjective) is that there are two obvious ways to do the same thing.
That is, getting a public key using:
Keyring::pair().public()
From<Keyring> or [u8; 32]
In practice this new approach is the same as the one used in the previous iteration only that the code that previously was in a member function has not being moved in From<Keyring>
for [u8; 32]`.
Again, IMO would be way better to have one way or another.
- One which is used for
std
orfull_crypto
or whatever you want to call the feature in this crate (which also includes the Pair` and capability to sign). - Another where
fn public
internally uses this new approach of pre-constructed arrays.
If at some point you want to include this stuff in no_std
you may want to remove fn pair()
anyway as to sign with a Schnorr key you need randomness.
IUC: the consequence of your proposal will be calling the Having the public key in form of raw bytes prevents this call (and is closer to cached approach). |
ok, I think I got it, you simply want this function to use predefined raw bytes, right? polkadot-sdk/substrate/primitives/keyring/src/sr25519.rs Lines 94 to 96 in 88ae185
|
Caching is pointless here. Alice, Bob and co keyring is used for tests, templates and a like. Never in production |
The ideal is:
As I said above, caching is not really important for these keys |
This will be done in chainspec generation (for all testnets, zombienets, etc...), which will be done in runtime. Why not keep this optimization? |
Is the cost of calling |
My suggestion was such that in the runtime you end up using the |
Support for |
Yeah, sorry my oversight, Obviously |
Ok I remember. But I also was thinking that with the introduction of statically computed What is the usage of |
We can gate Probably there is no use case for this in runtime. On the other hand we will have this functionality for free, and if not used linker should strip it off. |
It was different at the beggining, I spotted my mistake here: #2387 (comment) |
Co-authored-by: Koute <[email protected]>
Co-authored-by: Koute <[email protected]>
bot update-ui |
@michalkucharczyk https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/4662342 was started for your command Comment |
@michalkucharczyk Command |
The `lazy_static` package does not work well in `no-std`: it requires `spin_no_std` feature, which also will propagate into `std` if enabled. This is not what we want. This PR removes public/private key hash-maps and replaces them with simple static byte arrays. `&T` versions of `AsRef/Deref/From` traits implementation were removed. Little const helper for converting hex strings into array during compile time was also added. (somewhat similar to _hex_literal_). --------- Co-authored-by: command-bot <> Co-authored-by: Koute <[email protected]>
The
lazy_static
package does not work well inno-std
: it requiresspin_no_std
feature, which also will propagate intostd
if enabled. This is not what we want.This PR removes public/private key hash-maps and replaces them with simple static byte arrays.
&T
versions ofAsRef/Deref/From
traits implementation were removed.Little const helper for converting hex strings into array during compile time was also added. (somewhat similar to hex_literal).