Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds metering support for bulk memory operations (MemoryCopy and MemoryFill) in WebAssembly through an opcode versioning mechanism. The implementation introduces V2 opcodes that include these bulk memory operations, while V1 maintains backward compatibility.
Changes:
- Introduced opcode versioning (V1/V2) to enable/disable bulk memory operations
- Added metering for MemoryCopy and MemoryFill with per-byte cost calculation
- Refactored API from
set_opcode_costtoset_opcode_configto include version information
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| vm-executor/src/opcode_version.rs | New enum defining opcode versions V1 and V2 with i32 conversion |
| vm-executor/src/opcode_config.rs | New struct combining opcode version and cost configuration |
| vm-executor/src/opcode_cost.rs | Added cost fields for MemoryCopy and MemoryFill operations |
| vm-executor/src/lib.rs | Exported new OpcodeConfig and OpcodeVersion types |
| vm-executor/src/executor.rs | Updated trait method from set_opcode_cost to set_opcode_config |
| vm-executor-wasmer/src/wasmer_opcode_cost.rs | Split opcode cost logic into V1 and V2 functions, added bulk memory ops to V2 |
| vm-executor-wasmer/src/wasmer_metering.rs | Added bulk memory metering with size backup global and per-byte cost injection |
| vm-executor-wasmer/src/wasmer_helpers.rs | Added helper to identify supported bulk memory operators |
| vm-executor-wasmer/src/wasmer_instance.rs | Updated to use OpcodeConfig instead of OpcodeCost |
| vm-executor-wasmer/src/wasmer_executor.rs | Updated executor to use OpcodeConfig with improved error handling |
| vm-executor-wasmer/src/lib.rs | Renamed metering_helpers to opcode_cost module |
| vm-executor-wasmer/tests/opcode_version_test.rs | Added test verifying V1 rejects and V2 accepts bulk memory ops |
| vm-executor-wasmer/tests/memory-copy.wat | Test WAT file demonstrating memory.copy operation |
| vm-executor-wasmer/Cargo.toml | Added std feature to log dependency |
| vm-executor-experimental/* | Updated to use OpcodeConfig (but missing bulk memory metering) |
| c-api/src/capi_metering.rs | Updated C API to accept opcode version parameter |
| c-api/libvmexeccapi.h | Updated C header with new function signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical metering correctness, cache enforcement, import compatibility, and public ABI regressions remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 8
Open (8)
Removing managed crypto hooks breaks the public C/Wasm ABI · New Renaming the opcode cost symbol breaks existing native consumers · New Removing hook table fields breaks the public ABI layout · New Removing pairing imports breaks existing Wasm modules · New Cached modules bypass opcode version configuration checks · New Missing i32-to-i64 conversion breaks backup GlobalSet typing · New Missing i64-to-i32 conversion breaks injected GlobalGet typing · New Removing VM hooks breaks host and contract compatibility · New

The implementation is mostly complete, but it needs gas testing.
Also contains opcode versioning.