@fluffylabs/anan-as 1.1.3-e3864a9 → 1.1.3-eee81bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -10
- package/dist/bin/index.js +174 -102
- package/dist/bin/{fuzz.js → src/fuzz.js} +3 -20
- package/dist/bin/src/log-host-call.js +41 -0
- package/dist/bin/src/trace-parse.js +315 -0
- package/dist/bin/src/trace-replay.js +130 -0
- package/dist/bin/src/tracer.js +64 -0
- package/dist/bin/src/utils.js +25 -0
- package/dist/bin/test.js +1 -3
- package/dist/build/compiler-inline.js +1 -1
- package/dist/build/compiler.d.ts +2 -2
- package/dist/build/compiler.js +1 -1
- package/dist/build/compiler.wasm +0 -0
- package/dist/build/debug-inline.js +1 -1
- package/dist/build/debug-raw-inline.js +1 -1
- package/dist/build/debug-raw.d.ts +113 -57
- package/dist/build/debug-raw.js +97 -61
- package/dist/build/debug-raw.wasm +0 -0
- package/dist/build/debug.d.ts +113 -57
- package/dist/build/debug.js +107 -64
- package/dist/build/debug.wasm +0 -0
- package/dist/build/release-inline.js +1 -1
- package/dist/build/release-mini-inline.js +1 -1
- package/dist/build/release-mini.d.ts +113 -57
- package/dist/build/release-mini.js +107 -64
- package/dist/build/release-mini.wasm +0 -0
- package/dist/build/release-stub-inline.js +1 -1
- package/dist/build/release-stub.d.ts +113 -57
- package/dist/build/release-stub.js +107 -64
- package/dist/build/release-stub.wasm +0 -0
- package/dist/build/release.d.ts +113 -57
- package/dist/build/release.js +107 -64
- package/dist/build/release.wasm +0 -0
- package/dist/build/test-inline.js +1 -1
- package/dist/build/test.wasm +0 -0
- package/dist/test/test-as.js +3 -0
- package/dist/{bin → test}/test-gas-cost.js +1 -1
- package/dist/test/test-trace-replay.js +19 -0
- package/dist/{bin → test}/test-w3f.js +3 -1
- package/package.json +5 -5
- /package/dist/bin/{test-json.js → src/test-json.js} +0 -0
package/dist/build/release.js
CHANGED
|
@@ -113,24 +113,11 @@ async function instantiate(module, imports = {}) {
|
|
|
113
113
|
p = __lowerInternref(p) || __notnull();
|
|
114
114
|
return __liftString(exports.getAssembly(p) >>> 0);
|
|
115
115
|
},
|
|
116
|
-
runVm(input, logs, useSbrkGas) {
|
|
117
|
-
// assembly/api-internal/runVm(assembly/api-types/VmInput, bool?, bool?) => assembly/api-types/VmOutput
|
|
118
|
-
input = __lowerInternref(input) || __notnull();
|
|
119
|
-
logs = logs ? 1 : 0;
|
|
120
|
-
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
121
|
-
exports.__setArgumentsLength(arguments.length);
|
|
122
|
-
return __liftRecord49(exports.runVm(input, logs, useSbrkGas) >>> 0);
|
|
123
|
-
},
|
|
124
|
-
getOutputChunks(memory) {
|
|
125
|
-
// assembly/api-internal/getOutputChunks(assembly/memory/Memory) => ~lib/array/Array<assembly/api-types/InitialChunk>
|
|
126
|
-
memory = __lowerInternref(memory) || __notnull();
|
|
127
|
-
return __liftArray(pointer => __liftRecord45(__getU32(pointer)), 2, exports.getOutputChunks(memory) >>> 0);
|
|
128
|
-
},
|
|
129
116
|
buildMemory(builder, pages, chunks) {
|
|
130
117
|
// assembly/api-internal/buildMemory(assembly/memory/MemoryBuilder, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>) => assembly/memory/Memory
|
|
131
118
|
builder = __retain(__lowerInternref(builder) || __notnull());
|
|
132
|
-
pages = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
133
|
-
chunks = __lowerArray((pointer, value) => { __setU32(pointer,
|
|
119
|
+
pages = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, pages) || __notnull());
|
|
120
|
+
chunks = __lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, chunks) || __notnull();
|
|
134
121
|
try {
|
|
135
122
|
return __liftInternref(exports.buildMemory(builder, pages, chunks) >>> 0);
|
|
136
123
|
} finally {
|
|
@@ -138,6 +125,35 @@ async function instantiate(module, imports = {}) {
|
|
|
138
125
|
__release(pages);
|
|
139
126
|
}
|
|
140
127
|
},
|
|
128
|
+
vmInit(input, useSbrkGas) {
|
|
129
|
+
// assembly/api-internal/vmInit(assembly/api-types/VmInput, bool?) => assembly/interpreter/Interpreter
|
|
130
|
+
input = __lowerInternref(input) || __notnull();
|
|
131
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
132
|
+
exports.__setArgumentsLength(arguments.length);
|
|
133
|
+
return __liftInternref(exports.vmInit(input, useSbrkGas) >>> 0);
|
|
134
|
+
},
|
|
135
|
+
vmRunOnce(input, logs, useSbrkGas) {
|
|
136
|
+
// assembly/api-internal/vmRunOnce(assembly/api-types/VmInput, bool?, bool?) => assembly/api-types/VmOutput
|
|
137
|
+
input = __lowerInternref(input) || __notnull();
|
|
138
|
+
logs = logs ? 1 : 0;
|
|
139
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
140
|
+
exports.__setArgumentsLength(arguments.length);
|
|
141
|
+
return __liftRecord50(exports.vmRunOnce(input, logs, useSbrkGas) >>> 0);
|
|
142
|
+
},
|
|
143
|
+
vmExecute(int, logs) {
|
|
144
|
+
// assembly/api-internal/vmExecute(assembly/interpreter/Interpreter, bool?) => void
|
|
145
|
+
int = __lowerInternref(int) || __notnull();
|
|
146
|
+
logs = logs ? 1 : 0;
|
|
147
|
+
exports.__setArgumentsLength(arguments.length);
|
|
148
|
+
exports.vmExecute(int, logs);
|
|
149
|
+
},
|
|
150
|
+
vmDestroy(int, dumpMemory) {
|
|
151
|
+
// assembly/api-internal/vmDestroy(assembly/interpreter/Interpreter, bool?) => assembly/api-types/VmOutput
|
|
152
|
+
int = __lowerInternref(int) || __notnull();
|
|
153
|
+
dumpMemory = dumpMemory ? 1 : 0;
|
|
154
|
+
exports.__setArgumentsLength(arguments.length);
|
|
155
|
+
return __liftRecord50(exports.vmDestroy(int, dumpMemory) >>> 0);
|
|
156
|
+
},
|
|
141
157
|
InputKind: (values => (
|
|
142
158
|
// assembly/api-utils/InputKind
|
|
143
159
|
values[values.Generic = exports["InputKind.Generic"].valueOf()] = "Generic",
|
|
@@ -153,7 +169,7 @@ async function instantiate(module, imports = {}) {
|
|
|
153
169
|
getGasCosts(input, kind, withMetadata) {
|
|
154
170
|
// assembly/api-utils/getGasCosts(~lib/array/Array<u8>, i32, i32) => ~lib/array/Array<assembly/gas-costs/BlockGasCost>
|
|
155
171
|
input = __lowerArray(__setU8, 6, 0, input) || __notnull();
|
|
156
|
-
return __liftArray(pointer =>
|
|
172
|
+
return __liftArray(pointer => __liftRecord55(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
|
|
157
173
|
},
|
|
158
174
|
disassemble(input, kind, withMetadata) {
|
|
159
175
|
// assembly/api-utils/disassemble(~lib/array/Array<u8>, i32, i32) => ~lib/string/String
|
|
@@ -163,9 +179,9 @@ async function instantiate(module, imports = {}) {
|
|
|
163
179
|
prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) {
|
|
164
180
|
// assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-types/InitialPage>, ~lib/array/Array<assembly/api-types/InitialChunk>, ~lib/array/Array<u8>) => assembly/spi/StandardProgram
|
|
165
181
|
program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
|
|
166
|
-
initialRegisters = __retain(__lowerArray(__setU64,
|
|
167
|
-
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
168
|
-
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer,
|
|
182
|
+
initialRegisters = __retain(__lowerArray(__setU64, 51, 3, initialRegisters) || __notnull());
|
|
183
|
+
initialPageMap = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord44(value) || __notnull()); }, 45, 2, initialPageMap) || __notnull());
|
|
184
|
+
initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord46(value) || __notnull()); }, 47, 2, initialMemory) || __notnull());
|
|
169
185
|
args = __lowerArray(__setU8, 6, 0, args) || __notnull();
|
|
170
186
|
try {
|
|
171
187
|
return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
|
|
@@ -183,21 +199,39 @@ async function instantiate(module, imports = {}) {
|
|
|
183
199
|
logs = logs ? 1 : 0;
|
|
184
200
|
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
185
201
|
exports.__setArgumentsLength(arguments.length);
|
|
186
|
-
return
|
|
202
|
+
return __liftRecord50(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
|
|
203
|
+
},
|
|
204
|
+
pvmStart(program, useSbrkGas) {
|
|
205
|
+
// assembly/api-utils/pvmStart(assembly/spi/StandardProgram, bool?) => u32
|
|
206
|
+
program = __lowerInternref(program) || __notnull();
|
|
207
|
+
useSbrkGas = useSbrkGas ? 1 : 0;
|
|
208
|
+
exports.__setArgumentsLength(arguments.length);
|
|
209
|
+
return exports.pvmStart(program, useSbrkGas) >>> 0;
|
|
210
|
+
},
|
|
211
|
+
pvmDestroy(pvmId) {
|
|
212
|
+
// assembly/api-utils/pvmDestroy(u32) => assembly/api-types/VmOutput | null
|
|
213
|
+
return __liftRecord50(exports.pvmDestroy(pvmId) >>> 0);
|
|
214
|
+
},
|
|
215
|
+
pvmSetRegisters(pvmId, registers) {
|
|
216
|
+
// assembly/api-utils/pvmSetRegisters(u32, ~lib/array/Array<u64>) => void
|
|
217
|
+
registers = __lowerArray(__setU64, 51, 3, registers) || __notnull();
|
|
218
|
+
exports.pvmSetRegisters(pvmId, registers);
|
|
219
|
+
},
|
|
220
|
+
pvmReadMemory(pvmId, address, length) {
|
|
221
|
+
// assembly/api-utils/pvmReadMemory(u32, u32, u32) => ~lib/typedarray/Uint8Array | null
|
|
222
|
+
return __liftTypedArray(Uint8Array, exports.pvmReadMemory(pvmId, address, length) >>> 0);
|
|
223
|
+
},
|
|
224
|
+
pvmWriteMemory(pvmId, address, data) {
|
|
225
|
+
// assembly/api-utils/pvmWriteMemory(u32, u32, ~lib/typedarray/Uint8Array) => bool
|
|
226
|
+
data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
|
|
227
|
+
return exports.pvmWriteMemory(pvmId, address, data) != 0;
|
|
187
228
|
},
|
|
188
|
-
|
|
189
|
-
// assembly/api-utils/
|
|
229
|
+
pvmResume(pvmId, gas, pc, logs) {
|
|
230
|
+
// assembly/api-utils/pvmResume(u32, i64, u32, bool?) => assembly/api-types/VmPause | null
|
|
190
231
|
gas = gas || 0n;
|
|
191
|
-
program = __retain(__lowerArray(__setU8, 6, 0, program) || __notnull());
|
|
192
|
-
args = __lowerArray(__setU8, 6, 0, args) || __notnull();
|
|
193
232
|
logs = logs ? 1 : 0;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
exports.__setArgumentsLength(arguments.length);
|
|
197
|
-
return __liftRecord58(exports.runJAM(pc, gas, program, args, logs, useSbrkGas) >>> 0);
|
|
198
|
-
} finally {
|
|
199
|
-
__release(program);
|
|
200
|
-
}
|
|
233
|
+
exports.__setArgumentsLength(arguments.length);
|
|
234
|
+
return __liftRecord59(exports.pvmResume(pvmId, gas, pc, logs) >>> 0);
|
|
201
235
|
},
|
|
202
236
|
wrapAsProgram(bytecode) {
|
|
203
237
|
// assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
|
|
@@ -205,50 +239,51 @@ async function instantiate(module, imports = {}) {
|
|
|
205
239
|
return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
|
|
206
240
|
},
|
|
207
241
|
}, exports);
|
|
208
|
-
function
|
|
209
|
-
// assembly/api-types/InitialChunk
|
|
210
|
-
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
211
|
-
if (!pointer) return null;
|
|
212
|
-
return {
|
|
213
|
-
address: __getU32(pointer + 0),
|
|
214
|
-
data: __liftArray(__getU8, 0, __getU32(pointer + 4)),
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
function __liftRecord49(pointer) {
|
|
218
|
-
// assembly/api-types/VmOutput
|
|
219
|
-
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
220
|
-
if (!pointer) return null;
|
|
221
|
-
return {
|
|
222
|
-
status: __getI32(pointer + 0),
|
|
223
|
-
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 4)),
|
|
224
|
-
pc: __getU32(pointer + 8),
|
|
225
|
-
memory: __liftArray(pointer => __liftRecord45(__getU32(pointer)), 2, __getU32(pointer + 12)),
|
|
226
|
-
gas: __getI64(pointer + 16),
|
|
227
|
-
exitCode: __getU32(pointer + 24),
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function __lowerRecord43(value) {
|
|
242
|
+
function __lowerRecord44(value) {
|
|
231
243
|
// assembly/api-types/InitialPage
|
|
232
244
|
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
233
245
|
if (value == null) return 0;
|
|
234
|
-
const pointer = exports.__pin(exports.__new(12,
|
|
246
|
+
const pointer = exports.__pin(exports.__new(12, 44));
|
|
235
247
|
__setU32(pointer + 0, value.address);
|
|
236
248
|
__setU32(pointer + 4, value.length);
|
|
237
249
|
__setU32(pointer + 8, value.access);
|
|
238
250
|
exports.__unpin(pointer);
|
|
239
251
|
return pointer;
|
|
240
252
|
}
|
|
241
|
-
function
|
|
253
|
+
function __lowerRecord46(value) {
|
|
242
254
|
// assembly/api-types/InitialChunk
|
|
243
255
|
// Hint: Opt-out from lowering as a record by providing an empty constructor
|
|
244
256
|
if (value == null) return 0;
|
|
245
|
-
const pointer = exports.__pin(exports.__new(8,
|
|
257
|
+
const pointer = exports.__pin(exports.__new(8, 46));
|
|
246
258
|
__setU32(pointer + 0, value.address);
|
|
247
259
|
__setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
|
|
248
260
|
exports.__unpin(pointer);
|
|
249
261
|
return pointer;
|
|
250
262
|
}
|
|
251
|
-
function
|
|
263
|
+
function __liftRecord46(pointer) {
|
|
264
|
+
// assembly/api-types/InitialChunk
|
|
265
|
+
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
266
|
+
if (!pointer) return null;
|
|
267
|
+
return {
|
|
268
|
+
address: __getU32(pointer + 0),
|
|
269
|
+
data: __liftArray(__getU8, 0, __getU32(pointer + 4)),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function __liftRecord50(pointer) {
|
|
273
|
+
// assembly/api-types/VmOutput
|
|
274
|
+
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
275
|
+
if (!pointer) return null;
|
|
276
|
+
return {
|
|
277
|
+
status: __getI32(pointer + 0),
|
|
278
|
+
exitCode: __getU32(pointer + 4),
|
|
279
|
+
pc: __getU32(pointer + 8),
|
|
280
|
+
gas: __getI64(pointer + 16),
|
|
281
|
+
result: __liftArray(__getU8, 0, __getU32(pointer + 24)),
|
|
282
|
+
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 28)),
|
|
283
|
+
memory: __liftArray(pointer => __liftRecord46(__getU32(pointer)), 2, __getU32(pointer + 32)),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function __liftRecord55(pointer) {
|
|
252
287
|
// assembly/gas-costs/BlockGasCost
|
|
253
288
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
254
289
|
if (!pointer) return null;
|
|
@@ -257,16 +292,17 @@ async function instantiate(module, imports = {}) {
|
|
|
257
292
|
gas: __getU64(pointer + 8),
|
|
258
293
|
};
|
|
259
294
|
}
|
|
260
|
-
function
|
|
261
|
-
// assembly/api-types/
|
|
295
|
+
function __liftRecord59(pointer) {
|
|
296
|
+
// assembly/api-types/VmPause
|
|
262
297
|
// Hint: Opt-out from lifting as a record by providing an empty constructor
|
|
263
298
|
if (!pointer) return null;
|
|
264
299
|
return {
|
|
265
300
|
status: __getI32(pointer + 0),
|
|
266
301
|
exitCode: __getU32(pointer + 4),
|
|
267
302
|
pc: __getU32(pointer + 8),
|
|
303
|
+
nextPc: __getU32(pointer + 12),
|
|
268
304
|
gas: __getI64(pointer + 16),
|
|
269
|
-
|
|
305
|
+
registers: __liftArray(pointer => BigInt.asUintN(64, __getU64(pointer)), 3, __getU32(pointer + 24)),
|
|
270
306
|
};
|
|
271
307
|
}
|
|
272
308
|
function __liftString(pointer) {
|
|
@@ -444,16 +480,23 @@ export const {
|
|
|
444
480
|
getMemory,
|
|
445
481
|
setMemory,
|
|
446
482
|
getAssembly,
|
|
447
|
-
runVm,
|
|
448
|
-
getOutputChunks,
|
|
449
483
|
buildMemory,
|
|
484
|
+
vmInit,
|
|
485
|
+
vmRunOnce,
|
|
486
|
+
vmExecute,
|
|
487
|
+
vmDestroy,
|
|
450
488
|
InputKind,
|
|
451
489
|
HasMetadata,
|
|
452
490
|
getGasCosts,
|
|
453
491
|
disassemble,
|
|
454
492
|
prepareProgram,
|
|
455
493
|
runProgram,
|
|
456
|
-
|
|
494
|
+
pvmStart,
|
|
495
|
+
pvmDestroy,
|
|
496
|
+
pvmSetRegisters,
|
|
497
|
+
pvmReadMemory,
|
|
498
|
+
pvmWriteMemory,
|
|
499
|
+
pvmResume,
|
|
457
500
|
wrapAsProgram,
|
|
458
501
|
} = await (async url => instantiate(
|
|
459
502
|
await (async () => {
|
package/dist/build/release.wasm
CHANGED
|
Binary file
|