-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] | |||
serde = { version = "1.0.136", optional = true, features = ["derive"] } | |||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } | |||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } | |||
frame-metadata = { version = "15.0.0", default-features = false, features = ["v14"] } | |||
frame-metadata = { version = "15.1.0", default-features = false, features = ["v14"], git = "https://github.com/chiefbiiko/frame-metadata", branch = "blake3" } |
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.
Would open a frame-metadata
companion to expand its StorageHasher
enum if thumbs-up.
How do the outputted weight files compare? |
Some benches over the same 3x4K input https://github.com/davxy/crypto-benches/tree/main/hash#blake3 https://github.com/davxy/crypto-benches/tree/main/hash#blake2 |
This pull request doesn't contain any reasoning on why we should add Blake3. Yes there is some mentioning of some faster benchmarks, but there are no numbers in this pr. Why do you need this? Do you want to use this on some Parachain? |
Thanks for your feedback! Will run some more benchmarks later today. |
I am only seeing a difference for large key types (will push the code). So it really depends on your use-case. |
Small question, in the benches, does blake2-rfc run with simd activated? |
|
Thanks, I remember seeing good improvement for blake2 with simd (but it was a long time ago so probably on blake2-rfc), I am a bit surprise the blake3 perf are that much higher (it is just a bit less round from blake2 and we probably don't want parallelism for most of our content). On a side note I would be interested to use blake3 for some blob storage (to be able to use the binary tree hashing for recalculation on change and eventually proofs (but at this time blob storage is only something "in progress" and non persistent)). |
We should overall the blake3 interface to make blake3 A minor concern, blake3 might not work so well on really really tiny signer devices. It needs maybe An idea, one host call that creates an opaque blake3 hasher in the host, and then update and finalize hostcalls that manipulates it there, including building the copath elements that go into the PoV. None of what I'm saying here prevents adding a blake3 via the normal interface of course. Just fyi here really. |
I have such hashers for the existing ones implemented in https://github.com/cheme/substrate/blob/2278e8c761cede6eadb6e71a910fd2d414241d35/primitives/io/src/lib.rs#L1428 (my branch with the transient storage), it requires to store the hashers state in the state machine changes overlay, not finished/fully tested though. |
I opened a discussion on the blake3 repo BLAKE3-team/BLAKE3#279 which may tell us if many people think all that would be useful. |
From the heading comment in https://github.com/BLAKE3-team/BLAKE3/blob/master/src/guts.rs they already expose some internal for the bao project, which makes it possible to implement it ourselve, even if a bit of work that could be shared at the crate level indeed. |
It's also unclear how much we care, like how often someone needs a big bunch of bytes |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
We will use Blake3 for other purposes in our protocol and from our tests it does provide the lowest latency comparing to Sha256 and Blake3, so we'd be happy to utilize it across the board instead of Blake2 (so we have less variation in the protocol). |
Adds Blake3 to Substrate primitives and FRAME.
On paper Blake3 is fast (er than Blake2b/s, almost x2 for short inputs). That makes it an attractive alternative to Blake2 as a runtime's generic hasher (
BlakeThree256
) as well as for storage hashing (Blake3_128Concat
). Mostly interesting for new parachains but theoretically Blake3 could substitute Blake2 throughout the stack.Other projects that have adopted Blake3 so far include IPFS, Solana, and LLVM.
Below storage benchmarks comparing Blake version 2 vs 3 show no diff in reads but a considerable speedup writing. On my machine (passes benchmark check) I see write time decrease by 20%-33%.