@aztec/stdlib 4.1.0-rc.2 → 4.1.0-rc.3
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/decoder.d.ts +2 -2
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +6 -1
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +28 -1
- package/dest/abi/event_metadata_definition.d.ts +3 -1
- package/dest/abi/event_metadata_definition.d.ts.map +1 -1
- package/dest/abi/event_metadata_definition.js +1 -1
- package/dest/abi/utils.d.ts +14 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +15 -0
- package/dest/block/l2_block_source.d.ts +7 -5
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/epoch-helpers/index.d.ts +5 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +4 -2
- package/dest/interfaces/archiver.js +2 -2
- package/dest/interfaces/aztec-node-admin.d.ts +4 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +2 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +2 -0
- package/dest/interfaces/block-builder.d.ts +11 -9
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +6 -4
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +13 -10
- package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -3
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/public_log.d.ts +4 -3
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +2 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/p2p/checkpoint_proposal.d.ts +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -11
- package/dest/p2p/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/tx/tx_receipt.d.ts +7 -2
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +6 -3
- package/dest/update-checker/package_version.d.ts +2 -2
- package/dest/update-checker/package_version.d.ts.map +1 -1
- package/dest/update-checker/package_version.js +16 -3
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/package.json +9 -9
- package/src/abi/decoder.ts +14 -2
- package/src/abi/encoder.ts +41 -1
- package/src/abi/event_metadata_definition.ts +2 -0
- package/src/abi/utils.ts +25 -0
- package/src/block/l2_block_source.ts +6 -4
- package/src/epoch-helpers/index.ts +3 -0
- package/src/interfaces/archiver.ts +2 -2
- package/src/interfaces/aztec-node.ts +9 -1
- package/src/interfaces/block-builder.ts +13 -11
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
- package/src/kernel/hints/build_transient_data_hints.ts +17 -2
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/public_log.ts +4 -2
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/p2p/checkpoint_proposal.ts +23 -20
- package/src/p2p/peer_error.ts +7 -0
- package/src/tx/tx_receipt.ts +6 -1
- package/src/update-checker/package_version.ts +19 -6
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
|
@@ -3,6 +3,9 @@ import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { SiblingPath, UnbalancedMerkleTreeCalculator, computeUnbalancedShaRoot } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
|
+
import type { AztecNode } from '../interfaces/aztec-node.js';
|
|
7
|
+
import { TxHash } from '../tx/tx_hash.js';
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* # L2-to-L1 Message Tree Structure and Leaf IDs
|
|
8
11
|
*
|
|
@@ -92,59 +95,94 @@ export function getL2ToL1MessageLeafId(
|
|
|
92
95
|
return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
export interface MessageRetrieval {
|
|
96
|
-
getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
98
|
export type L2ToL1MembershipWitness = {
|
|
100
99
|
root: Fr;
|
|
101
100
|
leafIndex: bigint;
|
|
102
101
|
siblingPath: SiblingPath<number>;
|
|
102
|
+
epochNumber: EpochNumber;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Computes the L2 to L1 membership witness for a given message in a transaction.
|
|
107
|
+
*
|
|
108
|
+
* @param node - The Aztec node to query for block/tx/epoch data.
|
|
109
|
+
* @param message - The L2 to L1 message hash to prove membership of.
|
|
110
|
+
* @param txHash - The hash of the transaction that emitted the message.
|
|
111
|
+
* @param messageIndexInTx - Optional index of the message within the transaction's L2-to-L1 messages.
|
|
112
|
+
* If not provided, the message is found by scanning the tx's messages (throws if duplicates exist).
|
|
113
|
+
* @returns The membership witness and epoch number, or undefined if the tx is not yet in a block/epoch.
|
|
114
|
+
*/
|
|
105
115
|
export async function computeL2ToL1MembershipWitness(
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
node: Pick<
|
|
117
|
+
AztecNode,
|
|
118
|
+
'getL2ToL1Messages' | 'getTxReceipt' | 'getTxEffect' | 'getBlock' | 'getCheckpointsDataForEpoch'
|
|
119
|
+
>,
|
|
108
120
|
message: Fr,
|
|
121
|
+
txHash: TxHash,
|
|
122
|
+
messageIndexInTx?: number,
|
|
109
123
|
): Promise<L2ToL1MembershipWitness | undefined> {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
124
|
+
const { epochNumber, blockNumber } = await node.getTxReceipt(txHash);
|
|
125
|
+
if (epochNumber === undefined || blockNumber === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const [messagesInEpoch, block, txEffect, checkpointsData] = await Promise.all([
|
|
130
|
+
node.getL2ToL1Messages(epochNumber),
|
|
131
|
+
node.getBlock(blockNumber),
|
|
132
|
+
node.getTxEffect(txHash),
|
|
133
|
+
node.getCheckpointsDataForEpoch(epochNumber),
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
if (messagesInEpoch.length === 0 || !block || !txEffect) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const checkpointIndex = checkpointsData.findIndex(c => c.checkpointNumber === block.checkpointNumber);
|
|
141
|
+
if (checkpointIndex === -1) {
|
|
112
142
|
return undefined;
|
|
113
143
|
}
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
const blockIndex = block.indexWithinCheckpoint;
|
|
146
|
+
const txIndex = txEffect.txIndexInBlock;
|
|
147
|
+
|
|
148
|
+
const { root, leafIndex, siblingPath } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
149
|
+
messagesInEpoch,
|
|
150
|
+
message,
|
|
151
|
+
checkpointIndex,
|
|
152
|
+
blockIndex,
|
|
153
|
+
txIndex,
|
|
154
|
+
messageIndexInTx,
|
|
155
|
+
);
|
|
156
|
+
return { epochNumber, root, leafIndex, siblingPath };
|
|
116
157
|
}
|
|
117
158
|
|
|
118
|
-
|
|
119
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Computes a membership witness for a message in the epoch's L2-to-L1 message tree, given explicit position indices.
|
|
161
|
+
*
|
|
162
|
+
* @param messagesInEpoch - All L2-to-L1 messages in the epoch, organized as checkpoints → blocks → txs → messages.
|
|
163
|
+
* @param message - The message hash to prove membership of.
|
|
164
|
+
* @param checkpointIndex - Index of the checkpoint within the epoch's message array.
|
|
165
|
+
* @param blockIndex - Index of the block within the checkpoint.
|
|
166
|
+
* @param txIndex - Index of the transaction within the block.
|
|
167
|
+
* @param messageIndexInTx - Optional index of the message within the transaction's messages.
|
|
168
|
+
* If not provided, the message is found by scanning (throws if duplicates exist within the tx).
|
|
169
|
+
*/
|
|
170
|
+
/** @internal Exported for testing only. */
|
|
120
171
|
export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
121
172
|
messagesInEpoch: Fr[][][][],
|
|
122
173
|
message: Fr,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
txIndex = messagesInBlock.findIndex(messagesInTx => {
|
|
131
|
-
messageIndexInTx = messagesInTx.findIndex(msg => msg.equals(message));
|
|
132
|
-
return messageIndexInTx !== -1;
|
|
133
|
-
});
|
|
134
|
-
return txIndex !== -1;
|
|
135
|
-
});
|
|
136
|
-
return blockIndex !== -1;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (checkpointIndex === -1) {
|
|
140
|
-
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
141
|
-
}
|
|
174
|
+
checkpointIndex: number,
|
|
175
|
+
blockIndex: number,
|
|
176
|
+
txIndex: number,
|
|
177
|
+
messageIndexInTx?: number,
|
|
178
|
+
): { root: Fr; leafIndex: bigint; siblingPath: SiblingPath<number> } {
|
|
179
|
+
const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
|
|
180
|
+
const resolvedMessageIndex = resolveMessageIndex(messagesInTx, message, messageIndexInTx);
|
|
142
181
|
|
|
143
182
|
// Build the tx tree.
|
|
144
|
-
const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
|
|
145
183
|
const txTree = UnbalancedMerkleTreeCalculator.create(messagesInTx.map(msg => msg.toBuffer()));
|
|
146
184
|
// Get the sibling path of the target message in the tx tree.
|
|
147
|
-
const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(
|
|
185
|
+
const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(resolvedMessageIndex);
|
|
148
186
|
|
|
149
187
|
// Build the tree of the block containing the target message.
|
|
150
188
|
const blockTree = buildBlockTree(messagesInEpoch[checkpointIndex][blockIndex]);
|
|
@@ -189,7 +227,7 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
|
189
227
|
// Compute the combined index.
|
|
190
228
|
// It is the index of the message in the balanced tree (by filling up the wonky tree with empty nodes) at its current
|
|
191
229
|
// height. It's used to validate the membership proof.
|
|
192
|
-
const messageLeafPosition = txTree.getLeafLocation(
|
|
230
|
+
const messageLeafPosition = txTree.getLeafLocation(resolvedMessageIndex);
|
|
193
231
|
const txLeafPosition = blockTree.getLeafLocation(txIndex);
|
|
194
232
|
const blockLeafPosition = checkpointTree.getLeafLocation(blockIndex);
|
|
195
233
|
const checkpointLeafPosition = epochTree.getLeafLocation(checkpointIndex);
|
|
@@ -207,6 +245,33 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
|
|
|
207
245
|
};
|
|
208
246
|
}
|
|
209
247
|
|
|
248
|
+
function resolveMessageIndex(messagesInTx: Fr[], message: Fr, messageIndexInTx?: number): number {
|
|
249
|
+
if (messageIndexInTx !== undefined) {
|
|
250
|
+
if (!messagesInTx[messageIndexInTx]?.equals(message)) {
|
|
251
|
+
throw new Error(`Message at index ${messageIndexInTx} in tx does not match the expected message ${message}`);
|
|
252
|
+
}
|
|
253
|
+
return messageIndexInTx;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const indices = messagesInTx.reduce<number[]>((acc, msg, i) => {
|
|
257
|
+
if (msg.equals(message)) {
|
|
258
|
+
acc.push(i);
|
|
259
|
+
}
|
|
260
|
+
return acc;
|
|
261
|
+
}, []);
|
|
262
|
+
|
|
263
|
+
if (indices.length === 0) {
|
|
264
|
+
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
265
|
+
}
|
|
266
|
+
if (indices.length > 1) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Multiple messages with the same value ${message} found in tx (indices: ${indices.join(', ')}). ` +
|
|
269
|
+
`Provide messageIndexInTx to disambiguate.`,
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
return indices[0];
|
|
273
|
+
}
|
|
274
|
+
|
|
210
275
|
function buildCheckpointTree(messagesInCheckpoint: Fr[][][]) {
|
|
211
276
|
const blockOutHashes = messagesInCheckpoint.map(messagesInBlock => buildBlockTree(messagesInBlock).getRoot());
|
|
212
277
|
return buildCompressedTree(blockOutHashes);
|
|
@@ -178,29 +178,32 @@ export class CheckpointProposal extends Gossipable {
|
|
|
178
178
|
blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
|
|
179
179
|
dutyType: DutyType.CHECKPOINT_PROPOSAL,
|
|
180
180
|
};
|
|
181
|
-
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
182
181
|
|
|
183
|
-
if (
|
|
184
|
-
|
|
182
|
+
if (lastBlockInfo) {
|
|
183
|
+
// Sign block proposal before signing checkpoint proposal to ensure HA protection
|
|
184
|
+
const lastBlockProposal = await BlockProposal.createProposalFromSigner(
|
|
185
|
+
lastBlockInfo.blockHeader,
|
|
186
|
+
lastBlockInfo.indexWithinCheckpoint,
|
|
187
|
+
checkpointHeader.inHash,
|
|
188
|
+
archiveRoot,
|
|
189
|
+
lastBlockInfo.txHashes,
|
|
190
|
+
lastBlockInfo.txs,
|
|
191
|
+
payloadSigner,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
195
|
+
|
|
196
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
197
|
+
blockHeader: lastBlockInfo.blockHeader,
|
|
198
|
+
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
199
|
+
txHashes: lastBlockInfo.txHashes,
|
|
200
|
+
signature: lastBlockProposal.signature,
|
|
201
|
+
signedTxs: lastBlockProposal.signedTxs,
|
|
202
|
+
});
|
|
185
203
|
}
|
|
186
204
|
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
lastBlockInfo.indexWithinCheckpoint,
|
|
190
|
-
checkpointHeader.inHash,
|
|
191
|
-
archiveRoot,
|
|
192
|
-
lastBlockInfo.txHashes,
|
|
193
|
-
lastBlockInfo.txs,
|
|
194
|
-
payloadSigner,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
198
|
-
blockHeader: lastBlockInfo.blockHeader,
|
|
199
|
-
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
200
|
-
txHashes: lastBlockInfo.txHashes,
|
|
201
|
-
signature: lastBlockProposal.signature,
|
|
202
|
-
signedTxs: lastBlockProposal.signedTxs,
|
|
203
|
-
});
|
|
205
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
206
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
/**
|
package/src/p2p/peer_error.ts
CHANGED
|
@@ -15,3 +15,10 @@ export enum PeerErrorSeverity {
|
|
|
15
15
|
*/
|
|
16
16
|
HighToleranceError = 'HighToleranceError',
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/** Severities ordered from mildest to harshest. */
|
|
20
|
+
export const PeerErrorSeverityByHarshness = [
|
|
21
|
+
PeerErrorSeverity.HighToleranceError,
|
|
22
|
+
PeerErrorSeverity.MidToleranceError,
|
|
23
|
+
PeerErrorSeverity.LowToleranceError,
|
|
24
|
+
] as const;
|
package/src/tx/tx_receipt.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, BlockNumberSchema, EpochNumber, EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -58,6 +58,8 @@ export class TxReceipt {
|
|
|
58
58
|
public blockHash?: BlockHash,
|
|
59
59
|
/** The block number in which the transaction was included. */
|
|
60
60
|
public blockNumber?: BlockNumber,
|
|
61
|
+
/** The epoch number in which the transaction was included. */
|
|
62
|
+
public epochNumber?: EpochNumber,
|
|
61
63
|
/**
|
|
62
64
|
* Debug logs collected during public function execution. Served only when the node is in test mode and placed on
|
|
63
65
|
* the receipt only because it's a convenient place for it (the logs are printed out by the wallet when a mined
|
|
@@ -109,6 +111,7 @@ export class TxReceipt {
|
|
|
109
111
|
error: z.string().optional(),
|
|
110
112
|
blockHash: BlockHash.schema.optional(),
|
|
111
113
|
blockNumber: BlockNumberSchema.optional(),
|
|
114
|
+
epochNumber: EpochNumberSchema.optional(),
|
|
112
115
|
transactionFee: schemas.BigInt.optional(),
|
|
113
116
|
debugLogs: z.array(DebugLog.schema).optional(),
|
|
114
117
|
})
|
|
@@ -123,6 +126,7 @@ export class TxReceipt {
|
|
|
123
126
|
transactionFee?: bigint;
|
|
124
127
|
blockHash?: BlockHash;
|
|
125
128
|
blockNumber?: BlockNumber;
|
|
129
|
+
epochNumber?: EpochNumber;
|
|
126
130
|
debugLogs?: DebugLog[];
|
|
127
131
|
}) {
|
|
128
132
|
return new TxReceipt(
|
|
@@ -133,6 +137,7 @@ export class TxReceipt {
|
|
|
133
137
|
fields.transactionFee,
|
|
134
138
|
fields.blockHash,
|
|
135
139
|
fields.blockNumber,
|
|
140
|
+
fields.epochNumber,
|
|
136
141
|
fields.debugLogs,
|
|
137
142
|
);
|
|
138
143
|
}
|
|
@@ -3,15 +3,28 @@ import { fileURLToPath } from '@aztec/foundation/url';
|
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import { dirname, resolve } from 'path';
|
|
5
5
|
|
|
6
|
-
/** Returns the package version from the release-please manifest, or undefined if not found. */
|
|
6
|
+
/** Returns the package version from the release-please manifest or the package.json, or undefined if not found. */
|
|
7
7
|
export function getPackageVersion(): string | undefined {
|
|
8
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
// Try the release-please manifest first (works in dev/repo checkout).
|
|
8
11
|
try {
|
|
9
|
-
const releasePleaseManifestPath = resolve(
|
|
10
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
11
|
-
'../../../../.release-please-manifest.json',
|
|
12
|
-
);
|
|
12
|
+
const releasePleaseManifestPath = resolve(dir, '../../../../.release-please-manifest.json');
|
|
13
13
|
return JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
|
|
14
14
|
} catch {
|
|
15
|
-
|
|
15
|
+
// Not in a repo checkout, fall through.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fall back to the stdlib package.json version (works in npm-installed packages).
|
|
19
|
+
try {
|
|
20
|
+
const packageJsonPath = resolve(dir, '../../package.json');
|
|
21
|
+
const version = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
22
|
+
if (version && version !== '0.1.0') {
|
|
23
|
+
return version;
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
// No package.json found either.
|
|
16
27
|
}
|
|
28
|
+
|
|
29
|
+
return undefined;
|
|
17
30
|
}
|
package/src/validators/errors.ts
CHANGED
|
@@ -36,6 +36,15 @@ export class FailedToReExecuteTransactionsError extends ValidatorError {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export class ReExInitialStateMismatchError extends ValidatorError {
|
|
40
|
+
constructor(
|
|
41
|
+
public readonly expectedArchiveRoot: Fr,
|
|
42
|
+
public readonly actualArchiveRoot: Fr,
|
|
43
|
+
) {
|
|
44
|
+
super('Re-execution initial state mismatch');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
export class ReExStateMismatchError extends ValidatorError {
|
|
40
49
|
constructor(
|
|
41
50
|
public readonly expectedArchiveRoot: Fr,
|
|
@@ -115,7 +115,7 @@ export function validatePartialComponentVersionsMatch(
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/** Returns a Koa middleware that injects the versioning info as headers. */
|
|
118
|
-
export function getVersioningMiddleware(versions: Partial<ComponentsVersions
|
|
118
|
+
export function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: { packageVersion?: string }) {
|
|
119
119
|
return async (ctx: Koa.Context, next: () => Promise<void>) => {
|
|
120
120
|
try {
|
|
121
121
|
await next();
|
|
@@ -128,6 +128,9 @@ export function getVersioningMiddleware(versions: Partial<ComponentsVersions>) {
|
|
|
128
128
|
ctx.set(`x-aztec-${key}`, value.toString());
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
if (opts?.packageVersion) {
|
|
132
|
+
ctx.set('x-aztec-packageVersion', opts.packageVersion);
|
|
133
|
+
}
|
|
131
134
|
}
|
|
132
135
|
};
|
|
133
136
|
}
|