@aztec/stdlib 0.0.1-commit.2ed92850 → 0.0.1-commit.3469e52

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 (108) hide show
  1. package/dest/block/block_hash.d.ts +2 -3
  2. package/dest/block/block_hash.d.ts.map +1 -1
  3. package/dest/block/block_hash.js +0 -3
  4. package/dest/block/checkpointed_l2_block.d.ts +6 -6
  5. package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
  6. package/dest/block/checkpointed_l2_block.js +3 -3
  7. package/dest/block/in_block.d.ts +3 -3
  8. package/dest/block/in_block.d.ts.map +1 -1
  9. package/dest/block/index.d.ts +2 -2
  10. package/dest/block/index.d.ts.map +1 -1
  11. package/dest/block/index.js +1 -1
  12. package/dest/block/{l2_block.d.ts → l2_block_new.d.ts} +6 -6
  13. package/dest/block/l2_block_new.d.ts.map +1 -0
  14. package/dest/block/{l2_block.js → l2_block_new.js} +11 -8
  15. package/dest/block/l2_block_source.d.ts +29 -37
  16. package/dest/block/l2_block_source.d.ts.map +1 -1
  17. package/dest/block/l2_block_stream/interfaces.d.ts +3 -3
  18. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  19. package/dest/block/l2_block_stream/l2_block_stream.d.ts +3 -2
  20. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  21. package/dest/block/l2_block_stream/l2_block_stream.js +4 -4
  22. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +3 -3
  23. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  24. package/dest/block/test/l2_tips_store_test_suite.js +2 -2
  25. package/dest/checkpoint/checkpoint.d.ts +8 -8
  26. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  27. package/dest/checkpoint/checkpoint.js +4 -4
  28. package/dest/checkpoint/published_checkpoint.d.ts +2 -2
  29. package/dest/config/node-rpc-config.js +1 -1
  30. package/dest/contract/private_function.d.ts +1 -1
  31. package/dest/contract/private_function.d.ts.map +1 -1
  32. package/dest/contract/private_function.js +2 -1
  33. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +2 -2
  34. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
  35. package/dest/delayed_public_mutable/delayed_public_mutable_values.js +10 -7
  36. package/dest/epoch-helpers/index.js +1 -1
  37. package/dest/interfaces/archiver.d.ts +1 -1
  38. package/dest/interfaces/archiver.d.ts.map +1 -1
  39. package/dest/interfaces/archiver.js +15 -15
  40. package/dest/interfaces/aztec-node-admin.d.ts +1 -4
  41. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  42. package/dest/interfaces/aztec-node.d.ts +9 -23
  43. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  44. package/dest/interfaces/aztec-node.js +11 -11
  45. package/dest/interfaces/block-builder.d.ts +4 -4
  46. package/dest/interfaces/block-builder.d.ts.map +1 -1
  47. package/dest/interfaces/configs.d.ts +2 -2
  48. package/dest/interfaces/configs.d.ts.map +1 -1
  49. package/dest/interfaces/prover-client.d.ts +1 -10
  50. package/dest/interfaces/prover-client.d.ts.map +1 -1
  51. package/dest/interfaces/prover-client.js +1 -7
  52. package/dest/interfaces/tx_provider.d.ts +3 -3
  53. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  54. package/dest/interfaces/validator.d.ts +2 -2
  55. package/dest/interfaces/validator.d.ts.map +1 -1
  56. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
  57. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  58. package/dest/kernel/hints/build_nullifier_read_request_hints.js +6 -4
  59. package/dest/p2p/block_proposal.d.ts +4 -4
  60. package/dest/p2p/block_proposal.d.ts.map +1 -1
  61. package/dest/p2p/block_proposal.js +1 -1
  62. package/dest/p2p/message_validator.d.ts +3 -18
  63. package/dest/p2p/message_validator.d.ts.map +1 -1
  64. package/dest/p2p/message_validator.js +1 -2
  65. package/dest/tests/factories.js +1 -1
  66. package/dest/tests/jest.d.ts +4 -4
  67. package/dest/tests/jest.js +9 -9
  68. package/dest/tests/mocks.d.ts +9 -10
  69. package/dest/tests/mocks.d.ts.map +1 -1
  70. package/dest/tests/mocks.js +10 -15
  71. package/dest/tx/block_header.d.ts +2 -3
  72. package/dest/tx/block_header.d.ts.map +1 -1
  73. package/dest/tx/block_header.js +2 -3
  74. package/dest/tx/tx_receipt.d.ts +11 -39
  75. package/dest/tx/tx_receipt.d.ts.map +1 -1
  76. package/dest/tx/tx_receipt.js +13 -44
  77. package/package.json +9 -9
  78. package/src/block/block_hash.ts +1 -5
  79. package/src/block/checkpointed_l2_block.ts +4 -4
  80. package/src/block/in_block.ts +2 -2
  81. package/src/block/index.ts +1 -1
  82. package/src/block/{l2_block.ts → l2_block_new.ts} +13 -9
  83. package/src/block/l2_block_source.ts +30 -38
  84. package/src/block/l2_block_stream/interfaces.ts +2 -2
  85. package/src/block/l2_block_stream/l2_block_stream.ts +6 -5
  86. package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
  87. package/src/block/test/l2_tips_store_test_suite.ts +4 -4
  88. package/src/checkpoint/checkpoint.ts +7 -7
  89. package/src/config/node-rpc-config.ts +1 -1
  90. package/src/contract/private_function.ts +2 -1
  91. package/src/delayed_public_mutable/delayed_public_mutable_values.ts +10 -9
  92. package/src/epoch-helpers/index.ts +1 -1
  93. package/src/interfaces/archiver.ts +24 -15
  94. package/src/interfaces/aztec-node.ts +31 -38
  95. package/src/interfaces/block-builder.ts +3 -3
  96. package/src/interfaces/configs.ts +3 -1
  97. package/src/interfaces/prover-client.ts +0 -15
  98. package/src/interfaces/tx_provider.ts +2 -2
  99. package/src/interfaces/validator.ts +2 -1
  100. package/src/kernel/hints/build_nullifier_read_request_hints.ts +10 -1
  101. package/src/p2p/block_proposal.ts +3 -3
  102. package/src/p2p/message_validator.ts +2 -14
  103. package/src/tests/factories.ts +1 -1
  104. package/src/tests/jest.ts +9 -9
  105. package/src/tests/mocks.ts +13 -20
  106. package/src/tx/block_header.ts +4 -7
  107. package/src/tx/tx_receipt.ts +15 -72
  108. package/dest/block/l2_block.d.ts.map +0 -1
@@ -11,14 +11,13 @@ import type { FieldsOf } from '@aztec/foundation/types';
11
11
  import { inspect } from 'util';
12
12
  import { z } from 'zod';
13
13
 
14
- import { L2BlockHash } from '../block/block_hash.js';
15
14
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
16
15
  import { GlobalVariables } from './global_variables.js';
17
16
  import { StateReference } from './state_reference.js';
18
17
 
19
18
  /** A header of an L2 block. */
20
19
  export class BlockHeader {
21
- private _cachedHash?: Promise<L2BlockHash>;
20
+ private _cachedHash?: Promise<Fr>;
22
21
 
23
22
  constructor(
24
23
  /** Snapshot of archive before the block is applied. */
@@ -162,18 +161,16 @@ export class BlockHeader {
162
161
  return BlockHeader.fromBuffer(hexToBuffer(str));
163
162
  }
164
163
 
165
- hash(): Promise<L2BlockHash> {
164
+ hash(): Promise<Fr> {
166
165
  if (!this._cachedHash) {
167
- this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH).then(fr =>
168
- L2BlockHash.fromField(fr),
169
- );
166
+ this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH);
170
167
  }
171
168
  return this._cachedHash;
172
169
  }
173
170
 
174
171
  /** Manually set the hash for this block header if already computed */
175
172
  setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(L2BlockHash.fromField(hashed));
173
+ this._cachedHash = Promise.resolve(hashed);
177
174
  }
178
175
 
179
176
  static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
@@ -1,4 +1,5 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
+ import type { FieldsOf } from '@aztec/foundation/types';
2
3
 
3
4
  import { z } from 'zod';
4
5
 
@@ -7,28 +8,12 @@ import { L2BlockHash } from '../block/block_hash.js';
7
8
  import { type ZodFor, schemas } from '../schemas/schemas.js';
8
9
  import { TxHash } from './tx_hash.js';
9
10
 
10
- /** Block inclusion/finalization status. */
11
+ /**
12
+ * Possible status of a transaction.
13
+ */
11
14
  export enum TxStatus {
12
15
  DROPPED = 'dropped',
13
16
  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 {
32
17
  SUCCESS = 'success',
33
18
  APP_LOGIC_REVERTED = 'app_logic_reverted',
34
19
  TEARDOWN_REVERTED = 'teardown_reverted',
@@ -45,12 +30,10 @@ export class TxReceipt {
45
30
  constructor(
46
31
  /** A unique identifier for a transaction. */
47
32
  public txHash: TxHash,
48
- /** The transaction's block finalization status. */
33
+ /** The transaction's status. */
49
34
  public status: TxStatus,
50
- /** The execution result of the transaction, only set when tx is in a block. */
51
- public executionResult: TxExecutionResult | undefined,
52
35
  /** Description of transaction error, if any. */
53
- public error: string | undefined,
36
+ public error: string,
54
37
  /** The transaction fee paid for the transaction. */
55
38
  public transactionFee?: bigint,
56
39
  /** The hash of the block containing the transaction. */
@@ -59,38 +42,8 @@ export class TxReceipt {
59
42
  public blockNumber?: BlockNumber,
60
43
  ) {}
61
44
 
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
-
92
45
  static empty() {
93
- return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, undefined, undefined);
46
+ return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, '');
94
47
  }
95
48
 
96
49
  static get schema(): ZodFor<TxReceipt> {
@@ -98,28 +51,18 @@ export class TxReceipt {
98
51
  .object({
99
52
  txHash: TxHash.schema,
100
53
  status: z.nativeEnum(TxStatus),
101
- executionResult: z.nativeEnum(TxExecutionResult).optional(),
102
- error: z.string().optional(),
54
+ error: z.string(),
103
55
  blockHash: L2BlockHash.schema.optional(),
104
56
  blockNumber: BlockNumberSchema.optional(),
105
57
  transactionFee: schemas.BigInt.optional(),
106
58
  })
107
- .transform(fields => TxReceipt.from(fields));
59
+ .transform(TxReceipt.from);
108
60
  }
109
61
 
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
- }) {
62
+ static from(fields: FieldsOf<TxReceipt>) {
119
63
  return new TxReceipt(
120
64
  fields.txHash,
121
65
  fields.status,
122
- fields.executionResult,
123
66
  fields.error,
124
67
  fields.transactionFee,
125
68
  fields.blockHash,
@@ -127,15 +70,15 @@ export class TxReceipt {
127
70
  );
128
71
  }
129
72
 
130
- public static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult {
73
+ public static statusFromRevertCode(revertCode: RevertCode) {
131
74
  if (revertCode.equals(RevertCode.OK)) {
132
- return TxExecutionResult.SUCCESS;
75
+ return TxStatus.SUCCESS;
133
76
  } else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
134
- return TxExecutionResult.APP_LOGIC_REVERTED;
77
+ return TxStatus.APP_LOGIC_REVERTED;
135
78
  } else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
136
- return TxExecutionResult.TEARDOWN_REVERTED;
79
+ return TxStatus.TEARDOWN_REVERTED;
137
80
  } else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
138
- return TxExecutionResult.BOTH_REVERTED;
81
+ return TxStatus.BOTH_REVERTED;
139
82
  } else {
140
83
  throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
141
84
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"l2_block.d.ts","sourceRoot":"","sources":["../../src/block/l2_block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EACL,WAAW,EACX,gBAAgB,EAEhB,qBAAqB,EAErB,UAAU,EACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,qBAAa,OAAO;IAEhB,2DAA2D;IACp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