@aztec/stdlib 0.0.1-commit.dbf9cec → 0.0.1-commit.df81a97b5
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/abi.d.ts +138 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +10 -2
- package/dest/abi/buffer.d.ts +14 -4
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +25 -4
- 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/avm/avm.d.ts +300 -300
- package/dest/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +16 -8
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -4
- 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/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/config/pipelining-config.d.ts +19 -0
- package/dest/config/pipelining-config.d.ts.map +1 -0
- package/dest/config/pipelining-config.js +18 -0
- package/dest/config/sequencer-config.d.ts +4 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +6 -0
- package/dest/contract/contract_address.d.ts +3 -3
- package/dest/contract/contract_address.js +3 -3
- package/dest/contract/contract_class_id.d.ts +2 -2
- package/dest/contract/contract_class_id.js +2 -2
- package/dest/contract/index.d.ts +1 -3
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -2
- package/dest/contract/interfaces/contract_class.d.ts +3 -156
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +1 -28
- package/dest/epoch-helpers/index.d.ts +7 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +10 -2
- package/dest/gas/gas_fees.d.ts +1 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +4 -1
- package/dest/ha-signing/config.d.ts +49 -14
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +20 -15
- package/dest/ha-signing/index.d.ts +3 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +2 -1
- package/dest/ha-signing/local_config.d.ts +63 -0
- package/dest/ha-signing/local_config.d.ts.map +1 -0
- package/dest/ha-signing/local_config.js +24 -0
- package/dest/hash/hash.d.ts +16 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +24 -0
- package/dest/interfaces/allowed_element.d.ts +26 -20
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -8
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +76 -30
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +12 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +5 -2
- package/dest/interfaces/block-builder.d.ts +38 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +13 -6
- package/dest/interfaces/configs.d.ts +62 -32
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +6 -2
- package/dest/interfaces/l2_logs_source.d.ts +5 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- 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/interfaces/proving-job.d.ts +200 -200
- package/dest/interfaces/validator.d.ts +103 -41
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +8 -4
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/kv-store/config.d.ts +17 -0
- package/dest/kv-store/config.d.ts.map +1 -0
- package/dest/kv-store/config.js +26 -0
- package/dest/kv-store/index.d.ts +2 -0
- package/dest/kv-store/index.d.ts.map +1 -0
- package/dest/kv-store/index.js +1 -0
- package/dest/logs/index.d.ts +2 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +1 -0
- 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/logs/tagging_index_range.d.ts +40 -0
- package/dest/logs/tagging_index_range.d.ts.map +1 -0
- package/dest/logs/tagging_index_range.js +8 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -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/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +1 -6
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -23
- 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/slashing/tally.d.ts +7 -2
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +30 -2
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +0 -27
- package/dest/tests/mocks.d.ts +4 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -8
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/private_execution_result.d.ts +6 -6
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +6 -6
- package/dest/tx/profiling.d.ts +14 -2
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +13 -3
- package/dest/tx/simulated_tx.d.ts +113 -2
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +4 -1
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- 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/tx/validator/error_texts.d.ts +9 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +10 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +24 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- 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 +10 -9
- package/src/abi/abi.ts +25 -2
- package/src/abi/buffer.ts +25 -4
- 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.ts +13 -1
- package/src/block/l2_block_source.ts +16 -7
- package/src/checkpoint/checkpoint.ts +12 -3
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/index.ts +1 -0
- package/src/config/pipelining-config.ts +31 -0
- package/src/config/sequencer-config.ts +9 -1
- package/src/contract/contract_address.ts +3 -3
- package/src/contract/contract_class_id.ts +2 -2
- package/src/contract/index.ts +0 -2
- package/src/contract/interfaces/contract_class.ts +2 -82
- package/src/epoch-helpers/index.ts +14 -0
- package/src/gas/README.md +123 -0
- package/src/gas/gas_fees.ts +7 -1
- package/src/ha-signing/config.ts +45 -38
- package/src/ha-signing/index.ts +9 -0
- package/src/ha-signing/local_config.ts +46 -0
- package/src/hash/hash.ts +29 -0
- package/src/interfaces/allowed_element.ts +29 -9
- package/src/interfaces/archiver.ts +3 -2
- package/src/interfaces/aztec-node.ts +24 -5
- package/src/interfaces/block-builder.ts +60 -14
- package/src/interfaces/configs.ts +25 -8
- package/src/interfaces/l2_logs_source.ts +4 -1
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/validator.ts +50 -28
- package/src/interfaces/world_state.ts +4 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/kv-store/config.ts +36 -0
- package/src/kv-store/index.ts +1 -0
- package/src/logs/index.ts +1 -0
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/public_log.ts +4 -2
- package/src/logs/tagging_index_range.ts +24 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l1_to_l2_message_source.ts +3 -1
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/noir/index.ts +2 -2
- package/src/p2p/checkpoint_proposal.ts +23 -37
- package/src/p2p/peer_error.ts +7 -0
- package/src/slashing/tally.ts +34 -1
- package/src/tests/factories.ts +0 -33
- package/src/tests/mocks.ts +18 -7
- package/src/tx/block_header.ts +6 -0
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +11 -2
- package/src/tx/simulated_tx.ts +8 -1
- package/src/tx/tx.ts +20 -11
- package/src/tx/tx_receipt.ts +7 -2
- package/src/tx/validator/error_texts.ts +12 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +30 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/dest/contract/private_function_membership_proof.d.ts +0 -32
- package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/private_function_membership_proof.js +0 -124
- package/dest/contract/utility_function_membership_proof.d.ts +0 -27
- package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/utility_function_membership_proof.js +0 -87
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/contract/private_function_membership_proof.ts +0 -167
- package/src/contract/utility_function_membership_proof.ts +0 -118
- package/src/update-checker/update-checker.ts +0 -166
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
|
|
|
@@ -15,7 +15,7 @@ export enum TxStatus {
|
|
|
15
15
|
PROPOSED = 'proposed',
|
|
16
16
|
CHECKPOINTED = 'checkpointed',
|
|
17
17
|
PROVEN = 'proven',
|
|
18
|
-
FINALIZED = 'finalized',
|
|
18
|
+
FINALIZED = 'finalized',
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** Tx status sorted by finalization progress. */
|
|
@@ -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
|
}
|
|
@@ -6,6 +6,10 @@ export const TX_ERROR_GAS_LIMIT_TOO_HIGH = 'Gas limit is higher than the amount
|
|
|
6
6
|
|
|
7
7
|
// Phases
|
|
8
8
|
export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
|
|
9
|
+
export const TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT = 'Setup function targets unknown contract';
|
|
10
|
+
export const TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER = 'Setup only_self function called with incorrect msg_sender';
|
|
11
|
+
export const TX_ERROR_SETUP_NULL_MSG_SENDER = 'Setup function called with null msg sender';
|
|
12
|
+
export const TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH = 'Setup function called with wrong calldata length';
|
|
9
13
|
|
|
10
14
|
// Nullifiers
|
|
11
15
|
export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
|
|
@@ -37,5 +41,13 @@ export const TX_ERROR_SIZE_ABOVE_LIMIT = 'Transaction size above size limit';
|
|
|
37
41
|
// Block header
|
|
38
42
|
export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
|
|
39
43
|
|
|
44
|
+
// Contract instance
|
|
45
|
+
export const TX_ERROR_INCORRECT_CONTRACT_ADDRESS = 'Incorrect contract instance deployment address';
|
|
46
|
+
export const TX_ERROR_MALFORMED_CONTRACT_INSTANCE_LOG = 'Failed to parse contract instance deployment log';
|
|
47
|
+
|
|
48
|
+
// Contract class
|
|
49
|
+
export const TX_ERROR_INCORRECT_CONTRACT_CLASS_ID = 'Incorrect contract class id';
|
|
50
|
+
export const TX_ERROR_MALFORMED_CONTRACT_CLASS_LOG = 'Failed to parse contract class registration log';
|
|
51
|
+
|
|
40
52
|
// General
|
|
41
53
|
export const TX_ERROR_DURING_VALIDATION = 'Unexpected error during validation';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './package_version.js';
|
|
2
|
+
export * from './version_checker.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { dirname, resolve } from 'path';
|
|
5
|
+
|
|
6
|
+
/** Returns the package version from the release-please manifest or the package.json, or undefined if not found. */
|
|
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).
|
|
11
|
+
try {
|
|
12
|
+
const releasePleaseManifestPath = resolve(dir, '../../../../.release-please-manifest.json');
|
|
13
|
+
return JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
|
|
14
|
+
} catch {
|
|
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.
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
|
|
6
|
+
export type EventMap = {
|
|
7
|
+
newVersion: [{ name: string; currentVersion: string; latestVersion: string }];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type VersionCheck = {
|
|
11
|
+
name: string;
|
|
12
|
+
currentVersion: string;
|
|
13
|
+
getLatestVersion: () => Promise<string | undefined>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class VersionChecker extends EventEmitter<EventMap> {
|
|
17
|
+
private runningPromise: RunningPromise;
|
|
18
|
+
constructor(
|
|
19
|
+
private checks: Array<VersionCheck>,
|
|
20
|
+
intervalCheckMs = 60_000,
|
|
21
|
+
private logger = createLogger('version_checker'),
|
|
22
|
+
) {
|
|
23
|
+
super();
|
|
24
|
+
this.runningPromise = new RunningPromise(this.run, logger, intervalCheckMs);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public start(): void {
|
|
28
|
+
if (this.runningPromise.isRunning()) {
|
|
29
|
+
this.logger.warn('VersionChecker is already running');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.runningPromise.start();
|
|
34
|
+
this.logger.info('Version check started');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public trigger(): Promise<void> {
|
|
38
|
+
return this.runningPromise.trigger();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async stop(): Promise<void> {
|
|
42
|
+
if (!this.runningPromise.isRunning()) {
|
|
43
|
+
this.logger.warn('VersionChecker is not running');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await this.runningPromise.stop();
|
|
48
|
+
this.logger.info('Version checker stopped');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private run = async () => {
|
|
52
|
+
await Promise.allSettled(this.checks.map(check => this.checkVersion(check)));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
private async checkVersion({ name, currentVersion, getLatestVersion }: VersionCheck): Promise<void> {
|
|
56
|
+
try {
|
|
57
|
+
const latestVersion = await getLatestVersion();
|
|
58
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
59
|
+
this.emit('newVersion', { name, latestVersion, currentVersion });
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
this.logger.warn(`Error checking for new ${name} versions: ${err}`, { err });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
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
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, FunctionSelector } from '../abi/index.js';
|
|
2
|
-
import type { ContractClassPublic, ExecutablePrivateFunctionWithMembershipProof, PrivateFunctionMembershipProof } from './interfaces/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a membership proof for a private function in a contract class, to be verified via `isValidPrivateFunctionMembershipProof`.
|
|
5
|
-
* @param selector - Selector of the function to create the proof for.
|
|
6
|
-
* @param artifact - Artifact of the contract class where the function is defined.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createPrivateFunctionMembershipProof(selector: FunctionSelector, artifact: ContractArtifact): Promise<PrivateFunctionMembershipProof>;
|
|
9
|
-
/**
|
|
10
|
-
* Verifies that a private function with a membership proof as emitted by the ClassRegistry contract is valid,
|
|
11
|
-
* as defined in the protocol specs at contract-deployment/classes:
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* // Load contract class from local db
|
|
15
|
-
* contract_class = db.get_contract_class(contract_class_id)
|
|
16
|
-
*
|
|
17
|
-
* // Compute function leaf and assert it belongs to the private functions tree
|
|
18
|
-
* function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
|
|
19
|
-
* computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
|
|
20
|
-
* assert computed_private_function_tree_root == contract_class.private_functions_root
|
|
21
|
-
*
|
|
22
|
-
* // Compute artifact leaf and assert it belongs to the artifact
|
|
23
|
-
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
24
|
-
* computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
|
|
25
|
-
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
|
|
26
|
-
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
27
|
-
* ```
|
|
28
|
-
* @param fn - Function to check membership proof for.
|
|
29
|
-
* @param contractClass - In which contract class the function is expected to be.
|
|
30
|
-
*/
|
|
31
|
-
export declare function isValidPrivateFunctionMembershipProof(fn: ExecutablePrivateFunctionWithMembershipProof, contractClass: Pick<ContractClassPublic, 'privateFunctionsRoot' | 'artifactHash'>): Promise<boolean>;
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvcHJpdmF0ZV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFnQixNQUFNLGlCQUFpQixDQUFDO0FBVXhGLE9BQU8sS0FBSyxFQUNWLG1CQUFtQixFQUNuQiw0Q0FBNEMsRUFDNUMsOEJBQThCLEVBQy9CLE1BQU0sdUJBQXVCLENBQUM7QUFHL0I7Ozs7R0FJRztBQUNILHdCQUFzQixvQ0FBb0MsQ0FDeEQsUUFBUSxFQUFFLGdCQUFnQixFQUMxQixRQUFRLEVBQUUsZ0JBQWdCLEdBQ3pCLE9BQU8sQ0FBQyw4QkFBOEIsQ0FBQyxDQTREekM7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBQ0gsd0JBQXNCLHFDQUFxQyxDQUN6RCxFQUFFLEVBQUUsNENBQTRDLEVBQ2hELGFBQWEsRUFBRSxJQUFJLENBQUMsbUJBQW1CLEVBQUUsc0JBQXNCLEdBQUcsY0FBYyxDQUFDLG9CQWtEbEYifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"private_function_membership_proof.d.ts","sourceRoot":"","sources":["../../src/contract/private_function_membership_proof.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AAUxF,OAAO,KAAK,EACV,mBAAmB,EACnB,4CAA4C,EAC5C,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAG/B;;;;GAIG;AACH,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CA4DzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,4CAA4C,EAChD,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,GAAG,cAAc,CAAC,oBAkDlF"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { computeRootFromSiblingPath } from '@aztec/foundation/trees';
|
|
5
|
-
import { FunctionSelector, FunctionType } from '../abi/index.js';
|
|
6
|
-
import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPreimage, computeFunctionArtifactHash, computeFunctionMetadataHash, getArtifactMerkleTreeHasher } from './artifact_hash.js';
|
|
7
|
-
import { getContractClassPrivateFunctionFromArtifact } from './contract_class.js';
|
|
8
|
-
import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './private_function.js';
|
|
9
|
-
/**
|
|
10
|
-
* Creates a membership proof for a private function in a contract class, to be verified via `isValidPrivateFunctionMembershipProof`.
|
|
11
|
-
* @param selector - Selector of the function to create the proof for.
|
|
12
|
-
* @param artifact - Artifact of the contract class where the function is defined.
|
|
13
|
-
*/ export async function createPrivateFunctionMembershipProof(selector, artifact) {
|
|
14
|
-
const log = createLogger('circuits:function_membership_proof');
|
|
15
|
-
// Locate private function definition and artifact
|
|
16
|
-
const privateFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE);
|
|
17
|
-
const privateFunctionsFromArtifact = await Promise.all(privateFunctions.map(getContractClassPrivateFunctionFromArtifact));
|
|
18
|
-
const privateFunction = privateFunctionsFromArtifact.find((fn)=>fn.selector.equals(selector));
|
|
19
|
-
const privateFunctionsAndSelectors = await Promise.all(privateFunctions.map(async (fn)=>({
|
|
20
|
-
fn,
|
|
21
|
-
selector: await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)
|
|
22
|
-
})));
|
|
23
|
-
const privateFunctionArtifact = privateFunctionsAndSelectors.find((fnAndSelector)=>selector.equals(fnAndSelector.selector))?.fn;
|
|
24
|
-
if (!privateFunction || !privateFunctionArtifact) {
|
|
25
|
-
throw new Error(`Private function with selector ${selector.toString()} not found`);
|
|
26
|
-
}
|
|
27
|
-
// Compute preimage for the artifact hash
|
|
28
|
-
const { utilityFunctionRoot: utilityFunctionsTreeRoot, metadataHash: artifactMetadataHash } = await computeArtifactHashPreimage(artifact);
|
|
29
|
-
// We need two sibling paths because private function information is split across two trees:
|
|
30
|
-
// The "private function tree" captures the selectors and verification keys, and is used in the kernel circuit for verifying the proof generated by the app circuit.
|
|
31
|
-
const functionLeaf = await computePrivateFunctionLeaf(privateFunction);
|
|
32
|
-
const functionsTree = await computePrivateFunctionsTree(privateFunctionsFromArtifact);
|
|
33
|
-
const functionsTreeLeafIndex = functionsTree.getIndex(functionLeaf);
|
|
34
|
-
const functionsTreeSiblingPath = functionsTree.getSiblingPath(functionsTreeLeafIndex).map(Fr.fromBuffer);
|
|
35
|
-
// And the "artifact tree" captures function bytecode and metadata, and is used by the pxe to check that its executing the code it's supposed to be executing, but it never goes into circuits.
|
|
36
|
-
const functionMetadataHash = computeFunctionMetadataHash(privateFunctionArtifact);
|
|
37
|
-
const functionArtifactHash = await computeFunctionArtifactHash({
|
|
38
|
-
...privateFunctionArtifact,
|
|
39
|
-
functionMetadataHash
|
|
40
|
-
});
|
|
41
|
-
const artifactTree = await computeArtifactFunctionTree(artifact, FunctionType.PRIVATE);
|
|
42
|
-
const artifactTreeLeafIndex = artifactTree.getIndex(functionArtifactHash.toBuffer());
|
|
43
|
-
const artifactTreeSiblingPath = artifactTree.getSiblingPath(artifactTreeLeafIndex).map(Fr.fromBuffer);
|
|
44
|
-
log.debug(`Computed proof for private function with selector ${selector.toString()}`, {
|
|
45
|
-
functionArtifactHash,
|
|
46
|
-
functionMetadataHash,
|
|
47
|
-
functionLeaf: '0x' + functionLeaf.toString('hex'),
|
|
48
|
-
artifactMetadataHash,
|
|
49
|
-
privateFunctionsTreeRoot: '0x' + functionsTree.root.toString('hex'),
|
|
50
|
-
utilityFunctionsTreeRoot,
|
|
51
|
-
artifactFunctionTreeSiblingPath: artifactTreeSiblingPath.map((fr)=>fr.toString()).join(','),
|
|
52
|
-
privateFunctionTreeSiblingPath: functionsTreeSiblingPath.map((fr)=>fr.toString()).join(',')
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
artifactTreeSiblingPath,
|
|
56
|
-
artifactTreeLeafIndex,
|
|
57
|
-
artifactMetadataHash,
|
|
58
|
-
functionMetadataHash,
|
|
59
|
-
utilityFunctionsTreeRoot,
|
|
60
|
-
privateFunctionTreeSiblingPath: functionsTreeSiblingPath,
|
|
61
|
-
privateFunctionTreeLeafIndex: functionsTreeLeafIndex
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Verifies that a private function with a membership proof as emitted by the ClassRegistry contract is valid,
|
|
66
|
-
* as defined in the protocol specs at contract-deployment/classes:
|
|
67
|
-
*
|
|
68
|
-
* ```
|
|
69
|
-
* // Load contract class from local db
|
|
70
|
-
* contract_class = db.get_contract_class(contract_class_id)
|
|
71
|
-
*
|
|
72
|
-
* // Compute function leaf and assert it belongs to the private functions tree
|
|
73
|
-
* function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
|
|
74
|
-
* computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
|
|
75
|
-
* assert computed_private_function_tree_root == contract_class.private_functions_root
|
|
76
|
-
*
|
|
77
|
-
* // Compute artifact leaf and assert it belongs to the artifact
|
|
78
|
-
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
79
|
-
* computed_artifact_private_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path)
|
|
80
|
-
* computed_artifact_hash = sha256(computed_artifact_private_function_tree_root, utility_functions_artifact_tree_root, artifact_metadata_hash)
|
|
81
|
-
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
82
|
-
* ```
|
|
83
|
-
* @param fn - Function to check membership proof for.
|
|
84
|
-
* @param contractClass - In which contract class the function is expected to be.
|
|
85
|
-
*/ export async function isValidPrivateFunctionMembershipProof(fn, contractClass) {
|
|
86
|
-
const log = createLogger('circuits:function_membership_proof');
|
|
87
|
-
// Check private function tree membership
|
|
88
|
-
const functionLeaf = await computePrivateFunctionLeaf(fn);
|
|
89
|
-
const rootBuffer = await computeRootFromSiblingPath(functionLeaf, fn.privateFunctionTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.privateFunctionTreeLeafIndex, async (left, right)=>(await poseidon2Hash([
|
|
90
|
-
left,
|
|
91
|
-
right
|
|
92
|
-
])).toBuffer());
|
|
93
|
-
const computedPrivateFunctionTreeRoot = Fr.fromBuffer(rootBuffer);
|
|
94
|
-
if (!contractClass.privateFunctionsRoot.equals(computedPrivateFunctionTreeRoot)) {
|
|
95
|
-
log.debug(`Private function tree root mismatch`, {
|
|
96
|
-
expectedPrivateFunctionTreeRoot: contractClass.privateFunctionsRoot,
|
|
97
|
-
computedPrivateFunctionTreeRoot: computedPrivateFunctionTreeRoot,
|
|
98
|
-
computedFunctionLeaf: '0x' + functionLeaf.toString('hex')
|
|
99
|
-
});
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
// Check artifact hash
|
|
103
|
-
const functionArtifactHash = await computeFunctionArtifactHash(fn);
|
|
104
|
-
const computedArtifactPrivateFunctionTreeRootBuffer = await computeRootFromSiblingPath(functionArtifactHash.toBuffer(), fn.artifactTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.artifactTreeLeafIndex, getArtifactMerkleTreeHasher());
|
|
105
|
-
const computedArtifactPrivateFunctionTreeRoot = Fr.fromBuffer(computedArtifactPrivateFunctionTreeRootBuffer);
|
|
106
|
-
const computedArtifactHash = await computeArtifactHash({
|
|
107
|
-
privateFunctionRoot: computedArtifactPrivateFunctionTreeRoot,
|
|
108
|
-
utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
|
|
109
|
-
metadataHash: fn.artifactMetadataHash
|
|
110
|
-
});
|
|
111
|
-
if (!contractClass.artifactHash.equals(computedArtifactHash)) {
|
|
112
|
-
log.debug(`Artifact hash mismatch`, {
|
|
113
|
-
expected: contractClass.artifactHash,
|
|
114
|
-
computedArtifactHash,
|
|
115
|
-
computedFunctionArtifactHash: functionArtifactHash,
|
|
116
|
-
computedArtifactPrivateFunctionTreeRoot,
|
|
117
|
-
utilityFunctionRoot: fn.utilityFunctionsTreeRoot,
|
|
118
|
-
metadataHash: fn.artifactMetadataHash,
|
|
119
|
-
artifactFunctionTreeSiblingPath: fn.artifactTreeSiblingPath.map((fr)=>fr.toString()).join(',')
|
|
120
|
-
});
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, FunctionSelector } from '../abi/index.js';
|
|
2
|
-
import type { ContractClassPublic, UtilityFunctionMembershipProof, UtilityFunctionWithMembershipProof } from './interfaces/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a membership proof for a utility function in a contract class, to be verified via `isValidUtilityFunctionMembershipProof`.
|
|
5
|
-
* @param selector - Selector of the function to create the proof for.
|
|
6
|
-
* @param artifact - Artifact of the contract class where the function is defined.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createUtilityFunctionMembershipProof(selector: FunctionSelector, artifact: ContractArtifact): Promise<UtilityFunctionMembershipProof>;
|
|
9
|
-
/**
|
|
10
|
-
* Verifies that a utility function with a membership proof as emitted by the ClassRegistry contract is valid,
|
|
11
|
-
* as defined in the protocol specs at contract-deployment/classes:
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* // Load contract class from local db
|
|
15
|
-
* contract_class = db.get_contract_class(contract_class_id)
|
|
16
|
-
*
|
|
17
|
-
* // Compute artifact leaf and assert it belongs to the artifact
|
|
18
|
-
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
19
|
-
* computed_artifact_utility_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path, artifact_function_tree_leaf_index)
|
|
20
|
-
* computed_artifact_hash = sha256(private_functions_artifact_tree_root, computed_artifact_utility_function_tree_root, artifact_metadata_hash)
|
|
21
|
-
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
22
|
-
* ```
|
|
23
|
-
* @param fn - Function to check membership proof for.
|
|
24
|
-
* @param contractClass - In which contract class the function is expected to be.
|
|
25
|
-
*/
|
|
26
|
-
export declare function isValidUtilityFunctionMembershipProof(fn: UtilityFunctionWithMembershipProof, contractClass: Pick<ContractClassPublic, 'artifactHash'>): Promise<boolean>;
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0eV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvdXRpbGl0eV9mdW5jdGlvbl9tZW1iZXJzaGlwX3Byb29mLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFnQixNQUFNLGlCQUFpQixDQUFDO0FBU3hGLE9BQU8sS0FBSyxFQUNWLG1CQUFtQixFQUNuQiw4QkFBOEIsRUFDOUIsa0NBQWtDLEVBQ25DLE1BQU0sdUJBQXVCLENBQUM7QUFFL0I7Ozs7R0FJRztBQUNILHdCQUFzQixvQ0FBb0MsQ0FDeEQsUUFBUSxFQUFFLGdCQUFnQixFQUMxQixRQUFRLEVBQUUsZ0JBQWdCLEdBQ3pCLE9BQU8sQ0FBQyw4QkFBOEIsQ0FBQyxDQXNDekM7QUFFRDs7Ozs7Ozs7Ozs7Ozs7OztHQWdCRztBQUNILHdCQUFzQixxQ0FBcUMsQ0FDekQsRUFBRSxFQUFFLGtDQUFrQyxFQUN0QyxhQUFhLEVBQUUsSUFBSSxDQUFDLG1CQUFtQixFQUFFLGNBQWMsQ0FBQyxvQkErQnpEIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utility_function_membership_proof.d.ts","sourceRoot":"","sources":["../../src/contract/utility_function_membership_proof.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AASxF,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,wBAAsB,oCAAoC,CACxD,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAsCzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,kCAAkC,EACtC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,oBA+BzD"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { computeRootFromSiblingPath } from '@aztec/foundation/trees';
|
|
4
|
-
import { FunctionSelector, FunctionType } from '../abi/index.js';
|
|
5
|
-
import { computeArtifactFunctionTree, computeArtifactHash, computeArtifactHashPreimage, computeFunctionArtifactHash, computeFunctionMetadataHash, getArtifactMerkleTreeHasher } from './artifact_hash.js';
|
|
6
|
-
/**
|
|
7
|
-
* Creates a membership proof for a utility function in a contract class, to be verified via `isValidUtilityFunctionMembershipProof`.
|
|
8
|
-
* @param selector - Selector of the function to create the proof for.
|
|
9
|
-
* @param artifact - Artifact of the contract class where the function is defined.
|
|
10
|
-
*/ export async function createUtilityFunctionMembershipProof(selector, artifact) {
|
|
11
|
-
const log = createLogger('circuits:function_membership_proof');
|
|
12
|
-
// Locate function artifact
|
|
13
|
-
const utilityFunctions = artifact.functions.filter((fn)=>fn.functionType === FunctionType.UTILITY);
|
|
14
|
-
const utilityFunctionsAndSelectors = await Promise.all(utilityFunctions.map(async (fn)=>({
|
|
15
|
-
fn,
|
|
16
|
-
selector: await FunctionSelector.fromNameAndParameters(fn)
|
|
17
|
-
})));
|
|
18
|
-
const fn = utilityFunctionsAndSelectors.find((fnAndSelector)=>selector.equals(fnAndSelector.selector))?.fn;
|
|
19
|
-
if (!fn) {
|
|
20
|
-
throw new Error(`Utility function with selector ${selector.toString()} not found`);
|
|
21
|
-
}
|
|
22
|
-
// Compute preimage for the artifact hash
|
|
23
|
-
const { privateFunctionRoot: privateFunctionsArtifactTreeRoot, metadataHash: artifactMetadataHash } = await computeArtifactHashPreimage(artifact);
|
|
24
|
-
// Compute the sibling path for the "artifact tree"
|
|
25
|
-
const functionMetadataHash = computeFunctionMetadataHash(fn);
|
|
26
|
-
const functionArtifactHash = await computeFunctionArtifactHash({
|
|
27
|
-
...fn,
|
|
28
|
-
functionMetadataHash
|
|
29
|
-
});
|
|
30
|
-
const artifactTree = await computeArtifactFunctionTree(artifact, FunctionType.UTILITY);
|
|
31
|
-
const artifactTreeLeafIndex = artifactTree.getIndex(functionArtifactHash.toBuffer());
|
|
32
|
-
const artifactTreeSiblingPath = artifactTree.getSiblingPath(artifactTreeLeafIndex).map(Fr.fromBuffer);
|
|
33
|
-
log.debug(`Computed proof for utility function with selector ${selector.toString()}`, {
|
|
34
|
-
functionArtifactHash,
|
|
35
|
-
functionMetadataHash,
|
|
36
|
-
artifactMetadataHash,
|
|
37
|
-
artifactFunctionTreeSiblingPath: artifactTreeSiblingPath.map((fr)=>fr.toString()).join(','),
|
|
38
|
-
privateFunctionsArtifactTreeRoot
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
artifactTreeSiblingPath,
|
|
42
|
-
artifactTreeLeafIndex,
|
|
43
|
-
artifactMetadataHash,
|
|
44
|
-
functionMetadataHash,
|
|
45
|
-
privateFunctionsArtifactTreeRoot
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Verifies that a utility function with a membership proof as emitted by the ClassRegistry contract is valid,
|
|
50
|
-
* as defined in the protocol specs at contract-deployment/classes:
|
|
51
|
-
*
|
|
52
|
-
* ```
|
|
53
|
-
* // Load contract class from local db
|
|
54
|
-
* contract_class = db.get_contract_class(contract_class_id)
|
|
55
|
-
*
|
|
56
|
-
* // Compute artifact leaf and assert it belongs to the artifact
|
|
57
|
-
* artifact_function_leaf = sha256(selector, metadata_hash, sha256(bytecode))
|
|
58
|
-
* computed_artifact_utility_function_tree_root = compute_root(artifact_function_leaf, artifact_function_tree_sibling_path, artifact_function_tree_leaf_index)
|
|
59
|
-
* computed_artifact_hash = sha256(private_functions_artifact_tree_root, computed_artifact_utility_function_tree_root, artifact_metadata_hash)
|
|
60
|
-
* assert computed_artifact_hash == contract_class.artifact_hash
|
|
61
|
-
* ```
|
|
62
|
-
* @param fn - Function to check membership proof for.
|
|
63
|
-
* @param contractClass - In which contract class the function is expected to be.
|
|
64
|
-
*/ export async function isValidUtilityFunctionMembershipProof(fn, contractClass) {
|
|
65
|
-
const log = createLogger('circuits:function_membership_proof');
|
|
66
|
-
const functionArtifactHash = await computeFunctionArtifactHash(fn);
|
|
67
|
-
const computedArtifactFunctionTreeRootBuffer = await computeRootFromSiblingPath(functionArtifactHash.toBuffer(), fn.artifactTreeSiblingPath.map((fr)=>fr.toBuffer()), fn.artifactTreeLeafIndex, getArtifactMerkleTreeHasher());
|
|
68
|
-
const computedArtifactFunctionTreeRoot = Fr.fromBuffer(computedArtifactFunctionTreeRootBuffer);
|
|
69
|
-
const computedArtifactHash = await computeArtifactHash({
|
|
70
|
-
privateFunctionRoot: fn.privateFunctionsArtifactTreeRoot,
|
|
71
|
-
utilityFunctionRoot: computedArtifactFunctionTreeRoot,
|
|
72
|
-
metadataHash: fn.artifactMetadataHash
|
|
73
|
-
});
|
|
74
|
-
if (!contractClass.artifactHash.equals(computedArtifactHash)) {
|
|
75
|
-
log.debug(`Artifact hash mismatch`, {
|
|
76
|
-
expected: contractClass.artifactHash,
|
|
77
|
-
computedArtifactHash,
|
|
78
|
-
computedFunctionArtifactHash: functionArtifactHash,
|
|
79
|
-
computedArtifactFunctionTreeRoot,
|
|
80
|
-
privateFunctionsArtifactTreeRoot: fn.privateFunctionsArtifactTreeRoot,
|
|
81
|
-
metadataHash: fn.artifactMetadataHash,
|
|
82
|
-
artifactFunctionTreeSiblingPath: fn.artifactTreeSiblingPath.map((fr)=>fr.toString()).join(',')
|
|
83
|
-
});
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ViemClient } from '@aztec/ethereum/types';
|
|
2
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
export type EventMap = {
|
|
5
|
-
newRollupVersion: [{
|
|
6
|
-
currentVersion: bigint;
|
|
7
|
-
latestVersion: bigint;
|
|
8
|
-
}];
|
|
9
|
-
newNodeVersion: [{
|
|
10
|
-
currentVersion: string;
|
|
11
|
-
latestVersion: string;
|
|
12
|
-
}];
|
|
13
|
-
updateNodeConfig: [object];
|
|
14
|
-
updatePublicTelemetryConfig: [object];
|
|
15
|
-
};
|
|
16
|
-
type Config = {
|
|
17
|
-
baseURL: URL;
|
|
18
|
-
nodeVersion?: string;
|
|
19
|
-
checkIntervalMs?: number;
|
|
20
|
-
registryContractAddress: EthAddress;
|
|
21
|
-
publicClient: ViemClient;
|
|
22
|
-
fetch?: typeof fetch;
|
|
23
|
-
};
|
|
24
|
-
export declare class UpdateChecker extends EventEmitter<EventMap> {
|
|
25
|
-
private updatesUrl;
|
|
26
|
-
private nodeVersion;
|
|
27
|
-
private rollupVersion;
|
|
28
|
-
private fetch;
|
|
29
|
-
private getLatestRollupVersion;
|
|
30
|
-
private checkIntervalMs;
|
|
31
|
-
private log;
|
|
32
|
-
private runningPromise;
|
|
33
|
-
private lastPatchedConfig;
|
|
34
|
-
private lastPatchedPublicTelemetryConfig;
|
|
35
|
-
constructor(updatesUrl: URL, nodeVersion: string | undefined, rollupVersion: bigint, fetch: typeof globalThis.fetch, getLatestRollupVersion: () => Promise<bigint>, checkIntervalMs?: number, log?: import("@aztec/foundation/log").Logger);
|
|
36
|
-
static new(config: Config): Promise<UpdateChecker>;
|
|
37
|
-
start(): void;
|
|
38
|
-
stop(): Promise<void>;
|
|
39
|
-
trigger(): Promise<void>;
|
|
40
|
-
private runChecks;
|
|
41
|
-
private checkRollupVersion;
|
|
42
|
-
private checkConfig;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns package version.
|
|
46
|
-
*/
|
|
47
|
-
export declare function getPackageVersion(): string | undefined;
|
|
48
|
-
export {};
|
|
49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