@aztec/aztec-node 0.0.1-commit.343b43af6 → 0.0.1-commit.350e0a4d
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 +90 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +346 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +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 -139
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +393 -806
- 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 +509 -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 -27
- 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 +383 -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 +516 -1045
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +673 -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 {
|
|
378
|
-
import { EpochCache } from '@aztec/epoch-cache';
|
|
379
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
380
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
381
|
-
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
382
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
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';
|
|
377
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
383
378
|
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
384
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
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,353 +435,152 @@ _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
|
-
|
|
483
|
-
|
|
484
|
-
this.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
454
|
+
automineSequencer;
|
|
455
|
+
constructor(deps){
|
|
456
|
+
this.config = deps.config;
|
|
457
|
+
this.p2pClient = deps.p2pClient;
|
|
458
|
+
this.blockSource = deps.blockSource;
|
|
459
|
+
this.logsSource = deps.logsSource;
|
|
460
|
+
this.contractDataSource = deps.contractDataSource;
|
|
461
|
+
this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
|
|
462
|
+
this.worldStateSynchronizer = deps.worldStateSynchronizer;
|
|
463
|
+
this.sequencer = deps.sequencer;
|
|
464
|
+
this.proverNode = deps.proverNode;
|
|
465
|
+
this.slasherClient = deps.slasherClient;
|
|
466
|
+
this.validatorsSentinel = deps.validatorsSentinel;
|
|
467
|
+
this.stopStartedWatchers = deps.stopStartedWatchers;
|
|
468
|
+
this.l1ChainId = deps.l1ChainId;
|
|
469
|
+
this.version = deps.version;
|
|
470
|
+
this.globalVariableBuilder = deps.globalVariableBuilder;
|
|
471
|
+
this.rollupContract = deps.rollupContract;
|
|
472
|
+
this.feeProvider = deps.feeProvider;
|
|
473
|
+
this.epochCache = deps.epochCache;
|
|
474
|
+
this.packageVersion = deps.packageVersion;
|
|
475
|
+
this.peerProofVerifier = deps.peerProofVerifier;
|
|
476
|
+
this.rpcProofVerifier = deps.rpcProofVerifier;
|
|
477
|
+
this.telemetry = deps.telemetry ?? getTelemetryClient();
|
|
478
|
+
this.log = deps.log ?? createLogger('node');
|
|
479
|
+
this.blobClient = deps.blobClient;
|
|
480
|
+
this.validatorClient = deps.validatorClient;
|
|
481
|
+
this.keyStoreManager = deps.keyStoreManager;
|
|
482
|
+
this.debugLogStore = deps.debugLogStore ?? new NullDebugLogStore();
|
|
483
|
+
this.automineSequencer = deps.automineSequencer;
|
|
484
|
+
this.metrics = new NodeMetrics(this.telemetry, 'AztecNodeService');
|
|
485
|
+
this.tracer = this.telemetry.getTracer('AztecNodeService');
|
|
486
|
+
// The node never represents a proposer's payout addresses, so the simulator zeroes coinbase and
|
|
487
|
+
// fee recipient. The signature context only needs chain id + rollup address (see signature_utils).
|
|
488
|
+
this.nodePublicCallsSimulator = new NodePublicCallsSimulator({
|
|
489
|
+
blockSource: this.blockSource,
|
|
490
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
491
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
492
|
+
contractDataSource: this.contractDataSource,
|
|
493
|
+
globalVariableBuilder: this.globalVariableBuilder,
|
|
494
|
+
rollupContract: this.rollupContract,
|
|
495
|
+
epochCache: this.epochCache,
|
|
496
|
+
signatureContext: {
|
|
497
|
+
chainId: this.l1ChainId,
|
|
498
|
+
rollupAddress: this.config.rollupAddress
|
|
499
|
+
},
|
|
500
|
+
config: this.config,
|
|
501
|
+
telemetry: this.telemetry,
|
|
502
|
+
log: this.log.createChild('public-calls-simulator')
|
|
503
|
+
});
|
|
504
|
+
this.worldStateQueries = new NodeWorldStateQueries({
|
|
505
|
+
worldStateSynchronizer: this.worldStateSynchronizer,
|
|
506
|
+
blockSource: this.blockSource,
|
|
507
|
+
l1ToL2MessageSource: this.l1ToL2MessageSource,
|
|
508
|
+
log: this.log.createChild('world-state-queries')
|
|
509
|
+
});
|
|
510
|
+
this.blockProvider = new NodeBlockProvider(this.blockSource);
|
|
511
|
+
this.txReceiptBuilder = new NodeTxReceiptBuilder({
|
|
512
|
+
p2pClient: this.p2pClient,
|
|
513
|
+
blockSource: this.blockSource,
|
|
514
|
+
debugLogStore: this.debugLogStore
|
|
515
|
+
});
|
|
493
516
|
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
|
|
517
|
+
this.log.info(`Aztec Node started on chain 0x${this.l1ChainId.toString(16)}`, pickL1ContractAddresses(this.config));
|
|
518
|
+
// A defensive check that protects us against introducing a bug in the complex node creation flow. We must
|
|
496
519
|
// never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
|
|
497
520
|
// memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
|
|
498
|
-
if (debugLogStore.isEnabled && config.realProofs) {
|
|
521
|
+
if (this.debugLogStore.isEnabled && this.config.realProofs) {
|
|
499
522
|
throw new Error('debugLogStore should never be enabled when realProofs are set');
|
|
500
523
|
}
|
|
501
524
|
}
|
|
525
|
+
/** @internal Exposed for testing — returns the RPC proof verifier. */ getProofVerifier() {
|
|
526
|
+
return this.rpcProofVerifier;
|
|
527
|
+
}
|
|
502
528
|
async getWorldStateSyncStatus() {
|
|
503
529
|
const status = await this.worldStateSynchronizer.status();
|
|
504
530
|
return status.syncSummary;
|
|
505
531
|
}
|
|
506
|
-
|
|
532
|
+
getChainTips() {
|
|
507
533
|
return this.blockSource.getL2Tips();
|
|
508
534
|
}
|
|
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: fallback(config.l1RpcUrls.map((url)=>http(url, {
|
|
563
|
-
batch: false
|
|
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
|
-
});
|
|
642
|
-
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
643
|
-
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
644
|
-
// like attestations or auths will fail.
|
|
645
|
-
if (validatorClient) {
|
|
646
|
-
watchers.push(validatorClient);
|
|
647
|
-
if (!options.dontStartSequencer) {
|
|
648
|
-
await validatorClient.registerHandlers();
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
// If there's no validator client, create a BlockProposalHandler to handle block proposals
|
|
653
|
-
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
654
|
-
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
655
|
-
if (!validatorClient) {
|
|
656
|
-
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
657
|
-
log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
658
|
-
createBlockProposalHandler(config, {
|
|
659
|
-
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
660
|
-
worldState: worldStateSynchronizer,
|
|
661
|
-
epochCache,
|
|
662
|
-
blockSource: archiver,
|
|
663
|
-
l1ToL2MessageSource: archiver,
|
|
664
|
-
p2pClient,
|
|
665
|
-
dateProvider,
|
|
666
|
-
telemetry
|
|
667
|
-
}).register(p2pClient, reexecute);
|
|
668
|
-
}
|
|
669
|
-
// Start world state and wait for it to sync to the archiver.
|
|
670
|
-
await worldStateSynchronizer.start();
|
|
671
|
-
// Start p2p. Note that it depends on world state to be running.
|
|
672
|
-
await p2pClient.start();
|
|
673
|
-
let validatorsSentinel;
|
|
674
|
-
let epochPruneWatcher;
|
|
675
|
-
let attestationsBlockWatcher;
|
|
676
|
-
if (!proverOnly) {
|
|
677
|
-
validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
|
|
678
|
-
if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
|
|
679
|
-
watchers.push(validatorsSentinel);
|
|
680
|
-
}
|
|
681
|
-
if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
|
|
682
|
-
epochPruneWatcher = new EpochPruneWatcher(archiver, archiver, epochCache, p2pClient.getTxProvider(), validatorCheckpointsBuilder, config);
|
|
683
|
-
watchers.push(epochPruneWatcher);
|
|
684
|
-
}
|
|
685
|
-
// We assume we want to slash for invalid attestations unless all max penalties are set to 0
|
|
686
|
-
if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
|
|
687
|
-
attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
|
|
688
|
-
watchers.push(attestationsBlockWatcher);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
// Start p2p-related services once the archiver has completed sync
|
|
692
|
-
void archiver.waitForInitialSync().then(async ()=>{
|
|
693
|
-
await p2pClient.start();
|
|
694
|
-
await validatorsSentinel?.start();
|
|
695
|
-
await epochPruneWatcher?.start();
|
|
696
|
-
await attestationsBlockWatcher?.start();
|
|
697
|
-
log.info(`All p2p services started`);
|
|
698
|
-
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
699
|
-
// Validator enabled, create/start relevant service
|
|
700
|
-
let sequencer;
|
|
701
|
-
let slasherClient;
|
|
702
|
-
if (!config.disableValidator && validatorClient) {
|
|
703
|
-
// We create a slasher only if we have a sequencer, since all slashing actions go through the sequencer publisher
|
|
704
|
-
// as they are executed when the node is selected as proposer.
|
|
705
|
-
const validatorAddresses = keyStoreManager ? NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAddresses() : [];
|
|
706
|
-
slasherClient = await createSlasher(config, config.l1Contracts, getPublicClient(config), watchers, dateProvider, epochCache, validatorAddresses, undefined);
|
|
707
|
-
await slasherClient.start();
|
|
708
|
-
const l1TxUtils = config.sequencerPublisherForwarderAddress ? await createForwarderL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), config.sequencerPublisherForwarderAddress, {
|
|
709
|
-
...config,
|
|
710
|
-
scope: 'sequencer'
|
|
711
|
-
}, {
|
|
712
|
-
telemetry,
|
|
713
|
-
logger: log.createChild('l1-tx-utils'),
|
|
714
|
-
dateProvider,
|
|
715
|
-
kzg: Blob.getViemKzgInstance()
|
|
716
|
-
}) : await createL1TxUtilsFromSigners(publicClient, keyStoreManager.createAllValidatorPublisherSigners(), {
|
|
717
|
-
...config,
|
|
718
|
-
scope: 'sequencer'
|
|
719
|
-
}, {
|
|
720
|
-
telemetry,
|
|
721
|
-
logger: log.createChild('l1-tx-utils'),
|
|
722
|
-
dateProvider,
|
|
723
|
-
kzg: Blob.getViemKzgInstance()
|
|
724
|
-
});
|
|
725
|
-
// Create and start the sequencer client
|
|
726
|
-
const checkpointsBuilder = new CheckpointsBuilder({
|
|
727
|
-
...config,
|
|
728
|
-
l1GenesisTime,
|
|
729
|
-
slotDuration: Number(slotDuration),
|
|
730
|
-
rollupManaLimit
|
|
731
|
-
}, worldStateSynchronizer, archiver, dateProvider, telemetry, debugLogStore);
|
|
732
|
-
sequencer = await SequencerClient.new(config, {
|
|
733
|
-
...deps,
|
|
734
|
-
epochCache,
|
|
735
|
-
l1TxUtils,
|
|
736
|
-
validatorClient,
|
|
737
|
-
p2pClient,
|
|
738
|
-
worldStateSynchronizer,
|
|
739
|
-
slasherClient,
|
|
740
|
-
checkpointsBuilder,
|
|
741
|
-
l2BlockSource: archiver,
|
|
742
|
-
l1ToL2MessageSource: archiver,
|
|
743
|
-
telemetry,
|
|
744
|
-
dateProvider,
|
|
745
|
-
blobClient,
|
|
746
|
-
nodeKeyStore: keyStoreManager
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
if (!options.dontStartSequencer && sequencer) {
|
|
750
|
-
await sequencer.start();
|
|
751
|
-
log.verbose(`Sequencer started`);
|
|
752
|
-
} else if (sequencer) {
|
|
753
|
-
log.warn(`Sequencer created but not started`);
|
|
535
|
+
getL1Constants() {
|
|
536
|
+
return this.blockSource.getL1Constants();
|
|
537
|
+
}
|
|
538
|
+
getSyncedL2SlotNumber() {
|
|
539
|
+
return this.blockSource.getSyncedL2SlotNumber();
|
|
540
|
+
}
|
|
541
|
+
getSyncedL2EpochNumber() {
|
|
542
|
+
return this.blockSource.getSyncedL2EpochNumber();
|
|
543
|
+
}
|
|
544
|
+
getSyncedL1Timestamp() {
|
|
545
|
+
return this.blockSource.getL1Timestamp();
|
|
546
|
+
}
|
|
547
|
+
getCheckpointsData(query) {
|
|
548
|
+
return this.blockSource.getCheckpointsData(query);
|
|
549
|
+
}
|
|
550
|
+
async getBlockNumber(tip) {
|
|
551
|
+
if (tip === undefined || tip === 'proposed') {
|
|
552
|
+
return this.blockSource.getBlockNumber();
|
|
754
553
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (!options.dontStartProverNode) {
|
|
770
|
-
await proverNode.start();
|
|
771
|
-
log.info(`Prover node subsystem started`);
|
|
772
|
-
} else {
|
|
773
|
-
log.info(`Prover node subsystem created but not started`);
|
|
774
|
-
}
|
|
554
|
+
return await this.blockSource.getBlockNumber({
|
|
555
|
+
tag: tip
|
|
556
|
+
}) ?? BlockNumber.ZERO;
|
|
557
|
+
}
|
|
558
|
+
async getCheckpointNumber(tip) {
|
|
559
|
+
const tips = await this.blockSource.getL2Tips();
|
|
560
|
+
switch(tip){
|
|
561
|
+
case undefined:
|
|
562
|
+
case 'checkpointed':
|
|
563
|
+
return tips.checkpointed.checkpoint.number;
|
|
564
|
+
case 'proven':
|
|
565
|
+
return tips.proven.checkpoint.number;
|
|
566
|
+
case 'finalized':
|
|
567
|
+
return tips.finalized.checkpoint.number;
|
|
775
568
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
569
|
+
}
|
|
570
|
+
getBlock(param, options = {}) {
|
|
571
|
+
return this.blockProvider.getBlock(param, options);
|
|
572
|
+
}
|
|
573
|
+
getBlockData(param) {
|
|
574
|
+
return this.blockProvider.getBlockData(param);
|
|
575
|
+
}
|
|
576
|
+
getBlocks(from, limit, options = {}) {
|
|
577
|
+
return this.blockProvider.getBlocks(from, limit, options);
|
|
578
|
+
}
|
|
579
|
+
getCheckpoint(param, options = {}) {
|
|
580
|
+
return this.blockProvider.getCheckpoint(param, options);
|
|
581
|
+
}
|
|
582
|
+
getCheckpoints(from, limit, options = {}) {
|
|
583
|
+
return this.blockProvider.getCheckpoints(from, limit, options);
|
|
784
584
|
}
|
|
785
585
|
/**
|
|
786
586
|
* Returns the sequencer client instance.
|
|
@@ -788,6 +588,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
788
588
|
*/ getSequencer() {
|
|
789
589
|
return this.sequencer;
|
|
790
590
|
}
|
|
591
|
+
/** Test-only: returns the AutomineSequencer when wired via `useAutomineSequencer`. */ getAutomineSequencer() {
|
|
592
|
+
return this.automineSequencer;
|
|
593
|
+
}
|
|
791
594
|
/** Returns the prover node subsystem, if enabled. */ getProverNode() {
|
|
792
595
|
return this.proverNode;
|
|
793
596
|
}
|
|
@@ -804,7 +607,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
804
607
|
* Method to return the currently deployed L1 contract addresses.
|
|
805
608
|
* @returns - The currently deployed L1 contract addresses.
|
|
806
609
|
*/ getL1ContractAddresses() {
|
|
807
|
-
return Promise.resolve(this.config
|
|
610
|
+
return Promise.resolve(pickL1ContractAddresses(this.config));
|
|
808
611
|
}
|
|
809
612
|
getEncodedEnr() {
|
|
810
613
|
return Promise.resolve(this.p2pClient.getEnr()?.encodeTxt());
|
|
@@ -822,14 +625,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
822
625
|
return Promise.resolve(this.p2pClient.isReady() ?? false);
|
|
823
626
|
}
|
|
824
627
|
async getNodeInfo() {
|
|
825
|
-
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
628
|
+
const [nodeVersion, rollupVersion, chainId, enr, contractAddresses, protocolContractAddresses, l1Constants] = await Promise.all([
|
|
826
629
|
this.getNodeVersion(),
|
|
827
630
|
this.getVersion(),
|
|
828
631
|
this.getChainId(),
|
|
829
632
|
this.getEncodedEnr(),
|
|
830
633
|
this.getL1ContractAddresses(),
|
|
831
|
-
this.getProtocolContractAddresses()
|
|
634
|
+
this.getProtocolContractAddresses(),
|
|
635
|
+
this.blockSource.getL1Constants()
|
|
832
636
|
]);
|
|
637
|
+
// Gas limits a single tx may declare on this network, derived from network-wide constants only (the
|
|
638
|
+
// timetable's blocks-per-checkpoint and the network-minimum per-block multipliers) — never this node's
|
|
639
|
+
// local caps or configured multipliers, which can make the node stricter at block-building time but
|
|
640
|
+
// cannot define what the network accepts for relay. Clients read txsLimits to set fallback gas limits.
|
|
641
|
+
const maxTxGas = getNetworkTxGasLimits(this.config, l1Constants);
|
|
833
642
|
const nodeInfo = {
|
|
834
643
|
nodeVersion,
|
|
835
644
|
l1ChainId: chainId,
|
|
@@ -837,68 +646,26 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
837
646
|
enr,
|
|
838
647
|
l1ContractAddresses: contractAddresses,
|
|
839
648
|
protocolContractAddresses: protocolContractAddresses,
|
|
840
|
-
realProofs: !!this.config.realProofs
|
|
649
|
+
realProofs: !!this.config.realProofs,
|
|
650
|
+
txsLimits: {
|
|
651
|
+
gas: {
|
|
652
|
+
daGas: maxTxGas.daGas,
|
|
653
|
+
l2Gas: maxTxGas.l2Gas
|
|
654
|
+
}
|
|
655
|
+
}
|
|
841
656
|
};
|
|
842
657
|
return nodeInfo;
|
|
843
658
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
* @param block - The block parameter (block number, block hash, or 'latest').
|
|
847
|
-
* @returns The requested block.
|
|
848
|
-
*/ async getBlock(block) {
|
|
849
|
-
if (BlockHash.isBlockHash(block)) {
|
|
850
|
-
return this.getBlockByHash(block);
|
|
851
|
-
}
|
|
852
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
853
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
854
|
-
return this.buildInitialBlock();
|
|
855
|
-
}
|
|
856
|
-
return await this.blockSource.getL2Block(blockNumber);
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Get a block specified by its hash.
|
|
860
|
-
* @param blockHash - The block hash being requested.
|
|
861
|
-
* @returns The requested block.
|
|
862
|
-
*/ async getBlockByHash(blockHash) {
|
|
863
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
864
|
-
if (blockHash.equals(initialBlockHash)) {
|
|
865
|
-
return this.buildInitialBlock();
|
|
866
|
-
}
|
|
867
|
-
return await this.blockSource.getL2BlockByHash(blockHash);
|
|
868
|
-
}
|
|
869
|
-
buildInitialBlock() {
|
|
870
|
-
const initialHeader = this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
871
|
-
return L2Block.empty(initialHeader);
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Get a block specified by its archive root.
|
|
875
|
-
* @param archive - The archive root being requested.
|
|
876
|
-
* @returns The requested block.
|
|
877
|
-
*/ async getBlockByArchive(archive) {
|
|
878
|
-
return await this.blockSource.getL2BlockByArchive(archive);
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Method to request blocks. Will attempt to return all requested blocks but will return only those available.
|
|
882
|
-
* @param from - The start of the range of blocks to return.
|
|
883
|
-
* @param limit - The maximum number of blocks to obtain.
|
|
884
|
-
* @returns The blocks requested.
|
|
885
|
-
*/ async getBlocks(from, limit) {
|
|
886
|
-
return await this.blockSource.getBlocks(from, BlockNumber(limit)) ?? [];
|
|
887
|
-
}
|
|
888
|
-
async getCheckpoints(from, limit) {
|
|
889
|
-
return await this.blockSource.getCheckpoints(from, limit) ?? [];
|
|
659
|
+
async getCurrentMinFees() {
|
|
660
|
+
return await this.feeProvider.getCurrentMinFees();
|
|
890
661
|
}
|
|
891
|
-
async
|
|
892
|
-
return await this.
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* Method to fetch the current min L2 fees.
|
|
896
|
-
* @returns The current min L2 fees.
|
|
897
|
-
*/ async getCurrentMinFees() {
|
|
898
|
-
return await this.globalVariableBuilder.getCurrentMinFees();
|
|
662
|
+
/** Returns predicted min fees for the current slot and next N slots. */ async getPredictedMinFees(manaUsage) {
|
|
663
|
+
return await this.feeProvider.getPredictedMinFees(manaUsage);
|
|
899
664
|
}
|
|
900
665
|
async getMaxPriorityFees() {
|
|
901
|
-
for await (const tx of this.p2pClient.iteratePendingTxs(
|
|
666
|
+
for await (const tx of this.p2pClient.iteratePendingTxs({
|
|
667
|
+
includeProof: false
|
|
668
|
+
})){
|
|
902
669
|
return tx.getGasSettings().maxPriorityFeesPerGas;
|
|
903
670
|
}
|
|
904
671
|
return GasFees.from({
|
|
@@ -907,21 +674,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
907
674
|
});
|
|
908
675
|
}
|
|
909
676
|
/**
|
|
910
|
-
* Method to fetch the latest block number synchronized by the node.
|
|
911
|
-
* @returns The block number.
|
|
912
|
-
*/ async getBlockNumber() {
|
|
913
|
-
return await this.blockSource.getBlockNumber();
|
|
914
|
-
}
|
|
915
|
-
async getProvenBlockNumber() {
|
|
916
|
-
return await this.blockSource.getProvenBlockNumber();
|
|
917
|
-
}
|
|
918
|
-
async getCheckpointedBlockNumber() {
|
|
919
|
-
return await this.blockSource.getCheckpointedL2BlockNumber();
|
|
920
|
-
}
|
|
921
|
-
getCheckpointNumber() {
|
|
922
|
-
return this.blockSource.getCheckpointNumber();
|
|
923
|
-
}
|
|
924
|
-
/**
|
|
925
677
|
* Method to fetch the version of the package.
|
|
926
678
|
* @returns The node package version
|
|
927
679
|
*/ getNodeVersion() {
|
|
@@ -942,46 +694,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
942
694
|
getContractClass(id) {
|
|
943
695
|
return this.contractDataSource.getContractClass(id);
|
|
944
696
|
}
|
|
945
|
-
getContract(address) {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
if (referenceBlock) {
|
|
950
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
951
|
-
if (!referenceBlock.equals(initialBlockHash)) {
|
|
952
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
953
|
-
if (!header) {
|
|
954
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
return this.logsSource.getPrivateLogsByTags(tags, page);
|
|
959
|
-
}
|
|
960
|
-
async getPublicLogsByTagsFromContract(contractAddress, tags, page, referenceBlock) {
|
|
961
|
-
if (referenceBlock) {
|
|
962
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
963
|
-
if (!referenceBlock.equals(initialBlockHash)) {
|
|
964
|
-
const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
|
|
965
|
-
if (!header) {
|
|
966
|
-
throw new Error(`Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
697
|
+
async getContract(address, referenceBlock = 'latest') {
|
|
698
|
+
const blockData = await this.getBlockData(referenceBlock);
|
|
699
|
+
if (!blockData) {
|
|
700
|
+
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.`);
|
|
969
701
|
}
|
|
970
|
-
return this.
|
|
702
|
+
return this.contractDataSource.getContract(address, blockData.header.globalVariables.timestamp);
|
|
971
703
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
* @param filter - The filter to apply to the logs.
|
|
975
|
-
* @returns The requested logs.
|
|
976
|
-
*/ getPublicLogs(filter) {
|
|
977
|
-
return this.logsSource.getPublicLogs(filter);
|
|
704
|
+
getPrivateLogsByTags(query) {
|
|
705
|
+
return this.logsSource.getPrivateLogsByTags(query);
|
|
978
706
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
* @param filter - The filter to apply to the logs.
|
|
982
|
-
* @returns The requested logs.
|
|
983
|
-
*/ getContractClassLogs(filter) {
|
|
984
|
-
return this.logsSource.getContractClassLogs(filter);
|
|
707
|
+
getPublicLogsByTags(query) {
|
|
708
|
+
return this.logsSource.getPublicLogsByTags(query);
|
|
985
709
|
}
|
|
986
710
|
/**
|
|
987
711
|
* Method to submit a transaction to the p2p pool.
|
|
@@ -1001,34 +725,23 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1001
725
|
});
|
|
1002
726
|
throw new Error(`Invalid tx: ${reason}`);
|
|
1003
727
|
}
|
|
1004
|
-
|
|
728
|
+
try {
|
|
729
|
+
await this.p2pClient.sendTx(tx);
|
|
730
|
+
} catch (err) {
|
|
731
|
+
this.metrics.receivedTx(timer.ms(), false);
|
|
732
|
+
this.log.warn(`Mempool rejected tx ${txHash}: ${err.message}`, {
|
|
733
|
+
txHash
|
|
734
|
+
});
|
|
735
|
+
throw err;
|
|
736
|
+
}
|
|
1005
737
|
const duration = timer.ms();
|
|
1006
738
|
this.metrics.receivedTx(duration, true);
|
|
1007
739
|
this.log.info(`Received tx ${txHash} in ${duration}ms`, {
|
|
1008
740
|
txHash
|
|
1009
741
|
});
|
|
1010
742
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
// as a fallback if we don't find a settled receipt in the archiver.
|
|
1014
|
-
const txPoolStatus = await this.p2pClient.getTxStatus(txHash);
|
|
1015
|
-
const isKnownToPool = txPoolStatus === 'pending' || txPoolStatus === 'mined';
|
|
1016
|
-
// Then get the actual tx from the archiver, which tracks every tx in a mined block.
|
|
1017
|
-
const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
|
|
1018
|
-
let receipt;
|
|
1019
|
-
if (settledTxReceipt) {
|
|
1020
|
-
receipt = settledTxReceipt;
|
|
1021
|
-
} else if (isKnownToPool) {
|
|
1022
|
-
// If the tx is in the pool but not in the archiver, it's pending.
|
|
1023
|
-
// This handles race conditions between archiver and p2p, where the archiver
|
|
1024
|
-
// has pruned the block in which a tx was mined, but p2p has not caught up yet.
|
|
1025
|
-
receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
|
|
1026
|
-
} else {
|
|
1027
|
-
// Otherwise, if we don't know the tx, we consider it dropped.
|
|
1028
|
-
receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
|
|
1029
|
-
}
|
|
1030
|
-
this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
|
|
1031
|
-
return receipt;
|
|
743
|
+
getTxReceipt(txHash, options) {
|
|
744
|
+
return this.txReceiptBuilder.getTxReceipt(txHash, options);
|
|
1032
745
|
}
|
|
1033
746
|
getTxEffect(txHash) {
|
|
1034
747
|
return this.blockSource.getTxEffect(txHash);
|
|
@@ -1037,11 +750,14 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1037
750
|
* Method to stop the aztec node.
|
|
1038
751
|
*/ async stop() {
|
|
1039
752
|
this.log.info(`Stopping Aztec Node`);
|
|
1040
|
-
await
|
|
1041
|
-
await tryStop(this.epochPruneWatcher);
|
|
753
|
+
await this.stopStartedWatchers();
|
|
1042
754
|
await tryStop(this.slasherClient);
|
|
1043
|
-
await
|
|
755
|
+
await Promise.all([
|
|
756
|
+
tryStop(this.peerProofVerifier),
|
|
757
|
+
tryStop(this.rpcProofVerifier)
|
|
758
|
+
]);
|
|
1044
759
|
await tryStop(this.sequencer);
|
|
760
|
+
await tryStop(this.automineSequencer);
|
|
1045
761
|
await tryStop(this.proverNode);
|
|
1046
762
|
await tryStop(this.p2pClient);
|
|
1047
763
|
await tryStop(this.worldStateSynchronizer);
|
|
@@ -1061,298 +777,105 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1061
777
|
* @param limit - The number of items to returns
|
|
1062
778
|
* @param after - The last known pending tx. Used for pagination
|
|
1063
779
|
* @returns - The pending txs.
|
|
1064
|
-
*/ getPendingTxs(limit, after) {
|
|
1065
|
-
return this.p2pClient.getPendingTxs(limit, after);
|
|
780
|
+
*/ getPendingTxs(limit, after, options) {
|
|
781
|
+
return this.p2pClient.getPendingTxs(limit, after, options);
|
|
1066
782
|
}
|
|
1067
783
|
getPendingTxCount() {
|
|
1068
784
|
return this.p2pClient.getPendingTxCount();
|
|
1069
785
|
}
|
|
786
|
+
getPeers(includePending) {
|
|
787
|
+
return this.p2pClient.getPeers(includePending);
|
|
788
|
+
}
|
|
789
|
+
getCheckpointAttestationsForSlot(slot, proposalPayloadHash) {
|
|
790
|
+
return this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
791
|
+
}
|
|
792
|
+
getProposalsForSlot(slot) {
|
|
793
|
+
return this.p2pClient.getProposalsForSlot(slot);
|
|
794
|
+
}
|
|
1070
795
|
/**
|
|
1071
|
-
* Method to retrieve a single tx from the mempool or unfinalized chain.
|
|
796
|
+
* Method to retrieve a single tx from the mempool or unfinalized chain. The tx's proof is only loaded and returned
|
|
797
|
+
* when `includeProof` is set.
|
|
1072
798
|
* @param txHash - The transaction hash to return.
|
|
799
|
+
* @param options - Options for the returned tx (eg whether to include its proof).
|
|
1073
800
|
* @returns - The tx if it exists.
|
|
1074
|
-
*/ getTxByHash(txHash) {
|
|
1075
|
-
return
|
|
801
|
+
*/ getTxByHash(txHash, options) {
|
|
802
|
+
return this.p2pClient.getTxByHashFromPool(txHash, {
|
|
803
|
+
includeProof: !!options?.includeProof
|
|
804
|
+
});
|
|
1076
805
|
}
|
|
1077
806
|
/**
|
|
1078
|
-
* Method to retrieve txs from the mempool or unfinalized chain.
|
|
807
|
+
* Method to retrieve txs from the mempool or unfinalized chain. The txs' proofs are only loaded and returned when
|
|
808
|
+
* `includeProof` is set.
|
|
1079
809
|
* @param txHash - The transaction hash to return.
|
|
810
|
+
* @param options - Options for the returned txs (eg whether to include their proofs).
|
|
1080
811
|
* @returns - The txs if it exists.
|
|
1081
|
-
*/ async getTxsByHash(txHashes) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1085
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1086
|
-
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1087
|
-
// Filter out undefined values to query block numbers only for found leaves
|
|
1088
|
-
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1089
|
-
// Now we find the block numbers for the defined indices
|
|
1090
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1091
|
-
// Build a map from leaf index to block number
|
|
1092
|
-
const indexToBlockNumber = new Map();
|
|
1093
|
-
for(let i = 0; i < definedIndices.length; i++){
|
|
1094
|
-
const blockNumber = blockNumbers[i];
|
|
1095
|
-
if (blockNumber === undefined) {
|
|
1096
|
-
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1097
|
-
}
|
|
1098
|
-
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1099
|
-
}
|
|
1100
|
-
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1101
|
-
const uniqueBlockNumbers = [
|
|
1102
|
-
...new Set(indexToBlockNumber.values())
|
|
1103
|
-
];
|
|
1104
|
-
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1105
|
-
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1106
|
-
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1107
|
-
}));
|
|
1108
|
-
// Build a map from block number to block hash
|
|
1109
|
-
const blockNumberToHash = new Map();
|
|
1110
|
-
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1111
|
-
const blockHash = blockHashes[i];
|
|
1112
|
-
if (blockHash === undefined) {
|
|
1113
|
-
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1114
|
-
}
|
|
1115
|
-
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1116
|
-
}
|
|
1117
|
-
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1118
|
-
return maybeIndices.map((index)=>{
|
|
1119
|
-
if (index === undefined) {
|
|
1120
|
-
return undefined;
|
|
1121
|
-
}
|
|
1122
|
-
const blockNumber = indexToBlockNumber.get(index);
|
|
1123
|
-
if (blockNumber === undefined) {
|
|
1124
|
-
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1125
|
-
}
|
|
1126
|
-
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1127
|
-
if (blockHash === undefined) {
|
|
1128
|
-
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1129
|
-
}
|
|
1130
|
-
return {
|
|
1131
|
-
l2BlockNumber: blockNumber,
|
|
1132
|
-
l2BlockHash: new BlockHash(blockHash),
|
|
1133
|
-
data: index
|
|
1134
|
-
};
|
|
812
|
+
*/ async getTxsByHash(txHashes, options) {
|
|
813
|
+
const txs = await this.p2pClient.getTxsByHashFromPool(txHashes, {
|
|
814
|
+
includeProof: !!options?.includeProof
|
|
1135
815
|
});
|
|
816
|
+
return compactArray(txs);
|
|
1136
817
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1140
|
-
blockHash
|
|
1141
|
-
]);
|
|
1142
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
818
|
+
findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
819
|
+
return this.worldStateQueries.findLeavesIndexes(referenceBlock, treeId, leafValues);
|
|
1143
820
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1147
|
-
noteHash
|
|
1148
|
-
]);
|
|
1149
|
-
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
821
|
+
getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
822
|
+
return this.worldStateQueries.getBlockHashMembershipWitness(referenceBlock, blockHash);
|
|
1150
823
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1154
|
-
l1ToL2Message
|
|
1155
|
-
]);
|
|
1156
|
-
if (!witness) {
|
|
1157
|
-
return undefined;
|
|
1158
|
-
}
|
|
1159
|
-
// REFACTOR: Return a MembershipWitness object
|
|
1160
|
-
return [
|
|
1161
|
-
witness.index,
|
|
1162
|
-
witness.path
|
|
1163
|
-
];
|
|
824
|
+
getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
825
|
+
return this.worldStateQueries.getNoteHashMembershipWitness(referenceBlock, noteHash);
|
|
1164
826
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
|
|
827
|
+
getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
828
|
+
return this.worldStateQueries.getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message);
|
|
1168
829
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
1172
|
-
* @returns Whether the message is synced and ready to be included in a block.
|
|
1173
|
-
*/ async isL1ToL2MessageSynced(l1ToL2Message) {
|
|
1174
|
-
const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
|
|
1175
|
-
return messageIndex !== undefined;
|
|
830
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message) {
|
|
831
|
+
return this.worldStateQueries.getL1ToL2MessageCheckpoint(l1ToL2Message);
|
|
1176
832
|
}
|
|
1177
833
|
/**
|
|
1178
834
|
* Returns all the L2 to L1 messages in an epoch.
|
|
835
|
+
*
|
|
836
|
+
* @deprecated Use {@link getL2ToL1MembershipWitness} to get an L2-to-L1 message witness directly.
|
|
837
|
+
*
|
|
1179
838
|
* @param epoch - The epoch at which to get the data.
|
|
1180
839
|
* @returns The L2 to L1 messages (empty array if the epoch is not found).
|
|
1181
|
-
*/
|
|
1182
|
-
|
|
1183
|
-
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1184
|
-
const blocksInCheckpoints = [];
|
|
1185
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
1186
|
-
let checkpointIndex = -1;
|
|
1187
|
-
for (const checkpointedBlock of checkpointedBlocks){
|
|
1188
|
-
const block = checkpointedBlock.block;
|
|
1189
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1190
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1191
|
-
checkpointIndex++;
|
|
1192
|
-
blocksInCheckpoints.push([]);
|
|
1193
|
-
previousSlotNumber = slotNumber;
|
|
1194
|
-
}
|
|
1195
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1196
|
-
}
|
|
1197
|
-
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1198
|
-
}
|
|
1199
|
-
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1200
|
-
const db = await this.#getWorldState(referenceBlock);
|
|
1201
|
-
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1202
|
-
nullifier.toBuffer()
|
|
1203
|
-
]);
|
|
1204
|
-
if (!witness) {
|
|
1205
|
-
return undefined;
|
|
1206
|
-
}
|
|
1207
|
-
const { index, path } = witness;
|
|
1208
|
-
const leafPreimage = await db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1209
|
-
if (!leafPreimage) {
|
|
1210
|
-
return undefined;
|
|
1211
|
-
}
|
|
1212
|
-
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
840
|
+
*/ getL2ToL1Messages(epoch) {
|
|
841
|
+
return this.worldStateQueries.getL2ToL1Messages(epoch);
|
|
1213
842
|
}
|
|
1214
843
|
/**
|
|
1215
|
-
* Returns
|
|
1216
|
-
*
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
* @returns The low nullifier membership witness (if found).
|
|
1220
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1221
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1222
|
-
* we are trying to prove non-inclusion for.
|
|
1223
|
-
*
|
|
1224
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1225
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1226
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1227
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1228
|
-
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1229
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1230
|
-
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1231
|
-
if (!findResult) {
|
|
1232
|
-
return undefined;
|
|
1233
|
-
}
|
|
1234
|
-
const { index, alreadyPresent } = findResult;
|
|
1235
|
-
if (alreadyPresent) {
|
|
1236
|
-
this.log.warn(`Nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1237
|
-
}
|
|
1238
|
-
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1239
|
-
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1240
|
-
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1241
|
-
}
|
|
1242
|
-
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1243
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1244
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1245
|
-
if (!lowLeafResult) {
|
|
1246
|
-
return undefined;
|
|
1247
|
-
} else {
|
|
1248
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1249
|
-
const path = await committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1250
|
-
return new PublicDataWitness(lowLeafResult.index, preimage, path);
|
|
1251
|
-
}
|
|
844
|
+
* Returns the L2-to-L1 membership witness for a message in `txHash`. Passthrough to the
|
|
845
|
+
* archiver's locally-cached resolver — see {@link Archiver.getL2ToL1MembershipWitness}.
|
|
846
|
+
*/ getL2ToL1MembershipWitness(txHash, message, messageIndexInTx) {
|
|
847
|
+
return this.worldStateQueries.getL2ToL1MembershipWitness(txHash, message, messageIndexInTx);
|
|
1252
848
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1256
|
-
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1257
|
-
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
1258
|
-
return Fr.ZERO;
|
|
1259
|
-
}
|
|
1260
|
-
const preimage = await committedDb.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
1261
|
-
return preimage.leaf.value;
|
|
1262
|
-
}
|
|
1263
|
-
async getBlockHeader(block = 'latest') {
|
|
1264
|
-
if (BlockHash.isBlockHash(block)) {
|
|
1265
|
-
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1266
|
-
if (block.equals(initialBlockHash)) {
|
|
1267
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1268
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1269
|
-
}
|
|
1270
|
-
return this.blockSource.getBlockHeaderByHash(block);
|
|
1271
|
-
} else {
|
|
1272
|
-
// Block source doesn't handle initial header so we need to handle the case separately.
|
|
1273
|
-
const blockNumber = block === 'latest' ? await this.getBlockNumber() : block;
|
|
1274
|
-
if (blockNumber === BlockNumber.ZERO) {
|
|
1275
|
-
return this.worldStateSynchronizer.getCommitted().getInitialHeader();
|
|
1276
|
-
}
|
|
1277
|
-
return this.blockSource.getBlockHeader(block);
|
|
1278
|
-
}
|
|
849
|
+
getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
850
|
+
return this.worldStateQueries.getNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1279
851
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
* @param archive - The archive root being requested.
|
|
1283
|
-
* @returns The requested block header.
|
|
1284
|
-
*/ async getBlockHeaderByArchive(archive) {
|
|
1285
|
-
return await this.blockSource.getBlockHeaderByArchive(archive);
|
|
852
|
+
getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
853
|
+
return this.worldStateQueries.getLowNullifierMembershipWitness(referenceBlock, nullifier);
|
|
1286
854
|
}
|
|
1287
|
-
|
|
1288
|
-
return this.
|
|
855
|
+
getPublicDataWitness(referenceBlock, leafSlot) {
|
|
856
|
+
return this.worldStateQueries.getPublicDataWitness(referenceBlock, leafSlot);
|
|
1289
857
|
}
|
|
1290
|
-
|
|
1291
|
-
return this.
|
|
858
|
+
getPublicStorageAt(referenceBlock, contract, slot) {
|
|
859
|
+
return this.worldStateQueries.getPublicStorageAt(referenceBlock, contract, slot);
|
|
1292
860
|
}
|
|
1293
861
|
/**
|
|
1294
862
|
* Simulates the public part of a transaction with the current state.
|
|
1295
863
|
* @param tx - The transaction to simulate.
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
|
|
1301
|
-
if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
|
|
1302
|
-
throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
|
|
1303
|
-
}
|
|
1304
|
-
const txHash = tx.getTxHash();
|
|
1305
|
-
const latestBlockNumber = await this.blockSource.getBlockNumber();
|
|
1306
|
-
const blockNumber = BlockNumber.add(latestBlockNumber, 1);
|
|
1307
|
-
// If sequencer is not initialized, we just set these values to zero for simulation.
|
|
1308
|
-
const coinbase = EthAddress.ZERO;
|
|
1309
|
-
const feeRecipient = AztecAddress.ZERO;
|
|
1310
|
-
const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(blockNumber, coinbase, feeRecipient);
|
|
1311
|
-
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, new DateProvider(), this.telemetry, this.log.getBindings());
|
|
1312
|
-
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
|
|
1313
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
1314
|
-
txHash,
|
|
1315
|
-
blockNumber
|
|
1316
|
-
});
|
|
1317
|
-
// Ensure world-state has caught up with the latest block we loaded from the archiver
|
|
1318
|
-
await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
|
|
1319
|
-
const merkleTreeFork = await this.worldStateSynchronizer.fork();
|
|
1320
|
-
try {
|
|
1321
|
-
const config = PublicSimulatorConfig.from({
|
|
1322
|
-
skipFeeEnforcement,
|
|
1323
|
-
collectDebugLogs: true,
|
|
1324
|
-
collectHints: false,
|
|
1325
|
-
collectCallMetadata: true,
|
|
1326
|
-
collectStatistics: false,
|
|
1327
|
-
collectionLimits: CollectionLimitsConfig.from({
|
|
1328
|
-
maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
|
|
1329
|
-
})
|
|
1330
|
-
});
|
|
1331
|
-
const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
|
|
1332
|
-
// REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
|
|
1333
|
-
const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
|
|
1334
|
-
tx
|
|
1335
|
-
]);
|
|
1336
|
-
// REFACTOR: Consider returning the error rather than throwing
|
|
1337
|
-
if (failedTxs.length) {
|
|
1338
|
-
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
|
|
1339
|
-
txHash
|
|
1340
|
-
});
|
|
1341
|
-
throw failedTxs[0].error;
|
|
1342
|
-
}
|
|
1343
|
-
const [processedTx] = processedTxs;
|
|
1344
|
-
return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
|
|
1345
|
-
} finally{
|
|
1346
|
-
await merkleTreeFork.close();
|
|
1347
|
-
}
|
|
864
|
+
* @param skipFeeEnforcement - If true, fee enforcement is skipped.
|
|
865
|
+
* @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
|
|
866
|
+
**/ simulatePublicCalls(tx, skipFeeEnforcement = false, overrides) {
|
|
867
|
+
return this.nodePublicCallsSimulator.simulate(tx, skipFeeEnforcement, overrides);
|
|
1348
868
|
}
|
|
1349
869
|
async isValidTx(tx, { isSimulation, skipFeeEnforcement } = {}) {
|
|
1350
870
|
const db = this.worldStateSynchronizer.getCommitted();
|
|
1351
|
-
const verifier = isSimulation ? undefined : this.
|
|
871
|
+
const verifier = isSimulation ? undefined : this.rpcProofVerifier;
|
|
1352
872
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1353
873
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1354
874
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1355
875
|
const l1Constants = await this.blockSource.getL1Constants();
|
|
876
|
+
// Enforce the same network admission limit the node advertises in getNodeInfo (network-wide, not this
|
|
877
|
+
// node's local caps), so a tx the wallet sized against txsLimits is not rejected here.
|
|
878
|
+
const networkTxGasLimits = getNetworkTxGasLimits(this.config, l1Constants);
|
|
1356
879
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1357
880
|
timestamp: nextSlotTimestamp,
|
|
1358
881
|
blockNumber,
|
|
@@ -1364,10 +887,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1364
887
|
],
|
|
1365
888
|
gasFees: await this.getCurrentMinFees(),
|
|
1366
889
|
skipFeeEnforcement,
|
|
890
|
+
isSimulation,
|
|
1367
891
|
txsPermitted: !this.config.disableTransactions,
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
892
|
+
maxTxL2Gas: networkTxGasLimits.l2Gas,
|
|
893
|
+
maxTxDAGas: networkTxGasLimits.daGas
|
|
1371
894
|
}, this.log.getBindings());
|
|
1372
895
|
return await validator.validateTx(tx);
|
|
1373
896
|
}
|
|
@@ -1381,7 +904,20 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1381
904
|
...this.config,
|
|
1382
905
|
...config
|
|
1383
906
|
};
|
|
1384
|
-
|
|
907
|
+
// If the sequencer is currently paused via pauseSequencer(), record the caller's desired
|
|
908
|
+
// minTxsPerBlock as the restore value (so resumeSequencer applies it) and keep the freeze
|
|
909
|
+
// (MAX_SAFE_INTEGER) applied to the underlying sequencer. Without this guard, forwarding
|
|
910
|
+
// the new minTxsPerBlock to the sequencer would silently unpause block production while
|
|
911
|
+
// pauseSequencer() still considers it paused.
|
|
912
|
+
const sequencerUpdate = {
|
|
913
|
+
...config
|
|
914
|
+
};
|
|
915
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined && sequencerUpdate.minTxsPerBlock !== undefined) {
|
|
916
|
+
this.sequencerPausedMinTxsPerBlock = sequencerUpdate.minTxsPerBlock;
|
|
917
|
+
delete sequencerUpdate.minTxsPerBlock;
|
|
918
|
+
}
|
|
919
|
+
this.sequencer?.updateConfig(sequencerUpdate);
|
|
920
|
+
this.automineSequencer?.updateConfig(sequencerUpdate);
|
|
1385
921
|
this.slasherClient?.updateConfig(config);
|
|
1386
922
|
this.validatorsSentinel?.updateConfig(config);
|
|
1387
923
|
await this.p2pClient.updateP2PConfig(config);
|
|
@@ -1390,7 +926,18 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1390
926
|
archiver.updateConfig(config);
|
|
1391
927
|
}
|
|
1392
928
|
if (newConfig.realProofs !== this.config.realProofs) {
|
|
1393
|
-
|
|
929
|
+
await Promise.all([
|
|
930
|
+
tryStop(this.peerProofVerifier),
|
|
931
|
+
tryStop(this.rpcProofVerifier)
|
|
932
|
+
]);
|
|
933
|
+
if (newConfig.realProofs) {
|
|
934
|
+
this.peerProofVerifier = await BatchChonkVerifier.new(newConfig, newConfig.bbChonkVerifyMaxBatch, 'peer');
|
|
935
|
+
const rpcVerifier = await BBCircuitVerifier.new(newConfig);
|
|
936
|
+
this.rpcProofVerifier = new QueuedIVCVerifier(rpcVerifier, newConfig.numConcurrentIVCVerifiers);
|
|
937
|
+
} else {
|
|
938
|
+
this.peerProofVerifier = new TestCircuitVerifier();
|
|
939
|
+
this.rpcProofVerifier = new TestCircuitVerifier();
|
|
940
|
+
}
|
|
1394
941
|
}
|
|
1395
942
|
this.config = newConfig;
|
|
1396
943
|
}
|
|
@@ -1399,7 +946,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1399
946
|
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1400
947
|
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1401
948
|
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1402
|
-
multiCallEntrypoint:
|
|
949
|
+
multiCallEntrypoint: STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS
|
|
1403
950
|
});
|
|
1404
951
|
}
|
|
1405
952
|
registerContractFunctionSignatures(signatures) {
|
|
@@ -1450,7 +997,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1450
997
|
});
|
|
1451
998
|
return Promise.resolve();
|
|
1452
999
|
}
|
|
1453
|
-
async rollbackTo(targetBlock, force) {
|
|
1000
|
+
async rollbackTo(targetBlock, force, resumeSync = true) {
|
|
1454
1001
|
const archiver = this.blockSource;
|
|
1455
1002
|
if (!('rollbackTo' in archiver)) {
|
|
1456
1003
|
throw new Error('Archiver implementation does not support rollbacks.');
|
|
@@ -1478,9 +1025,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1478
1025
|
this.log.error(`Error during rollback`, err);
|
|
1479
1026
|
throw err;
|
|
1480
1027
|
} finally{
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1028
|
+
if (resumeSync) {
|
|
1029
|
+
this.log.info(`Resuming world state and archiver sync.`);
|
|
1030
|
+
this.worldStateSynchronizer.resumeSync();
|
|
1031
|
+
archiver.resume();
|
|
1032
|
+
} else {
|
|
1033
|
+
this.log.info(`Sync left paused after rollback (resumeSync=false).`);
|
|
1034
|
+
}
|
|
1484
1035
|
}
|
|
1485
1036
|
}
|
|
1486
1037
|
async pauseSync() {
|
|
@@ -1494,18 +1045,51 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1494
1045
|
this.blockSource.resume();
|
|
1495
1046
|
return Promise.resolve();
|
|
1496
1047
|
}
|
|
1497
|
-
|
|
1498
|
-
if (
|
|
1499
|
-
|
|
1048
|
+
pauseSequencer() {
|
|
1049
|
+
if (this.automineSequencer) {
|
|
1050
|
+
this.automineSequencer.pause();
|
|
1051
|
+
return Promise.resolve();
|
|
1500
1052
|
}
|
|
1501
|
-
|
|
1053
|
+
if (this.sequencer) {
|
|
1054
|
+
if (this.sequencerPausedMinTxsPerBlock === undefined) {
|
|
1055
|
+
this.sequencerPausedMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock ?? 0;
|
|
1056
|
+
this.sequencer.updateConfig({
|
|
1057
|
+
minTxsPerBlock: Number.MAX_SAFE_INTEGER
|
|
1058
|
+
});
|
|
1059
|
+
this.log.info(`Sequencer paused (minTxsPerBlock set to MAX_SAFE_INTEGER)`, {
|
|
1060
|
+
previousMinTxsPerBlock: this.sequencerPausedMinTxsPerBlock
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
return Promise.resolve();
|
|
1064
|
+
}
|
|
1065
|
+
throw new BadRequestError('Cannot pause sequencer: no sequencer is running');
|
|
1066
|
+
}
|
|
1067
|
+
resumeSequencer() {
|
|
1068
|
+
if (this.automineSequencer) {
|
|
1069
|
+
this.automineSequencer.resume();
|
|
1070
|
+
return Promise.resolve();
|
|
1071
|
+
}
|
|
1072
|
+
if (this.sequencer) {
|
|
1073
|
+
if (this.sequencerPausedMinTxsPerBlock !== undefined) {
|
|
1074
|
+
const restored = this.sequencerPausedMinTxsPerBlock;
|
|
1075
|
+
this.sequencerPausedMinTxsPerBlock = undefined;
|
|
1076
|
+
this.sequencer.updateConfig({
|
|
1077
|
+
minTxsPerBlock: restored
|
|
1078
|
+
});
|
|
1079
|
+
this.log.info(`Sequencer resumed (minTxsPerBlock restored)`, {
|
|
1080
|
+
minTxsPerBlock: restored
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
return Promise.resolve();
|
|
1084
|
+
}
|
|
1085
|
+
throw new BadRequestError('Cannot resume sequencer: no sequencer is running');
|
|
1502
1086
|
}
|
|
1503
1087
|
getSlashOffenses(round) {
|
|
1504
1088
|
if (!this.slasherClient) {
|
|
1505
1089
|
throw new Error(`Slasher client not enabled`);
|
|
1506
1090
|
}
|
|
1507
1091
|
if (round === 'all') {
|
|
1508
|
-
return this.slasherClient.
|
|
1092
|
+
return this.slasherClient.getOffenses();
|
|
1509
1093
|
} else {
|
|
1510
1094
|
return this.slasherClient.gatherOffensesForRound(round === 'current' ? undefined : BigInt(round));
|
|
1511
1095
|
}
|
|
@@ -1577,57 +1161,60 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1577
1161
|
this.keyStoreManager = newManager;
|
|
1578
1162
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1579
1163
|
}
|
|
1580
|
-
|
|
1581
|
-
if (
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1164
|
+
async mineBlock() {
|
|
1165
|
+
if (this.automineSequencer) {
|
|
1166
|
+
await this.automineSequencer.buildEmptyBlock();
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (!this.sequencer) {
|
|
1170
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1171
|
+
}
|
|
1172
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1173
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1174
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1175
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1176
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1177
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1178
|
+
this.sequencer.updateConfig({
|
|
1179
|
+
minTxsPerBlock: 0
|
|
1180
|
+
});
|
|
1592
1181
|
try {
|
|
1593
|
-
//
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1182
|
+
// Trigger the sequencer to produce a block immediately
|
|
1183
|
+
void this.sequencer.trigger();
|
|
1184
|
+
// Wait for the new L2 block to appear
|
|
1185
|
+
await retryUntil(async ()=>{
|
|
1186
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1187
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1188
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1189
|
+
} finally{
|
|
1190
|
+
this.sequencer.updateConfig({
|
|
1191
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1192
|
+
});
|
|
1597
1193
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1194
|
+
}
|
|
1195
|
+
async prove(upToCheckpoint) {
|
|
1196
|
+
if (!this.automineSequencer) {
|
|
1197
|
+
throw new BadRequestError('Cannot prove checkpoint: no automine sequencer is running');
|
|
1601
1198
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1608
|
-
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1609
|
-
if (!header) {
|
|
1610
|
-
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.`);
|
|
1611
|
-
}
|
|
1612
|
-
const blockNumber = header.getBlockNumber();
|
|
1613
|
-
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1614
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1199
|
+
return await this.automineSequencer.prove(upToCheckpoint);
|
|
1200
|
+
}
|
|
1201
|
+
async warpL2TimeAtLeastTo(targetTimestamp) {
|
|
1202
|
+
if (!this.automineSequencer) {
|
|
1203
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1615
1204
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1623
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1205
|
+
await this.automineSequencer.warpTo(targetTimestamp);
|
|
1206
|
+
}
|
|
1207
|
+
async warpL2TimeAtLeastBy(duration) {
|
|
1208
|
+
if (!this.automineSequencer) {
|
|
1209
|
+
throw new BadRequestError('Cannot warp L2 time: no automine sequencer is running');
|
|
1624
1210
|
}
|
|
1211
|
+
await this.automineSequencer.warpBy(duration);
|
|
1625
1212
|
}
|
|
1626
1213
|
/**
|
|
1627
|
-
*
|
|
1628
|
-
* @
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
return
|
|
1214
|
+
* Returns a committed world-state view at `block`, driving sync first. Delegates to
|
|
1215
|
+
* {@link NodeWorldStateQueries.getWorldState}; kept as a protected method so subclasses and tests can
|
|
1216
|
+
* exercise the node's block-resolution and reorg-aware sync behavior.
|
|
1217
|
+
*/ getWorldState(block) {
|
|
1218
|
+
return this.worldStateQueries.getWorldState(block);
|
|
1632
1219
|
}
|
|
1633
1220
|
}
|