@aztec/stdlib 5.0.0-rc.1 → 5.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/abi/buffer.d.ts +6 -2
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +13 -1
- package/dest/avm/avm.js +1 -1
- package/dest/aztec-address/index.d.ts +35 -5
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +32 -8
- package/dest/block/l2_block_source.d.ts +11 -25
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +0 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +25 -5
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +29 -7
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +165 -152
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +10 -2
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +33 -15
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +94 -3
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/simulation_overrides.d.ts +61 -0
- package/dest/checkpoint/simulation_overrides.d.ts.map +1 -0
- package/dest/checkpoint/simulation_overrides.js +98 -0
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -5
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/file-store/factory.d.ts +1 -1
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +7 -0
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/file-store/index.js +1 -0
- package/dest/file-store/memory.d.ts +24 -0
- package/dest/file-store/memory.d.ts.map +1 -0
- package/dest/file-store/memory.js +80 -0
- package/dest/interfaces/archiver.js +1 -1
- package/dest/interfaces/aztec-node-debug.d.ts +26 -1
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.js +20 -0
- package/dest/interfaces/aztec-node.d.ts +20 -20
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +8 -15
- package/dest/interfaces/chain_tips.d.ts +8 -47
- package/dest/interfaces/chain_tips.d.ts.map +1 -1
- package/dest/interfaces/chain_tips.js +1 -6
- package/dest/interfaces/checkpoint_parameter.d.ts +3 -3
- package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -1
- package/dest/interfaces/checkpoint_parameter.js +3 -3
- package/dest/interfaces/prover-node.d.ts +6 -7
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +15 -10
- package/dest/kernel/hints/read_request.js +1 -1
- package/dest/kernel/log_hash.d.ts +1 -1
- package/dest/kernel/log_hash.d.ts.map +1 -1
- package/dest/kernel/log_hash.js +2 -2
- package/dest/kernel/note_hash.js +1 -1
- package/dest/kernel/nullifier.js +1 -1
- package/dest/kernel/private_log_data.d.ts +1 -1
- package/dest/kernel/private_log_data.d.ts.map +1 -1
- package/dest/kernel/private_log_data.js +1 -1
- package/dest/logs/app_tagging_secret.d.ts +21 -6
- package/dest/logs/app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/app_tagging_secret.js +32 -22
- package/dest/logs/contract_class_log.d.ts +1 -2
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +0 -4
- package/dest/logs/message_context.d.ts +5 -15
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +1 -66
- package/dest/logs/pending_tagged_log.d.ts +6 -8
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +1 -31
- package/dest/p2p/checkpoint_attestation.d.ts +2 -1
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +2 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.d.ts +2 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.d.ts +8 -3
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +20 -10
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -12
- package/dest/trees/nullifier_membership_witness.d.ts +5 -8
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +0 -9
- package/dest/trees/public_data_witness.d.ts +7 -17
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +0 -27
- package/dest/tx/execution_payload.d.ts +1 -1
- package/dest/tx/execution_payload.d.ts.map +1 -1
- package/dest/tx/execution_payload.js +1 -1
- package/dest/tx/global_variable_builder.d.ts +2 -12
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.js +2 -2
- package/package.json +8 -8
- package/src/abi/buffer.ts +13 -1
- package/src/avm/avm.ts +1 -1
- package/src/aztec-address/index.ts +36 -6
- package/src/block/l2_block_source.ts +10 -15
- package/src/block/l2_block_stream/interfaces.ts +25 -5
- package/src/block/l2_block_stream/l2_block_stream.ts +222 -172
- package/src/block/l2_block_stream/l2_tips_store_base.ts +36 -15
- package/src/block/test/l2_tips_store_test_suite.ts +73 -4
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/simulation_overrides.ts +171 -0
- package/src/contract/interfaces/contract_data_source.ts +2 -4
- package/src/file-store/factory.ts +7 -0
- package/src/file-store/index.ts +1 -0
- package/src/file-store/memory.ts +94 -0
- package/src/interfaces/archiver.ts +1 -1
- package/src/interfaces/aztec-node-debug.ts +37 -0
- package/src/interfaces/aztec-node.ts +30 -33
- package/src/interfaces/chain_tips.ts +8 -16
- package/src/interfaces/checkpoint_parameter.ts +3 -3
- package/src/interfaces/prover-node.ts +19 -11
- package/src/kernel/hints/read_request.ts +1 -1
- package/src/kernel/log_hash.ts +5 -2
- package/src/kernel/note_hash.ts +1 -1
- package/src/kernel/nullifier.ts +1 -1
- package/src/kernel/private_log_data.ts +4 -1
- package/src/logs/app_tagging_secret.ts +39 -23
- package/src/logs/contract_class_log.ts +0 -9
- package/src/logs/message_context.ts +7 -65
- package/src/logs/pending_tagged_log.ts +6 -33
- package/src/rollup/checkpoint_header.ts +16 -2
- package/src/tests/factories.ts +3 -6
- package/src/trees/nullifier_membership_witness.ts +0 -11
- package/src/trees/public_data_witness.ts +0 -31
- package/src/tx/execution_payload.ts +2 -1
- package/src/tx/global_variable_builder.ts +1 -17
- package/src/tx/global_variables.ts +2 -2
package/src/avm/avm.ts
CHANGED
|
@@ -1152,7 +1152,7 @@ export class CallStackMetadata {
|
|
|
1152
1152
|
|
|
1153
1153
|
const { stack, leaf } = failingCall;
|
|
1154
1154
|
const aztecCallStack = stack.map(call => ({
|
|
1155
|
-
contractAddress: AztecAddress.
|
|
1155
|
+
contractAddress: AztecAddress.fromFieldUnsafe(call.contractAddress),
|
|
1156
1156
|
functionSelector: call.calldata.length > 0 ? FunctionSelector.fromFieldOrUndefined(call.calldata[0]) : undefined,
|
|
1157
1157
|
}));
|
|
1158
1158
|
|
|
@@ -43,34 +43,64 @@ export class AztecAddress {
|
|
|
43
43
|
static ZERO = new AztecAddress(Buffer.alloc(32, 0));
|
|
44
44
|
|
|
45
45
|
/** Null msg sender address. Not part of the protocol contracts tree. */
|
|
46
|
-
static NULL_MSG_SENDER = AztecAddress.
|
|
46
|
+
static NULL_MSG_SENDER = AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS);
|
|
47
47
|
|
|
48
48
|
static zero(): AztecAddress {
|
|
49
49
|
return AztecAddress.ZERO;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Builds an `AztecAddress` from a field **without checking it is a valid address** (the x-coordinate of a point on
|
|
54
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
55
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
56
|
+
*/
|
|
57
|
+
static fromFieldUnsafe(fr: Fr) {
|
|
53
58
|
return new AztecAddress(fr);
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Deserializes an `AztecAddress` from a buffer. It does **not** check the value is a valid Grumpkin-curve address
|
|
63
|
+
* (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized data. Use
|
|
64
|
+
* {@link AztecAddress.random} for valid test addresses.
|
|
65
|
+
*/
|
|
56
66
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
57
67
|
return new AztecAddress(fromBuffer(buffer, Fr));
|
|
58
68
|
}
|
|
59
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Deserializes an `AztecAddress` from a field reader. It does **not** check the value is a valid Grumpkin-curve
|
|
72
|
+
* address (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized
|
|
73
|
+
* data. Use {@link AztecAddress.random} for valid test addresses.
|
|
74
|
+
*/
|
|
60
75
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
61
76
|
const reader = FieldReader.asReader(fields);
|
|
62
77
|
return new AztecAddress(reader.readField());
|
|
63
78
|
}
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Builds an `AztecAddress` from a bigint **without checking it is a valid address** (the x-coordinate of a point on
|
|
82
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
83
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
84
|
+
*/
|
|
85
|
+
static fromBigIntUnsafe(value: bigint) {
|
|
66
86
|
return new AztecAddress(new Fr(value));
|
|
67
87
|
}
|
|
68
88
|
|
|
69
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Builds an `AztecAddress` from a number **without checking it is a valid address** (the x-coordinate of a point on
|
|
91
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
92
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
93
|
+
*/
|
|
94
|
+
static fromNumberUnsafe(value: number) {
|
|
70
95
|
return new AztecAddress(new Fr(value));
|
|
71
96
|
}
|
|
72
97
|
|
|
73
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Builds an `AztecAddress` from a hex string **without checking it is a valid address** (the x-coordinate of a
|
|
100
|
+
* point on the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to
|
|
101
|
+
* validate an untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
102
|
+
*/
|
|
103
|
+
static fromStringUnsafe(buf: string) {
|
|
74
104
|
return new AztecAddress(hexToBuffer(buf));
|
|
75
105
|
}
|
|
76
106
|
|
|
@@ -89,7 +119,7 @@ export class AztecAddress {
|
|
|
89
119
|
if (obj instanceof Buffer || Buffer.isBuffer(obj)) {
|
|
90
120
|
return new AztecAddress(obj);
|
|
91
121
|
}
|
|
92
|
-
return AztecAddress.
|
|
122
|
+
return AztecAddress.fromStringUnsafe(obj);
|
|
93
123
|
}
|
|
94
124
|
|
|
95
125
|
/**
|
|
@@ -241,7 +241,10 @@ export interface L2BlockSource {
|
|
|
241
241
|
|
|
242
242
|
/**
|
|
243
243
|
* Looks up a proposed (archiver-internal, not-yet-L1-confirmed) checkpoint.
|
|
244
|
-
* Returns the latest proposed entry when called with no args or `{ tag: 'proposed' }
|
|
244
|
+
* Returns the latest proposed entry when called with no args or `{ tag: 'proposed' }`; since a
|
|
245
|
+
* proposed entry can only be stored with a checkpoint number beyond the confirmed frontier (and is
|
|
246
|
+
* deleted on confirmation), the latest entry is always the leading one. Callers derive the proposed
|
|
247
|
+
* tip from the payload (checkpoint number, and last block `startBlock + blockCount - 1`).
|
|
245
248
|
* With `{ number }` or `{ slot }`, returns the matching entry or undefined.
|
|
246
249
|
* Never falls back to confirmed checkpoints.
|
|
247
250
|
*/
|
|
@@ -327,36 +330,29 @@ export interface L2BlockSourceEventEmitter extends L2BlockSource {
|
|
|
327
330
|
}
|
|
328
331
|
|
|
329
332
|
/**
|
|
330
|
-
* Identifier for L2 block tags. Internal counterpart to {@link BlockTag} that
|
|
331
|
-
*
|
|
332
|
-
* archiver side) and omits `latest` (which is an alias for `proposed` accepted only at
|
|
333
|
-
* the public RPC surface).
|
|
333
|
+
* Identifier for L2 block tags. Internal counterpart to {@link BlockTag} that omits `latest`
|
|
334
|
+
* (which is an alias for `proposed` accepted only at the public RPC surface).
|
|
334
335
|
*
|
|
335
336
|
* - proposed: Latest block proposed on L2.
|
|
336
|
-
* - proposedCheckpoint: Latest block in the most recent proposed checkpoint (archiver-internal).
|
|
337
337
|
* - checkpointed: Latest block whose enclosing checkpoint has been published on L1.
|
|
338
338
|
* - proven: Latest block whose enclosing checkpoint has been proven on L1.
|
|
339
339
|
* - finalized: Latest block whose proving L1 transaction has reached L1 finality.
|
|
340
|
-
*
|
|
341
|
-
* TODO(palla): Remove `proposedCheckpoint` and unify with `proposed`.
|
|
342
340
|
*/
|
|
343
|
-
export type L2BlockTag = 'proposed' | '
|
|
341
|
+
export type L2BlockTag = 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
344
342
|
|
|
345
343
|
/** Tips of the L2 chain. */
|
|
346
344
|
export type L2Tips = {
|
|
347
345
|
proposed: L2BlockId;
|
|
348
346
|
checkpointed: L2TipId;
|
|
349
|
-
proposedCheckpoint: L2TipId;
|
|
350
347
|
proven: L2TipId;
|
|
351
348
|
finalized: L2TipId;
|
|
352
349
|
};
|
|
353
350
|
|
|
354
351
|
/**
|
|
355
|
-
* Tips of the L2 chain as tracked by a local provider (world-state, l2-tips-store).
|
|
356
|
-
*
|
|
357
|
-
* is only meaningful on the archiver side via {@link L2BlockSource}.
|
|
352
|
+
* Tips of the L2 chain as tracked by a local provider (world-state, l2-tips-store). Identical to
|
|
353
|
+
* {@link L2Tips}; the alias is retained for call sites that document a local-only provenance.
|
|
358
354
|
*/
|
|
359
|
-
export type LocalL2Tips =
|
|
355
|
+
export type LocalL2Tips = L2Tips;
|
|
360
356
|
|
|
361
357
|
export const GENESIS_CHECKPOINT_HEADER_HASH = CheckpointHeader.empty().hash();
|
|
362
358
|
|
|
@@ -398,7 +394,6 @@ const L2TipIdSchema = z.object({
|
|
|
398
394
|
export const L2TipsSchema = z.object({
|
|
399
395
|
proposed: L2BlockIdSchema,
|
|
400
396
|
checkpointed: L2TipIdSchema,
|
|
401
|
-
proposedCheckpoint: L2TipIdSchema,
|
|
402
397
|
proven: L2TipIdSchema,
|
|
403
398
|
finalized: L2TipIdSchema,
|
|
404
399
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
|
|
3
|
-
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
4
3
|
import type { L2Block } from '../l2_block.js';
|
|
5
4
|
import type { CheckpointId, L2BlockId, L2TipId, LocalL2Tips } from '../l2_block_source.js';
|
|
6
5
|
|
|
@@ -21,7 +20,7 @@ export type LocalL2BlockId = { number: BlockNumber; hash?: string };
|
|
|
21
20
|
*/
|
|
22
21
|
export type LocalChainTips = {
|
|
23
22
|
proposed: LocalL2BlockId;
|
|
24
|
-
checkpointed?: { checkpoint: CheckpointId };
|
|
23
|
+
checkpointed?: { block: LocalL2BlockId; checkpoint: CheckpointId };
|
|
25
24
|
proven: { block: LocalL2BlockId };
|
|
26
25
|
finalized: { block: LocalL2BlockId };
|
|
27
26
|
};
|
|
@@ -46,10 +45,24 @@ export type L2BlockStreamEvent =
|
|
|
46
45
|
type: 'blocks-added';
|
|
47
46
|
blocks: L2Block[];
|
|
48
47
|
}
|
|
49
|
-
| /**
|
|
48
|
+
| /**
|
|
49
|
+
* Reports the new proposed tip of the chain. Emitted once per sync pass when the source's proposed tip differs
|
|
50
|
+
* from the pre-pass local one (downloads, a prune, or a thin tip movement). Carries only the block id; in block
|
|
51
|
+
* mode the corresponding payloads arrive via preceding `blocks-added` events, while in tips-only mode this is the
|
|
52
|
+
* sole signal that the proposed tip moved. Consumers that only track the proposed tip can ignore `blocks-added`
|
|
53
|
+
* entirely and anchor on this event instead.
|
|
54
|
+
*/ {
|
|
55
|
+
type: 'chain-proposed';
|
|
56
|
+
block: L2BlockId;
|
|
57
|
+
}
|
|
58
|
+
| /**
|
|
59
|
+
* Reports a new checkpointed tip. Emitted at most once per sync pass when the source's checkpointed tip
|
|
60
|
+
* leads the local one. Carries only the block + checkpoint ids; consumers that need the full checkpoint
|
|
61
|
+
* payload fetch it on demand from the block source.
|
|
62
|
+
*/ {
|
|
50
63
|
type: 'chain-checkpointed';
|
|
51
|
-
checkpoint: PublishedCheckpoint;
|
|
52
64
|
block: L2BlockId;
|
|
65
|
+
checkpoint: CheckpointId;
|
|
53
66
|
}
|
|
54
67
|
| /**
|
|
55
68
|
* Reports last correct block (new tip of the proposed chain). Note that this is not necessarily the anchor block
|
|
@@ -77,4 +90,11 @@ export type L2BlockStreamEvent =
|
|
|
77
90
|
|
|
78
91
|
export type L2TipsStore = L2BlockStreamEventHandler &
|
|
79
92
|
L2TipsProvider &
|
|
80
|
-
Pick<L2BlockStreamLocalDataProvider, 'getL2BlockHash'
|
|
93
|
+
Pick<L2BlockStreamLocalDataProvider, 'getL2BlockHash'> & {
|
|
94
|
+
/**
|
|
95
|
+
* Records `(number → hash)` witnesses into the walk-back hash index without moving any tip cursor. Consumers that
|
|
96
|
+
* materialize per-height state should record a witness for each height they materialize, so a reorg below the
|
|
97
|
+
* nearest sparse anchor does not produce an over-deep prune event. See {@link L2TipsStoreBase.recordBlockHashes}.
|
|
98
|
+
*/
|
|
99
|
+
recordBlockHashes(blocks: L2BlockId[]): Promise<void>;
|
|
100
|
+
};
|