Description
Issue Description
I am seeking to improve the debugging, profiling, and code coverage capabilities for WebAssembly (WASM) smart contracts using the near-workspaces-rs
library. This issue serves as a discussion point for potential approaches to implement these features.
One potential solution involves the use of minicov
, a crate that provides code coverage and profile-guided optimization (PGO) for no_std
and embedded programs such as WASM smart contracts. Minicov
achieves this by utilizing a modified version of the LLVM profiling runtime, from which all dependencies on libc have been removed.
However, minicov
relies on outputting profraw files for its functionality. By default, near-workspaces-rs
and NEAR do not allow file writes as a feature, creating a barrier for using minicov
in this context.
Proposed Solution
To overcome this barrier, I propose that near-workspaces-rs
or NEAR should allow a special debugging mode that permits file writes or some other output channel where these profraw files can be piped. This would enable the profraw files to be processed with llvm-cov
, thus allowing actual code coverage of WASM smart contracts on the NEAR runtime to be measured.
This is particularly important as the general coverage developers can currently get is not actually on the NEAR runtime, and this caveat might be missed by those developing near smart contracts unfamiliar with Rust. For example, if only running unit tests, the #[payable]
attributes might be completely missed on some functions that are thought to be tested based on default coverage reporting, but are missed in the workspace-rs
tests.
Discussion Points
I would like to open a broader discussion on this topic and outline other similar cases. Some potential discussion points could include:
- Pros and cons of allowing file writes or other output channels in
near-workspaces-rs
or NEAR. - Other potential solutions for improving code coverage and debugging capabilities.
- The impact of these changes on the overall performance and security of the system.
I look forward to hearing the community's thoughts and ideas on this matter.
Metadata
Assignees
Labels
Type
Projects
Status
NEW❗