-
-
Notifications
You must be signed in to change notification settings - Fork 108
Description
Problem
Debug-compiled WASM contracts are ~65x larger than release builds (e.g., 12MB vs 186KB for the ping contract). When clients attempt to PUT these contracts, they can exceed WebSocket message size limits, causing confusing "Message too long" errors.
This was discovered when test contracts were accidentally being compiled in debug mode, producing 12MB WASM files that serialized to ~21MB over WebSocket.
Proposed Solution
Add validation in the contract PUT handler to detect debug WASM and return a clear error message.
Detection Method
Debug WASM files contain .debug_* custom sections:
.debug_abbrev.debug_info.debug_ranges.debug_str.debug_line.debug_loc
Release builds have none of these sections.
Implementation
- Use
wasmparser(already available via wasmer) to scan custom sections - Check if any custom section name starts with
.debug_ - If found, return an error like:
Contract appears to be compiled in debug mode (contains .debug_* sections). Debug WASM is typically 10-100x larger than release builds. Please compile with --release for production use.
Alternative: Warning vs Error
Could make this a warning instead of an error, logged server-side, to avoid breaking existing workflows. However, an error at publish time is cleaner since debug contracts shouldn't be deployed to production.
Where to Add
The validation should be in crates/core/src/client_events/mod.rs or crates/core/src/contract/handler.rs where PUT requests are processed.
Context
- PR fix(test): use port retry instead of serial execution for blocked_peers tests #2254 fixed tests to use release builds
- PR fix: increase WebSocket client message size limit to 100MB #2252 (merged) increased WebSocket limit to 100MB as a workaround
- This issue would prevent the problem at the source
[AI-assisted - Claude]
Metadata
Metadata
Assignees
Labels
Type
Projects
Status