You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: runtime/wasm-go/README.md
+55-7Lines changed: 55 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
# WASM Go Module: Payment App
2
2
3
-
This repository contains the Go implementation of the **Payment App** WASM module, an example application for handling deposits, transfers, and withdrawals for the Horizen PES project.
3
+
This module contains the Go implementation of the **Payment App** WASM module — a privacy-preserving payment application for deposits, transfers, and withdrawals, built on the Horizen PES (Privacy Preserving Execution System) framework.
4
4
5
-
**Note:** The WebAssembly (WASM) runtime itself is implemented and maintained in the `horizen-pes` repository. This module depends on that runtime for building and executing tests.
5
+
The PES framework (`horizen-pes`) is **application-agnostic**: it provides a generic execution pipeline (EVM blockchain → Manager → Executor → WASM Runtime) that processes requests without ever parsing application payloads. This module is a specific application that plugs into that framework — the only layer that knows about payment logic. Any WASM module implementing the expected exports can replace it.
6
+
7
+
**Note:** The WebAssembly (WASM) runtime itself (Wasmtime) is implemented and maintained in the `horizen-pes` repository. This module depends on that runtime for building and executing tests.
6
8
7
9
## Prerequisites
8
10
@@ -30,13 +32,19 @@ tinygo version
30
32
31
33
## Dependencies
32
34
33
-
TODO: This will change when the github public repo will be available.
35
+
This module depends on two external packages:
36
+
37
+
-**`horizen-pes`** — The application-agnostic PES framework. Provides the generic WASM runtime (Wasmtime), common types (`common.Request`, `common.Event`, `common.Withdrawal`), and the `Runtime` interface. Used in tests to run the compiled WASM module.
38
+
-**`horizen-cce-common-go/wasm`** — Shared WASM guest-side types and utilities. Provides `types.Uint256`, `types.Address`, `types.PlainEvent`, result types (`LoadModuleResult`, `DepositResult`, `ProcessResult`, `DeanonymizationResult`), memory allocator (`utils.Allocate`/`Deallocate`), logging, and pointer conversions. These are the shared data structures that the wallet also imports to ensure identical serialization.
34
39
35
-
This module depends on the `horizen-pes` repository.
36
-
Since it is a private repo, you need to set Go to access Github private repos:
40
+
Both dependencies use `replace` directives in `go.mod`. For local development, uncomment the local path replaces pointing to sibling directories.
37
41
42
+
Since these are private repos, you need to configure Go for private module access:
The wallet (`wallet/`) constructs `PayloadInstructions` (defined in `app/types.go`) and encrypts them before submitting to the blockchain. This module receives and decrypts those instructions inside the TEE. Both sides import `types.Address` and `types.Uint256` from `horizen-cce-common-go/wasm/types` to ensure identical serialization.
96
+
57
97
## Development Workflow
58
98
59
-
1.**Modify WASM Module**: The core application logic is in `main.go` and `app/app.go`. Utility functions are located in `utils/`.
99
+
1.**Modify WASM Module**: The core application logic is in `app/app.go`. The WASM export bridge is in `main.go`. App-specific types are in `app/types.go`. Shared guest-side types and utilities come from `horizen-cce-common-go/wasm`.
60
100
2.**Rebuild Module**: After making changes, rebuild the WASM module using `make build` or the `tinygo` command directly.
61
101
3.**Update Tests**: Add or update corresponding tests in `wasmtime_runtime_test.go` or `integration_test.go` to reflect your changes.
62
102
4.**Verify Changes**: Run the test suite to ensure everything is working correctly:
@@ -69,9 +109,14 @@ This will create the `build/payment_app.wasm` file.
69
109
To run the tests, use the standard `go test` command:
70
110
71
111
```bash
72
-
go test ./...
112
+
# Fast suite (skips Wasmtime-dependent tests)
113
+
CI_FLAG=true go test -v ./...
114
+
115
+
# Full suite (includes all Wasmtime integration tests)
116
+
go test -v ./...
73
117
```
74
118
119
+
Use `CI_FLAG=true` to skip tests that require the Wasmtime runtime or external dependencies.
75
120
76
121
### Test Files Overview
77
122
@@ -91,6 +136,9 @@ This project contains three distinct types of tests, each with a different focus
91
136
* **Type**: End-to-End (E2E) System Test
92
137
* **Scope**: Covers the entire application stack, including simulated components like an "Executor," a "Manager," a database, and a blockchain.
93
138
* **Purpose**: To validate that all components of the system work together correctly in a production-like environment. It tests the full user flow, including cryptographic operations, request submission, and state verification across the entire distributed system.
139
+
* **Key tests**:
140
+
- `TestPaymentAppFullFlow`: Deploys the app, registers user and auditor keys, deposits funds, withdraws funds, and generates a deanonymization report. Validates deposit and withdrawal event fields, verifies on-chain withdrawal recording, checks update payload signatures, and verifies the deanonymization report (framework envelope, base64-encoded report data, and expected user balance after all operations).
141
+
* **Note**: Skipped when `CI_FLAG=true` due to long execution time.
0 commit comments