@deroll/cm 0.1.0

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.
@@ -0,0 +1,671 @@
1
+ /**
2
+ * TypeScript type definitions for Cartesi Machine
3
+ * Based on the JSON-RPC schema from jsonrpc-discover.json
4
+ */
5
+ type UnsignedInteger = number;
6
+ type Base64String = string;
7
+ type Base64Hash = string;
8
+ type VirtIODeviceType = "console" | "p9fs" | "net-user" | "net-tuntap";
9
+ interface ConcurrencyRuntimeConfig {
10
+ update_merkle_tree?: UnsignedInteger;
11
+ }
12
+ interface HTIFRuntimeConfig {
13
+ no_console_putchar?: boolean;
14
+ }
15
+ interface MachineRuntimeConfig {
16
+ concurrency?: ConcurrencyRuntimeConfig;
17
+ htif?: HTIFRuntimeConfig;
18
+ skip_root_hash_check?: boolean;
19
+ skip_root_hash_store?: boolean;
20
+ skip_version_check?: boolean;
21
+ soft_yield?: boolean;
22
+ }
23
+ interface ProcessorConfig {
24
+ x0?: UnsignedInteger;
25
+ x1?: UnsignedInteger;
26
+ x2?: UnsignedInteger;
27
+ x3?: UnsignedInteger;
28
+ x4?: UnsignedInteger;
29
+ x5?: UnsignedInteger;
30
+ x6?: UnsignedInteger;
31
+ x7?: UnsignedInteger;
32
+ x8?: UnsignedInteger;
33
+ x9?: UnsignedInteger;
34
+ x10?: UnsignedInteger;
35
+ x11?: UnsignedInteger;
36
+ x12?: UnsignedInteger;
37
+ x13?: UnsignedInteger;
38
+ x14?: UnsignedInteger;
39
+ x15?: UnsignedInteger;
40
+ x16?: UnsignedInteger;
41
+ x17?: UnsignedInteger;
42
+ x18?: UnsignedInteger;
43
+ x19?: UnsignedInteger;
44
+ x20?: UnsignedInteger;
45
+ x21?: UnsignedInteger;
46
+ x22?: UnsignedInteger;
47
+ x23?: UnsignedInteger;
48
+ x24?: UnsignedInteger;
49
+ x25?: UnsignedInteger;
50
+ x26?: UnsignedInteger;
51
+ x27?: UnsignedInteger;
52
+ x28?: UnsignedInteger;
53
+ x29?: UnsignedInteger;
54
+ x30?: UnsignedInteger;
55
+ x31?: UnsignedInteger;
56
+ f0?: UnsignedInteger;
57
+ f1?: UnsignedInteger;
58
+ f2?: UnsignedInteger;
59
+ f3?: UnsignedInteger;
60
+ f4?: UnsignedInteger;
61
+ f5?: UnsignedInteger;
62
+ f6?: UnsignedInteger;
63
+ f7?: UnsignedInteger;
64
+ f8?: UnsignedInteger;
65
+ f9?: UnsignedInteger;
66
+ f10?: UnsignedInteger;
67
+ f11?: UnsignedInteger;
68
+ f12?: UnsignedInteger;
69
+ f13?: UnsignedInteger;
70
+ f14?: UnsignedInteger;
71
+ f15?: UnsignedInteger;
72
+ f16?: UnsignedInteger;
73
+ f17?: UnsignedInteger;
74
+ f18?: UnsignedInteger;
75
+ f19?: UnsignedInteger;
76
+ f20?: UnsignedInteger;
77
+ f21?: UnsignedInteger;
78
+ f22?: UnsignedInteger;
79
+ f23?: UnsignedInteger;
80
+ f24?: UnsignedInteger;
81
+ f25?: UnsignedInteger;
82
+ f26?: UnsignedInteger;
83
+ f27?: UnsignedInteger;
84
+ f28?: UnsignedInteger;
85
+ f29?: UnsignedInteger;
86
+ f30?: UnsignedInteger;
87
+ f31?: UnsignedInteger;
88
+ pc?: UnsignedInteger;
89
+ fcsr?: UnsignedInteger;
90
+ mvendorid?: UnsignedInteger;
91
+ marchid?: UnsignedInteger;
92
+ mimpid?: UnsignedInteger;
93
+ mcycle?: UnsignedInteger;
94
+ icycleinstret?: UnsignedInteger;
95
+ mstatus?: UnsignedInteger;
96
+ mtvec?: UnsignedInteger;
97
+ mscratch?: UnsignedInteger;
98
+ mepc?: UnsignedInteger;
99
+ mcause?: UnsignedInteger;
100
+ mtval?: UnsignedInteger;
101
+ misa?: UnsignedInteger;
102
+ mie?: UnsignedInteger;
103
+ mip?: UnsignedInteger;
104
+ medeleg?: UnsignedInteger;
105
+ mideleg?: UnsignedInteger;
106
+ mcounteren?: UnsignedInteger;
107
+ menvcfg?: UnsignedInteger;
108
+ stvec?: UnsignedInteger;
109
+ sscratch?: UnsignedInteger;
110
+ sepc?: UnsignedInteger;
111
+ scause?: UnsignedInteger;
112
+ stval?: UnsignedInteger;
113
+ satp?: UnsignedInteger;
114
+ scounteren?: UnsignedInteger;
115
+ senvcfg?: UnsignedInteger;
116
+ ilrsc?: UnsignedInteger;
117
+ iprv?: UnsignedInteger;
118
+ iflags_X?: UnsignedInteger;
119
+ iflags_Y?: UnsignedInteger;
120
+ iflags_H?: UnsignedInteger;
121
+ iunrep?: UnsignedInteger;
122
+ }
123
+ interface RAMConfig {
124
+ length: UnsignedInteger;
125
+ image_filename?: string;
126
+ }
127
+ interface DTBConfig {
128
+ bootargs?: string;
129
+ init?: string;
130
+ entrypoint?: string;
131
+ image_filename?: string;
132
+ }
133
+ interface MemoryRangeConfig {
134
+ start?: UnsignedInteger;
135
+ length?: UnsignedInteger;
136
+ image_filename?: string;
137
+ shared?: boolean;
138
+ }
139
+ interface MemoryRangeDescription {
140
+ start?: UnsignedInteger;
141
+ length?: UnsignedInteger;
142
+ description?: string;
143
+ }
144
+ interface Proof {
145
+ target_address: UnsignedInteger;
146
+ log2_target_size: UnsignedInteger;
147
+ target_hash: Base64Hash;
148
+ log2_root_size: UnsignedInteger;
149
+ root_hash: Base64Hash;
150
+ sibling_hashes: Base64Hash[];
151
+ }
152
+ type AccessType = "read" | "write";
153
+ interface AccessLogType {
154
+ has_annotations: boolean;
155
+ has_large_data: boolean;
156
+ }
157
+ interface Access {
158
+ type: AccessType;
159
+ address: UnsignedInteger;
160
+ log2_size: UnsignedInteger;
161
+ read_hash: Base64Hash;
162
+ read?: Base64String;
163
+ written_hash?: Base64Hash;
164
+ written?: Base64String;
165
+ sibling_hashes?: Base64Hash[];
166
+ }
167
+ type BracketType = "begin" | "end";
168
+ interface Bracket {
169
+ type: BracketType;
170
+ where: UnsignedInteger;
171
+ text: string;
172
+ }
173
+ interface AccessLog {
174
+ log_type: AccessLogType;
175
+ accesses: Access[];
176
+ notes?: string[];
177
+ brackets?: Bracket[];
178
+ }
179
+ type FlashDriveConfigs = MemoryRangeConfig[];
180
+ interface TLBConfig {
181
+ image_filename?: string;
182
+ }
183
+ interface CLINTConfig {
184
+ mtimecmp?: UnsignedInteger;
185
+ }
186
+ interface PLICConfig {
187
+ girqpend?: UnsignedInteger;
188
+ girqsrvd?: UnsignedInteger;
189
+ }
190
+ interface HTIFConfig {
191
+ fromhost?: UnsignedInteger;
192
+ tohost?: UnsignedInteger;
193
+ console_getchar?: boolean;
194
+ yield_manual?: boolean;
195
+ yield_automatic?: boolean;
196
+ }
197
+ interface UarchProcessorConfig {
198
+ x0?: UnsignedInteger;
199
+ x1?: UnsignedInteger;
200
+ x2?: UnsignedInteger;
201
+ x3?: UnsignedInteger;
202
+ x4?: UnsignedInteger;
203
+ x5?: UnsignedInteger;
204
+ x6?: UnsignedInteger;
205
+ x7?: UnsignedInteger;
206
+ x8?: UnsignedInteger;
207
+ x9?: UnsignedInteger;
208
+ x10?: UnsignedInteger;
209
+ x11?: UnsignedInteger;
210
+ x12?: UnsignedInteger;
211
+ x13?: UnsignedInteger;
212
+ x14?: UnsignedInteger;
213
+ x15?: UnsignedInteger;
214
+ x16?: UnsignedInteger;
215
+ x17?: UnsignedInteger;
216
+ x18?: UnsignedInteger;
217
+ x19?: UnsignedInteger;
218
+ x20?: UnsignedInteger;
219
+ x21?: UnsignedInteger;
220
+ x22?: UnsignedInteger;
221
+ x23?: UnsignedInteger;
222
+ x24?: UnsignedInteger;
223
+ x25?: UnsignedInteger;
224
+ x26?: UnsignedInteger;
225
+ x27?: UnsignedInteger;
226
+ x28?: UnsignedInteger;
227
+ x29?: UnsignedInteger;
228
+ x30?: UnsignedInteger;
229
+ x31?: UnsignedInteger;
230
+ pc?: UnsignedInteger;
231
+ cycle?: UnsignedInteger;
232
+ halt_flag?: boolean;
233
+ }
234
+ interface UarchRAMConfig {
235
+ length?: UnsignedInteger;
236
+ image_filename?: string;
237
+ }
238
+ interface UarchConfig {
239
+ processor?: UarchProcessorConfig;
240
+ ram?: UarchRAMConfig;
241
+ }
242
+ interface CmioBufferConfig {
243
+ image_filename?: string;
244
+ shared?: boolean;
245
+ }
246
+ interface CmioConfig {
247
+ rx_buffer?: CmioBufferConfig;
248
+ tx_buffer?: CmioBufferConfig;
249
+ }
250
+ interface VirtIOHostfwd {
251
+ is_udp?: boolean;
252
+ host_ip?: UnsignedInteger;
253
+ guest_ip?: UnsignedInteger;
254
+ host_port?: UnsignedInteger;
255
+ guest_port?: UnsignedInteger;
256
+ }
257
+ interface VirtIODeviceConfig {
258
+ type: VirtIODeviceType;
259
+ tag?: string;
260
+ host_directory?: string;
261
+ hostfwd?: VirtIOHostfwd[];
262
+ iface?: string;
263
+ }
264
+ type VirtIOConfigs = VirtIODeviceConfig[];
265
+ interface MachineConfig {
266
+ processor?: ProcessorConfig;
267
+ ram: RAMConfig;
268
+ dtb?: DTBConfig;
269
+ flash_drive?: FlashDriveConfigs;
270
+ tlb?: TLBConfig;
271
+ clint?: CLINTConfig;
272
+ plic?: PLICConfig;
273
+ htif?: HTIFConfig;
274
+ uarch?: UarchConfig;
275
+ cmio?: CmioConfig;
276
+ virtio?: VirtIOConfigs;
277
+ }
278
+
279
+ /**
280
+ * The maximum value for mcycle
281
+ */
282
+ declare const MAX_MCYCLE = 4722366482869645213695n;
283
+ declare enum Constant {
284
+ HashSize = 32,
285
+ TreeLog2WordSize = 5,
286
+ TreeLog2PageSize = 12,
287
+ TreeLog2RootSize = 64
288
+ }
289
+ declare const PmaConstant: {
290
+ readonly CmioRxBufferStart: 1610612736n;
291
+ readonly CmioRxBufferLog2Size: 21;
292
+ readonly CmioTxBufferStart: 1619001344n;
293
+ readonly CmioTxBufferLog2Size: 21;
294
+ readonly RamStart: 2147483648n;
295
+ };
296
+ declare enum ErrorCode {
297
+ Ok = 0,
298
+ InvalidArgument = -1,
299
+ DomainError = -2,
300
+ LengthError = -3,
301
+ OutOfRange = -4,
302
+ LogicError = -5,
303
+ RuntimeError = -6,
304
+ RangeError = -7,
305
+ OverflowError = -8,
306
+ UnderflowError = -9,
307
+ RegexError = -10,
308
+ SystemError = -11,
309
+ BadTypeid = -12,
310
+ BadCast = -13,
311
+ BadAnyCast = -14,
312
+ BadOptionalAccess = -15,
313
+ BadWeakPtr = -16,
314
+ BadFunctionCall = -17,
315
+ BadAlloc = -18,
316
+ BadArrayNewLength = -19,
317
+ BadException = -20,
318
+ BadVariantAccess = -21,
319
+ Exception = -22,
320
+ Unknown = -23
321
+ }
322
+ /**
323
+ * Custom error class for Cartesi Machine operations
324
+ * Contains both the error code and a human-readable description
325
+ */
326
+ declare class MachineError extends Error {
327
+ readonly code: ErrorCode;
328
+ readonly description: string;
329
+ constructor(code: ErrorCode, description: string);
330
+ /**
331
+ * Creates a MachineError from an error code, automatically fetching the description
332
+ */
333
+ static fromCode(code: ErrorCode): MachineError;
334
+ }
335
+ declare enum BreakReason {
336
+ Failed = 0,
337
+ Halted = 1,
338
+ YieldedManually = 2,
339
+ YieldedAutomatically = 3,
340
+ YieldedSoftly = 4,
341
+ ReachedTargetMcycle = 5
342
+ }
343
+ declare enum UarchBreakReason {
344
+ ReachedTargetCycle = 0,
345
+ UarchHalted = 1,
346
+ Failed = 2
347
+ }
348
+ declare enum CmioYieldCommand {
349
+ Automatic = 0,
350
+ Manual = 1
351
+ }
352
+ declare enum CmioYieldReason {
353
+ AutomaticProgress = 1,///< Progress is available
354
+ AutomaticTxOutput = 2,///< Output is available in tx buffer
355
+ AutomaticTxReport = 4,///< Report is available in tx buffer
356
+ ManualRxAccepted = 1,///< Input in rx buffer was accepted
357
+ ManualRxRejected = 2,///< Input in rx buffer was rejected
358
+ ManualTxException = 4,///< Exception happened
359
+ AdvanceState = 0,///< Input in rx buffer is an advance state
360
+ InspectState = 1
361
+ }
362
+ declare enum Reg {
363
+ X0 = 0,
364
+ X1 = 1,
365
+ X2 = 2,
366
+ X3 = 3,
367
+ X4 = 4,
368
+ X5 = 5,
369
+ X6 = 6,
370
+ X7 = 7,
371
+ X8 = 8,
372
+ X9 = 9,
373
+ X10 = 10,
374
+ X11 = 11,
375
+ X12 = 12,
376
+ X13 = 13,
377
+ X14 = 14,
378
+ X15 = 15,
379
+ X16 = 16,
380
+ X17 = 17,
381
+ X18 = 18,
382
+ X19 = 19,
383
+ X20 = 20,
384
+ X21 = 21,
385
+ X22 = 22,
386
+ X23 = 23,
387
+ X24 = 24,
388
+ X25 = 25,
389
+ X26 = 26,
390
+ X27 = 27,
391
+ X28 = 28,
392
+ X29 = 29,
393
+ X30 = 30,
394
+ X31 = 31,
395
+ F0 = 32,
396
+ F1 = 33,
397
+ F2 = 34,
398
+ F3 = 35,
399
+ F4 = 36,
400
+ F5 = 37,
401
+ F6 = 38,
402
+ F7 = 39,
403
+ F8 = 40,
404
+ F9 = 41,
405
+ F10 = 42,
406
+ F11 = 43,
407
+ F12 = 44,
408
+ F13 = 45,
409
+ F14 = 46,
410
+ F15 = 47,
411
+ F16 = 48,
412
+ F17 = 49,
413
+ F18 = 50,
414
+ F19 = 51,
415
+ F20 = 52,
416
+ F21 = 53,
417
+ F22 = 54,
418
+ F23 = 55,
419
+ F24 = 56,
420
+ F25 = 57,
421
+ F26 = 58,
422
+ F27 = 59,
423
+ F28 = 60,
424
+ F29 = 61,
425
+ F30 = 62,
426
+ F31 = 63,
427
+ Pc = 64,
428
+ Fcsr = 65,
429
+ Mvendorid = 66,
430
+ Marchid = 67,
431
+ Mimpid = 68,
432
+ Mcycle = 69,
433
+ Icycleinstret = 70,
434
+ Mstatus = 71,
435
+ Mtvec = 72,
436
+ Mscratch = 73,
437
+ Mepc = 74,
438
+ Mcause = 75,
439
+ Mtval = 76,
440
+ Misa = 77,
441
+ Mie = 78,
442
+ Mip = 79,
443
+ Medeleg = 80,
444
+ Mideleg = 81,
445
+ Mcounteren = 82,
446
+ Menvcfg = 83,
447
+ Stvec = 84,
448
+ Sscratch = 85,
449
+ Sepc = 86,
450
+ Scause = 87,
451
+ Stval = 88,
452
+ Satp = 89,
453
+ Scounteren = 90,
454
+ Senvcfg = 91,
455
+ Ilrsc = 92,
456
+ Iprv = 93,
457
+ IflagsX = 94,
458
+ IflagsY = 95,
459
+ IflagsH = 96,
460
+ Iunrep = 97,
461
+ ClintMtimecmp = 98,
462
+ PlicGirqpend = 99,
463
+ PlicGirqsrvd = 100,
464
+ HtifToHost = 101,
465
+ HtifFromHost = 102,
466
+ HtifIhalt = 103,
467
+ HtifIconsole = 104,
468
+ HtifIyield = 105,
469
+ UarchX0 = 106,
470
+ UarchX1 = 107,
471
+ UarchX2 = 108,
472
+ UarchX3 = 109,
473
+ UarchX4 = 110,
474
+ UarchX5 = 111,
475
+ UarchX6 = 112,
476
+ UarchX7 = 113,
477
+ UarchX8 = 114,
478
+ UarchX9 = 115,
479
+ UarchX10 = 116,
480
+ UarchX11 = 117,
481
+ UarchX12 = 118,
482
+ UarchX13 = 119,
483
+ UarchX14 = 120,
484
+ UarchX15 = 121,
485
+ UarchX16 = 122,
486
+ UarchX17 = 123,
487
+ UarchX18 = 124,
488
+ UarchX19 = 125,
489
+ UarchX20 = 126,
490
+ UarchX21 = 127,
491
+ UarchX22 = 128,
492
+ UarchX23 = 129,
493
+ UarchX24 = 130,
494
+ UarchX25 = 131,
495
+ UarchX26 = 132,
496
+ UarchX27 = 133,
497
+ UarchX28 = 134,
498
+ UarchX29 = 135,
499
+ UarchX30 = 136,
500
+ UarchX31 = 137,
501
+ UarchPc = 138,
502
+ UarchCycle = 139,
503
+ UarchHaltFlag = 140,
504
+ HtifToHostDev = 141,
505
+ HtifToHostCmd = 142,
506
+ HtifToHostReason = 143,
507
+ HtifToHostData = 144,
508
+ HtifFromHostDev = 145,
509
+ HtifFromHostCmd = 146,
510
+ HtifFromHostReason = 147,
511
+ HtifFromHostData = 148,
512
+ Unknown_ = 149,
513
+ First_ = 150,
514
+ Last_ = 151
515
+ }
516
+ interface CartesiMachine {
517
+ isEmpty(): boolean;
518
+ create(config: MachineConfig, runtimeConfig?: MachineRuntimeConfig): CartesiMachine;
519
+ load(dir: string, runtimeConfig?: MachineRuntimeConfig): CartesiMachine;
520
+ cloneEmpty(): CartesiMachine;
521
+ store(dir: string): CartesiMachine;
522
+ destroy(): void;
523
+ getDefaultConfig(): MachineConfig;
524
+ setRuntimeConfig(runtimeConfig: MachineRuntimeConfig): void;
525
+ getRuntimeConfig(): MachineRuntimeConfig;
526
+ replaceMemoryRange(start: bigint, length: bigint, shared: boolean, imageFilename?: string): void;
527
+ getInitialConfig(): MachineConfig;
528
+ getMemoryRanges(): MemoryRangeDescription[];
529
+ getRegAddress(reg: Reg): bigint;
530
+ getRootHash(): Buffer;
531
+ getProof(address: bigint, log2Size: number): Proof;
532
+ readWord(address: bigint): bigint;
533
+ readReg(reg: Reg): bigint;
534
+ writeReg(reg: Reg, value: bigint): void;
535
+ readMemory(address: bigint, length: bigint): Buffer;
536
+ writeMemory(address: bigint, data: Buffer): void;
537
+ readVirtualMemory(address: bigint, length: bigint): Buffer;
538
+ writeVirtualMemory(address: bigint, data: Buffer): void;
539
+ translateVirtualAddress(vaddr: bigint): bigint;
540
+ run(mcycleEnd?: bigint): BreakReason;
541
+ runUarch(uarchCycleEnd: bigint): UarchBreakReason;
542
+ resetUarch(): void;
543
+ receiveCmioRequest(): {
544
+ cmd: CmioYieldCommand;
545
+ reason: CmioYieldReason;
546
+ data: Buffer;
547
+ };
548
+ sendCmioResponse(reason: CmioYieldReason, data: Buffer): void;
549
+ logStep(mcycleCount: bigint, logFilename: string): BreakReason;
550
+ logStepUarch(logType: AccessLogType): AccessLog;
551
+ logResetUarch(logType: AccessLogType): AccessLog;
552
+ logSendCmioResponse(reason: CmioYieldReason, data: Buffer, logType: AccessLogType): string;
553
+ verifyStep(rootHashBefore: Buffer, logFilename: string, mcycleCount: bigint, rootHashAfter: Buffer): BreakReason;
554
+ verifyStepUarch(rootHashBefore: Buffer, log: AccessLog, rootHashAfter: Buffer): void;
555
+ verifyResetUarch(rootHashBefore: Buffer, log: AccessLog, rootHashAfter: Buffer): void;
556
+ verifyMerkleTree(): boolean;
557
+ verifyDirtyPageMaps(): boolean;
558
+ }
559
+ declare function empty(): CartesiMachine;
560
+ declare function create(config: MachineConfig, runtimeConfig?: MachineRuntimeConfig): CartesiMachine;
561
+ declare function load(dir: string, runtimeConfig?: MachineRuntimeConfig): CartesiMachine;
562
+ declare function getLastError(): string;
563
+ declare function getDefaultConfig(): MachineConfig;
564
+ declare function getRegAddress(reg: Reg): bigint;
565
+ declare function verifyStep(rootHashBefore: Buffer, logFilename: string, mcycleCount: bigint, rootHashAfter: Buffer): BreakReason;
566
+ declare function verifyStepUarch(rootHashBefore: Buffer, log: AccessLog, rootHashAfter: Buffer): void;
567
+ declare function verifyResetUarch(rootHashBefore: Buffer, log: AccessLog, rootHashAfter: Buffer): void;
568
+ declare function verifySendCmioResponse(reason: CmioYieldReason, data: Buffer, rootHashBefore: Buffer, log: AccessLog, rootHashAfter: Buffer): void;
569
+
570
+ declare enum CleanupCall {
571
+ Nothing = 0,// CM_JSONRPC_NOTHING
572
+ Destroy = 1,// CM_JSONRPC_DESTROY
573
+ Shutdown = 2
574
+ }
575
+ interface RemoteCartesiMachine extends CartesiMachine {
576
+ getServerAddress(): string;
577
+ getServerPid(): number | null;
578
+ shutdown(): void;
579
+ rebind(address: string): string;
580
+ emancipate(): void;
581
+ setTimeout(ms: number): void;
582
+ getTimeout(): number;
583
+ setCleanupCall(call: CleanupCall): RemoteCartesiMachine;
584
+ getCleanupCall(): CleanupCall;
585
+ getServerVersion(): string;
586
+ delayNextRequest(ms: number): void;
587
+ getBoundAddress(): string | null;
588
+ fork(): RemoteCartesiMachine;
589
+ load(dir: string, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine;
590
+ cloneEmpty(): RemoteCartesiMachine;
591
+ create(config: MachineConfig, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine;
592
+ store(dir: string): RemoteCartesiMachine;
593
+ }
594
+ declare function spawn(address?: string, timeout?: number): RemoteCartesiMachine;
595
+ declare function connect(address: string, timeout?: number): RemoteCartesiMachine;
596
+
597
+ /**
598
+ * Custom error class to signal the rollup has entered an invalid state
599
+ */
600
+ declare class RollupsFatalError extends Error {
601
+ constructor(message: string);
602
+ }
603
+ /**
604
+ * Custom error class to signal an input was rejected
605
+ */
606
+ declare class RollupsInputRejectedError extends Error {
607
+ constructor();
608
+ }
609
+ /**
610
+ * Advance requests can yield either an output or a report, indicated by the type field.
611
+ * The data field contains the output or report data.
612
+ */
613
+ type AdvanceYield = {
614
+ type: "output";
615
+ data: Buffer;
616
+ } | {
617
+ type: "report";
618
+ data: Buffer;
619
+ } | {
620
+ type: "progress";
621
+ data: number;
622
+ };
623
+ type AdvanceReturn = Buffer;
624
+ type AdvanceResult = {
625
+ outputs: Buffer[];
626
+ reports: Buffer[];
627
+ outputsMerkleRoot: Buffer;
628
+ };
629
+ interface RollupsMachine {
630
+ advance(input: Buffer): IterableIterator<AdvanceYield, AdvanceReturn>;
631
+ advance(input: Buffer, options: {
632
+ collect: true;
633
+ }): AdvanceResult;
634
+ inspect(query: Buffer): IterableIterator<Buffer>;
635
+ inspect(query: Buffer, options: {
636
+ collect: true;
637
+ }): Buffer[];
638
+ shutdown(): void;
639
+ store(dir: string): RollupsMachine;
640
+ }
641
+ /**
642
+ * Create a rollups machine from a remote machine.
643
+ * @param machine - The remote machine.
644
+ * @returns A rollups machine.
645
+ */
646
+ declare function rollups(machine: RemoteCartesiMachine, options?: {
647
+ noRollback: boolean;
648
+ }): RollupsMachine;
649
+ /**
650
+ * Create a rollups machine from a local machine.
651
+ * @param machine - The local machine.
652
+ * @returns A rollups machine.
653
+ */
654
+ declare function rollups(machine: CartesiMachine): RollupsMachine;
655
+ /**
656
+ * Create a rollups machine from a store directory.
657
+ * @param dir - The directory containing the store.
658
+ * @param runtimeConfig - The runtime configuration.
659
+ * @param address - The address of the remote machine.
660
+ * @param timeout - The timeout for the remote machine.
661
+ * @description This function spawns a new machine, and loads the stored snapshot on it.
662
+ * @returns A rollups machine.
663
+ */
664
+ declare function rollups(dir: string, options?: {
665
+ noRollback?: boolean;
666
+ runtimeConfig?: MachineRuntimeConfig;
667
+ address?: string;
668
+ timeout?: number;
669
+ }): RollupsMachine;
670
+
671
+ export { type Access, type AccessLog, type AccessLogType, type AccessType, type AdvanceResult, type AdvanceReturn, type AdvanceYield, type Base64Hash, type Base64String, type Bracket, type BracketType, BreakReason, type CLINTConfig, type CartesiMachine, CleanupCall, type CmioBufferConfig, type CmioConfig, CmioYieldCommand, CmioYieldReason, type ConcurrencyRuntimeConfig, Constant, type DTBConfig, ErrorCode, type FlashDriveConfigs, type HTIFConfig, type HTIFRuntimeConfig, MAX_MCYCLE, type MachineConfig, MachineError, type MachineRuntimeConfig, type MemoryRangeConfig, type MemoryRangeDescription, type PLICConfig, PmaConstant, type ProcessorConfig, type Proof, type RAMConfig, Reg, type RemoteCartesiMachine, RollupsFatalError, RollupsInputRejectedError, type RollupsMachine, type TLBConfig, UarchBreakReason, type UarchConfig, type UarchProcessorConfig, type UarchRAMConfig, type UnsignedInteger, type VirtIOConfigs, type VirtIODeviceConfig, type VirtIODeviceType, type VirtIOHostfwd, connect, create, empty, getDefaultConfig, getLastError, getRegAddress, load, rollups, spawn, verifyResetUarch, verifySendCmioResponse, verifyStep, verifyStepUarch };