casper-network / casper-network/casper-node

Move away from hand made wasm code and use walrus crate to construct wasm bytes using a DSL

Open
#3,586 0 comments 0 reactions 0 assignees View on GitHub
execution engine tech-debt
Dominant language
Rust
Stars
399
Forks
224
Avg merge
15h 44m
Merged PRs (30d)
2

Description

As part of #3585 non-trivial wasm was made by hand to ensure we have precise control costs of specific wasm opcodes. The only reliable way to do that is to construct wasm by hand - and writing nontrivial wasm by hand is hard, especially if you do a lot of labels, recursive code generators, parametric blocks etc. Walrus https://docs.rs/walrus/latest/walrus/ is official rustwasm project for dealing with manipulation of wasm modules. One of the features is a DSL to write wasm by hand to ensure compile time safety which decreases time to develop new wasms by orders of magnitude. Here’s an example that can be followed from their repo https://github.com/rustwasm/walrus/blob/9d6c9de432d6a97478dc76ebdf18aed51584c3af/examples/build-wasm-from-scratch.rs
As their module manipulation APIs have much less boilerplate code, and emphasizes on safety, there are less ways to shoot ourselves in the foot compared to parity wasm utils. (which bite us numerous times in past). In a future when we took over pwasm-utils we could attempt to port gas injector, and stack height limiters to walrus and observe less code, and also less foot guns.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.