Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Introduce entropy function into frame System#14149

Merged
gavofyork merged 1 commit into
masterfrom
gav-unique-hash
May 15, 2023
Merged

Introduce entropy function into frame System#14149
gavofyork merged 1 commit into
masterfrom
gav-unique-hash

Conversation

@gavofyork
Copy link
Copy Markdown
Member

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.

@gavofyork gavofyork added A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited B1-note_worthy Changes should be noted in the release notes T1-runtime This PR/Issue is related to the topic “runtime”. labels May 15, 2023
@gavofyork gavofyork requested a review from a team May 15, 2023 15:52
Comment thread frame/system/src/lib.rs
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[..]);
Copy link
Copy Markdown
Member

@ggwpez ggwpez May 15, 2023

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Copy Markdown
Contributor

@liamaharon liamaharon May 15, 2023

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

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

@ggwpez ggwpez May 16, 2023

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good point 🙈

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited T1-runtime This PR/Issue is related to the topic “runtime”.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants