@aztec/aztec-node 0.0.1-commit.a89ec08 → 0.0.1-commit.aa0c64f
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 +17 -5
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +16 -6
- package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +351 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
- package/dest/aztec-node/server.d.ts +130 -133
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +373 -827
- package/dest/bin/index.js +15 -10
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +523 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/modules/block_parameter.d.ts +25 -0
- package/dest/modules/block_parameter.d.ts.map +1 -0
- package/dest/modules/block_parameter.js +100 -0
- package/dest/modules/node_block_provider.d.ts +19 -0
- package/dest/modules/node_block_provider.d.ts.map +1 -0
- package/dest/modules/node_block_provider.js +112 -0
- package/dest/modules/node_tx_receipt.d.ts +24 -0
- package/dest/modules/node_tx_receipt.d.ts.map +1 -0
- package/dest/modules/node_tx_receipt.js +70 -0
- package/dest/modules/node_world_state_queries.d.ts +65 -0
- package/dest/modules/node_world_state_queries.d.ts.map +1 -0
- package/dest/modules/node_world_state_queries.js +272 -0
- package/dest/sentinel/config.d.ts +3 -2
- package/dest/sentinel/config.d.ts.map +1 -1
- package/dest/sentinel/config.js +15 -5
- package/dest/sentinel/factory.d.ts +6 -4
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +12 -5
- package/dest/sentinel/sentinel.d.ts +145 -21
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +227 -105
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +25 -17
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -27
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +31 -8
- package/src/aztec-node/node_public_calls_simulator.ts +394 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
- package/src/aztec-node/server.ts +497 -1082
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +688 -0
- package/src/index.ts +2 -0
- package/src/modules/block_parameter.ts +93 -0
- package/src/modules/node_block_provider.ts +149 -0
- package/src/modules/node_tx_receipt.ts +115 -0
- package/src/modules/node_world_state_queries.ts +374 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +22 -7
- package/src/sentinel/sentinel.ts +277 -130
- package/src/sentinel/store.ts +26 -18
- package/src/test/index.ts +2 -2
|
@@ -371,59 +371,59 @@ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
|
371
371
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
372
|
}
|
|
373
373
|
var _dec, _initProto;
|
|
374
|
-
import {
|
|
375
|
-
import {
|
|
376
|
-
import {
|
|
377
|
-
import { Blob } from '@aztec/blob-lib';
|
|
378
|
-
import { EpochCache } from '@aztec/epoch-cache';
|
|
379
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
380
|
-
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
381
|
-
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
374
|
+
import { BBCircuitVerifier, BatchChonkVerifier, QueuedIVCVerifier } from '@aztec/bb-prover';
|
|
375
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
376
|
+
import { pickL1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
382
377
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
383
|
-
import {
|
|
384
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
378
|
+
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
385
379
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
386
380
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
387
381
|
import { createLogger } from '@aztec/foundation/log';
|
|
388
382
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
389
383
|
import { count } from '@aztec/foundation/string';
|
|
390
|
-
import {
|
|
391
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
384
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
392
385
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
393
|
-
import {
|
|
394
|
-
import {
|
|
395
|
-
import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
386
|
+
import { uploadSnapshot } from '@aztec/node-lib/actions';
|
|
387
|
+
import { createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
396
388
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
397
|
-
import {
|
|
398
|
-
import {
|
|
399
|
-
import {
|
|
400
|
-
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
401
|
-
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
402
|
-
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
403
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
404
|
-
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
405
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
406
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
389
|
+
import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint';
|
|
390
|
+
import { inspectBlockParameter } from '@aztec/stdlib/block';
|
|
391
|
+
import { GasFees, getNetworkTxGasLimits } from '@aztec/stdlib/gas';
|
|
407
392
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
408
393
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
409
|
-
import {
|
|
410
|
-
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
411
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
412
|
-
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
413
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
394
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
414
395
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
415
|
-
import {
|
|
416
|
-
import {
|
|
417
|
-
import {
|
|
418
|
-
import {
|
|
419
|
-
import { createKeyStoreForValidator } from './config.js';
|
|
396
|
+
import { NodeKeystoreAdapter, ValidatorClient } from '@aztec/validator-client';
|
|
397
|
+
import { NodeBlockProvider } from '../modules/node_block_provider.js';
|
|
398
|
+
import { NodeTxReceiptBuilder } from '../modules/node_tx_receipt.js';
|
|
399
|
+
import { NodeWorldStateQueries } from '../modules/node_world_state_queries.js';
|
|
420
400
|
import { NodeMetrics } from './node_metrics.js';
|
|
401
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
421
402
|
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
422
403
|
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
423
404
|
}));
|
|
424
405
|
/**
|
|
425
406
|
* The aztec node.
|
|
426
407
|
*/ export class AztecNodeService {
|
|
408
|
+
static{
|
|
409
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
410
|
+
[
|
|
411
|
+
_dec,
|
|
412
|
+
2,
|
|
413
|
+
"simulatePublicCalls"
|
|
414
|
+
]
|
|
415
|
+
], []));
|
|
416
|
+
}
|
|
417
|
+
metrics;
|
|
418
|
+
// Prevent two snapshot operations to happen simultaneously
|
|
419
|
+
isUploadingSnapshot = (_initProto(this), false);
|
|
420
|
+
// Saved minTxsPerBlock used by `pauseSequencer` to restore production-sequencer config on resume.
|
|
421
|
+
sequencerPausedMinTxsPerBlock;
|
|
422
|
+
nodePublicCallsSimulator;
|
|
423
|
+
worldStateQueries;
|
|
424
|
+
blockProvider;
|
|
425
|
+
txReceiptBuilder;
|
|
426
|
+
tracer;
|
|
427
427
|
config;
|
|
428
428
|
p2pClient;
|
|
429
429
|
blockSource;
|
|
@@ -435,358 +435,155 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
435
435
|
proverNode;
|
|
436
436
|
slasherClient;
|
|
437
437
|
validatorsSentinel;
|
|
438
|
-
|
|
438
|
+
stopStartedWatchers;
|
|
439
439
|
l1ChainId;
|
|
440
440
|
version;
|
|
441
441
|
globalVariableBuilder;
|
|
442
|
+
rollupContract;
|
|
443
|
+
feeProvider;
|
|
442
444
|
epochCache;
|
|
443
445
|
packageVersion;
|
|
444
|
-
|
|
446
|
+
peerProofVerifier;
|
|
447
|
+
rpcProofVerifier;
|
|
445
448
|
telemetry;
|
|
446
449
|
log;
|
|
447
450
|
blobClient;
|
|
448
451
|
validatorClient;
|
|
449
452
|
keyStoreManager;
|
|
450
453
|
debugLogStore;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
this.
|
|
467
|
-
this.
|
|
468
|
-
this.
|
|
469
|
-
this.
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
473
|
-
this.
|
|
474
|
-
this.
|
|
475
|
-
this.
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
481
|
-
this.
|
|
482
|
-
this.
|
|
483
|
-
this.
|
|
484
|
-
this.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
this.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
454
|
+
automineSequencer;
|
|
455
|
+
avmSimulator;
|
|
456
|
+
constructor(deps){
|
|
457
|
+
this.config = deps.config;
|
|
458
|
+
this.p2pClient = deps.p2pClient;
|
|
459
|
+
this.blockSource = deps.blockSource;
|
|
460
|
+
this.logsSource = deps.logsSource;
|
|
461
|
+
this.contractDataSource = deps.contractDataSource;
|
|
462
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
463
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
464
|
+
this.sequencer = deps.sequencer;
|
|
465
|
+
this.proverNode = deps.proverNode;
|
|
466
|
+
this.slasherClient = deps.slasherClient;
|
|
467
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
468
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
469
|
+
this.l1ChainId = deps.l1ChainId;
|
|
470
|
+
this.version = deps.version;
|
|
471
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
472
|
+
this.rollupContract = deps.rollupContract;
|
|
473
|
+
this.feeProvider = deps.feeProvider;
|
|
474
|
+
this.epochCache = deps.epochCache;
|
|
475
|
+
this.packageVersion = deps.packageVersion;
|
|
476
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
477
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
478
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
479
|
+
this.log = deps.log ?? createLogger('node');
|
|
480
|
+
this.blobClient = deps.blobClient;
|
|
481
|
+
this.validatorClient = deps.validatorClient;
|
|
482
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
483
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
484
|
+
this.automineSequencer = deps.automineSequencer;
|
|
485
|
+
this.avmSimulator = deps.avmSimulator;
|
|
486
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
487
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
488
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
489
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
490
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
491
|
+
blockSource: this.blockSource,
|
|
492
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
493
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
494
|
+
contractDataSource: this.contractDataSource,
|
|
495
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
496
|
+
rollupContract: this.rollupContract,
|
|
497
|
+
epochCache: this.epochCache,
|
|
498
|
+
signatureContext: {
|
|
499
|
+
chainId: this.l1ChainId,
|
|
500
|
+
rollupAddress: this.config.rollupAddress
|
|
501
|
+
},
|
|
502
|
+
config: this.config,
|
|
503
|
+
avmSimulator: this.avmSimulator,
|
|
504
|
+
telemetry: this.telemetry,
|
|
505
|
+
log: this.log.createChild('public-calls-simulator')
|
|
506
|
+
});
|
|
507
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
508
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
509
|
+
blockSource: this.blockSource,
|
|
510
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
511
|
+
log: this.log.createChild('world-state-queries')
|
|
512
|
+
});
|
|
513
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
514
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
515
|
+
p2pClient: this.p2pClient,
|
|
516
|
+
blockSource: this.blockSource,
|
|
517
|
+
debugLogStore: this.debugLogStore
|
|
518
|
+
});
|
|
494
519
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
495
|
-
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config
|
|
496
|
-
// A defensive check that protects us against introducing a bug in the complex
|
|
520
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
521
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
497
522
|
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
498
523
|
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
499
|
-
if (debugLogStore.isEnabled && config.realProofs) {
|
|
524
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
500
525
|
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
501
526
|
}
|
|
502
527
|
}
|
|
528
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
529
|
+
return this.rpcProofVerifier;
|
|
530
|
+
}
|
|
503
531
|
async getWorldStateSyncStatus() {
|
|
504
532
|
const status = await this.worldStateSynchronizer.status();
|
|
505
533
|
return status.syncSummary;
|
|
506
534
|
}
|
|
507
|
-
|
|
535
|
+
getChainTips() {
|
|
508
536
|
return this.blockSource.getL2Tips();
|
|
509
537
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
529
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
530
|
-
} else {
|
|
531
|
-
const rawKeyStores = [];
|
|
532
|
-
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
533
|
-
if (validatorKeyStore) {
|
|
534
|
-
rawKeyStores.push(validatorKeyStore);
|
|
535
|
-
}
|
|
536
|
-
if (config.enableProverNode) {
|
|
537
|
-
const proverKeyStore = createKeyStoreForProver(config);
|
|
538
|
-
if (proverKeyStore) {
|
|
539
|
-
rawKeyStores.push(proverKeyStore);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
if (rawKeyStores.length > 0) {
|
|
543
|
-
keyStoreManager = new KeystoreManager(rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores));
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
await keyStoreManager?.validateSigners();
|
|
547
|
-
// If we are a validator, verify our configuration before doing too much more.
|
|
548
|
-
if (!config.disableValidator) {
|
|
549
|
-
if (keyStoreManager === undefined) {
|
|
550
|
-
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
551
|
-
}
|
|
552
|
-
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
553
|
-
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
554
|
-
}
|
|
555
|
-
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
556
|
-
}
|
|
557
|
-
// validate that the actual chain id matches that specified in configuration
|
|
558
|
-
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
559
|
-
throw new Error(`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`);
|
|
560
|
-
}
|
|
561
|
-
const publicClient = createPublicClient({
|
|
562
|
-
chain: ethereumChain.chainInfo,
|
|
563
|
-
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
564
|
-
timeout: config.l1HttpTimeoutMS
|
|
565
|
-
}),
|
|
566
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
567
|
-
});
|
|
568
|
-
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
569
|
-
// Overwrite the passed in vars.
|
|
570
|
-
config.l1Contracts = {
|
|
571
|
-
...config.l1Contracts,
|
|
572
|
-
...l1ContractsAddresses
|
|
573
|
-
};
|
|
574
|
-
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
575
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
576
|
-
rollupContract.getL1GenesisTime(),
|
|
577
|
-
rollupContract.getSlotDuration(),
|
|
578
|
-
rollupContract.getVersion(),
|
|
579
|
-
rollupContract.getManaLimit().then(Number)
|
|
580
|
-
]);
|
|
581
|
-
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
582
|
-
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
583
|
-
log.warn(`Registry looked up and returned a rollup with version (${config.rollupVersion}), but this does not match with version detected from the rollup directly: (${rollupVersionFromRollup}).`);
|
|
584
|
-
}
|
|
585
|
-
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
586
|
-
// attempt snapshot sync if possible
|
|
587
|
-
await trySnapshotSync(config, log);
|
|
588
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
589
|
-
dateProvider
|
|
590
|
-
});
|
|
591
|
-
const archiver = await createArchiver(config, {
|
|
592
|
-
blobClient,
|
|
593
|
-
epochCache,
|
|
594
|
-
telemetry,
|
|
595
|
-
dateProvider
|
|
596
|
-
}, {
|
|
597
|
-
blockUntilSync: !config.skipArchiverInitialSync
|
|
598
|
-
});
|
|
599
|
-
// now create the merkle trees and the world state synchronizer
|
|
600
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
601
|
-
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
602
|
-
let debugLogStore;
|
|
603
|
-
if (!config.realProofs) {
|
|
604
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
605
|
-
debugLogStore = new InMemoryDebugLogStore();
|
|
606
|
-
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
607
|
-
} else {
|
|
608
|
-
debugLogStore = new NullDebugLogStore();
|
|
609
|
-
}
|
|
610
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
611
|
-
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
612
|
-
if (proverOnly) {
|
|
613
|
-
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
614
|
-
}
|
|
615
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
616
|
-
const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
617
|
-
// We'll accumulate sentinel watchers here
|
|
618
|
-
const watchers = [];
|
|
619
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
620
|
-
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
621
|
-
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
622
|
-
...config,
|
|
623
|
-
l1GenesisTime,
|
|
624
|
-
slotDuration: Number(slotDuration),
|
|
625
|
-
rollupManaLimit,
|
|
626
|
-
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
627
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
628
|
-
let validatorClient;
|
|
629
|
-
if (!proverOnly) {
|
|
630
|
-
// Create validator client if required
|
|
631
|
-
validatorClient = await createValidatorClient(config, {
|
|
632
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
633
|
-
worldState: worldStateSynchronizer,
|
|
634
|
-
p2pClient,
|
|
635
|
-
telemetry,
|
|
636
|
-
dateProvider,
|
|
637
|
-
epochCache,
|
|
638
|
-
blockSource: archiver,
|
|
639
|
-
l1ToL2MessageSource: archiver,
|
|
640
|
-
keyStoreManager,
|
|
641
|
-
blobClient,
|
|
642
|
-
slashingProtectionDb: deps.slashingProtectionDb
|
|
643
|
-
});
|
|
644
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
645
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
646
|
-
// like attestations or auths will fail.
|
|
647
|
-
if (validatorClient) {
|
|
648
|
-
watchers.push(validatorClient);
|
|
649
|
-
if (!options.dontStartSequencer) {
|
|
650
|
-
await validatorClient.registerHandlers();
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
655
|
-
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
656
|
-
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
657
|
-
// Checkpoint proposals are handled if the blob client can upload blobs.
|
|
658
|
-
if (!validatorClient) {
|
|
659
|
-
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
660
|
-
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
661
|
-
createProposalHandler(config, {
|
|
662
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
663
|
-
worldState: worldStateSynchronizer,
|
|
664
|
-
epochCache,
|
|
665
|
-
blockSource: archiver,
|
|
666
|
-
l1ToL2MessageSource: archiver,
|
|
667
|
-
p2pClient,
|
|
668
|
-
blobClient,
|
|
669
|
-
dateProvider,
|
|
670
|
-
telemetry
|
|
671
|
-
}).register(p2pClient, reexecute);
|
|
672
|
-
}
|
|
673
|
-
// Start world state and wait for it to sync to the archiver.
|
|
674
|
-
await worldStateSynchronizer.start();
|
|
675
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
676
|
-
await p2pClient.start();
|
|
677
|
-
let validatorsSentinel;
|
|
678
|
-
let epochPruneWatcher;
|
|
679
|
-
let attestationsBlockWatcher;
|
|
680
|
-
if (!proverOnly) {
|
|
681
|
-
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
682
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
683
|
-
watchers.push(validatorsSentinel);
|
|
684
|
-
}
|
|
685
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
686
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
687
|
-
watchers.push(epochPruneWatcher);
|
|
688
|
-
}
|
|
689
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
690
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
691
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
692
|
-
watchers.push(attestationsBlockWatcher);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
// Start p2p-related services once the archiver has completed sync
|
|
696
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
697
|
-
await p2pClient.start();
|
|
698
|
-
await validatorsSentinel?.start();
|
|
699
|
-
await epochPruneWatcher?.start();
|
|
700
|
-
await attestationsBlockWatcher?.start();
|
|
701
|
-
log.info(`All p2p services started`);
|
|
702
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
703
|
-
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
704
|
-
l1Contracts: config.l1Contracts,
|
|
705
|
-
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
706
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
707
|
-
l1GenesisTime,
|
|
708
|
-
slotDuration: Number(slotDuration)
|
|
709
|
-
});
|
|
710
|
-
// Validator enabled, create/start relevant service
|
|
711
|
-
let sequencer;
|
|
712
|
-
let slasherClient;
|
|
713
|
-
if (!config.disableValidator && validatorClient) {
|
|
714
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
715
|
-
// as they are executed when the node is selected as proposer.
|
|
716
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
717
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
718
|
-
await slasherClient.start();
|
|
719
|
-
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
720
|
-
...config,
|
|
721
|
-
scope: 'sequencer'
|
|
722
|
-
}, {
|
|
723
|
-
telemetry,
|
|
724
|
-
logger: log.createChild('l1-tx-utils'),
|
|
725
|
-
dateProvider,
|
|
726
|
-
kzg: Blob.getViemKzgInstance()
|
|
727
|
-
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
728
|
-
...config,
|
|
729
|
-
scope: 'sequencer'
|
|
730
|
-
}, {
|
|
731
|
-
telemetry,
|
|
732
|
-
logger: log.createChild('l1-tx-utils'),
|
|
733
|
-
dateProvider,
|
|
734
|
-
kzg: Blob.getViemKzgInstance()
|
|
735
|
-
});
|
|
736
|
-
// Create and start the sequencer client
|
|
737
|
-
const checkpointsBuilder = new CheckpointsBuilder({
|
|
738
|
-
...config,
|
|
739
|
-
l1GenesisTime,
|
|
740
|
-
slotDuration: Number(slotDuration),
|
|
741
|
-
rollupManaLimit
|
|
742
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
743
|
-
sequencer = await SequencerClient.new(config, {
|
|
744
|
-
...deps,
|
|
745
|
-
epochCache,
|
|
746
|
-
l1TxUtils,
|
|
747
|
-
validatorClient,
|
|
748
|
-
p2pClient,
|
|
749
|
-
worldStateSynchronizer,
|
|
750
|
-
slasherClient,
|
|
751
|
-
checkpointsBuilder,
|
|
752
|
-
l2BlockSource: archiver,
|
|
753
|
-
l1ToL2MessageSource: archiver,
|
|
754
|
-
telemetry,
|
|
755
|
-
dateProvider,
|
|
756
|
-
blobClient,
|
|
757
|
-
nodeKeyStore: keyStoreManager,
|
|
758
|
-
globalVariableBuilder
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
if (!options.dontStartSequencer && sequencer) {
|
|
762
|
-
await sequencer.start();
|
|
763
|
-
log.verbose(`Sequencer started`);
|
|
764
|
-
} else if (sequencer) {
|
|
765
|
-
log.warn(`Sequencer created but not started`);
|
|
538
|
+
getL1Constants() {
|
|
539
|
+
return this.blockSource.getL1Constants();
|
|
540
|
+
}
|
|
541
|
+
getSyncedL2SlotNumber() {
|
|
542
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
543
|
+
}
|
|
544
|
+
getSyncedL2EpochNumber() {
|
|
545
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
546
|
+
}
|
|
547
|
+
getSyncedL1Timestamp() {
|
|
548
|
+
return this.blockSource.getL1Timestamp();
|
|
549
|
+
}
|
|
550
|
+
getCheckpointsData(query) {
|
|
551
|
+
return this.blockSource.getCheckpointsData(query);
|
|
552
|
+
}
|
|
553
|
+
async getBlockNumber(tip) {
|
|
554
|
+
if (tip === undefined || tip === 'proposed') {
|
|
555
|
+
return this.blockSource.getBlockNumber();
|
|
766
556
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
if (!options.dontStartProverNode) {
|
|
782
|
-
await proverNode.start();
|
|
783
|
-
log.info(`Prover node subsystem started`);
|
|
784
|
-
} else {
|
|
785
|
-
log.info(`Prover node subsystem created but not started`);
|
|
786
|
-
}
|
|
557
|
+
return await this.blockSource.getBlockNumber({
|
|
558
|
+
tag: tip
|
|
559
|
+
}) ?? BlockNumber.ZERO;
|
|
560
|
+
}
|
|
561
|
+
async getCheckpointNumber(tip) {
|
|
562
|
+
const tips = await this.blockSource.getL2Tips();
|
|
563
|
+
switch(tip){
|
|
564
|
+
case undefined:
|
|
565
|
+
case 'checkpointed':
|
|
566
|
+
return tips.checkpointed.checkpoint.number;
|
|
567
|
+
case 'proven':
|
|
568
|
+
return tips.proven.checkpoint.number;
|
|
569
|
+
case 'finalized':
|
|
570
|
+
return tips.finalized.checkpoint.number;
|
|
787
571
|
}
|
|
788
|
-
|
|
789
|
-
|
|
572
|
+
}
|
|
573
|
+
getBlock(param, options = {}) {
|
|
574
|
+
return this.blockProvider.getBlock(param, options);
|
|
575
|
+
}
|
|
576
|
+
getBlockData(param) {
|
|
577
|
+
return this.blockProvider.getBlockData(param);
|
|
578
|
+
}
|
|
579
|
+
getBlocks(from, limit, options = {}) {
|
|
580
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
581
|
+
}
|
|
582
|
+
getCheckpoint(param, options = {}) {
|
|
583
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
584
|
+
}
|
|
585
|
+
getCheckpoints(from, limit, options = {}) {
|
|
586
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
790
587
|
}
|
|
791
588
|
/**
|
|
792
589
|
* Returns the sequencer client instance.
|
|
@@ -794,6 +591,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
794
591
|
*/ getSequencer() {
|
|
795
592
|
return this.sequencer;
|
|
796
593
|
}
|
|
594
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */ getAutomineSequencer() {
|
|
595
|
+
return this.automineSequencer;
|
|
596
|
+
}
|
|
797
597
|
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
798
598
|
return this.proverNode;
|
|
799
599
|
}
|
|
@@ -810,7 +610,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
810
610
|
* Method to return the currently deployed L1 contract addresses.
|
|
811
611
|
* @returns - The currently deployed L1 contract addresses.
|
|
812
612
|
*/ getL1ContractAddresses() {
|
|
813
|
-
return Promise.resolve(this.config
|
|
613
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
814
614
|
}
|
|
815
615
|
getEncodedEnr() {
|
|
816
616
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
@@ -828,14 +628,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
828
628
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
829
629
|
}
|
|
830
630
|
async getNodeInfo() {
|
|
831
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
631
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
832
632
|
this.getNodeVersion(),
|
|
833
633
|
this.getVersion(),
|
|
834
634
|
this.getChainId(),
|
|
835
635
|
this.getEncodedEnr(),
|
|
836
636
|
this.getL1ContractAddresses(),
|
|
837
|
-
this.getProtocolContractAddresses()
|
|
637
|
+
this.getProtocolContractAddresses(),
|
|
638
|
+
this.blockSource.getL1Constants()
|
|
838
639
|
]);
|
|
640
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
641
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
642
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
643
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
644
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
839
645
|
const nodeInfo = {
|
|
840
646
|
nodeVersion,
|
|
841
647
|
l1ChainId: chainId,
|
|
@@ -843,71 +649,26 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
843
649
|
enr,
|
|
844
650
|
l1ContractAddresses: contractAddresses,
|
|
845
651
|
protocolContractAddresses: protocolContractAddresses,
|
|
846
|
-
realProofs: !!this.config.realProofs
|
|
652
|
+
realProofs: !!this.config.realProofs,
|
|
653
|
+
txsLimits: {
|
|
654
|
+
gas: {
|
|
655
|
+
daGas: maxTxGas.daGas,
|
|
656
|
+
l2Gas: maxTxGas.l2Gas
|
|
657
|
+
}
|
|
658
|
+
}
|
|
847
659
|
};
|
|
848
660
|
return nodeInfo;
|
|
849
661
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
853
|
-
* @returns The requested block.
|
|
854
|
-
*/ async getBlock(block) {
|
|
855
|
-
if (BlockHash.isBlockHash(block)) {
|
|
856
|
-
return this.getBlockByHash(block);
|
|
857
|
-
}
|
|
858
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
859
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
860
|
-
return this.buildInitialBlock();
|
|
861
|
-
}
|
|
862
|
-
return await this.blockSource.getL2Block(blockNumber);
|
|
662
|
+
async getCurrentMinFees() {
|
|
663
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
863
664
|
}
|
|
864
|
-
/**
|
|
865
|
-
|
|
866
|
-
* @param blockHash - The block hash being requested.
|
|
867
|
-
* @returns The requested block.
|
|
868
|
-
*/ async getBlockByHash(blockHash) {
|
|
869
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
870
|
-
if (blockHash.equals(initialBlockHash)) {
|
|
871
|
-
return this.buildInitialBlock();
|
|
872
|
-
}
|
|
873
|
-
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
874
|
-
}
|
|
875
|
-
buildInitialBlock() {
|
|
876
|
-
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
877
|
-
return L2Block.empty(initialHeader);
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* Get a block specified by its archive root.
|
|
881
|
-
* @param archive - The archive root being requested.
|
|
882
|
-
* @returns The requested block.
|
|
883
|
-
*/ async getBlockByArchive(archive) {
|
|
884
|
-
return await this.blockSource.getL2BlockByArchive(archive);
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
888
|
-
* @param from - The start of the range of blocks to return.
|
|
889
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
890
|
-
* @returns The blocks requested.
|
|
891
|
-
*/ async getBlocks(from, limit) {
|
|
892
|
-
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
893
|
-
}
|
|
894
|
-
async getCheckpoints(from, limit) {
|
|
895
|
-
return await this.blockSource.getCheckpoints(from, limit) ?? [];
|
|
896
|
-
}
|
|
897
|
-
async getCheckpointedBlocks(from, limit) {
|
|
898
|
-
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
899
|
-
}
|
|
900
|
-
getCheckpointsDataForEpoch(epochNumber) {
|
|
901
|
-
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Method to fetch the current min L2 fees.
|
|
905
|
-
* @returns The current min L2 fees.
|
|
906
|
-
*/ async getCurrentMinFees() {
|
|
907
|
-
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
665
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
666
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
908
667
|
}
|
|
909
668
|
async getMaxPriorityFees() {
|
|
910
|
-
for await (const tx of this.p2pClient.iteratePendingTxs(
|
|
669
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({
|
|
670
|
+
includeProof: false
|
|
671
|
+
})){
|
|
911
672
|
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
912
673
|
}
|
|
913
674
|
return GasFees.from({
|
|
@@ -916,21 +677,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
916
677
|
});
|
|
917
678
|
}
|
|
918
679
|
/**
|
|
919
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
920
|
-
* @returns The block number.
|
|
921
|
-
*/ async getBlockNumber() {
|
|
922
|
-
return await this.blockSource.getBlockNumber();
|
|
923
|
-
}
|
|
924
|
-
async getProvenBlockNumber() {
|
|
925
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
926
|
-
}
|
|
927
|
-
async getCheckpointedBlockNumber() {
|
|
928
|
-
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
929
|
-
}
|
|
930
|
-
getCheckpointNumber() {
|
|
931
|
-
return this.blockSource.getCheckpointNumber();
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
680
|
* Method to fetch the version of the package.
|
|
935
681
|
* @returns The node package version
|
|
936
682
|
*/ getNodeVersion() {
|
|
@@ -951,46 +697,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
951
697
|
getContractClass(id) {
|
|
952
698
|
return this.contractDataSource.getContractClass(id);
|
|
953
699
|
}
|
|
954
|
-
getContract(address) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
if (referenceBlock) {
|
|
959
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
960
|
-
if (!referenceBlock.equals(initialBlockHash)) {
|
|
961
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
962
|
-
if (!header) {
|
|
963
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
968
|
-
}
|
|
969
|
-
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
970
|
-
if (referenceBlock) {
|
|
971
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
972
|
-
if (!referenceBlock.equals(initialBlockHash)) {
|
|
973
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
974
|
-
if (!header) {
|
|
975
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
700
|
+
async getContract(address, referenceBlock = 'latest') {
|
|
701
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
702
|
+
if (!blockData) {
|
|
703
|
+
throw new Error(`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.`);
|
|
978
704
|
}
|
|
979
|
-
return this.
|
|
705
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
980
706
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
* @param filter - The filter to apply to the logs.
|
|
984
|
-
* @returns The requested logs.
|
|
985
|
-
*/ getPublicLogs(filter) {
|
|
986
|
-
return this.logsSource.getPublicLogs(filter);
|
|
707
|
+
getPrivateLogsByTags(query) {
|
|
708
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
987
709
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
* @param filter - The filter to apply to the logs.
|
|
991
|
-
* @returns The requested logs.
|
|
992
|
-
*/ getContractClassLogs(filter) {
|
|
993
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
710
|
+
getPublicLogsByTags(query) {
|
|
711
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
994
712
|
}
|
|
995
713
|
/**
|
|
996
714
|
* Method to submit a transaction to the p2p pool.
|
|
@@ -1010,34 +728,23 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1010
728
|
});
|
|
1011
729
|
throw new Error(`Invalid tx: ${reason}`);
|
|
1012
730
|
}
|
|
1013
|
-
|
|
731
|
+
try {
|
|
732
|
+
await this.p2pClient.sendTx(tx);
|
|
733
|
+
} catch (err) {
|
|
734
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
735
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${err.message}`, {
|
|
736
|
+
txHash
|
|
737
|
+
});
|
|
738
|
+
throw err;
|
|
739
|
+
}
|
|
1014
740
|
const duration = timer.ms();
|
|
1015
741
|
this.metrics.receivedTx(duration, true);
|
|
1016
742
|
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
1017
743
|
txHash
|
|
1018
744
|
});
|
|
1019
745
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
// as a fallback if we don't find a settled receipt in the archiver.
|
|
1023
|
-
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
1024
|
-
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
1025
|
-
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
1026
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1027
|
-
let receipt;
|
|
1028
|
-
if (settledTxReceipt) {
|
|
1029
|
-
receipt = settledTxReceipt;
|
|
1030
|
-
} else if (isKnownToPool) {
|
|
1031
|
-
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1032
|
-
// This handles race conditions between archiver and p2p, where the archiver
|
|
1033
|
-
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1034
|
-
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1035
|
-
} else {
|
|
1036
|
-
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1037
|
-
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
1038
|
-
}
|
|
1039
|
-
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1040
|
-
return receipt;
|
|
746
|
+
getTxReceipt(txHash, options) {
|
|
747
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
1041
748
|
}
|
|
1042
749
|
getTxEffect(txHash) {
|
|
1043
750
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -1046,13 +753,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1046
753
|
* Method to stop the aztec node.
|
|
1047
754
|
*/ async stop() {
|
|
1048
755
|
this.log.info(`Stopping Aztec Node`);
|
|
1049
|
-
await
|
|
1050
|
-
await tryStop(this.epochPruneWatcher);
|
|
756
|
+
await this.stopStartedWatchers();
|
|
1051
757
|
await tryStop(this.slasherClient);
|
|
1052
|
-
await
|
|
758
|
+
await Promise.all([
|
|
759
|
+
tryStop(this.peerProofVerifier),
|
|
760
|
+
tryStop(this.rpcProofVerifier)
|
|
761
|
+
]);
|
|
1053
762
|
await tryStop(this.sequencer);
|
|
763
|
+
await tryStop(this.automineSequencer);
|
|
1054
764
|
await tryStop(this.proverNode);
|
|
1055
765
|
await tryStop(this.p2pClient);
|
|
766
|
+
// Dispose the AVM backend before world state: it kills the bb-avm-sim processes and closes the CDB IPC
|
|
767
|
+
// server, releasing their connections to the WSDB so it shuts down cleanly (and freeing the
|
|
768
|
+
// Server/Socket/ChildProcess handles that would otherwise keep the process alive after teardown).
|
|
769
|
+
await this.avmSimulator?.[Symbol.asyncDispose]();
|
|
1056
770
|
await tryStop(this.worldStateSynchronizer);
|
|
1057
771
|
await tryStop(this.blockSource);
|
|
1058
772
|
await tryStop(this.blobClient);
|
|
@@ -1070,286 +784,105 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1070
784
|
* @param limit - The number of items to returns
|
|
1071
785
|
* @param after - The last known pending tx. Used for pagination
|
|
1072
786
|
* @returns - The pending txs.
|
|
1073
|
-
*/ getPendingTxs(limit, after) {
|
|
1074
|
-
return this.p2pClient.getPendingTxs(limit, after);
|
|
787
|
+
*/ getPendingTxs(limit, after, options) {
|
|
788
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
1075
789
|
}
|
|
1076
790
|
getPendingTxCount() {
|
|
1077
791
|
return this.p2pClient.getPendingTxCount();
|
|
1078
792
|
}
|
|
793
|
+
getPeers(includePending) {
|
|
794
|
+
return this.p2pClient.getPeers(includePending);
|
|
795
|
+
}
|
|
796
|
+
getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
797
|
+
return this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
798
|
+
}
|
|
799
|
+
getProposalsForSlot(slot) {
|
|
800
|
+
return this.p2pClient.getProposalsForSlot(slot);
|
|
801
|
+
}
|
|
1079
802
|
/**
|
|
1080
|
-
* Method to retrieve a single tx from the mempool or unfinalized chain.
|
|
803
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
804
|
+
* when `includeProof` is set.
|
|
1081
805
|
* @param txHash - The transaction hash to return.
|
|
806
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
1082
807
|
* @returns - The tx if it exists.
|
|
1083
|
-
*/ getTxByHash(txHash) {
|
|
1084
|
-
return
|
|
808
|
+
*/ getTxByHash(txHash, options) {
|
|
809
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
810
|
+
includeProof: !!options?.includeProof
|
|
811
|
+
});
|
|
1085
812
|
}
|
|
1086
813
|
/**
|
|
1087
|
-
* Method to retrieve txs from the mempool or unfinalized chain.
|
|
814
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
815
|
+
* `includeProof` is set.
|
|
1088
816
|
* @param txHash - The transaction hash to return.
|
|
817
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
1089
818
|
* @returns - The txs if it exists.
|
|
1090
|
-
*/ async getTxsByHash(txHashes) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1094
|
-
const committedDb = await this.getWorldState(referenceBlock);
|
|
1095
|
-
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1096
|
-
// Filter out undefined values to query block numbers only for found leaves
|
|
1097
|
-
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1098
|
-
// Now we find the block numbers for the defined indices
|
|
1099
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1100
|
-
// Build a map from leaf index to block number
|
|
1101
|
-
const indexToBlockNumber = new Map();
|
|
1102
|
-
for(let i = 0; i < definedIndices.length; i++){
|
|
1103
|
-
const blockNumber = blockNumbers[i];
|
|
1104
|
-
if (blockNumber === undefined) {
|
|
1105
|
-
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1106
|
-
}
|
|
1107
|
-
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1108
|
-
}
|
|
1109
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1110
|
-
const uniqueBlockNumbers = [
|
|
1111
|
-
...new Set(indexToBlockNumber.values())
|
|
1112
|
-
];
|
|
1113
|
-
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1114
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1115
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1116
|
-
}));
|
|
1117
|
-
// Build a map from block number to block hash
|
|
1118
|
-
const blockNumberToHash = new Map();
|
|
1119
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1120
|
-
const blockHash = blockHashes[i];
|
|
1121
|
-
if (blockHash === undefined) {
|
|
1122
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1123
|
-
}
|
|
1124
|
-
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1125
|
-
}
|
|
1126
|
-
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1127
|
-
return maybeIndices.map((index)=>{
|
|
1128
|
-
if (index === undefined) {
|
|
1129
|
-
return undefined;
|
|
1130
|
-
}
|
|
1131
|
-
const blockNumber = indexToBlockNumber.get(index);
|
|
1132
|
-
if (blockNumber === undefined) {
|
|
1133
|
-
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1134
|
-
}
|
|
1135
|
-
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1136
|
-
if (blockHash === undefined) {
|
|
1137
|
-
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1138
|
-
}
|
|
1139
|
-
return {
|
|
1140
|
-
l2BlockNumber: blockNumber,
|
|
1141
|
-
l2BlockHash: new BlockHash(blockHash),
|
|
1142
|
-
data: index
|
|
1143
|
-
};
|
|
819
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
820
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
821
|
+
includeProof: !!options?.includeProof
|
|
1144
822
|
});
|
|
823
|
+
return compactArray(txs);
|
|
1145
824
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
if (referenceBlock === BlockNumber.ZERO) {
|
|
1149
|
-
return undefined;
|
|
1150
|
-
}
|
|
1151
|
-
if (BlockHash.isBlockHash(referenceBlock)) {
|
|
1152
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1153
|
-
if (referenceBlock.equals(initialBlockHash)) {
|
|
1154
|
-
return undefined;
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1158
|
-
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1159
|
-
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1160
|
-
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1161
|
-
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1162
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1163
|
-
blockHash
|
|
1164
|
-
]);
|
|
1165
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
825
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
826
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
1166
827
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1170
|
-
noteHash
|
|
1171
|
-
]);
|
|
1172
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
828
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
829
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
1173
830
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1177
|
-
l1ToL2Message
|
|
1178
|
-
]);
|
|
1179
|
-
if (!witness) {
|
|
1180
|
-
return undefined;
|
|
1181
|
-
}
|
|
1182
|
-
// REFACTOR: Return a MembershipWitness object
|
|
1183
|
-
return [
|
|
1184
|
-
witness.index,
|
|
1185
|
-
witness.path
|
|
1186
|
-
];
|
|
831
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
832
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
1187
833
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
834
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
835
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
1191
836
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
1195
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
1196
|
-
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
1197
|
-
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1198
|
-
return messageIndex !== undefined;
|
|
837
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
838
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
1199
839
|
}
|
|
1200
840
|
/**
|
|
1201
841
|
* Returns all the L2 to L1 messages in an epoch.
|
|
842
|
+
*
|
|
843
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
844
|
+
*
|
|
1202
845
|
* @param epoch - The epoch at which to get the data.
|
|
1203
846
|
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1204
|
-
*/
|
|
1205
|
-
|
|
1206
|
-
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1207
|
-
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1208
|
-
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1209
|
-
}
|
|
1210
|
-
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1211
|
-
const db = await this.getWorldState(referenceBlock);
|
|
1212
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1213
|
-
nullifier.toBuffer()
|
|
1214
|
-
]);
|
|
1215
|
-
if (!witness) {
|
|
1216
|
-
return undefined;
|
|
1217
|
-
}
|
|
1218
|
-
const { index, path } = witness;
|
|
1219
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1220
|
-
if (!leafPreimage) {
|
|
1221
|
-
return undefined;
|
|
1222
|
-
}
|
|
1223
|
-
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
847
|
+
*/ getL2ToL1Messages(epoch) {
|
|
848
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
1224
849
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}
|
|
1231
|
-
const { index, alreadyPresent } = findResult;
|
|
1232
|
-
if (alreadyPresent) {
|
|
1233
|
-
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1234
|
-
}
|
|
1235
|
-
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1236
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1237
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1238
|
-
}
|
|
1239
|
-
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1240
|
-
const committedDb = await this.getWorldState(referenceBlock);
|
|
1241
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1242
|
-
if (!lowLeafResult) {
|
|
1243
|
-
return undefined;
|
|
1244
|
-
} else {
|
|
1245
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1246
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1247
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
1248
|
-
}
|
|
850
|
+
/**
|
|
851
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
852
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
853
|
+
*/ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
|
|
854
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
1249
855
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1253
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1254
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
1255
|
-
return Fr.ZERO;
|
|
1256
|
-
}
|
|
1257
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1258
|
-
return preimage.leaf.value;
|
|
1259
|
-
}
|
|
1260
|
-
async getBlockHeader(block = 'latest') {
|
|
1261
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1262
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1263
|
-
if (block.equals(initialBlockHash)) {
|
|
1264
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1265
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1266
|
-
}
|
|
1267
|
-
return this.blockSource.getBlockHeaderByHash(block);
|
|
1268
|
-
} else {
|
|
1269
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1270
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1271
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
1272
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1273
|
-
}
|
|
1274
|
-
return this.blockSource.getBlockHeader(block);
|
|
1275
|
-
}
|
|
856
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
857
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1276
858
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
* @param archive - The archive root being requested.
|
|
1280
|
-
* @returns The requested block header.
|
|
1281
|
-
*/ async getBlockHeaderByArchive(archive) {
|
|
1282
|
-
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
859
|
+
getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
860
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1283
861
|
}
|
|
1284
|
-
|
|
1285
|
-
return this.
|
|
862
|
+
getPublicDataWitness(referenceBlock, leafSlot) {
|
|
863
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
1286
864
|
}
|
|
1287
|
-
|
|
1288
|
-
return this.
|
|
865
|
+
getPublicStorageAt(referenceBlock, contract, slot) {
|
|
866
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
1289
867
|
}
|
|
1290
868
|
/**
|
|
1291
869
|
* Simulates the public part of a transaction with the current state.
|
|
1292
870
|
* @param tx - The transaction to simulate.
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
1298
|
-
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
1299
|
-
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1300
|
-
}
|
|
1301
|
-
const txHash = tx.getTxHash();
|
|
1302
|
-
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1303
|
-
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1304
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1305
|
-
const coinbase = EthAddress.ZERO;
|
|
1306
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
1307
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
1308
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
1309
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
1310
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
1311
|
-
txHash,
|
|
1312
|
-
blockNumber
|
|
1313
|
-
});
|
|
1314
|
-
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1315
|
-
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1316
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1317
|
-
try {
|
|
1318
|
-
const config = PublicSimulatorConfig.from({
|
|
1319
|
-
skipFeeEnforcement,
|
|
1320
|
-
collectDebugLogs: true,
|
|
1321
|
-
collectHints: false,
|
|
1322
|
-
collectCallMetadata: true,
|
|
1323
|
-
collectStatistics: false,
|
|
1324
|
-
collectionLimits: CollectionLimitsConfig.from({
|
|
1325
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1326
|
-
})
|
|
1327
|
-
});
|
|
1328
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1329
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1330
|
-
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1331
|
-
tx
|
|
1332
|
-
]);
|
|
1333
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
1334
|
-
if (failedTxs.length) {
|
|
1335
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
|
|
1336
|
-
txHash
|
|
1337
|
-
});
|
|
1338
|
-
throw failedTxs[0].error;
|
|
1339
|
-
}
|
|
1340
|
-
const [processedTx] = processedTxs;
|
|
1341
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
1342
|
-
} finally{
|
|
1343
|
-
await merkleTreeFork.close();
|
|
1344
|
-
}
|
|
871
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
872
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
873
|
+
**/ simulatePublicCalls(tx, skipFeeEnforcement = false, overrides) {
|
|
874
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
1345
875
|
}
|
|
1346
876
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1347
877
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1348
|
-
const verifier = isSimulation ? undefined : this.
|
|
878
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1349
879
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1350
880
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1351
881
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1352
882
|
const l1Constants = await this.blockSource.getL1Constants();
|
|
883
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
884
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
885
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
1353
886
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1354
887
|
timestamp: nextSlotTimestamp,
|
|
1355
888
|
blockNumber,
|
|
@@ -1361,10 +894,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1361
894
|
],
|
|
1362
895
|
gasFees: await this.getCurrentMinFees(),
|
|
1363
896
|
skipFeeEnforcement,
|
|
897
|
+
isSimulation,
|
|
1364
898
|
txsPermitted: !this.config.disableTransactions,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
899
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
900
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
1368
901
|
}, this.log.getBindings());
|
|
1369
902
|
return await validator.validateTx(tx);
|
|
1370
903
|
}
|
|
@@ -1378,7 +911,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1378
911
|
...this.config,
|
|
1379
912
|
...config
|
|
1380
913
|
};
|
|
1381
|
-
|
|
914
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
915
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
916
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
917
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
918
|
+
// pauseSequencer() still considers it paused.
|
|
919
|
+
const sequencerUpdate = {
|
|
920
|
+
...config
|
|
921
|
+
};
|
|
922
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
923
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
924
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
925
|
+
}
|
|
926
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
927
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
1382
928
|
this.slasherClient?.updateConfig(config);
|
|
1383
929
|
this.validatorsSentinel?.updateConfig(config);
|
|
1384
930
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -1387,7 +933,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1387
933
|
archiver.updateConfig(config);
|
|
1388
934
|
}
|
|
1389
935
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1390
|
-
|
|
936
|
+
await Promise.all([
|
|
937
|
+
tryStop(this.peerProofVerifier),
|
|
938
|
+
tryStop(this.rpcProofVerifier)
|
|
939
|
+
]);
|
|
940
|
+
if (newConfig.realProofs) {
|
|
941
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
942
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
943
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
944
|
+
} else {
|
|
945
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
946
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
947
|
+
}
|
|
1391
948
|
}
|
|
1392
949
|
this.config = newConfig;
|
|
1393
950
|
}
|
|
@@ -1396,7 +953,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1396
953
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1397
954
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1398
955
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1399
|
-
multiCallEntrypoint:
|
|
956
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
1400
957
|
});
|
|
1401
958
|
}
|
|
1402
959
|
registerContractFunctionSignatures(signatures) {
|
|
@@ -1447,7 +1004,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1447
1004
|
});
|
|
1448
1005
|
return Promise.resolve();
|
|
1449
1006
|
}
|
|
1450
|
-
async rollbackTo(targetBlock, force) {
|
|
1007
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1451
1008
|
const archiver = this.blockSource;
|
|
1452
1009
|
if (!('rollbackTo' in archiver)) {
|
|
1453
1010
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1475,9 +1032,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1475
1032
|
this.log.error(`Error during rollback`, err);
|
|
1476
1033
|
throw err;
|
|
1477
1034
|
} finally{
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1035
|
+
if (resumeSync) {
|
|
1036
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1037
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1038
|
+
archiver.resume();
|
|
1039
|
+
} else {
|
|
1040
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1041
|
+
}
|
|
1481
1042
|
}
|
|
1482
1043
|
}
|
|
1483
1044
|
async pauseSync() {
|
|
@@ -1491,18 +1052,51 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1491
1052
|
this.blockSource.resume();
|
|
1492
1053
|
return Promise.resolve();
|
|
1493
1054
|
}
|
|
1494
|
-
|
|
1495
|
-
if (
|
|
1496
|
-
|
|
1055
|
+
pauseSequencer() {
|
|
1056
|
+
if (this.automineSequencer) {
|
|
1057
|
+
this.automineSequencer.pause();
|
|
1058
|
+
return Promise.resolve();
|
|
1497
1059
|
}
|
|
1498
|
-
|
|
1060
|
+
if (this.sequencer) {
|
|
1061
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
1062
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
1063
|
+
this.sequencer.updateConfig({
|
|
1064
|
+
minTxsPerBlock: Number.MAX_SAFE_INTEGER
|
|
1065
|
+
});
|
|
1066
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
1067
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
return Promise.resolve();
|
|
1071
|
+
}
|
|
1072
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
1073
|
+
}
|
|
1074
|
+
resumeSequencer() {
|
|
1075
|
+
if (this.automineSequencer) {
|
|
1076
|
+
this.automineSequencer.resume();
|
|
1077
|
+
return Promise.resolve();
|
|
1078
|
+
}
|
|
1079
|
+
if (this.sequencer) {
|
|
1080
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
1081
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
1082
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
1083
|
+
this.sequencer.updateConfig({
|
|
1084
|
+
minTxsPerBlock: restored
|
|
1085
|
+
});
|
|
1086
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, {
|
|
1087
|
+
minTxsPerBlock: restored
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
return Promise.resolve();
|
|
1091
|
+
}
|
|
1092
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
1499
1093
|
}
|
|
1500
1094
|
getSlashOffenses(round) {
|
|
1501
1095
|
if (!this.slasherClient) {
|
|
1502
1096
|
throw new Error(`Slasher client not enabled`);
|
|
1503
1097
|
}
|
|
1504
1098
|
if (round === 'all') {
|
|
1505
|
-
return this.slasherClient.
|
|
1099
|
+
return this.slasherClient.getOffenses();
|
|
1506
1100
|
} else {
|
|
1507
1101
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1508
1102
|
}
|
|
@@ -1575,6 +1169,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1575
1169
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1576
1170
|
}
|
|
1577
1171
|
async mineBlock() {
|
|
1172
|
+
if (this.automineSequencer) {
|
|
1173
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1578
1176
|
if (!this.sequencer) {
|
|
1579
1177
|
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1580
1178
|
}
|
|
@@ -1601,81 +1199,29 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1601
1199
|
});
|
|
1602
1200
|
}
|
|
1603
1201
|
}
|
|
1604
|
-
|
|
1605
|
-
if (!this.
|
|
1606
|
-
|
|
1202
|
+
async prove(upToCheckpoint) {
|
|
1203
|
+
if (!this.automineSequencer) {
|
|
1204
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1607
1205
|
}
|
|
1608
|
-
return this.
|
|
1206
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1609
1207
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
* @returns An instance of a committed MerkleTreeOperations
|
|
1614
|
-
*/ async getWorldState(block) {
|
|
1615
|
-
let blockSyncedTo = BlockNumber.ZERO;
|
|
1616
|
-
try {
|
|
1617
|
-
// Attempt to sync the world state if necessary
|
|
1618
|
-
blockSyncedTo = await this.#syncWorldState();
|
|
1619
|
-
} catch (err) {
|
|
1620
|
-
this.log.error(`Error getting world state: ${err}`);
|
|
1621
|
-
}
|
|
1622
|
-
if (block === 'latest') {
|
|
1623
|
-
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1624
|
-
return this.worldStateSynchronizer.getCommitted();
|
|
1625
|
-
}
|
|
1626
|
-
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1627
|
-
let blockNumber;
|
|
1628
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1629
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1630
|
-
if (block.equals(initialBlockHash)) {
|
|
1631
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1632
|
-
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1633
|
-
}
|
|
1634
|
-
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1635
|
-
if (!header) {
|
|
1636
|
-
throw new Error(`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1637
|
-
}
|
|
1638
|
-
blockNumber = header.getBlockNumber();
|
|
1639
|
-
} else {
|
|
1640
|
-
blockNumber = block;
|
|
1208
|
+
async warpL2TimeAtLeastTo(targetTimestamp) {
|
|
1209
|
+
if (!this.automineSequencer) {
|
|
1210
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1641
1211
|
}
|
|
1642
|
-
|
|
1643
|
-
if (blockNumber > blockSyncedTo) {
|
|
1644
|
-
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1645
|
-
}
|
|
1646
|
-
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1647
|
-
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1648
|
-
// Double-check world-state synced to the same block hash as was requested
|
|
1649
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1650
|
-
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1651
|
-
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1652
|
-
throw new Error(`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
return snapshot;
|
|
1212
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1656
1213
|
}
|
|
1657
|
-
|
|
1658
|
-
if (
|
|
1659
|
-
|
|
1660
|
-
}
|
|
1661
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1662
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1663
|
-
if (block.equals(initialBlockHash)) {
|
|
1664
|
-
return BlockNumber.ZERO;
|
|
1665
|
-
}
|
|
1666
|
-
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1667
|
-
if (!header) {
|
|
1668
|
-
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1669
|
-
}
|
|
1670
|
-
return header.getBlockNumber();
|
|
1214
|
+
async warpL2TimeAtLeastBy(duration) {
|
|
1215
|
+
if (!this.automineSequencer) {
|
|
1216
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1671
1217
|
}
|
|
1672
|
-
|
|
1218
|
+
await this.automineSequencer.warpBy(duration);
|
|
1673
1219
|
}
|
|
1674
1220
|
/**
|
|
1675
|
-
*
|
|
1676
|
-
* @
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
return
|
|
1221
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1222
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1223
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1224
|
+
*/ getWorldState(block) {
|
|
1225
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1680
1226
|
}
|
|
1681
1227
|
}
|