-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Introduce entropy function into frame System
#14149
Conversation
| ExecutionPhase::<T>::put(Phase::Initialization); | ||
| storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); | ||
| let entropy = (b"frame_system::initialize", parent_hash).using_encoded(blake2_256); | ||
| storage::unhashed::put(well_known_keys::INTRABLOCK_ENTROPY, &entropy[..]); |
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.
| storage::unhashed::put(well_known_keys::INTRABLOCK_ENTROPY, &entropy[..]); | |
| storage::unhashed::put_raw(well_known_keys::INTRABLOCK_ENTROPY, &entropy[..]); |
Otherwise put encodes again and pretends the length, so it looses one byte of entropy when only reading the first 32 bytes.
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.
Just linking to PR addressing this: #14152
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.
fixed lengths arrays are not prepended with its length.
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.
It is a slice though, because of the [..] i assume.
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.
Good point 🙈
This is a stateless function which provides a universally unique datum, suitable for use in XCM to provide each message with an unpredictable-but-unique identifier across the consensus universe. It may have other uses across the ecosystem.