Commit a8c6301
authored
feat(wasm): integrate evaluation pipeline with structured I/O and registry support (#35)
* feat(wasm): integrate WASM executor with evaluation pipeline and challenge registry
Update the validator node WASM executor, challenge registry, build
infrastructure, and documentation to support loading and executing
term-challenge WASM modules through the evaluation pipeline.
WASM Executor (wasm_executor.rs, main.rs):
- Add EvaluationInput/EvaluationOutput structs for structured data exchange
across the WASM boundary using bincode serialization
- Refactor execute_evaluation() to accept challenge_id and params, construct
EvaluationInput, and deserialize packed ptr+len return values into
EvaluationOutput with score, valid flag, and message
- Add StorageHostConfig/StorageHostState integration for persistent storage
- Rename allocator call from "allocate" to "alloc" matching WASM SDK ABI
- Handle WASM traps, OOM, fuel exhaustion with descriptive error types
- Update main.rs call sites to pass challenge_id and params, and read
structured output fields (score, valid, message) from EvaluationOutput
Challenge Registry (registry.rs):
- Deprecate docker_image field with compile warning in favor of wasm_module
- Add register_wasm_challenge() method that validates the WASM file exists,
computes its SHA256 hash, and stores the entry with WasmModuleMetadata
- Add #[allow(deprecated)] annotations to suppress warnings in existing
tests and constructors that still reference docker_image
Build Script (build-wasm.sh):
- Extract build logic into reusable build_challenge() function
- Add wasm-strip support for reducing binary size before wasm-opt
- Copy compiled artifacts to challenges/compiled/ standard location
- Compute and print SHA256 hash of each compiled module
- When no argument given, discover and build all challenge crates under
challenges/*/ plus term-challenge-wasm if present as workspace member
- Preserve chain-runtime fallback build when no challenges are found
Documentation (challenges/README.md):
- Document WASM Challenge trait as recommended approach alongside legacy
ServerChallenge
- Add WASM ABI export requirements (evaluate, validate, alloc)
- Add term-challenge-wasm build instructions and link to term-challenge repo
- Update external challenge guidance to reference Challenge trait and
register_challenge! macro
* ci: trigger CI run1 parent 7846d16 commit a8c6301
7 files changed
Lines changed: 306 additions & 65 deletions
File tree
- bins/validator-node/src
- challenges
- crates
- challenge-registry/src
- distributed-storage/src
- wasm-runtime-interface/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
376 | 377 | | |
377 | 378 | | |
378 | 379 | | |
| |||
985 | 986 | | |
986 | 987 | | |
987 | 988 | | |
| 989 | + | |
988 | 990 | | |
989 | 991 | | |
990 | 992 | | |
991 | 993 | | |
992 | 994 | | |
993 | | - | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
994 | 1002 | | |
995 | 1003 | | |
996 | 1004 | | |
997 | 1005 | | |
998 | | - | |
| 1006 | + | |
999 | 1007 | | |
1000 | 1008 | | |
1001 | 1009 | | |
1002 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1003 | 1013 | | |
1004 | 1014 | | |
1005 | 1015 | | |
1006 | 1016 | | |
1007 | 1017 | | |
1008 | 1018 | | |
1009 | | - | |
| 1019 | + | |
1010 | 1020 | | |
1011 | 1021 | | |
1012 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
14 | 49 | | |
15 | 50 | | |
16 | 51 | | |
17 | 52 | | |
18 | 53 | | |
| 54 | + | |
19 | 55 | | |
20 | 56 | | |
21 | 57 | | |
| |||
25 | 61 | | |
26 | 62 | | |
27 | 63 | | |
| 64 | + | |
28 | 65 | | |
29 | 66 | | |
30 | 67 | | |
| |||
72 | 109 | | |
73 | 110 | | |
74 | 111 | | |
75 | | - | |
76 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
77 | 116 | | |
78 | 117 | | |
79 | 118 | | |
80 | 119 | | |
81 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
82 | 123 | | |
83 | 124 | | |
84 | 125 | | |
| |||
87 | 128 | | |
88 | 129 | | |
89 | 130 | | |
90 | | - | |
91 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
92 | 135 | | |
93 | 136 | | |
94 | 137 | | |
95 | 138 | | |
96 | 139 | | |
97 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
98 | 150 | | |
99 | 151 | | |
100 | 152 | | |
| |||
105 | 157 | | |
106 | 158 | | |
107 | 159 | | |
108 | | - | |
| 160 | + | |
109 | 161 | | |
110 | 162 | | |
111 | 163 | | |
| |||
117 | 169 | | |
118 | 170 | | |
119 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
120 | 178 | | |
121 | 179 | | |
122 | | - | |
| 180 | + | |
123 | 181 | | |
124 | 182 | | |
125 | | - | |
| 183 | + | |
126 | 184 | | |
127 | 185 | | |
128 | | - | |
129 | | - | |
| 186 | + | |
| 187 | + | |
130 | 188 | | |
131 | 189 | | |
132 | 190 | | |
| |||
137 | 195 | | |
138 | 196 | | |
139 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
140 | 216 | | |
141 | 217 | | |
142 | 218 | | |
| |||
151 | 227 | | |
152 | 228 | | |
153 | 229 | | |
154 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
155 | 234 | | |
156 | 235 | | |
157 | 236 | | |
158 | 237 | | |
159 | 238 | | |
160 | 239 | | |
161 | 240 | | |
162 | | - | |
| 241 | + | |
163 | 242 | | |
164 | 243 | | |
165 | 244 | | |
166 | 245 | | |
167 | 246 | | |
168 | 247 | | |
169 | 248 | | |
170 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
171 | 252 | | |
172 | 253 | | |
173 | 254 | | |
174 | 255 | | |
175 | 256 | | |
176 | 257 | | |
177 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
178 | 268 | | |
179 | 269 | | |
180 | 270 | | |
| |||
185 | 275 | | |
186 | 276 | | |
187 | 277 | | |
188 | | - | |
| 278 | + | |
189 | 279 | | |
190 | 280 | | |
191 | 281 | | |
| |||
197 | 287 | | |
198 | 288 | | |
199 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
200 | 296 | | |
201 | 297 | | |
202 | | - | |
| 298 | + | |
203 | 299 | | |
204 | 300 | | |
205 | | - | |
| 301 | + | |
206 | 302 | | |
207 | 303 | | |
208 | 304 | | |
209 | | - | |
| 305 | + | |
210 | 306 | | |
211 | 307 | | |
212 | 308 | | |
| |||
233 | 329 | | |
234 | 330 | | |
235 | 331 | | |
| 332 | + | |
236 | 333 | | |
237 | 334 | | |
238 | 335 | | |
| |||
0 commit comments