@aztec/aztec-node 0.0.1-commit.4d79d1f2d → 0.0.1-commit.4d9804df
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/aztec-node/block_response_helpers.d.ts +25 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +112 -0
- package/dest/aztec-node/config.d.ts +23 -8
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +26 -8
- package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +351 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
- package/dest/aztec-node/server.d.ts +143 -135
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +496 -730
- package/dest/bin/index.js +15 -10
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +523 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/modules/block_parameter.d.ts +25 -0
- package/dest/modules/block_parameter.d.ts.map +1 -0
- package/dest/modules/block_parameter.js +100 -0
- package/dest/modules/node_block_provider.d.ts +19 -0
- package/dest/modules/node_block_provider.d.ts.map +1 -0
- package/dest/modules/node_block_provider.js +112 -0
- package/dest/modules/node_tx_receipt.d.ts +24 -0
- package/dest/modules/node_tx_receipt.d.ts.map +1 -0
- package/dest/modules/node_tx_receipt.js +70 -0
- package/dest/modules/node_world_state_queries.d.ts +65 -0
- package/dest/modules/node_world_state_queries.d.ts.map +1 -0
- package/dest/modules/node_world_state_queries.js +272 -0
- package/dest/sentinel/config.d.ts +3 -2
- package/dest/sentinel/config.d.ts.map +1 -1
- package/dest/sentinel/config.js +15 -5
- package/dest/sentinel/factory.d.ts +6 -4
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +12 -5
- package/dest/sentinel/sentinel.d.ts +146 -22
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +266 -118
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +33 -21
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +55 -16
- package/src/aztec-node/node_public_calls_simulator.ts +394 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
- package/src/aztec-node/server.ts +643 -939
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +688 -0
- package/src/index.ts +2 -0
- package/src/modules/block_parameter.ts +93 -0
- package/src/modules/node_block_provider.ts +149 -0
- package/src/modules/node_tx_receipt.ts +115 -0
- package/src/modules/node_world_state_queries.ts +374 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +22 -7
- package/src/sentinel/sentinel.ts +316 -136
- package/src/sentinel/store.ts +35 -27
- package/src/test/index.ts +2 -2
package/src/aztec-node/server.ts
CHANGED
|
@@ -1,42 +1,49 @@
|
|
|
1
|
-
import { Archiver
|
|
2
|
-
import { BBCircuitVerifier,
|
|
3
|
-
import {
|
|
1
|
+
import { Archiver } from '@aztec/archiver';
|
|
2
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
3
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
4
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
4
5
|
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
7
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
8
|
+
import { type L1ContractAddresses, pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
9
|
+
import {
|
|
10
|
+
BlockNumber,
|
|
11
|
+
CheckpointNumber,
|
|
12
|
+
type CheckpointProposalHash,
|
|
13
|
+
EpochNumber,
|
|
14
|
+
SlotNumber,
|
|
15
|
+
} from '@aztec/foundation/branded-types';
|
|
16
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
12
17
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
18
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
19
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
15
20
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
21
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
22
|
import { count } from '@aztec/foundation/string';
|
|
17
|
-
import {
|
|
23
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
18
24
|
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
|
|
19
25
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
createForwarderL1TxUtilsFromEthSigner,
|
|
23
|
-
createL1TxUtilsWithBlobsFromEthSigner,
|
|
24
|
-
} from '@aztec/node-lib/factories';
|
|
25
|
-
import { type P2P, type P2PClientDeps, createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
26
|
+
import { uploadSnapshot } from '@aztec/node-lib/actions';
|
|
27
|
+
import { type P2P, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
26
28
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type Watcher,
|
|
34
|
-
createSlasher,
|
|
35
|
-
} from '@aztec/slasher';
|
|
36
|
-
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
29
|
+
import type { ProverNode } from '@aztec/prover-node';
|
|
30
|
+
import { SequencerClient } from '@aztec/sequencer-client';
|
|
31
|
+
import { AutomineSequencer } from '@aztec/sequencer-client/automine';
|
|
32
|
+
import type { AvmSimulator } from '@aztec/simulator/server';
|
|
33
|
+
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
34
|
+
import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint';
|
|
37
35
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
38
|
-
import {
|
|
39
|
-
|
|
36
|
+
import {
|
|
37
|
+
type BlockData,
|
|
38
|
+
BlockHash,
|
|
39
|
+
type BlockParameter,
|
|
40
|
+
type CheckpointsQuery,
|
|
41
|
+
type DataInBlock,
|
|
42
|
+
type L2BlockSource,
|
|
43
|
+
type L2BlockTag,
|
|
44
|
+
type L2Tips,
|
|
45
|
+
inspectBlockParameter,
|
|
46
|
+
} from '@aztec/stdlib/block';
|
|
40
47
|
import type {
|
|
41
48
|
ContractClassPublic,
|
|
42
49
|
ContractDataSource,
|
|
@@ -44,16 +51,25 @@ import type {
|
|
|
44
51
|
NodeInfo,
|
|
45
52
|
ProtocolContractAddresses,
|
|
46
53
|
} from '@aztec/stdlib/contract';
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
55
|
+
import { GasFees, type ManaUsageEstimate, getNetworkTxGasLimits } from '@aztec/stdlib/gas';
|
|
56
|
+
import type {
|
|
57
|
+
AztecNode,
|
|
58
|
+
AztecNodeAdmin,
|
|
59
|
+
AztecNodeAdminConfig,
|
|
60
|
+
AztecNodeDebug,
|
|
61
|
+
BlockIncludeOptions,
|
|
62
|
+
BlockResponse,
|
|
63
|
+
BlocksIncludeOptions,
|
|
64
|
+
CheckpointIncludeOptions,
|
|
65
|
+
CheckpointParameter,
|
|
66
|
+
CheckpointResponse,
|
|
67
|
+
CheckpointTag,
|
|
68
|
+
GetTxByHashOptions,
|
|
69
|
+
PeerInfo,
|
|
70
|
+
ProposalsForSlot,
|
|
56
71
|
} from '@aztec/stdlib/interfaces/client';
|
|
72
|
+
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
57
73
|
import {
|
|
58
74
|
type AllowedElement,
|
|
59
75
|
type ClientProtocolCircuitVerifier,
|
|
@@ -63,24 +79,24 @@ import {
|
|
|
63
79
|
type WorldStateSynchronizer,
|
|
64
80
|
tryStop,
|
|
65
81
|
} from '@aztec/stdlib/interfaces/server';
|
|
66
|
-
import type {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import type {
|
|
70
|
-
import type {
|
|
82
|
+
import type { DebugLogStore, LogResult, PrivateLogsQuery, PublicLogsQuery } from '@aztec/stdlib/logs';
|
|
83
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
84
|
+
import type { L1ToL2MessageSource, L2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
85
|
+
import type { CheckpointAttestation } from '@aztec/stdlib/p2p';
|
|
86
|
+
import type { Offense } from '@aztec/stdlib/slashing';
|
|
71
87
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
72
88
|
import {
|
|
73
|
-
type
|
|
89
|
+
type FeeProvider,
|
|
90
|
+
type GetTxReceiptOptions,
|
|
74
91
|
type GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
75
92
|
type IndexedTxEffect,
|
|
76
93
|
PublicSimulationOutput,
|
|
94
|
+
type SimulationOverrides,
|
|
77
95
|
Tx,
|
|
78
96
|
type TxHash,
|
|
79
|
-
TxReceipt,
|
|
80
|
-
TxStatus,
|
|
97
|
+
type TxReceipt,
|
|
81
98
|
type TxValidationResult,
|
|
82
99
|
} from '@aztec/stdlib/tx';
|
|
83
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
84
100
|
import type { SingleValidatorStats, ValidatorsStats } from '@aztec/stdlib/validators';
|
|
85
101
|
import {
|
|
86
102
|
Attributes,
|
|
@@ -90,63 +106,182 @@ import {
|
|
|
90
106
|
getTelemetryClient,
|
|
91
107
|
trackSpan,
|
|
92
108
|
} from '@aztec/telemetry-client';
|
|
93
|
-
import {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
createBlockProposalHandler,
|
|
99
|
-
createValidatorClient,
|
|
100
|
-
createValidatorForAcceptingTxs,
|
|
101
|
-
} from '@aztec/validator-client';
|
|
102
|
-
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
103
|
-
|
|
104
|
-
import { createPublicClient, fallback, http } from 'viem';
|
|
105
|
-
|
|
106
|
-
import { createSentinel } from '../sentinel/factory.js';
|
|
109
|
+
import { NodeKeystoreAdapter, ValidatorClient } from '@aztec/validator-client';
|
|
110
|
+
|
|
111
|
+
import { NodeBlockProvider } from '../modules/node_block_provider.js';
|
|
112
|
+
import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
|
|
113
|
+
import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
|
|
107
114
|
import { Sentinel } from '../sentinel/sentinel.js';
|
|
108
|
-
import {
|
|
115
|
+
import type { AztecNodeConfig } from './config.js';
|
|
109
116
|
import { NodeMetrics } from './node_metrics.js';
|
|
117
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Fully-constructed collaborators and settings an {@link AztecNodeService} owns. Built by `createAztecNodeService`
|
|
121
|
+
* (see `factory.ts`); passed as a single object so call sites name each dependency instead of relying on
|
|
122
|
+
* positional order.
|
|
123
|
+
*/
|
|
124
|
+
export interface AztecNodeServiceDeps {
|
|
125
|
+
config: AztecNodeConfig;
|
|
126
|
+
p2pClient: P2P;
|
|
127
|
+
blockSource: L2BlockSource & Partial<Service>;
|
|
128
|
+
logsSource: L2LogsSource;
|
|
129
|
+
contractDataSource: ContractDataSource;
|
|
130
|
+
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
131
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
132
|
+
sequencer: SequencerClient | undefined;
|
|
133
|
+
proverNode: ProverNode | undefined;
|
|
134
|
+
slasherClient: SlasherClientInterface | undefined;
|
|
135
|
+
validatorsSentinel: Sentinel | undefined;
|
|
136
|
+
stopStartedWatchers: () => Promise<void>;
|
|
137
|
+
l1ChainId: number;
|
|
138
|
+
version: number;
|
|
139
|
+
globalVariableBuilder: GlobalVariableBuilderInterface;
|
|
140
|
+
rollupContract: RollupContract | undefined;
|
|
141
|
+
feeProvider: FeeProvider;
|
|
142
|
+
epochCache: EpochCacheInterface;
|
|
143
|
+
packageVersion: string;
|
|
144
|
+
peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
145
|
+
rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
146
|
+
telemetry?: TelemetryClient;
|
|
147
|
+
log?: Logger;
|
|
148
|
+
blobClient?: BlobClientInterface;
|
|
149
|
+
validatorClient?: ValidatorClient;
|
|
150
|
+
keyStoreManager?: KeystoreManager;
|
|
151
|
+
debugLogStore?: DebugLogStore;
|
|
152
|
+
automineSequencer?: AutomineSequencer;
|
|
153
|
+
// AVM execution backend for public simulation. Wired in production (factory.ts); absent in unit/TXE nodes
|
|
154
|
+
// that don't drive public execution, hence optional and asserted at the simulation call site. Owned by the
|
|
155
|
+
// node (disposed on stop), so it must be disposable — a spawned process pool + CDB IPC server.
|
|
156
|
+
avmSimulator?: AvmSimulator & AsyncDisposable;
|
|
157
|
+
}
|
|
110
158
|
|
|
111
159
|
/**
|
|
112
160
|
* The aztec node.
|
|
113
161
|
*/
|
|
114
|
-
export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
162
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
115
163
|
private metrics: NodeMetrics;
|
|
116
|
-
private initialHeaderHashPromise: Promise<BlockHash> | undefined = undefined;
|
|
117
|
-
|
|
118
164
|
// Prevent two snapshot operations to happen simultaneously
|
|
119
165
|
private isUploadingSnapshot = false;
|
|
166
|
+
// Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
|
|
167
|
+
private sequencerPausedMinTxsPerBlock: number | undefined;
|
|
168
|
+
private readonly nodePublicCallsSimulator: NodePublicCallsSimulator;
|
|
169
|
+
private readonly worldStateQueries: NodeWorldStateQueries;
|
|
170
|
+
private readonly blockProvider: NodeBlockProvider;
|
|
171
|
+
private readonly txReceiptBuilder: NodeTxReceiptBuilder;
|
|
120
172
|
|
|
121
173
|
public readonly tracer: Tracer;
|
|
122
174
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
175
|
+
protected config: AztecNodeConfig;
|
|
176
|
+
protected readonly p2pClient: P2P;
|
|
177
|
+
protected readonly blockSource: L2BlockSource & Partial<Service>;
|
|
178
|
+
protected readonly logsSource: L2LogsSource;
|
|
179
|
+
protected readonly contractDataSource: ContractDataSource;
|
|
180
|
+
protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
|
|
181
|
+
protected readonly worldStateSynchronizer: WorldStateSynchronizer;
|
|
182
|
+
protected readonly sequencer: SequencerClient | undefined;
|
|
183
|
+
protected readonly proverNode: ProverNode | undefined;
|
|
184
|
+
protected readonly slasherClient: SlasherClientInterface | undefined;
|
|
185
|
+
protected readonly validatorsSentinel: Sentinel | undefined;
|
|
186
|
+
private readonly stopStartedWatchers: () => Promise<void>;
|
|
187
|
+
protected readonly l1ChainId: number;
|
|
188
|
+
protected readonly version: number;
|
|
189
|
+
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface;
|
|
190
|
+
protected readonly rollupContract: RollupContract | undefined;
|
|
191
|
+
protected readonly feeProvider: FeeProvider;
|
|
192
|
+
protected readonly epochCache: EpochCacheInterface;
|
|
193
|
+
protected readonly packageVersion: string;
|
|
194
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
195
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
196
|
+
private telemetry: TelemetryClient;
|
|
197
|
+
private log: Logger;
|
|
198
|
+
private blobClient?: BlobClientInterface;
|
|
199
|
+
private validatorClient?: ValidatorClient;
|
|
200
|
+
private keyStoreManager?: KeystoreManager;
|
|
201
|
+
private debugLogStore: DebugLogStore;
|
|
202
|
+
private readonly automineSequencer?: AutomineSequencer;
|
|
203
|
+
private readonly avmSimulator?: AvmSimulator & AsyncDisposable;
|
|
204
|
+
|
|
205
|
+
constructor(deps: AztecNodeServiceDeps) {
|
|
206
|
+
this.config = deps.config;
|
|
207
|
+
this.p2pClient = deps.p2pClient;
|
|
208
|
+
this.blockSource = deps.blockSource;
|
|
209
|
+
this.logsSource = deps.logsSource;
|
|
210
|
+
this.contractDataSource = deps.contractDataSource;
|
|
211
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
212
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
213
|
+
this.sequencer = deps.sequencer;
|
|
214
|
+
this.proverNode = deps.proverNode;
|
|
215
|
+
this.slasherClient = deps.slasherClient;
|
|
216
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
217
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
218
|
+
this.l1ChainId = deps.l1ChainId;
|
|
219
|
+
this.version = deps.version;
|
|
220
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
221
|
+
this.rollupContract = deps.rollupContract;
|
|
222
|
+
this.feeProvider = deps.feeProvider;
|
|
223
|
+
this.epochCache = deps.epochCache;
|
|
224
|
+
this.packageVersion = deps.packageVersion;
|
|
225
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
226
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
227
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
228
|
+
this.log = deps.log ?? createLogger('node');
|
|
229
|
+
this.blobClient = deps.blobClient;
|
|
230
|
+
this.validatorClient = deps.validatorClient;
|
|
231
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
232
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
233
|
+
this.automineSequencer = deps.automineSequencer;
|
|
234
|
+
this.avmSimulator = deps.avmSimulator;
|
|
235
|
+
|
|
236
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
237
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
238
|
+
|
|
239
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
240
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
241
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
242
|
+
blockSource: this.blockSource,
|
|
243
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
244
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
245
|
+
contractDataSource: this.contractDataSource,
|
|
246
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
247
|
+
rollupContract: this.rollupContract,
|
|
248
|
+
epochCache: this.epochCache,
|
|
249
|
+
signatureContext: { chainId: this.l1ChainId, rollupAddress: this.config.rollupAddress },
|
|
250
|
+
config: this.config,
|
|
251
|
+
avmSimulator: this.avmSimulator,
|
|
252
|
+
telemetry: this.telemetry,
|
|
253
|
+
log: this.log.createChild('public-calls-simulator'),
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
257
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
258
|
+
blockSource: this.blockSource,
|
|
259
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
260
|
+
log: this.log.createChild('world-state-queries'),
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
264
|
+
|
|
265
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
266
|
+
p2pClient: this.p2pClient,
|
|
267
|
+
blockSource: this.blockSource,
|
|
268
|
+
debugLogStore: this.debugLogStore,
|
|
269
|
+
});
|
|
147
270
|
|
|
148
271
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
149
|
-
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config
|
|
272
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
273
|
+
|
|
274
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
275
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
276
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
277
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
278
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
283
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
284
|
+
return this.rpcProofVerifier;
|
|
150
285
|
}
|
|
151
286
|
|
|
152
287
|
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
@@ -154,342 +289,82 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
154
289
|
return status.syncSummary;
|
|
155
290
|
}
|
|
156
291
|
|
|
157
|
-
public
|
|
292
|
+
public getChainTips(): Promise<L2Tips> {
|
|
158
293
|
return this.blockSource.getL2Tips();
|
|
159
294
|
}
|
|
160
295
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* @returns - A fully synced Aztec Node for use in development/testing.
|
|
165
|
-
*/
|
|
166
|
-
public static async createAndSync(
|
|
167
|
-
inputConfig: AztecNodeConfig,
|
|
168
|
-
deps: {
|
|
169
|
-
telemetry?: TelemetryClient;
|
|
170
|
-
logger?: Logger;
|
|
171
|
-
publisher?: SequencerPublisher;
|
|
172
|
-
dateProvider?: DateProvider;
|
|
173
|
-
p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
|
|
174
|
-
} = {},
|
|
175
|
-
options: {
|
|
176
|
-
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
177
|
-
dontStartSequencer?: boolean;
|
|
178
|
-
} = {},
|
|
179
|
-
): Promise<AztecNodeService> {
|
|
180
|
-
const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
|
|
181
|
-
const log = deps.logger ?? createLogger('node');
|
|
182
|
-
const packageVersion = getPackageVersion() ?? '';
|
|
183
|
-
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
184
|
-
const dateProvider = deps.dateProvider ?? new DateProvider();
|
|
185
|
-
const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
186
|
-
|
|
187
|
-
// Build a key store from file if given or from environment otherwise
|
|
188
|
-
let keyStoreManager: KeystoreManager | undefined;
|
|
189
|
-
const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
|
|
190
|
-
if (keyStoreProvided) {
|
|
191
|
-
const keyStores = loadKeystores(config.keyStoreDirectory!);
|
|
192
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
193
|
-
} else {
|
|
194
|
-
const keyStore = createKeyStoreForValidator(config);
|
|
195
|
-
if (keyStore) {
|
|
196
|
-
keyStoreManager = new KeystoreManager(keyStore);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
await keyStoreManager?.validateSigners();
|
|
201
|
-
|
|
202
|
-
// If we are a validator, verify our configuration before doing too much more.
|
|
203
|
-
if (!config.disableValidator) {
|
|
204
|
-
if (keyStoreManager === undefined) {
|
|
205
|
-
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
206
|
-
}
|
|
207
|
-
if (!keyStoreProvided) {
|
|
208
|
-
log.warn(
|
|
209
|
-
'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// validate that the actual chain id matches that specified in configuration
|
|
216
|
-
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
217
|
-
throw new Error(
|
|
218
|
-
`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`,
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const publicClient = createPublicClient({
|
|
223
|
-
chain: ethereumChain.chainInfo,
|
|
224
|
-
transport: fallback(config.l1RpcUrls.map((url: string) => http(url, { batch: false }))),
|
|
225
|
-
pollingInterval: config.viemPollingIntervalMS,
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
const l1ContractsAddresses = await RegistryContract.collectAddresses(
|
|
229
|
-
publicClient,
|
|
230
|
-
config.l1Contracts.registryAddress,
|
|
231
|
-
config.rollupVersion ?? 'canonical',
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// Overwrite the passed in vars.
|
|
235
|
-
config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
|
|
236
|
-
|
|
237
|
-
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
238
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
|
|
239
|
-
rollupContract.getL1GenesisTime(),
|
|
240
|
-
rollupContract.getSlotDuration(),
|
|
241
|
-
rollupContract.getVersion(),
|
|
242
|
-
] as const);
|
|
243
|
-
|
|
244
|
-
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
245
|
-
|
|
246
|
-
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
247
|
-
log.warn(
|
|
248
|
-
`Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`,
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
|
|
253
|
-
|
|
254
|
-
// attempt snapshot sync if possible
|
|
255
|
-
await trySnapshotSync(config, log);
|
|
256
|
-
|
|
257
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, { dateProvider });
|
|
258
|
-
|
|
259
|
-
const archiver = await createArchiver(
|
|
260
|
-
config,
|
|
261
|
-
{ blobClient, epochCache, telemetry, dateProvider },
|
|
262
|
-
{ blockUntilSync: !config.skipArchiverInitialSync },
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
// now create the merkle trees and the world state synchronizer
|
|
266
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(
|
|
267
|
-
config,
|
|
268
|
-
archiver,
|
|
269
|
-
options.prefilledPublicData,
|
|
270
|
-
telemetry,
|
|
271
|
-
);
|
|
272
|
-
const circuitVerifier =
|
|
273
|
-
config.realProofs || config.debugForceTxProofVerification
|
|
274
|
-
? await BBCircuitVerifier.new(config)
|
|
275
|
-
: new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
276
|
-
if (!config.realProofs) {
|
|
277
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
278
|
-
}
|
|
279
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
280
|
-
|
|
281
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
282
|
-
const p2pClient = await createP2PClient(
|
|
283
|
-
P2PClientType.Full,
|
|
284
|
-
config,
|
|
285
|
-
archiver,
|
|
286
|
-
proofVerifier,
|
|
287
|
-
worldStateSynchronizer,
|
|
288
|
-
epochCache,
|
|
289
|
-
packageVersion,
|
|
290
|
-
dateProvider,
|
|
291
|
-
telemetry,
|
|
292
|
-
deps.p2pClientDeps,
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
// We should really not be modifying the config object
|
|
296
|
-
config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
297
|
-
|
|
298
|
-
// Create FullNodeCheckpointsBuilder for validator and non-validator block proposal handling
|
|
299
|
-
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
|
|
300
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
301
|
-
worldStateSynchronizer,
|
|
302
|
-
archiver,
|
|
303
|
-
dateProvider,
|
|
304
|
-
telemetry,
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
// We'll accumulate sentinel watchers here
|
|
308
|
-
const watchers: Watcher[] = [];
|
|
309
|
-
|
|
310
|
-
// Create validator client if required
|
|
311
|
-
const validatorClient = await createValidatorClient(config, {
|
|
312
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
313
|
-
worldState: worldStateSynchronizer,
|
|
314
|
-
p2pClient,
|
|
315
|
-
telemetry,
|
|
316
|
-
dateProvider,
|
|
317
|
-
epochCache,
|
|
318
|
-
blockSource: archiver,
|
|
319
|
-
l1ToL2MessageSource: archiver,
|
|
320
|
-
keyStoreManager,
|
|
321
|
-
blobClient,
|
|
322
|
-
});
|
|
296
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
297
|
+
return this.blockSource.getL1Constants();
|
|
298
|
+
}
|
|
323
299
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (validatorClient) {
|
|
328
|
-
watchers.push(validatorClient);
|
|
329
|
-
if (!options.dontStartSequencer) {
|
|
330
|
-
await validatorClient.registerHandlers();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
300
|
+
public getSyncedL2SlotNumber() {
|
|
301
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
302
|
+
}
|
|
333
303
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
log.info('Setting up block proposal reexecution for monitoring');
|
|
338
|
-
createBlockProposalHandler(config, {
|
|
339
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
340
|
-
worldState: worldStateSynchronizer,
|
|
341
|
-
epochCache,
|
|
342
|
-
blockSource: archiver,
|
|
343
|
-
l1ToL2MessageSource: archiver,
|
|
344
|
-
p2pClient,
|
|
345
|
-
dateProvider,
|
|
346
|
-
telemetry,
|
|
347
|
-
}).registerForReexecution(p2pClient);
|
|
348
|
-
}
|
|
304
|
+
public getSyncedL2EpochNumber() {
|
|
305
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
306
|
+
}
|
|
349
307
|
|
|
350
|
-
|
|
351
|
-
|
|
308
|
+
public getSyncedL1Timestamp() {
|
|
309
|
+
return this.blockSource.getL1Timestamp();
|
|
310
|
+
}
|
|
352
311
|
|
|
353
|
-
|
|
354
|
-
|
|
312
|
+
public getCheckpointsData(query: CheckpointsQuery) {
|
|
313
|
+
return this.blockSource.getCheckpointsData(query);
|
|
314
|
+
}
|
|
355
315
|
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
316
|
+
public async getBlockNumber(tip?: L2BlockTag): Promise<BlockNumber> {
|
|
317
|
+
if (tip === undefined || tip === 'proposed') {
|
|
318
|
+
return this.blockSource.getBlockNumber();
|
|
359
319
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
320
|
+
return (await this.blockSource.getBlockNumber({ tag: tip })) ?? BlockNumber.ZERO;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
public async getCheckpointNumber(tip?: CheckpointTag): Promise<CheckpointNumber> {
|
|
324
|
+
const tips = await this.blockSource.getL2Tips();
|
|
325
|
+
switch (tip) {
|
|
326
|
+
case undefined:
|
|
327
|
+
case 'checkpointed':
|
|
328
|
+
return tips.checkpointed.checkpoint.number;
|
|
329
|
+
case 'proven':
|
|
330
|
+
return tips.proven.checkpoint.number;
|
|
331
|
+
case 'finalized':
|
|
332
|
+
return tips.finalized.checkpoint.number;
|
|
372
333
|
}
|
|
334
|
+
}
|
|
373
335
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// Start p2p-related services once the archiver has completed sync
|
|
382
|
-
void archiver
|
|
383
|
-
.waitForInitialSync()
|
|
384
|
-
.then(async () => {
|
|
385
|
-
await p2pClient.start();
|
|
386
|
-
await validatorsSentinel?.start();
|
|
387
|
-
await epochPruneWatcher?.start();
|
|
388
|
-
await attestationsBlockWatcher?.start();
|
|
389
|
-
log.info(`All p2p services started`);
|
|
390
|
-
})
|
|
391
|
-
.catch(err => log.error('Failed to start p2p services after archiver sync', err));
|
|
392
|
-
|
|
393
|
-
// Validator enabled, create/start relevant service
|
|
394
|
-
let sequencer: SequencerClient | undefined;
|
|
395
|
-
let slasherClient: SlasherClientInterface | undefined;
|
|
396
|
-
if (!config.disableValidator && validatorClient) {
|
|
397
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
398
|
-
// as they are executed when the node is selected as proposer.
|
|
399
|
-
const validatorAddresses = keyStoreManager
|
|
400
|
-
? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses()
|
|
401
|
-
: [];
|
|
402
|
-
|
|
403
|
-
slasherClient = await createSlasher(
|
|
404
|
-
config,
|
|
405
|
-
config.l1Contracts,
|
|
406
|
-
getPublicClient(config),
|
|
407
|
-
watchers,
|
|
408
|
-
dateProvider,
|
|
409
|
-
epochCache,
|
|
410
|
-
validatorAddresses,
|
|
411
|
-
undefined, // logger
|
|
412
|
-
);
|
|
413
|
-
await slasherClient.start();
|
|
414
|
-
|
|
415
|
-
const l1TxUtils = config.publisherForwarderAddress
|
|
416
|
-
? await createForwarderL1TxUtilsFromEthSigner(
|
|
417
|
-
publicClient,
|
|
418
|
-
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
419
|
-
config.publisherForwarderAddress,
|
|
420
|
-
{ ...config, scope: 'sequencer' },
|
|
421
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
422
|
-
)
|
|
423
|
-
: await createL1TxUtilsWithBlobsFromEthSigner(
|
|
424
|
-
publicClient,
|
|
425
|
-
keyStoreManager!.createAllValidatorPublisherSigners(),
|
|
426
|
-
{ ...config, scope: 'sequencer' },
|
|
427
|
-
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
// Create and start the sequencer client
|
|
431
|
-
const checkpointsBuilder = new CheckpointsBuilder(
|
|
432
|
-
{ ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
|
|
433
|
-
worldStateSynchronizer,
|
|
434
|
-
archiver,
|
|
435
|
-
dateProvider,
|
|
436
|
-
telemetry,
|
|
437
|
-
);
|
|
336
|
+
public getBlock<Opts extends BlockIncludeOptions = {}>(
|
|
337
|
+
param: BlockParameter,
|
|
338
|
+
options: Opts = {} as Opts,
|
|
339
|
+
): Promise<BlockResponse<Opts> | undefined> {
|
|
340
|
+
return this.blockProvider.getBlock(param, options);
|
|
341
|
+
}
|
|
438
342
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
l1TxUtils,
|
|
443
|
-
validatorClient,
|
|
444
|
-
p2pClient,
|
|
445
|
-
worldStateSynchronizer,
|
|
446
|
-
slasherClient,
|
|
447
|
-
checkpointsBuilder,
|
|
448
|
-
l2BlockSource: archiver,
|
|
449
|
-
l1ToL2MessageSource: archiver,
|
|
450
|
-
telemetry,
|
|
451
|
-
dateProvider,
|
|
452
|
-
blobClient,
|
|
453
|
-
nodeKeyStore: keyStoreManager!,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
343
|
+
public getBlockData(param: BlockParameter): Promise<BlockData | undefined> {
|
|
344
|
+
return this.blockProvider.getBlockData(param);
|
|
345
|
+
}
|
|
456
346
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
347
|
+
public getBlocks<Opts extends BlocksIncludeOptions = {}>(
|
|
348
|
+
from: BlockNumber,
|
|
349
|
+
limit: number,
|
|
350
|
+
options: Opts = {} as Opts,
|
|
351
|
+
): Promise<BlockResponse<Opts>[]> {
|
|
352
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
353
|
+
}
|
|
463
354
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
355
|
+
public getCheckpoint<Opts extends CheckpointIncludeOptions = {}>(
|
|
356
|
+
param: CheckpointParameter,
|
|
357
|
+
options: Opts = {} as Opts,
|
|
358
|
+
): Promise<CheckpointResponse<Opts> | undefined> {
|
|
359
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
360
|
+
}
|
|
470
361
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
archiver,
|
|
478
|
-
worldStateSynchronizer,
|
|
479
|
-
sequencer,
|
|
480
|
-
slasherClient,
|
|
481
|
-
validatorsSentinel,
|
|
482
|
-
epochPruneWatcher,
|
|
483
|
-
ethereumChain.chainInfo.id,
|
|
484
|
-
config.rollupVersion,
|
|
485
|
-
globalVariableBuilder,
|
|
486
|
-
epochCache,
|
|
487
|
-
packageVersion,
|
|
488
|
-
proofVerifier,
|
|
489
|
-
telemetry,
|
|
490
|
-
log,
|
|
491
|
-
blobClient,
|
|
492
|
-
);
|
|
362
|
+
public getCheckpoints<Opts extends CheckpointIncludeOptions = {}>(
|
|
363
|
+
from: CheckpointNumber,
|
|
364
|
+
limit: number,
|
|
365
|
+
options: Opts = {} as Opts,
|
|
366
|
+
): Promise<CheckpointResponse<Opts>[]> {
|
|
367
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
493
368
|
}
|
|
494
369
|
|
|
495
370
|
/**
|
|
@@ -500,6 +375,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
500
375
|
return this.sequencer;
|
|
501
376
|
}
|
|
502
377
|
|
|
378
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */
|
|
379
|
+
public getAutomineSequencer(): AutomineSequencer | undefined {
|
|
380
|
+
return this.automineSequencer;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
384
|
+
public getProverNode(): ProverNode | undefined {
|
|
385
|
+
return this.proverNode;
|
|
386
|
+
}
|
|
387
|
+
|
|
503
388
|
public getBlockSource(): L2BlockSource {
|
|
504
389
|
return this.blockSource;
|
|
505
390
|
}
|
|
@@ -517,7 +402,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
517
402
|
* @returns - The currently deployed L1 contract addresses.
|
|
518
403
|
*/
|
|
519
404
|
public getL1ContractAddresses(): Promise<L1ContractAddresses> {
|
|
520
|
-
return Promise.resolve(this.config
|
|
405
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
521
406
|
}
|
|
522
407
|
|
|
523
408
|
public getEncodedEnr(): Promise<string | undefined> {
|
|
@@ -525,7 +410,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
525
410
|
}
|
|
526
411
|
|
|
527
412
|
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
528
|
-
return this.config.
|
|
413
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
529
414
|
}
|
|
530
415
|
|
|
531
416
|
/**
|
|
@@ -537,14 +422,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
537
422
|
}
|
|
538
423
|
|
|
539
424
|
public async getNodeInfo(): Promise<NodeInfo> {
|
|
540
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
425
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] =
|
|
426
|
+
await Promise.all([
|
|
427
|
+
this.getNodeVersion(),
|
|
428
|
+
this.getVersion(),
|
|
429
|
+
this.getChainId(),
|
|
430
|
+
this.getEncodedEnr(),
|
|
431
|
+
this.getL1ContractAddresses(),
|
|
432
|
+
this.getProtocolContractAddresses(),
|
|
433
|
+
this.blockSource.getL1Constants(),
|
|
434
|
+
]);
|
|
435
|
+
|
|
436
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
437
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
438
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
439
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
440
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
548
441
|
|
|
549
442
|
const nodeInfo: NodeInfo = {
|
|
550
443
|
nodeVersion,
|
|
@@ -554,104 +447,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
554
447
|
l1ContractAddresses: contractAddresses,
|
|
555
448
|
protocolContractAddresses: protocolContractAddresses,
|
|
556
449
|
realProofs: !!this.config.realProofs,
|
|
450
|
+
txsLimits: { gas: { daGas: maxTxGas.daGas, l2Gas: maxTxGas.l2Gas } },
|
|
557
451
|
};
|
|
558
452
|
|
|
559
453
|
return nodeInfo;
|
|
560
454
|
}
|
|
561
455
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
565
|
-
* @returns The requested block.
|
|
566
|
-
*/
|
|
567
|
-
public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
|
|
568
|
-
if (BlockHash.isBlockHash(block)) {
|
|
569
|
-
return this.getBlockByHash(block);
|
|
570
|
-
}
|
|
571
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
572
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
573
|
-
return this.buildInitialBlock();
|
|
574
|
-
}
|
|
575
|
-
return await this.blockSource.getL2Block(blockNumber);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Get a block specified by its hash.
|
|
580
|
-
* @param blockHash - The block hash being requested.
|
|
581
|
-
* @returns The requested block.
|
|
582
|
-
*/
|
|
583
|
-
public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
584
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
585
|
-
if (blockHash.equals(initialBlockHash)) {
|
|
586
|
-
return this.buildInitialBlock();
|
|
587
|
-
}
|
|
588
|
-
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
private buildInitialBlock(): L2Block {
|
|
592
|
-
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
593
|
-
return L2Block.empty(initialHeader);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Get a block specified by its archive root.
|
|
598
|
-
* @param archive - The archive root being requested.
|
|
599
|
-
* @returns The requested block.
|
|
600
|
-
*/
|
|
601
|
-
public async getBlockByArchive(archive: Fr): Promise<L2Block | undefined> {
|
|
602
|
-
return await this.blockSource.getL2BlockByArchive(archive);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
607
|
-
* @param from - The start of the range of blocks to return.
|
|
608
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
609
|
-
* @returns The blocks requested.
|
|
610
|
-
*/
|
|
611
|
-
public async getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
|
|
612
|
-
return (await this.blockSource.getBlocks(from, BlockNumber(limit))) ?? [];
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
public async getCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
|
|
616
|
-
return (await this.blockSource.getCheckpoints(from, limit)) ?? [];
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
public async getCheckpointedBlocks(from: BlockNumber, limit: number) {
|
|
620
|
-
return (await this.blockSource.getCheckpointedBlocks(from, limit)) ?? [];
|
|
456
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
457
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
621
458
|
}
|
|
622
459
|
|
|
623
|
-
/**
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
*/
|
|
627
|
-
public async getCurrentMinFees(): Promise<GasFees> {
|
|
628
|
-
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
460
|
+
/** Returns predicted min fees for the current slot and next N slots. */
|
|
461
|
+
public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
462
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
629
463
|
}
|
|
630
464
|
|
|
631
465
|
public async getMaxPriorityFees(): Promise<GasFees> {
|
|
632
|
-
for await (const tx of this.p2pClient.iteratePendingTxs()) {
|
|
466
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({ includeProof: false })) {
|
|
633
467
|
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
634
468
|
}
|
|
635
469
|
|
|
636
470
|
return GasFees.from({ feePerDaGas: 0n, feePerL2Gas: 0n });
|
|
637
471
|
}
|
|
638
472
|
|
|
639
|
-
/**
|
|
640
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
641
|
-
* @returns The block number.
|
|
642
|
-
*/
|
|
643
|
-
public async getBlockNumber(): Promise<BlockNumber> {
|
|
644
|
-
return await this.blockSource.getBlockNumber();
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
public async getProvenBlockNumber(): Promise<BlockNumber> {
|
|
648
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
public async getCheckpointedBlockNumber(): Promise<BlockNumber> {
|
|
652
|
-
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
653
|
-
}
|
|
654
|
-
|
|
655
473
|
/**
|
|
656
474
|
* Method to fetch the version of the package.
|
|
657
475
|
* @returns The node package version
|
|
@@ -680,65 +498,25 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
680
498
|
return this.contractDataSource.getContractClass(id);
|
|
681
499
|
}
|
|
682
500
|
|
|
683
|
-
public getContract(
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
-
}
|
|
703
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
public async getPublicLogsByTagsFromContract(
|
|
707
|
-
contractAddress: AztecAddress,
|
|
708
|
-
tags: Tag[],
|
|
709
|
-
page?: number,
|
|
710
|
-
referenceBlock?: BlockHash,
|
|
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
|
-
}
|
|
501
|
+
public async getContract(
|
|
502
|
+
address: AztecAddress,
|
|
503
|
+
referenceBlock: BlockParameter = 'latest',
|
|
504
|
+
): Promise<ContractInstanceWithAddress | undefined> {
|
|
505
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
506
|
+
if (!blockData) {
|
|
507
|
+
throw new Error(
|
|
508
|
+
`Reference block ${inspectBlockParameter(referenceBlock)} not found when querying contract ${address}. If the node API has been queried with an anchor block hash, possibly a reorg has occurred.`,
|
|
509
|
+
);
|
|
722
510
|
}
|
|
723
|
-
return this.
|
|
511
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
724
512
|
}
|
|
725
513
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
* @param filter - The filter to apply to the logs.
|
|
729
|
-
* @returns The requested logs.
|
|
730
|
-
*/
|
|
731
|
-
getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
732
|
-
return this.logsSource.getPublicLogs(filter);
|
|
514
|
+
public getPrivateLogsByTags(query: PrivateLogsQuery): Promise<LogResult[][]> {
|
|
515
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
733
516
|
}
|
|
734
517
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
* @param filter - The filter to apply to the logs.
|
|
738
|
-
* @returns The requested logs.
|
|
739
|
-
*/
|
|
740
|
-
getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
741
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
518
|
+
public getPublicLogsByTags(query: PublicLogsQuery): Promise<LogResult[][]> {
|
|
519
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
742
520
|
}
|
|
743
521
|
|
|
744
522
|
/**
|
|
@@ -761,32 +539,23 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
761
539
|
throw new Error(`Invalid tx: ${reason}`);
|
|
762
540
|
}
|
|
763
541
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
542
|
+
try {
|
|
543
|
+
await this.p2pClient!.sendTx(tx);
|
|
544
|
+
} catch (err) {
|
|
545
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
546
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${(err as Error).message}`, { txHash });
|
|
547
|
+
throw err;
|
|
548
|
+
}
|
|
549
|
+
const duration = timer.ms();
|
|
550
|
+
this.metrics.receivedTx(duration, true);
|
|
551
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
767
552
|
}
|
|
768
553
|
|
|
769
|
-
public
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
776
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
777
|
-
|
|
778
|
-
if (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');
|
|
789
|
-
}
|
|
554
|
+
public getTxReceipt<TGetTxReceiptOptions extends GetTxReceiptOptions = {}>(
|
|
555
|
+
txHash: TxHash,
|
|
556
|
+
options?: TGetTxReceiptOptions,
|
|
557
|
+
): Promise<TxReceipt<TGetTxReceiptOptions>> {
|
|
558
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
790
559
|
}
|
|
791
560
|
|
|
792
561
|
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
@@ -798,12 +567,17 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
798
567
|
*/
|
|
799
568
|
public async stop() {
|
|
800
569
|
this.log.info(`Stopping Aztec Node`);
|
|
801
|
-
await
|
|
802
|
-
await tryStop(this.epochPruneWatcher);
|
|
570
|
+
await this.stopStartedWatchers();
|
|
803
571
|
await tryStop(this.slasherClient);
|
|
804
|
-
await tryStop(this.
|
|
572
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
805
573
|
await tryStop(this.sequencer);
|
|
574
|
+
await tryStop(this.automineSequencer);
|
|
575
|
+
await tryStop(this.proverNode);
|
|
806
576
|
await tryStop(this.p2pClient);
|
|
577
|
+
// Dispose the AVM backend before world state: it kills the bb-avm-sim processes and closes the CDB IPC
|
|
578
|
+
// server, releasing their connections to the WSDB so it shuts down cleanly (and freeing the
|
|
579
|
+
// Server/Socket/ChildProcess handles that would otherwise keep the process alive after teardown).
|
|
580
|
+
await this.avmSimulator?.[Symbol.asyncDispose]();
|
|
807
581
|
await tryStop(this.worldStateSynchronizer);
|
|
808
582
|
await tryStop(this.blockSource);
|
|
809
583
|
await tryStop(this.blobClient);
|
|
@@ -825,367 +599,146 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
825
599
|
* @param after - The last known pending tx. Used for pagination
|
|
826
600
|
* @returns - The pending txs.
|
|
827
601
|
*/
|
|
828
|
-
public getPendingTxs(limit?: number, after?: TxHash): Promise<Tx[]> {
|
|
829
|
-
return this.p2pClient!.getPendingTxs(limit, after);
|
|
602
|
+
public getPendingTxs(limit?: number, after?: TxHash, options?: GetTxByHashOptions): Promise<Tx[]> {
|
|
603
|
+
return this.p2pClient!.getPendingTxs(limit, after, options);
|
|
830
604
|
}
|
|
831
605
|
|
|
832
606
|
public getPendingTxCount(): Promise<number> {
|
|
833
607
|
return this.p2pClient!.getPendingTxCount();
|
|
834
608
|
}
|
|
835
609
|
|
|
610
|
+
public getPeers(includePending?: boolean): Promise<PeerInfo[]> {
|
|
611
|
+
return this.p2pClient!.getPeers(includePending);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
public getCheckpointAttestationsForSlot(
|
|
615
|
+
slot: SlotNumber,
|
|
616
|
+
proposalPayloadHash?: CheckpointProposalHash,
|
|
617
|
+
): Promise<CheckpointAttestation[]> {
|
|
618
|
+
return this.p2pClient!.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
public getProposalsForSlot(slot: SlotNumber): Promise<ProposalsForSlot> {
|
|
622
|
+
return this.p2pClient!.getProposalsForSlot(slot);
|
|
623
|
+
}
|
|
624
|
+
|
|
836
625
|
/**
|
|
837
|
-
* Method to retrieve a single tx from the mempool or unfinalized chain.
|
|
626
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
627
|
+
* when `includeProof` is set.
|
|
838
628
|
* @param txHash - The transaction hash to return.
|
|
629
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
839
630
|
* @returns - The tx if it exists.
|
|
840
631
|
*/
|
|
841
|
-
public getTxByHash(txHash: TxHash): Promise<Tx | undefined> {
|
|
842
|
-
return
|
|
632
|
+
public getTxByHash(txHash: TxHash, options?: GetTxByHashOptions): Promise<Tx | undefined> {
|
|
633
|
+
return this.p2pClient!.getTxByHashFromPool(txHash, { includeProof: !!options?.includeProof });
|
|
843
634
|
}
|
|
844
635
|
|
|
845
636
|
/**
|
|
846
|
-
* Method to retrieve txs from the mempool or unfinalized chain.
|
|
637
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
638
|
+
* `includeProof` is set.
|
|
847
639
|
* @param txHash - The transaction hash to return.
|
|
640
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
848
641
|
* @returns - The txs if it exists.
|
|
849
642
|
*/
|
|
850
|
-
public async getTxsByHash(txHashes: TxHash[]): Promise<Tx[]> {
|
|
851
|
-
|
|
643
|
+
public async getTxsByHash(txHashes: TxHash[], options?: GetTxByHashOptions): Promise<Tx[]> {
|
|
644
|
+
const txs = await this.p2pClient!.getTxsByHashFromPool(txHashes, { includeProof: !!options?.includeProof });
|
|
645
|
+
return compactArray(txs);
|
|
852
646
|
}
|
|
853
647
|
|
|
854
|
-
public
|
|
648
|
+
public findLeavesIndexes(
|
|
855
649
|
referenceBlock: BlockParameter,
|
|
856
650
|
treeId: MerkleTreeId,
|
|
857
651
|
leafValues: Fr[],
|
|
858
652
|
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
859
|
-
|
|
860
|
-
const maybeIndices = await committedDb.findLeafIndices(
|
|
861
|
-
treeId,
|
|
862
|
-
leafValues.map(x => x.toBuffer()),
|
|
863
|
-
);
|
|
864
|
-
// We filter out undefined values
|
|
865
|
-
const indices = maybeIndices.filter(x => x !== undefined) as bigint[];
|
|
866
|
-
|
|
867
|
-
// Now we find the block numbers for the indices
|
|
868
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, indices);
|
|
869
|
-
|
|
870
|
-
// If any of the block numbers are undefined, we throw an error.
|
|
871
|
-
for (let i = 0; i < indices.length; i++) {
|
|
872
|
-
if (blockNumbers[i] === undefined) {
|
|
873
|
-
throw new Error(`Block number is undefined for leaf index ${indices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
878
|
-
const uniqueBlockNumbers = [...new Set(blockNumbers.filter(x => x !== undefined))];
|
|
879
|
-
|
|
880
|
-
// Now we obtain the block hashes from the archive tree by calling await `committedDb.getLeafValue(treeId, index)`
|
|
881
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
882
|
-
const blockHashes = await Promise.all(
|
|
883
|
-
uniqueBlockNumbers.map(blockNumber => {
|
|
884
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
885
|
-
}),
|
|
886
|
-
);
|
|
887
|
-
|
|
888
|
-
// If any of the block hashes are undefined, we throw an error.
|
|
889
|
-
for (let i = 0; i < uniqueBlockNumbers.length; i++) {
|
|
890
|
-
if (blockHashes[i] === undefined) {
|
|
891
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
896
|
-
return maybeIndices.map((index, i) => {
|
|
897
|
-
if (index === undefined) {
|
|
898
|
-
return undefined;
|
|
899
|
-
}
|
|
900
|
-
const blockNumber = blockNumbers[i];
|
|
901
|
-
if (blockNumber === undefined) {
|
|
902
|
-
return undefined;
|
|
903
|
-
}
|
|
904
|
-
const blockHashIndex = uniqueBlockNumbers.indexOf(blockNumber);
|
|
905
|
-
const blockHash = blockHashes[blockHashIndex];
|
|
906
|
-
if (!blockHash) {
|
|
907
|
-
return undefined;
|
|
908
|
-
}
|
|
909
|
-
return {
|
|
910
|
-
l2BlockNumber: BlockNumber(Number(blockNumber)),
|
|
911
|
-
l2BlockHash: new BlockHash(blockHash),
|
|
912
|
-
data: index,
|
|
913
|
-
};
|
|
914
|
-
});
|
|
653
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
915
654
|
}
|
|
916
655
|
|
|
917
|
-
public
|
|
656
|
+
public getBlockHashMembershipWitness(
|
|
918
657
|
referenceBlock: BlockParameter,
|
|
919
658
|
blockHash: BlockHash,
|
|
920
659
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
921
|
-
|
|
922
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
|
|
923
|
-
return pathAndIndex === undefined
|
|
924
|
-
? undefined
|
|
925
|
-
: MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
660
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
926
661
|
}
|
|
927
662
|
|
|
928
|
-
public
|
|
663
|
+
public getNoteHashMembershipWitness(
|
|
929
664
|
referenceBlock: BlockParameter,
|
|
930
665
|
noteHash: Fr,
|
|
931
666
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
932
|
-
|
|
933
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
|
|
934
|
-
MerkleTreeId.NOTE_HASH_TREE,
|
|
935
|
-
[noteHash],
|
|
936
|
-
);
|
|
937
|
-
return pathAndIndex === undefined
|
|
938
|
-
? undefined
|
|
939
|
-
: MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
667
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
940
668
|
}
|
|
941
669
|
|
|
942
|
-
public
|
|
670
|
+
public getL1ToL2MessageMembershipWitness(
|
|
943
671
|
referenceBlock: BlockParameter,
|
|
944
672
|
l1ToL2Message: Fr,
|
|
945
673
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
946
|
-
|
|
947
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
|
|
948
|
-
if (!witness) {
|
|
949
|
-
return undefined;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
// REFACTOR: Return a MembershipWitness object
|
|
953
|
-
return [witness.index, witness.path];
|
|
674
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
954
675
|
}
|
|
955
676
|
|
|
956
|
-
public
|
|
957
|
-
|
|
958
|
-
return messageIndex
|
|
959
|
-
? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
|
|
960
|
-
: undefined;
|
|
677
|
+
public getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
|
|
678
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
961
679
|
}
|
|
962
680
|
|
|
963
681
|
/**
|
|
964
|
-
* Returns
|
|
965
|
-
*
|
|
966
|
-
* @
|
|
682
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
683
|
+
*
|
|
684
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
685
|
+
*
|
|
686
|
+
* @param epoch - The epoch at which to get the data.
|
|
687
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
967
688
|
*/
|
|
968
|
-
public
|
|
969
|
-
|
|
970
|
-
return messageIndex !== undefined;
|
|
689
|
+
public getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
690
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
971
691
|
}
|
|
972
692
|
|
|
973
693
|
/**
|
|
974
|
-
* Returns
|
|
975
|
-
*
|
|
976
|
-
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
694
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
695
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
977
696
|
*/
|
|
978
|
-
public
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
for (const checkpointedBlock of checkpointedBlocks) {
|
|
985
|
-
const block = checkpointedBlock.block;
|
|
986
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
987
|
-
if (slotNumber !== previousSlotNumber) {
|
|
988
|
-
checkpointIndex++;
|
|
989
|
-
blocksInCheckpoints.push([]);
|
|
990
|
-
previousSlotNumber = slotNumber;
|
|
991
|
-
}
|
|
992
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
993
|
-
}
|
|
994
|
-
return blocksInCheckpoints.map(blocks =>
|
|
995
|
-
blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs)),
|
|
996
|
-
);
|
|
697
|
+
public getL2ToL1MembershipWitness(
|
|
698
|
+
txHash: TxHash,
|
|
699
|
+
message: Fr,
|
|
700
|
+
messageIndexInTx?: number,
|
|
701
|
+
): Promise<L2ToL1MembershipWitness | undefined> {
|
|
702
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
997
703
|
}
|
|
998
704
|
|
|
999
|
-
public
|
|
705
|
+
public getNullifierMembershipWitness(
|
|
1000
706
|
referenceBlock: BlockParameter,
|
|
1001
707
|
nullifier: Fr,
|
|
1002
708
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1003
|
-
|
|
1004
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
|
|
1005
|
-
if (!witness) {
|
|
1006
|
-
return undefined;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
const { index, path } = witness;
|
|
1010
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1011
|
-
if (!leafPreimage) {
|
|
1012
|
-
return undefined;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
return new NullifierMembershipWitness(index, leafPreimage as NullifierLeafPreimage, path);
|
|
709
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1016
710
|
}
|
|
1017
711
|
|
|
1018
|
-
|
|
1019
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
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).
|
|
1022
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1023
|
-
* @returns The low nullifier membership witness (if found).
|
|
1024
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1025
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1026
|
-
* we are trying to prove non-inclusion for.
|
|
1027
|
-
*
|
|
1028
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1029
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1030
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1031
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1032
|
-
*/
|
|
1033
|
-
public async getLowNullifierMembershipWitness(
|
|
712
|
+
public getLowNullifierMembershipWitness(
|
|
1034
713
|
referenceBlock: BlockParameter,
|
|
1035
714
|
nullifier: Fr,
|
|
1036
715
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
1037
|
-
|
|
1038
|
-
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1039
|
-
if (!findResult) {
|
|
1040
|
-
return undefined;
|
|
1041
|
-
}
|
|
1042
|
-
const { index, alreadyPresent } = findResult;
|
|
1043
|
-
if (alreadyPresent) {
|
|
1044
|
-
this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1045
|
-
}
|
|
1046
|
-
const preimageData = (await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index))!;
|
|
1047
|
-
|
|
1048
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1049
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
|
|
716
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1050
717
|
}
|
|
1051
718
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1055
|
-
if (!lowLeafResult) {
|
|
1056
|
-
return undefined;
|
|
1057
|
-
} else {
|
|
1058
|
-
const preimage = (await committedDb.getLeafPreimage(
|
|
1059
|
-
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
1060
|
-
lowLeafResult.index,
|
|
1061
|
-
)) as PublicDataTreeLeafPreimage;
|
|
1062
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1063
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
1068
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1069
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1070
|
-
|
|
1071
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1072
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
1073
|
-
return Fr.ZERO;
|
|
1074
|
-
}
|
|
1075
|
-
const preimage = (await committedDb.getLeafPreimage(
|
|
1076
|
-
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
1077
|
-
lowLeafResult.index,
|
|
1078
|
-
)) as PublicDataTreeLeafPreimage;
|
|
1079
|
-
return preimage.leaf.value;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
|
|
1083
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1084
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1085
|
-
if (block.equals(initialBlockHash)) {
|
|
1086
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1087
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1088
|
-
}
|
|
1089
|
-
return this.blockSource.getBlockHeaderByHash(block);
|
|
1090
|
-
} else {
|
|
1091
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1092
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
|
|
1093
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
1094
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1095
|
-
}
|
|
1096
|
-
return this.blockSource.getBlockHeader(block);
|
|
1097
|
-
}
|
|
719
|
+
public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
720
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
1098
721
|
}
|
|
1099
722
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
* @param archive - The archive root being requested.
|
|
1103
|
-
* @returns The requested block header.
|
|
1104
|
-
*/
|
|
1105
|
-
public async getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined> {
|
|
1106
|
-
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
723
|
+
public getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
724
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
1107
725
|
}
|
|
1108
726
|
|
|
1109
727
|
/**
|
|
1110
728
|
* Simulates the public part of a transaction with the current state.
|
|
1111
729
|
* @param tx - The transaction to simulate.
|
|
730
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
731
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
1112
732
|
**/
|
|
1113
733
|
@trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
|
|
1114
734
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
1115
735
|
}))
|
|
1116
|
-
public
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
throw new BadRequestError(
|
|
1123
|
-
`Transaction total gas limit ${
|
|
1124
|
-
txGasLimit + teardownGasLimit
|
|
1125
|
-
} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${
|
|
1126
|
-
this.config.rpcSimulatePublicMaxGasLimit
|
|
1127
|
-
} for simulation`,
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
const txHash = tx.getTxHash();
|
|
1132
|
-
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1133
|
-
|
|
1134
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1135
|
-
const coinbase = EthAddress.ZERO;
|
|
1136
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
1137
|
-
|
|
1138
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
|
|
1139
|
-
blockNumber,
|
|
1140
|
-
coinbase,
|
|
1141
|
-
feeRecipient,
|
|
1142
|
-
);
|
|
1143
|
-
const publicProcessorFactory = new PublicProcessorFactory(
|
|
1144
|
-
this.contractDataSource,
|
|
1145
|
-
new DateProvider(),
|
|
1146
|
-
this.telemetry,
|
|
1147
|
-
this.log.getBindings(),
|
|
1148
|
-
);
|
|
1149
|
-
|
|
1150
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
1151
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
1152
|
-
txHash,
|
|
1153
|
-
blockNumber,
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1157
|
-
try {
|
|
1158
|
-
const config = PublicSimulatorConfig.from({
|
|
1159
|
-
skipFeeEnforcement,
|
|
1160
|
-
collectDebugLogs: true,
|
|
1161
|
-
collectHints: false,
|
|
1162
|
-
collectCallMetadata: true,
|
|
1163
|
-
collectStatistics: false,
|
|
1164
|
-
collectionLimits: CollectionLimitsConfig.from({
|
|
1165
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads,
|
|
1166
|
-
}),
|
|
1167
|
-
});
|
|
1168
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1169
|
-
|
|
1170
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1171
|
-
const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
|
|
1172
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
1173
|
-
if (failedTxs.length) {
|
|
1174
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
|
|
1175
|
-
throw failedTxs[0].error;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
const [processedTx] = processedTxs;
|
|
1179
|
-
return new PublicSimulationOutput(
|
|
1180
|
-
processedTx.revertReason,
|
|
1181
|
-
processedTx.globalVariables,
|
|
1182
|
-
processedTx.txEffect,
|
|
1183
|
-
returns,
|
|
1184
|
-
processedTx.gasUsed,
|
|
1185
|
-
);
|
|
1186
|
-
} finally {
|
|
1187
|
-
await merkleTreeFork.close();
|
|
1188
|
-
}
|
|
736
|
+
public simulatePublicCalls(
|
|
737
|
+
tx: Tx,
|
|
738
|
+
skipFeeEnforcement = false,
|
|
739
|
+
overrides?: SimulationOverrides,
|
|
740
|
+
): Promise<PublicSimulationOutput> {
|
|
741
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
1189
742
|
}
|
|
1190
743
|
|
|
1191
744
|
public async isValidTx(
|
|
@@ -1193,12 +746,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1193
746
|
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
1194
747
|
): Promise<TxValidationResult> {
|
|
1195
748
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1196
|
-
const verifier = isSimulation ? undefined : this.
|
|
749
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1197
750
|
|
|
1198
|
-
// We accept transactions if they are not expired by the next slot (checked based on the
|
|
751
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1199
752
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1200
753
|
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
1201
|
-
const
|
|
754
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
755
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
756
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
757
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
758
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
1202
759
|
db,
|
|
1203
760
|
this.contractDataSource,
|
|
1204
761
|
verifier,
|
|
@@ -1207,10 +764,16 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1207
764
|
blockNumber,
|
|
1208
765
|
l1ChainId: this.l1ChainId,
|
|
1209
766
|
rollupVersion: this.version,
|
|
1210
|
-
setupAllowList:
|
|
767
|
+
setupAllowList: [
|
|
768
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
769
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
770
|
+
],
|
|
1211
771
|
gasFees: await this.getCurrentMinFees(),
|
|
1212
772
|
skipFeeEnforcement,
|
|
773
|
+
isSimulation,
|
|
1213
774
|
txsPermitted: !this.config.disableTransactions,
|
|
775
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
776
|
+
maxTxDAGas: networkTxGasLimits.daGas,
|
|
1214
777
|
},
|
|
1215
778
|
this.log.getBindings(),
|
|
1216
779
|
);
|
|
@@ -1226,7 +789,18 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1226
789
|
|
|
1227
790
|
public async setConfig(config: Partial<AztecNodeAdminConfig>): Promise<void> {
|
|
1228
791
|
const newConfig = { ...this.config, ...config };
|
|
1229
|
-
|
|
792
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
793
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
794
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
795
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
796
|
+
// pauseSequencer() still considers it paused.
|
|
797
|
+
const sequencerUpdate = { ...config };
|
|
798
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
799
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
800
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
801
|
+
}
|
|
802
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
803
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
1230
804
|
this.slasherClient?.updateConfig(config);
|
|
1231
805
|
this.validatorsSentinel?.updateConfig(config);
|
|
1232
806
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -1235,7 +809,15 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1235
809
|
archiver.updateConfig(config);
|
|
1236
810
|
}
|
|
1237
811
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1238
|
-
|
|
812
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
813
|
+
if (newConfig.realProofs) {
|
|
814
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
815
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
816
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
817
|
+
} else {
|
|
818
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
819
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
820
|
+
}
|
|
1239
821
|
}
|
|
1240
822
|
|
|
1241
823
|
this.config = newConfig;
|
|
@@ -1246,7 +828,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1246
828
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1247
829
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1248
830
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1249
|
-
multiCallEntrypoint:
|
|
831
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
1250
832
|
});
|
|
1251
833
|
}
|
|
1252
834
|
|
|
@@ -1310,7 +892,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1310
892
|
return Promise.resolve();
|
|
1311
893
|
}
|
|
1312
894
|
|
|
1313
|
-
public async rollbackTo(targetBlock: BlockNumber, force?: boolean): Promise<void> {
|
|
895
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
1314
896
|
const archiver = this.blockSource as Archiver;
|
|
1315
897
|
if (!('rollbackTo' in archiver)) {
|
|
1316
898
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1340,9 +922,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1340
922
|
this.log.error(`Error during rollback`, err);
|
|
1341
923
|
throw err;
|
|
1342
924
|
} finally {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
925
|
+
if (resumeSync) {
|
|
926
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
927
|
+
this.worldStateSynchronizer.resumeSync();
|
|
928
|
+
archiver.resume();
|
|
929
|
+
} else {
|
|
930
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
931
|
+
}
|
|
1346
932
|
}
|
|
1347
933
|
}
|
|
1348
934
|
|
|
@@ -1359,11 +945,39 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1359
945
|
return Promise.resolve();
|
|
1360
946
|
}
|
|
1361
947
|
|
|
1362
|
-
public
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
948
|
+
public pauseSequencer(): Promise<void> {
|
|
949
|
+
if (this.automineSequencer) {
|
|
950
|
+
this.automineSequencer.pause();
|
|
951
|
+
return Promise.resolve();
|
|
952
|
+
}
|
|
953
|
+
if (this.sequencer) {
|
|
954
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
955
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
956
|
+
this.sequencer.updateConfig({ minTxsPerBlock: Number.MAX_SAFE_INTEGER });
|
|
957
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
958
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock,
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
return Promise.resolve();
|
|
962
|
+
}
|
|
963
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
public resumeSequencer(): Promise<void> {
|
|
967
|
+
if (this.automineSequencer) {
|
|
968
|
+
this.automineSequencer.resume();
|
|
969
|
+
return Promise.resolve();
|
|
1365
970
|
}
|
|
1366
|
-
|
|
971
|
+
if (this.sequencer) {
|
|
972
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
973
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
974
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
975
|
+
this.sequencer.updateConfig({ minTxsPerBlock: restored });
|
|
976
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, { minTxsPerBlock: restored });
|
|
977
|
+
}
|
|
978
|
+
return Promise.resolve();
|
|
979
|
+
}
|
|
980
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
1367
981
|
}
|
|
1368
982
|
|
|
1369
983
|
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
@@ -1371,75 +985,165 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
|
|
|
1371
985
|
throw new Error(`Slasher client not enabled`);
|
|
1372
986
|
}
|
|
1373
987
|
if (round === 'all') {
|
|
1374
|
-
return this.slasherClient.
|
|
988
|
+
return this.slasherClient.getOffenses();
|
|
1375
989
|
} else {
|
|
1376
990
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1377
991
|
}
|
|
1378
992
|
}
|
|
1379
993
|
|
|
1380
|
-
|
|
1381
|
-
if (!this.
|
|
1382
|
-
|
|
994
|
+
public async reloadKeystore(): Promise<void> {
|
|
995
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
996
|
+
throw new BadRequestError(
|
|
997
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
998
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
if (!this.validatorClient) {
|
|
1002
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1383
1003
|
}
|
|
1384
|
-
return this.initialHeaderHashPromise;
|
|
1385
|
-
}
|
|
1386
1004
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1005
|
+
this.log.info('Reloading keystore from disk');
|
|
1006
|
+
|
|
1007
|
+
// Re-read and validate keystore files
|
|
1008
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1009
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1010
|
+
await newManager.validateSigners();
|
|
1011
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1012
|
+
|
|
1013
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1014
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1015
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1016
|
+
// would silently fail on every proposer slot.
|
|
1017
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1018
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1019
|
+
const availablePublishers = new Set(
|
|
1020
|
+
oldAdapter
|
|
1021
|
+
.getAttesterAddresses()
|
|
1022
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1023
|
+
);
|
|
1024
|
+
|
|
1025
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1026
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1027
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1028
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1029
|
+
throw new BadRequestError(
|
|
1030
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1031
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1032
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1033
|
+
`use an existing publisher key or restart the node.`,
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1399
1037
|
}
|
|
1400
1038
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1039
|
+
// Build adapters for old and new keystores to compute diff
|
|
1040
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1041
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1042
|
+
const oldAddresses = this.keyStoreManager
|
|
1043
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1044
|
+
: [];
|
|
1045
|
+
|
|
1046
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1047
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1048
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1049
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1050
|
+
|
|
1051
|
+
if (added.length > 0) {
|
|
1052
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1053
|
+
}
|
|
1054
|
+
if (removed.length > 0) {
|
|
1055
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1056
|
+
}
|
|
1057
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1058
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1404
1059
|
}
|
|
1405
1060
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
if (block.equals(initialBlockHash)) {
|
|
1409
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1410
|
-
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1411
|
-
}
|
|
1061
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1062
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1412
1063
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
);
|
|
1418
|
-
}
|
|
1419
|
-
const blockNumber = header.getBlockNumber();
|
|
1420
|
-
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1421
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1064
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1065
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1066
|
+
if (this.sequencer) {
|
|
1067
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1422
1068
|
}
|
|
1423
1069
|
|
|
1424
|
-
//
|
|
1425
|
-
{
|
|
1426
|
-
const
|
|
1070
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1071
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1072
|
+
const slashValidatorsNever = unique(
|
|
1073
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1074
|
+
).map(EthAddress.fromString);
|
|
1075
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1076
|
+
}
|
|
1427
1077
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1078
|
+
this.keyStoreManager = newManager;
|
|
1079
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
public async mineBlock(): Promise<void> {
|
|
1083
|
+
if (this.automineSequencer) {
|
|
1084
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (!this.sequencer) {
|
|
1088
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1092
|
+
|
|
1093
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1094
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1095
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1096
|
+
|
|
1097
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1098
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1099
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1100
|
+
|
|
1101
|
+
try {
|
|
1102
|
+
// Trigger the sequencer to produce a block immediately
|
|
1103
|
+
void this.sequencer.trigger();
|
|
1104
|
+
|
|
1105
|
+
// Wait for the new L2 block to appear
|
|
1106
|
+
await retryUntil(
|
|
1107
|
+
async () => {
|
|
1108
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1109
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1110
|
+
},
|
|
1111
|
+
'mineBlock',
|
|
1112
|
+
timeoutSeconds,
|
|
1113
|
+
0.1,
|
|
1114
|
+
);
|
|
1115
|
+
} finally {
|
|
1116
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
public async prove(upToCheckpoint?: CheckpointNumber): Promise<CheckpointNumber> {
|
|
1121
|
+
if (!this.automineSequencer) {
|
|
1122
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1123
|
+
}
|
|
1124
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
public async warpL2TimeAtLeastTo(targetTimestamp: number): Promise<void> {
|
|
1128
|
+
if (!this.automineSequencer) {
|
|
1129
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1130
|
+
}
|
|
1131
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1132
|
+
}
|
|
1431
1133
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1134
|
+
public async warpL2TimeAtLeastBy(duration: number): Promise<void> {
|
|
1135
|
+
if (!this.automineSequencer) {
|
|
1136
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1434
1137
|
}
|
|
1138
|
+
await this.automineSequencer.warpBy(duration);
|
|
1435
1139
|
}
|
|
1436
1140
|
|
|
1437
1141
|
/**
|
|
1438
|
-
*
|
|
1439
|
-
* @
|
|
1142
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1143
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1144
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1440
1145
|
*/
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
return await this.worldStateSynchronizer.syncImmediate(blockSourceHeight);
|
|
1146
|
+
protected getWorldState(block: BlockParameter) {
|
|
1147
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1444
1148
|
}
|
|
1445
1149
|
}
|