@typeberry/lib 0.5.10-6cb1bd5 → 0.5.10-cf84e93
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/codec/encoder.d.ts +1 -1
- package/packages/core/codec/encoder.d.ts.map +1 -1
- package/packages/core/codec/encoder.js +3 -2
- package/packages/jam/executor/pvm-executor.d.ts +2 -2
- package/packages/jam/executor/pvm-executor.d.ts.map +1 -1
- package/packages/jam/in-core/in-core.d.ts.map +1 -1
- package/packages/jam/in-core/in-core.js +2 -5
- package/packages/jam/jam-host-calls/general/fetch.d.ts +159 -98
- package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/general/fetch.js +110 -16
- package/packages/jam/jam-host-calls/general/fetch.test.js +87 -56
- package/packages/jam/transition/accumulate/accumulate.js +2 -2
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.d.ts +19 -0
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.d.ts.map +1 -0
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.js +45 -0
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.test.d.ts +2 -0
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.test.d.ts.map +1 -0
- package/packages/jam/transition/externalities/accumulate-fetch-externalities.test.js +192 -0
- package/packages/jam/transition/externalities/fetch-externalities.d.ts +3 -39
- package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/fetch-externalities.js +2 -88
- package/packages/jam/transition/externalities/index.d.ts +2 -0
- package/packages/jam/transition/externalities/index.d.ts.map +1 -1
- package/packages/jam/transition/externalities/index.js +2 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.d.ts +23 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.d.ts.map +1 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.js +48 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.test.d.ts +2 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.test.d.ts.map +1 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.test.js +32 -0
- package/packages/jam/transition/externalities/fetch-externalities.test.d.ts +0 -2
- package/packages/jam/transition/externalities/fetch-externalities.test.d.ts.map +0 -1
- package/packages/jam/transition/externalities/fetch-externalities.test.js +0 -254
package/package.json
CHANGED
|
@@ -125,7 +125,7 @@ export declare class Encoder {
|
|
|
125
125
|
*/
|
|
126
126
|
i8(num: number): void;
|
|
127
127
|
/**
|
|
128
|
-
* Encode a single boolean discriminator using
|
|
128
|
+
* Encode a single boolean discriminator using 1-byte encoding.
|
|
129
129
|
*
|
|
130
130
|
* https://graypaper.fluffylabs.dev/#/579bd12/375300375300
|
|
131
131
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../../../packages/core/codec/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../../../packages/core/codec/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAIxD,mDAAmD;AACnD,MAAM,MAAM,QAAQ,GAAG;IACrB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAAE,Q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CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE;IAM3D,OAAO,CAAC,aAAa;IAOrB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;CA8BxB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
2
2
|
import { tryAsU32 } from "#@typeberry/numbers";
|
|
3
3
|
import { check } from "#@typeberry/utils";
|
|
4
|
+
import { tryAsU8 } from "../numbers/index.js";
|
|
4
5
|
export function tryAsExactBytes(a) {
|
|
5
6
|
check `${a.isExact} The value is not exact size estimation!`;
|
|
6
7
|
return a.bytes;
|
|
@@ -150,12 +151,12 @@ export class Encoder {
|
|
|
150
151
|
this.offset += 1;
|
|
151
152
|
}
|
|
152
153
|
/**
|
|
153
|
-
* Encode a single boolean discriminator using
|
|
154
|
+
* Encode a single boolean discriminator using 1-byte encoding.
|
|
154
155
|
*
|
|
155
156
|
* https://graypaper.fluffylabs.dev/#/579bd12/375300375300
|
|
156
157
|
*/
|
|
157
158
|
bool(bool) {
|
|
158
|
-
this.
|
|
159
|
+
this.i8(tryAsU8(bool ? 1 : 0));
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
161
162
|
* Prepare for encoding of a fixed-bytes number.
|
|
@@ -6,11 +6,11 @@ import type { PartialState } from "#@typeberry/jam-host-calls/externalities/part
|
|
|
6
6
|
import { type RefineExternalities } from "#@typeberry/jam-host-calls/externalities/refine-externalities.js";
|
|
7
7
|
export type RefineHostCallExternalities = {
|
|
8
8
|
refine: RefineExternalities;
|
|
9
|
-
fetchExternalities: general.
|
|
9
|
+
fetchExternalities: general.IRefineFetch;
|
|
10
10
|
};
|
|
11
11
|
export type AccumulateHostCallExternalities = {
|
|
12
12
|
partialState: PartialState;
|
|
13
|
-
fetchExternalities: general.
|
|
13
|
+
fetchExternalities: general.IAccumulateFetch;
|
|
14
14
|
serviceExternalities: general.AccountsInfo & general.AccountsLookup & general.AccountsWrite & general.AccountsRead;
|
|
15
15
|
};
|
|
16
16
|
type OnTransferHostCallExternalities = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pvm-executor.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/executor/pvm-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAc,OAAO,EAAU,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAC7F,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,iEAAiE,CAAC;AAuCzE,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,kBAAkB,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"pvm-executor.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/executor/pvm-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAc,OAAO,EAAU,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAC7F,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,iEAAiE,CAAC;AAuCzE,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,k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MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAgBF,qBAAa,MAAM;aAEC,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHR,SAAS,EAAE,SAAS,EACnB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO;IAGnC;;;;;;;;;OASG;IACG,MAAM,CACV,kBAAkB,EAAE,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,EAC1D,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,EACvC,UAAU,EAAE,WAAW,CAAC,iBAAiB,EAAE,CAAC,GAC3C,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAgF7C,OAAO,CAAC,oBAAoB;YAuDd,gBAAgB;YAkBhB,UAAU;IAoGxB,iBAAiB,CAAC,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;IAiBrD,OAAO,CAAC,cAAc;IAyCtB,OAAO,CAAC,yBAAyB;CAqBlC"}
|
|
@@ -10,7 +10,7 @@ import { PvmExecutor, ReturnStatus } from "#@typeberry/executor";
|
|
|
10
10
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
11
11
|
import { Logger } from "#@typeberry/logger";
|
|
12
12
|
import { tryAsU8, tryAsU16, tryAsU32 } from "#@typeberry/numbers";
|
|
13
|
-
import {
|
|
13
|
+
import { RefineFetchExternalities } from "#@typeberry/transition/externalities/refine-fetch-externalities.js";
|
|
14
14
|
import { assertEmpty, assertNever, Result } from "#@typeberry/utils";
|
|
15
15
|
import { RefineExternalitiesImpl } from "./externalities/refine.js";
|
|
16
16
|
export var RefineError;
|
|
@@ -286,10 +286,7 @@ export class InCore {
|
|
|
286
286
|
}
|
|
287
287
|
createRefineExternalities(args) {
|
|
288
288
|
// TODO [ToDr] Pass all required fetch data
|
|
289
|
-
const fetchExternalities =
|
|
290
|
-
entropy: undefined,
|
|
291
|
-
...args,
|
|
292
|
-
}, this.chainSpec);
|
|
289
|
+
const fetchExternalities = new RefineFetchExternalities(this.chainSpec);
|
|
293
290
|
const refine = RefineExternalitiesImpl.create({
|
|
294
291
|
currentServiceId: args.currentServiceId,
|
|
295
292
|
lookupState: args.lookupState,
|
|
@@ -1,168 +1,229 @@
|
|
|
1
|
-
import type { ServiceId } from "#@typeberry/block";
|
|
1
|
+
import type { EntropyHash, ServiceId } from "#@typeberry/block";
|
|
2
2
|
import type { BytesBlob } from "#@typeberry/bytes";
|
|
3
3
|
import { type U64 } from "#@typeberry/numbers";
|
|
4
4
|
import type { HostCallHandler, HostCallMemory, HostCallRegisters } from "#@typeberry/pvm-host-calls";
|
|
5
5
|
import { PvmExecution } from "#@typeberry/pvm-host-calls";
|
|
6
6
|
import { type IGasCounter } from "#@typeberry/pvm-interface";
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Fetchable data contexts.
|
|
9
|
+
*
|
|
10
|
+
* The fetch host call (ecalli 1) returns context-dependent data based on
|
|
11
|
+
* ω₁₀ (the kind selector). Each invocation context passes different
|
|
12
|
+
* parameters to Ω_Y, which determines which kinds return data vs NONE.
|
|
13
|
+
*
|
|
14
|
+
* Ω_Y signature: Ω_Y(ρ, φ, μ, p, n, r, i, ī, x̄, 𝐢, ...)
|
|
15
|
+
*
|
|
16
|
+
* Context parameter mapping
|
|
17
|
+
* Is-Authorized: Ω_Y(ρ, φ, μ, 𝐩, ∅, ∅, ∅, ∅, ∅, ∅, ∅)
|
|
18
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2e43012e4301?v=0.7.2
|
|
19
|
+
* Refine: Ω_Y(ρ, φ, μ, p, H₀, r, i, ī, x̄, ∅, (m,e))
|
|
20
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fe0012fe001?v=0.7.2
|
|
21
|
+
* Accumulate: Ω_Y(ρ, φ, μ, ∅, η'₀, ∅, ∅, ∅, ∅, 𝐢, (x,y))
|
|
22
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/30c00030c000?v=0.7.2
|
|
23
|
+
*
|
|
24
|
+
* Kind availability per context:
|
|
25
|
+
* Kind 0 (constants) — all contexts
|
|
26
|
+
* Kind 1 (n) — Refine (H₀), Accumulate (η'₀)
|
|
27
|
+
* Kind 2 (r) — Refine only
|
|
28
|
+
* Kind 3-4 (x̄ extrinsics) — Refine only
|
|
29
|
+
* Kind 5-6 (ī imports) — Refine only
|
|
30
|
+
* Kind 7-13 (p work pkg) — Is-Authorized, Refine
|
|
31
|
+
* Kind 14-15 (𝐢 acc items) — Accumulate only
|
|
32
|
+
*/
|
|
33
|
+
export declare enum FetchContext {
|
|
34
|
+
IsAuthorized = "isAuthorized",
|
|
35
|
+
Refine = "refine",
|
|
36
|
+
Accumulate = "accumulate"
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetch externalities for the Is-Authorized context.
|
|
40
|
+
*
|
|
41
|
+
* Ω_Y(ρ, φ, μ, 𝐩, ∅, ∅, ∅, ∅, ∅, ∅, ∅)
|
|
42
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2e43012e4301?v=0.7.2
|
|
43
|
+
*
|
|
44
|
+
* Available kinds: 0 (constants), 7-13 (work package)
|
|
45
|
+
*/
|
|
46
|
+
export interface IIsAuthorizedFetch {
|
|
47
|
+
readonly context: FetchContext.IsAuthorized;
|
|
9
48
|
/**
|
|
10
|
-
* Encoded constants info.
|
|
49
|
+
* Kind 0: Encoded constants info (𝐜).
|
|
11
50
|
*
|
|
12
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
51
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315001315001?v=0.7.2
|
|
13
52
|
*/
|
|
14
53
|
constants(): BytesBlob;
|
|
15
54
|
/**
|
|
16
|
-
*
|
|
55
|
+
* Kind 7: Encoded work package — E(𝐩).
|
|
56
|
+
*
|
|
57
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c10231c102?v=0.7.2
|
|
58
|
+
*/
|
|
59
|
+
workPackage(): BytesBlob | null;
|
|
60
|
+
/**
|
|
61
|
+
* Kind 8: Authorizer code hash and config — p_f.
|
|
62
|
+
*
|
|
63
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c80231c802?v=0.7.2
|
|
64
|
+
*/
|
|
65
|
+
authorizer(): BytesBlob | null;
|
|
66
|
+
/**
|
|
67
|
+
* Kind 9: Authorization token — p_j.
|
|
68
|
+
*
|
|
69
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31cf0231cf02?v=0.7.2
|
|
70
|
+
*/
|
|
71
|
+
authorizationToken(): BytesBlob | null;
|
|
72
|
+
/**
|
|
73
|
+
* Kind 10: Refinement context — E(p_x).
|
|
74
|
+
*
|
|
75
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31da0231da02?v=0.7.2
|
|
76
|
+
*/
|
|
77
|
+
refineContext(): BytesBlob | null;
|
|
78
|
+
/**
|
|
79
|
+
* Kind 11: All work-item summaries — E(↕[S(w) | w ← p_w]).
|
|
17
80
|
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
81
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31f40231f402?v=0.7.2
|
|
82
|
+
*/
|
|
83
|
+
allWorkItems(): BytesBlob | null;
|
|
84
|
+
/**
|
|
85
|
+
* Kind 12: Single work-item summary — S(p_w[φ₁₁]).
|
|
86
|
+
*
|
|
87
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31fc0231fc02?v=0.7.2
|
|
88
|
+
*/
|
|
89
|
+
oneWorkItem(workItem: U64): BytesBlob | null;
|
|
90
|
+
/**
|
|
91
|
+
* Kind 13: Work-item payload — p_w[φ₁₁]_y.
|
|
22
92
|
*
|
|
23
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
93
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/313b03313b03?v=0.7.2
|
|
24
94
|
*/
|
|
25
|
-
|
|
95
|
+
workItemPayload(workItem: U64): BytesBlob | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Fetch externalities for the Refine context.
|
|
99
|
+
*
|
|
100
|
+
* Ω_Y(ρ, φ, μ, p, H₀, r, i, ī, x̄, ∅, (m,e))
|
|
101
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fe0012fe001?v=0.7.2
|
|
102
|
+
*
|
|
103
|
+
* Available kinds: 0-13 (all except accumulation items)
|
|
104
|
+
*/
|
|
105
|
+
export interface IRefineFetch {
|
|
106
|
+
readonly context: FetchContext.Refine;
|
|
26
107
|
/**
|
|
108
|
+
* Kind 0: Encoded constants info (𝐜).
|
|
27
109
|
*
|
|
28
|
-
*
|
|
110
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315001315001?v=0.7.2
|
|
111
|
+
*/
|
|
112
|
+
constants(): BytesBlob;
|
|
113
|
+
/**
|
|
114
|
+
* Kind 1: Entropy pool — H₀ (zero hash).
|
|
29
115
|
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
116
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fe0012fe201?v=0.7.2
|
|
117
|
+
*/
|
|
118
|
+
entropy(): EntropyHash;
|
|
119
|
+
/**
|
|
120
|
+
* Kind 2: Authorizer trace (𝐫).
|
|
34
121
|
*
|
|
35
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
122
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314902314902?v=0.7.2
|
|
36
123
|
*/
|
|
37
124
|
authorizerTrace(): BytesBlob | null;
|
|
38
125
|
/**
|
|
39
|
-
*
|
|
126
|
+
* Kind 3 (other) / Kind 4 (my): Work-item extrinsics (x̄).
|
|
40
127
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/2fd8002fd800?v=0.6.6
|
|
44
|
-
* Accumulate: <empty>
|
|
45
|
-
* On Transfer: <empty>
|
|
128
|
+
* When workItem is null, uses Kind 4 (current work item's extrinsics).
|
|
129
|
+
* When workItem is provided, uses Kind 3 (other work item's extrinsics).
|
|
46
130
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
131
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315402315402?v=0.7.2
|
|
132
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/317302317302?v=0.7.2
|
|
49
133
|
*/
|
|
50
134
|
workItemExtrinsic(workItem: U64 | null, index: U64): BytesBlob | null;
|
|
51
135
|
/**
|
|
52
|
-
*
|
|
136
|
+
* Kind 5 (other) / Kind 6 (my): Import segments (ī).
|
|
53
137
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/2e15012e1501?v=0.6.6
|
|
57
|
-
* Accumulate: <empty>
|
|
58
|
-
* On Transfer: <empty>
|
|
138
|
+
* When workItem is null, uses Kind 6 (current work item's imports).
|
|
139
|
+
* When workItem is provided, uses Kind 5 (other work item's imports).
|
|
59
140
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
141
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/318b02318b02?v=0.7.2
|
|
142
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31aa0231aa02?v=0.7.2
|
|
62
143
|
*/
|
|
63
144
|
workItemImport(workItem: U64 | null, index: U64): BytesBlob | null;
|
|
64
145
|
/**
|
|
65
|
-
*
|
|
146
|
+
* Kind 7: Encoded work package — E(p).
|
|
66
147
|
*
|
|
67
|
-
*
|
|
68
|
-
* Refine: `E(p)`
|
|
69
|
-
* Accumulate: <empty>
|
|
70
|
-
* On Transfer: <empty>
|
|
71
|
-
*
|
|
72
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/329f0132a201?v=0.6.6
|
|
148
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c10231c102?v=0.7.2
|
|
73
149
|
*/
|
|
74
150
|
workPackage(): BytesBlob | null;
|
|
75
151
|
/**
|
|
76
|
-
*
|
|
77
|
-
* authorizer code hash (`u`) and parametrization (`p`).
|
|
78
|
-
*
|
|
79
|
-
* Is Authorized: <empty>
|
|
80
|
-
* Refine: `E(p_u, ↕p_p)`
|
|
81
|
-
* Accumulate: <empty>
|
|
82
|
-
* On Transfer: <empty>
|
|
152
|
+
* Kind 8: Authorizer code hash and config — p_f.
|
|
83
153
|
*
|
|
84
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
154
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c80231c802?v=0.7.2
|
|
85
155
|
*/
|
|
86
156
|
authorizer(): BytesBlob | null;
|
|
87
157
|
/**
|
|
88
|
-
*
|
|
158
|
+
* Kind 9: Authorization token — p_j.
|
|
89
159
|
*
|
|
90
|
-
*
|
|
91
|
-
* Refine: `p_j`
|
|
92
|
-
* Accumulate: <empty>
|
|
93
|
-
* On Transfer: <empty>
|
|
94
|
-
*
|
|
95
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/32b10132b101?v=0.6.6
|
|
160
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31cf0231cf02?v=0.7.2
|
|
96
161
|
*/
|
|
97
162
|
authorizationToken(): BytesBlob | null;
|
|
98
163
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* Is Authorized: <empty>
|
|
102
|
-
* Refine: `p_x`
|
|
103
|
-
* Accumulate: <empty>
|
|
104
|
-
* On Transfer: <empty>
|
|
164
|
+
* Kind 10: Refinement context — E(p_x).
|
|
105
165
|
*
|
|
106
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
166
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31da0231da02?v=0.7.2
|
|
107
167
|
*/
|
|
108
168
|
refineContext(): BytesBlob | null;
|
|
109
169
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* Is Authorized: <empty>
|
|
113
|
-
* Refine: `E(↕[S(w): w <- p_w ]))`
|
|
114
|
-
* `S(w)`: https://graypaper.fluffylabs.dev/#/9a08063/32db0132ea01?v=0.6.6
|
|
115
|
-
* Accumulate: <empty>
|
|
116
|
-
* On Transfer: <empty>
|
|
170
|
+
* Kind 11: All work-item summaries — E(↕[S(w) | w ← p_w]).
|
|
117
171
|
*
|
|
118
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
172
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31f40231f402?v=0.7.2
|
|
119
173
|
*/
|
|
120
174
|
allWorkItems(): BytesBlob | null;
|
|
121
175
|
/**
|
|
122
|
-
*
|
|
123
|
-
* `S(w)`: https://graypaper.fluffylabs.dev/#/9a08063/32db0132ea01?v=0.6.6
|
|
176
|
+
* Kind 12: Single work-item summary — S(p_w[φ₁₁]).
|
|
124
177
|
*
|
|
125
|
-
*
|
|
126
|
-
* Refine: `S(w)`
|
|
127
|
-
* `S(w)`: https://graypaper.fluffylabs.dev/#/9a08063/32db0132ea01?v=0.6.6
|
|
128
|
-
* Accumulate: <empty>
|
|
129
|
-
* On Transfer: <empty>
|
|
130
|
-
*
|
|
131
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/32d50132d501?v=0.6.6
|
|
178
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31fc0231fc02?v=0.7.2
|
|
132
179
|
*/
|
|
133
180
|
oneWorkItem(workItem: U64): BytesBlob | null;
|
|
134
181
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* Is Authorized: <empty>
|
|
138
|
-
* Refine: `p_w[omega_11]_y`
|
|
139
|
-
* Accumulate: <empty>
|
|
140
|
-
* On Transfer: <empty>
|
|
182
|
+
* Kind 13: Work-item payload — p_w[φ₁₁]_y.
|
|
141
183
|
*
|
|
142
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
184
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/313b03313b03?v=0.7.2
|
|
143
185
|
*/
|
|
144
186
|
workItemPayload(workItem: U64): BytesBlob | null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Fetch externalities for the Accumulate context.
|
|
190
|
+
*
|
|
191
|
+
* Ω_Y(ρ, φ, μ, ∅, η'₀, ∅, ∅, ∅, ∅, 𝐢, (x,y))
|
|
192
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/30c00030c000?v=0.7.2
|
|
193
|
+
*
|
|
194
|
+
* Available kinds: 0 (constants), 1 (entropy), 14-15 (accumulation items)
|
|
195
|
+
*/
|
|
196
|
+
export interface IAccumulateFetch {
|
|
197
|
+
readonly context: FetchContext.Accumulate;
|
|
198
|
+
/**
|
|
199
|
+
* Kind 0: Encoded constants info (𝐜).
|
|
200
|
+
*
|
|
201
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315001315001?v=0.7.2
|
|
202
|
+
*/
|
|
203
|
+
constants(): BytesBlob;
|
|
145
204
|
/**
|
|
146
|
-
*
|
|
205
|
+
* Kind 1: Entropy pool — η'₀ (posterior entropy).
|
|
147
206
|
*
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
207
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314302314602?v=0.7.2
|
|
208
|
+
*/
|
|
209
|
+
entropy(): EntropyHash;
|
|
210
|
+
/**
|
|
211
|
+
* Kind 14: All accumulation operands and transfers — E(↕𝐢).
|
|
151
212
|
*
|
|
152
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/
|
|
213
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314e03314e03?v=0.7.2
|
|
153
214
|
*/
|
|
154
215
|
allTransfersAndOperands(): BytesBlob | null;
|
|
155
216
|
/**
|
|
156
|
-
*
|
|
217
|
+
* Kind 15: Single accumulation operand or transfer — E(𝐢[φ₁₁]).
|
|
157
218
|
*
|
|
158
|
-
*
|
|
159
|
-
* Refine: <empty>
|
|
160
|
-
* Accumulate: `E(i[omega_11])`
|
|
161
|
-
*
|
|
162
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315503315503?v=0.7.2
|
|
219
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315903315903?v=0.7.2
|
|
163
220
|
*/
|
|
164
221
|
oneTransferOrOperand(index: U64): BytesBlob | null;
|
|
165
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Union of all context-specific fetch externality interfaces.
|
|
225
|
+
*/
|
|
226
|
+
export type IFetchExternalities = IIsAuthorizedFetch | IRefineFetch | IAccumulateFetch;
|
|
166
227
|
/**
|
|
167
228
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/324000324000?v=0.6.7
|
|
168
229
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/jam-host-calls/general/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/jam-host-calls/general/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAA8B,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,YAAY,EAAsC,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,KAAK,WAAW,E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AG,OAAO,CAAC,SAAS,GAAG,YAAY,CAAC;IA6BpH,OAAO,CAAC,QAAQ;CA2IjB;AAED,oBAAY,SAAS;IACnB,SAAS,IAAI;IACb,OAAO,IAAI;IACX,eAAe,IAAI;IACnB,uBAAuB,IAAI;IAC3B,YAAY,IAAI;IAChB,oBAAoB,IAAI;IACxB,SAAS,IAAI;IACb,WAAW,IAAI;IACf,UAAU,IAAI;IACd,kBAAkB,IAAI;IACtB,aAAa,KAAK;IAClB,YAAY,KAAK;IACjB,WAAW,KAAK;IAChB,eAAe,KAAK;IACpB,uBAAuB,KAAK;IAC5B,oBAAoB,KAAK;CAC1B"}
|
|
@@ -4,6 +4,38 @@ import { tryAsSmallGas } from "#@typeberry/pvm-interface";
|
|
|
4
4
|
import { logger } from "../logger.js";
|
|
5
5
|
import { clampU64ToU32 } from "../utils.js";
|
|
6
6
|
import { HostCallResult } from "./results.js";
|
|
7
|
+
/**
|
|
8
|
+
* Fetchable data contexts.
|
|
9
|
+
*
|
|
10
|
+
* The fetch host call (ecalli 1) returns context-dependent data based on
|
|
11
|
+
* ω₁₀ (the kind selector). Each invocation context passes different
|
|
12
|
+
* parameters to Ω_Y, which determines which kinds return data vs NONE.
|
|
13
|
+
*
|
|
14
|
+
* Ω_Y signature: Ω_Y(ρ, φ, μ, p, n, r, i, ī, x̄, 𝐢, ...)
|
|
15
|
+
*
|
|
16
|
+
* Context parameter mapping
|
|
17
|
+
* Is-Authorized: Ω_Y(ρ, φ, μ, 𝐩, ∅, ∅, ∅, ∅, ∅, ∅, ∅)
|
|
18
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2e43012e4301?v=0.7.2
|
|
19
|
+
* Refine: Ω_Y(ρ, φ, μ, p, H₀, r, i, ī, x̄, ∅, (m,e))
|
|
20
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fe0012fe001?v=0.7.2
|
|
21
|
+
* Accumulate: Ω_Y(ρ, φ, μ, ∅, η'₀, ∅, ∅, ∅, ∅, 𝐢, (x,y))
|
|
22
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/30c00030c000?v=0.7.2
|
|
23
|
+
*
|
|
24
|
+
* Kind availability per context:
|
|
25
|
+
* Kind 0 (constants) — all contexts
|
|
26
|
+
* Kind 1 (n) — Refine (H₀), Accumulate (η'₀)
|
|
27
|
+
* Kind 2 (r) — Refine only
|
|
28
|
+
* Kind 3-4 (x̄ extrinsics) — Refine only
|
|
29
|
+
* Kind 5-6 (ī imports) — Refine only
|
|
30
|
+
* Kind 7-13 (p work pkg) — Is-Authorized, Refine
|
|
31
|
+
* Kind 14-15 (𝐢 acc items) — Accumulate only
|
|
32
|
+
*/
|
|
33
|
+
export var FetchContext;
|
|
34
|
+
(function (FetchContext) {
|
|
35
|
+
FetchContext["IsAuthorized"] = "isAuthorized";
|
|
36
|
+
FetchContext["Refine"] = "refine";
|
|
37
|
+
FetchContext["Accumulate"] = "accumulate";
|
|
38
|
+
})(FetchContext || (FetchContext = {}));
|
|
7
39
|
const IN_OUT_REG = 7;
|
|
8
40
|
/**
|
|
9
41
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/324000324000?v=0.6.7
|
|
@@ -43,62 +75,124 @@ export class Fetch {
|
|
|
43
75
|
regs.set(IN_OUT_REG, value === null ? HostCallResult.NONE : valueLength);
|
|
44
76
|
}
|
|
45
77
|
getValue(kind, regs) {
|
|
78
|
+
const ext = this.fetch;
|
|
79
|
+
// Kind 0: constants — all contexts
|
|
46
80
|
if (kind === FetchKind.Constants) {
|
|
47
|
-
return
|
|
81
|
+
return ext.constants();
|
|
48
82
|
}
|
|
83
|
+
// Kind 1: entropy — Refine, Accumulate
|
|
49
84
|
if (kind === FetchKind.Entropy) {
|
|
50
|
-
|
|
85
|
+
if (ext.context === FetchContext.IsAuthorized) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return ext.entropy();
|
|
51
89
|
}
|
|
90
|
+
// Kind 2: authorizer trace — Refine only
|
|
52
91
|
if (kind === FetchKind.AuthorizerTrace) {
|
|
53
|
-
|
|
92
|
+
if (ext.context !== FetchContext.Refine) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return ext.authorizerTrace();
|
|
54
96
|
}
|
|
97
|
+
// Kind 3: other work item extrinsics — Refine only
|
|
55
98
|
if (kind === FetchKind.OtherWorkItemExtrinsics) {
|
|
99
|
+
if (ext.context !== FetchContext.Refine) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
56
102
|
const workItem = regs.get(11);
|
|
57
103
|
const index = regs.get(12);
|
|
58
|
-
return
|
|
104
|
+
return ext.workItemExtrinsic(workItem, index);
|
|
59
105
|
}
|
|
106
|
+
// Kind 4: my extrinsics — Refine only
|
|
60
107
|
if (kind === FetchKind.MyExtrinsics) {
|
|
108
|
+
if (ext.context !== FetchContext.Refine) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
61
111
|
const index = regs.get(11);
|
|
62
|
-
return
|
|
112
|
+
return ext.workItemExtrinsic(null, index);
|
|
63
113
|
}
|
|
114
|
+
// Kind 5: other work item imports — Refine only
|
|
64
115
|
if (kind === FetchKind.OtherWorkItemImports) {
|
|
116
|
+
if (ext.context !== FetchContext.Refine) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
65
119
|
const workItem = regs.get(11);
|
|
66
120
|
const index = regs.get(12);
|
|
67
|
-
return
|
|
121
|
+
return ext.workItemImport(workItem, index);
|
|
68
122
|
}
|
|
123
|
+
// Kind 6: my imports — Refine only
|
|
69
124
|
if (kind === FetchKind.MyImports) {
|
|
125
|
+
if (ext.context !== FetchContext.Refine) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
70
128
|
const index = regs.get(11);
|
|
71
|
-
return
|
|
129
|
+
return ext.workItemImport(null, index);
|
|
72
130
|
}
|
|
131
|
+
// Kind 7: work package — Is-Authorized, Refine
|
|
73
132
|
if (kind === FetchKind.WorkPackage) {
|
|
74
|
-
|
|
133
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return ext.workPackage();
|
|
75
137
|
}
|
|
138
|
+
// Kind 8: authorizer — Is-Authorized, Refine
|
|
76
139
|
if (kind === FetchKind.Authorizer) {
|
|
77
|
-
|
|
140
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return ext.authorizer();
|
|
78
144
|
}
|
|
145
|
+
// Kind 9: authorization token — Is-Authorized, Refine
|
|
79
146
|
if (kind === FetchKind.AuthorizationToken) {
|
|
80
|
-
|
|
147
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return ext.authorizationToken();
|
|
81
151
|
}
|
|
152
|
+
// Kind 10: refine context — Is-Authorized, Refine
|
|
82
153
|
if (kind === FetchKind.RefineContext) {
|
|
83
|
-
|
|
154
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return ext.refineContext();
|
|
84
158
|
}
|
|
159
|
+
// Kind 11: all work items — Is-Authorized, Refine
|
|
85
160
|
if (kind === FetchKind.AllWorkItems) {
|
|
86
|
-
|
|
161
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return ext.allWorkItems();
|
|
87
165
|
}
|
|
166
|
+
// Kind 12: one work item — Is-Authorized, Refine
|
|
88
167
|
if (kind === FetchKind.OneWorkItem) {
|
|
168
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
89
171
|
const workItem = regs.get(11);
|
|
90
|
-
return
|
|
172
|
+
return ext.oneWorkItem(workItem);
|
|
91
173
|
}
|
|
174
|
+
// Kind 13: work item payload — Is-Authorized, Refine
|
|
92
175
|
if (kind === FetchKind.WorkItemPayload) {
|
|
176
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
93
179
|
const workItem = regs.get(11);
|
|
94
|
-
return
|
|
180
|
+
return ext.workItemPayload(workItem);
|
|
95
181
|
}
|
|
182
|
+
// Kind 14: all transfers and operands — Accumulate only
|
|
96
183
|
if (kind === FetchKind.AllTransfersAndOperands) {
|
|
97
|
-
|
|
184
|
+
if (ext.context !== FetchContext.Accumulate) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return ext.allTransfersAndOperands();
|
|
98
188
|
}
|
|
189
|
+
// Kind 15: one transfer or operand — Accumulate only
|
|
99
190
|
if (kind === FetchKind.OneTransferOrOperand) {
|
|
191
|
+
if (ext.context !== FetchContext.Accumulate) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
100
194
|
const index = regs.get(11);
|
|
101
|
-
return
|
|
195
|
+
return ext.oneTransferOrOperand(index);
|
|
102
196
|
}
|
|
103
197
|
return null;
|
|
104
198
|
}
|