@typeberry/lib 0.5.3 → 0.5.4

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.
Files changed (149) hide show
  1. package/package.json +8 -4
  2. package/packages/core/hash/hash.d.ts.map +1 -1
  3. package/packages/core/hash/hash.js +1 -0
  4. package/packages/core/networking/certificate.d.ts.map +1 -1
  5. package/packages/core/networking/certificate.js +1 -0
  6. package/packages/core/networking/package.json +1 -1
  7. package/packages/core/networking/setup.d.ts.map +1 -1
  8. package/packages/core/networking/setup.js +16 -12
  9. package/packages/core/numbers/index.d.ts +4 -0
  10. package/packages/core/numbers/index.d.ts.map +1 -1
  11. package/packages/core/numbers/index.js +4 -4
  12. package/packages/core/pvm-host-calls/host-calls-executor.d.ts +23 -17
  13. package/packages/core/pvm-host-calls/host-calls-executor.d.ts.map +1 -1
  14. package/packages/core/pvm-host-calls/host-calls-executor.js +23 -31
  15. package/packages/core/pvm-interpreter/ops/math-consts.d.ts +2 -3
  16. package/packages/core/pvm-interpreter/ops/math-consts.d.ts.map +1 -1
  17. package/packages/core/pvm-interpreter/ops/math-consts.js +2 -3
  18. package/packages/core/pvm-interpreter/ops/math-ops.js +3 -3
  19. package/packages/core/pvm-interpreter/ops/math-utils.js +13 -13
  20. package/packages/core/pvm-interpreter/ops/math-utils.test.js +17 -16
  21. package/packages/core/telemetry/package.json +1 -1
  22. package/packages/extensions/ipc/jamnp/handler.d.ts +5 -4
  23. package/packages/extensions/ipc/jamnp/handler.d.ts.map +1 -1
  24. package/packages/extensions/ipc/jamnp/handler.js +59 -34
  25. package/packages/extensions/ipc/jamnp/stream.d.ts +6 -4
  26. package/packages/extensions/ipc/jamnp/stream.d.ts.map +1 -1
  27. package/packages/jam/block/work-item.d.ts +13 -4
  28. package/packages/jam/block/work-item.d.ts.map +1 -1
  29. package/packages/jam/block/work-package.d.ts +3 -1
  30. package/packages/jam/block/work-package.d.ts.map +1 -1
  31. package/packages/jam/block/work-package.js +6 -2
  32. package/packages/jam/block/work-result.d.ts +3 -5
  33. package/packages/jam/block/work-result.d.ts.map +1 -1
  34. package/packages/jam/block/work-result.js +6 -0
  35. package/packages/jam/block-json/block.d.ts +125 -0
  36. package/packages/jam/block-json/block.d.ts.map +1 -1
  37. package/packages/jam/block-json/block.js +9 -2
  38. package/packages/jam/block-json/work-result.d.ts.map +1 -1
  39. package/packages/jam/block-json/work-result.js +6 -6
  40. package/packages/jam/database-lmdb/states.test.js +4 -3
  41. package/packages/jam/executor/index.d.ts +4 -0
  42. package/packages/jam/executor/index.d.ts.map +1 -0
  43. package/packages/jam/executor/index.js +2 -0
  44. package/packages/jam/{transition/accumulate → executor}/pvm-executor.d.ts +19 -16
  45. package/packages/jam/executor/pvm-executor.d.ts.map +1 -0
  46. package/packages/jam/{transition/accumulate → executor}/pvm-executor.js +46 -3
  47. package/packages/jam/fuzz-proto/v1/handler.d.ts +1 -1
  48. package/packages/jam/fuzz-proto/v1/handler.d.ts.map +1 -1
  49. package/packages/jam/fuzz-proto/v1/handler.js +43 -19
  50. package/packages/jam/in-core/externalities/refine.d.ts +24 -0
  51. package/packages/jam/in-core/externalities/refine.d.ts.map +1 -0
  52. package/packages/jam/in-core/externalities/refine.js +36 -0
  53. package/packages/jam/in-core/in-core.d.ts +60 -0
  54. package/packages/jam/in-core/in-core.d.ts.map +1 -0
  55. package/packages/jam/in-core/in-core.js +294 -0
  56. package/packages/jam/in-core/in-core.test.d.ts +2 -0
  57. package/packages/jam/in-core/in-core.test.d.ts.map +1 -0
  58. package/packages/jam/in-core/in-core.test.js +81 -0
  59. package/packages/jam/in-core/index.d.ts +2 -0
  60. package/packages/jam/in-core/index.d.ts.map +1 -0
  61. package/packages/jam/in-core/index.js +1 -0
  62. package/packages/jam/jam-host-calls/accumulate/bless.test.js +4 -5
  63. package/packages/jam/jamnp-s/peers.d.ts.map +1 -1
  64. package/packages/jam/jamnp-s/peers.js +10 -0
  65. package/packages/jam/jamnp-s/protocol/ce-128-block-request.d.ts +1 -1
  66. package/packages/jam/jamnp-s/protocol/ce-128-block-request.d.ts.map +1 -1
  67. package/packages/jam/jamnp-s/protocol/ce-128-block-request.js +10 -8
  68. package/packages/jam/jamnp-s/protocol/ce-129-state-request.d.ts.map +1 -1
  69. package/packages/jam/jamnp-s/protocol/ce-129-state-request.js +11 -9
  70. package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.d.ts +3 -3
  71. package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.d.ts.map +1 -1
  72. package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.js +2 -2
  73. package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +5 -5
  74. package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts.map +1 -1
  75. package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.js +2 -2
  76. package/packages/jam/jamnp-s/protocol/ce-134-work-package-sharing.d.ts.map +1 -1
  77. package/packages/jam/jamnp-s/protocol/ce-134-work-package-sharing.js +8 -6
  78. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts +3 -3
  79. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts.map +1 -1
  80. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.js +2 -2
  81. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.test.js +2 -2
  82. package/packages/jam/jamnp-s/protocol/stream.d.ts +13 -7
  83. package/packages/jam/jamnp-s/protocol/stream.d.ts.map +1 -1
  84. package/packages/jam/jamnp-s/protocol/stream.js +5 -4
  85. package/packages/jam/jamnp-s/protocol/test-utils.d.ts +1 -1
  86. package/packages/jam/jamnp-s/protocol/test-utils.d.ts.map +1 -1
  87. package/packages/jam/jamnp-s/protocol/test-utils.js +9 -12
  88. package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts +1 -1
  89. package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts.map +1 -1
  90. package/packages/jam/jamnp-s/protocol/up-0-block-announcement.js +1 -1
  91. package/packages/jam/jamnp-s/stream-manager.d.ts.map +1 -1
  92. package/packages/jam/jamnp-s/stream-manager.js +7 -5
  93. package/packages/jam/jamnp-s/stream-manager.test.js +8 -5
  94. package/packages/jam/jamnp-s/tasks/sync.js +1 -1
  95. package/packages/jam/node/jam-config.d.ts +4 -1
  96. package/packages/jam/node/jam-config.d.ts.map +1 -1
  97. package/packages/jam/node/jam-config.js +6 -2
  98. package/packages/jam/node/main.d.ts.map +1 -1
  99. package/packages/jam/node/main.js +5 -4
  100. package/packages/jam/node/package.json +1 -1
  101. package/packages/jam/rpc-validation/types.d.ts +7 -3
  102. package/packages/jam/rpc-validation/types.d.ts.map +1 -1
  103. package/packages/jam/rpc-validation/validation.d.ts +254 -36
  104. package/packages/jam/rpc-validation/validation.d.ts.map +1 -1
  105. package/packages/jam/rpc-validation/validation.js +20 -2
  106. package/packages/jam/state/in-memory-state.d.ts.map +1 -1
  107. package/packages/jam/state/in-memory-state.js +2 -3
  108. package/packages/jam/state/test.utils.d.ts.map +1 -1
  109. package/packages/jam/state/test.utils.js +2 -3
  110. package/packages/jam/state-vectors/index.d.ts +377 -5
  111. package/packages/jam/state-vectors/index.d.ts.map +1 -1
  112. package/packages/jam/state-vectors/index.js +3 -3
  113. package/packages/jam/transition/accumulate/accumulate-data.d.ts.map +1 -1
  114. package/packages/jam/transition/accumulate/accumulate-data.js +1 -2
  115. package/packages/jam/transition/accumulate/accumulate-queue.test.js +2 -2
  116. package/packages/jam/transition/accumulate/accumulate-utils.test.js +2 -2
  117. package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
  118. package/packages/jam/transition/accumulate/accumulate.js +8 -13
  119. package/packages/jam/transition/accumulate/accumulate.test.js +2 -2
  120. package/packages/jam/transition/accumulate/accumulation-result-merge-utils.d.ts.map +1 -1
  121. package/packages/jam/transition/accumulate/accumulation-result-merge-utils.js +1 -2
  122. package/packages/jam/transition/accumulate/accumulation-result-merge-utils.test.js +1 -2
  123. package/packages/jam/transition/accumulate/deferred-transfers.d.ts +1 -1
  124. package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +1 -1
  125. package/packages/jam/transition/accumulate/deferred-transfers.js +6 -7
  126. package/packages/jam/transition/disputes/disputes.test.data2.js +2 -2
  127. package/packages/jam/transition/externalities/fetch-externalities.d.ts +7 -1
  128. package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
  129. package/packages/jam/transition/externalities/fetch-externalities.js +4 -0
  130. package/packages/jam/transition/externalities/fetch-externalities.test.js +2 -2
  131. package/packages/jam/transition/hasher.test.js +2 -2
  132. package/packages/jam/transition/reports/error.d.ts +3 -1
  133. package/packages/jam/transition/reports/error.d.ts.map +1 -1
  134. package/packages/jam/transition/reports/error.js +2 -0
  135. package/packages/jam/transition/reports/test.utils.d.ts.map +1 -1
  136. package/packages/jam/transition/reports/test.utils.js +2 -2
  137. package/packages/jam/transition/reports/verify-basic.d.ts.map +1 -1
  138. package/packages/jam/transition/reports/verify-basic.js +10 -0
  139. package/packages/jam/transition/reports/verify-basic.test.js +29 -0
  140. package/packages/workers/block-authorship/main.d.ts.map +1 -1
  141. package/packages/workers/block-authorship/main.js +23 -4
  142. package/packages/workers/block-authorship/package.json +1 -1
  143. package/packages/workers/block-authorship/protocol.d.ts +3 -1
  144. package/packages/workers/block-authorship/protocol.d.ts.map +1 -1
  145. package/packages/workers/block-authorship/protocol.js +6 -3
  146. package/packages/workers/importer/importer.d.ts.map +1 -1
  147. package/packages/workers/importer/importer.js +0 -1
  148. package/packages/workers/importer/package.json +1 -1
  149. package/packages/jam/transition/accumulate/pvm-executor.d.ts.map +0 -1
@@ -1,7 +1,14 @@
1
1
  import { BytesBlob } from "#@typeberry/bytes";
2
2
  import { Decoder, Encoder } from "#@typeberry/codec";
3
+ import { tryAsStreamId, } from "#@typeberry/jamnp-s";
3
4
  import { Logger } from "#@typeberry/logger";
5
+ import { assertNever } from "#@typeberry/utils";
4
6
  import { NewStream, StreamEnvelope, StreamEnvelopeType } from "./stream.js";
7
+ const IPC_PEER_ID = "ipc-peer";
8
+ /** Construct a protocol-level StreamId from an IPC-level numeric stream ID. */
9
+ function toStreamId(ipcStreamId) {
10
+ return tryAsStreamId(`${IPC_PEER_ID}:${ipcStreamId}`);
11
+ }
5
12
  const logger = Logger.new(import.meta.filename, "ext-ipc-jamnp");
6
13
  export class JamnpIpcHandler {
7
14
  sender;
@@ -37,9 +44,9 @@ export class JamnpIpcHandler {
37
44
  /** Re-use an existing stream of given kind if present. */
38
45
  withStreamOfKind(streamKind, work) {
39
46
  // find first stream id with given kind
40
- for (const [streamId, handler] of this.streams.entries()) {
47
+ for (const [ipcStreamId, handler] of this.streams.entries()) {
41
48
  if (handler.kind === streamKind) {
42
- work(handler, new EnvelopeSender(streamId, this.sender));
49
+ work(handler, new EnvelopeSender(ipcStreamId, this.sender));
43
50
  return;
44
51
  }
45
52
  }
@@ -52,19 +59,19 @@ export class JamnpIpcHandler {
52
59
  throw new Error(`Stream with unregistered handler of kind: ${kind} was requested to be opened.`);
53
60
  }
54
61
  // pick a stream id
55
- const getRandomStreamId = () => Math.floor(Math.random() * 2 ** 16);
62
+ const getRandomIpcStreamId = () => Math.floor(Math.random() * 2 ** 32);
56
63
  const streams = this.streams;
57
- const streamId = (function findStreamId() {
58
- const s = getRandomStreamId();
64
+ const ipcStreamId = (function findStreamId() {
65
+ const s = getRandomIpcStreamId();
59
66
  if (!streams.has(s)) {
60
67
  return s;
61
68
  }
62
69
  return findStreamId();
63
70
  })();
64
71
  // register the stream
65
- this.streams.set(streamId, handler);
66
- this.pendingStreams.set(streamId, true);
67
- const sender = new EnvelopeSender(streamId, this.sender);
72
+ this.streams.set(ipcStreamId, handler);
73
+ this.pendingStreams.set(ipcStreamId, true);
74
+ const sender = new EnvelopeSender(ipcStreamId, this.sender);
68
75
  sender.open(NewStream.create({ streamByte: kind }));
69
76
  work(handler, sender);
70
77
  }
@@ -72,24 +79,24 @@ export class JamnpIpcHandler {
72
79
  async onSocketMessage(msg) {
73
80
  // decode the message as `StreamEnvelope`
74
81
  const envelope = Decoder.decodeObject(StreamEnvelope.Codec, msg);
75
- const streamId = envelope.streamId;
76
- logger.log `[${streamId}] incoming message: ${envelope.type} ${envelope.data}`;
82
+ const ipcStreamId = envelope.streamId;
83
+ logger.log `[${ipcStreamId}] incoming message: ${envelope.type} ${envelope.data}`;
77
84
  // check if this is a already known stream id
78
- const streamHandler = this.streams.get(streamId);
79
- const streamSender = new EnvelopeSender(streamId, this.sender);
85
+ const streamHandler = this.streams.get(ipcStreamId);
86
+ const streamSender = new EnvelopeSender(ipcStreamId, this.sender);
80
87
  // we don't know that stream yet, so it has to be a new one
81
88
  if (streamHandler === undefined) {
82
89
  // closing or message of unknown stream - ignore.
83
90
  if (envelope.type !== StreamEnvelopeType.Open) {
84
- logger.warn `[${streamId}] (unknown) got invalid type ${envelope.type}.`;
91
+ logger.warn `[${ipcStreamId}] (unknown) got invalid type ${envelope.type}.`;
85
92
  return;
86
93
  }
87
94
  const newStream = Decoder.decodeObject(NewStream.Codec, envelope.data);
88
95
  const handler = this.streamHandlers.get(newStream.streamByte);
89
96
  if (handler !== undefined) {
90
- logger.log `[${streamId}] new stream for ${handler.kind}`;
97
+ logger.log `[${ipcStreamId}] new stream for ${handler.kind}`;
91
98
  // insert the stream
92
- this.streams.set(streamId, handler);
99
+ this.streams.set(ipcStreamId, handler);
93
100
  // Just send back the same stream byte.
94
101
  streamSender.open(newStream);
95
102
  return;
@@ -98,31 +105,47 @@ export class JamnpIpcHandler {
98
105
  streamSender.close();
99
106
  return;
100
107
  }
101
- // close the stream
102
- if (envelope.type === StreamEnvelopeType.Close) {
103
- const handler = this.streams.get(streamId);
104
- handler?.onClose(streamId, false);
105
- this.streams.delete(streamId);
106
- return;
107
- }
108
- if (envelope.type !== StreamEnvelopeType.Msg) {
108
+ if (envelope.type === StreamEnvelopeType.Open) {
109
109
  // display a warning but only if the stream was not pending for confirmation.
110
- if (!this.pendingStreams.delete(streamId)) {
111
- logger.warn `[${streamId}] got invalid type ${envelope.type}.`;
110
+ if (!this.pendingStreams.delete(ipcStreamId)) {
111
+ logger.warn `[${ipcStreamId}] got invalid type ${envelope.type}.`;
112
112
  }
113
113
  return;
114
114
  }
115
+ // reject stream messages without open ack first.
116
+ if (this.pendingStreams.has(ipcStreamId)) {
117
+ logger.warn `[${ipcStreamId}] got invalid type ${envelope.type}. Expected Open.`;
118
+ // closing the connection and removing the stream from pending.
119
+ this.pendingStreams.delete(ipcStreamId);
120
+ // the stream should not be in the collection yet, but we remove it just for safety.
121
+ this.streams.delete(ipcStreamId);
122
+ streamSender.close();
123
+ return;
124
+ }
115
125
  // this is a known stream, so just dispatch the message.
116
- streamHandler.onStreamMessage(streamSender, envelope.data);
126
+ if (envelope.type === StreamEnvelopeType.Msg) {
127
+ streamHandler.onStreamMessage(streamSender, envelope.data);
128
+ return;
129
+ }
130
+ // close the stream
131
+ if (envelope.type === StreamEnvelopeType.Close) {
132
+ streamHandler.onClose(toStreamId(ipcStreamId), false);
133
+ this.streams.delete(ipcStreamId);
134
+ // not really needed, but just for sure.
135
+ this.pendingStreams.delete(ipcStreamId);
136
+ return;
137
+ }
138
+ assertNever(envelope.type);
117
139
  }
118
140
  /** Notify about termination of the underlying socket. */
119
141
  onClose({ error }) {
120
142
  logger.log `Closing the handler. Reason: ${error !== undefined ? error.message : "close"}.`;
121
143
  // Socket closed - we should probably clear everything.
122
- for (const [streamId, handler] of this.streams.entries()) {
123
- handler.onClose(streamId, error === undefined);
144
+ for (const [ipcStreamId, handler] of this.streams.entries()) {
145
+ handler.onClose(toStreamId(ipcStreamId), error !== undefined);
124
146
  }
125
147
  this.streams.clear();
148
+ this.pendingStreams.clear();
126
149
  // finish the handler.
127
150
  this.onEnd.finished = true;
128
151
  if (error !== undefined) {
@@ -139,24 +162,26 @@ export class JamnpIpcHandler {
139
162
  }
140
163
  }
141
164
  class EnvelopeSender {
142
- streamId;
165
+ ipcStreamId;
143
166
  sender;
144
- constructor(streamId, sender) {
145
- this.streamId = streamId;
167
+ streamId;
168
+ constructor(ipcStreamId, sender) {
169
+ this.ipcStreamId = ipcStreamId;
146
170
  this.sender = sender;
171
+ this.streamId = toStreamId(ipcStreamId);
147
172
  }
148
173
  open(newStream) {
149
174
  const msg = Encoder.encodeObject(NewStream.Codec, newStream);
150
- this.sender.send(Encoder.encodeObject(StreamEnvelope.Codec, StreamEnvelope.create({ streamId: this.streamId, type: StreamEnvelopeType.Open, data: msg })));
175
+ this.sender.send(Encoder.encodeObject(StreamEnvelope.Codec, StreamEnvelope.create({ streamId: this.ipcStreamId, type: StreamEnvelopeType.Open, data: msg })));
151
176
  }
152
177
  bufferAndSend(msg) {
153
- this.sender.send(Encoder.encodeObject(StreamEnvelope.Codec, StreamEnvelope.create({ streamId: this.streamId, type: StreamEnvelopeType.Msg, data: msg })));
178
+ this.sender.send(Encoder.encodeObject(StreamEnvelope.Codec, StreamEnvelope.create({ streamId: this.ipcStreamId, type: StreamEnvelopeType.Msg, data: msg })));
154
179
  // we are buffering until we run OOM
155
180
  return true;
156
181
  }
157
182
  close() {
158
183
  this.sender.send(Encoder.encodeObject(StreamEnvelope.Codec, StreamEnvelope.create({
159
- streamId: this.streamId,
184
+ streamId: this.ipcStreamId,
160
185
  type: StreamEnvelopeType.Close,
161
186
  data: BytesBlob.blobFromNumbers([]),
162
187
  })));
@@ -1,18 +1,20 @@
1
1
  import type { BytesBlob } from "#@typeberry/bytes";
2
2
  import { type CodecRecord } from "#@typeberry/codec";
3
- import type { StreamId, StreamKind } from "#@typeberry/jamnp-s";
4
- import { type U8 } from "#@typeberry/numbers";
3
+ import type { StreamKind } from "#@typeberry/jamnp-s";
4
+ import { type U8, type U32 } from "#@typeberry/numbers";
5
+ /** IPC-level stream identifier (u32), used for multiplexing streams over a single socket. */
6
+ export type IpcStreamId = U32;
5
7
  export declare enum StreamEnvelopeType {
6
8
  Msg = 0,
7
9
  Open = 1,
8
10
  Close = 2
9
11
  }
10
12
  export declare class StreamEnvelope {
11
- readonly streamId: StreamId;
13
+ readonly streamId: IpcStreamId;
12
14
  readonly type: StreamEnvelopeType;
13
15
  readonly data: BytesBlob;
14
16
  static Codec: import("@typeberry/codec").Descriptor<StreamEnvelope, import("@typeberry/codec").ViewOf<StreamEnvelope, {
15
- streamId: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/bytes").Bytes<4>>;
17
+ streamId: import("@typeberry/codec").Descriptor<U32, import("@typeberry/bytes").Bytes<4>>;
16
18
  type: import("@typeberry/codec").Descriptor<StreamEnvelopeType, U8>;
17
19
  data: import("@typeberry/codec").Descriptor<BytesBlob, BytesBlob>;
18
20
  }>>;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../../packages/extensions/ipc/jamnp/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAEtD,oBAAY,kBAAkB;IAC5B,GAAG,IAAI;IACP,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,qBAAa,cAAc;aA0BP,QAAQ,EAAE,QAAQ;aAClB,IAAI,EAAE,kBAAkB;aACxB,IAAI,EAAE,SAAS;IA3BjC,MAAM,CAAC,KAAK;;;;QAkBT;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,cAAc,CAAC;IAInE,OAAO;CAKR;AAED,qBAAa,SAAS;aASgB,UAAU,EAAE,UAAU;IAR1D,MAAM,CAAC,KAAK;;QAET;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,WAAW,CAAC,SAAS,CAAC;IAIpD,OAAO;CACR"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../../packages/extensions/ipc/jamnp/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAW,KAAK,EAAE,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEhE,6FAA6F;AAC7F,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC;AAE9B,oBAAY,kBAAkB;IAC5B,GAAG,IAAI;IACP,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,qBAAa,cAAc;aA0BP,QAAQ,EAAE,WAAW;aACrB,IAAI,EAAE,kBAAkB;aACxB,IAAI,EAAE,SAAS;IA3BjC,MAAM,CAAC,KAAK;;;;QAkBT;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,cAAc,CAAC;IAInE,OAAO;CAKR;AAED,qBAAa,SAAS;aASgB,UAAU,EAAE,UAAU;IAR1D,MAAM,CAAC,KAAK;;QAET;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,WAAW,CAAC,SAAS,CAAC;IAIpD,OAAO;CACR"}
@@ -8,6 +8,19 @@ import type { ServiceGas, ServiceId } from "./common.js";
8
8
  import type { CodeHash } from "./hash.js";
9
9
  import { MAX_NUMBER_OF_SEGMENTS, type SegmentIndex } from "./work-item-segment.js";
10
10
  type WorkItemExtrinsicHash = Opaque<OpaqueHash, "ExtrinsicHash">;
11
+ /**
12
+ * An opaque piece of data that the work item brings in.
13
+ *
14
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/1a1b001a1d00?v=0.7.2
15
+ */
16
+ export type WorkItemExtrinsic = Opaque<BytesBlob, "Extrinsic">;
17
+ /**
18
+ * Extrinsics that are needed by all [`WorkItem`]s and are specified via [`WorkItemExtrinsicSpec`].
19
+ *
20
+ * This is a flat-package of all extrinsics in a work package across all work items.
21
+ * For encoding it also requires the length of items to be known in advance.
22
+ */
23
+ export type WorkPackageExtrinsics = KnownSizeArray<Bytes<U32>, "Count of all extrinsics within work items in a work package">;
11
24
  /**
12
25
  * Definition of data segment that was exported by some work package earlier
13
26
  * and now is being imported by another work-item.
@@ -40,10 +53,6 @@ export declare class WorkItemExtrinsicSpec extends WithDebug {
40
53
  static create({ hash, len }: CodecRecord<WorkItemExtrinsicSpec>): WorkItemExtrinsicSpec;
41
54
  private constructor();
42
55
  }
43
- /**
44
- * Extrinsics that are needed by [`WorkItem`]s and are specified via [`WorkItemExtrinsicSpec`].
45
- */
46
- export type WorkItemExtrinsics = KnownSizeArray<Bytes<U32>, "Count of all extrinsics within work items in a work package">;
47
56
  /**
48
57
  * To encode/decode extrinsics that are specified via [`WorkItemExtrinsicSpec`]
49
58
  * we need to know their lenghts. Hence this is created dynamically.
@@ -1 +1 @@
1
- {"version":3,"file":"work-item.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block/work-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAU,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,O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,MAAM,CAAC,EACZ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,WAAW,GACZ,EAAE,WAAW,CAAC,QAAQ,CAAC;IAaxB,OAAO;CAyBR"}
@@ -10,8 +10,10 @@ import { WorkItem } from "./work-item.js";
10
10
  /** Possible number of work items in the package or results in the report. */
11
11
  /** Constrained by I=16 https://graypaper.fluffylabs.dev/#/68eaa1f/417a00417a00?v=0.6.4 */
12
12
  export type WorkItemsCount = U8;
13
- /** Verify the value is within the `WorkItemsCount` bounds. */
13
+ /** Convert the value to `WorkItemsCount` bounds. */
14
14
  export declare function tryAsWorkItemsCount(len: number): WorkItemsCount;
15
+ /** Verify the value is within the `WorkItemsCount` bounds. */
16
+ export declare function isWorkItemsCount(len: number): len is WorkItemsCount;
15
17
  /** Minimal number of work items in the work package or results in work report. */
16
18
  export declare const MIN_NUMBER_OF_WORK_ITEMS = 1;
17
19
  /** `I`: Maximal number of work items in the work package or results in work report. */
@@ -1 +1 @@
1
- {"version":3,"file":"work-package.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block/work-package.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAS,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAS,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC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AAC"}
@@ -5,14 +5,18 @@ import { tryAsU8 } from "#@typeberry/numbers";
5
5
  import { check, WithDebug } from "#@typeberry/utils";
6
6
  import { RefineContext } from "./refine-context.js";
7
7
  import { WorkItem } from "./work-item.js";
8
- /** Verify the value is within the `WorkItemsCount` bounds. */
8
+ /** Convert the value to `WorkItemsCount` bounds. */
9
9
  export function tryAsWorkItemsCount(len) {
10
10
  check `
11
- ${len >= MIN_NUMBER_OF_WORK_ITEMS && len <= MAX_NUMBER_OF_WORK_ITEMS}
11
+ ${isWorkItemsCount(len)}
12
12
  WorkItemsCount: Expected '${MIN_NUMBER_OF_WORK_ITEMS} <= count <= ${MAX_NUMBER_OF_WORK_ITEMS}' got ${len}
13
13
  `;
14
14
  return tryAsU8(len);
15
15
  }
16
+ /** Verify the value is within the `WorkItemsCount` bounds. */
17
+ export function isWorkItemsCount(len) {
18
+ return len >= MIN_NUMBER_OF_WORK_ITEMS && len <= MAX_NUMBER_OF_WORK_ITEMS;
19
+ }
16
20
  /** Minimal number of work items in the work package or results in work report. */
17
21
  export const MIN_NUMBER_OF_WORK_ITEMS = 1;
18
22
  /** `I`: Maximal number of work items in the work package or results in work report. */
@@ -45,11 +45,9 @@ export declare class WorkExecResult extends WithDebug {
45
45
  /** Optional octet sequence - available only if `kind === ok` */
46
46
  readonly okBlob: BytesBlob | null;
47
47
  static Codec: import("@typeberry/codec").Descriptor<WorkExecResult, WorkExecResultUnion>;
48
- constructor(
49
- /** The execution result tag. */
50
- kind: WorkExecResultKind,
51
- /** Optional octet sequence - available only if `kind === ok` */
52
- okBlob?: BytesBlob | null);
48
+ static ok(blob: BytesBlob): WorkExecResult;
49
+ static error(kind: Exclude<WorkExecResultKind, WorkExecResultKind.ok>): WorkExecResult;
50
+ private constructor();
53
51
  }
54
52
  /**
55
53
  * Five fields describing the level of activity which this workload
@@ -1 +1 @@
1
- {"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block/work-result.ts"],"names":[],"mappings":"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AM,CAAC,KAAK,6EAkBR;IAEJ,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS;IAIzB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,EAAE,CAAC;IAIrE,OAAO;CAQR;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAoBzC,wDAAwD;aACxC,OAAO,EAAE,UAAU;IACnC,4CAA4C;aAC5B,gBAAgB,EAAE,GAAG;IACrC,+DAA+D;aAC/C,cAAc,EAAE,GAAG;IACnC,6DAA6D;aAC7C,aAAa,EAAE,GAAG;IAClC,4CAA4C;aAC5B,gBAAgB,EAAE,GAAG;IA5BvC,MAAM,CAAC,KAAK;;;;;;QAMT;IAEH,MAAM,CAAC,MAAM,CAAC,EACZ,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,EAAE,WAAW,CAAC,cAAc,CAAC;IAI9B,OAAO;CAcR;AAED;;;;GAIG;AACH,qBAAa,UAAU;IAenB,wFAAwF;aACxE,SAAS,EAAE,SAAS;IACpC,0EAA0E;aAC1D,QAAQ,EAAE,QAAQ;IAClC;;;;;;OAMG;aACa,WAAW,EAAE,UAAU;IACvC;;;;;OAKG;aACa,GAAG,EAAE,UAAU;IAC/B,6DAA6D;aAC7C,MAAM,EAAE,cAAc;IACtC;;;;;;OAMG;aACa,IAAI,EAAE,cAAc;IA1CtC,MAAM,CAAC,KAAK;;;;;;;;;;;;;QAOT;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,UAAU,CAAC;IAI9F,OAAO;CA+BR"}
@@ -40,6 +40,12 @@ export class WorkExecResult extends WithDebug {
40
40
  }
41
41
  return { kind: x.kind };
42
42
  }, (x) => new WorkExecResult(x.kind, x.kind === WorkExecResultKind.ok ? x.okBlob : null));
43
+ static ok(blob) {
44
+ return new WorkExecResult(WorkExecResultKind.ok, blob);
45
+ }
46
+ static error(kind) {
47
+ return new WorkExecResult(kind, null);
48
+ }
43
49
  constructor(
44
50
  /** The execution result tag. */
45
51
  kind,
@@ -1,4 +1,129 @@
1
1
  import { Block } from "#@typeberry/block";
2
2
  import type { ChainSpec } from "#@typeberry/config";
3
3
  export declare const blockFromJson: (spec: ChainSpec) => import("@typeberry/json-parser").FromJsonWithParser<unknown, Block>;
4
+ export declare const blockViewFromJson: (spec: ChainSpec) => import("@typeberry/json-parser").FromJsonWithParser<unknown, import("@typeberry/codec").ViewOf<Block, {
5
+ header: import("@typeberry/codec").Descriptor<import("@typeberry/block").Header & import("@typeberry/codec").CodecRecord<import("@typeberry/block").Header>, import("@typeberry/codec").ViewOf<import("@typeberry/block").Header & import("@typeberry/codec").CodecRecord<import("@typeberry/block").Header>, {
6
+ parentHeaderHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"HeaderHash">, import("@typeberry/bytes").Bytes<32>>;
7
+ priorStateRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"StateRootHash">, import("@typeberry/bytes").Bytes<32>>;
8
+ extrinsicHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"ExtrinsicHash">, import("@typeberry/bytes").Bytes<32>>;
9
+ timeSlotIndex: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"TimeSlot[u32]">, import("@typeberry/bytes").Bytes<4>>;
10
+ epochMarker: import("@typeberry/codec").Descriptor<import("@typeberry/block").EpochMarker | null, import("@typeberry/codec").ViewOf<import("@typeberry/block").EpochMarker, {
11
+ entropy: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"EntropyHash">, import("@typeberry/bytes").Bytes<32>>;
12
+ ticketsEntropy: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"EntropyHash">, import("@typeberry/bytes").Bytes<32>>;
13
+ validators: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block").ValidatorKeys[] & import("@typeberry/utils").WithOpaque<"ValidatorsCount">, import("@typeberry/codec").SequenceView<import("@typeberry/block").ValidatorKeys, import("@typeberry/codec").ViewOf<import("@typeberry/block").ValidatorKeys, {
14
+ bandersnatch: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"BandersnatchKey">, import("@typeberry/bytes").Bytes<32>>;
15
+ ed25519: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"Ed25519Key">, import("@typeberry/bytes").Bytes<32>>;
16
+ }>>>;
17
+ }> | null>;
18
+ ticketsMarker: import("@typeberry/codec").Descriptor<import("@typeberry/block").TicketsMarker | null, import("@typeberry/codec").ViewOf<import("@typeberry/block").TicketsMarker, {
19
+ tickets: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/tickets.js").Ticket[] & import("@typeberry/utils").WithOpaque<"EpochLength">, import("@typeberry/codec").SequenceView<import("@typeberry/block/tickets.js").Ticket, import("@typeberry/codec").ViewOf<import("@typeberry/block/tickets.js").Ticket, {
20
+ id: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32>, import("@typeberry/bytes").Bytes<32>>;
21
+ attempt: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<1> & import("@typeberry/utils").WithOpaque<"TicketAttempt[0|1|2]">, import("@typeberry/numbers").U8>;
22
+ }>>>;
23
+ }> | null>;
24
+ bandersnatchBlockAuthorIndex: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<2> & import("@typeberry/utils").WithOpaque<"ValidatorIndex[u16]">, import("@typeberry/bytes").Bytes<2>>;
25
+ entropySource: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<96> & import("@typeberry/utils").WithOpaque<"BandersnatchVrfSignature">, import("@typeberry/bytes").Bytes<96>>;
26
+ offendersMarker: import("@typeberry/codec").Descriptor<(import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"Ed25519Key">)[], import("@typeberry/codec").SequenceView<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"Ed25519Key">, import("@typeberry/bytes").Bytes<32>>>;
27
+ seal: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<96> & import("@typeberry/utils").WithOpaque<"BandersnatchVrfSignature">, import("@typeberry/bytes").Bytes<96>>;
28
+ }>>;
29
+ extrinsic: import("@typeberry/codec").Descriptor<import("@typeberry/block").Extrinsic, import("@typeberry/codec").ViewOf<import("@typeberry/block").Extrinsic, {
30
+ tickets: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/tickets.js").SignedTicket[] & import("@typeberry/utils").WithOpaque<"Size: [0..chainSpec.maxTicketsPerExtrinsic)">, import("@typeberry/codec").SequenceView<import("@typeberry/block/tickets.js").SignedTicket, import("@typeberry/codec").ViewOf<import("@typeberry/block/tickets.js").SignedTicket, {
31
+ attempt: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<1> & import("@typeberry/utils").WithOpaque<"TicketAttempt[0|1|2]">, import("@typeberry/numbers").U8>;
32
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<784> & import("@typeberry/utils").WithOpaque<"BandersnatchRingSignature">, import("@typeberry/bytes").Bytes<784>>;
33
+ }>>>;
34
+ preimages: import("@typeberry/codec").Descriptor<import("@typeberry/block/preimage.js").Preimage[], import("@typeberry/codec").SequenceView<import("@typeberry/block/preimage.js").Preimage, import("@typeberry/codec").ViewOf<import("@typeberry/block/preimage.js").Preimage, {
35
+ requester: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"ServiceId[u32]">, import("@typeberry/bytes").Bytes<4>>;
36
+ blob: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").BytesBlob, import("@typeberry/bytes").BytesBlob>;
37
+ }>>>;
38
+ guarantees: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/guarantees.js").ReportGuarantee[] & import("@typeberry/utils").WithOpaque<"[0..CoresCount)">, import("@typeberry/codec").SequenceView<import("@typeberry/block/guarantees.js").ReportGuarantee, import("@typeberry/codec").ViewOf<import("@typeberry/block/guarantees.js").ReportGuarantee, {
39
+ report: import("@typeberry/codec").Descriptor<import("@typeberry/block/work-report.js").WorkReport, import("@typeberry/codec").ViewOf<import("@typeberry/block/work-report.js").WorkReport, {
40
+ workPackageSpec: import("@typeberry/codec").Descriptor<import("@typeberry/block/work-report.js").WorkPackageSpec, import("@typeberry/codec").ViewOf<import("@typeberry/block/work-report.js").WorkPackageSpec, {
41
+ hash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">, import("@typeberry/bytes").Bytes<32>>;
42
+ length: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/bytes").Bytes<4>>;
43
+ erasureRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32>, import("@typeberry/bytes").Bytes<32>>;
44
+ exportsRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"ExportsRootHash">, import("@typeberry/bytes").Bytes<32>>;
45
+ exportsCount: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U16, import("@typeberry/bytes").Bytes<2>>;
46
+ }>>;
47
+ context: import("@typeberry/codec").Descriptor<import("@typeberry/block/refine-context.js").RefineContext, import("@typeberry/codec").ViewOf<import("@typeberry/block/refine-context.js").RefineContext, {
48
+ anchor: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"HeaderHash">, import("@typeberry/bytes").Bytes<32>>;
49
+ stateRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"StateRootHash">, import("@typeberry/bytes").Bytes<32>>;
50
+ beefyRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"BeefyHash">, import("@typeberry/bytes").Bytes<32>>;
51
+ lookupAnchor: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"HeaderHash">, import("@typeberry/bytes").Bytes<32>>;
52
+ lookupAnchorSlot: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"TimeSlot[u32]">, import("@typeberry/bytes").Bytes<4>>;
53
+ prerequisites: import("@typeberry/codec").Descriptor<(import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">)[], import("@typeberry/codec").SequenceView<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">, import("@typeberry/bytes").Bytes<32>>>;
54
+ }>>;
55
+ coreIndex: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<2> & import("@typeberry/utils").WithOpaque<"CoreIndex[u16]">, import("@typeberry/numbers").U32>;
56
+ authorizerHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"AuthorizerHash">, import("@typeberry/bytes").Bytes<32>>;
57
+ authorizationGasUsed: import("@typeberry/codec").Descriptor<bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">, import("@typeberry/numbers").U64>;
58
+ authorizationOutput: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").BytesBlob, import("@typeberry/bytes").BytesBlob>;
59
+ segmentRootLookup: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/refine-context.js").WorkPackageInfo[], import("@typeberry/codec").SequenceView<import("@typeberry/block/refine-context.js").WorkPackageInfo, import("@typeberry/codec").ViewOf<import("@typeberry/block/refine-context.js").WorkPackageInfo, {
60
+ workPackageHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">, import("@typeberry/bytes").Bytes<32>>;
61
+ segmentTreeRoot: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"ExportsRootHash">, import("@typeberry/bytes").Bytes<32>>;
62
+ }>>>;
63
+ results: import("@typeberry/codec").Descriptor<import("@typeberry/collections").FixedSizeArray<import("@typeberry/block/work-result.js").WorkResult, import("@typeberry/numbers").U8>, import("@typeberry/codec").SequenceView<import("@typeberry/block/work-result.js").WorkResult, import("@typeberry/codec").ViewOf<import("@typeberry/block/work-result.js").WorkResult, {
64
+ serviceId: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"ServiceId[u32]">, import("@typeberry/bytes").Bytes<4>>;
65
+ codeHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"CodeHash">, import("@typeberry/bytes").Bytes<32>>;
66
+ payloadHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32>, import("@typeberry/bytes").Bytes<32>>;
67
+ gas: import("@typeberry/codec").Descriptor<bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">, import("@typeberry/bytes").Bytes<8>>;
68
+ result: import("@typeberry/codec").Descriptor<import("@typeberry/block/work-result.js").WorkExecResult, {
69
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.ok;
70
+ okBlob: import("@typeberry/bytes").BytesBlob;
71
+ } | {
72
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.outOfGas;
73
+ } | {
74
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.panic;
75
+ } | {
76
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.incorrectNumberOfExports;
77
+ } | {
78
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.digestTooBig;
79
+ } | {
80
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.badCode;
81
+ } | {
82
+ kind: import("@typeberry/block/work-result.js").WorkExecResultKind.codeOversize;
83
+ }>;
84
+ load: import("@typeberry/codec").Descriptor<import("@typeberry/block/work-result.js").WorkRefineLoad, import("@typeberry/codec").ViewOf<import("@typeberry/block/work-result.js").WorkRefineLoad, {
85
+ gasUsed: import("@typeberry/codec").Descriptor<bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">, import("@typeberry/numbers").U64>;
86
+ importedSegments: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/numbers").U32>;
87
+ extrinsicCount: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/numbers").U32>;
88
+ extrinsicSize: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/numbers").U32>;
89
+ exportedSegments: import("@typeberry/codec").Descriptor<import("@typeberry/numbers").U32, import("@typeberry/numbers").U32>;
90
+ }>>;
91
+ }>>>;
92
+ }>>;
93
+ slot: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"TimeSlot[u32]">, import("@typeberry/bytes").Bytes<4>>;
94
+ credentials: import("@typeberry/codec").Descriptor<(readonly import("@typeberry/block/guarantees.js").Credential[] & import("@typeberry/utils").WithOpaque<"2">) | (readonly import("@typeberry/block/guarantees.js").Credential[] & import("@typeberry/utils").WithOpaque<"3">), import("@typeberry/codec").SequenceView<import("@typeberry/block/guarantees.js").Credential, import("@typeberry/codec").ViewOf<import("@typeberry/block/guarantees.js").Credential, {
95
+ validatorIndex: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<2> & import("@typeberry/utils").WithOpaque<"ValidatorIndex[u16]">, import("@typeberry/bytes").Bytes<2>>;
96
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<64> & import("@typeberry/utils").WithOpaque<"Ed25519Signature">, import("@typeberry/bytes").Bytes<64>>;
97
+ }>>>;
98
+ }>>>;
99
+ assurances: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/assurances.js").AvailabilityAssurance[] & import("@typeberry/utils").WithOpaque<"[0 .. ValidatorsCount)">, import("@typeberry/codec").SequenceView<import("@typeberry/block/assurances.js").AvailabilityAssurance, import("@typeberry/codec").ViewOf<import("@typeberry/block/assurances.js").AvailabilityAssurance, {
100
+ anchor: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"HeaderHash">, import("@typeberry/bytes").Bytes<32>>;
101
+ bitfield: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").BitVec, import("@typeberry/bytes").BitVec>;
102
+ validatorIndex: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<2> & import("@typeberry/utils").WithOpaque<"ValidatorIndex[u16]">, import("@typeberry/bytes").Bytes<2>>;
103
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<64> & import("@typeberry/utils").WithOpaque<"Ed25519Signature">, import("@typeberry/bytes").Bytes<64>>;
104
+ }>>>;
105
+ disputes: import("@typeberry/codec").Descriptor<import("@typeberry/block/disputes.js").DisputesExtrinsic, import("@typeberry/codec").ViewOf<import("@typeberry/block/disputes.js").DisputesExtrinsic, {
106
+ verdicts: import("@typeberry/codec").Descriptor<import("@typeberry/block/disputes.js").Verdict[], import("@typeberry/codec").SequenceView<import("@typeberry/block/disputes.js").Verdict, import("@typeberry/codec").ViewOf<import("@typeberry/block/disputes.js").Verdict, {
107
+ workReportHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkReportHash">, import("@typeberry/bytes").Bytes<32>>;
108
+ votesEpoch: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"Epoch">, import("@typeberry/bytes").Bytes<4>>;
109
+ votes: import("@typeberry/codec").Descriptor<readonly import("@typeberry/block/disputes.js").Judgement[] & import("@typeberry/utils").WithOpaque<"Validators super majority">, import("@typeberry/codec").SequenceView<import("@typeberry/block/disputes.js").Judgement, import("@typeberry/codec").ViewOf<import("@typeberry/block/disputes.js").Judgement, {
110
+ isWorkReportValid: import("@typeberry/codec").Descriptor<boolean, boolean>;
111
+ index: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<2> & import("@typeberry/utils").WithOpaque<"ValidatorIndex[u16]">, import("@typeberry/bytes").Bytes<2>>;
112
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<64> & import("@typeberry/utils").WithOpaque<"Ed25519Signature">, import("@typeberry/bytes").Bytes<64>>;
113
+ }>>>;
114
+ }>>>;
115
+ culprits: import("@typeberry/codec").Descriptor<import("@typeberry/block/disputes.js").Culprit[], import("@typeberry/codec").SequenceView<import("@typeberry/block/disputes.js").Culprit, import("@typeberry/codec").ViewOf<import("@typeberry/block/disputes.js").Culprit, {
116
+ workReportHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkReportHash">, import("@typeberry/bytes").Bytes<32>>;
117
+ key: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"Ed25519Key">, import("@typeberry/bytes").Bytes<32>>;
118
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<64> & import("@typeberry/utils").WithOpaque<"Ed25519Signature">, import("@typeberry/bytes").Bytes<64>>;
119
+ }>>>;
120
+ faults: import("@typeberry/codec").Descriptor<import("@typeberry/block/disputes.js").Fault[], import("@typeberry/codec").SequenceView<import("@typeberry/block/disputes.js").Fault, import("@typeberry/codec").ViewOf<import("@typeberry/block/disputes.js").Fault, {
121
+ workReportHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkReportHash">, import("@typeberry/bytes").Bytes<32>>;
122
+ wasConsideredValid: import("@typeberry/codec").Descriptor<boolean, boolean>;
123
+ key: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"Ed25519Key">, import("@typeberry/bytes").Bytes<32>>;
124
+ signature: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<64> & import("@typeberry/utils").WithOpaque<"Ed25519Signature">, import("@typeberry/bytes").Bytes<64>>;
125
+ }>>>;
126
+ }>>;
127
+ }>>;
128
+ }>>;
4
129
  //# sourceMappingURL=block.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,wEAO1C,CAAC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,wEAO1C,CAAC;AAEJ,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMhD,CAAC"}
@@ -1,8 +1,15 @@
1
- import { Block } from "#@typeberry/block";
2
- import { json } from "#@typeberry/json-parser";
1
+ import { Block, reencodeAsView } from "#@typeberry/block";
2
+ import { json, parseFromJson } from "#@typeberry/json-parser";
3
3
  import { getExtrinsicFromJson } from "./extrinsic.js";
4
4
  import { headerFromJson } from "./header.js";
5
5
  export const blockFromJson = (spec) => json.object({
6
6
  header: headerFromJson,
7
7
  extrinsic: getExtrinsicFromJson(spec),
8
8
  }, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
9
+ export const blockViewFromJson = (spec) => {
10
+ const parseBlock = blockFromJson(spec);
11
+ return json.fromAny((p) => {
12
+ const block = parseFromJson(p, parseBlock);
13
+ return reencodeAsView(Block.Codec, block, spec);
14
+ });
15
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/work-result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsD,UAAU,EAAE,MAAM,iCAAiC,CAAC;AA6EjH,eAAO,MAAM,kBAAkB,0EAkB9B,CAAC"}
1
+ {"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/work-result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsD,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAkFjH,eAAO,MAAM,kBAAkB,0EAkB9B,CAAC"}
@@ -15,22 +15,22 @@ const workExecResultFromJson = json.object({
15
15
  }, (val) => {
16
16
  const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
17
17
  if (ok !== undefined) {
18
- return new WorkExecResult(tryAsU32(WorkExecResultKind.ok), ok);
18
+ return WorkExecResult.ok(ok);
19
19
  }
20
20
  if (out_of_gas === null) {
21
- return new WorkExecResult(tryAsU32(WorkExecResultKind.outOfGas));
21
+ return WorkExecResult.error(WorkExecResultKind.outOfGas);
22
22
  }
23
23
  if (panic === null) {
24
- return new WorkExecResult(tryAsU32(WorkExecResultKind.panic));
24
+ return WorkExecResult.error(WorkExecResultKind.panic);
25
25
  }
26
26
  if (bad_code === null) {
27
- return new WorkExecResult(tryAsU32(WorkExecResultKind.badCode));
27
+ return WorkExecResult.error(WorkExecResultKind.badCode);
28
28
  }
29
29
  if (code_oversize === null) {
30
- return new WorkExecResult(tryAsU32(WorkExecResultKind.codeOversize));
30
+ return WorkExecResult.error(WorkExecResultKind.codeOversize);
31
31
  }
32
32
  if (output_oversize === null) {
33
- return new WorkExecResult(tryAsU32(WorkExecResultKind.digestTooBig));
33
+ return WorkExecResult.error(WorkExecResultKind.digestTooBig);
34
34
  }
35
35
  throw new Error("Invalid WorkExecResult");
36
36
  });
@@ -6,8 +6,7 @@ import { Bytes, BytesBlob } from "#@typeberry/bytes";
6
6
  import { SortedSet } from "#@typeberry/collections";
7
7
  import { tinyChainSpec } from "#@typeberry/config";
8
8
  import { Blake2b, HASH_SIZE } from "#@typeberry/hash";
9
- import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
10
- import { MAX_VALUE } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
9
+ import { MAX_VALUE_U32, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
11
10
  import { InMemoryState, LookupHistoryItem, PrivilegedServices, ServiceAccountInfo, tryAsLookupHistorySlots, tryAsPerCore, UpdateService, } from "#@typeberry/state";
12
11
  import { testState } from "#@typeberry/state/test.utils.js";
13
12
  import { StateEntries } from "#@typeberry/state-merkleization";
@@ -74,7 +73,9 @@ describe("LMDB States database", () => {
74
73
  manager: tryAsServiceId(1),
75
74
  assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(2)), spec),
76
75
  delegator: tryAsServiceId(3),
77
- registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? tryAsServiceId(4) : tryAsServiceId(MAX_VALUE),
76
+ registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
77
+ ? tryAsServiceId(4)
78
+ : tryAsServiceId(MAX_VALUE_U32),
78
79
  autoAccumulateServices: new Map(),
79
80
  }),
80
81
  updated: new Map([
@@ -0,0 +1,4 @@
1
+ export type { ReturnValue } from "#@typeberry/pvm-host-calls";
2
+ export { ReturnStatus } from "#@typeberry/pvm-host-calls";
3
+ export * from "./pvm-executor.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/executor/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ReturnStatus } from "#@typeberry/pvm-host-calls";
2
+ export * from "./pvm-executor.js";