@typeberry/lib 0.5.10-6cb1bd5 → 0.5.10-7338c21
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/core/pvm-interface/pvm.d.ts +2 -0
- package/packages/core/pvm-interface/pvm.d.ts.map +1 -1
- package/packages/jam/block/work-package.d.ts +7 -7
- package/packages/jam/block/work-package.d.ts.map +1 -1
- package/packages/jam/block/work-package.js +12 -12
- package/packages/jam/executor/pvm-executor.d.ts +9 -2
- package/packages/jam/executor/pvm-executor.d.ts.map +1 -1
- package/packages/jam/executor/pvm-executor.js +15 -0
- package/packages/jam/in-core/externalities/refine.d.ts +18 -8
- package/packages/jam/in-core/externalities/refine.d.ts.map +1 -1
- package/packages/jam/in-core/externalities/refine.js +86 -7
- package/packages/jam/in-core/externalities/refine.test.js +167 -2
- package/packages/jam/in-core/in-core.d.ts +7 -22
- package/packages/jam/in-core/in-core.d.ts.map +1 -1
- package/packages/jam/in-core/in-core.js +16 -186
- package/packages/jam/in-core/in-core.test.js +47 -15
- package/packages/jam/in-core/is-authorized.d.ts +33 -0
- package/packages/jam/in-core/is-authorized.d.ts.map +1 -0
- package/packages/jam/in-core/is-authorized.js +72 -0
- package/packages/jam/in-core/is-authorized.test.d.ts +2 -0
- package/packages/jam/in-core/is-authorized.test.d.ts.map +1 -0
- package/packages/jam/in-core/is-authorized.test.js +125 -0
- package/packages/jam/in-core/refine.d.ts +34 -0
- package/packages/jam/in-core/refine.d.ts.map +1 -0
- package/packages/jam/in-core/refine.js +176 -0
- package/packages/jam/in-core/refine.test.d.ts +2 -0
- package/packages/jam/in-core/refine.test.d.ts.map +1 -0
- package/packages/jam/in-core/refine.test.js +6 -0
- package/packages/jam/jam-host-calls/accumulate/bless.js +9 -9
- package/packages/jam/jam-host-calls/externalities/partial-state.d.ts +1 -1
- package/packages/jam/jam-host-calls/externalities/refine-externalities.d.ts +1 -1
- package/packages/jam/jam-host-calls/externalities/refine-externalities.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/general/fetch.d.ts +164 -103
- package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/general/fetch.js +117 -23
- package/packages/jam/jam-host-calls/general/fetch.test.js +100 -66
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +2 -2
- package/packages/jam/transition/accumulate/accumulate.js +2 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.js +48 -39
- package/packages/jam/transition/externalities/accumulate-externalities.d.ts +2 -2
- package/packages/jam/transition/externalities/accumulate-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/accumulate-externalities.js +20 -7
- package/packages/jam/transition/externalities/accumulate-externalities.test.js +74 -4
- 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 +3 -0
- package/packages/jam/transition/externalities/index.d.ts.map +1 -1
- package/packages/jam/transition/externalities/index.js +3 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.d.ts +22 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.d.ts.map +1 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.js +41 -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 +56 -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
|
@@ -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
|
+
* IsAuthorized: Ω_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) - IsAuthorized, 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 IsAuthorized 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
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Is Authorized: `p` (work package?)
|
|
19
|
-
* Refine: `H_0` (might change in the future)
|
|
20
|
-
* Accumulate: `eta_0 prime`
|
|
21
|
-
* On Transfer: `eta_0 prime`
|
|
55
|
+
* Kind 7: Encoded work package - E(𝐩).
|
|
22
56
|
*
|
|
23
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
57
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c10231c102?v=0.7.2
|
|
24
58
|
*/
|
|
25
|
-
|
|
59
|
+
workPackage(): BytesBlob;
|
|
26
60
|
/**
|
|
61
|
+
* Kind 8: Authorizer configuration - p_f.
|
|
27
62
|
*
|
|
28
|
-
*
|
|
63
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c80231c802?v=0.7.2
|
|
64
|
+
*/
|
|
65
|
+
authConfiguration(): BytesBlob;
|
|
66
|
+
/**
|
|
67
|
+
* Kind 9: Authorization token - p_j.
|
|
29
68
|
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
69
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31cf0231cf02?v=0.7.2
|
|
70
|
+
*/
|
|
71
|
+
authToken(): BytesBlob;
|
|
72
|
+
/**
|
|
73
|
+
* Kind 10: Refinement context - E(p_x).
|
|
34
74
|
*
|
|
35
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
75
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31da0231da02?v=0.7.2
|
|
36
76
|
*/
|
|
37
|
-
|
|
77
|
+
refineContext(): BytesBlob;
|
|
38
78
|
/**
|
|
39
|
-
*
|
|
79
|
+
* Kind 11: All work-item summaries - E(↕[S(w) | w ← p_w]).
|
|
40
80
|
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
81
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31f40231f402?v=0.7.2
|
|
82
|
+
*/
|
|
83
|
+
allWorkItems(): BytesBlob;
|
|
84
|
+
/**
|
|
85
|
+
* Kind 12: Single work-item summary - S(p_w[φ₁₁]).
|
|
46
86
|
*
|
|
47
|
-
*
|
|
48
|
-
* My: https://graypaper.fluffylabs.dev/#/9a08063/327701327701?v=0.6.6
|
|
87
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31fc0231fc02?v=0.7.2
|
|
49
88
|
*/
|
|
50
|
-
|
|
89
|
+
oneWorkItem(workItem: U64): BytesBlob | null;
|
|
51
90
|
/**
|
|
52
|
-
*
|
|
91
|
+
* Kind 13: Work-item payload - p_w[φ₁₁]_y.
|
|
53
92
|
*
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
93
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/313b03313b03?v=0.7.2
|
|
94
|
+
*/
|
|
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;
|
|
107
|
+
/**
|
|
108
|
+
* Kind 0: Encoded constants info (𝐜).
|
|
59
109
|
*
|
|
60
|
-
*
|
|
61
|
-
* My: https://graypaper.fluffylabs.dev/#/9a08063/329601329601?v=0.6.6
|
|
110
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315001315001?v=0.7.2
|
|
62
111
|
*/
|
|
63
|
-
|
|
112
|
+
constants(): BytesBlob;
|
|
64
113
|
/**
|
|
65
|
-
*
|
|
114
|
+
* Kind 1: Entropy pool - H₀ (zero hash).
|
|
66
115
|
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
116
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fe0012fe201?v=0.7.2
|
|
117
|
+
*/
|
|
118
|
+
entropy(): EntropyHash;
|
|
119
|
+
/**
|
|
120
|
+
* Kind 2: Authorizer trace (𝐫).
|
|
71
121
|
*
|
|
72
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
122
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314902314902?v=0.7.2
|
|
73
123
|
*/
|
|
74
|
-
|
|
124
|
+
authorizerTrace(): BytesBlob;
|
|
75
125
|
/**
|
|
76
|
-
*
|
|
77
|
-
* authorizer code hash (`u`) and parametrization (`p`).
|
|
126
|
+
* Kind 3 (other) / Kind 4 (my): Work-item extrinsics (x̄).
|
|
78
127
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* Accumulate: <empty>
|
|
82
|
-
* 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).
|
|
83
130
|
*
|
|
84
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
131
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315402315402?v=0.7.2
|
|
132
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/317302317302?v=0.7.2
|
|
85
133
|
*/
|
|
86
|
-
|
|
134
|
+
workItemExtrinsic(workItem: U64 | null, index: U64): BytesBlob | null;
|
|
87
135
|
/**
|
|
88
|
-
*
|
|
136
|
+
* Kind 5 (other) / Kind 6 (my): Import segments (ī).
|
|
89
137
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* Accumulate: <empty>
|
|
93
|
-
* 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).
|
|
94
140
|
*
|
|
95
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
141
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/318b02318b02?v=0.7.2
|
|
142
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31aa0231aa02?v=0.7.2
|
|
96
143
|
*/
|
|
97
|
-
|
|
144
|
+
workItemImport(workItem: U64 | null, index: U64): BytesBlob | null;
|
|
98
145
|
/**
|
|
99
|
-
*
|
|
146
|
+
* Kind 7: Encoded work package - E(p).
|
|
100
147
|
*
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
148
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c10231c102?v=0.7.2
|
|
149
|
+
*/
|
|
150
|
+
workPackage(): BytesBlob;
|
|
151
|
+
/**
|
|
152
|
+
* Kind 8: Authorizer configuration - p_f.
|
|
105
153
|
*
|
|
106
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
154
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31c80231c802?v=0.7.2
|
|
107
155
|
*/
|
|
108
|
-
|
|
156
|
+
authConfiguration(): BytesBlob;
|
|
109
157
|
/**
|
|
110
|
-
*
|
|
158
|
+
* Kind 9: Authorization token - p_j.
|
|
111
159
|
*
|
|
112
|
-
*
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*
|
|
160
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31cf0231cf02?v=0.7.2
|
|
161
|
+
*/
|
|
162
|
+
authToken(): BytesBlob;
|
|
163
|
+
/**
|
|
164
|
+
* Kind 10: Refinement context - E(p_x).
|
|
117
165
|
*
|
|
118
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
166
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31da0231da02?v=0.7.2
|
|
119
167
|
*/
|
|
120
|
-
|
|
168
|
+
refineContext(): BytesBlob;
|
|
121
169
|
/**
|
|
122
|
-
*
|
|
123
|
-
* `S(w)`: https://graypaper.fluffylabs.dev/#/9a08063/32db0132ea01?v=0.6.6
|
|
170
|
+
* Kind 11: All work-item summaries - E(↕[S(w) | w ← p_w]).
|
|
124
171
|
*
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
172
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31f40231f402?v=0.7.2
|
|
173
|
+
*/
|
|
174
|
+
allWorkItems(): BytesBlob;
|
|
175
|
+
/**
|
|
176
|
+
* Kind 12: Single work-item summary - S(p_w[φ₁₁]).
|
|
130
177
|
*
|
|
131
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
178
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/31fc0231fc02?v=0.7.2
|
|
132
179
|
*/
|
|
133
180
|
oneWorkItem(workItem: U64): BytesBlob | null;
|
|
134
181
|
/**
|
|
135
|
-
*
|
|
182
|
+
* Kind 13: Work-item payload - p_w[φ₁₁]_y.
|
|
136
183
|
*
|
|
137
|
-
*
|
|
138
|
-
* Refine: `p_w[omega_11]_y`
|
|
139
|
-
* Accumulate: <empty>
|
|
140
|
-
* On Transfer: <empty>
|
|
141
|
-
*
|
|
142
|
-
* https://graypaper.fluffylabs.dev/#/9a08063/32f00132f001?v=0.6.6
|
|
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;
|
|
145
198
|
/**
|
|
146
|
-
*
|
|
199
|
+
* Kind 0: Encoded constants info (𝐜).
|
|
147
200
|
*
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
201
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/315001315001?v=0.7.2
|
|
202
|
+
*/
|
|
203
|
+
constants(): BytesBlob;
|
|
204
|
+
/**
|
|
205
|
+
* Kind 1: Entropy pool - η'₀ (posterior entropy).
|
|
151
206
|
*
|
|
152
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/
|
|
207
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314302314602?v=0.7.2
|
|
153
208
|
*/
|
|
154
|
-
|
|
209
|
+
entropy(): EntropyHash;
|
|
155
210
|
/**
|
|
156
|
-
*
|
|
211
|
+
* Kind 14: All accumulation operands and transfers - E(↕𝐢).
|
|
157
212
|
*
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
213
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/314e03314e03?v=0.7.2
|
|
214
|
+
*/
|
|
215
|
+
allTransfersAndOperands(): BytesBlob | null;
|
|
216
|
+
/**
|
|
217
|
+
* Kind 15: Single accumulation operand or transfer - E(𝐢[φ₁₁]).
|
|
161
218
|
*
|
|
162
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/
|
|
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
|
*/
|
|
@@ -185,8 +246,8 @@ export declare enum FetchKind {
|
|
|
185
246
|
OtherWorkItemImports = 5,
|
|
186
247
|
MyImports = 6,
|
|
187
248
|
WorkPackage = 7,
|
|
188
|
-
|
|
189
|
-
|
|
249
|
+
AuthConfiguration = 8,
|
|
250
|
+
AuthToken = 9,
|
|
190
251
|
RefineContext = 10,
|
|
191
252
|
AllWorkItems = 11,
|
|
192
253
|
OneWorkItem = 12,
|
|
@@ -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,EAAiB,MAAM,0BAA0B,CAAC;AAK3E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,oBAAY,YAAY;IACtB,YAAY,iBAAiB;IAC7B,MAAM,WAAW;IACjB,UA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SAAS,IAAI;IACb,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
|
+
* IsAuthorized: Ω_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) - IsAuthorized, 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 - IsAuthorized, Refine
|
|
73
132
|
if (kind === FetchKind.WorkPackage) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
133
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return ext.workPackage();
|
|
137
|
+
}
|
|
138
|
+
// Kind 8: auth configuration - IsAuthorized, Refine
|
|
139
|
+
if (kind === FetchKind.AuthConfiguration) {
|
|
140
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return ext.authConfiguration();
|
|
144
|
+
}
|
|
145
|
+
// Kind 9: authorization token - IsAuthorized, Refine
|
|
146
|
+
if (kind === FetchKind.AuthToken) {
|
|
147
|
+
if (ext.context === FetchContext.Accumulate) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return ext.authToken();
|
|
151
|
+
}
|
|
152
|
+
// Kind 10: refine context - IsAuthorized, 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 - IsAuthorized, 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 - IsAuthorized, 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 - IsAuthorized, 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
|
}
|
|
@@ -113,8 +207,8 @@ export var FetchKind;
|
|
|
113
207
|
FetchKind[FetchKind["OtherWorkItemImports"] = 5] = "OtherWorkItemImports";
|
|
114
208
|
FetchKind[FetchKind["MyImports"] = 6] = "MyImports";
|
|
115
209
|
FetchKind[FetchKind["WorkPackage"] = 7] = "WorkPackage";
|
|
116
|
-
FetchKind[FetchKind["
|
|
117
|
-
FetchKind[FetchKind["
|
|
210
|
+
FetchKind[FetchKind["AuthConfiguration"] = 8] = "AuthConfiguration";
|
|
211
|
+
FetchKind[FetchKind["AuthToken"] = 9] = "AuthToken";
|
|
118
212
|
FetchKind[FetchKind["RefineContext"] = 10] = "RefineContext";
|
|
119
213
|
FetchKind[FetchKind["AllWorkItems"] = 11] = "AllWorkItems";
|
|
120
214
|
FetchKind[FetchKind["OneWorkItem"] = 12] = "OneWorkItem";
|