@aztec/stdlib 4.0.0-nightly.20260121 → 4.0.0-nightly.20260122

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 (51) hide show
  1. package/dest/block/l2_block_source.d.ts +13 -1
  2. package/dest/block/l2_block_source.d.ts.map +1 -1
  3. package/dest/block/l2_block_stream/l2_block_stream.d.ts +5 -1
  4. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  5. package/dest/block/l2_block_stream/l2_block_stream.js +34 -22
  6. package/dest/config/node-rpc-config.js +1 -1
  7. package/dest/interfaces/api_limit.d.ts +2 -1
  8. package/dest/interfaces/api_limit.d.ts.map +1 -1
  9. package/dest/interfaces/api_limit.js +1 -0
  10. package/dest/interfaces/archiver.d.ts +1 -1
  11. package/dest/interfaces/archiver.d.ts.map +1 -1
  12. package/dest/interfaces/archiver.js +4 -2
  13. package/dest/interfaces/aztec-node-admin.d.ts +4 -1
  14. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  15. package/dest/interfaces/aztec-node.d.ts +14 -5
  16. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  17. package/dest/interfaces/aztec-node.js +2 -2
  18. package/dest/interfaces/l2_logs_source.d.ts +14 -5
  19. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  20. package/dest/interfaces/prover-client.d.ts +10 -1
  21. package/dest/interfaces/prover-client.d.ts.map +1 -1
  22. package/dest/interfaces/prover-client.js +7 -1
  23. package/dest/p2p/constants.d.ts +3 -0
  24. package/dest/p2p/constants.d.ts.map +1 -0
  25. package/dest/p2p/constants.js +2 -0
  26. package/dest/p2p/index.d.ts +2 -1
  27. package/dest/p2p/index.d.ts.map +1 -1
  28. package/dest/p2p/index.js +1 -0
  29. package/dest/tx/tx.d.ts +2 -1
  30. package/dest/tx/tx.d.ts.map +1 -1
  31. package/dest/tx/tx.js +6 -3
  32. package/dest/tx/tx_receipt.d.ts +39 -11
  33. package/dest/tx/tx_receipt.d.ts.map +1 -1
  34. package/dest/tx/tx_receipt.js +44 -13
  35. package/dest/tx/validator/error_texts.d.ts +2 -1
  36. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  37. package/dest/tx/validator/error_texts.js +2 -0
  38. package/package.json +9 -9
  39. package/src/block/l2_block_source.ts +14 -0
  40. package/src/block/l2_block_stream/l2_block_stream.ts +40 -22
  41. package/src/config/node-rpc-config.ts +1 -1
  42. package/src/interfaces/api_limit.ts +1 -0
  43. package/src/interfaces/archiver.ts +4 -2
  44. package/src/interfaces/aztec-node.ts +19 -6
  45. package/src/interfaces/l2_logs_source.ts +17 -4
  46. package/src/interfaces/prover-client.ts +15 -0
  47. package/src/p2p/constants.ts +3 -0
  48. package/src/p2p/index.ts +1 -0
  49. package/src/tx/tx.ts +8 -9
  50. package/src/tx/tx_receipt.ts +72 -15
  51. package/src/tx/validator/error_texts.ts +3 -0
@@ -17,6 +17,12 @@ export type ActualProverConfig = {
17
17
  proverTestDelayMs: number;
18
18
  /** If using realistic delays, what percentage of realistic times to apply. */
19
19
  proverTestDelayFactor: number;
20
+ /**
21
+ * Whether to abort pending proving jobs when the orchestrator is cancelled.
22
+ * When false (default), jobs remain in the broker queue and can be reused on restart/reorg.
23
+ * When true, jobs are explicitly cancelled with the broker, which prevents reuse.
24
+ */
25
+ cancelJobsOnStop: boolean;
20
26
  };
21
27
 
22
28
  /**
@@ -43,6 +49,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
43
49
  proverTestDelayFactor: z.number(),
44
50
  proverAgentCount: z.number(),
45
51
  failedProofStore: z.string().optional(),
52
+ cancelJobsOnStop: z.boolean(),
46
53
  }),
47
54
  );
48
55
 
@@ -85,6 +92,14 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
85
92
  description:
86
93
  'Store for failed proof inputs. Google cloud storage is only supported at the moment. Set this value as gs://bucket-name/path/to/store.',
87
94
  },
95
+ cancelJobsOnStop: {
96
+ env: 'PROVER_CANCEL_JOBS_ON_STOP',
97
+ description:
98
+ 'Whether to abort pending proving jobs when the orchestrator is cancelled. ' +
99
+ 'When false (default), jobs remain in the broker queue and can be reused on restart/reorg. ' +
100
+ 'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
101
+ ...booleanConfigHelper(false),
102
+ },
88
103
  };
89
104
 
90
105
  function parseProverId(str?: string) {
@@ -0,0 +1,3 @@
1
+ export const MAX_TX_SIZE_KB: number = 512;
2
+
3
+ export const MAX_MESSAGE_SIZE_KB: number = 10 * 1024;
package/src/p2p/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from './topic_type.js';
11
11
  export * from './client_type.js';
12
12
  export * from './message_validator.js';
13
13
  export * from './peer_error.js';
14
+ export * from './constants.js';
package/src/tx/tx.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
- import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
3
2
  import { Fr } from '@aztec/foundation/curves/bn254';
4
3
  import type { ZodFor } from '@aztec/foundation/schemas';
5
4
  import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -247,7 +246,7 @@ export class Tx extends Gossipable {
247
246
  contractClassLogSize: this.data.getEmittedContractClassLogsLength(),
248
247
 
249
248
  proofSize: this.chonkProof.fields.length,
250
- size: this.toBuffer().length,
249
+ size: this.getSize(),
251
250
 
252
251
  feePaymentMethod:
253
252
  // needsSetup? then we pay through a fee payment contract
@@ -255,13 +254,13 @@ export class Tx extends Gossipable {
255
254
  };
256
255
  }
257
256
 
258
- getSize() {
259
- return (
260
- this.data.getSize() +
261
- this.chonkProof.fields.length * Fr.SIZE_IN_BYTES +
262
- arraySerializedSizeOfNonEmpty(this.contractClassLogFields) +
263
- this.publicFunctionCalldata.reduce((accum, cd) => accum + cd.getSize(), 0)
264
- );
257
+ private sizeCache: number | undefined;
258
+
259
+ getSize(): number {
260
+ if (this.sizeCache == undefined) {
261
+ this.sizeCache = this.toBuffer().length;
262
+ }
263
+ return this.sizeCache;
265
264
  }
266
265
 
267
266
  /**
@@ -1,5 +1,4 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
2
 
4
3
  import { z } from 'zod';
5
4
 
@@ -8,12 +7,28 @@ import { L2BlockHash } from '../block/block_hash.js';
8
7
  import { type ZodFor, schemas } from '../schemas/schemas.js';
9
8
  import { TxHash } from './tx_hash.js';
10
9
 
11
- /**
12
- * Possible status of a transaction.
13
- */
10
+ /** Block inclusion/finalization status. */
14
11
  export enum TxStatus {
15
12
  DROPPED = 'dropped',
16
13
  PENDING = 'pending',
14
+ PROPOSED = 'proposed',
15
+ CHECKPOINTED = 'checkpointed',
16
+ PROVEN = 'proven',
17
+ FINALIZED = 'finalized', // TODO(#13569): Implement finalized status properly
18
+ }
19
+
20
+ /** Tx status sorted by finalization progress. */
21
+ export const SortedTxStatuses: TxStatus[] = [
22
+ TxStatus.DROPPED,
23
+ TxStatus.PENDING,
24
+ TxStatus.PROPOSED,
25
+ TxStatus.CHECKPOINTED,
26
+ TxStatus.PROVEN,
27
+ TxStatus.FINALIZED,
28
+ ];
29
+
30
+ /** Execution result - only set when tx is in a block. */
31
+ export enum TxExecutionResult {
17
32
  SUCCESS = 'success',
18
33
  APP_LOGIC_REVERTED = 'app_logic_reverted',
19
34
  TEARDOWN_REVERTED = 'teardown_reverted',
@@ -30,10 +45,12 @@ export class TxReceipt {
30
45
  constructor(
31
46
  /** A unique identifier for a transaction. */
32
47
  public txHash: TxHash,
33
- /** The transaction's status. */
48
+ /** The transaction's block finalization status. */
34
49
  public status: TxStatus,
50
+ /** The execution result of the transaction, only set when tx is in a block. */
51
+ public executionResult: TxExecutionResult | undefined,
35
52
  /** Description of transaction error, if any. */
36
- public error: string,
53
+ public error: string | undefined,
37
54
  /** The transaction fee paid for the transaction. */
38
55
  public transactionFee?: bigint,
39
56
  /** The hash of the block containing the transaction. */
@@ -42,8 +59,38 @@ export class TxReceipt {
42
59
  public blockNumber?: BlockNumber,
43
60
  ) {}
44
61
 
62
+ /** Returns true if the transaction was executed successfully. */
63
+ hasExecutionSucceeded(): boolean {
64
+ return this.executionResult === TxExecutionResult.SUCCESS;
65
+ }
66
+
67
+ /** Returns true if the transaction execution reverted. */
68
+ hasExecutionReverted(): boolean {
69
+ return this.executionResult !== undefined && this.executionResult !== TxExecutionResult.SUCCESS;
70
+ }
71
+
72
+ /** Returns true if the transaction has been included in a block (proposed, checkpointed, proven, or finalized). */
73
+ isMined(): boolean {
74
+ return (
75
+ this.status === TxStatus.PROPOSED ||
76
+ this.status === TxStatus.CHECKPOINTED ||
77
+ this.status === TxStatus.PROVEN ||
78
+ this.status === TxStatus.FINALIZED
79
+ );
80
+ }
81
+
82
+ /** Returns true if the transaction is pending. */
83
+ isPending(): boolean {
84
+ return this.status === TxStatus.PENDING;
85
+ }
86
+
87
+ /** Returns true if the transaction was dropped. */
88
+ isDropped(): boolean {
89
+ return this.status === TxStatus.DROPPED;
90
+ }
91
+
45
92
  static empty() {
46
- return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, '');
93
+ return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, undefined, undefined);
47
94
  }
48
95
 
49
96
  static get schema(): ZodFor<TxReceipt> {
@@ -51,18 +98,28 @@ export class TxReceipt {
51
98
  .object({
52
99
  txHash: TxHash.schema,
53
100
  status: z.nativeEnum(TxStatus),
54
- error: z.string(),
101
+ executionResult: z.nativeEnum(TxExecutionResult).optional(),
102
+ error: z.string().optional(),
55
103
  blockHash: L2BlockHash.schema.optional(),
56
104
  blockNumber: BlockNumberSchema.optional(),
57
105
  transactionFee: schemas.BigInt.optional(),
58
106
  })
59
- .transform(TxReceipt.from);
107
+ .transform(fields => TxReceipt.from(fields));
60
108
  }
61
109
 
62
- static from(fields: FieldsOf<TxReceipt>) {
110
+ static from(fields: {
111
+ txHash: TxHash;
112
+ status: TxStatus;
113
+ executionResult?: TxExecutionResult;
114
+ error?: string;
115
+ transactionFee?: bigint;
116
+ blockHash?: L2BlockHash;
117
+ blockNumber?: BlockNumber;
118
+ }) {
63
119
  return new TxReceipt(
64
120
  fields.txHash,
65
121
  fields.status,
122
+ fields.executionResult,
66
123
  fields.error,
67
124
  fields.transactionFee,
68
125
  fields.blockHash,
@@ -70,15 +127,15 @@ export class TxReceipt {
70
127
  );
71
128
  }
72
129
 
73
- public static statusFromRevertCode(revertCode: RevertCode) {
130
+ public static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult {
74
131
  if (revertCode.equals(RevertCode.OK)) {
75
- return TxStatus.SUCCESS;
132
+ return TxExecutionResult.SUCCESS;
76
133
  } else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
77
- return TxStatus.APP_LOGIC_REVERTED;
134
+ return TxExecutionResult.APP_LOGIC_REVERTED;
78
135
  } else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
79
- return TxStatus.TEARDOWN_REVERTED;
136
+ return TxExecutionResult.TEARDOWN_REVERTED;
80
137
  } else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
81
- return TxStatus.BOTH_REVERTED;
138
+ return TxExecutionResult.BOTH_REVERTED;
82
139
  } else {
83
140
  throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
84
141
  }
@@ -31,6 +31,9 @@ export const TX_ERROR_CONTRACT_CLASS_LOGS = 'Mismatched contract class logs';
31
31
  export const TX_ERROR_CONTRACT_CLASS_LOG_SORTING = 'Incorrectly sorted contract class logs';
32
32
  export const TX_ERROR_INCORRECT_HASH = 'Incorrect tx hash';
33
33
 
34
+ // Size
35
+ export const TX_ERROR_SIZE_ABOVE_LIMIT = 'Transaction size above size limit';
36
+
34
37
  // Block header
35
38
  export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
36
39