-
Notifications
You must be signed in to change notification settings - Fork 40
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
2221 feature request handle pvf execution parameters #2227
2221 feature request handle pvf execution parameters #2227
Conversation
82eaab2
to
5e26dab
Compare
5e26dab
to
140b775
Compare
0e6c2a1
to
9a2ddde
Compare
9a2ddde
to
d1a997e
Compare
core/runtime/wabt/util.hpp
Outdated
std::vector<uint8_t> wat_to_wasm(std::string_view wat) { | ||
auto module = wat_to_module(kagome::str2byte(wat)); | ||
wabt::MemoryStream stream; | ||
if (wabt::Failed(wabt::WriteBinaryModule( | ||
&stream, | ||
module.get(), | ||
wabt::WriteBinaryOptions{{}, true, false, true}))) { | ||
throw std::runtime_error{"Failed to write binary wasm"}; | ||
} | ||
return std::move(stream.output_buffer().data); | ||
} | ||
|
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.
wabtEncode(watDecodeWat(wat))
std::vector<uint8_t> wat_to_wasm(std::string_view wat) { | |
auto module = wat_to_module(kagome::str2byte(wat)); | |
wabt::MemoryStream stream; | |
if (wabt::Failed(wabt::WriteBinaryModule( | |
&stream, | |
module.get(), | |
wabt::WriteBinaryOptions{{}, true, false, true}))) { | |
throw std::runtime_error{"Failed to write binary wasm"}; | |
} | |
return std::move(stream.output_buffer().data); | |
} |
Buffer code; | ||
if (not readFile(code, path_compiled)) { | ||
return CompilationError{"read file failed"}; | ||
} | ||
/// TODO(erakhtinb) handle wasm bulk memory flag if Binaryen is keeped |
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.
loadCompiled
should check flag too
if (config.wasm_ext_bulk_memory) {
return CompilationError{"bulk memory is not supported"};
}
core/runtime/wabt/util.hpp
Outdated
wabt::MemoryStream stream; | ||
if (wabt::Failed(wabt::WriteBinaryModule( | ||
&stream, | ||
module.get(), | ||
wabt::WriteBinaryOptions{{}, true, false, true}))) { | ||
throw std::runtime_error{"Failed to write binary wasm"}; | ||
} | ||
return std::move(stream.output_buffer().data); | ||
} |
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.
wabt::MemoryStream stream; | |
if (wabt::Failed(wabt::WriteBinaryModule( | |
&stream, | |
module.get(), | |
wabt::WriteBinaryOptions{{}, true, false, true}))) { | |
throw std::runtime_error{"Failed to write binary wasm"}; | |
} | |
return std::move(stream.output_buffer().data); | |
} | |
return wabtEncode(module).value(); | |
} |
@@ -52,4 +63,41 @@ namespace kagome::runtime { | |||
} | |||
return common::Buffer{std::move(s.output_buffer().data)}; | |||
} | |||
|
|||
inline std::unique_ptr<wabt::Module> watToModule( |
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.
May rename to wabtDecodeWat(string_view)
test/core/runtime/wasm_test.cpp
Outdated
if (bulk) { | ||
EXPECT_TRUE(instrumented); | ||
code = std::move(instrumented.value()); | ||
} else { | ||
EXPECT_FALSE(instrumented); | ||
return nullptr; | ||
} |
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.
if (bulk) { | |
EXPECT_TRUE(instrumented); | |
code = std::move(instrumented.value()); | |
} else { | |
EXPECT_FALSE(instrumented); | |
return nullptr; | |
} | |
if (bulk) { | |
EXPECT_TRUE(instrumented); | |
} else { | |
EXPECT_FALSE(instrumented); | |
} | |
if (not instrumented) { | |
return nullptr; | |
} | |
code = std::move(instrumented.value()); |
Referenced issues
Closes #2221
Description of the Change
Both kinds (approval and backing) of pvf execution timeout are handled right. WasmExtBulkMemory parameter for WasmEdge is parsed and used for parachain compilation
Possible Drawbacks
Checklist Before Opening a PR
Before you open a Pull Request (PR), please make sure you've completed the following steps and confirm by answering 'Yes' to each item: