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

Fix the wasm substitute caching bug #64

Merged
merged 2 commits into from
Jul 27, 2023

Conversation

rimbi
Copy link

@rimbi rimbi commented Jul 27, 2023

Fix the wasm substitute caching bug.

When there exist multiple code substitutes in the spec, the used to keep only one. The current solution fixes this bug by creating a unique hash for each wasm blob.

@rimbi rimbi self-assigned this Jul 27, 2023
@crystalin
Copy link

@rimbi please rebase the PR, it doesn't seem correct

@rimbi rimbi changed the base branch from master to moonbeam-polkadot-v0.9.40 July 27, 2023 13:23
@rimbi
Copy link
Author

rimbi commented Jul 27, 2023

sorry for the inconvenience, ready for review again @crystalin @nbaztec @librelois

let runtime_code = RuntimeCode {
code_fetcher: &WrappedRuntimeCode((&code).into()),
heap_pages: None,
hash: Vec::new(),
hash,

Choose a reason for hiding this comment

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

Suggested change
hash,
hash: make_hash(&code),

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks 👍

@@ -123,10 +123,13 @@ where
let substitutes = substitutes
.into_iter()
.map(|(block_number, code)| {
let mut hasher = DefaultHasher::new();

Choose a reason for hiding this comment

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

Suggested change
let mut hasher = DefaultHasher::new();

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks 👍

@@ -123,10 +123,13 @@ where
let substitutes = substitutes
.into_iter()
.map(|(block_number, code)| {
let mut hasher = DefaultHasher::new();
hasher.write(&code);

Choose a reason for hiding this comment

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

Suggested change
hasher.write(&code);

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks 👍

@@ -123,10 +123,13 @@ where
let substitutes = substitutes
.into_iter()
.map(|(block_number, code)| {
let mut hasher = DefaultHasher::new();
hasher.write(&code);
let hash = hasher.finish().to_ne_bytes().to_vec();

Choose a reason for hiding this comment

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

Suggested change
let hash = hasher.finish().to_ne_bytes().to_vec();

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks 👍

@librelois librelois merged commit 8c3bdd6 into moonbeam-polkadot-v0.9.40 Jul 27, 2023
0 of 6 checks passed
@librelois librelois deleted the cem-moonsama-stuck-sync branch July 27, 2023 14:09
noandrea pushed a commit that referenced this pull request Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants