@aztec/stdlib 0.0.1-commit.2ed92850 → 0.0.1-commit.54489865
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 +16 -19
- 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 +4 -4
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +2 -2
- package/dest/block/in_block.d.ts +9 -9
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/in_block.js +4 -4
- 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/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.d.ts +5 -5
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +4 -4
- package/dest/interfaces/block-builder.d.ts +3 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.d.ts +7 -7
- package/dest/interfaces/validator.d.ts +2 -2
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/logs/extended_public_log.d.ts +6 -6
- package/dest/logs/log_id.d.ts +8 -8
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +6 -5
- 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/p2p/block_proposal.d.ts +10 -3
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +10 -3
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/tests/mocks.d.ts +6 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +4 -3
- package/dest/tx/block_header.d.ts +3 -3
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +3 -3
- package/dest/tx/in_tx.d.ts +3 -3
- package/dest/tx/indexed_tx_effect.d.ts +5 -5
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +3 -2
- package/dest/tx/tx_receipt.d.ts +5 -5
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +2 -2
- package/package.json +9 -9
- package/src/block/block_hash.ts +25 -50
- package/src/block/block_parameter.ts +3 -3
- package/src/block/in_block.ts +5 -5
- 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/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.ts +7 -7
- package/src/interfaces/block-builder.ts +2 -0
- package/src/interfaces/validator.ts +1 -2
- package/src/logs/log_id.ts +7 -6
- package/src/logs/siloed_tag.ts +3 -2
- package/src/p2p/block_proposal.ts +9 -2
- package/src/p2p/checkpoint_proposal.ts +9 -2
- package/src/tests/mocks.ts +6 -4
- package/src/tx/block_header.ts +6 -6
- package/src/tx/indexed_tx_effect.ts +3 -2
- package/src/tx/tx_receipt.ts +4 -4
package/src/block/l2_block.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { z } from 'zod';
|
|
|
15
15
|
import type { PrivateLog } from '../logs/private_log.js';
|
|
16
16
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
17
17
|
import { BlockHeader } from '../tx/block_header.js';
|
|
18
|
+
import type { BlockHash } from './block_hash.js';
|
|
18
19
|
import { Body } from './body.js';
|
|
19
20
|
import type { L2BlockInfo } from './l2_block_info.js';
|
|
20
21
|
|
|
@@ -89,9 +90,8 @@ export class L2Block {
|
|
|
89
90
|
* Returns the block's hash (hash of block header).
|
|
90
91
|
* @returns The block's hash.
|
|
91
92
|
*/
|
|
92
|
-
public
|
|
93
|
-
|
|
94
|
-
return blockHash.toField();
|
|
93
|
+
public hash(): Promise<BlockHash> {
|
|
94
|
+
return this.header.hash();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -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
|
*
|
|
@@ -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()),
|
|
@@ -23,7 +23,7 @@ import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
|
23
23
|
import { z } from 'zod';
|
|
24
24
|
|
|
25
25
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
26
|
-
import {
|
|
26
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
27
27
|
import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
|
|
28
28
|
import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
|
|
29
29
|
import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
|
|
@@ -234,7 +234,7 @@ export interface AztecNode
|
|
|
234
234
|
* @param blockHash - The block hash being requested.
|
|
235
235
|
* @returns The requested block.
|
|
236
236
|
*/
|
|
237
|
-
getBlockByHash(blockHash:
|
|
237
|
+
getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
240
|
* Get a block specified by its archive root.
|
|
@@ -355,7 +355,7 @@ export interface AztecNode
|
|
|
355
355
|
* @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
|
|
356
356
|
* for a tag, the caller should fetch the next page to check for more logs.
|
|
357
357
|
*/
|
|
358
|
-
getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?:
|
|
358
|
+
getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: BlockHash): Promise<TxScopedL2Log[][]>;
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
361
|
* Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
|
|
@@ -374,7 +374,7 @@ export interface AztecNode
|
|
|
374
374
|
contractAddress: AztecAddress,
|
|
375
375
|
tags: Tag[],
|
|
376
376
|
page?: number,
|
|
377
|
-
referenceBlock?:
|
|
377
|
+
referenceBlock?: BlockHash,
|
|
378
378
|
): Promise<TxScopedL2Log[][]>;
|
|
379
379
|
|
|
380
380
|
/**
|
|
@@ -579,7 +579,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
579
579
|
|
|
580
580
|
getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
|
|
581
581
|
|
|
582
|
-
getBlockByHash: z.function().args(
|
|
582
|
+
getBlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
|
|
583
583
|
|
|
584
584
|
getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
|
|
585
585
|
|
|
@@ -633,7 +633,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
633
633
|
|
|
634
634
|
getPrivateLogsByTags: z
|
|
635
635
|
.function()
|
|
636
|
-
.args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(
|
|
636
|
+
.args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(BlockHash.schema))
|
|
637
637
|
.returns(z.array(z.array(TxScopedL2Log.schema))),
|
|
638
638
|
|
|
639
639
|
getPublicLogsByTagsFromContract: z
|
|
@@ -642,7 +642,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
642
642
|
schemas.AztecAddress,
|
|
643
643
|
z.array(Tag.schema).max(MAX_RPC_LEN),
|
|
644
644
|
optional(z.number().gte(0)),
|
|
645
|
-
optional(
|
|
645
|
+
optional(BlockHash.schema),
|
|
646
646
|
)
|
|
647
647
|
.returns(z.array(z.array(TxScopedL2Log.schema))),
|
|
648
648
|
|
|
@@ -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';
|
|
@@ -92,5 +93,6 @@ export interface ICheckpointsBuilder {
|
|
|
92
93
|
l1ToL2Messages: Fr[],
|
|
93
94
|
previousCheckpointOutHashes: Fr[],
|
|
94
95
|
fork: MerkleTreeWriteOperations,
|
|
96
|
+
bindings?: LoggerBindings,
|
|
95
97
|
): Promise<ICheckpointBlockBuilder>;
|
|
96
98
|
}
|
|
@@ -51,8 +51,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig & {
|
|
|
51
51
|
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
52
52
|
fishermanMode?: boolean;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
/** Skip checkpoint proposal validation and always attest (default: true) */
|
|
54
|
+
/** Skip checkpoint proposal validation and always attest (default: false) */
|
|
56
55
|
skipCheckpointProposalValidation?: boolean;
|
|
57
56
|
|
|
58
57
|
/** Skip pushing re-executed blocks to archiver (default: false) */
|
package/src/logs/log_id.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
2
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
3
3
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
5
6
|
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
9
10
|
import { schemas } from '../schemas/index.js';
|
|
10
11
|
|
|
11
12
|
/** A globally unique log id. */
|
|
@@ -20,7 +21,7 @@ export class LogId {
|
|
|
20
21
|
/** The block number the log was emitted in. */
|
|
21
22
|
public readonly blockNumber: BlockNumber,
|
|
22
23
|
/** The hash of the block the log was emitted in. */
|
|
23
|
-
public readonly blockHash:
|
|
24
|
+
public readonly blockHash: BlockHash,
|
|
24
25
|
/** The index of a tx in a block the log was emitted in. */
|
|
25
26
|
public readonly txIndex: number,
|
|
26
27
|
/** The index of a log the tx was emitted in. */
|
|
@@ -40,7 +41,7 @@ export class LogId {
|
|
|
40
41
|
static random() {
|
|
41
42
|
return new LogId(
|
|
42
43
|
BlockNumber(Math.floor(Math.random() * 1000) + 1),
|
|
43
|
-
|
|
44
|
+
BlockHash.random(),
|
|
44
45
|
Math.floor(Math.random() * 1000),
|
|
45
46
|
Math.floor(Math.random() * 100),
|
|
46
47
|
);
|
|
@@ -50,7 +51,7 @@ export class LogId {
|
|
|
50
51
|
return z
|
|
51
52
|
.object({
|
|
52
53
|
blockNumber: BlockNumberSchema,
|
|
53
|
-
blockHash:
|
|
54
|
+
blockHash: BlockHash.schema,
|
|
54
55
|
txIndex: schemas.Integer,
|
|
55
56
|
logIndex: schemas.Integer,
|
|
56
57
|
})
|
|
@@ -81,7 +82,7 @@ export class LogId {
|
|
|
81
82
|
const reader = BufferReader.asReader(buffer);
|
|
82
83
|
|
|
83
84
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
84
|
-
const blockHash = reader.readObject(
|
|
85
|
+
const blockHash = new BlockHash(reader.readObject(Fr));
|
|
85
86
|
const txIndex = reader.readNumber();
|
|
86
87
|
const logIndex = reader.readNumber();
|
|
87
88
|
|
|
@@ -104,7 +105,7 @@ export class LogId {
|
|
|
104
105
|
static fromString(data: string): LogId {
|
|
105
106
|
const [rawBlockNumber, rawTxIndex, rawLogIndex, rawBlockHash] = data.split('-');
|
|
106
107
|
const blockNumber = BlockNumber(Number(rawBlockNumber));
|
|
107
|
-
const blockHash =
|
|
108
|
+
const blockHash = BlockHash.fromString(rawBlockHash);
|
|
108
109
|
const txIndex = Number(rawTxIndex);
|
|
109
110
|
const logIndex = Number(rawLogIndex);
|
|
110
111
|
|
package/src/logs/siloed_tag.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
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
5
|
|
|
@@ -22,7 +23,7 @@ export class SiloedTag {
|
|
|
22
23
|
constructor(public readonly value: Fr) {}
|
|
23
24
|
|
|
24
25
|
static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
|
|
25
|
-
const siloedTag = await
|
|
26
|
+
const siloedTag = await poseidon2HashWithSeparator([app, tag.value], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
|
|
26
27
|
return new SiloedTag(siloedTag);
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -30,8 +30,15 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export type BlockProposalOptions = {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Whether to include the tx objects along with the block proposal.
|
|
35
|
+
* Dramatically increases size of the payload but eliminates failed reexecutions due to missing txs.
|
|
36
|
+
*/
|
|
37
|
+
publishFullTxs?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to generate an invalid block proposal for broadcasting.
|
|
40
|
+
* Use only for testing.
|
|
41
|
+
*/
|
|
35
42
|
broadcastInvalidBlockProposal?: boolean;
|
|
36
43
|
};
|
|
37
44
|
|
|
@@ -32,8 +32,15 @@ export class CheckpointProposalHash extends Buffer32 {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type CheckpointProposalOptions = {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Whether to include the tx objects along with the block proposal.
|
|
37
|
+
* Dramatically increases size of the payload but eliminates failed reexecutions due to missing txs.
|
|
38
|
+
*/
|
|
39
|
+
publishFullTxs?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether to generate an invalid checkpoint proposal for broadcasting.
|
|
42
|
+
* Use only for testing.
|
|
43
|
+
*/
|
|
37
44
|
broadcastInvalidCheckpointProposal?: boolean;
|
|
38
45
|
};
|
|
39
46
|
|
package/src/tests/mocks.ts
CHANGED
|
@@ -97,12 +97,14 @@ export const mockTx = async (
|
|
|
97
97
|
publicCalldataSize = 2,
|
|
98
98
|
feePayer,
|
|
99
99
|
chonkProof = ChonkProof.random(),
|
|
100
|
+
maxFeesPerGas = new GasFees(10, 10),
|
|
100
101
|
maxPriorityFeesPerGas,
|
|
101
102
|
gasUsed = Gas.empty(),
|
|
102
103
|
chainId = Fr.ZERO,
|
|
103
104
|
version = Fr.ZERO,
|
|
104
105
|
vkTreeRoot = Fr.ZERO,
|
|
105
106
|
protocolContractsHash = Fr.ZERO,
|
|
107
|
+
anchorBlockHeader = BlockHeader.empty(),
|
|
106
108
|
}: {
|
|
107
109
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
108
110
|
numberOfRevertiblePublicCallRequests?: number;
|
|
@@ -111,12 +113,14 @@ export const mockTx = async (
|
|
|
111
113
|
publicCalldataSize?: number;
|
|
112
114
|
feePayer?: AztecAddress;
|
|
113
115
|
chonkProof?: ChonkProof;
|
|
116
|
+
maxFeesPerGas?: GasFees;
|
|
114
117
|
maxPriorityFeesPerGas?: GasFees;
|
|
115
118
|
gasUsed?: Gas;
|
|
116
119
|
chainId?: Fr;
|
|
117
120
|
version?: Fr;
|
|
118
121
|
vkTreeRoot?: Fr;
|
|
119
122
|
protocolContractsHash?: Fr;
|
|
123
|
+
anchorBlockHeader?: BlockHeader;
|
|
120
124
|
} = {},
|
|
121
125
|
) => {
|
|
122
126
|
const totalPublicCallRequests =
|
|
@@ -126,10 +130,8 @@ export const mockTx = async (
|
|
|
126
130
|
const isForPublic = totalPublicCallRequests > 0;
|
|
127
131
|
const data = PrivateKernelTailCircuitPublicInputs.empty();
|
|
128
132
|
const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
|
|
129
|
-
data.constants.
|
|
130
|
-
|
|
131
|
-
maxPriorityFeesPerGas,
|
|
132
|
-
});
|
|
133
|
+
data.constants.anchorBlockHeader = anchorBlockHeader;
|
|
134
|
+
data.constants.txContext.gasSettings = GasSettings.default({ maxFeesPerGas, maxPriorityFeesPerGas });
|
|
133
135
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
134
136
|
data.gasUsed = gasUsed;
|
|
135
137
|
data.constants.txContext.chainId = chainId;
|
package/src/tx/block_header.ts
CHANGED
|
@@ -11,14 +11,14 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
11
11
|
import { inspect } from 'util';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
15
15
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
16
16
|
import { GlobalVariables } from './global_variables.js';
|
|
17
17
|
import { StateReference } from './state_reference.js';
|
|
18
18
|
|
|
19
19
|
/** A header of an L2 block. */
|
|
20
20
|
export class BlockHeader {
|
|
21
|
-
private _cachedHash?: Promise<
|
|
21
|
+
private _cachedHash?: Promise<BlockHash>;
|
|
22
22
|
|
|
23
23
|
constructor(
|
|
24
24
|
/** Snapshot of archive before the block is applied. */
|
|
@@ -162,10 +162,10 @@ export class BlockHeader {
|
|
|
162
162
|
return BlockHeader.fromBuffer(hexToBuffer(str));
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
hash(): Promise<
|
|
165
|
+
hash(): Promise<BlockHash> {
|
|
166
166
|
if (!this._cachedHash) {
|
|
167
|
-
this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.
|
|
168
|
-
|
|
167
|
+
this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HEADER_HASH).then(
|
|
168
|
+
fr => new BlockHash(fr),
|
|
169
169
|
);
|
|
170
170
|
}
|
|
171
171
|
return this._cachedHash;
|
|
@@ -173,7 +173,7 @@ export class BlockHeader {
|
|
|
173
173
|
|
|
174
174
|
/** Manually set the hash for this block header if already computed */
|
|
175
175
|
setHash(hashed: Fr) {
|
|
176
|
-
this._cachedHash = Promise.resolve(
|
|
176
|
+
this._cachedHash = Promise.resolve(new BlockHash(hashed));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { schemas } from '@aztec/foundation/schemas';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
6
7
|
import { type DataInBlock, dataInBlockSchemaFor, randomDataInBlock } from '../block/in_block.js';
|
|
7
8
|
import { TxEffect } from './tx_effect.js';
|
|
8
9
|
|
|
@@ -26,7 +27,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
|
|
|
26
27
|
export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
|
|
27
28
|
const reader = BufferReader.asReader(buffer);
|
|
28
29
|
|
|
29
|
-
const l2BlockHash = reader.readObject(
|
|
30
|
+
const l2BlockHash = new BlockHash(reader.readObject(Fr));
|
|
30
31
|
const l2BlockNumber = BlockNumber(reader.readNumber());
|
|
31
32
|
const txIndexInBlock = reader.readNumber();
|
|
32
33
|
const data = reader.readObject(TxEffect);
|
package/src/tx/tx_receipt.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types'
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { RevertCode } from '../avm/revert_code.js';
|
|
6
|
-
import {
|
|
6
|
+
import { BlockHash } from '../block/block_hash.js';
|
|
7
7
|
import { type ZodFor, schemas } from '../schemas/schemas.js';
|
|
8
8
|
import { TxHash } from './tx_hash.js';
|
|
9
9
|
|
|
@@ -54,7 +54,7 @@ export class TxReceipt {
|
|
|
54
54
|
/** The transaction fee paid for the transaction. */
|
|
55
55
|
public transactionFee?: bigint,
|
|
56
56
|
/** The hash of the block containing the transaction. */
|
|
57
|
-
public blockHash?:
|
|
57
|
+
public blockHash?: BlockHash,
|
|
58
58
|
/** The block number in which the transaction was included. */
|
|
59
59
|
public blockNumber?: BlockNumber,
|
|
60
60
|
) {}
|
|
@@ -100,7 +100,7 @@ export class TxReceipt {
|
|
|
100
100
|
status: z.nativeEnum(TxStatus),
|
|
101
101
|
executionResult: z.nativeEnum(TxExecutionResult).optional(),
|
|
102
102
|
error: z.string().optional(),
|
|
103
|
-
blockHash:
|
|
103
|
+
blockHash: BlockHash.schema.optional(),
|
|
104
104
|
blockNumber: BlockNumberSchema.optional(),
|
|
105
105
|
transactionFee: schemas.BigInt.optional(),
|
|
106
106
|
})
|
|
@@ -113,7 +113,7 @@ export class TxReceipt {
|
|
|
113
113
|
executionResult?: TxExecutionResult;
|
|
114
114
|
error?: string;
|
|
115
115
|
transactionFee?: bigint;
|
|
116
|
-
blockHash?:
|
|
116
|
+
blockHash?: BlockHash;
|
|
117
117
|
blockNumber?: BlockNumber;
|
|
118
118
|
}) {
|
|
119
119
|
return new TxReceipt(
|