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

reject imported memories early #8146

Merged
merged 2 commits into from
Dec 8, 2022

Conversation

Ekleog-NEAR
Copy link
Collaborator

They were already rejected by wasmer2 before this change, just after preparation. So this should not be a protocol change.

Second attempt at #8029, without a protocol change this time

_ => continue,
// TODO: it’s a protocol change because the gas amount burned would change for some tests, but here we should
// _ => return Err(PrepareError::Instantiate),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Allowing imports of globals etc. seems fine to me, even if we don’t have any currently. As long as we confirm that they must come from env which we do, it is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm so I was coming from the idea that right now we validate func types again (though I’m not really sure why), but we just ignore globals etc. Anyway it doesn’t change anything, so I’m removing this comment :)

// This test assumes that maximum page number is configured to a certain number.
assert_eq!(VMConfig::test().limit_config.max_memory_pages, 2048);

let r = parse_and_prepare_wat(r#"(module (import "env" "memory" (memory 1 1)))"#);
assert_matches!(r, Ok(_));
assert_matches!(r, Err(PrepareError::Memory));
Copy link
Collaborator

@nagisa nagisa Dec 1, 2022

Choose a reason for hiding this comment

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

So in the past the preparation would pass, and then the code would get passed into Wasmer2VM::compile_uncached() which then returned WasmerCompileError { ... } rather than a PrepareError::Memory.

This then moves on to be encoded into, I believe, the chain as the error message. At least that’s what I think matklad has explained to me in the past. So in the end this is still a protocol change, isn’t it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Based on the chat here, I think it isn’t :)

@Ekleog-NEAR Ekleog-NEAR force-pushed the reject-imported-mem-early branch 2 times, most recently from 58882e5 to 894f16d Compare December 7, 2022 17:46
They were already rejected by wasmer2 before this change, just after
preparation. So this should not be a protocol change.
@Ekleog-NEAR Ekleog-NEAR force-pushed the reject-imported-mem-early branch from 894f16d to c49257c Compare December 7, 2022 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants