@aztec/stdlib 0.0.1-commit.59e663cd → 0.0.1-commit.5cf06de3
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/block/block_hash.d.ts +14 -17
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +21 -34
- package/dest/block/block_parameter.d.ts +2 -2
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/in_block.d.ts +5 -5
- package/dest/block/in_block.js +1 -1
- package/dest/block/l2_block.d.ts +3 -2
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +2 -3
- package/dest/block/l2_block_source.d.ts +5 -4
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/contract/contract_address.js +1 -1
- package/dest/contract/contract_class_id.d.ts +1 -1
- package/dest/contract/contract_class_id.js +1 -1
- package/dest/contract/private_function.js +1 -1
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/database-version/database_version.d.ts +58 -0
- package/dest/database-version/database_version.d.ts.map +1 -0
- package/dest/database-version/database_version.js +69 -0
- package/dest/database-version/version_manager.d.ts +2 -50
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +1 -66
- package/dest/epoch-helpers/index.d.ts +3 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +4 -0
- package/dest/hash/hash.js +2 -2
- package/dest/hash/map_slot.d.ts +1 -1
- package/dest/hash/map_slot.d.ts.map +1 -1
- package/dest/hash/map_slot.js +4 -3
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -3
- package/dest/interfaces/aztec-node-admin.d.ts +8 -2
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +3 -1
- package/dest/interfaces/aztec-node.d.ts +30 -51
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +3 -7
- package/dest/interfaces/block-builder.d.ts +10 -4
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +7 -0
- package/dest/interfaces/get_logs_response.d.ts +6 -6
- package/dest/interfaces/prover-broker.d.ts +16 -1
- package/dest/interfaces/prover-broker.d.ts.map +1 -1
- package/dest/interfaces/prover-broker.js +4 -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 +5 -0
- package/dest/interfaces/proving-job.d.ts +34 -34
- package/dest/interfaces/validator.d.ts +33 -1
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/keys/derivation.d.ts +3 -3
- package/dest/keys/derivation.js +8 -8
- package/dest/keys/key_types.d.ts +1 -1
- package/dest/keys/utils.d.ts +1 -1
- package/dest/keys/utils.d.ts.map +1 -1
- package/dest/keys/utils.js +7 -3
- package/dest/l1-contracts/slash_factory.d.ts +1 -1
- package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
- package/dest/l1-contracts/slash_factory.js +1 -0
- package/dest/logs/extended_public_log.d.ts +5 -5
- package/dest/logs/log_id.d.ts +4 -4
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +2 -1
- package/dest/logs/siloed_tag.d.ts +1 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +4 -3
- package/dest/stats/stats.d.ts +1 -3
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tx/block_header.js +2 -2
- package/dest/tx/in_tx.d.ts +2 -2
- package/dest/tx/indexed_tx_effect.d.ts +3 -3
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +2 -1
- package/package.json +11 -10
- package/src/block/block_hash.ts +25 -50
- package/src/block/in_block.ts +1 -1
- package/src/block/l2_block.ts +3 -3
- package/src/block/l2_block_source.ts +4 -3
- package/src/contract/contract_address.ts +1 -1
- package/src/contract/contract_class_id.ts +1 -1
- package/src/contract/private_function.ts +1 -1
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/database-version/database_version.ts +87 -0
- package/src/database-version/version_manager.ts +1 -77
- package/src/epoch-helpers/index.ts +9 -0
- package/src/hash/hash.ts +2 -2
- package/src/hash/map_slot.ts +3 -2
- package/src/interfaces/archiver.ts +4 -3
- package/src/interfaces/aztec-node-admin.ts +3 -2
- package/src/interfaces/aztec-node.ts +37 -88
- package/src/interfaces/block-builder.ts +12 -2
- package/src/interfaces/prover-broker.ts +22 -0
- package/src/interfaces/prover-client.ts +7 -0
- package/src/keys/derivation.ts +8 -8
- package/src/keys/key_types.ts +1 -1
- package/src/keys/utils.ts +7 -3
- package/src/l1-contracts/slash_factory.ts +1 -0
- package/src/logs/log_id.ts +2 -1
- package/src/logs/siloed_tag.ts +3 -2
- package/src/stats/stats.ts +0 -2
- package/src/tx/block_header.ts +3 -3
- package/src/tx/indexed_tx_effect.ts +2 -1
- package/dest/database-version/index.d.ts +0 -2
- package/dest/database-version/index.d.ts.map +0 -1
- package/dest/database-version/index.js +0 -1
- package/src/database-version/index.ts +0 -1
|
@@ -20,6 +20,7 @@ import type { BlockHeader } from '../tx/block_header.js';
|
|
|
20
20
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
21
21
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
22
22
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
23
|
+
import type { BlockHash } from './block_hash.js';
|
|
23
24
|
import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
|
|
24
25
|
import type { L2Block } from './l2_block.js';
|
|
25
26
|
import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
|
|
@@ -102,7 +103,7 @@ export interface L2BlockSource {
|
|
|
102
103
|
* @param blockHash - The block hash to retrieve.
|
|
103
104
|
* @returns The requested block header (or undefined if not found).
|
|
104
105
|
*/
|
|
105
|
-
getBlockHeaderByHash(blockHash:
|
|
106
|
+
getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined>;
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
109
|
* Gets a block header by its archive root.
|
|
@@ -123,7 +124,7 @@ export interface L2BlockSource {
|
|
|
123
124
|
* @param blockHash - The block hash to retrieve.
|
|
124
125
|
* @returns The requested L2 block (or undefined if not found).
|
|
125
126
|
*/
|
|
126
|
-
getL2BlockByHash(blockHash:
|
|
127
|
+
getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* Gets an L2 block by its archive root.
|
|
@@ -228,7 +229,7 @@ export interface L2BlockSource {
|
|
|
228
229
|
* @param blockHash - The block hash to retrieve.
|
|
229
230
|
* @returns The requested block (or undefined if not found).
|
|
230
231
|
*/
|
|
231
|
-
getCheckpointedBlockByHash(blockHash:
|
|
232
|
+
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined>;
|
|
232
233
|
|
|
233
234
|
/**
|
|
234
235
|
* Gets a checkpointed block by its archive root.
|
|
@@ -87,5 +87,5 @@ export async function computeInitializationHashFromEncodedArgs(
|
|
|
87
87
|
encodedArgs: Fr[],
|
|
88
88
|
): Promise<Fr> {
|
|
89
89
|
const argsHash = await computeVarArgsHash(encodedArgs);
|
|
90
|
-
return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.
|
|
90
|
+
return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.INITIALIZER);
|
|
91
91
|
}
|
|
@@ -13,7 +13,7 @@ import { computePrivateFunctionsRoot } from './private_function.js';
|
|
|
13
13
|
*
|
|
14
14
|
* ```
|
|
15
15
|
* version = 1
|
|
16
|
-
* private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash],
|
|
16
|
+
* private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF))
|
|
17
17
|
* private_functions_root = merkleize(private_function_leaves)
|
|
18
18
|
* bytecode_commitment = calculate_commitment(packed_bytecode)
|
|
19
19
|
* contract_class_id = pedersen([version, artifact_hash, private_functions_root, bytecode_commitment], GENERATOR__CLASS_IDENTIFIER)
|
|
@@ -31,7 +31,7 @@ function computePrivateFunctionLeaves(fns: PrivateFunction[]): Promise<Buffer[]>
|
|
|
31
31
|
|
|
32
32
|
/** Returns the leaf for a given private function. */
|
|
33
33
|
export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<Buffer> {
|
|
34
|
-
return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.
|
|
34
|
+
return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.PRIVATE_FUNCTION_LEAF)).toBuffer();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
|
|
@@ -99,7 +99,7 @@ export async function createPrivateFunctionMembershipProof(
|
|
|
99
99
|
* contract_class = db.get_contract_class(contract_class_id)
|
|
100
100
|
*
|
|
101
101
|
* // Compute function leaf and assert it belongs to the private functions tree
|
|
102
|
-
* function_leaf = pedersen([selector as Field, vk_hash],
|
|
102
|
+
* function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
|
|
103
103
|
* computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
|
|
104
104
|
* assert computed_private_function_tree_root == contract_class.private_functions_root
|
|
105
105
|
*
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
|
+
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Symbol for Node.js custom inspect. Using Symbol.for() is the documented way to
|
|
8
|
+
* reference this without importing node:util. In browsers, objects with this symbol
|
|
9
|
+
* simply won't have custom inspect behavior (which is fine).
|
|
10
|
+
* @see https://nodejs.org/api/util.html#utilinspectcustom
|
|
11
|
+
*/
|
|
12
|
+
const inspectCustomSymbol = Symbol.for('nodejs.util.inspect.custom');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents a version record for storing in a version file.
|
|
16
|
+
*/
|
|
17
|
+
export class DatabaseVersion {
|
|
18
|
+
constructor(
|
|
19
|
+
/** The version of the data on disk. Used to perform upgrades */
|
|
20
|
+
public readonly schemaVersion: number,
|
|
21
|
+
/** The rollup the data pertains to */
|
|
22
|
+
public readonly rollupAddress: EthAddress,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
public toBuffer(): Buffer {
|
|
26
|
+
return Buffer.from(jsonStringify(this));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static fromBuffer(buf: Buffer): DatabaseVersion {
|
|
30
|
+
try {
|
|
31
|
+
return jsonParseWithSchema(buf.toString('utf-8'), DatabaseVersion.schema);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
throw new Error(`Failed to deserialize version information: ${err}`, { cause: err });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Compares two versions. If the rollups addresses are different then it returns undefined
|
|
39
|
+
*/
|
|
40
|
+
public cmp(other: DatabaseVersion): undefined | -1 | 0 | 1 {
|
|
41
|
+
if (this.rollupAddress.equals(other.rollupAddress)) {
|
|
42
|
+
if (this.schemaVersion < other.schemaVersion) {
|
|
43
|
+
return -1;
|
|
44
|
+
} else if (this.schemaVersion > other.schemaVersion) {
|
|
45
|
+
return 1;
|
|
46
|
+
} else {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Checks if two versions exactly match
|
|
55
|
+
*/
|
|
56
|
+
public equals(other: DatabaseVersion): boolean {
|
|
57
|
+
return this.cmp(other) === 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the schema for this class
|
|
62
|
+
*/
|
|
63
|
+
static get schema() {
|
|
64
|
+
return z
|
|
65
|
+
.object({
|
|
66
|
+
schemaVersion: z.number(),
|
|
67
|
+
rollupAddress: EthAddress.schema,
|
|
68
|
+
})
|
|
69
|
+
.transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Allows for better introspection in Node.js console. Ignored in browser envs. */
|
|
73
|
+
public [inspectCustomSymbol](): string {
|
|
74
|
+
return this.toString();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public toString(): string {
|
|
78
|
+
return `DatabaseVersion{schemaVersion=${this.schemaVersion},rollupAddress=${this.rollupAddress}"}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns an empty instance
|
|
83
|
+
*/
|
|
84
|
+
static empty() {
|
|
85
|
+
return new DatabaseVersion(0, EthAddress.ZERO);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,86 +1,10 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
3
|
|
|
5
4
|
import fs from 'fs/promises';
|
|
6
|
-
import { inspect } from 'node:util';
|
|
7
5
|
import { join } from 'path';
|
|
8
|
-
import { z } from 'zod';
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
* Represents a version record for storing in a version file.
|
|
12
|
-
*/
|
|
13
|
-
export class DatabaseVersion {
|
|
14
|
-
constructor(
|
|
15
|
-
/** The version of the data on disk. Used to perform upgrades */
|
|
16
|
-
public readonly schemaVersion: number,
|
|
17
|
-
/** The rollup the data pertains to */
|
|
18
|
-
public readonly rollupAddress: EthAddress,
|
|
19
|
-
) {}
|
|
20
|
-
|
|
21
|
-
public toBuffer(): Buffer {
|
|
22
|
-
return Buffer.from(jsonStringify(this));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static fromBuffer(buf: Buffer): DatabaseVersion {
|
|
26
|
-
try {
|
|
27
|
-
return jsonParseWithSchema(buf.toString('utf-8'), DatabaseVersion.schema);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
throw new Error(`Failed to deserialize version information: ${err}`, { cause: err });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Compares two versions. If the rollups addresses are different then it returns undefined
|
|
35
|
-
*/
|
|
36
|
-
public cmp(other: DatabaseVersion): undefined | -1 | 0 | 1 {
|
|
37
|
-
if (this.rollupAddress.equals(other.rollupAddress)) {
|
|
38
|
-
if (this.schemaVersion < other.schemaVersion) {
|
|
39
|
-
return -1;
|
|
40
|
-
} else if (this.schemaVersion > other.schemaVersion) {
|
|
41
|
-
return 1;
|
|
42
|
-
} else {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Checks if two versions exactly match
|
|
51
|
-
*/
|
|
52
|
-
public equals(other: DatabaseVersion): boolean {
|
|
53
|
-
return this.cmp(other) === 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns the schema for this class
|
|
58
|
-
*/
|
|
59
|
-
static get schema() {
|
|
60
|
-
return z
|
|
61
|
-
.object({
|
|
62
|
-
schemaVersion: z.number(),
|
|
63
|
-
rollupAddress: EthAddress.schema,
|
|
64
|
-
})
|
|
65
|
-
.transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Allows for better introspection. */
|
|
69
|
-
public [inspect.custom](): string {
|
|
70
|
-
return this.toString();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public toString(): string {
|
|
74
|
-
return `DatabaseVersion{schemaVersion=${this.schemaVersion},rollupAddress=${this.rollupAddress}"}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns an empty instance
|
|
79
|
-
*/
|
|
80
|
-
static empty() {
|
|
81
|
-
return new DatabaseVersion(0, EthAddress.ZERO);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
7
|
+
import { DatabaseVersion } from './database_version.js';
|
|
84
8
|
|
|
85
9
|
export type DatabaseVersionManagerFs = Pick<typeof fs, 'readFile' | 'writeFile' | 'rm' | 'mkdir'>;
|
|
86
10
|
|
|
@@ -51,6 +51,15 @@ export function getSlotAtTimestamp(
|
|
|
51
51
|
: SlotNumber.fromBigInt((ts - constants.l1GenesisTime) / BigInt(constants.slotDuration));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** Returns the L2 slot number at the next L1 block based on the current timestamp. */
|
|
55
|
+
export function getSlotAtNextL1Block(
|
|
56
|
+
currentL1Timestamp: bigint,
|
|
57
|
+
constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'ethereumSlotDuration'>,
|
|
58
|
+
): SlotNumber {
|
|
59
|
+
const nextL1BlockTimestamp = currentL1Timestamp + BigInt(constants.ethereumSlotDuration);
|
|
60
|
+
return getSlotAtTimestamp(nextL1BlockTimestamp, constants);
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
/** Returns the epoch number for a given timestamp. */
|
|
55
64
|
export function getEpochNumberAtTimestamp(
|
|
56
65
|
ts: bigint,
|
package/src/hash/hash.ts
CHANGED
|
@@ -55,7 +55,7 @@ export function computeUniqueNoteHash(noteNonce: Fr, siloedNoteHash: Fr): Promis
|
|
|
55
55
|
* @returns A siloed nullifier.
|
|
56
56
|
*/
|
|
57
57
|
export function siloNullifier(contract: AztecAddress, innerNullifier: Fr): Promise<Fr> {
|
|
58
|
-
return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.
|
|
58
|
+
return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.SILOED_NULLIFIER);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -87,7 +87,7 @@ export function computePublicDataTreeValue(value: Fr): Fr {
|
|
|
87
87
|
|
|
88
88
|
*/
|
|
89
89
|
export function computePublicDataTreeLeafSlot(contractAddress: AztecAddress, storageSlot: Fr): Promise<Fr> {
|
|
90
|
-
return poseidon2HashWithSeparator([contractAddress, storageSlot], GeneratorIndex.
|
|
90
|
+
return poseidon2HashWithSeparator([contractAddress, storageSlot], GeneratorIndex.PUBLIC_LEAF_SLOT);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
package/src/hash/map_slot.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
2
3
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -14,5 +15,5 @@ export function deriveStorageSlotInMap(
|
|
|
14
15
|
toField: () => Fr;
|
|
15
16
|
},
|
|
16
17
|
): Promise<Fr> {
|
|
17
|
-
return
|
|
18
|
+
return poseidon2HashWithSeparator([mapSlot, key.toField()], GeneratorIndex.PUBLIC_STORAGE_MAP_SLOT);
|
|
18
19
|
}
|
|
@@ -4,6 +4,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
7
8
|
import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
|
|
8
9
|
import { L2Block } from '../block/l2_block.js';
|
|
9
10
|
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
@@ -99,12 +100,12 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
99
100
|
.function()
|
|
100
101
|
.args(CheckpointNumberSchema, schemas.Integer)
|
|
101
102
|
.returns(z.array(PublishedCheckpoint.schema)),
|
|
102
|
-
getCheckpointedBlockByHash: z.function().args(
|
|
103
|
+
getCheckpointedBlockByHash: z.function().args(BlockHash.schema).returns(CheckpointedL2Block.schema.optional()),
|
|
103
104
|
getCheckpointedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
|
|
104
|
-
getBlockHeaderByHash: z.function().args(
|
|
105
|
+
getBlockHeaderByHash: z.function().args(BlockHash.schema).returns(BlockHeader.schema.optional()),
|
|
105
106
|
getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
106
107
|
getL2Block: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
|
|
107
|
-
getL2BlockByHash: z.function().args(
|
|
108
|
+
getL2BlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
|
|
108
109
|
getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
|
|
109
110
|
getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
|
|
110
111
|
getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
|
|
@@ -52,7 +52,8 @@ export interface AztecNodeAdmin {
|
|
|
52
52
|
getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]>;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// L1 contracts are not mutable via admin updates.
|
|
56
|
+
export type AztecNodeAdminConfig = Omit<ValidatorClientFullConfig, 'l1Contracts'> &
|
|
56
57
|
SequencerConfig &
|
|
57
58
|
ProverConfig &
|
|
58
59
|
SlasherConfig &
|
|
@@ -65,7 +66,7 @@ export type AztecNodeAdminConfig = ValidatorClientFullConfig &
|
|
|
65
66
|
|
|
66
67
|
export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConfigSchema)
|
|
67
68
|
.merge(SlasherConfigSchema)
|
|
68
|
-
.merge(ValidatorClientFullConfigSchema)
|
|
69
|
+
.merge(ValidatorClientFullConfigSchema.omit({ l1Contracts: true }))
|
|
69
70
|
.merge(
|
|
70
71
|
ArchiverSpecificConfigSchema.pick({
|
|
71
72
|
archiverPollingIntervalMS: true,
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ARCHIVE_HEIGHT,
|
|
3
|
-
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
4
|
-
NOTE_HASH_TREE_HEIGHT,
|
|
5
|
-
NULLIFIER_TREE_HEIGHT,
|
|
6
|
-
PUBLIC_DATA_TREE_HEIGHT,
|
|
7
|
-
} from '@aztec/constants';
|
|
1
|
+
import { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
8
2
|
import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum/l1-contract-addresses';
|
|
9
3
|
import {
|
|
10
4
|
BlockNumber,
|
|
@@ -93,63 +87,31 @@ export interface AztecNode
|
|
|
93
87
|
/**
|
|
94
88
|
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
95
89
|
* the leaves were inserted.
|
|
96
|
-
* @param
|
|
90
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
97
91
|
* @param treeId - The tree to search in.
|
|
98
92
|
* @param leafValues - The values to search for.
|
|
99
93
|
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
100
94
|
*/
|
|
101
95
|
findLeavesIndexes(
|
|
102
|
-
|
|
96
|
+
referenceBlock: BlockParameter,
|
|
103
97
|
treeId: MerkleTreeId,
|
|
104
98
|
leafValues: Fr[],
|
|
105
99
|
): Promise<(DataInBlock<bigint> | undefined)[]>;
|
|
106
100
|
|
|
107
|
-
/**
|
|
108
|
-
* Returns a sibling path for the given index in the nullifier tree.
|
|
109
|
-
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
110
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
111
|
-
* @returns The sibling path for the leaf index.
|
|
112
|
-
*/
|
|
113
|
-
getNullifierSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Returns a sibling path for the given index in the note hash tree.
|
|
117
|
-
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
118
|
-
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
119
|
-
* @returns The sibling path for the leaf index.
|
|
120
|
-
*/
|
|
121
|
-
getNoteHashSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Returns a sibling path for a leaf in the committed historic blocks tree.
|
|
125
|
-
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
126
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
127
|
-
* @returns The sibling path.
|
|
128
|
-
*/
|
|
129
|
-
getArchiveSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns a sibling path for a leaf in the committed public data tree.
|
|
133
|
-
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
134
|
-
* @param leafIndex - Index of the leaf in the tree.
|
|
135
|
-
* @returns The sibling path.
|
|
136
|
-
*/
|
|
137
|
-
getPublicDataSiblingPath(
|
|
138
|
-
block: BlockParameter,
|
|
139
|
-
leafIndex: bigint,
|
|
140
|
-
): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>>;
|
|
141
|
-
|
|
142
101
|
/**
|
|
143
102
|
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
144
|
-
* @param
|
|
103
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
145
104
|
* @param nullifier - Nullifier we try to find witness for.
|
|
146
105
|
* @returns The nullifier membership witness (if found).
|
|
147
106
|
*/
|
|
148
|
-
getNullifierMembershipWitness(
|
|
107
|
+
getNullifierMembershipWitness(
|
|
108
|
+
referenceBlock: BlockParameter,
|
|
109
|
+
nullifier: Fr,
|
|
110
|
+
): Promise<NullifierMembershipWitness | undefined>;
|
|
149
111
|
|
|
150
112
|
/**
|
|
151
113
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
152
|
-
* @param
|
|
114
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
153
115
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
154
116
|
* @returns The low nullifier membership witness (if found).
|
|
155
117
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -157,49 +119,56 @@ export interface AztecNode
|
|
|
157
119
|
* we are trying to prove non-inclusion for.
|
|
158
120
|
*/
|
|
159
121
|
getLowNullifierMembershipWitness(
|
|
160
|
-
|
|
122
|
+
referenceBlock: BlockParameter,
|
|
161
123
|
nullifier: Fr,
|
|
162
124
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
163
125
|
|
|
164
126
|
/**
|
|
165
127
|
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
166
|
-
* @param
|
|
128
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
167
129
|
* @param leafSlot - The leaf slot we try to find the witness for.
|
|
168
130
|
* @returns The public data witness (if found).
|
|
169
131
|
* @remarks The witness can be used to compute the current value of the public data tree leaf. If the low leaf preimage corresponds to an
|
|
170
132
|
* "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
|
|
171
133
|
* is contained in the leaf preimage.
|
|
172
134
|
*/
|
|
173
|
-
getPublicDataWitness(
|
|
135
|
+
getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
174
136
|
|
|
175
137
|
/**
|
|
176
|
-
* Returns a membership witness for a given
|
|
177
|
-
*
|
|
178
|
-
*
|
|
138
|
+
* Returns a membership witness for a given block hash in the archive tree.
|
|
139
|
+
*
|
|
140
|
+
* Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
|
|
141
|
+
* its block hash is appended as a new leaf to the archive tree. This method finds the membership
|
|
142
|
+
* witness (leaf index and sibling path) for a given block hash, which can be used to prove that
|
|
143
|
+
* a specific block exists in the chain's history.
|
|
144
|
+
*
|
|
145
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
146
|
+
* (which contains the root of the archive tree in which we are searching for the block hash).
|
|
147
|
+
* @param blockHash - The block hash to find in the archive tree.
|
|
179
148
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
149
|
+
getBlockHashMembershipWitness(
|
|
150
|
+
referenceBlock: BlockParameter,
|
|
151
|
+
blockHash: BlockHash,
|
|
183
152
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
|
|
184
153
|
|
|
185
154
|
/**
|
|
186
155
|
* Returns a membership witness for a given note hash at a given block.
|
|
187
|
-
* @param
|
|
156
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
188
157
|
* @param noteHash - The note hash we try to find the witness for.
|
|
189
158
|
*/
|
|
190
159
|
getNoteHashMembershipWitness(
|
|
191
|
-
|
|
160
|
+
referenceBlock: BlockParameter,
|
|
192
161
|
noteHash: Fr,
|
|
193
162
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
194
163
|
|
|
195
164
|
/**
|
|
196
165
|
* Returns the index and a sibling path for a leaf in the committed l1 to l2 data tree.
|
|
197
|
-
* @param
|
|
166
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
198
167
|
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
199
168
|
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
200
169
|
*/
|
|
201
170
|
getL1ToL2MessageMembershipWitness(
|
|
202
|
-
|
|
171
|
+
referenceBlock: BlockParameter,
|
|
203
172
|
l1ToL2Message: Fr,
|
|
204
173
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
|
|
205
174
|
|
|
@@ -224,17 +193,17 @@ export interface AztecNode
|
|
|
224
193
|
|
|
225
194
|
/**
|
|
226
195
|
* Get a block specified by its block number or 'latest'.
|
|
227
|
-
* @param
|
|
196
|
+
* @param blockParameter - The block parameter (block number, block hash, or 'latest').
|
|
228
197
|
* @returns The requested block.
|
|
229
198
|
*/
|
|
230
|
-
getBlock(
|
|
199
|
+
getBlock(blockParameter: BlockParameter): Promise<L2Block | undefined>;
|
|
231
200
|
|
|
232
201
|
/**
|
|
233
202
|
* Get a block specified by its hash.
|
|
234
203
|
* @param blockHash - The block hash being requested.
|
|
235
204
|
* @returns The requested block.
|
|
236
205
|
*/
|
|
237
|
-
getBlockByHash(blockHash:
|
|
206
|
+
getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
|
|
238
207
|
|
|
239
208
|
/**
|
|
240
209
|
* Get a block specified by its archive root.
|
|
@@ -433,12 +402,12 @@ export interface AztecNode
|
|
|
433
402
|
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
434
403
|
* Aztec's version of `eth_getStorageAt`.
|
|
435
404
|
*
|
|
436
|
-
* @param
|
|
405
|
+
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
437
406
|
* @param contract - Address of the contract to query.
|
|
438
407
|
* @param slot - Slot to query.
|
|
439
408
|
* @returns Storage value at the given contract slot.
|
|
440
409
|
*/
|
|
441
|
-
getPublicStorageAt(
|
|
410
|
+
getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
442
411
|
|
|
443
412
|
/**
|
|
444
413
|
* Returns the block header for a given block number, block hash, or 'latest'.
|
|
@@ -518,26 +487,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
518
487
|
.args(BlockParameterSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.Fr).max(MAX_RPC_LEN))
|
|
519
488
|
.returns(z.array(optional(dataInBlockSchemaFor(schemas.BigInt)))),
|
|
520
489
|
|
|
521
|
-
getNullifierSiblingPath: z
|
|
522
|
-
.function()
|
|
523
|
-
.args(BlockParameterSchema, schemas.BigInt)
|
|
524
|
-
.returns(SiblingPath.schemaFor(NULLIFIER_TREE_HEIGHT)),
|
|
525
|
-
|
|
526
|
-
getNoteHashSiblingPath: z
|
|
527
|
-
.function()
|
|
528
|
-
.args(BlockParameterSchema, schemas.BigInt)
|
|
529
|
-
.returns(SiblingPath.schemaFor(NOTE_HASH_TREE_HEIGHT)),
|
|
530
|
-
|
|
531
|
-
getArchiveSiblingPath: z
|
|
532
|
-
.function()
|
|
533
|
-
.args(BlockParameterSchema, schemas.BigInt)
|
|
534
|
-
.returns(SiblingPath.schemaFor(ARCHIVE_HEIGHT)),
|
|
535
|
-
|
|
536
|
-
getPublicDataSiblingPath: z
|
|
537
|
-
.function()
|
|
538
|
-
.args(BlockParameterSchema, schemas.BigInt)
|
|
539
|
-
.returns(SiblingPath.schemaFor(PUBLIC_DATA_TREE_HEIGHT)),
|
|
540
|
-
|
|
541
490
|
getNullifierMembershipWitness: z
|
|
542
491
|
.function()
|
|
543
492
|
.args(BlockParameterSchema, schemas.Fr)
|
|
@@ -553,9 +502,9 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
553
502
|
.args(BlockParameterSchema, schemas.Fr)
|
|
554
503
|
.returns(PublicDataWitness.schema.optional()),
|
|
555
504
|
|
|
556
|
-
|
|
505
|
+
getBlockHashMembershipWitness: z
|
|
557
506
|
.function()
|
|
558
|
-
.args(BlockParameterSchema,
|
|
507
|
+
.args(BlockParameterSchema, BlockHash.schema)
|
|
559
508
|
.returns(MembershipWitness.schemaFor(ARCHIVE_HEIGHT).optional()),
|
|
560
509
|
|
|
561
510
|
getNoteHashMembershipWitness: z
|
|
@@ -579,7 +528,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
579
528
|
|
|
580
529
|
getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
|
|
581
530
|
|
|
582
|
-
getBlockByHash: z.function().args(
|
|
531
|
+
getBlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
|
|
583
532
|
|
|
584
533
|
getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
|
|
585
534
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
3
4
|
|
|
4
5
|
import type { L2Block } from '../block/l2_block.js';
|
|
5
6
|
import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
|
|
@@ -61,8 +62,16 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
|
|
|
61
62
|
'fakeThrowAfterProcessingTxCount',
|
|
62
63
|
] as const;
|
|
63
64
|
|
|
65
|
+
/** Thrown when no valid transactions are available to include in a block after processing, and this is not the first block in a checkpoint. */
|
|
66
|
+
export class NoValidTxsError extends Error {
|
|
67
|
+
constructor(public readonly failedTxs: FailedTx[]) {
|
|
68
|
+
super('No valid transactions to include in block');
|
|
69
|
+
this.name = 'NoValidTxsError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
/** Result of building a block within a checkpoint. */
|
|
65
|
-
export
|
|
74
|
+
export type BuildBlockInCheckpointResult = {
|
|
66
75
|
block: L2Block;
|
|
67
76
|
publicGas: Gas;
|
|
68
77
|
publicProcessorDuration: number;
|
|
@@ -70,7 +79,7 @@ export interface BuildBlockInCheckpointResult {
|
|
|
70
79
|
failedTxs: FailedTx[];
|
|
71
80
|
usedTxs: Tx[];
|
|
72
81
|
usedTxBlobFields: number;
|
|
73
|
-
}
|
|
82
|
+
};
|
|
74
83
|
|
|
75
84
|
/** Interface for building blocks within a checkpoint context. */
|
|
76
85
|
export interface ICheckpointBlockBuilder {
|
|
@@ -92,5 +101,6 @@ export interface ICheckpointsBuilder {
|
|
|
92
101
|
l1ToL2Messages: Fr[],
|
|
93
102
|
previousCheckpointOutHashes: Fr[],
|
|
94
103
|
fork: MerkleTreeWriteOperations,
|
|
104
|
+
bindings?: LoggerBindings,
|
|
95
105
|
): Promise<ICheckpointBlockBuilder>;
|
|
96
106
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
1
3
|
import type { ProvingRequestType } from '../proofs/proving_request_type.js';
|
|
2
4
|
import type { ProofUri, ProvingJob, ProvingJobId, ProvingJobStatus } from './proving-job.js';
|
|
3
5
|
|
|
@@ -88,3 +90,23 @@ export interface ProvingJobConsumer {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export interface ProvingJobBroker extends ProvingJobProducer, ProvingJobConsumer {}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Debug interface for replaying proving jobs from stored inputs.
|
|
96
|
+
* Used for benchmarking different agent configurations against the same workload.
|
|
97
|
+
*/
|
|
98
|
+
export interface ProvingJobBrokerDebug {
|
|
99
|
+
/**
|
|
100
|
+
* Replays a proving job by re-enqueuing it with inputs from the configured proof store.
|
|
101
|
+
* The proof type is parsed from the job ID (format: epoch:typeName:hash).
|
|
102
|
+
* @param jobId - The original job ID to replay
|
|
103
|
+
* @param epochNumber - The epoch number to assign
|
|
104
|
+
* @param inputsUri - The proof inputs location
|
|
105
|
+
*/
|
|
106
|
+
replayProvingJob(
|
|
107
|
+
jobId: ProvingJobId,
|
|
108
|
+
type: ProvingRequestType,
|
|
109
|
+
epochNumber: EpochNumber,
|
|
110
|
+
inputsUri: ProofUri,
|
|
111
|
+
): Promise<ProvingJobStatus>;
|
|
112
|
+
}
|