@aztec/stdlib 5.0.0-nightly.20260413 → 5.0.0-nightly.20260415
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/authorization_selector.d.ts +3 -6
- package/dest/abi/authorization_selector.d.ts.map +1 -1
- package/dest/abi/event_selector.d.ts +3 -6
- package/dest/abi/event_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.d.ts +3 -6
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +1 -3
- package/dest/abi/note_selector.d.ts +3 -6
- package/dest/abi/note_selector.d.ts.map +1 -1
- package/dest/abi/note_selector.js +1 -3
- package/dest/aztec-address/index.d.ts +3 -6
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +2 -4
- package/dest/block/block_data.d.ts +8 -8
- package/dest/block/block_data.d.ts.map +1 -1
- package/dest/block/block_data.js +2 -2
- package/dest/block/block_hash.d.ts +11 -10
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +10 -9
- package/dest/block/l2_block_info.d.ts +6 -5
- package/dest/block/l2_block_info.d.ts.map +1 -1
- package/dest/block/l2_block_info.js +6 -5
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +1 -1
- package/dest/config/chain-config.d.ts +1 -1
- package/dest/config/chain-config.d.ts.map +1 -1
- package/dest/config/chain-config.js +7 -1
- package/dest/config/sequencer-config.js +4 -4
- package/dest/ha-signing/index.d.ts +2 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +1 -1
- package/dest/ha-signing/local_config.js +1 -1
- package/dest/ha-signing/types.d.ts +37 -32
- package/dest/ha-signing/types.d.ts.map +1 -1
- package/dest/ha-signing/types.js +13 -6
- package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +1 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +0 -3
- package/dest/interfaces/validator.d.ts +7 -7
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/logs/log_id.d.ts +1 -1
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +1 -2
- package/dest/logs/siloed_tag.d.ts +5 -7
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +4 -0
- package/dest/logs/tag.d.ts +5 -6
- package/dest/logs/tag.d.ts.map +1 -1
- package/dest/logs/tag.js +4 -0
- package/dest/p2p/block_proposal.d.ts +6 -8
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +4 -9
- package/dest/p2p/checkpoint_attestation.d.ts +4 -6
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_attestation.js +2 -7
- package/dest/p2p/checkpoint_proposal.d.ts +8 -10
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +4 -11
- package/dest/p2p/gossipable.d.ts +4 -4
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -2
- package/dest/tx/block_header.d.ts +2 -2
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +1 -1
- package/dest/tx/indexed_tx_effect.d.ts +1 -1
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +1 -2
- package/dest/tx/tx.d.ts +3 -3
- package/dest/tx/tx.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/abi/authorization_selector.ts +2 -8
- package/src/abi/event_selector.ts +2 -8
- package/src/abi/function_selector.ts +3 -12
- package/src/abi/note_selector.ts +3 -12
- package/src/aztec-address/index.ts +4 -10
- package/src/block/block_data.ts +3 -4
- package/src/block/block_hash.ts +21 -14
- package/src/block/l2_block_info.ts +8 -6
- package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
- package/src/block/test/l2_tips_store_test_suite.ts +1 -1
- package/src/config/chain-config.ts +7 -1
- package/src/config/sequencer-config.ts +4 -4
- package/src/ha-signing/index.ts +3 -1
- package/src/ha-signing/local_config.ts +1 -1
- package/src/ha-signing/types.ts +48 -34
- package/src/interfaces/merkle_tree_operations.ts +3 -2
- package/src/interfaces/prover-client.ts +2 -5
- package/src/interfaces/validator.ts +14 -4
- package/src/logs/log_id.ts +1 -2
- package/src/logs/siloed_tag.ts +8 -9
- package/src/logs/tag.ts +8 -8
- package/src/p2p/block_proposal.ts +13 -9
- package/src/p2p/checkpoint_attestation.ts +5 -9
- package/src/p2p/checkpoint_proposal.ts +12 -11
- package/src/p2p/gossipable.ts +4 -4
- package/src/tests/mocks.ts +2 -0
- package/src/tx/block_header.ts +2 -2
- package/src/tx/indexed_tx_effect.ts +1 -2
- package/src/tx/tx.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "5.0.0-nightly.
|
|
3
|
+
"version": "5.0.0-nightly.20260415",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
95
|
-
"@aztec/bb.js": "5.0.0-nightly.
|
|
96
|
-
"@aztec/blob-lib": "5.0.0-nightly.
|
|
97
|
-
"@aztec/constants": "5.0.0-nightly.
|
|
98
|
-
"@aztec/ethereum": "5.0.0-nightly.
|
|
99
|
-
"@aztec/foundation": "5.0.0-nightly.
|
|
100
|
-
"@aztec/l1-artifacts": "5.0.0-nightly.
|
|
101
|
-
"@aztec/noir-noirc_abi": "5.0.0-nightly.
|
|
95
|
+
"@aztec/bb.js": "5.0.0-nightly.20260415",
|
|
96
|
+
"@aztec/blob-lib": "5.0.0-nightly.20260415",
|
|
97
|
+
"@aztec/constants": "5.0.0-nightly.20260415",
|
|
98
|
+
"@aztec/ethereum": "5.0.0-nightly.20260415",
|
|
99
|
+
"@aztec/foundation": "5.0.0-nightly.20260415",
|
|
100
|
+
"@aztec/l1-artifacts": "5.0.0-nightly.20260415",
|
|
101
|
+
"@aztec/noir-noirc_abi": "5.0.0-nightly.20260415",
|
|
102
102
|
"@google-cloud/storage": "^7.15.0",
|
|
103
103
|
"axios": "^1.13.5",
|
|
104
104
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -7,18 +7,12 @@ import { BufferReader } from '@aztec/foundation/serialize';
|
|
|
7
7
|
|
|
8
8
|
import { Selector } from './selector.js';
|
|
9
9
|
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
11
|
-
|
|
12
|
-
/** Authorization selector branding */
|
|
13
|
-
export interface AuthorizationSelector {
|
|
14
|
-
/** Brand. */
|
|
15
|
-
_branding: 'AuthorizationSelector';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
/**
|
|
19
11
|
* An authorization selector is the first 4 bytes of the hash of an authorization struct signature.
|
|
20
12
|
*/
|
|
21
13
|
export class AuthorizationSelector extends Selector {
|
|
14
|
+
/** Branding for nominal typing. */
|
|
15
|
+
declare private readonly _branding: 'AuthorizationSelector';
|
|
22
16
|
/**
|
|
23
17
|
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
24
18
|
* @param buffer - Buffer or BufferReader to read from.
|
|
@@ -7,16 +7,10 @@ import { BufferReader } from '@aztec/foundation/serialize';
|
|
|
7
7
|
|
|
8
8
|
import { Selector } from './selector.js';
|
|
9
9
|
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
11
|
-
|
|
12
|
-
/** Event selector branding */
|
|
13
|
-
export interface EventSelector {
|
|
14
|
-
/** Brand. */
|
|
15
|
-
_branding: 'EventSelector';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
/** An event selector is the first 4 bytes of the hash of an event signature. */
|
|
19
11
|
export class EventSelector extends Selector {
|
|
12
|
+
/** Branding for nominal typing. */
|
|
13
|
+
declare private readonly _branding: 'EventSelector';
|
|
20
14
|
/**
|
|
21
15
|
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
22
16
|
* @param buffer - Buffer or BufferReader to read from.
|
|
@@ -3,22 +3,16 @@ import { poseidon2HashBytes } from '@aztec/foundation/crypto/poseidon';
|
|
|
3
3
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
4
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { type ZodFor, hexSchemaFor } from '@aztec/foundation/schemas';
|
|
6
|
-
import { BufferReader, FieldReader
|
|
6
|
+
import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
7
7
|
|
|
8
8
|
import type { ABIParameter } from './abi.js';
|
|
9
9
|
import { decodeFunctionSignature } from './function_signature_decoder.js';
|
|
10
10
|
import { Selector } from './selector.js';
|
|
11
11
|
|
|
12
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
13
|
-
|
|
14
|
-
/** Function selector branding */
|
|
15
|
-
export interface FunctionSelector {
|
|
16
|
-
/** Brand. */
|
|
17
|
-
_branding: 'FunctionSelector';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
/** A function selector is the first 4 bytes of the hash of a function signature. */
|
|
21
13
|
export class FunctionSelector extends Selector {
|
|
14
|
+
/** Branding for nominal typing. */
|
|
15
|
+
declare private readonly _branding: 'FunctionSelector';
|
|
22
16
|
/**
|
|
23
17
|
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
24
18
|
* @param buffer - Buffer or BufferReader to read from.
|
|
@@ -127,6 +121,3 @@ export class FunctionSelector extends Selector {
|
|
|
127
121
|
return hexSchemaFor(FunctionSelector);
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
|
-
|
|
131
|
-
// For deserializing JSON.
|
|
132
|
-
TypeRegistry.register('FunctionSelector', FunctionSelector);
|
package/src/abi/note_selector.ts
CHANGED
|
@@ -2,23 +2,17 @@ import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
|
2
2
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { hexSchemaFor } from '@aztec/foundation/schemas';
|
|
5
|
-
import { BufferReader
|
|
5
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
6
6
|
|
|
7
7
|
import { Selector } from './selector.js';
|
|
8
8
|
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
10
|
-
|
|
11
|
-
/** Note selector branding */
|
|
12
|
-
export interface NoteSelector {
|
|
13
|
-
/** Brand. */
|
|
14
|
-
_branding: 'NoteSelector';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
/**
|
|
18
10
|
* A note selector is a 7 bit long value that identifies a note type within a contract.
|
|
19
11
|
* TODO(#10952): Encoding of note type id can be reduced to 7 bits.
|
|
20
12
|
*/
|
|
21
13
|
export class NoteSelector extends Selector {
|
|
14
|
+
/** Branding for nominal typing. */
|
|
15
|
+
declare private readonly _branding: 'NoteSelector';
|
|
22
16
|
/**
|
|
23
17
|
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
24
18
|
* @param buffer - Buffer or BufferReader to read from.
|
|
@@ -73,6 +67,3 @@ export class NoteSelector extends Selector {
|
|
|
73
67
|
return hexSchemaFor(NoteSelector);
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
|
-
|
|
77
|
-
// For deserializing JSON.
|
|
78
|
-
TypeRegistry.register('NoteSelector', NoteSelector);
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
2
1
|
import { Fr, fromBuffer } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
3
|
import { type ZodFor, bufferSchemaFor, hexSchemaFor } from '@aztec/foundation/schemas';
|
|
5
|
-
import { type BufferReader, FieldReader
|
|
4
|
+
import { type BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
6
5
|
import { hexToBuffer } from '@aztec/foundation/string';
|
|
7
6
|
|
|
8
7
|
import { inspect } from 'util';
|
|
9
8
|
import { z } from 'zod';
|
|
10
9
|
|
|
11
|
-
/** Branding to ensure fields are not interchangeable types. */
|
|
12
|
-
export interface AztecAddress {
|
|
13
|
-
/** Brand. */
|
|
14
|
-
_branding: 'AztecAddress';
|
|
15
|
-
}
|
|
16
10
|
/**
|
|
17
11
|
* AztecAddress represents a 32-byte address in the Aztec Protocol. It provides methods to create, manipulate, and
|
|
18
12
|
* compare addresses, as well as conversion to and from strings, buffers, and other formats.
|
|
@@ -23,6 +17,9 @@ export interface AztecAddress {
|
|
|
23
17
|
* wild.
|
|
24
18
|
*/
|
|
25
19
|
export class AztecAddress {
|
|
20
|
+
/** Branding for nominal typing. */
|
|
21
|
+
declare private readonly _branding: 'AztecAddress';
|
|
22
|
+
|
|
26
23
|
private xCoord: Fr;
|
|
27
24
|
|
|
28
25
|
constructor(buffer: Buffer | Fr) {
|
|
@@ -165,6 +162,3 @@ export class AztecAddress {
|
|
|
165
162
|
]);
|
|
166
163
|
}
|
|
167
164
|
}
|
|
168
|
-
|
|
169
|
-
// For deserializing JSON.
|
|
170
|
-
TypeRegistry.register('AztecAddress', AztecAddress);
|
package/src/block/block_data.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { CheckpointNumberSchema, IndexWithinCheckpointSchema } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { schemas } from '@aztec/foundation/schemas';
|
|
5
3
|
|
|
6
4
|
import { z } from 'zod';
|
|
7
5
|
|
|
8
6
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
9
7
|
import { BlockHeader } from '../tx/block_header.js';
|
|
8
|
+
import { BlockHash } from './block_hash.js';
|
|
10
9
|
|
|
11
10
|
/** L2Block metadata. Equivalent to L2Block but without block body containing tx data. */
|
|
12
11
|
export type BlockData = {
|
|
13
12
|
header: BlockHeader;
|
|
14
13
|
archive: AppendOnlyTreeSnapshot;
|
|
15
|
-
blockHash:
|
|
14
|
+
blockHash: BlockHash;
|
|
16
15
|
checkpointNumber: CheckpointNumber;
|
|
17
16
|
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
18
17
|
};
|
|
@@ -20,7 +19,7 @@ export type BlockData = {
|
|
|
20
19
|
export const BlockDataSchema = z.object({
|
|
21
20
|
header: BlockHeader.schema,
|
|
22
21
|
archive: AppendOnlyTreeSnapshot.schema,
|
|
23
|
-
blockHash:
|
|
22
|
+
blockHash: BlockHash.schema,
|
|
24
23
|
checkpointNumber: CheckpointNumberSchema,
|
|
25
24
|
indexWithinCheckpoint: IndexWithinCheckpointSchema,
|
|
26
25
|
});
|
package/src/block/block_hash.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH as GENESIS_BLOCK_HEADER_HASH_FR } from '@aztec/constants';
|
|
2
|
+
import { BaseFr, Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
|
+
import type { BufferReader } from '@aztec/foundation/serialize';
|
|
3
5
|
|
|
4
6
|
import { inspect } from 'util';
|
|
5
7
|
|
|
6
8
|
import { hexSchemaFor } from '../schemas/schemas.js';
|
|
7
9
|
|
|
8
|
-
const BLOCK_HASH_BRAND = Symbol.for('aztec.BlockHash');
|
|
9
|
-
|
|
10
10
|
/** Hash of an L2 block. */
|
|
11
|
-
export class BlockHash extends
|
|
12
|
-
|
|
11
|
+
export class BlockHash extends BaseFr {
|
|
12
|
+
/** Branding for nominal typing. */
|
|
13
|
+
declare private readonly _branding: 'BlockHash';
|
|
14
|
+
|
|
15
|
+
static ZERO = new BlockHash(Fr.ZERO);
|
|
13
16
|
|
|
14
17
|
constructor(hash: Fr) {
|
|
15
18
|
super(hash);
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
[inspect.custom]() {
|
|
19
22
|
return `BlockHash<${this.toString()}>`;
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -23,23 +26,27 @@ export class BlockHash extends Fr {
|
|
|
23
26
|
return new Fr(this.toBigInt());
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
/**
|
|
27
|
-
* Type guard that checks if a value is a BlockHash instance.
|
|
28
|
-
* Uses Symbol.for to ensure cross-module compatibility.
|
|
29
|
-
*/
|
|
29
|
+
/** Type guard that checks if a value is a BlockHash instance. */
|
|
30
30
|
static isBlockHash(value: unknown): value is BlockHash {
|
|
31
|
-
return
|
|
31
|
+
return value instanceof BlockHash;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
static
|
|
34
|
+
static random() {
|
|
35
35
|
return new BlockHash(Fr.random());
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
static
|
|
38
|
+
static fromBuffer(buffer: Buffer | BufferReader): BlockHash {
|
|
39
|
+
return new BlockHash(Fr.fromBuffer(buffer));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static fromString(str: string): BlockHash {
|
|
39
43
|
return new BlockHash(Fr.fromString(str));
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
static
|
|
46
|
+
static get schema() {
|
|
43
47
|
return hexSchemaFor(BlockHash) as ZodFor<BlockHash>;
|
|
44
48
|
}
|
|
45
49
|
}
|
|
50
|
+
|
|
51
|
+
/** The block header hash for the genesis block (block 0). */
|
|
52
|
+
export const GENESIS_BLOCK_HEADER_HASH: BlockHash = new BlockHash(GENESIS_BLOCK_HEADER_HASH_FR);
|
|
@@ -5,8 +5,10 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
+
import { BlockHash } from './block_hash.js';
|
|
9
|
+
|
|
8
10
|
export type L2BlockInfo = {
|
|
9
|
-
blockHash?:
|
|
11
|
+
blockHash?: BlockHash;
|
|
10
12
|
archive: Fr;
|
|
11
13
|
lastArchive: Fr;
|
|
12
14
|
blockNumber: BlockNumber;
|
|
@@ -17,7 +19,7 @@ export type L2BlockInfo = {
|
|
|
17
19
|
|
|
18
20
|
export function randomBlockInfo(blockNumber?: BlockNumber | number): L2BlockInfo {
|
|
19
21
|
return {
|
|
20
|
-
blockHash:
|
|
22
|
+
blockHash: BlockHash.random(),
|
|
21
23
|
archive: Fr.random(),
|
|
22
24
|
lastArchive: Fr.random(),
|
|
23
25
|
blockNumber: BlockNumber(blockNumber ?? Math.floor(Math.random() * 100000) + 1),
|
|
@@ -28,7 +30,7 @@ export function randomBlockInfo(blockNumber?: BlockNumber | number): L2BlockInfo
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export const BlockInfoSchema = z.object({
|
|
31
|
-
blockHash:
|
|
33
|
+
blockHash: BlockHash.schema.optional(),
|
|
32
34
|
archive: schemas.Fr,
|
|
33
35
|
lastArchive: schemas.Fr,
|
|
34
36
|
blockNumber: BlockNumberSchema,
|
|
@@ -39,7 +41,7 @@ export const BlockInfoSchema = z.object({
|
|
|
39
41
|
|
|
40
42
|
export function serializeBlockInfo(blockInfo: L2BlockInfo): Buffer {
|
|
41
43
|
return serializeToBuffer(
|
|
42
|
-
blockInfo.blockHash ??
|
|
44
|
+
blockInfo.blockHash ?? BlockHash.ZERO,
|
|
43
45
|
blockInfo.archive,
|
|
44
46
|
blockInfo.lastArchive,
|
|
45
47
|
blockInfo.blockNumber,
|
|
@@ -51,9 +53,9 @@ export function serializeBlockInfo(blockInfo: L2BlockInfo): Buffer {
|
|
|
51
53
|
|
|
52
54
|
export function deserializeBlockInfo(buffer: Buffer | BufferReader): L2BlockInfo {
|
|
53
55
|
const reader = BufferReader.asReader(buffer);
|
|
54
|
-
const blockHash =
|
|
56
|
+
const blockHash = BlockHash.fromBuffer(reader);
|
|
55
57
|
return {
|
|
56
|
-
blockHash: blockHash.equals(
|
|
58
|
+
blockHash: blockHash.equals(BlockHash.ZERO) ? undefined : blockHash,
|
|
57
59
|
archive: reader.readObject(Fr),
|
|
58
60
|
lastArchive: reader.readObject(Fr),
|
|
59
61
|
blockNumber: BlockNumber(reader.readNumber()),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
2
|
|
|
4
3
|
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
4
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '../block_hash.js';
|
|
5
5
|
import type { L2Block } from '../l2_block.js';
|
|
6
6
|
import {
|
|
7
7
|
type CheckpointId,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
2
|
import { times } from '@aztec/foundation/collection';
|
|
4
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -13,6 +12,7 @@ import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/
|
|
|
13
12
|
|
|
14
13
|
import { jestExpect as expect } from '@jest/expect';
|
|
15
14
|
|
|
15
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '../block_hash.js';
|
|
16
16
|
import type { L2TipsStore } from '../l2_block_stream/index.js';
|
|
17
17
|
|
|
18
18
|
export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
@@ -21,7 +21,13 @@ export const chainConfigMappings: ConfigMappingsType<ChainConfig> = {
|
|
|
21
21
|
rollupVersion: {
|
|
22
22
|
env: 'ROLLUP_VERSION',
|
|
23
23
|
description: 'The version of the rollup.',
|
|
24
|
-
parseEnv: (val: string) =>
|
|
24
|
+
parseEnv: (val: string) => {
|
|
25
|
+
const parsed = parseInt(val, 10);
|
|
26
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
27
|
+
throw new Error(`Invalid rollup version: ${val}`);
|
|
28
|
+
}
|
|
29
|
+
return parsed;
|
|
30
|
+
},
|
|
25
31
|
},
|
|
26
32
|
l1Contracts: {
|
|
27
33
|
description: 'The deployed L1 contract addresses',
|
|
@@ -23,25 +23,25 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
|
|
|
23
23
|
description:
|
|
24
24
|
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
25
25
|
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
26
|
-
parseEnv: (val: string) =>
|
|
26
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
27
27
|
},
|
|
28
28
|
expectedBlockProposalsPerSlot: {
|
|
29
29
|
env: 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT',
|
|
30
30
|
description:
|
|
31
31
|
'Expected number of block proposals per slot for P2P peer scoring. ' +
|
|
32
32
|
'0 (default) disables block proposal scoring. Set to a positive value to enable.',
|
|
33
|
-
parseEnv: (val: string) =>
|
|
33
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
34
34
|
defaultValue: 0,
|
|
35
35
|
},
|
|
36
36
|
maxTxsPerBlock: {
|
|
37
37
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
38
38
|
description: 'The maximum number of txs to include in a block.',
|
|
39
|
-
parseEnv: (val: string) =>
|
|
39
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
40
40
|
},
|
|
41
41
|
attestationPropagationTime: {
|
|
42
42
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
43
43
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way).',
|
|
44
|
-
parseEnv: (val: string) =>
|
|
44
|
+
parseEnv: (val: string) => parseFloat(val),
|
|
45
45
|
defaultValue: DEFAULT_P2P_PROPAGATION_TIME,
|
|
46
46
|
},
|
|
47
47
|
};
|
package/src/ha-signing/index.ts
CHANGED
|
@@ -16,12 +16,14 @@ export {
|
|
|
16
16
|
} from './local_config.js';
|
|
17
17
|
export {
|
|
18
18
|
DutyType,
|
|
19
|
+
type AttestationSigningContext,
|
|
19
20
|
type BlockProposalSigningContext,
|
|
21
|
+
type CheckpointProposalSigningContext,
|
|
20
22
|
type HAProtectedSigningContext,
|
|
21
23
|
type NoHAProtectionSigningContext,
|
|
22
|
-
type OtherSigningContext,
|
|
23
24
|
type SigningContext,
|
|
24
25
|
type VoteSigningContext,
|
|
25
26
|
getBlockNumberFromSigningContext,
|
|
27
|
+
getCheckpointNumberFromSigningContext,
|
|
26
28
|
isHAProtectedContext,
|
|
27
29
|
} from './types.js';
|
|
@@ -26,7 +26,7 @@ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> =
|
|
|
26
26
|
env: 'SIGNING_PROTECTION_MAP_SIZE_KB',
|
|
27
27
|
description:
|
|
28
28
|
'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
29
|
-
parseEnv: (val: string
|
|
29
|
+
parseEnv: (val: string) => +val,
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
|
package/src/ha-signing/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockNumber,
|
|
3
|
-
|
|
3
|
+
CheckpointNumber,
|
|
4
4
|
type IndexWithinCheckpoint,
|
|
5
5
|
type SlotNumber,
|
|
6
6
|
} from '@aztec/foundation/branded-types';
|
|
@@ -20,40 +20,40 @@ export enum DutyType {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Signing context for block proposals.
|
|
24
|
+
* Includes both the block number and the checkpoint number the block belongs to.
|
|
24
25
|
*/
|
|
25
|
-
interface
|
|
26
|
-
/** Slot number for this duty */
|
|
26
|
+
export interface BlockProposalSigningContext {
|
|
27
27
|
slot: SlotNumber;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
blockNumber: BlockNumber | CheckpointNumber;
|
|
28
|
+
blockNumber: BlockNumber;
|
|
29
|
+
checkpointNumber: CheckpointNumber;
|
|
30
|
+
/** Block index within checkpoint (0, 1, 2...). Required for block proposals. */
|
|
31
|
+
blockIndexWithinCheckpoint: IndexWithinCheckpoint;
|
|
32
|
+
dutyType: DutyType.BLOCK_PROPOSAL;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
|
-
* Signing context for
|
|
38
|
-
*
|
|
36
|
+
* Signing context for checkpoint proposals.
|
|
37
|
+
* Includes the checkpoint number being proposed, but not a block number.
|
|
39
38
|
*/
|
|
40
|
-
export interface
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
dutyType: DutyType.
|
|
39
|
+
export interface CheckpointProposalSigningContext {
|
|
40
|
+
slot: SlotNumber;
|
|
41
|
+
checkpointNumber: CheckpointNumber;
|
|
42
|
+
dutyType: DutyType.CHECKPOINT_PROPOSAL;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
* Signing context for
|
|
48
|
-
*
|
|
46
|
+
* Signing context for attestation duties (checkpoint attestations).
|
|
47
|
+
* Includes the checkpoint number when available (from proposal validation).
|
|
49
48
|
*/
|
|
50
|
-
export interface
|
|
51
|
-
|
|
49
|
+
export interface AttestationSigningContext {
|
|
50
|
+
slot: SlotNumber;
|
|
51
|
+
checkpointNumber: CheckpointNumber;
|
|
52
|
+
dutyType: DutyType.ATTESTATION | DutyType.ATTESTATIONS_AND_SIGNERS;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* Signing context for governance/slashing votes which only need slot for HA protection.
|
|
56
|
-
* blockNumber is not applicable (internally always 0).
|
|
57
57
|
*/
|
|
58
58
|
export interface VoteSigningContext {
|
|
59
59
|
slot: SlotNumber;
|
|
@@ -69,18 +69,23 @@ export interface NoHAProtectionSigningContext {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Signing contexts that require HA protection (excludes AUTH_REQUEST).
|
|
72
|
+
* Signing contexts that require HA protection (excludes AUTH_REQUEST and TXS).
|
|
73
73
|
* Used by the HA signer's signWithProtection method.
|
|
74
74
|
*/
|
|
75
|
-
export type HAProtectedSigningContext =
|
|
75
|
+
export type HAProtectedSigningContext =
|
|
76
|
+
| BlockProposalSigningContext
|
|
77
|
+
| CheckpointProposalSigningContext
|
|
78
|
+
| AttestationSigningContext
|
|
79
|
+
| VoteSigningContext;
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
82
|
* Context required for slashing protection during signing operations.
|
|
79
83
|
* Uses discriminated union to enforce type safety:
|
|
80
|
-
* - BLOCK_PROPOSAL duties
|
|
81
|
-
* -
|
|
82
|
-
* -
|
|
83
|
-
* -
|
|
84
|
+
* - BLOCK_PROPOSAL duties have blockNumber, checkpointNumber, and blockIndexWithinCheckpoint
|
|
85
|
+
* - CHECKPOINT_PROPOSAL duties have checkpointNumber
|
|
86
|
+
* - ATTESTATION/ATTESTATIONS_AND_SIGNERS duties have only slot
|
|
87
|
+
* - Vote duties have only slot
|
|
88
|
+
* - AUTH_REQUEST and TXS duties don't need HA protection
|
|
84
89
|
*/
|
|
85
90
|
export type SigningContext = HAProtectedSigningContext | NoHAProtectionSigningContext;
|
|
86
91
|
|
|
@@ -94,19 +99,28 @@ export function isHAProtectedContext(context: SigningContext): context is HAProt
|
|
|
94
99
|
|
|
95
100
|
/**
|
|
96
101
|
* Gets the block number from a signing context.
|
|
97
|
-
*
|
|
98
|
-
* - Other duties: returns the blockNumber from the context
|
|
102
|
+
* Only BLOCK_PROPOSAL duties carry a block number; all others return BlockNumber(0).
|
|
99
103
|
*/
|
|
100
|
-
export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber
|
|
101
|
-
|
|
104
|
+
export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber {
|
|
105
|
+
if (context.dutyType === DutyType.BLOCK_PROPOSAL) {
|
|
106
|
+
return context.blockNumber;
|
|
107
|
+
}
|
|
108
|
+
return BlockNumber(0);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Gets the checkpoint number from a signing context.
|
|
113
|
+
* BLOCK_PROPOSAL, CHECKPOINT_PROPOSAL, ATTESTATION, and ATTESTATIONS_AND_SIGNERS duties carry a checkpoint number;
|
|
114
|
+
* vote duties return CheckpointNumber(0).
|
|
115
|
+
*/
|
|
116
|
+
export function getCheckpointNumberFromSigningContext(context: HAProtectedSigningContext): CheckpointNumber {
|
|
102
117
|
if (
|
|
103
118
|
context.dutyType === DutyType.BLOCK_PROPOSAL ||
|
|
104
119
|
context.dutyType === DutyType.CHECKPOINT_PROPOSAL ||
|
|
105
120
|
context.dutyType === DutyType.ATTESTATION ||
|
|
106
121
|
context.dutyType === DutyType.ATTESTATIONS_AND_SIGNERS
|
|
107
122
|
) {
|
|
108
|
-
return context.
|
|
123
|
+
return context.checkpointNumber;
|
|
109
124
|
}
|
|
110
|
-
|
|
111
|
-
return BlockNumber(0);
|
|
125
|
+
return CheckpointNumber(0);
|
|
112
126
|
}
|
|
@@ -3,6 +3,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
|
+
import type { BlockHash } from '../block/block_hash.js';
|
|
6
7
|
import type { MerkleTreeId, TreeHeights } from '../trees/merkle_tree_id.js';
|
|
7
8
|
import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
|
|
8
9
|
import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
|
|
@@ -99,7 +100,7 @@ type LeafTypes = {
|
|
|
99
100
|
[MerkleTreeId.NOTE_HASH_TREE]: Fr;
|
|
100
101
|
[MerkleTreeId.PUBLIC_DATA_TREE]: Buffer;
|
|
101
102
|
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
|
|
102
|
-
[MerkleTreeId.ARCHIVE]:
|
|
103
|
+
[MerkleTreeId.ARCHIVE]: BlockHash;
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
type LeafValueTypes = {
|
|
@@ -107,7 +108,7 @@ type LeafValueTypes = {
|
|
|
107
108
|
[MerkleTreeId.NOTE_HASH_TREE]: Fr;
|
|
108
109
|
[MerkleTreeId.PUBLIC_DATA_TREE]: PublicDataTreeLeaf;
|
|
109
110
|
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
|
|
110
|
-
[MerkleTreeId.ARCHIVE]:
|
|
111
|
+
[MerkleTreeId.ARCHIVE]: BlockHash;
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
export type MerkleTreeLeafType<ID extends MerkleTreeId> = LeafTypes[ID];
|
|
@@ -71,7 +71,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
71
71
|
},
|
|
72
72
|
proverId: {
|
|
73
73
|
env: 'PROVER_ID',
|
|
74
|
-
parseEnv: (val
|
|
74
|
+
parseEnv: (val: string) => parseProverId(val),
|
|
75
75
|
description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
|
|
76
76
|
},
|
|
77
77
|
proverTestDelayType: {
|
|
@@ -117,10 +117,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
function parseProverId(str
|
|
121
|
-
if (!str) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
120
|
+
function parseProverId(str: string) {
|
|
124
121
|
return EthAddress.fromString(str);
|
|
125
122
|
}
|
|
126
123
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { SecretValue } from '@aztec/foundation/config';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -124,6 +124,7 @@ export interface Validator {
|
|
|
124
124
|
// Block validation responsibilities
|
|
125
125
|
createBlockProposal(
|
|
126
126
|
blockHeader: BlockHeader,
|
|
127
|
+
checkpointNumber: CheckpointNumber,
|
|
127
128
|
indexWithinCheckpoint: number,
|
|
128
129
|
inHash: Fr,
|
|
129
130
|
archive: Fr,
|
|
@@ -136,6 +137,7 @@ export interface Validator {
|
|
|
136
137
|
createCheckpointProposal(
|
|
137
138
|
checkpointHeader: CheckpointHeader,
|
|
138
139
|
archive: Fr,
|
|
140
|
+
checkpointNumber: CheckpointNumber,
|
|
139
141
|
feeAssetPriceModifier: bigint,
|
|
140
142
|
lastBlockProposal: BlockProposal | undefined,
|
|
141
143
|
proposerAddress: EthAddress | undefined,
|
|
@@ -161,15 +163,23 @@ export interface Validator {
|
|
|
161
163
|
broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
|
|
162
164
|
|
|
163
165
|
/** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
|
|
164
|
-
collectOwnAttestations(
|
|
166
|
+
collectOwnAttestations(
|
|
167
|
+
proposal: CheckpointProposal,
|
|
168
|
+
checkpointNumber: CheckpointNumber,
|
|
169
|
+
): Promise<CheckpointAttestation[]>;
|
|
165
170
|
|
|
166
171
|
/** Collect attestations from the p2p network for a checkpoint proposal */
|
|
167
|
-
collectAttestations(
|
|
172
|
+
collectAttestations(
|
|
173
|
+
proposal: CheckpointProposal,
|
|
174
|
+
required: number,
|
|
175
|
+
deadline: Date,
|
|
176
|
+
checkpointNumber: CheckpointNumber,
|
|
177
|
+
): Promise<CheckpointAttestation[]>;
|
|
168
178
|
|
|
169
179
|
signAttestationsAndSigners(
|
|
170
180
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
171
181
|
proposer: EthAddress,
|
|
172
182
|
slot: SlotNumber,
|
|
173
|
-
|
|
183
|
+
checkpointNumber: CheckpointNumber,
|
|
174
184
|
): Promise<Signature>;
|
|
175
185
|
}
|