@typeberry/lib 0.5.2-9afefa7 → 0.5.2-ab56433
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/package.json +1 -1
- package/packages/core/pvm-host-calls/bin.js +6 -6
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts +32 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.js +14 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts +139 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.js +209 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts +2 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.js +231 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts +2 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-memory.js +12 -2
- package/packages/core/pvm-host-calls/host-call-registers.d.ts +6 -0
- package/packages/core/pvm-host-calls/host-call-registers.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-registers.js +24 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts +31 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/host-calls-executor.js +137 -0
- package/packages/core/pvm-host-calls/host-calls.d.ts +20 -26
- package/packages/core/pvm-host-calls/host-calls.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-calls.js +40 -112
- package/packages/core/pvm-host-calls/index.d.ts +7 -6
- package/packages/core/pvm-host-calls/index.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/index.js +7 -6
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.d.ts → pvm-instance-manager.d.ts} +3 -3
- package/packages/core/pvm-host-calls/pvm-instance-manager.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.js → pvm-instance-manager.js} +2 -2
- package/packages/jam/safrole/bandersnatch-vrf.d.ts +2 -0
- package/packages/jam/safrole/bandersnatch-vrf.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-vrf.js +11 -0
- package/packages/jam/safrole/bandersnatch-wasm.d.ts +1 -0
- package/packages/jam/safrole/bandersnatch-wasm.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-wasm.js +3 -0
- package/packages/jam/safrole/safrole-seal.d.ts +1 -3
- package/packages/jam/safrole/safrole-seal.d.ts.map +1 -1
- package/packages/jam/safrole/safrole-seal.js +14 -25
- package/packages/jam/transition/accumulate/pvm-executor.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/pvm-executor.js +2 -2
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts +0 -23
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts.map +0 -1
- package/packages/core/pvm-host-calls/host-calls-manager.js +0 -44
- package/packages/core/pvm-host-calls/interpreter-instance-manager.d.ts.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type U64 } from "#@typeberry/numbers";
|
|
2
2
|
import type { IMemory, PageFault } from "#@typeberry/pvm-interface";
|
|
3
3
|
import { OK, Result } from "#@typeberry/utils";
|
|
4
|
+
import type { IoTracker } from "./ecalli-io-tracker.js";
|
|
4
5
|
export declare class HostCallMemory {
|
|
5
6
|
private readonly memory;
|
|
7
|
+
ioTracker: IoTracker | null;
|
|
6
8
|
constructor(memory: IMemory);
|
|
7
9
|
/**
|
|
8
10
|
* Save some bytes into memory under given address.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-call-memory.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-call-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"host-call-memory.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-call-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAF5B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAEb,MAAM,EAAE,OAAO;IAE5C;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC;IAgBpE;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC;CAerE"}
|
|
@@ -2,6 +2,8 @@ import { tryAsU32 } from "#@typeberry/numbers";
|
|
|
2
2
|
import { OK, Result } from "#@typeberry/utils";
|
|
3
3
|
export class HostCallMemory {
|
|
4
4
|
memory;
|
|
5
|
+
// Track successful memory reads and writes.
|
|
6
|
+
ioTracker = null;
|
|
5
7
|
constructor(memory) {
|
|
6
8
|
this.memory = memory;
|
|
7
9
|
}
|
|
@@ -19,7 +21,11 @@ export class HostCallMemory {
|
|
|
19
21
|
//
|
|
20
22
|
// https://graypaper.fluffylabs.dev/#/ab2cdbd/25ed0025ed00?v=0.7.2
|
|
21
23
|
const address = tryAsU32(Number(regAddress & 0xffffffffn));
|
|
22
|
-
|
|
24
|
+
const result = this.memory.store(address, bytes);
|
|
25
|
+
if (result.isOk && this.ioTracker !== null) {
|
|
26
|
+
this.ioTracker.memWrite(address, bytes);
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* Read some bytes from memory under given address.
|
|
@@ -35,6 +41,10 @@ export class HostCallMemory {
|
|
|
35
41
|
//
|
|
36
42
|
// NOTE we are taking the the lower U32 part of the register, hence it's safe.
|
|
37
43
|
const address = tryAsU32(Number(regAddress & 0xffffffffn));
|
|
38
|
-
|
|
44
|
+
const result = this.memory.read(address, output);
|
|
45
|
+
if (result.isOk && this.ioTracker !== null) {
|
|
46
|
+
this.ioTracker.memRead(address, output);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
39
49
|
}
|
|
40
50
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type U64 } from "#@typeberry/numbers";
|
|
2
|
+
import type { IoTracker } from "./ecalli-io-tracker.js";
|
|
2
3
|
export declare class HostCallRegisters {
|
|
3
4
|
private readonly bytes;
|
|
5
|
+
private readonly raw;
|
|
4
6
|
private readonly registers;
|
|
7
|
+
ioTracker: IoTracker | null;
|
|
5
8
|
constructor(bytes: Uint8Array);
|
|
6
9
|
/** Get U64 register value. */
|
|
7
10
|
get(registerIndex: number): U64;
|
|
@@ -9,5 +12,8 @@ export declare class HostCallRegisters {
|
|
|
9
12
|
set(registerIndex: number, value: U64): void;
|
|
10
13
|
/** Get all registers encoded into little-endian bytes. */
|
|
11
14
|
getEncoded(): Uint8Array;
|
|
15
|
+
/** Ovewrite all encoded registers. */
|
|
16
|
+
setEncoded(bytes: Uint8Array): void;
|
|
17
|
+
toString(): string;
|
|
12
18
|
}
|
|
13
19
|
//# sourceMappingURL=host-call-registers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-call-registers.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-call-registers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGxD,qBAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"host-call-registers.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-call-registers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAAa,iBAAiB;IAMhB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALlC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IAE9B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAEb,KAAK,EAAE,UAAU;IAK9C,8BAA8B;IAC9B,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG;IAI/B,8BAA8B;IAC9B,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAOrC,0DAA0D;IAC1D,UAAU,IAAI,UAAU;IAIxB,sCAAsC;IACtC,UAAU,CAAC,KAAK,EAAE,UAAU;IAK5B,QAAQ;CAWT"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { tryAsU64 } from "#@typeberry/numbers";
|
|
2
2
|
import { REGISTER_BYTE_SIZE } from "#@typeberry/pvm-interface";
|
|
3
|
+
import { check } from "#@typeberry/utils";
|
|
3
4
|
export class HostCallRegisters {
|
|
4
5
|
bytes;
|
|
6
|
+
raw;
|
|
5
7
|
registers;
|
|
8
|
+
// Track register modifications.
|
|
9
|
+
ioTracker = null;
|
|
6
10
|
constructor(bytes) {
|
|
7
11
|
this.bytes = bytes;
|
|
12
|
+
this.raw = bytes;
|
|
8
13
|
this.registers = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
9
14
|
}
|
|
10
15
|
/** Get U64 register value. */
|
|
@@ -14,9 +19,28 @@ export class HostCallRegisters {
|
|
|
14
19
|
/** Set U64 register value. */
|
|
15
20
|
set(registerIndex, value) {
|
|
16
21
|
this.registers.setBigUint64(registerIndex * REGISTER_BYTE_SIZE, value, true);
|
|
22
|
+
if (this.ioTracker !== null) {
|
|
23
|
+
this.ioTracker.setReg(registerIndex, value);
|
|
24
|
+
}
|
|
17
25
|
}
|
|
18
26
|
/** Get all registers encoded into little-endian bytes. */
|
|
19
27
|
getEncoded() {
|
|
20
28
|
return this.bytes;
|
|
21
29
|
}
|
|
30
|
+
/** Ovewrite all encoded registers. */
|
|
31
|
+
setEncoded(bytes) {
|
|
32
|
+
check `${bytes.length === this.raw.length} Invalid registers array: ${bytes.length} vs ${this.raw.length}`;
|
|
33
|
+
this.raw.set(bytes, 0);
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
const elementCount = this.raw.byteLength / REGISTER_BYTE_SIZE;
|
|
37
|
+
const values = new BigUint64Array(this.raw.buffer, this.raw.byteOffset, elementCount);
|
|
38
|
+
const entries = [];
|
|
39
|
+
for (const [idx, value] of values.entries()) {
|
|
40
|
+
if (value !== 0n) {
|
|
41
|
+
entries.push(`r${idx.toString().padStart(2, "0")}=${value.toString(16)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return entries.join(" ");
|
|
45
|
+
}
|
|
22
46
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Gas, Status } from "#@typeberry/pvm-interface";
|
|
2
|
+
import { EcalliTraceLogger } from "./ecalli-trace-logger.js";
|
|
3
|
+
import type { HostCalls } from "./host-calls.js";
|
|
4
|
+
import type { PvmInstanceManager } from "./pvm-instance-manager.js";
|
|
5
|
+
declare class ReturnValue {
|
|
6
|
+
consumedGas: Gas;
|
|
7
|
+
status: Status | null;
|
|
8
|
+
memorySlice: Uint8Array | null;
|
|
9
|
+
private constructor();
|
|
10
|
+
static fromStatus(consumedGas: Gas, status: Status): ReturnValue;
|
|
11
|
+
static fromMemorySlice(consumedGas: Gas, memorySlice: Uint8Array): ReturnValue;
|
|
12
|
+
hasMemorySlice(): this is this & {
|
|
13
|
+
status: null;
|
|
14
|
+
memorySlice: Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
hasStatus(): this is this & {
|
|
17
|
+
status: Status;
|
|
18
|
+
memorySlice: null;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare class HostCallsExecutor {
|
|
22
|
+
private pvmInstanceManager;
|
|
23
|
+
private hostCalls;
|
|
24
|
+
private ioTracer;
|
|
25
|
+
constructor(pvmInstanceManager: PvmInstanceManager, hostCalls: HostCalls, ioTracer?: EcalliTraceLogger | null);
|
|
26
|
+
private getReturnValue;
|
|
27
|
+
private execute;
|
|
28
|
+
runProgram(program: Uint8Array, args: Uint8Array, initialPc: number, initialGas: Gas): Promise<ReturnValue>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=host-calls-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-calls-executor.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-calls-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAM,WAAW;IAEN,WAAW,EAAE,GAAG;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI;IACrB,WAAW,EAAE,UAAU,GAAG,IAAI;IAHvC,OAAO;IAWP,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;IAIlD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU;IAIhE,cAAc,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,WAAW,EAAE,UAAU,CAAA;KAAE;IAI1E,SAAS,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,IAAI,CAAA;KAAE;CAGlE;AAED,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ;gBAFR,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,SAAS,EACpB,QAAQ,GAAE,iBAAiB,GAAG,IAAiC;IAGzE,OAAO,CAAC,cAAc;YAoCR,OAAO;IAiFf,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;CAWlH"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Status } from "#@typeberry/pvm-interface";
|
|
2
|
+
import { assertNever, check, safeAllocUint8Array } from "#@typeberry/utils";
|
|
3
|
+
import { EcalliTraceLogger } from "./ecalli-trace-logger.js";
|
|
4
|
+
import { PvmExecution, tryAsHostCallIndex } from "./host-call-handler.js";
|
|
5
|
+
import { HostCallMemory } from "./host-call-memory.js";
|
|
6
|
+
import { HostCallRegisters } from "./host-call-registers.js";
|
|
7
|
+
class ReturnValue {
|
|
8
|
+
consumedGas;
|
|
9
|
+
status;
|
|
10
|
+
memorySlice;
|
|
11
|
+
constructor(consumedGas, status, memorySlice) {
|
|
12
|
+
this.consumedGas = consumedGas;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.memorySlice = memorySlice;
|
|
15
|
+
check `
|
|
16
|
+
${(status === null && memorySlice !== null) || (status !== null && memorySlice === null)}
|
|
17
|
+
'status' and 'memorySlice' must not both be null or both be non-null — exactly one must be provided
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
static fromStatus(consumedGas, status) {
|
|
21
|
+
return new ReturnValue(consumedGas, status, null);
|
|
22
|
+
}
|
|
23
|
+
static fromMemorySlice(consumedGas, memorySlice) {
|
|
24
|
+
return new ReturnValue(consumedGas, null, memorySlice);
|
|
25
|
+
}
|
|
26
|
+
hasMemorySlice() {
|
|
27
|
+
return this.memorySlice instanceof Uint8Array && this.status === null;
|
|
28
|
+
}
|
|
29
|
+
hasStatus() {
|
|
30
|
+
return !this.hasMemorySlice();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class HostCallsExecutor {
|
|
34
|
+
pvmInstanceManager;
|
|
35
|
+
hostCalls;
|
|
36
|
+
ioTracer;
|
|
37
|
+
constructor(pvmInstanceManager, hostCalls, ioTracer = EcalliTraceLogger.create()) {
|
|
38
|
+
this.pvmInstanceManager = pvmInstanceManager;
|
|
39
|
+
this.hostCalls = hostCalls;
|
|
40
|
+
this.ioTracer = ioTracer;
|
|
41
|
+
}
|
|
42
|
+
getReturnValue(status, pvmInstance, registers, memory) {
|
|
43
|
+
const gasConsumed = pvmInstance.gas.used();
|
|
44
|
+
const pc = pvmInstance.getPC();
|
|
45
|
+
const gas = pvmInstance.gas.get();
|
|
46
|
+
if (status === Status.OOG) {
|
|
47
|
+
this.ioTracer?.logOog(pc, gas, registers);
|
|
48
|
+
return ReturnValue.fromStatus(gasConsumed, status);
|
|
49
|
+
}
|
|
50
|
+
if (status === Status.HALT) {
|
|
51
|
+
this.ioTracer?.logHalt(pc, gas, registers);
|
|
52
|
+
const address = registers.get(7);
|
|
53
|
+
const length = Number(registers.get(8) & 0xffffffffn);
|
|
54
|
+
const result = safeAllocUint8Array(length);
|
|
55
|
+
const loadResult = memory.loadInto(result, address);
|
|
56
|
+
if (loadResult.isError) {
|
|
57
|
+
return ReturnValue.fromMemorySlice(gasConsumed, new Uint8Array());
|
|
58
|
+
}
|
|
59
|
+
return ReturnValue.fromMemorySlice(gasConsumed, result);
|
|
60
|
+
}
|
|
61
|
+
this.ioTracer?.logPanic(pvmInstance.getExitParam() ?? 0, pc, gas, registers);
|
|
62
|
+
return ReturnValue.fromStatus(gasConsumed, Status.PANIC);
|
|
63
|
+
}
|
|
64
|
+
async execute(pvmInstance) {
|
|
65
|
+
const ioTracker = this.ioTracer?.tracker() ?? null;
|
|
66
|
+
const registers = new HostCallRegisters(pvmInstance.registers.getAllEncoded());
|
|
67
|
+
registers.ioTracker = ioTracker;
|
|
68
|
+
const memory = new HostCallMemory(pvmInstance.memory);
|
|
69
|
+
memory.ioTracker = ioTracker;
|
|
70
|
+
const gas = pvmInstance.gas;
|
|
71
|
+
// log start of execution (note the PVM initialisation should be logged already)
|
|
72
|
+
this.ioTracer?.logStart(pvmInstance.getPC(), pvmInstance.gas.get(), registers);
|
|
73
|
+
for (;;) {
|
|
74
|
+
// execute program as much as we can
|
|
75
|
+
pvmInstance.runProgram();
|
|
76
|
+
// and update the PVM state
|
|
77
|
+
registers.setEncoded(pvmInstance.registers.getAllEncoded());
|
|
78
|
+
const status = pvmInstance.getStatus();
|
|
79
|
+
const pc = pvmInstance.getPC();
|
|
80
|
+
const exitParam = pvmInstance.getExitParam() ?? -1;
|
|
81
|
+
if (status !== Status.HOST) {
|
|
82
|
+
return this.getReturnValue(status, pvmInstance, registers, memory);
|
|
83
|
+
}
|
|
84
|
+
// get the PVM state now
|
|
85
|
+
check `
|
|
86
|
+
${exitParam !== -1}
|
|
87
|
+
"We know that the exit param is not null, because the status is 'Status.HOST'
|
|
88
|
+
`;
|
|
89
|
+
const hostCallIndex = tryAsHostCallIndex(exitParam);
|
|
90
|
+
// retrieve the host call
|
|
91
|
+
const hostCall = this.hostCalls.get(hostCallIndex);
|
|
92
|
+
const basicGasCost = typeof hostCall.basicGasCost === "number" ? hostCall.basicGasCost : hostCall.basicGasCost(registers);
|
|
93
|
+
// calculate gas
|
|
94
|
+
const gasBefore = gas.get();
|
|
95
|
+
const underflow = gas.sub(basicGasCost);
|
|
96
|
+
const pcLog = `[PC: ${pc}]`;
|
|
97
|
+
if (underflow) {
|
|
98
|
+
const gasAfterBasicGas = gas.get();
|
|
99
|
+
this.hostCalls.traceHostCall(`${pcLog} OOG`, hostCallIndex, hostCall, registers, gasAfterBasicGas);
|
|
100
|
+
this.ioTracer?.logSetGas(gasAfterBasicGas);
|
|
101
|
+
return this.getReturnValue(Status.OOG, pvmInstance, registers, memory);
|
|
102
|
+
}
|
|
103
|
+
this.ioTracer?.logEcalli(hostCallIndex, pc, gasBefore, registers);
|
|
104
|
+
this.hostCalls.traceHostCall(`${pcLog} Invoking`, hostCallIndex, hostCall, registers, gasBefore);
|
|
105
|
+
ioTracker?.clear();
|
|
106
|
+
const result = await hostCall.execute(gas, registers, memory);
|
|
107
|
+
const gasAfter = gas.get();
|
|
108
|
+
this.ioTracer?.logHostActions(ioTracker, gasBefore, gasAfter);
|
|
109
|
+
this.hostCalls.traceHostCall(result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`, hostCallIndex, hostCall, registers, gasAfter);
|
|
110
|
+
pvmInstance.registers.setAllEncoded(registers.getEncoded());
|
|
111
|
+
if (result === PvmExecution.Halt) {
|
|
112
|
+
return this.getReturnValue(Status.HALT, pvmInstance, registers, memory);
|
|
113
|
+
}
|
|
114
|
+
if (result === PvmExecution.Panic) {
|
|
115
|
+
return this.getReturnValue(Status.PANIC, pvmInstance, registers, memory);
|
|
116
|
+
}
|
|
117
|
+
if (result === PvmExecution.OOG) {
|
|
118
|
+
return this.getReturnValue(Status.OOG, pvmInstance, registers, memory);
|
|
119
|
+
}
|
|
120
|
+
if (result === undefined) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
assertNever(result);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async runProgram(program, args, initialPc, initialGas) {
|
|
127
|
+
const pvmInstance = await this.pvmInstanceManager.getInstance();
|
|
128
|
+
pvmInstance.resetJam(program, args, initialPc, initialGas);
|
|
129
|
+
try {
|
|
130
|
+
this.ioTracer?.logProgram(program, args);
|
|
131
|
+
return await this.execute(pvmInstance);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this.pvmInstanceManager.releaseInstance(pvmInstance);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
import { type Gas
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
consumedGas: Gas;
|
|
6
|
-
status: Status | null;
|
|
7
|
-
memorySlice: Uint8Array | null;
|
|
8
|
-
private constructor();
|
|
9
|
-
static fromStatus(consumedGas: Gas, status: Status): ReturnValue;
|
|
10
|
-
static fromMemorySlice(consumedGas: Gas, memorySlice: Uint8Array): ReturnValue;
|
|
11
|
-
hasMemorySlice(): this is this & {
|
|
12
|
-
status: null;
|
|
13
|
-
memorySlice: Uint8Array;
|
|
14
|
-
};
|
|
15
|
-
hasStatus(): this is this & {
|
|
16
|
-
status: Status;
|
|
17
|
-
memorySlice: null;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
1
|
+
import { type Gas } from "#@typeberry/pvm-interface";
|
|
2
|
+
import { type HostCallHandler, type HostCallIndex, type PvmExecution } from "./host-call-handler.js";
|
|
3
|
+
import type { HostCallRegisters } from "./host-call-registers.js";
|
|
4
|
+
/** Container for all available host calls. */
|
|
20
5
|
export declare class HostCalls {
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
private readonly hostCalls;
|
|
7
|
+
private readonly missing;
|
|
8
|
+
constructor({ missing, handlers, }: {
|
|
9
|
+
missing: HostCallHandler;
|
|
10
|
+
handlers?: HostCallHandler[];
|
|
11
|
+
});
|
|
12
|
+
/** Get a host call by index. */
|
|
13
|
+
get(hostCallIndex: HostCallIndex): HostCallHandler;
|
|
14
|
+
traceHostCall(context: string, hostCallIndex: HostCallIndex, hostCallHandler: HostCallHandler, registers: HostCallRegisters, gas: Gas): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class NoopMissing implements HostCallHandler {
|
|
17
|
+
index: number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"HostCallIndex[U32]">;
|
|
18
|
+
basicGasCost: number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"SmallGas[U32]">;
|
|
19
|
+
currentServiceId: import("@typeberry/numbers").U32;
|
|
20
|
+
tracedRegisters: never[];
|
|
21
|
+
execute(): Promise<undefined | PvmExecution>;
|
|
27
22
|
}
|
|
28
|
-
export {};
|
|
29
23
|
//# sourceMappingURL=host-calls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-calls.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-calls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host-calls.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/host-calls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAiB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,8CAA8C;AAC9C,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IACvE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAEb,EACV,OAAO,EACP,QAAa,GACd,EAAE;QACD,OAAO,EAAE,eAAe,CAAC;QACzB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;KAC9B;IASD,gCAAgC;IAChC,GAAG,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe;IAIlD,aAAa,CACX,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAAG;CAkBX;AAED,qBAAa,WAAY,YAAW,eAAe;IACjD,KAAK,iIAAmC;IACxC,YAAY,4HAAoB;IAChC,gBAAgB,mCAAe;IAC/B,eAAe,UAAM;IAEf,OAAO,IAAI,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC;CAGnD"}
|
|
@@ -1,119 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
status;
|
|
9
|
-
memorySlice;
|
|
10
|
-
constructor(consumedGas, status, memorySlice) {
|
|
11
|
-
this.consumedGas = consumedGas;
|
|
12
|
-
this.status = status;
|
|
13
|
-
this.memorySlice = memorySlice;
|
|
14
|
-
check `
|
|
15
|
-
${(status === null && memorySlice !== null) || (status !== null && memorySlice === null)}
|
|
16
|
-
'status' and 'memorySlice' must not both be null or both be non-null — exactly one must be provided
|
|
17
|
-
`;
|
|
18
|
-
}
|
|
19
|
-
static fromStatus(consumedGas, status) {
|
|
20
|
-
return new ReturnValue(consumedGas, status, null);
|
|
21
|
-
}
|
|
22
|
-
static fromMemorySlice(consumedGas, memorySlice) {
|
|
23
|
-
return new ReturnValue(consumedGas, null, memorySlice);
|
|
24
|
-
}
|
|
25
|
-
hasMemorySlice() {
|
|
26
|
-
return this.memorySlice instanceof Uint8Array && this.status === null;
|
|
27
|
-
}
|
|
28
|
-
hasStatus() {
|
|
29
|
-
return !this.hasMemorySlice();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import { Level, Logger } from "#@typeberry/logger";
|
|
2
|
+
import { tryAsU32 } from "#@typeberry/numbers";
|
|
3
|
+
import { tryAsSmallGas } from "#@typeberry/pvm-interface";
|
|
4
|
+
import { check } from "#@typeberry/utils";
|
|
5
|
+
import { tryAsHostCallIndex, } from "./host-call-handler.js";
|
|
6
|
+
const logger = Logger.new(import.meta.filename, "host-calls-pvm");
|
|
7
|
+
/** Container for all available host calls. */
|
|
32
8
|
export class HostCalls {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const gasConsumed = pvmInstance.gas.used();
|
|
41
|
-
if (status === Status.OOG) {
|
|
42
|
-
return ReturnValue.fromStatus(gasConsumed, status);
|
|
43
|
-
}
|
|
44
|
-
if (status === Status.HALT) {
|
|
45
|
-
const regs = new HostCallRegisters(pvmInstance.registers.getAllEncoded());
|
|
46
|
-
const memory = new HostCallMemory(pvmInstance.memory);
|
|
47
|
-
const address = regs.get(7);
|
|
48
|
-
// NOTE we are taking the the lower U32 part of the register, hence it's safe.
|
|
49
|
-
const length = Number(regs.get(8) & 0xffffffffn);
|
|
50
|
-
const result = safeAllocUint8Array(length);
|
|
51
|
-
const loadResult = memory.loadInto(result, address);
|
|
52
|
-
if (loadResult.isError) {
|
|
53
|
-
return ReturnValue.fromMemorySlice(gasConsumed, new Uint8Array());
|
|
54
|
-
}
|
|
55
|
-
return ReturnValue.fromMemorySlice(gasConsumed, result);
|
|
9
|
+
hostCalls = new Map();
|
|
10
|
+
missing;
|
|
11
|
+
constructor({ missing, handlers = [], }) {
|
|
12
|
+
this.missing = missing;
|
|
13
|
+
for (const handler of handlers) {
|
|
14
|
+
check `${this.hostCalls.get(handler.index) === undefined} Overwriting host call handler at index ${handler.index}`;
|
|
15
|
+
this.hostCalls.set(handler.index, handler);
|
|
56
16
|
}
|
|
57
|
-
return ReturnValue.fromStatus(gasConsumed, Status.PANIC);
|
|
58
17
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let status = pvmInstance.getStatus();
|
|
63
|
-
if (status !== Status.HOST) {
|
|
64
|
-
return this.getReturnValue(status, pvmInstance);
|
|
65
|
-
}
|
|
66
|
-
check `
|
|
67
|
-
${pvmInstance.getExitParam() !== null}
|
|
68
|
-
"We know that the exit param is not null, because the status is 'Status.HOST'
|
|
69
|
-
`;
|
|
70
|
-
const hostCallIndex = pvmInstance.getExitParam() ?? -1;
|
|
71
|
-
const gas = pvmInstance.gas;
|
|
72
|
-
const regs = new HostCallRegisters(pvmInstance.registers.getAllEncoded());
|
|
73
|
-
const memory = new HostCallMemory(pvmInstance.memory);
|
|
74
|
-
const index = tryAsHostCallIndex(hostCallIndex);
|
|
75
|
-
const hostCall = this.hostCalls.get(index);
|
|
76
|
-
const gasBefore = gas.get();
|
|
77
|
-
// NOTE: `basicGasCost(regs)` function is for compatibility reasons: pre GP 0.7.2
|
|
78
|
-
const basicGasCost = typeof hostCall.basicGasCost === "number" ? hostCall.basicGasCost : hostCall.basicGasCost(regs);
|
|
79
|
-
const underflow = gas.sub(basicGasCost);
|
|
80
|
-
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
81
|
-
if (underflow) {
|
|
82
|
-
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
83
|
-
return ReturnValue.fromStatus(gas.used(), Status.OOG);
|
|
84
|
-
}
|
|
85
|
-
this.hostCalls.traceHostCall(`${pcLog} Invoking`, index, hostCall, regs, gasBefore);
|
|
86
|
-
const result = await hostCall.execute(gas, regs, memory);
|
|
87
|
-
this.hostCalls.traceHostCall(result === undefined ? `${pcLog} Result` : `${pcLog} Status(${PvmExecution[result]})`, index, hostCall, regs, gas.get());
|
|
88
|
-
pvmInstance.registers.setAllEncoded(regs.getEncoded());
|
|
89
|
-
if (result === PvmExecution.Halt) {
|
|
90
|
-
status = Status.HALT;
|
|
91
|
-
return this.getReturnValue(status, pvmInstance);
|
|
92
|
-
}
|
|
93
|
-
if (result === PvmExecution.Panic) {
|
|
94
|
-
status = Status.PANIC;
|
|
95
|
-
return this.getReturnValue(status, pvmInstance);
|
|
96
|
-
}
|
|
97
|
-
if (result === PvmExecution.OOG) {
|
|
98
|
-
status = Status.OOG;
|
|
99
|
-
return this.getReturnValue(status, pvmInstance);
|
|
100
|
-
}
|
|
101
|
-
if (result === undefined) {
|
|
102
|
-
pvmInstance.runProgram();
|
|
103
|
-
status = pvmInstance.getStatus();
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
assertNever(result);
|
|
107
|
-
}
|
|
18
|
+
/** Get a host call by index. */
|
|
19
|
+
get(hostCallIndex) {
|
|
20
|
+
return this.hostCalls.get(hostCallIndex) ?? this.missing;
|
|
108
21
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
return await this.execute(pvmInstance);
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
this.pvmInstanceManager.releaseInstance(pvmInstance);
|
|
22
|
+
traceHostCall(context, hostCallIndex, hostCallHandler, registers, gas) {
|
|
23
|
+
if (logger.getLevel() > Level.INSANE) {
|
|
24
|
+
return;
|
|
117
25
|
}
|
|
26
|
+
const { currentServiceId } = hostCallHandler;
|
|
27
|
+
const requested = hostCallIndex !== hostCallHandler.index ? ` (${hostCallIndex})` : "";
|
|
28
|
+
const name = `${hostCallHandler.constructor.name}:${hostCallHandler.index}`;
|
|
29
|
+
const registerValues = hostCallHandler.tracedRegisters
|
|
30
|
+
.map((idx) => [idx.toString().padStart(2, "0"), registers.get(idx)])
|
|
31
|
+
.filter((v) => v[1] !== 0n)
|
|
32
|
+
.map(([idx, value]) => {
|
|
33
|
+
return `r${idx}=${value} (0x${value.toString(16)})`;
|
|
34
|
+
})
|
|
35
|
+
.join(", ");
|
|
36
|
+
logger.insane `[${currentServiceId}] ${context} ${name}${requested}. Gas: ${gas}. Regs: ${registerValues}.`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class NoopMissing {
|
|
40
|
+
index = tryAsHostCallIndex(2 ** 32 - 1);
|
|
41
|
+
basicGasCost = tryAsSmallGas(0);
|
|
42
|
+
currentServiceId = tryAsU32(0);
|
|
43
|
+
tracedRegisters = [];
|
|
44
|
+
async execute() {
|
|
45
|
+
return;
|
|
118
46
|
}
|
|
119
47
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export * from "./ecalli-trace-logger.js";
|
|
2
|
+
export * from "./host-call-handler.js";
|
|
3
|
+
export * from "./host-call-memory.js";
|
|
4
|
+
export * from "./host-call-registers.js";
|
|
5
|
+
export * from "./host-calls.js";
|
|
6
|
+
export * from "./host-calls-executor.js";
|
|
7
|
+
export * from "./pvm-instance-manager.js";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export * from "./ecalli-trace-logger.js";
|
|
2
|
+
export * from "./host-call-handler.js";
|
|
3
|
+
export * from "./host-call-memory.js";
|
|
4
|
+
export * from "./host-call-registers.js";
|
|
5
|
+
export * from "./host-calls.js";
|
|
6
|
+
export * from "./host-calls-executor.js";
|
|
7
|
+
export * from "./pvm-instance-manager.js";
|
package/packages/core/pvm-host-calls/{interpreter-instance-manager.d.ts → pvm-instance-manager.d.ts}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PvmBackend } from "#@typeberry/config";
|
|
2
2
|
import type { IPvmInterpreter } from "#@typeberry/pvm-interface";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class PvmInstanceManager {
|
|
4
4
|
private readonly instances;
|
|
5
5
|
private waitingQueue;
|
|
6
6
|
private constructor();
|
|
7
|
-
static new(interpreter: PvmBackend): Promise<
|
|
7
|
+
static new(interpreter: PvmBackend): Promise<PvmInstanceManager>;
|
|
8
8
|
getInstance(): Promise<IPvmInterpreter>;
|
|
9
9
|
releaseInstance(pvm: IPvmInterpreter): void;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=pvm-instance-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pvm-instance-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/core/pvm-host-calls/pvm-instance-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQhE,qBAAa,kBAAkB;IAGT,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF9C,OAAO,CAAC,YAAY,CAAmB;IAEvC,OAAO;WAEM,GAAG,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAmBhE,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAU7C,eAAe,CAAC,GAAG,EAAE,eAAe;CAOrC"}
|
package/packages/core/pvm-host-calls/{interpreter-instance-manager.js → pvm-instance-manager.js}
RENAMED
|
@@ -3,7 +3,7 @@ import { Interpreter } from "#@typeberry/pvm-interpreter";
|
|
|
3
3
|
import { AnanasInterpreter } from "#@typeberry/pvm-interpreter-ananas";
|
|
4
4
|
import { assertNever } from "#@typeberry/utils";
|
|
5
5
|
// TODO [MaSo] Delete this & also make host calls independent from intepreters.
|
|
6
|
-
export class
|
|
6
|
+
export class PvmInstanceManager {
|
|
7
7
|
instances;
|
|
8
8
|
waitingQueue = [];
|
|
9
9
|
constructor(instances) {
|
|
@@ -23,7 +23,7 @@ export class InterpreterInstanceManager {
|
|
|
23
23
|
default:
|
|
24
24
|
assertNever(interpreter);
|
|
25
25
|
}
|
|
26
|
-
return new
|
|
26
|
+
return new PvmInstanceManager(instances);
|
|
27
27
|
}
|
|
28
28
|
async getInstance() {
|
|
29
29
|
const instance = this.instances.pop();
|
|
@@ -8,12 +8,14 @@ import { type Opaque, Result } from "#@typeberry/utils";
|
|
|
8
8
|
import type { BandernsatchWasm } from "./bandersnatch-wasm.js";
|
|
9
9
|
declare const FUNCTIONS: {
|
|
10
10
|
verifySeal: typeof verifySeal;
|
|
11
|
+
verifyHeaderSeals: typeof verifyHeaderSeals;
|
|
11
12
|
verifyTickets: typeof verifyTickets;
|
|
12
13
|
getRingCommitment: typeof getRingCommitment;
|
|
13
14
|
generateSeal: typeof generateSeal;
|
|
14
15
|
getVrfOutputHash: typeof getVrfOutputHash;
|
|
15
16
|
};
|
|
16
17
|
export default FUNCTIONS;
|
|
18
|
+
declare function verifyHeaderSeals(bandersnatch: BandernsatchWasm, authorKey: BandersnatchKey, signature: BandersnatchVrfSignature, payload: BytesBlob, encodedUnsealedHeader: BytesBlob, entropySignature: BandersnatchVrfSignature, entropyPayloadPrefix: BytesBlob): Promise<Result<[EntropyHash, EntropyHash], null>>;
|
|
17
19
|
declare function verifySeal(bandersnatch: BandernsatchWasm, authorKey: BandersnatchKey, signature: BandersnatchVrfSignature, payload: BytesBlob, encodedUnsealedHeader: BytesBlob): Promise<Result<EntropyHash, null>>;
|
|
18
20
|
declare function getRingCommitment(bandersnatch: BandernsatchWasm, validators: BandersnatchKey[]): Promise<Result<BandersnatchRingRoot, null>>;
|
|
19
21
|
declare function verifyTickets(bandersnatch: BandernsatchWasm, numberOfValidators: number, epochRoot: BandersnatchRingRoot, tickets: readonly SignedTicket[], entropy: EntropyHash): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bandersnatch-vrf.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/safrole/bandersnatch-vrf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAS,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAwB/D,QAAA,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"bandersnatch-vrf.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/safrole/bandersnatch-vrf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAS,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAwB/D,QAAA,MAAM,SAAS;;;;;;;CAOd,CAAC;AAKF,eAAe,SAAS,CAAC;AAEzB,iBAAe,iBAAiB,CAC9B,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,wBAAwB,EACnC,OAAO,EAAE,SAAS,EAClB,qBAAqB,EAAE,SAAS,EAChC,gBAAgB,EAAE,wBAAwB,EAC1C,oBAAoB,EAAE,SAAS,GAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAkBnD;AAED,iBAAe,UAAU,CACvB,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,wBAAwB,EACnC,OAAO,EAAE,SAAS,EAClB,qBAAqB,EAAE,SAAS,GAC/B,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAapC;AAED,iBAAS,iBAAiB,CACxB,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAE,eAAe,EAAE,GAC5B,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAmB7C;AAkBD,iBAAe,aAAa,CAC1B,YAAY,EAAE,gBAAgB,EAC9B,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,EAAE,CAAC,CAqB3D;AAED,iBAAe,YAAY,CACzB,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE,sBAAsB,EACjC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAQjD;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAElE,iBAAe,gBAAgB,CAC7B,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE,sBAAsB,EACjC,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,CAQtC"}
|