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