24个版本
新版本 0.1.24 | 2024年8月22日 |
---|---|
0.1.22 | 2024年6月25日 |
0.1.20 | 2024年3月21日 |
0.1.16 | 2023年10月30日 |
0.1.5 | 2022年7月21日 |
#60 in WebAssembly
5,118每月下载量
8KB
76 行
确定性-wasi-ctx
关于此仓库
这是一个Rust包,用于创建一个完全确定性的wasi-common WASI上下文实现。
确定性指的是提供的WASI函数对于同一系列调用始终返回相同的系列结果。例如,对系统时钟调用clock_time_get
将始终返回相同的时间戳。或者调用random_get
将始终在第一次调用时返回155
,然后在第二次调用时始终返回111
。
这可以在各种环境中非常有用。例如,缓存调用Wasm模块中函数的结果。
用法
let wasi = deterministic_wasi_ctx::build_wasi_ctx();
let engine = Engine::default();
let mut linker = Linker::new(&engine);
wasmtime_wasi::add_to_linker(&mut linker, |s| s).unwrap();
let module_path = ...; // path to a Wasm module
let module = Module::from_file(&engine, module_path).unwrap();
let mut store = Store::new(&engine, wasi);
linker.module(&mut store, "", &module).unwrap();
let instance = linker.instantiate(&mut store, &module).unwrap();
... // invoke functions on `instance`
贡献
确定性-wasi-ctx
是一个测试项目,将进行重大开发。我们欢迎反馈、错误报告和错误修复。我们也很乐意讨论功能开发,但在贡献之前请先在问题中讨论功能。
构建依赖
- rustup
- 稳定通道上Rust的最新版本
wasm32-wasi
目标,可以通过运行rustup target add wasm32-wasi
来安装
构建
在安装所有依赖项之后,运行make build-deterministic-wasi-ctx
来构建包。
测试
运行make test
以运行集成测试。
结构
确定性-wasi-ctx-test-programs
包用于构建一组Wasm文件,这些文件调用WASI函数,这些函数在确定性-wasi-ctx
包中的集成测试中使用,以验证这些Wasm文件的输出是否具有确定性。
发布
依赖
~14–25MB
~386K SLoC