@aztec/aztec-node 0.0.1-commit.b6e433891 → 0.0.1-commit.b8a057fa
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 +16 -4
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +15 -5
- 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 +132 -134
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +400 -820
- 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 +5 -3
- 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 -26
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +30 -7
- 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 +527 -1070
- 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 +21 -6
- package/src/sentinel/sentinel.ts +277 -130
- package/src/sentinel/store.ts +26 -18
- package/src/test/index.ts +2 -2
|
@@ -371,58 +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';
|
|
382
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
388
383
|
import { count } from '@aztec/foundation/string';
|
|
389
|
-
import {
|
|
390
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
384
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
391
385
|
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
|
|
392
|
-
import {
|
|
393
|
-
import {
|
|
394
|
-
import { createP2PClient, createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
386
|
+
import { uploadSnapshot } from '@aztec/node-lib/actions';
|
|
387
|
+
import { createTxValidatorForAcceptingTxsOverRPC, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
|
|
395
388
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
396
|
-
import {
|
|
397
|
-
import {
|
|
398
|
-
import {
|
|
399
|
-
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
400
|
-
import { AttestationsBlockWatcher, EpochPruneWatcher, createSlasher } from '@aztec/slasher';
|
|
401
|
-
import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
402
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
403
|
-
import { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
404
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
405
|
-
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';
|
|
406
392
|
import { AztecNodeAdminConfigSchema } from '@aztec/stdlib/interfaces/client';
|
|
407
393
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
408
|
-
import {
|
|
409
|
-
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
410
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
411
|
-
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
412
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
394
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
413
395
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
414
|
-
import {
|
|
415
|
-
import {
|
|
416
|
-
import {
|
|
417
|
-
import {
|
|
418
|
-
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';
|
|
419
400
|
import { NodeMetrics } from './node_metrics.js';
|
|
401
|
+
import { NodePublicCallsSimulator } from './node_public_calls_simulator.js';
|
|
420
402
|
_dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
421
403
|
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
422
404
|
}));
|
|
423
405
|
/**
|
|
424
406
|
* The aztec node.
|
|
425
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;
|
|
426
427
|
config;
|
|
427
428
|
p2pClient;
|
|
428
429
|
blockSource;
|
|
@@ -434,354 +435,155 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
434
435
|
proverNode;
|
|
435
436
|
slasherClient;
|
|
436
437
|
validatorsSentinel;
|
|
437
|
-
|
|
438
|
+
stopStartedWatchers;
|
|
438
439
|
l1ChainId;
|
|
439
440
|
version;
|
|
440
441
|
globalVariableBuilder;
|
|
442
|
+
rollupContract;
|
|
443
|
+
feeProvider;
|
|
441
444
|
epochCache;
|
|
442
445
|
packageVersion;
|
|
443
|
-
|
|
446
|
+
peerProofVerifier;
|
|
447
|
+
rpcProofVerifier;
|
|
444
448
|
telemetry;
|
|
445
449
|
log;
|
|
446
450
|
blobClient;
|
|
447
451
|
validatorClient;
|
|
448
452
|
keyStoreManager;
|
|
449
453
|
debugLogStore;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
this.
|
|
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
|
-
|
|
485
|
-
|
|
486
|
-
this.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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
|
+
});
|
|
493
519
|
this.log.info(`Aztec Node version: ${this.packageVersion}`);
|
|
494
|
-
this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config
|
|
495
|
-
// 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
|
|
496
522
|
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
497
523
|
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
498
|
-
if (debugLogStore.isEnabled && config.realProofs) {
|
|
524
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
499
525
|
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
526
|
}
|
|
501
527
|
}
|
|
528
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
529
|
+
return this.rpcProofVerifier;
|
|
530
|
+
}
|
|
502
531
|
async getWorldStateSyncStatus() {
|
|
503
532
|
const status = await this.worldStateSynchronizer.status();
|
|
504
533
|
return status.syncSummary;
|
|
505
534
|
}
|
|
506
|
-
|
|
535
|
+
getChainTips() {
|
|
507
536
|
return this.blockSource.getL2Tips();
|
|
508
537
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const keyStores = loadKeystores(config.keyStoreDirectory);
|
|
528
|
-
keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
|
|
529
|
-
} else {
|
|
530
|
-
const rawKeyStores = [];
|
|
531
|
-
const validatorKeyStore = createKeyStoreForValidator(config);
|
|
532
|
-
if (validatorKeyStore) {
|
|
533
|
-
rawKeyStores.push(validatorKeyStore);
|
|
534
|
-
}
|
|
535
|
-
if (config.enableProverNode) {
|
|
536
|
-
const proverKeyStore = createKeyStoreForProver(config);
|
|
537
|
-
if (proverKeyStore) {
|
|
538
|
-
rawKeyStores.push(proverKeyStore);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
if (rawKeyStores.length > 0) {
|
|
542
|
-
keyStoreManager = new KeystoreManager(rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores));
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
await keyStoreManager?.validateSigners();
|
|
546
|
-
// If we are a validator, verify our configuration before doing too much more.
|
|
547
|
-
if (!config.disableValidator) {
|
|
548
|
-
if (keyStoreManager === undefined) {
|
|
549
|
-
throw new Error('Failed to create key store, a requirement for running a validator');
|
|
550
|
-
}
|
|
551
|
-
if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
|
|
552
|
-
log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
|
|
553
|
-
}
|
|
554
|
-
ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
|
|
555
|
-
}
|
|
556
|
-
// validate that the actual chain id matches that specified in configuration
|
|
557
|
-
if (config.l1ChainId !== ethereumChain.chainInfo.id) {
|
|
558
|
-
throw new Error(`RPC URL configured for chain id ${ethereumChain.chainInfo.id} but expected id ${config.l1ChainId}`);
|
|
559
|
-
}
|
|
560
|
-
const publicClient = createPublicClient({
|
|
561
|
-
chain: ethereumChain.chainInfo,
|
|
562
|
-
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
563
|
-
timeout: config.l1HttpTimeoutMS
|
|
564
|
-
}),
|
|
565
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
566
|
-
});
|
|
567
|
-
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
568
|
-
// Overwrite the passed in vars.
|
|
569
|
-
config.l1Contracts = {
|
|
570
|
-
...config.l1Contracts,
|
|
571
|
-
...l1ContractsAddresses
|
|
572
|
-
};
|
|
573
|
-
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
574
|
-
const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
|
|
575
|
-
rollupContract.getL1GenesisTime(),
|
|
576
|
-
rollupContract.getSlotDuration(),
|
|
577
|
-
rollupContract.getVersion(),
|
|
578
|
-
rollupContract.getManaLimit().then(Number)
|
|
579
|
-
]);
|
|
580
|
-
config.rollupVersion ??= Number(rollupVersionFromRollup);
|
|
581
|
-
if (config.rollupVersion !== Number(rollupVersionFromRollup)) {
|
|
582
|
-
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}).`);
|
|
583
|
-
}
|
|
584
|
-
const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
|
|
585
|
-
// attempt snapshot sync if possible
|
|
586
|
-
await trySnapshotSync(config, log);
|
|
587
|
-
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
|
|
588
|
-
dateProvider
|
|
589
|
-
});
|
|
590
|
-
const archiver = await createArchiver(config, {
|
|
591
|
-
blobClient,
|
|
592
|
-
epochCache,
|
|
593
|
-
telemetry,
|
|
594
|
-
dateProvider
|
|
595
|
-
}, {
|
|
596
|
-
blockUntilSync: !config.skipArchiverInitialSync
|
|
597
|
-
});
|
|
598
|
-
// now create the merkle trees and the world state synchronizer
|
|
599
|
-
const worldStateSynchronizer = await createWorldStateSynchronizer(config, archiver, options.prefilledPublicData, telemetry);
|
|
600
|
-
const circuitVerifier = config.realProofs || config.debugForceTxProofVerification ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
|
|
601
|
-
let debugLogStore;
|
|
602
|
-
if (!config.realProofs) {
|
|
603
|
-
log.warn(`Aztec node is accepting fake proofs`);
|
|
604
|
-
debugLogStore = new InMemoryDebugLogStore();
|
|
605
|
-
log.info('Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served');
|
|
606
|
-
} else {
|
|
607
|
-
debugLogStore = new NullDebugLogStore();
|
|
608
|
-
}
|
|
609
|
-
const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
|
|
610
|
-
const proverOnly = config.enableProverNode && config.disableValidator;
|
|
611
|
-
if (proverOnly) {
|
|
612
|
-
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
|
|
613
|
-
}
|
|
614
|
-
// create the tx pool and the p2p client, which will need the l2 block source
|
|
615
|
-
const p2pClient = await createP2PClient(config, archiver, proofVerifier, worldStateSynchronizer, epochCache, packageVersion, dateProvider, telemetry, deps.p2pClientDeps);
|
|
616
|
-
// We'll accumulate sentinel watchers here
|
|
617
|
-
const watchers = [];
|
|
618
|
-
// Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
|
|
619
|
-
// Override maxTxsPerCheckpoint with the validator-specific limit if set.
|
|
620
|
-
const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder({
|
|
621
|
-
...config,
|
|
622
|
-
l1GenesisTime,
|
|
623
|
-
slotDuration: Number(slotDuration),
|
|
624
|
-
rollupManaLimit,
|
|
625
|
-
maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint
|
|
626
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry);
|
|
627
|
-
let validatorClient;
|
|
628
|
-
if (!proverOnly) {
|
|
629
|
-
// Create validator client if required
|
|
630
|
-
validatorClient = await createValidatorClient(config, {
|
|
631
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
632
|
-
worldState: worldStateSynchronizer,
|
|
633
|
-
p2pClient,
|
|
634
|
-
telemetry,
|
|
635
|
-
dateProvider,
|
|
636
|
-
epochCache,
|
|
637
|
-
blockSource: archiver,
|
|
638
|
-
l1ToL2MessageSource: archiver,
|
|
639
|
-
keyStoreManager,
|
|
640
|
-
blobClient,
|
|
641
|
-
slashingProtectionDb: deps.slashingProtectionDb
|
|
642
|
-
});
|
|
643
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
644
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
645
|
-
// like attestations or auths will fail.
|
|
646
|
-
if (validatorClient) {
|
|
647
|
-
watchers.push(validatorClient);
|
|
648
|
-
if (!options.dontStartSequencer) {
|
|
649
|
-
await validatorClient.registerHandlers();
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
654
|
-
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
655
|
-
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
656
|
-
if (!validatorClient) {
|
|
657
|
-
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
658
|
-
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
659
|
-
createBlockProposalHandler(config, {
|
|
660
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
661
|
-
worldState: worldStateSynchronizer,
|
|
662
|
-
epochCache,
|
|
663
|
-
blockSource: archiver,
|
|
664
|
-
l1ToL2MessageSource: archiver,
|
|
665
|
-
p2pClient,
|
|
666
|
-
dateProvider,
|
|
667
|
-
telemetry
|
|
668
|
-
}).register(p2pClient, reexecute);
|
|
669
|
-
}
|
|
670
|
-
// Start world state and wait for it to sync to the archiver.
|
|
671
|
-
await worldStateSynchronizer.start();
|
|
672
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
673
|
-
await p2pClient.start();
|
|
674
|
-
let validatorsSentinel;
|
|
675
|
-
let epochPruneWatcher;
|
|
676
|
-
let attestationsBlockWatcher;
|
|
677
|
-
if (!proverOnly) {
|
|
678
|
-
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
679
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
680
|
-
watchers.push(validatorsSentinel);
|
|
681
|
-
}
|
|
682
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
683
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
684
|
-
watchers.push(epochPruneWatcher);
|
|
685
|
-
}
|
|
686
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
687
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
688
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
689
|
-
watchers.push(attestationsBlockWatcher);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
// Start p2p-related services once the archiver has completed sync
|
|
693
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
694
|
-
await p2pClient.start();
|
|
695
|
-
await validatorsSentinel?.start();
|
|
696
|
-
await epochPruneWatcher?.start();
|
|
697
|
-
await attestationsBlockWatcher?.start();
|
|
698
|
-
log.info(`All p2p services started`);
|
|
699
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
700
|
-
// Validator enabled, create/start relevant service
|
|
701
|
-
let sequencer;
|
|
702
|
-
let slasherClient;
|
|
703
|
-
if (!config.disableValidator && validatorClient) {
|
|
704
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
705
|
-
// as they are executed when the node is selected as proposer.
|
|
706
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
707
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
708
|
-
await slasherClient.start();
|
|
709
|
-
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
710
|
-
...config,
|
|
711
|
-
scope: 'sequencer'
|
|
712
|
-
}, {
|
|
713
|
-
telemetry,
|
|
714
|
-
logger: log.createChild('l1-tx-utils'),
|
|
715
|
-
dateProvider,
|
|
716
|
-
kzg: Blob.getViemKzgInstance()
|
|
717
|
-
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
718
|
-
...config,
|
|
719
|
-
scope: 'sequencer'
|
|
720
|
-
}, {
|
|
721
|
-
telemetry,
|
|
722
|
-
logger: log.createChild('l1-tx-utils'),
|
|
723
|
-
dateProvider,
|
|
724
|
-
kzg: Blob.getViemKzgInstance()
|
|
725
|
-
});
|
|
726
|
-
// Create and start the sequencer client
|
|
727
|
-
const checkpointsBuilder = new CheckpointsBuilder({
|
|
728
|
-
...config,
|
|
729
|
-
l1GenesisTime,
|
|
730
|
-
slotDuration: Number(slotDuration),
|
|
731
|
-
rollupManaLimit
|
|
732
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
733
|
-
sequencer = await SequencerClient.new(config, {
|
|
734
|
-
...deps,
|
|
735
|
-
epochCache,
|
|
736
|
-
l1TxUtils,
|
|
737
|
-
validatorClient,
|
|
738
|
-
p2pClient,
|
|
739
|
-
worldStateSynchronizer,
|
|
740
|
-
slasherClient,
|
|
741
|
-
checkpointsBuilder,
|
|
742
|
-
l2BlockSource: archiver,
|
|
743
|
-
l1ToL2MessageSource: archiver,
|
|
744
|
-
telemetry,
|
|
745
|
-
dateProvider,
|
|
746
|
-
blobClient,
|
|
747
|
-
nodeKeyStore: keyStoreManager
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
if (!options.dontStartSequencer && sequencer) {
|
|
751
|
-
await sequencer.start();
|
|
752
|
-
log.verbose(`Sequencer started`);
|
|
753
|
-
} else if (sequencer) {
|
|
754
|
-
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();
|
|
755
556
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
if (!options.dontStartProverNode) {
|
|
771
|
-
await proverNode.start();
|
|
772
|
-
log.info(`Prover node subsystem started`);
|
|
773
|
-
} else {
|
|
774
|
-
log.info(`Prover node subsystem created but not started`);
|
|
775
|
-
}
|
|
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;
|
|
776
571
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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);
|
|
785
587
|
}
|
|
786
588
|
/**
|
|
787
589
|
* Returns the sequencer client instance.
|
|
@@ -789,6 +591,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
789
591
|
*/ getSequencer() {
|
|
790
592
|
return this.sequencer;
|
|
791
593
|
}
|
|
594
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */ getAutomineSequencer() {
|
|
595
|
+
return this.automineSequencer;
|
|
596
|
+
}
|
|
792
597
|
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
793
598
|
return this.proverNode;
|
|
794
599
|
}
|
|
@@ -805,7 +610,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
805
610
|
* Method to return the currently deployed L1 contract addresses.
|
|
806
611
|
* @returns - The currently deployed L1 contract addresses.
|
|
807
612
|
*/ getL1ContractAddresses() {
|
|
808
|
-
return Promise.resolve(this.config
|
|
613
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
809
614
|
}
|
|
810
615
|
getEncodedEnr() {
|
|
811
616
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
@@ -823,14 +628,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
823
628
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
824
629
|
}
|
|
825
630
|
async getNodeInfo() {
|
|
826
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
631
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
827
632
|
this.getNodeVersion(),
|
|
828
633
|
this.getVersion(),
|
|
829
634
|
this.getChainId(),
|
|
830
635
|
this.getEncodedEnr(),
|
|
831
636
|
this.getL1ContractAddresses(),
|
|
832
|
-
this.getProtocolContractAddresses()
|
|
637
|
+
this.getProtocolContractAddresses(),
|
|
638
|
+
this.blockSource.getL1Constants()
|
|
833
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);
|
|
834
645
|
const nodeInfo = {
|
|
835
646
|
nodeVersion,
|
|
836
647
|
l1ChainId: chainId,
|
|
@@ -838,71 +649,26 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
838
649
|
enr,
|
|
839
650
|
l1ContractAddresses: contractAddresses,
|
|
840
651
|
protocolContractAddresses: protocolContractAddresses,
|
|
841
|
-
realProofs: !!this.config.realProofs
|
|
652
|
+
realProofs: !!this.config.realProofs,
|
|
653
|
+
txsLimits: {
|
|
654
|
+
gas: {
|
|
655
|
+
daGas: maxTxGas.daGas,
|
|
656
|
+
l2Gas: maxTxGas.l2Gas
|
|
657
|
+
}
|
|
658
|
+
}
|
|
842
659
|
};
|
|
843
660
|
return nodeInfo;
|
|
844
661
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
848
|
-
* @returns The requested block.
|
|
849
|
-
*/ async getBlock(block) {
|
|
850
|
-
if (BlockHash.isBlockHash(block)) {
|
|
851
|
-
return this.getBlockByHash(block);
|
|
852
|
-
}
|
|
853
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
854
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
855
|
-
return this.buildInitialBlock();
|
|
856
|
-
}
|
|
857
|
-
return await this.blockSource.getL2Block(blockNumber);
|
|
858
|
-
}
|
|
859
|
-
/**
|
|
860
|
-
* Get a block specified by its hash.
|
|
861
|
-
* @param blockHash - The block hash being requested.
|
|
862
|
-
* @returns The requested block.
|
|
863
|
-
*/ async getBlockByHash(blockHash) {
|
|
864
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
865
|
-
if (blockHash.equals(initialBlockHash)) {
|
|
866
|
-
return this.buildInitialBlock();
|
|
867
|
-
}
|
|
868
|
-
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
869
|
-
}
|
|
870
|
-
buildInitialBlock() {
|
|
871
|
-
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
872
|
-
return L2Block.empty(initialHeader);
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* Get a block specified by its archive root.
|
|
876
|
-
* @param archive - The archive root being requested.
|
|
877
|
-
* @returns The requested block.
|
|
878
|
-
*/ async getBlockByArchive(archive) {
|
|
879
|
-
return await this.blockSource.getL2BlockByArchive(archive);
|
|
880
|
-
}
|
|
881
|
-
/**
|
|
882
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
883
|
-
* @param from - The start of the range of blocks to return.
|
|
884
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
885
|
-
* @returns The blocks requested.
|
|
886
|
-
*/ async getBlocks(from, limit) {
|
|
887
|
-
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
662
|
+
async getCurrentMinFees() {
|
|
663
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
888
664
|
}
|
|
889
|
-
async
|
|
890
|
-
return await this.
|
|
891
|
-
}
|
|
892
|
-
async getCheckpointedBlocks(from, limit) {
|
|
893
|
-
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
894
|
-
}
|
|
895
|
-
getCheckpointsDataForEpoch(epochNumber) {
|
|
896
|
-
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Method to fetch the current min L2 fees.
|
|
900
|
-
* @returns The current min L2 fees.
|
|
901
|
-
*/ async getCurrentMinFees() {
|
|
902
|
-
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);
|
|
903
667
|
}
|
|
904
668
|
async getMaxPriorityFees() {
|
|
905
|
-
for await (const tx of this.p2pClient.iteratePendingTxs(
|
|
669
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({
|
|
670
|
+
includeProof: false
|
|
671
|
+
})){
|
|
906
672
|
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
907
673
|
}
|
|
908
674
|
return GasFees.from({
|
|
@@ -911,21 +677,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
911
677
|
});
|
|
912
678
|
}
|
|
913
679
|
/**
|
|
914
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
915
|
-
* @returns The block number.
|
|
916
|
-
*/ async getBlockNumber() {
|
|
917
|
-
return await this.blockSource.getBlockNumber();
|
|
918
|
-
}
|
|
919
|
-
async getProvenBlockNumber() {
|
|
920
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
921
|
-
}
|
|
922
|
-
async getCheckpointedBlockNumber() {
|
|
923
|
-
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
924
|
-
}
|
|
925
|
-
getCheckpointNumber() {
|
|
926
|
-
return this.blockSource.getCheckpointNumber();
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
680
|
* Method to fetch the version of the package.
|
|
930
681
|
* @returns The node package version
|
|
931
682
|
*/ getNodeVersion() {
|
|
@@ -946,54 +697,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
946
697
|
getContractClass(id) {
|
|
947
698
|
return this.contractDataSource.getContractClass(id);
|
|
948
699
|
}
|
|
949
|
-
getContract(address) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
let upToBlockNumber;
|
|
954
|
-
if (referenceBlock) {
|
|
955
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
956
|
-
if (referenceBlock.equals(initialBlockHash)) {
|
|
957
|
-
upToBlockNumber = BlockNumber(0);
|
|
958
|
-
} else {
|
|
959
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
960
|
-
if (!header) {
|
|
961
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
962
|
-
}
|
|
963
|
-
upToBlockNumber = header.globalVariables.blockNumber;
|
|
964
|
-
}
|
|
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.`);
|
|
965
704
|
}
|
|
966
|
-
return this.
|
|
967
|
-
}
|
|
968
|
-
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
969
|
-
let upToBlockNumber;
|
|
970
|
-
if (referenceBlock) {
|
|
971
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
972
|
-
if (referenceBlock.equals(initialBlockHash)) {
|
|
973
|
-
upToBlockNumber = BlockNumber(0);
|
|
974
|
-
} else {
|
|
975
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
976
|
-
if (!header) {
|
|
977
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
978
|
-
}
|
|
979
|
-
upToBlockNumber = header.globalVariables.blockNumber;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return this.logsSource.getPublicLogsByTagsFromContract(contractAddress, tags, page, upToBlockNumber);
|
|
705
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
983
706
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
* @param filter - The filter to apply to the logs.
|
|
987
|
-
* @returns The requested logs.
|
|
988
|
-
*/ getPublicLogs(filter) {
|
|
989
|
-
return this.logsSource.getPublicLogs(filter);
|
|
707
|
+
getPrivateLogsByTags(query) {
|
|
708
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
990
709
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
* @param filter - The filter to apply to the logs.
|
|
994
|
-
* @returns The requested logs.
|
|
995
|
-
*/ getContractClassLogs(filter) {
|
|
996
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
710
|
+
getPublicLogsByTags(query) {
|
|
711
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
997
712
|
}
|
|
998
713
|
/**
|
|
999
714
|
* Method to submit a transaction to the p2p pool.
|
|
@@ -1013,34 +728,23 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1013
728
|
});
|
|
1014
729
|
throw new Error(`Invalid tx: ${reason}`);
|
|
1015
730
|
}
|
|
1016
|
-
|
|
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
|
+
}
|
|
1017
740
|
const duration = timer.ms();
|
|
1018
741
|
this.metrics.receivedTx(duration, true);
|
|
1019
742
|
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
1020
743
|
txHash
|
|
1021
744
|
});
|
|
1022
745
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
// as a fallback if we don't find a settled receipt in the archiver.
|
|
1026
|
-
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
1027
|
-
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
1028
|
-
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
1029
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1030
|
-
let receipt;
|
|
1031
|
-
if (settledTxReceipt) {
|
|
1032
|
-
receipt = settledTxReceipt;
|
|
1033
|
-
} else if (isKnownToPool) {
|
|
1034
|
-
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1035
|
-
// This handles race conditions between archiver and p2p, where the archiver
|
|
1036
|
-
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1037
|
-
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1038
|
-
} else {
|
|
1039
|
-
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1040
|
-
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
1041
|
-
}
|
|
1042
|
-
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1043
|
-
return receipt;
|
|
746
|
+
getTxReceipt(txHash, options) {
|
|
747
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
1044
748
|
}
|
|
1045
749
|
getTxEffect(txHash) {
|
|
1046
750
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -1049,13 +753,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1049
753
|
* Method to stop the aztec node.
|
|
1050
754
|
*/ async stop() {
|
|
1051
755
|
this.log.info(`Stopping Aztec Node`);
|
|
1052
|
-
await
|
|
1053
|
-
await tryStop(this.epochPruneWatcher);
|
|
756
|
+
await this.stopStartedWatchers();
|
|
1054
757
|
await tryStop(this.slasherClient);
|
|
1055
|
-
await
|
|
758
|
+
await Promise.all([
|
|
759
|
+
tryStop(this.peerProofVerifier),
|
|
760
|
+
tryStop(this.rpcProofVerifier)
|
|
761
|
+
]);
|
|
1056
762
|
await tryStop(this.sequencer);
|
|
763
|
+
await tryStop(this.automineSequencer);
|
|
1057
764
|
await tryStop(this.proverNode);
|
|
1058
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]();
|
|
1059
770
|
await tryStop(this.worldStateSynchronizer);
|
|
1060
771
|
await tryStop(this.blockSource);
|
|
1061
772
|
await tryStop(this.blobClient);
|
|
@@ -1073,276 +784,105 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1073
784
|
* @param limit - The number of items to returns
|
|
1074
785
|
* @param after - The last known pending tx. Used for pagination
|
|
1075
786
|
* @returns - The pending txs.
|
|
1076
|
-
*/ getPendingTxs(limit, after) {
|
|
1077
|
-
return this.p2pClient.getPendingTxs(limit, after);
|
|
787
|
+
*/ getPendingTxs(limit, after, options) {
|
|
788
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
1078
789
|
}
|
|
1079
790
|
getPendingTxCount() {
|
|
1080
791
|
return this.p2pClient.getPendingTxCount();
|
|
1081
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
|
+
}
|
|
1082
802
|
/**
|
|
1083
|
-
* 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.
|
|
1084
805
|
* @param txHash - The transaction hash to return.
|
|
806
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
1085
807
|
* @returns - The tx if it exists.
|
|
1086
|
-
*/ getTxByHash(txHash) {
|
|
1087
|
-
return
|
|
808
|
+
*/ getTxByHash(txHash, options) {
|
|
809
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
810
|
+
includeProof: !!options?.includeProof
|
|
811
|
+
});
|
|
1088
812
|
}
|
|
1089
813
|
/**
|
|
1090
|
-
* 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.
|
|
1091
816
|
* @param txHash - The transaction hash to return.
|
|
817
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
1092
818
|
* @returns - The txs if it exists.
|
|
1093
|
-
*/ async getTxsByHash(txHashes) {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1097
|
-
const committedDb = await this.getWorldState(referenceBlock);
|
|
1098
|
-
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1099
|
-
// Filter out undefined values to query block numbers only for found leaves
|
|
1100
|
-
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1101
|
-
// Now we find the block numbers for the defined indices
|
|
1102
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1103
|
-
// Build a map from leaf index to block number
|
|
1104
|
-
const indexToBlockNumber = new Map();
|
|
1105
|
-
for(let i = 0; i < definedIndices.length; i++){
|
|
1106
|
-
const blockNumber = blockNumbers[i];
|
|
1107
|
-
if (blockNumber === undefined) {
|
|
1108
|
-
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1109
|
-
}
|
|
1110
|
-
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1111
|
-
}
|
|
1112
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1113
|
-
const uniqueBlockNumbers = [
|
|
1114
|
-
...new Set(indexToBlockNumber.values())
|
|
1115
|
-
];
|
|
1116
|
-
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1117
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1118
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1119
|
-
}));
|
|
1120
|
-
// Build a map from block number to block hash
|
|
1121
|
-
const blockNumberToHash = new Map();
|
|
1122
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1123
|
-
const blockHash = blockHashes[i];
|
|
1124
|
-
if (blockHash === undefined) {
|
|
1125
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1126
|
-
}
|
|
1127
|
-
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1128
|
-
}
|
|
1129
|
-
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1130
|
-
return maybeIndices.map((index)=>{
|
|
1131
|
-
if (index === undefined) {
|
|
1132
|
-
return undefined;
|
|
1133
|
-
}
|
|
1134
|
-
const blockNumber = indexToBlockNumber.get(index);
|
|
1135
|
-
if (blockNumber === undefined) {
|
|
1136
|
-
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1137
|
-
}
|
|
1138
|
-
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1139
|
-
if (blockHash === undefined) {
|
|
1140
|
-
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1141
|
-
}
|
|
1142
|
-
return {
|
|
1143
|
-
l2BlockNumber: blockNumber,
|
|
1144
|
-
l2BlockHash: new BlockHash(blockHash),
|
|
1145
|
-
data: index
|
|
1146
|
-
};
|
|
819
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
820
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
821
|
+
includeProof: !!options?.includeProof
|
|
1147
822
|
});
|
|
823
|
+
return compactArray(txs);
|
|
1148
824
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1152
|
-
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1153
|
-
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1154
|
-
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1155
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1156
|
-
blockHash
|
|
1157
|
-
]);
|
|
1158
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
825
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
826
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
1159
827
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1163
|
-
noteHash
|
|
1164
|
-
]);
|
|
1165
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
828
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
829
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
1166
830
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1170
|
-
l1ToL2Message
|
|
1171
|
-
]);
|
|
1172
|
-
if (!witness) {
|
|
1173
|
-
return undefined;
|
|
1174
|
-
}
|
|
1175
|
-
// REFACTOR: Return a MembershipWitness object
|
|
1176
|
-
return [
|
|
1177
|
-
witness.index,
|
|
1178
|
-
witness.path
|
|
1179
|
-
];
|
|
831
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
832
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
1180
833
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
834
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
835
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
1184
836
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
1188
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
1189
|
-
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
1190
|
-
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1191
|
-
return messageIndex !== undefined;
|
|
837
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
838
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
1192
839
|
}
|
|
1193
840
|
/**
|
|
1194
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
|
+
*
|
|
1195
845
|
* @param epoch - The epoch at which to get the data.
|
|
1196
846
|
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1197
|
-
*/
|
|
1198
|
-
|
|
1199
|
-
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1200
|
-
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1201
|
-
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1202
|
-
}
|
|
1203
|
-
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1204
|
-
const db = await this.getWorldState(referenceBlock);
|
|
1205
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1206
|
-
nullifier.toBuffer()
|
|
1207
|
-
]);
|
|
1208
|
-
if (!witness) {
|
|
1209
|
-
return undefined;
|
|
1210
|
-
}
|
|
1211
|
-
const { index, path } = witness;
|
|
1212
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1213
|
-
if (!leafPreimage) {
|
|
1214
|
-
return undefined;
|
|
1215
|
-
}
|
|
1216
|
-
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
847
|
+
*/ getL2ToL1Messages(epoch) {
|
|
848
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
1217
849
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1224
|
-
const { index, alreadyPresent } = findResult;
|
|
1225
|
-
if (alreadyPresent) {
|
|
1226
|
-
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1227
|
-
}
|
|
1228
|
-
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1229
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1230
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1231
|
-
}
|
|
1232
|
-
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1233
|
-
const committedDb = await this.getWorldState(referenceBlock);
|
|
1234
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1235
|
-
if (!lowLeafResult) {
|
|
1236
|
-
return undefined;
|
|
1237
|
-
} else {
|
|
1238
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1239
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1240
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
1241
|
-
}
|
|
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);
|
|
1242
855
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1246
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1247
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
1248
|
-
return Fr.ZERO;
|
|
1249
|
-
}
|
|
1250
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1251
|
-
return preimage.leaf.value;
|
|
1252
|
-
}
|
|
1253
|
-
async getBlockHeader(block = 'latest') {
|
|
1254
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1255
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1256
|
-
if (block.equals(initialBlockHash)) {
|
|
1257
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1258
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1259
|
-
}
|
|
1260
|
-
return this.blockSource.getBlockHeaderByHash(block);
|
|
1261
|
-
} else {
|
|
1262
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1263
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1264
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
1265
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1266
|
-
}
|
|
1267
|
-
return this.blockSource.getBlockHeader(block);
|
|
1268
|
-
}
|
|
856
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
857
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1269
858
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
* @param archive - The archive root being requested.
|
|
1273
|
-
* @returns The requested block header.
|
|
1274
|
-
*/ async getBlockHeaderByArchive(archive) {
|
|
1275
|
-
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
859
|
+
getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
860
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1276
861
|
}
|
|
1277
|
-
|
|
1278
|
-
return this.
|
|
862
|
+
getPublicDataWitness(referenceBlock, leafSlot) {
|
|
863
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
1279
864
|
}
|
|
1280
|
-
|
|
1281
|
-
return this.
|
|
865
|
+
getPublicStorageAt(referenceBlock, contract, slot) {
|
|
866
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
1282
867
|
}
|
|
1283
868
|
/**
|
|
1284
869
|
* Simulates the public part of a transaction with the current state.
|
|
1285
870
|
* @param tx - The transaction to simulate.
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
1291
|
-
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
1292
|
-
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1293
|
-
}
|
|
1294
|
-
const txHash = tx.getTxHash();
|
|
1295
|
-
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1296
|
-
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1297
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1298
|
-
const coinbase = EthAddress.ZERO;
|
|
1299
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
1300
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
1301
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
1302
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
1303
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
1304
|
-
txHash,
|
|
1305
|
-
blockNumber
|
|
1306
|
-
});
|
|
1307
|
-
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1308
|
-
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1309
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1310
|
-
try {
|
|
1311
|
-
const config = PublicSimulatorConfig.from({
|
|
1312
|
-
skipFeeEnforcement,
|
|
1313
|
-
collectDebugLogs: true,
|
|
1314
|
-
collectHints: false,
|
|
1315
|
-
collectCallMetadata: true,
|
|
1316
|
-
collectStatistics: false,
|
|
1317
|
-
collectionLimits: CollectionLimitsConfig.from({
|
|
1318
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1319
|
-
})
|
|
1320
|
-
});
|
|
1321
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1322
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1323
|
-
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1324
|
-
tx
|
|
1325
|
-
]);
|
|
1326
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
1327
|
-
if (failedTxs.length) {
|
|
1328
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
|
|
1329
|
-
txHash
|
|
1330
|
-
});
|
|
1331
|
-
throw failedTxs[0].error;
|
|
1332
|
-
}
|
|
1333
|
-
const [processedTx] = processedTxs;
|
|
1334
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
1335
|
-
} finally{
|
|
1336
|
-
await merkleTreeFork.close();
|
|
1337
|
-
}
|
|
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);
|
|
1338
875
|
}
|
|
1339
876
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1340
877
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1341
|
-
const verifier = isSimulation ? undefined : this.
|
|
878
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1342
879
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1343
880
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1344
881
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1345
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);
|
|
1346
886
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1347
887
|
timestamp: nextSlotTimestamp,
|
|
1348
888
|
blockNumber,
|
|
@@ -1354,10 +894,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1354
894
|
],
|
|
1355
895
|
gasFees: await this.getCurrentMinFees(),
|
|
1356
896
|
skipFeeEnforcement,
|
|
897
|
+
isSimulation,
|
|
1357
898
|
txsPermitted: !this.config.disableTransactions,
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
899
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
900
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
1361
901
|
}, this.log.getBindings());
|
|
1362
902
|
return await validator.validateTx(tx);
|
|
1363
903
|
}
|
|
@@ -1371,7 +911,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1371
911
|
...this.config,
|
|
1372
912
|
...config
|
|
1373
913
|
};
|
|
1374
|
-
|
|
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);
|
|
1375
928
|
this.slasherClient?.updateConfig(config);
|
|
1376
929
|
this.validatorsSentinel?.updateConfig(config);
|
|
1377
930
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -1380,7 +933,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1380
933
|
archiver.updateConfig(config);
|
|
1381
934
|
}
|
|
1382
935
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1383
|
-
|
|
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
|
+
}
|
|
1384
948
|
}
|
|
1385
949
|
this.config = newConfig;
|
|
1386
950
|
}
|
|
@@ -1389,7 +953,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1389
953
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1390
954
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1391
955
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1392
|
-
multiCallEntrypoint:
|
|
956
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
1393
957
|
});
|
|
1394
958
|
}
|
|
1395
959
|
registerContractFunctionSignatures(signatures) {
|
|
@@ -1440,7 +1004,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1440
1004
|
});
|
|
1441
1005
|
return Promise.resolve();
|
|
1442
1006
|
}
|
|
1443
|
-
async rollbackTo(targetBlock, force) {
|
|
1007
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1444
1008
|
const archiver = this.blockSource;
|
|
1445
1009
|
if (!('rollbackTo' in archiver)) {
|
|
1446
1010
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1468,9 +1032,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1468
1032
|
this.log.error(`Error during rollback`, err);
|
|
1469
1033
|
throw err;
|
|
1470
1034
|
} finally{
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
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
|
+
}
|
|
1474
1042
|
}
|
|
1475
1043
|
}
|
|
1476
1044
|
async pauseSync() {
|
|
@@ -1484,18 +1052,51 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1484
1052
|
this.blockSource.resume();
|
|
1485
1053
|
return Promise.resolve();
|
|
1486
1054
|
}
|
|
1487
|
-
|
|
1488
|
-
if (
|
|
1489
|
-
|
|
1055
|
+
pauseSequencer() {
|
|
1056
|
+
if (this.automineSequencer) {
|
|
1057
|
+
this.automineSequencer.pause();
|
|
1058
|
+
return Promise.resolve();
|
|
1059
|
+
}
|
|
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();
|
|
1490
1071
|
}
|
|
1491
|
-
|
|
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');
|
|
1492
1093
|
}
|
|
1493
1094
|
getSlashOffenses(round) {
|
|
1494
1095
|
if (!this.slasherClient) {
|
|
1495
1096
|
throw new Error(`Slasher client not enabled`);
|
|
1496
1097
|
}
|
|
1497
1098
|
if (round === 'all') {
|
|
1498
|
-
return this.slasherClient.
|
|
1099
|
+
return this.slasherClient.getOffenses();
|
|
1499
1100
|
} else {
|
|
1500
1101
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1501
1102
|
}
|
|
@@ -1567,81 +1168,60 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1567
1168
|
this.keyStoreManager = newManager;
|
|
1568
1169
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1569
1170
|
}
|
|
1570
|
-
|
|
1571
|
-
if (
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1171
|
+
async mineBlock() {
|
|
1172
|
+
if (this.automineSequencer) {
|
|
1173
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (!this.sequencer) {
|
|
1177
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1178
|
+
}
|
|
1179
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1180
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1181
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1182
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1183
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1184
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1185
|
+
this.sequencer.updateConfig({
|
|
1186
|
+
minTxsPerBlock: 0
|
|
1187
|
+
});
|
|
1582
1188
|
try {
|
|
1583
|
-
//
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1595
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1596
|
-
if (block.equals(initialBlockHash)) {
|
|
1597
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1598
|
-
return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
|
|
1599
|
-
}
|
|
1600
|
-
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1601
|
-
if (!header) {
|
|
1602
|
-
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.`);
|
|
1603
|
-
}
|
|
1604
|
-
blockNumber = header.getBlockNumber();
|
|
1605
|
-
} else {
|
|
1606
|
-
blockNumber = block;
|
|
1607
|
-
}
|
|
1608
|
-
// Check it's within world state sync range
|
|
1609
|
-
if (blockNumber > blockSyncedTo) {
|
|
1610
|
-
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1189
|
+
// Trigger the sequencer to produce a block immediately
|
|
1190
|
+
void this.sequencer.trigger();
|
|
1191
|
+
// Wait for the new L2 block to appear
|
|
1192
|
+
await retryUntil(async ()=>{
|
|
1193
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1194
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1195
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1196
|
+
} finally{
|
|
1197
|
+
this.sequencer.updateConfig({
|
|
1198
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1199
|
+
});
|
|
1611
1200
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1617
|
-
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1618
|
-
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.`);
|
|
1619
|
-
}
|
|
1201
|
+
}
|
|
1202
|
+
async prove(upToCheckpoint) {
|
|
1203
|
+
if (!this.automineSequencer) {
|
|
1204
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1620
1205
|
}
|
|
1621
|
-
return
|
|
1206
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1622
1207
|
}
|
|
1623
|
-
|
|
1624
|
-
if (
|
|
1625
|
-
|
|
1208
|
+
async warpL2TimeAtLeastTo(targetTimestamp) {
|
|
1209
|
+
if (!this.automineSequencer) {
|
|
1210
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1626
1211
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1633
|
-
if (!header) {
|
|
1634
|
-
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1635
|
-
}
|
|
1636
|
-
return header.getBlockNumber();
|
|
1212
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1213
|
+
}
|
|
1214
|
+
async warpL2TimeAtLeastBy(duration) {
|
|
1215
|
+
if (!this.automineSequencer) {
|
|
1216
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1637
1217
|
}
|
|
1638
|
-
|
|
1218
|
+
await this.automineSequencer.warpBy(duration);
|
|
1639
1219
|
}
|
|
1640
1220
|
/**
|
|
1641
|
-
*
|
|
1642
|
-
* @
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
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);
|
|
1646
1226
|
}
|
|
1647
1227
|
}
|