@aztec/aztec-node 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed

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.
@@ -6,4 +6,4 @@ import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
6
6
  import type { SentinelConfig } from './config.js';
7
7
  import { Sentinel } from './sentinel.js';
8
8
  export declare function createSentinel(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, config: SentinelConfig & DataStoreConfig & SlasherConfig, logger?: import("@aztec/foundation/log").Logger): Promise<Sentinel | undefined>;
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlbnRpbmVsL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzVDLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRXJFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBR3pDLHdCQUFzQixjQUFjLENBQ2xDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFFBQVEsRUFBRSxhQUFhLEVBQ3ZCLEdBQUcsRUFBRSxTQUFTLEVBQ2QsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLEdBQUcsYUFBYSxFQUN4RCxNQUFNLHlDQUFnQyxHQUNyQyxPQUFPLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQyxDQWlCL0IifQ==
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlbnRpbmVsL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzVDLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRXJFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBR3pDLHdCQUFzQixjQUFjLENBQ2xDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFFBQVEsRUFBRSxhQUFhLEVBQ3ZCLEdBQUcsRUFBRSxTQUFTLEVBQ2QsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLEdBQUcsYUFBYSxFQUN4RCxNQUFNLHlDQUFnQyxHQUNyQyxPQUFPLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQyxDQVkvQiJ9
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAiB/B"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAY/B"}
@@ -6,7 +6,7 @@ export async function createSentinel(epochCache, archiver, p2p, config, logger =
6
6
  if (!config.sentinelEnabled) {
7
7
  return undefined;
8
8
  }
9
- const kvStore = await createStore('sentinel', SentinelStore.SCHEMA_VERSION, config, createLogger('node:sentinel:lmdb'));
9
+ const kvStore = await createStore('sentinel', SentinelStore.SCHEMA_VERSION, config, logger.getBindings());
10
10
  const storeHistoryLength = config.sentinelHistoryLengthInEpochs * epochCache.getL1Constants().epochDuration;
11
11
  const storeHistoricProvenPerformanceLength = config.sentinelHistoricProvenPerformanceLengthInEpochs;
12
12
  const sentinelStore = new SentinelStore(kvStore, {
@@ -82,7 +82,7 @@ export class Sentinel extends EventEmitter {
82
82
  return;
83
83
  }
84
84
  const blockNumber = event.block.number;
85
- const block = await this.archiver.getL2BlockNew(blockNumber);
85
+ const block = await this.archiver.getL2Block(blockNumber);
86
86
  if (!block) {
87
87
  this.logger.error(`Failed to get block ${blockNumber}`, {
88
88
  block
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/aztec-node",
3
- "version": "0.0.1-commit.d431d1c",
3
+ "version": "0.0.1-commit.e2b2873ed",
4
4
  "main": "dest/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -65,30 +65,30 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/archiver": "0.0.1-commit.d431d1c",
69
- "@aztec/bb-prover": "0.0.1-commit.d431d1c",
70
- "@aztec/blob-client": "0.0.1-commit.d431d1c",
71
- "@aztec/constants": "0.0.1-commit.d431d1c",
72
- "@aztec/epoch-cache": "0.0.1-commit.d431d1c",
73
- "@aztec/ethereum": "0.0.1-commit.d431d1c",
74
- "@aztec/foundation": "0.0.1-commit.d431d1c",
75
- "@aztec/kv-store": "0.0.1-commit.d431d1c",
76
- "@aztec/l1-artifacts": "0.0.1-commit.d431d1c",
77
- "@aztec/merkle-tree": "0.0.1-commit.d431d1c",
78
- "@aztec/node-keystore": "0.0.1-commit.d431d1c",
79
- "@aztec/node-lib": "0.0.1-commit.d431d1c",
80
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.d431d1c",
81
- "@aztec/p2p": "0.0.1-commit.d431d1c",
82
- "@aztec/protocol-contracts": "0.0.1-commit.d431d1c",
83
- "@aztec/prover-client": "0.0.1-commit.d431d1c",
84
- "@aztec/sequencer-client": "0.0.1-commit.d431d1c",
85
- "@aztec/simulator": "0.0.1-commit.d431d1c",
86
- "@aztec/slasher": "0.0.1-commit.d431d1c",
87
- "@aztec/stdlib": "0.0.1-commit.d431d1c",
88
- "@aztec/telemetry-client": "0.0.1-commit.d431d1c",
89
- "@aztec/validator-client": "0.0.1-commit.d431d1c",
90
- "@aztec/validator-ha-signer": "0.0.1-commit.d431d1c",
91
- "@aztec/world-state": "0.0.1-commit.d431d1c",
68
+ "@aztec/archiver": "0.0.1-commit.e2b2873ed",
69
+ "@aztec/bb-prover": "0.0.1-commit.e2b2873ed",
70
+ "@aztec/blob-client": "0.0.1-commit.e2b2873ed",
71
+ "@aztec/constants": "0.0.1-commit.e2b2873ed",
72
+ "@aztec/epoch-cache": "0.0.1-commit.e2b2873ed",
73
+ "@aztec/ethereum": "0.0.1-commit.e2b2873ed",
74
+ "@aztec/foundation": "0.0.1-commit.e2b2873ed",
75
+ "@aztec/kv-store": "0.0.1-commit.e2b2873ed",
76
+ "@aztec/l1-artifacts": "0.0.1-commit.e2b2873ed",
77
+ "@aztec/merkle-tree": "0.0.1-commit.e2b2873ed",
78
+ "@aztec/node-keystore": "0.0.1-commit.e2b2873ed",
79
+ "@aztec/node-lib": "0.0.1-commit.e2b2873ed",
80
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.e2b2873ed",
81
+ "@aztec/p2p": "0.0.1-commit.e2b2873ed",
82
+ "@aztec/protocol-contracts": "0.0.1-commit.e2b2873ed",
83
+ "@aztec/prover-client": "0.0.1-commit.e2b2873ed",
84
+ "@aztec/sequencer-client": "0.0.1-commit.e2b2873ed",
85
+ "@aztec/simulator": "0.0.1-commit.e2b2873ed",
86
+ "@aztec/slasher": "0.0.1-commit.e2b2873ed",
87
+ "@aztec/stdlib": "0.0.1-commit.e2b2873ed",
88
+ "@aztec/telemetry-client": "0.0.1-commit.e2b2873ed",
89
+ "@aztec/validator-client": "0.0.1-commit.e2b2873ed",
90
+ "@aztec/validator-ha-signer": "0.0.1-commit.e2b2873ed",
91
+ "@aztec/world-state": "0.0.1-commit.e2b2873ed",
92
92
  "koa": "^2.16.1",
93
93
  "koa-router": "^13.1.1",
94
94
  "tslib": "^2.4.0",
@@ -1,4 +1,11 @@
1
- import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
1
+ import {
2
+ Attributes,
3
+ type Histogram,
4
+ Metrics,
5
+ type TelemetryClient,
6
+ type UpDownCounter,
7
+ createUpDownCounterWithDefault,
8
+ } from '@aztec/telemetry-client';
2
9
 
3
10
  export class NodeMetrics {
4
11
  private receiveTxCount: UpDownCounter;
@@ -9,14 +16,14 @@ export class NodeMetrics {
9
16
 
10
17
  constructor(client: TelemetryClient, name = 'AztecNode') {
11
18
  const meter = client.getMeter(name);
12
- this.receiveTxCount = meter.createUpDownCounter(Metrics.NODE_RECEIVE_TX_COUNT);
19
+ this.receiveTxCount = createUpDownCounterWithDefault(meter, Metrics.NODE_RECEIVE_TX_COUNT, {
20
+ [Attributes.OK]: [true, false],
21
+ });
13
22
  this.receiveTxDuration = meter.createHistogram(Metrics.NODE_RECEIVE_TX_DURATION);
14
23
 
15
24
  this.snapshotDuration = meter.createHistogram(Metrics.NODE_SNAPSHOT_DURATION);
16
25
 
17
- this.snapshotErrorCount = meter.createUpDownCounter(Metrics.NODE_SNAPSHOT_ERROR_COUNT);
18
-
19
- this.snapshotErrorCount.add(0);
26
+ this.snapshotErrorCount = createUpDownCounterWithDefault(meter, Metrics.NODE_SNAPSHOT_ERROR_COUNT);
20
27
  }
21
28
 
22
29
  receivedTx(durationMs: number, isAccepted: boolean) {
@@ -1,13 +1,7 @@
1
1
  import { Archiver, createArchiver } from '@aztec/archiver';
2
2
  import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
3
3
  import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
4
- import {
5
- ARCHIVE_HEIGHT,
6
- type L1_TO_L2_MSG_TREE_HEIGHT,
7
- type NOTE_HASH_TREE_HEIGHT,
8
- type NULLIFIER_TREE_HEIGHT,
9
- type PUBLIC_DATA_TREE_HEIGHT,
10
- } from '@aztec/constants';
4
+ import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
11
5
  import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
12
6
  import { createEthereumChain } from '@aztec/ethereum/chain';
13
7
  import { getPublicClient } from '@aztec/ethereum/client';
@@ -41,14 +35,7 @@ import {
41
35
  } from '@aztec/slasher';
42
36
  import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
43
37
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
44
- import {
45
- type BlockParameter,
46
- type CheckpointedL2Block,
47
- type DataInBlock,
48
- L2BlockHash,
49
- L2BlockNew,
50
- type L2BlockSource,
51
- } from '@aztec/stdlib/block';
38
+ import { BlockHash, type BlockParameter, type DataInBlock, L2Block, type L2BlockSource } from '@aztec/stdlib/block';
52
39
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
53
40
  import type {
54
41
  ContractClassPublic,
@@ -126,7 +113,7 @@ import { NodeMetrics } from './node_metrics.js';
126
113
  */
127
114
  export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
128
115
  private metrics: NodeMetrics;
129
- private initialHeaderHashPromise: Promise<L2BlockHash> | undefined = undefined;
116
+ private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
130
117
 
131
118
  // Prevent two snapshot operations to happen simultaneously
132
119
  private isUploadingSnapshot = false;
@@ -566,6 +553,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
566
553
  enr,
567
554
  l1ContractAddresses: contractAddresses,
568
555
  protocolContractAddresses: protocolContractAddresses,
556
+ realProofs: !!this.config.realProofs,
569
557
  };
570
558
 
571
559
  return nodeInfo;
@@ -576,15 +564,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
576
564
  * @param block - The block parameter (block number, block hash, or 'latest').
577
565
  * @returns The requested block.
578
566
  */
579
- public async getBlock(block: BlockParameter): Promise<L2BlockNew | undefined> {
580
- if (L2BlockHash.isL2BlockHash(block)) {
581
- return this.getBlockByHash(Fr.fromBuffer(block.toBuffer()));
567
+ public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
568
+ if (BlockHash.isBlockHash(block)) {
569
+ return this.getBlockByHash(block);
582
570
  }
583
571
  const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
584
572
  if (blockNumber === BlockNumber.ZERO) {
585
573
  return this.buildInitialBlock();
586
574
  }
587
- return await this.blockSource.getL2BlockNew(blockNumber);
575
+ return await this.blockSource.getL2Block(blockNumber);
588
576
  }
589
577
 
590
578
  /**
@@ -592,17 +580,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
592
580
  * @param blockHash - The block hash being requested.
593
581
  * @returns The requested block.
594
582
  */
595
- public async getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined> {
583
+ public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
596
584
  const initialBlockHash = await this.#getInitialHeaderHash();
597
- if (blockHash.equals(Fr.fromBuffer(initialBlockHash.toBuffer()))) {
585
+ if (blockHash.equals(initialBlockHash)) {
598
586
  return this.buildInitialBlock();
599
587
  }
600
- return await this.blockSource.getL2BlockNewByHash(blockHash);
588
+ return await this.blockSource.getL2BlockByHash(blockHash);
601
589
  }
602
590
 
603
- private buildInitialBlock(): L2BlockNew {
591
+ private buildInitialBlock(): L2Block {
604
592
  const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
605
- return L2BlockNew.empty(initialHeader);
593
+ return L2Block.empty(initialHeader);
606
594
  }
607
595
 
608
596
  /**
@@ -610,8 +598,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
610
598
  * @param archive - The archive root being requested.
611
599
  * @returns The requested block.
612
600
  */
613
- public async getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined> {
614
- return await this.blockSource.getL2BlockNewByArchive(archive);
601
+ public async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
602
+ return await this.blockSource.getL2BlockByArchive(archive);
615
603
  }
616
604
 
617
605
  /**
@@ -620,24 +608,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
620
608
  * @param limit - The maximum number of blocks to obtain.
621
609
  * @returns The blocks requested.
622
610
  */
623
- public async getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
624
- return (await this.blockSource.getL2BlocksNew(from, limit)) ?? [];
625
- }
626
-
627
- public async getPublishedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]> {
628
- return (await this.blockSource.getPublishedBlocks(from, limit)) ?? [];
629
- }
630
-
631
- public async getPublishedCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
632
- return (await this.blockSource.getPublishedCheckpoints(from, limit)) ?? [];
611
+ public async getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
612
+ return (await this.blockSource.getBlocks(from, BlockNumber(limit))) ?? [];
633
613
  }
634
614
 
635
- public async getL2BlocksNew(from: BlockNumber, limit: number): Promise<L2BlockNew[]> {
636
- return (await this.blockSource.getL2BlocksNew(from, limit)) ?? [];
615
+ public async getCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
616
+ return (await this.blockSource.getCheckpoints(from, limit)) ?? [];
637
617
  }
638
618
 
639
- public async getCheckpointedBlocks(from: BlockNumber, limit: number, proven?: boolean) {
640
- return (await this.blockSource.getCheckpointedBlocks(from, limit, proven)) ?? [];
619
+ public async getCheckpointedBlocks(from: BlockNumber, limit: number) {
620
+ return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
641
621
  }
642
622
 
643
623
  /**
@@ -668,6 +648,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
668
648
  return await this.blockSource.getProvenBlockNumber();
669
649
  }
670
650
 
651
+ public async getCheckpointedBlockNumber(): Promise<BlockNumber> {
652
+ return await this.blockSource.getCheckpointedL2BlockNumber();
653
+ }
654
+
671
655
  /**
672
656
  * Method to fetch the version of the package.
673
657
  * @returns The node package version
@@ -700,15 +684,42 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
700
684
  return this.contractDataSource.getContract(address);
701
685
  }
702
686
 
703
- public getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]> {
687
+ public async getPrivateLogsByTags(
688
+ tags: SiloedTag[],
689
+ page?: number,
690
+ referenceBlock?: BlockHash,
691
+ ): Promise<TxScopedL2Log[][]> {
692
+ if (referenceBlock) {
693
+ const initialBlockHash = await this.#getInitialHeaderHash();
694
+ if (!referenceBlock.equals(initialBlockHash)) {
695
+ const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
696
+ if (!header) {
697
+ throw new Error(
698
+ `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
699
+ );
700
+ }
701
+ }
702
+ }
704
703
  return this.logsSource.getPrivateLogsByTags(tags, page);
705
704
  }
706
705
 
707
- public getPublicLogsByTagsFromContract(
706
+ public async getPublicLogsByTagsFromContract(
708
707
  contractAddress: AztecAddress,
709
708
  tags: Tag[],
710
709
  page?: number,
710
+ referenceBlock?: BlockHash,
711
711
  ): Promise<TxScopedL2Log[][]> {
712
+ if (referenceBlock) {
713
+ const initialBlockHash = await this.#getInitialHeaderHash();
714
+ if (!referenceBlock.equals(initialBlockHash)) {
715
+ const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
716
+ if (!header) {
717
+ throw new Error(
718
+ `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
719
+ );
720
+ }
721
+ }
722
+ }
712
723
  return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page);
713
724
  }
714
725
 
@@ -756,21 +767,26 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
756
767
  }
757
768
 
758
769
  public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
759
- let txReceipt = new TxReceipt(txHash, TxStatus.DROPPED, 'Tx dropped by P2P node.');
760
-
761
- // We first check if the tx is in pending (instead of first checking if it is mined) because if we first check
762
- // for mined and then for pending there could be a race condition where the tx is mined between the two checks
763
- // and we would incorrectly return a TxReceipt with status DROPPED
764
- if ((await this.p2pClient.getTxStatus(txHash)) === 'pending') {
765
- txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
766
- }
770
+ // Check the tx pool status first. If the tx is known to the pool (pending or mined), we'll use that
771
+ // as a fallback if we don't find a settled receipt in the archiver.
772
+ const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
773
+ const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
767
774
 
775
+ // Then get the actual tx from the archiver, which tracks every tx in a mined block.
768
776
  const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
777
+
769
778
  if (settledTxReceipt) {
770
- txReceipt = settledTxReceipt;
779
+ // If the archiver has the receipt then return it.
780
+ return settledTxReceipt;
781
+ } else if (isKnownToPool) {
782
+ // If the tx is in the pool but not in the archiver, it's pending.
783
+ // This handles race conditions between archiver and p2p, where the archiver
784
+ // has pruned the block in which a tx was mined, but p2p has not caught up yet.
785
+ return new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
786
+ } else {
787
+ // Otherwise, if we don't know the tx, we consider it dropped.
788
+ return new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
771
789
  }
772
-
773
- return txReceipt;
774
790
  }
775
791
 
776
792
  public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
@@ -836,11 +852,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
836
852
  }
837
853
 
838
854
  public async findLeavesIndexes(
839
- block: BlockParameter,
855
+ referenceBlock: BlockParameter,
840
856
  treeId: MerkleTreeId,
841
857
  leafValues: Fr[],
842
858
  ): Promise<(DataInBlock<bigint> | undefined)[]> {
843
- const committedDb = await this.#getWorldState(block);
859
+ const committedDb = await this.#getWorldState(referenceBlock);
844
860
  const maybeIndices = await committedDb.findLeafIndices(
845
861
  treeId,
846
862
  leafValues.map(x => x.toBuffer()),
@@ -892,44 +908,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
892
908
  }
893
909
  return {
894
910
  l2BlockNumber: BlockNumber(Number(blockNumber)),
895
- l2BlockHash: L2BlockHash.fromField(blockHash),
911
+ l2BlockHash: new BlockHash(blockHash),
896
912
  data: index,
897
913
  };
898
914
  });
899
915
  }
900
916
 
901
- public async getNullifierSiblingPath(
902
- block: BlockParameter,
903
- leafIndex: bigint,
904
- ): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>> {
905
- const committedDb = await this.#getWorldState(block);
906
- return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
907
- }
908
-
909
- public async getNoteHashSiblingPath(
910
- block: BlockParameter,
911
- leafIndex: bigint,
912
- ): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>> {
913
- const committedDb = await this.#getWorldState(block);
914
- return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
915
- }
916
-
917
- public async getArchiveMembershipWitness(
918
- block: BlockParameter,
919
- archive: Fr,
917
+ public async getBlockHashMembershipWitness(
918
+ referenceBlock: BlockParameter,
919
+ blockHash: BlockHash,
920
920
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
921
- const committedDb = await this.#getWorldState(block);
922
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [archive]);
921
+ const committedDb = await this.#getWorldState(referenceBlock);
922
+ const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
923
923
  return pathAndIndex === undefined
924
924
  ? undefined
925
925
  : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
926
926
  }
927
927
 
928
928
  public async getNoteHashMembershipWitness(
929
- block: BlockParameter,
929
+ referenceBlock: BlockParameter,
930
930
  noteHash: Fr,
931
931
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
932
- const committedDb = await this.#getWorldState(block);
932
+ const committedDb = await this.#getWorldState(referenceBlock);
933
933
  const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
934
934
  MerkleTreeId.NOTE_HASH_TREE,
935
935
  [noteHash],
@@ -940,10 +940,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
940
940
  }
941
941
 
942
942
  public async getL1ToL2MessageMembershipWitness(
943
- block: BlockParameter,
943
+ referenceBlock: BlockParameter,
944
944
  l1ToL2Message: Fr,
945
945
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
946
- const db = await this.#getWorldState(block);
946
+ const db = await this.#getWorldState(referenceBlock);
947
947
  const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
948
948
  if (!witness) {
949
949
  return undefined;
@@ -976,12 +976,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
976
976
  * @returns The L2 to L1 messages (empty array if the epoch is not found).
977
977
  */
978
978
  public async getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
979
- // Assumes `getBlocksForEpoch` returns blocks in ascending order of block number.
980
- const blocks = await this.blockSource.getBlocksForEpoch(epoch);
981
- const blocksInCheckpoints: L2BlockNew[][] = [];
979
+ // Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
980
+ const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
981
+ const blocksInCheckpoints: L2Block[][] = [];
982
982
  let previousSlotNumber = SlotNumber.ZERO;
983
983
  let checkpointIndex = -1;
984
- for (const block of blocks) {
984
+ for (const checkpointedBlock of checkpointedBlocks) {
985
+ const block = checkpointedBlock.block;
985
986
  const slotNumber = block.header.globalVariables.slotNumber;
986
987
  if (slotNumber !== previousSlotNumber) {
987
988
  checkpointIndex++;
@@ -995,27 +996,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
995
996
  );
996
997
  }
997
998
 
998
- public async getArchiveSiblingPath(
999
- block: BlockParameter,
1000
- leafIndex: bigint,
1001
- ): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>> {
1002
- const committedDb = await this.#getWorldState(block);
1003
- return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
1004
- }
1005
-
1006
- public async getPublicDataSiblingPath(
1007
- block: BlockParameter,
1008
- leafIndex: bigint,
1009
- ): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>> {
1010
- const committedDb = await this.#getWorldState(block);
1011
- return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
1012
- }
1013
-
1014
999
  public async getNullifierMembershipWitness(
1015
- block: BlockParameter,
1000
+ referenceBlock: BlockParameter,
1016
1001
  nullifier: Fr,
1017
1002
  ): Promise<NullifierMembershipWitness | undefined> {
1018
- const db = await this.#getWorldState(block);
1003
+ const db = await this.#getWorldState(referenceBlock);
1019
1004
  const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
1020
1005
  if (!witness) {
1021
1006
  return undefined;
@@ -1032,7 +1017,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1032
1017
 
1033
1018
  /**
1034
1019
  * Returns a low nullifier membership witness for a given nullifier at a given block.
1035
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
1020
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
1021
+ * (which contains the root of the nullifier tree in which we are searching for the nullifier).
1036
1022
  * @param nullifier - Nullifier we try to find the low nullifier witness for.
1037
1023
  * @returns The low nullifier membership witness (if found).
1038
1024
  * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
@@ -1045,10 +1031,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1045
1031
  * TODO: This is a confusing behavior and we should eventually address that.
1046
1032
  */
1047
1033
  public async getLowNullifierMembershipWitness(
1048
- block: BlockParameter,
1034
+ referenceBlock: BlockParameter,
1049
1035
  nullifier: Fr,
1050
1036
  ): Promise<NullifierMembershipWitness | undefined> {
1051
- const committedDb = await this.#getWorldState(block);
1037
+ const committedDb = await this.#getWorldState(referenceBlock);
1052
1038
  const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
1053
1039
  if (!findResult) {
1054
1040
  return undefined;
@@ -1063,8 +1049,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1063
1049
  return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
1064
1050
  }
1065
1051
 
1066
- async getPublicDataWitness(block: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1067
- const committedDb = await this.#getWorldState(block);
1052
+ async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1053
+ const committedDb = await this.#getWorldState(referenceBlock);
1068
1054
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1069
1055
  if (!lowLeafResult) {
1070
1056
  return undefined;
@@ -1078,8 +1064,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1078
1064
  }
1079
1065
  }
1080
1066
 
1081
- public async getPublicStorageAt(block: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1082
- const committedDb = await this.#getWorldState(block);
1067
+ public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1068
+ const committedDb = await this.#getWorldState(referenceBlock);
1083
1069
  const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
1084
1070
 
1085
1071
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
@@ -1094,14 +1080,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1094
1080
  }
1095
1081
 
1096
1082
  public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
1097
- if (L2BlockHash.isL2BlockHash(block)) {
1083
+ if (BlockHash.isBlockHash(block)) {
1098
1084
  const initialBlockHash = await this.#getInitialHeaderHash();
1099
1085
  if (block.equals(initialBlockHash)) {
1100
1086
  // Block source doesn't handle initial header so we need to handle the case separately.
1101
1087
  return this.worldStateSynchronizer.getCommitted().getInitialHeader();
1102
1088
  }
1103
- const blockHashFr = Fr.fromBuffer(block.toBuffer());
1104
- return this.blockSource.getBlockHeaderByHash(blockHashFr);
1089
+ return this.blockSource.getBlockHeaderByHash(block);
1105
1090
  } else {
1106
1091
  // Block source doesn't handle initial header so we need to handle the case separately.
1107
1092
  const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
@@ -1159,6 +1144,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1159
1144
  this.contractDataSource,
1160
1145
  new DateProvider(),
1161
1146
  this.telemetry,
1147
+ this.log.getBindings(),
1162
1148
  );
1163
1149
 
1164
1150
  this.log.verbose(`Simulating public calls for tx ${txHash}`, {
@@ -1212,16 +1198,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1212
1198
  // We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
1213
1199
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1214
1200
  const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1215
- const validator = createValidatorForAcceptingTxs(db, this.contractDataSource, verifier, {
1216
- timestamp: nextSlotTimestamp,
1217
- blockNumber,
1218
- l1ChainId: this.l1ChainId,
1219
- rollupVersion: this.version,
1220
- setupAllowList: this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions()),
1221
- gasFees: await this.getCurrentMinFees(),
1222
- skipFeeEnforcement,
1223
- txsPermitted: !this.config.disableTransactions,
1224
- });
1201
+ const validator = createValidatorForAcceptingTxs(
1202
+ db,
1203
+ this.contractDataSource,
1204
+ verifier,
1205
+ {
1206
+ timestamp: nextSlotTimestamp,
1207
+ blockNumber,
1208
+ l1ChainId: this.l1ChainId,
1209
+ rollupVersion: this.version,
1210
+ setupAllowList: this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions()),
1211
+ gasFees: await this.getCurrentMinFees(),
1212
+ skipFeeEnforcement,
1213
+ txsPermitted: !this.config.disableTransactions,
1214
+ },
1215
+ this.log.getBindings(),
1216
+ );
1225
1217
 
1226
1218
  return await validator.validateTx(tx);
1227
1219
  }
@@ -1385,13 +1377,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1385
1377
  }
1386
1378
  }
1387
1379
 
1388
- #getInitialHeaderHash(): Promise<L2BlockHash> {
1380
+ #getInitialHeaderHash(): Promise<BlockHash> {
1389
1381
  if (!this.initialHeaderHashPromise) {
1390
- this.initialHeaderHashPromise = this.worldStateSynchronizer
1391
- .getCommitted()
1392
- .getInitialHeader()
1393
- .hash()
1394
- .then(hash => L2BlockHash.fromField(hash));
1382
+ this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
1395
1383
  }
1396
1384
  return this.initialHeaderHashPromise;
1397
1385
  }
@@ -1415,15 +1403,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1415
1403
  return this.worldStateSynchronizer.getCommitted();
1416
1404
  }
1417
1405
 
1418
- if (L2BlockHash.isL2BlockHash(block)) {
1406
+ if (BlockHash.isBlockHash(block)) {
1419
1407
  const initialBlockHash = await this.#getInitialHeaderHash();
1420
1408
  if (block.equals(initialBlockHash)) {
1421
1409
  // Block source doesn't handle initial header so we need to handle the case separately.
1422
1410
  return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
1423
1411
  }
1424
1412
 
1425
- const blockHashFr = Fr.fromBuffer(block.toBuffer());
1426
- const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
1413
+ const header = await this.blockSource.getBlockHeaderByHash(block);
1427
1414
  if (!header) {
1428
1415
  throw new Error(
1429
1416
  `Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,
@@ -20,12 +20,7 @@ export async function createSentinel(
20
20
  if (!config.sentinelEnabled) {
21
21
  return undefined;
22
22
  }
23
- const kvStore = await createStore(
24
- 'sentinel',
25
- SentinelStore.SCHEMA_VERSION,
26
- config,
27
- createLogger('node:sentinel:lmdb'),
28
- );
23
+ const kvStore = await createStore('sentinel', SentinelStore.SCHEMA_VERSION, config, logger.getBindings());
29
24
  const storeHistoryLength = config.sentinelHistoryLengthInEpochs * epochCache.getL1Constants().epochDuration;
30
25
  const storeHistoricProvenPerformanceLength = config.sentinelHistoricProvenPerformanceLengthInEpochs;
31
26
  const sentinelStore = new SentinelStore(kvStore, {
@@ -128,7 +128,7 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
128
128
  return;
129
129
  }
130
130
  const blockNumber = event.block.number;
131
- const block = await this.archiver.getL2BlockNew(blockNumber);
131
+ const block = await this.archiver.getL2Block(blockNumber);
132
132
  if (!block) {
133
133
  this.logger.error(`Failed to get block ${blockNumber}`, { block });
134
134
  return;