Skip to content

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 requested review from crystalin, librelois and nbaztec July 27, 2023 12:25
@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

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 👍

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 👍

.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 👍

.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
@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.

4 participants