@aztec-labs/aztec-node 6.0.0-nightly.20260829
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/README.md +15 -0
- 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 +52 -0
- package/dest/aztec-node/config.d.ts.map +1 -0
- package/dest/aztec-node/config.js +129 -0
- package/dest/aztec-node/node_metrics.d.ts +12 -0
- package/dest/aztec-node/node_metrics.d.ts.map +1 -0
- package/dest/aztec-node/node_metrics.js +36 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts +108 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +380 -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 +11 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +48 -0
- package/dest/aztec-node/server.d.ts +281 -0
- package/dest/aztec-node/server.d.ts.map +1 -0
- package/dest/aztec-node/server.js +1235 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +57 -0
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +539 -0
- package/dest/index.d.ts +5 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +4 -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 +270 -0
- package/dest/sentinel/config.d.ts +9 -0
- package/dest/sentinel/config.d.ts.map +1 -0
- package/dest/sentinel/config.js +39 -0
- package/dest/sentinel/factory.d.ts +11 -0
- package/dest/sentinel/factory.d.ts.map +1 -0
- package/dest/sentinel/factory.js +24 -0
- package/dest/sentinel/index.d.ts +3 -0
- package/dest/sentinel/index.d.ts.map +1 -0
- package/dest/sentinel/index.js +1 -0
- package/dest/sentinel/sentinel.d.ts +217 -0
- package/dest/sentinel/sentinel.d.ts.map +1 -0
- package/dest/sentinel/sentinel.js +551 -0
- package/dest/sentinel/store.d.ts +35 -0
- package/dest/sentinel/store.d.ts.map +1 -0
- package/dest/sentinel/store.js +182 -0
- package/dest/test/index.d.ts +31 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/package.json +118 -0
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +216 -0
- package/src/aztec-node/node_metrics.ts +49 -0
- package/src/aztec-node/node_public_calls_simulator.ts +437 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +45 -0
- package/src/aztec-node/server.ts +1155 -0
- package/src/bin/index.ts +77 -0
- package/src/factory.ts +704 -0
- package/src/index.ts +4 -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 +373 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +49 -0
- package/src/sentinel/factory.ts +46 -0
- package/src/sentinel/index.ts +8 -0
- package/src/sentinel/sentinel.ts +694 -0
- package/src/sentinel/store.ts +193 -0
- package/src/test/index.ts +32 -0
|
@@ -0,0 +1,1155 @@
|
|
|
1
|
+
import { Archiver } from '@aztec-labs/archiver';
|
|
2
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec-labs/bb-prover';
|
|
3
|
+
import { TestCircuitVerifier } from '@aztec-labs/bb-prover/test';
|
|
4
|
+
import type { BlobClientInterface } from '@aztec-labs/blob-client/client';
|
|
5
|
+
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec-labs/constants';
|
|
6
|
+
import type { EpochCacheInterface } from '@aztec-labs/epoch-cache';
|
|
7
|
+
import { RollupContract } from '@aztec-labs/ethereum/contracts';
|
|
8
|
+
import { type L1ContractAddresses, pickL1ContractAddresses } from '@aztec-labs/ethereum/l1-contract-addresses';
|
|
9
|
+
import {
|
|
10
|
+
BlockNumber,
|
|
11
|
+
CheckpointNumber,
|
|
12
|
+
type CheckpointProposalHash,
|
|
13
|
+
EpochNumber,
|
|
14
|
+
SlotNumber,
|
|
15
|
+
} from '@aztec-labs/foundation/branded-types';
|
|
16
|
+
import { compactArray, pick, unique } from '@aztec-labs/foundation/collection';
|
|
17
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
18
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
19
|
+
import { first } from '@aztec-labs/foundation/iterable';
|
|
20
|
+
import { BadRequestError } from '@aztec-labs/foundation/json-rpc';
|
|
21
|
+
import { type Logger, createLogger } from '@aztec-labs/foundation/log';
|
|
22
|
+
import { retryUntil } from '@aztec-labs/foundation/retry';
|
|
23
|
+
import { count } from '@aztec-labs/foundation/string';
|
|
24
|
+
import { Timer } from '@aztec-labs/foundation/timer';
|
|
25
|
+
import { MembershipWitness, SiblingPath } from '@aztec-labs/foundation/trees';
|
|
26
|
+
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec-labs/node-keystore';
|
|
27
|
+
import { uploadSnapshot } from '@aztec-labs/node-lib/actions';
|
|
28
|
+
import { type P2P, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec-labs/p2p';
|
|
29
|
+
import { ProtocolContractAddress } from '@aztec-labs/protocol-contracts';
|
|
30
|
+
import type { ProverNode } from '@aztec-labs/prover-node';
|
|
31
|
+
import { SequencerClient } from '@aztec-labs/sequencer-client';
|
|
32
|
+
import { AutomineSequencer } from '@aztec-labs/sequencer-client/automine';
|
|
33
|
+
import type { AvmSimulator } from '@aztec-labs/simulator/server';
|
|
34
|
+
import type { SlasherClientInterface } from '@aztec-labs/slasher';
|
|
35
|
+
import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec-labs/standard-contracts/multi-call-entrypoint';
|
|
36
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
37
|
+
import {
|
|
38
|
+
type BlockData,
|
|
39
|
+
BlockHash,
|
|
40
|
+
type BlockParameter,
|
|
41
|
+
type CheckpointsQuery,
|
|
42
|
+
type DataInBlock,
|
|
43
|
+
type L2BlockSource,
|
|
44
|
+
type L2BlockTag,
|
|
45
|
+
type L2Tips,
|
|
46
|
+
inspectBlockParameter,
|
|
47
|
+
} from '@aztec-labs/stdlib/block';
|
|
48
|
+
import type {
|
|
49
|
+
ContractClassPublic,
|
|
50
|
+
ContractDataSource,
|
|
51
|
+
ContractInstanceWithAddress,
|
|
52
|
+
NodeInfo,
|
|
53
|
+
ProtocolContractAddresses,
|
|
54
|
+
} from '@aztec-labs/stdlib/contract';
|
|
55
|
+
import type { L1RollupConstants } from '@aztec-labs/stdlib/epoch-helpers';
|
|
56
|
+
import { GasFees, type ManaUsageEstimate, getNetworkTxGasLimits } from '@aztec-labs/stdlib/gas';
|
|
57
|
+
import type {
|
|
58
|
+
AztecNode,
|
|
59
|
+
AztecNodeAdmin,
|
|
60
|
+
AztecNodeAdminConfig,
|
|
61
|
+
AztecNodeDebug,
|
|
62
|
+
BlockIncludeOptions,
|
|
63
|
+
BlockResponse,
|
|
64
|
+
BlocksIncludeOptions,
|
|
65
|
+
CheckpointIncludeOptions,
|
|
66
|
+
CheckpointParameter,
|
|
67
|
+
CheckpointResponse,
|
|
68
|
+
CheckpointTag,
|
|
69
|
+
GetTxByHashOptions,
|
|
70
|
+
PeerInfo,
|
|
71
|
+
ProposalsForSlot,
|
|
72
|
+
} from '@aztec-labs/stdlib/interfaces/client';
|
|
73
|
+
import { AztecNodeAdminConfigSchema } from '@aztec-labs/stdlib/interfaces/client';
|
|
74
|
+
import {
|
|
75
|
+
type AllowedElement,
|
|
76
|
+
type ClientProtocolCircuitVerifier,
|
|
77
|
+
type L2LogsSource,
|
|
78
|
+
type Service,
|
|
79
|
+
type WorldStateSyncStatus,
|
|
80
|
+
type WorldStateSynchronizer,
|
|
81
|
+
tryStop,
|
|
82
|
+
} from '@aztec-labs/stdlib/interfaces/server';
|
|
83
|
+
import type { DebugLogStore, LogResult, PrivateLogsQuery, PublicLogsQuery } from '@aztec-labs/stdlib/logs';
|
|
84
|
+
import { NullDebugLogStore } from '@aztec-labs/stdlib/logs';
|
|
85
|
+
import type { L1ToL2MessageSource, L2ToL1MembershipWitness } from '@aztec-labs/stdlib/messaging';
|
|
86
|
+
import type { CheckpointAttestation } from '@aztec-labs/stdlib/p2p';
|
|
87
|
+
import type { Offense } from '@aztec-labs/stdlib/slashing';
|
|
88
|
+
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec-labs/stdlib/trees';
|
|
89
|
+
import {
|
|
90
|
+
type FeeProvider,
|
|
91
|
+
type GetTxReceiptOptions,
|
|
92
|
+
type GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
93
|
+
type IndexedTxEffect,
|
|
94
|
+
PublicSimulationOutput,
|
|
95
|
+
type SimulationOverrides,
|
|
96
|
+
Tx,
|
|
97
|
+
type TxHash,
|
|
98
|
+
type TxReceipt,
|
|
99
|
+
type TxValidationResult,
|
|
100
|
+
} from '@aztec-labs/stdlib/tx';
|
|
101
|
+
import type { SingleValidatorStats, ValidatorsStats } from '@aztec-labs/stdlib/validators';
|
|
102
|
+
import {
|
|
103
|
+
Attributes,
|
|
104
|
+
type TelemetryClient,
|
|
105
|
+
type Traceable,
|
|
106
|
+
type Tracer,
|
|
107
|
+
getTelemetryClient,
|
|
108
|
+
trackSpan,
|
|
109
|
+
} from '@aztec-labs/telemetry-client';
|
|
110
|
+
import { NodeKeystoreAdapter, ValidatorClient } from '@aztec-labs/validator-client';
|
|
111
|
+
|
|
112
|
+
import { NodeBlockProvider } from '../modules/node_block_provider.js';
|
|
113
|
+
import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
|
|
114
|
+
import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
|
|
115
|
+
import { Sentinel } from '../sentinel/sentinel.js';
|
|
116
|
+
import type { AztecNodeConfig } from './config.js';
|
|
117
|
+
import { NodeMetrics } from './node_metrics.js';
|
|
118
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Fully-constructed collaborators and settings an {@link AztecNodeService} owns. Built by `createAztecNodeService`
|
|
122
|
+
* (see `factory.ts`); passed as a single object so call sites name each dependency instead of relying on
|
|
123
|
+
* positional order.
|
|
124
|
+
*/
|
|
125
|
+
export interface AztecNodeServiceDeps {
|
|
126
|
+
config: AztecNodeConfig;
|
|
127
|
+
p2pClient: P2P;
|
|
128
|
+
blockSource: L2BlockSource & Partial<Service>;
|
|
129
|
+
logsSource: L2LogsSource;
|
|
130
|
+
contractDataSource: ContractDataSource;
|
|
131
|
+
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
132
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
133
|
+
sequencer: SequencerClient | undefined;
|
|
134
|
+
proverNode: ProverNode | undefined;
|
|
135
|
+
slasherClient: SlasherClientInterface | undefined;
|
|
136
|
+
validatorsSentinel: Sentinel | undefined;
|
|
137
|
+
stopStartedWatchers: () => Promise<void>;
|
|
138
|
+
l1ChainId: number;
|
|
139
|
+
version: number;
|
|
140
|
+
globalVariableBuilder: GlobalVariableBuilderInterface;
|
|
141
|
+
rollupContract: RollupContract | undefined;
|
|
142
|
+
feeProvider: FeeProvider;
|
|
143
|
+
epochCache: EpochCacheInterface;
|
|
144
|
+
packageVersion: string;
|
|
145
|
+
peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
146
|
+
rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
147
|
+
telemetry?: TelemetryClient;
|
|
148
|
+
log?: Logger;
|
|
149
|
+
blobClient?: BlobClientInterface;
|
|
150
|
+
validatorClient?: ValidatorClient;
|
|
151
|
+
keyStoreManager?: KeystoreManager;
|
|
152
|
+
debugLogStore?: DebugLogStore;
|
|
153
|
+
automineSequencer?: AutomineSequencer;
|
|
154
|
+
// AVM execution backend for public simulation. Wired in production (factory.ts); absent in unit/TXE nodes
|
|
155
|
+
// that don't drive public execution, hence optional and asserted at the simulation call site. Owned by the
|
|
156
|
+
// node (disposed on stop), so it must be disposable — a spawned process pool + CDB IPC server.
|
|
157
|
+
avmSimulator?: AvmSimulator & AsyncDisposable;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The aztec node.
|
|
162
|
+
*/
|
|
163
|
+
export class AztecNodeService implements AztecNode, AztecNodeAdmin, AztecNodeDebug, Traceable {
|
|
164
|
+
private metrics: NodeMetrics;
|
|
165
|
+
// Prevent two snapshot operations to happen simultaneously
|
|
166
|
+
private isUploadingSnapshot = false;
|
|
167
|
+
// Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
|
|
168
|
+
private sequencerPausedMinTxsPerBlock: number | undefined;
|
|
169
|
+
private readonly nodePublicCallsSimulator: NodePublicCallsSimulator;
|
|
170
|
+
private readonly worldStateQueries: NodeWorldStateQueries;
|
|
171
|
+
private readonly blockProvider: NodeBlockProvider;
|
|
172
|
+
private readonly txReceiptBuilder: NodeTxReceiptBuilder;
|
|
173
|
+
|
|
174
|
+
public readonly tracer: Tracer;
|
|
175
|
+
|
|
176
|
+
protected config: AztecNodeConfig;
|
|
177
|
+
protected readonly p2pClient: P2P;
|
|
178
|
+
protected readonly blockSource: L2BlockSource & Partial<Service>;
|
|
179
|
+
protected readonly logsSource: L2LogsSource;
|
|
180
|
+
protected readonly contractDataSource: ContractDataSource;
|
|
181
|
+
protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
|
|
182
|
+
protected readonly worldStateSynchronizer: WorldStateSynchronizer;
|
|
183
|
+
protected readonly sequencer: SequencerClient | undefined;
|
|
184
|
+
protected readonly proverNode: ProverNode | undefined;
|
|
185
|
+
protected readonly slasherClient: SlasherClientInterface | undefined;
|
|
186
|
+
protected readonly validatorsSentinel: Sentinel | undefined;
|
|
187
|
+
private readonly stopStartedWatchers: () => Promise<void>;
|
|
188
|
+
protected readonly l1ChainId: number;
|
|
189
|
+
protected readonly version: number;
|
|
190
|
+
protected readonly globalVariableBuilder: GlobalVariableBuilderInterface;
|
|
191
|
+
protected readonly rollupContract: RollupContract | undefined;
|
|
192
|
+
protected readonly feeProvider: FeeProvider;
|
|
193
|
+
protected readonly epochCache: EpochCacheInterface;
|
|
194
|
+
protected readonly packageVersion: string;
|
|
195
|
+
private peerProofVerifier: ClientProtocolCircuitVerifier;
|
|
196
|
+
private rpcProofVerifier: ClientProtocolCircuitVerifier;
|
|
197
|
+
private telemetry: TelemetryClient;
|
|
198
|
+
private log: Logger;
|
|
199
|
+
private blobClient?: BlobClientInterface;
|
|
200
|
+
private validatorClient?: ValidatorClient;
|
|
201
|
+
private keyStoreManager?: KeystoreManager;
|
|
202
|
+
private debugLogStore: DebugLogStore;
|
|
203
|
+
private readonly automineSequencer?: AutomineSequencer;
|
|
204
|
+
private readonly avmSimulator?: AvmSimulator & AsyncDisposable;
|
|
205
|
+
|
|
206
|
+
constructor(deps: AztecNodeServiceDeps) {
|
|
207
|
+
this.config = deps.config;
|
|
208
|
+
this.p2pClient = deps.p2pClient;
|
|
209
|
+
this.blockSource = deps.blockSource;
|
|
210
|
+
this.logsSource = deps.logsSource;
|
|
211
|
+
this.contractDataSource = deps.contractDataSource;
|
|
212
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
213
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
214
|
+
this.sequencer = deps.sequencer;
|
|
215
|
+
this.proverNode = deps.proverNode;
|
|
216
|
+
this.slasherClient = deps.slasherClient;
|
|
217
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
218
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
219
|
+
this.l1ChainId = deps.l1ChainId;
|
|
220
|
+
this.version = deps.version;
|
|
221
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
222
|
+
this.rollupContract = deps.rollupContract;
|
|
223
|
+
this.feeProvider = deps.feeProvider;
|
|
224
|
+
this.epochCache = deps.epochCache;
|
|
225
|
+
this.packageVersion = deps.packageVersion;
|
|
226
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
227
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
228
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
229
|
+
this.log = deps.log ?? createLogger('node');
|
|
230
|
+
this.blobClient = deps.blobClient;
|
|
231
|
+
this.validatorClient = deps.validatorClient;
|
|
232
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
233
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
234
|
+
this.automineSequencer = deps.automineSequencer;
|
|
235
|
+
this.avmSimulator = deps.avmSimulator;
|
|
236
|
+
|
|
237
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
238
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
239
|
+
|
|
240
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
241
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
242
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
243
|
+
blockSource: this.blockSource,
|
|
244
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
245
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
246
|
+
contractDataSource: this.contractDataSource,
|
|
247
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
248
|
+
rollupContract: this.rollupContract,
|
|
249
|
+
epochCache: this.epochCache,
|
|
250
|
+
signatureContext: { chainId: this.l1ChainId, rollupAddress: this.config.rollupAddress },
|
|
251
|
+
config: this.config,
|
|
252
|
+
avmSimulator: this.avmSimulator,
|
|
253
|
+
telemetry: this.telemetry,
|
|
254
|
+
log: this.log.createChild('public-calls-simulator'),
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
258
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
259
|
+
blockSource: this.blockSource,
|
|
260
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
261
|
+
log: this.log.createChild('world-state-queries'),
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
265
|
+
|
|
266
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
267
|
+
p2pClient: this.p2pClient,
|
|
268
|
+
blockSource: this.blockSource,
|
|
269
|
+
debugLogStore: this.debugLogStore,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
273
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
274
|
+
|
|
275
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
276
|
+
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
277
|
+
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
278
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
279
|
+
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */
|
|
284
|
+
public getProofVerifier(): ClientProtocolCircuitVerifier {
|
|
285
|
+
return this.rpcProofVerifier;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
|
|
289
|
+
const status = await this.worldStateSynchronizer.status();
|
|
290
|
+
return status.syncSummary;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
public getChainTips(): Promise<L2Tips> {
|
|
294
|
+
return this.blockSource.getL2Tips();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
298
|
+
return this.blockSource.getL1Constants();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public getSyncedL2SlotNumber() {
|
|
302
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public getSyncedL2EpochNumber() {
|
|
306
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
public getSyncedL1Timestamp() {
|
|
310
|
+
return this.blockSource.getL1Timestamp();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public getCheckpointsData(query: CheckpointsQuery) {
|
|
314
|
+
return this.blockSource.getCheckpointsData(query);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public async getBlockNumber(tip?: L2BlockTag): Promise<BlockNumber> {
|
|
318
|
+
if (tip === undefined || tip === 'proposed') {
|
|
319
|
+
return this.blockSource.getBlockNumber();
|
|
320
|
+
}
|
|
321
|
+
return (await this.blockSource.getBlockNumber({ tag: tip })) ?? BlockNumber.ZERO;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
public async getCheckpointNumber(tip?: CheckpointTag): Promise<CheckpointNumber> {
|
|
325
|
+
const tips = await this.blockSource.getL2Tips();
|
|
326
|
+
switch (tip) {
|
|
327
|
+
case undefined:
|
|
328
|
+
case 'checkpointed':
|
|
329
|
+
return tips.checkpointed.checkpoint.number;
|
|
330
|
+
case 'proven':
|
|
331
|
+
return tips.proven.checkpoint.number;
|
|
332
|
+
case 'finalized':
|
|
333
|
+
return tips.finalized.checkpoint.number;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public getBlock<Opts extends BlockIncludeOptions = {}>(
|
|
338
|
+
param: BlockParameter,
|
|
339
|
+
options: Opts = {} as Opts,
|
|
340
|
+
): Promise<BlockResponse<Opts> | undefined> {
|
|
341
|
+
return this.blockProvider.getBlock(param, options);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
public getBlockData(param: BlockParameter): Promise<BlockData | undefined> {
|
|
345
|
+
return this.blockProvider.getBlockData(param);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
public getBlocks<Opts extends BlocksIncludeOptions = {}>(
|
|
349
|
+
from: BlockNumber,
|
|
350
|
+
limit: number,
|
|
351
|
+
options: Opts = {} as Opts,
|
|
352
|
+
): Promise<BlockResponse<Opts>[]> {
|
|
353
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
public getCheckpoint<Opts extends CheckpointIncludeOptions = {}>(
|
|
357
|
+
param: CheckpointParameter,
|
|
358
|
+
options: Opts = {} as Opts,
|
|
359
|
+
): Promise<CheckpointResponse<Opts> | undefined> {
|
|
360
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
public getCheckpoints<Opts extends CheckpointIncludeOptions = {}>(
|
|
364
|
+
from: CheckpointNumber,
|
|
365
|
+
limit: number,
|
|
366
|
+
options: Opts = {} as Opts,
|
|
367
|
+
): Promise<CheckpointResponse<Opts>[]> {
|
|
368
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Returns the sequencer client instance.
|
|
373
|
+
* @returns The sequencer client instance.
|
|
374
|
+
*/
|
|
375
|
+
public getSequencer(): SequencerClient | undefined {
|
|
376
|
+
return this.sequencer;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */
|
|
380
|
+
public getAutomineSequencer(): AutomineSequencer | undefined {
|
|
381
|
+
return this.automineSequencer;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Returns the prover node subsystem, if enabled. */
|
|
385
|
+
public getProverNode(): ProverNode | undefined {
|
|
386
|
+
return this.proverNode;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
public getBlockSource(): L2BlockSource {
|
|
390
|
+
return this.blockSource;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
public getContractDataSource(): ContractDataSource {
|
|
394
|
+
return this.contractDataSource;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
public getP2P(): P2P {
|
|
398
|
+
return this.p2pClient;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Method to return the currently deployed L1 contract addresses.
|
|
403
|
+
* @returns - The currently deployed L1 contract addresses.
|
|
404
|
+
*/
|
|
405
|
+
public getL1ContractAddresses(): Promise<L1ContractAddresses> {
|
|
406
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public getEncodedEnr(): Promise<string | undefined> {
|
|
410
|
+
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
|
|
414
|
+
return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Method to determine if the node is ready to accept transactions.
|
|
419
|
+
* @returns - Flag indicating the readiness for tx submission.
|
|
420
|
+
*/
|
|
421
|
+
public isReady() {
|
|
422
|
+
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
public async getNodeInfo(): Promise<NodeInfo> {
|
|
426
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] =
|
|
427
|
+
await Promise.all([
|
|
428
|
+
this.getNodeVersion(),
|
|
429
|
+
this.getVersion(),
|
|
430
|
+
this.getChainId(),
|
|
431
|
+
this.getEncodedEnr(),
|
|
432
|
+
this.getL1ContractAddresses(),
|
|
433
|
+
this.getProtocolContractAddresses(),
|
|
434
|
+
this.blockSource.getL1Constants(),
|
|
435
|
+
]);
|
|
436
|
+
|
|
437
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
438
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
439
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
440
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
441
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
442
|
+
|
|
443
|
+
const nodeInfo: NodeInfo = {
|
|
444
|
+
nodeVersion,
|
|
445
|
+
l1ChainId: chainId,
|
|
446
|
+
rollupVersion,
|
|
447
|
+
enr,
|
|
448
|
+
l1ContractAddresses: contractAddresses,
|
|
449
|
+
protocolContractAddresses: protocolContractAddresses,
|
|
450
|
+
realProofs: !!this.config.realProofs,
|
|
451
|
+
txsLimits: { gas: { daGas: maxTxGas.daGas, l2Gas: maxTxGas.l2Gas } },
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
return nodeInfo;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
458
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Returns predicted min fees for the current slot and next N slots. */
|
|
462
|
+
public async getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
463
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
public async getMaxPriorityFees(): Promise<GasFees> {
|
|
467
|
+
const tx = await first(this.p2pClient.iteratePendingTxs({ includeProof: false }));
|
|
468
|
+
return tx ? tx.getGasSettings().maxPriorityFeesPerGas : GasFees.from({ feePerDaGas: 0n, feePerL2Gas: 0n });
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Method to fetch the version of the package.
|
|
473
|
+
* @returns The node package version
|
|
474
|
+
*/
|
|
475
|
+
public getNodeVersion(): Promise<string> {
|
|
476
|
+
return Promise.resolve(this.packageVersion);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Method to fetch the version of the rollup the node is connected to.
|
|
481
|
+
* @returns The rollup version.
|
|
482
|
+
*/
|
|
483
|
+
public getVersion(): Promise<number> {
|
|
484
|
+
return Promise.resolve(this.version);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Method to fetch the chain id of the base-layer for the rollup.
|
|
489
|
+
* @returns The chain id.
|
|
490
|
+
*/
|
|
491
|
+
public getChainId(): Promise<number> {
|
|
492
|
+
return Promise.resolve(this.l1ChainId);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
public getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
496
|
+
return this.contractDataSource.getContractClass(id);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
public async getContract(
|
|
500
|
+
address: AztecAddress,
|
|
501
|
+
referenceBlock: BlockParameter = 'latest',
|
|
502
|
+
): Promise<ContractInstanceWithAddress | undefined> {
|
|
503
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
504
|
+
if (!blockData) {
|
|
505
|
+
throw new Error(
|
|
506
|
+
`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.`,
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
public getPrivateLogsByTags(query: PrivateLogsQuery): Promise<LogResult[][]> {
|
|
513
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
public getPublicLogsByTags(query: PublicLogsQuery): Promise<LogResult[][]> {
|
|
517
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Method to submit a transaction to the p2p pool.
|
|
522
|
+
* @param tx - The transaction to be submitted.
|
|
523
|
+
*/
|
|
524
|
+
public async sendTx(tx: Tx) {
|
|
525
|
+
await this.#sendTx(tx);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async #sendTx(tx: Tx) {
|
|
529
|
+
const timer = new Timer();
|
|
530
|
+
const txHash = tx.getTxHash().toString();
|
|
531
|
+
|
|
532
|
+
const connectivity = await this.p2pClient.getP2PConnectivity();
|
|
533
|
+
if (connectivity.enabled && connectivity.connectedPeers === 0) {
|
|
534
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
535
|
+
this.log.warn(`Rejecting tx ${txHash}: node has no connected peers`, { txHash });
|
|
536
|
+
throw new Error('Cannot accept tx: node has no connected peers to propagate it');
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const valid = await this.isValidTx(tx);
|
|
540
|
+
if (valid.result !== 'valid') {
|
|
541
|
+
const reason = valid.reason.join(', ');
|
|
542
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
543
|
+
this.log.warn(`Received invalid tx ${txHash}: ${reason}`, { txHash });
|
|
544
|
+
throw new Error(`Invalid tx: ${reason}`);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
try {
|
|
548
|
+
await this.p2pClient!.sendTx(tx);
|
|
549
|
+
} catch (err) {
|
|
550
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
551
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${(err as Error).message}`, { txHash });
|
|
552
|
+
throw err;
|
|
553
|
+
}
|
|
554
|
+
const duration = timer.ms();
|
|
555
|
+
this.metrics.receivedTx(duration, true);
|
|
556
|
+
this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
public getTxReceipt<TGetTxReceiptOptions extends GetTxReceiptOptions = {}>(
|
|
560
|
+
txHash: TxHash,
|
|
561
|
+
options?: TGetTxReceiptOptions,
|
|
562
|
+
): Promise<TxReceipt<TGetTxReceiptOptions>> {
|
|
563
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
567
|
+
return this.blockSource.getTxEffect(txHash);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Method to stop the aztec node.
|
|
572
|
+
*/
|
|
573
|
+
public async stop() {
|
|
574
|
+
this.log.info(`Stopping Aztec Node`);
|
|
575
|
+
await this.stopStartedWatchers();
|
|
576
|
+
await tryStop(this.slasherClient);
|
|
577
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
578
|
+
await tryStop(this.sequencer);
|
|
579
|
+
await tryStop(this.automineSequencer);
|
|
580
|
+
await tryStop(this.proverNode);
|
|
581
|
+
await tryStop(this.p2pClient);
|
|
582
|
+
await tryStop(this.feeProvider);
|
|
583
|
+
// Dispose the AVM backend before world state: it kills the bb-avm-sim processes and closes the CDB IPC
|
|
584
|
+
// server, releasing their connections to the WSDB so it shuts down cleanly (and freeing the
|
|
585
|
+
// Server/Socket/ChildProcess handles that would otherwise keep the process alive after teardown).
|
|
586
|
+
await this.avmSimulator?.[Symbol.asyncDispose]();
|
|
587
|
+
await tryStop(this.worldStateSynchronizer);
|
|
588
|
+
await tryStop(this.blockSource);
|
|
589
|
+
await tryStop(this.blobClient);
|
|
590
|
+
await tryStop(this.telemetry);
|
|
591
|
+
this.log.info(`Stopped Aztec Node`);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Returns the blob client used by this node.
|
|
596
|
+
* @internal - Exposed for testing purposes only.
|
|
597
|
+
*/
|
|
598
|
+
public getBlobClient(): BlobClientInterface | undefined {
|
|
599
|
+
return this.blobClient;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Method to retrieve pending txs.
|
|
604
|
+
* @param limit - The number of items to returns
|
|
605
|
+
* @param after - The last known pending tx. Used for pagination
|
|
606
|
+
* @returns - The pending txs.
|
|
607
|
+
*/
|
|
608
|
+
public getPendingTxs(limit?: number, after?: TxHash, options?: GetTxByHashOptions): Promise<Tx[]> {
|
|
609
|
+
return this.p2pClient!.getPendingTxs(limit, after, options);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
public getPendingTxCount(): Promise<number> {
|
|
613
|
+
return this.p2pClient!.getPendingTxCount();
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
public getPeers(includePending?: boolean): Promise<PeerInfo[]> {
|
|
617
|
+
return this.p2pClient!.getPeers(includePending);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
public getCheckpointAttestationsForSlot(
|
|
621
|
+
slot: SlotNumber,
|
|
622
|
+
proposalPayloadHash?: CheckpointProposalHash,
|
|
623
|
+
): Promise<CheckpointAttestation[]> {
|
|
624
|
+
return this.p2pClient!.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
public getProposalsForSlot(slot: SlotNumber): Promise<ProposalsForSlot> {
|
|
628
|
+
return this.p2pClient!.getProposalsForSlot(slot);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
633
|
+
* when `includeProof` is set.
|
|
634
|
+
* @param txHash - The transaction hash to return.
|
|
635
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
636
|
+
* @returns - The tx if it exists.
|
|
637
|
+
*/
|
|
638
|
+
public getTxByHash(txHash: TxHash, options?: GetTxByHashOptions): Promise<Tx | undefined> {
|
|
639
|
+
return this.p2pClient!.getTxByHashFromPool(txHash, { includeProof: !!options?.includeProof });
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
644
|
+
* `includeProof` is set.
|
|
645
|
+
* @param txHash - The transaction hash to return.
|
|
646
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
647
|
+
* @returns - The txs if it exists.
|
|
648
|
+
*/
|
|
649
|
+
public async getTxsByHash(txHashes: TxHash[], options?: GetTxByHashOptions): Promise<Tx[]> {
|
|
650
|
+
const txs = await this.p2pClient!.getTxsByHashFromPool(txHashes, { includeProof: !!options?.includeProof });
|
|
651
|
+
return compactArray(txs);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
public findLeavesIndexes(
|
|
655
|
+
referenceBlock: BlockParameter,
|
|
656
|
+
treeId: MerkleTreeId,
|
|
657
|
+
leafValues: Fr[],
|
|
658
|
+
): Promise<(DataInBlock<bigint> | undefined)[]> {
|
|
659
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
public getBlockHashMembershipWitness(
|
|
663
|
+
referenceBlock: BlockParameter,
|
|
664
|
+
blockHash: BlockHash,
|
|
665
|
+
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
666
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
public getNoteHashMembershipWitness(
|
|
670
|
+
referenceBlock: BlockParameter,
|
|
671
|
+
noteHash: Fr,
|
|
672
|
+
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
673
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
public getL1ToL2MessageMembershipWitness(
|
|
677
|
+
referenceBlock: BlockParameter,
|
|
678
|
+
l1ToL2Message: Fr,
|
|
679
|
+
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
|
|
680
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
public getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
684
|
+
return this.worldStateQueries.getL1ToL2MessageIndex(l1ToL2Message);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Returns all the L2 to L1 messages in an epoch.
|
|
689
|
+
*
|
|
690
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
691
|
+
*
|
|
692
|
+
* @param epoch - The epoch at which to get the data.
|
|
693
|
+
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
694
|
+
*/
|
|
695
|
+
public getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]> {
|
|
696
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
701
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
702
|
+
*/
|
|
703
|
+
public getL2ToL1MembershipWitness(
|
|
704
|
+
txHash: TxHash,
|
|
705
|
+
message: Fr,
|
|
706
|
+
messageIndexInTx?: number,
|
|
707
|
+
): Promise<L2ToL1MembershipWitness | undefined> {
|
|
708
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
public getNullifierMembershipWitness(
|
|
712
|
+
referenceBlock: BlockParameter,
|
|
713
|
+
nullifier: Fr,
|
|
714
|
+
): Promise<NullifierMembershipWitness | undefined> {
|
|
715
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
public getLowNullifierMembershipWitness(
|
|
719
|
+
referenceBlock: BlockParameter,
|
|
720
|
+
nullifier: Fr,
|
|
721
|
+
): Promise<NullifierMembershipWitness | undefined> {
|
|
722
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
public getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
726
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
public getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
730
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Simulates the public part of a transaction with the current state.
|
|
735
|
+
* @param tx - The transaction to simulate.
|
|
736
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
737
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
738
|
+
**/
|
|
739
|
+
@trackSpan('AztecNodeService.simulatePublicCalls', (tx: Tx) => ({
|
|
740
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
741
|
+
}))
|
|
742
|
+
public simulatePublicCalls(
|
|
743
|
+
tx: Tx,
|
|
744
|
+
skipFeeEnforcement = false,
|
|
745
|
+
overrides?: SimulationOverrides,
|
|
746
|
+
): Promise<PublicSimulationOutput> {
|
|
747
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
public async isValidTx(
|
|
751
|
+
tx: Tx,
|
|
752
|
+
{ isSimulation, skipFeeEnforcement }: { isSimulation?: boolean; skipFeeEnforcement?: boolean } = {},
|
|
753
|
+
): Promise<TxValidationResult> {
|
|
754
|
+
const db = this.worldStateSynchronizer.getCommitted();
|
|
755
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
756
|
+
|
|
757
|
+
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
758
|
+
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
759
|
+
const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
|
|
760
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
761
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
762
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
763
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
764
|
+
const validator = createTxValidatorForAcceptingTxsOverRPC(
|
|
765
|
+
db,
|
|
766
|
+
this.contractDataSource,
|
|
767
|
+
verifier,
|
|
768
|
+
{
|
|
769
|
+
timestamp: nextSlotTimestamp,
|
|
770
|
+
blockNumber,
|
|
771
|
+
l1ChainId: this.l1ChainId,
|
|
772
|
+
rollupVersion: this.version,
|
|
773
|
+
setupAllowList: [
|
|
774
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
775
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
776
|
+
],
|
|
777
|
+
gasFees: await this.getCurrentMinFees(),
|
|
778
|
+
skipFeeEnforcement,
|
|
779
|
+
isSimulation,
|
|
780
|
+
txsPermitted: !this.config.disableTransactions,
|
|
781
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
782
|
+
maxTxDAGas: networkTxGasLimits.daGas,
|
|
783
|
+
},
|
|
784
|
+
this.log.getBindings(),
|
|
785
|
+
);
|
|
786
|
+
|
|
787
|
+
return await validator.validateTx(tx);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
public getConfig(): Promise<AztecNodeAdminConfig> {
|
|
791
|
+
const schema = AztecNodeAdminConfigSchema;
|
|
792
|
+
const keys = schema.keyof().options;
|
|
793
|
+
return Promise.resolve(pick(this.config, ...keys));
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
public async setConfig(config: Partial<AztecNodeAdminConfig>): Promise<void> {
|
|
797
|
+
const newConfig = { ...this.config, ...config };
|
|
798
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
799
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
800
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
801
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
802
|
+
// pauseSequencer() still considers it paused.
|
|
803
|
+
const sequencerUpdate = { ...config };
|
|
804
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
805
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
806
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
807
|
+
}
|
|
808
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
809
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
810
|
+
this.slasherClient?.updateConfig(config);
|
|
811
|
+
this.validatorsSentinel?.updateConfig(config);
|
|
812
|
+
await this.p2pClient.updateP2PConfig(config);
|
|
813
|
+
const archiver = this.blockSource as Archiver;
|
|
814
|
+
if ('updateConfig' in archiver) {
|
|
815
|
+
archiver.updateConfig(config);
|
|
816
|
+
}
|
|
817
|
+
if (newConfig.realProofs !== this.config.realProofs) {
|
|
818
|
+
await Promise.all([tryStop(this.peerProofVerifier), tryStop(this.rpcProofVerifier)]);
|
|
819
|
+
if (newConfig.realProofs) {
|
|
820
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
821
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
822
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
823
|
+
} else {
|
|
824
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
825
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
this.config = newConfig;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
public getProtocolContractAddresses(): Promise<ProtocolContractAddresses> {
|
|
833
|
+
return Promise.resolve({
|
|
834
|
+
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
835
|
+
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
836
|
+
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
837
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
public registerContractFunctionSignatures(signatures: string[]): Promise<void> {
|
|
842
|
+
return this.contractDataSource.registerContractFunctionSignatures(signatures);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
public getValidatorsStats(): Promise<ValidatorsStats> {
|
|
846
|
+
return this.validatorsSentinel?.computeStats() ?? Promise.resolve({ stats: {}, slotWindow: 0 });
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
public getValidatorStats(
|
|
850
|
+
validatorAddress: EthAddress,
|
|
851
|
+
fromSlot?: SlotNumber,
|
|
852
|
+
toSlot?: SlotNumber,
|
|
853
|
+
): Promise<SingleValidatorStats | undefined> {
|
|
854
|
+
return this.validatorsSentinel?.getValidatorStats(validatorAddress, fromSlot, toSlot) ?? Promise.resolve(undefined);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
public async startSnapshotUpload(location: string): Promise<void> {
|
|
858
|
+
// Note that we are forcefully casting the blocksource as an archiver
|
|
859
|
+
// We break support for archiver running remotely to the node
|
|
860
|
+
const archiver = this.blockSource as Archiver;
|
|
861
|
+
if (!('backupTo' in archiver)) {
|
|
862
|
+
this.metrics.recordSnapshotError();
|
|
863
|
+
throw new Error('Archiver implementation does not support backups. Cannot generate snapshot.');
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// Test that the archiver has done an initial sync.
|
|
867
|
+
if (!archiver.isInitialSyncComplete()) {
|
|
868
|
+
this.metrics.recordSnapshotError();
|
|
869
|
+
throw new Error(`Archiver initial sync not complete. Cannot start snapshot.`);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// And it has an L2 block hash
|
|
873
|
+
const l2BlockHash = await archiver.getL2Tips().then(tips => tips.proposed.hash);
|
|
874
|
+
if (!l2BlockHash) {
|
|
875
|
+
this.metrics.recordSnapshotError();
|
|
876
|
+
throw new Error(`Archiver has no latest L2 block hash downloaded. Cannot start snapshot.`);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (this.isUploadingSnapshot) {
|
|
880
|
+
this.metrics.recordSnapshotError();
|
|
881
|
+
throw new Error(`Snapshot upload already in progress. Cannot start another one until complete.`);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// Do not wait for the upload to be complete to return to the caller, but flag that an operation is in progress
|
|
885
|
+
this.isUploadingSnapshot = true;
|
|
886
|
+
const timer = new Timer();
|
|
887
|
+
void uploadSnapshot(location, this.blockSource as Archiver, this.worldStateSynchronizer, this.config, this.log)
|
|
888
|
+
.then(() => {
|
|
889
|
+
this.isUploadingSnapshot = false;
|
|
890
|
+
this.metrics.recordSnapshot(timer.ms());
|
|
891
|
+
})
|
|
892
|
+
.catch(err => {
|
|
893
|
+
this.isUploadingSnapshot = false;
|
|
894
|
+
this.metrics.recordSnapshotError();
|
|
895
|
+
this.log.error(`Error uploading snapshot: ${err}`);
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
return Promise.resolve();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
public async rollbackTo(targetBlock: BlockNumber, force?: boolean, resumeSync = true): Promise<void> {
|
|
902
|
+
const archiver = this.blockSource as Archiver;
|
|
903
|
+
if (!('rollbackTo' in archiver)) {
|
|
904
|
+
throw new Error('Archiver implementation does not support rollbacks.');
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const finalizedBlock = await archiver.getL2Tips().then(tips => tips.finalized.block.number);
|
|
908
|
+
if (targetBlock < finalizedBlock) {
|
|
909
|
+
if (force) {
|
|
910
|
+
this.log.warn(`Clearing world state database to allow rolling back behind finalized block ${finalizedBlock}`);
|
|
911
|
+
await this.worldStateSynchronizer.clear();
|
|
912
|
+
await this.p2pClient.clear();
|
|
913
|
+
} else {
|
|
914
|
+
throw new Error(`Cannot rollback to block ${targetBlock} as it is before finalized ${finalizedBlock}`);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
try {
|
|
919
|
+
this.log.info(`Pausing archiver and world state sync to start rollback`);
|
|
920
|
+
await archiver.stop();
|
|
921
|
+
await this.worldStateSynchronizer.stopSync();
|
|
922
|
+
const currentBlock = await archiver.getBlockNumber();
|
|
923
|
+
const blocksToUnwind = currentBlock - targetBlock;
|
|
924
|
+
this.log.info(`Unwinding ${count(blocksToUnwind, 'block')} from L2 block ${currentBlock} to ${targetBlock}`);
|
|
925
|
+
await archiver.rollbackTo(targetBlock);
|
|
926
|
+
this.log.info(`Unwinding complete.`);
|
|
927
|
+
} catch (err) {
|
|
928
|
+
this.log.error(`Error during rollback`, err);
|
|
929
|
+
throw err;
|
|
930
|
+
} finally {
|
|
931
|
+
if (resumeSync) {
|
|
932
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
933
|
+
this.worldStateSynchronizer.resumeSync();
|
|
934
|
+
archiver.resume();
|
|
935
|
+
} else {
|
|
936
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
public async pauseSync(): Promise<void> {
|
|
942
|
+
this.log.info(`Pausing archiver and world state sync`);
|
|
943
|
+
await (this.blockSource as Archiver).stop();
|
|
944
|
+
await this.worldStateSynchronizer.stopSync();
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
public resumeSync(): Promise<void> {
|
|
948
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
949
|
+
this.worldStateSynchronizer.resumeSync();
|
|
950
|
+
(this.blockSource as Archiver).resume();
|
|
951
|
+
return Promise.resolve();
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
public pauseSequencer(): Promise<void> {
|
|
955
|
+
if (this.automineSequencer) {
|
|
956
|
+
this.automineSequencer.pause();
|
|
957
|
+
return Promise.resolve();
|
|
958
|
+
}
|
|
959
|
+
if (this.sequencer) {
|
|
960
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
961
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
962
|
+
this.sequencer.updateConfig({ minTxsPerBlock: Number.MAX_SAFE_INTEGER });
|
|
963
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
964
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
return Promise.resolve();
|
|
968
|
+
}
|
|
969
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
public resumeSequencer(): Promise<void> {
|
|
973
|
+
if (this.automineSequencer) {
|
|
974
|
+
this.automineSequencer.resume();
|
|
975
|
+
return Promise.resolve();
|
|
976
|
+
}
|
|
977
|
+
if (this.sequencer) {
|
|
978
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
979
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
980
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
981
|
+
this.sequencer.updateConfig({ minTxsPerBlock: restored });
|
|
982
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, { minTxsPerBlock: restored });
|
|
983
|
+
}
|
|
984
|
+
return Promise.resolve();
|
|
985
|
+
}
|
|
986
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
public getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]> {
|
|
990
|
+
if (!this.slasherClient) {
|
|
991
|
+
throw new Error(`Slasher client not enabled`);
|
|
992
|
+
}
|
|
993
|
+
if (round === 'all') {
|
|
994
|
+
return this.slasherClient.getOffenses();
|
|
995
|
+
} else {
|
|
996
|
+
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
public async reloadKeystore(): Promise<void> {
|
|
1001
|
+
if (!this.config.keyStoreDirectory?.length) {
|
|
1002
|
+
throw new BadRequestError(
|
|
1003
|
+
'Cannot reload keystore: node is not using a file-based keystore. ' +
|
|
1004
|
+
'Set KEY_STORE_DIRECTORY to use file-based keystores.',
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
if (!this.validatorClient) {
|
|
1008
|
+
throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
this.log.info('Reloading keystore from disk');
|
|
1012
|
+
|
|
1013
|
+
// Re-read and validate keystore files
|
|
1014
|
+
const keyStores = loadKeystores(this.config.keyStoreDirectory);
|
|
1015
|
+
const newManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
1016
|
+
await newManager.validateSigners();
|
|
1017
|
+
ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
|
|
1018
|
+
|
|
1019
|
+
// Validate that every validator's publisher keys overlap with the L1 signers
|
|
1020
|
+
// that were initialized at startup. Publishers cannot be hot-reloaded, so a
|
|
1021
|
+
// validator with a publisher key that doesn't match any existing L1 signer
|
|
1022
|
+
// would silently fail on every proposer slot.
|
|
1023
|
+
if (this.keyStoreManager && this.sequencer) {
|
|
1024
|
+
const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
|
|
1025
|
+
const availablePublishers = new Set(
|
|
1026
|
+
oldAdapter
|
|
1027
|
+
.getAttesterAddresses()
|
|
1028
|
+
.flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
|
|
1029
|
+
);
|
|
1030
|
+
|
|
1031
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1032
|
+
for (const attester of newAdapter.getAttesterAddresses()) {
|
|
1033
|
+
const pubs = newAdapter.getPublisherAddresses(attester);
|
|
1034
|
+
if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
|
|
1035
|
+
throw new BadRequestError(
|
|
1036
|
+
`Cannot reload keystore: validator ${attester} has publisher keys ` +
|
|
1037
|
+
`[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
|
|
1038
|
+
`[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
|
|
1039
|
+
`use an existing publisher key or restart the node.`,
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// Build adapters for old and new keystores to compute diff
|
|
1046
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
1047
|
+
const newAddresses = newAdapter.getAttesterAddresses();
|
|
1048
|
+
const oldAddresses = this.keyStoreManager
|
|
1049
|
+
? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
|
|
1050
|
+
: [];
|
|
1051
|
+
|
|
1052
|
+
const oldSet = new Set(oldAddresses.map(a => a.toString()));
|
|
1053
|
+
const newSet = new Set(newAddresses.map(a => a.toString()));
|
|
1054
|
+
const added = newAddresses.filter(a => !oldSet.has(a.toString()));
|
|
1055
|
+
const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
|
|
1056
|
+
|
|
1057
|
+
if (added.length > 0) {
|
|
1058
|
+
this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
|
|
1059
|
+
}
|
|
1060
|
+
if (removed.length > 0) {
|
|
1061
|
+
this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
|
|
1062
|
+
}
|
|
1063
|
+
if (added.length === 0 && removed.length === 0) {
|
|
1064
|
+
this.log.info('Keystore reload: attester keys unchanged');
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// Update the validator client (coinbase, feeRecipient, attester keys)
|
|
1068
|
+
this.validatorClient.reloadKeystore(newManager);
|
|
1069
|
+
|
|
1070
|
+
// Update the publisher factory's keystore so newly-added validators
|
|
1071
|
+
// can be matched to existing publisher keys when proposing blocks.
|
|
1072
|
+
if (this.sequencer) {
|
|
1073
|
+
this.sequencer.updatePublisherNodeKeyStore(newAdapter);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// Update slasher's "don't-slash-self" list with new validator addresses
|
|
1077
|
+
if (this.slasherClient && !this.config.slashSelfAllowed) {
|
|
1078
|
+
const slashValidatorsNever = unique(
|
|
1079
|
+
[...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
|
|
1080
|
+
).map(EthAddress.fromString);
|
|
1081
|
+
this.slasherClient.updateConfig({ slashValidatorsNever });
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
this.keyStoreManager = newManager;
|
|
1085
|
+
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
public async mineBlock(): Promise<void> {
|
|
1089
|
+
if (this.automineSequencer) {
|
|
1090
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (!this.sequencer) {
|
|
1094
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1098
|
+
|
|
1099
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1100
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1101
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1102
|
+
|
|
1103
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1104
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1105
|
+
this.sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
1106
|
+
|
|
1107
|
+
try {
|
|
1108
|
+
// Trigger the sequencer to produce a block immediately
|
|
1109
|
+
void this.sequencer.trigger();
|
|
1110
|
+
|
|
1111
|
+
// Wait for the new L2 block to appear
|
|
1112
|
+
await retryUntil(
|
|
1113
|
+
async () => {
|
|
1114
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1115
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1116
|
+
},
|
|
1117
|
+
'mineBlock',
|
|
1118
|
+
timeoutSeconds,
|
|
1119
|
+
0.1,
|
|
1120
|
+
);
|
|
1121
|
+
} finally {
|
|
1122
|
+
this.sequencer.updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
public async prove(upToCheckpoint?: CheckpointNumber): Promise<CheckpointNumber> {
|
|
1127
|
+
if (!this.automineSequencer) {
|
|
1128
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1129
|
+
}
|
|
1130
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
public async warpL2TimeAtLeastTo(targetTimestamp: number): Promise<void> {
|
|
1134
|
+
if (!this.automineSequencer) {
|
|
1135
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1136
|
+
}
|
|
1137
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
public async warpL2TimeAtLeastBy(duration: number): Promise<void> {
|
|
1141
|
+
if (!this.automineSequencer) {
|
|
1142
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1143
|
+
}
|
|
1144
|
+
await this.automineSequencer.warpBy(duration);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1149
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1150
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1151
|
+
*/
|
|
1152
|
+
protected getWorldState(block: BlockParameter) {
|
|
1153
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1154
|
+
}
|
|
1155
|
+
}
|