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