@aztec/aztec-node 0.0.1-commit.ffe5b04ea → 0.0.1-commit.fff30aa
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/config.d.ts +2 -2
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +1 -1
- package/dest/aztec-node/server.d.ts +15 -18
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +146 -90
- package/dest/sentinel/factory.d.ts +2 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +3 -3
- package/package.json +27 -27
- package/src/aztec-node/config.ts +1 -1
- package/src/aztec-node/server.ts +163 -85
- package/src/sentinel/factory.ts +1 -1
- package/src/sentinel/sentinel.ts +3 -3
|
@@ -377,14 +377,15 @@ import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
|
377
377
|
import { Blob } from '@aztec/blob-lib';
|
|
378
378
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
379
379
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
380
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
380
|
+
import { getPublicClient, makeL1HttpTransport } from '@aztec/ethereum/client';
|
|
381
381
|
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
382
|
-
import { BlockNumber
|
|
383
|
-
import { compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
382
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
383
|
+
import { chunkBy, compactArray, pick, unique } from '@aztec/foundation/collection';
|
|
384
384
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
385
385
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
386
386
|
import { BadRequestError } from '@aztec/foundation/json-rpc';
|
|
387
387
|
import { createLogger } from '@aztec/foundation/log';
|
|
388
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
388
389
|
import { count } from '@aztec/foundation/string';
|
|
389
390
|
import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
390
391
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
@@ -411,9 +412,9 @@ import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@az
|
|
|
411
412
|
import { PublicSimulationOutput, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
|
|
412
413
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
413
414
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
414
|
-
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient,
|
|
415
|
+
import { FullNodeCheckpointsBuilder as CheckpointsBuilder, FullNodeCheckpointsBuilder, NodeKeystoreAdapter, ValidatorClient, createProposalHandler, createValidatorClient } from '@aztec/validator-client';
|
|
415
416
|
import { createWorldStateSynchronizer } from '@aztec/world-state';
|
|
416
|
-
import { createPublicClient
|
|
417
|
+
import { createPublicClient } from 'viem';
|
|
417
418
|
import { createSentinel } from '../sentinel/factory.js';
|
|
418
419
|
import { createKeyStoreForValidator } from './config.js';
|
|
419
420
|
import { NodeMetrics } from './node_metrics.js';
|
|
@@ -559,9 +560,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
559
560
|
}
|
|
560
561
|
const publicClient = createPublicClient({
|
|
561
562
|
chain: ethereumChain.chainInfo,
|
|
562
|
-
transport:
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, {
|
|
564
|
+
timeout: config.l1HttpTimeoutMS
|
|
565
|
+
}),
|
|
565
566
|
pollingInterval: config.viemPollingIntervalMS
|
|
566
567
|
});
|
|
567
568
|
const l1ContractsAddresses = await RegistryContract.collectAddresses(publicClient, config.l1Contracts.registryAddress, config.rollupVersion ?? 'canonical');
|
|
@@ -637,7 +638,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
637
638
|
blockSource: archiver,
|
|
638
639
|
l1ToL2MessageSource: archiver,
|
|
639
640
|
keyStoreManager,
|
|
640
|
-
blobClient
|
|
641
|
+
blobClient,
|
|
642
|
+
slashingProtectionDb: deps.slashingProtectionDb
|
|
641
643
|
});
|
|
642
644
|
// If we have a validator client, register it as a source of offenses for the slasher,
|
|
643
645
|
// and have it register callbacks on the p2p client *before* we start it, otherwise messages
|
|
@@ -649,19 +651,21 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
649
651
|
}
|
|
650
652
|
}
|
|
651
653
|
}
|
|
652
|
-
// If there's no validator client, create a
|
|
654
|
+
// If there's no validator client, create a ProposalHandler to handle block and checkpoint proposals
|
|
653
655
|
// for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
|
|
654
656
|
// while non-reexecution is used for validating the proposals and collecting their txs.
|
|
657
|
+
// Checkpoint proposals are handled if the blob client can upload blobs.
|
|
655
658
|
if (!validatorClient) {
|
|
656
659
|
const reexecute = !!config.alwaysReexecuteBlockProposals;
|
|
657
|
-
log.info(`Setting up
|
|
658
|
-
|
|
660
|
+
log.info(`Setting up proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
|
|
661
|
+
createProposalHandler(config, {
|
|
659
662
|
checkpointsBuilder: validatorCheckpointsBuilder,
|
|
660
663
|
worldState: worldStateSynchronizer,
|
|
661
664
|
epochCache,
|
|
662
665
|
blockSource: archiver,
|
|
663
666
|
l1ToL2MessageSource: archiver,
|
|
664
667
|
p2pClient,
|
|
668
|
+
blobClient,
|
|
665
669
|
dateProvider,
|
|
666
670
|
telemetry
|
|
667
671
|
}).register(p2pClient, reexecute);
|
|
@@ -696,6 +700,13 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
696
700
|
await attestationsBlockWatcher?.start();
|
|
697
701
|
log.info(`All p2p services started`);
|
|
698
702
|
}).catch((err)=>log.error('Failed to start p2p services after archiver sync', err));
|
|
703
|
+
const globalVariableBuilder = new GlobalVariableBuilder(dateProvider, publicClient, {
|
|
704
|
+
l1Contracts: config.l1Contracts,
|
|
705
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
706
|
+
rollupVersion: BigInt(config.rollupVersion),
|
|
707
|
+
l1GenesisTime,
|
|
708
|
+
slotDuration: Number(slotDuration)
|
|
709
|
+
});
|
|
699
710
|
// Validator enabled, create/start relevant service
|
|
700
711
|
let sequencer;
|
|
701
712
|
let slasherClient;
|
|
@@ -743,7 +754,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
743
754
|
telemetry,
|
|
744
755
|
dateProvider,
|
|
745
756
|
blobClient,
|
|
746
|
-
nodeKeyStore: keyStoreManager
|
|
757
|
+
nodeKeyStore: keyStoreManager,
|
|
758
|
+
globalVariableBuilder
|
|
747
759
|
});
|
|
748
760
|
}
|
|
749
761
|
if (!options.dontStartSequencer && sequencer) {
|
|
@@ -773,12 +785,6 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
773
785
|
log.info(`Prover node subsystem created but not started`);
|
|
774
786
|
}
|
|
775
787
|
}
|
|
776
|
-
const globalVariableBuilder = new GlobalVariableBuilder({
|
|
777
|
-
...config,
|
|
778
|
-
rollupVersion: BigInt(config.rollupVersion),
|
|
779
|
-
l1GenesisTime,
|
|
780
|
-
slotDuration: Number(slotDuration)
|
|
781
|
-
});
|
|
782
788
|
const node = new AztecNodeService(config, p2pClient, archiver, archiver, archiver, archiver, worldStateSynchronizer, sequencer, proverNode, slasherClient, validatorsSentinel, epochPruneWatcher, ethereumChain.chainInfo.id, config.rollupVersion, globalVariableBuilder, epochCache, packageVersion, proofVerifier, telemetry, log, blobClient, validatorClient, keyStoreManager, debugLogStore);
|
|
783
789
|
return node;
|
|
784
790
|
}
|
|
@@ -891,6 +897,9 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
891
897
|
async getCheckpointedBlocks(from, limit) {
|
|
892
898
|
return await this.blockSource.getCheckpointedBlocks(from, limit) ?? [];
|
|
893
899
|
}
|
|
900
|
+
getCheckpointsDataForEpoch(epochNumber) {
|
|
901
|
+
return this.blockSource.getCheckpointsDataForEpoch(epochNumber);
|
|
902
|
+
}
|
|
894
903
|
/**
|
|
895
904
|
* Method to fetch the current min L2 fees.
|
|
896
905
|
* @returns The current min L2 fees.
|
|
@@ -1082,70 +1091,88 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1082
1091
|
return compactArray(await Promise.all(txHashes.map((txHash)=>this.getTxByHash(txHash))));
|
|
1083
1092
|
}
|
|
1084
1093
|
async findLeavesIndexes(referenceBlock, treeId, leafValues) {
|
|
1085
|
-
const committedDb = await this
|
|
1094
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1086
1095
|
const maybeIndices = await committedDb.findLeafIndices(treeId, leafValues.map((x)=>x.toBuffer()));
|
|
1087
|
-
//
|
|
1088
|
-
const
|
|
1089
|
-
// Now we find the block numbers for the indices
|
|
1090
|
-
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId,
|
|
1091
|
-
//
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1096
|
+
// Filter out undefined values to query block numbers only for found leaves
|
|
1097
|
+
const definedIndices = maybeIndices.filter((x)=>x !== undefined);
|
|
1098
|
+
// Now we find the block numbers for the defined indices
|
|
1099
|
+
const blockNumbers = await committedDb.getBlockNumbersForLeafIndices(treeId, definedIndices);
|
|
1100
|
+
// Build a map from leaf index to block number
|
|
1101
|
+
const indexToBlockNumber = new Map();
|
|
1102
|
+
for(let i = 0; i < definedIndices.length; i++){
|
|
1103
|
+
const blockNumber = blockNumbers[i];
|
|
1104
|
+
if (blockNumber === undefined) {
|
|
1105
|
+
throw new Error(`Block number is undefined for leaf index ${definedIndices[i]} in tree ${MerkleTreeId[treeId]}`);
|
|
1095
1106
|
}
|
|
1107
|
+
indexToBlockNumber.set(definedIndices[i], blockNumber);
|
|
1096
1108
|
}
|
|
1097
1109
|
// Get unique block numbers in order to optimize num calls to getLeafValue function.
|
|
1098
1110
|
const uniqueBlockNumbers = [
|
|
1099
|
-
...new Set(
|
|
1111
|
+
...new Set(indexToBlockNumber.values())
|
|
1100
1112
|
];
|
|
1101
|
-
// Now we obtain the block hashes from the archive tree
|
|
1102
|
-
// (note that block number corresponds to the leaf index in the archive tree).
|
|
1113
|
+
// Now we obtain the block hashes from the archive tree (block number = leaf index in archive tree).
|
|
1103
1114
|
const blockHashes = await Promise.all(uniqueBlockNumbers.map((blockNumber)=>{
|
|
1104
1115
|
return committedDb.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1105
1116
|
}));
|
|
1106
|
-
//
|
|
1117
|
+
// Build a map from block number to block hash
|
|
1118
|
+
const blockNumberToHash = new Map();
|
|
1107
1119
|
for(let i = 0; i < uniqueBlockNumbers.length; i++){
|
|
1108
|
-
|
|
1120
|
+
const blockHash = blockHashes[i];
|
|
1121
|
+
if (blockHash === undefined) {
|
|
1109
1122
|
throw new Error(`Block hash is undefined for block number ${uniqueBlockNumbers[i]}`);
|
|
1110
1123
|
}
|
|
1124
|
+
blockNumberToHash.set(uniqueBlockNumbers[i], blockHash);
|
|
1111
1125
|
}
|
|
1112
1126
|
// Create DataInBlock objects by combining indices, blockNumbers and blockHashes and return them.
|
|
1113
|
-
return maybeIndices.map((index
|
|
1127
|
+
return maybeIndices.map((index)=>{
|
|
1114
1128
|
if (index === undefined) {
|
|
1115
1129
|
return undefined;
|
|
1116
1130
|
}
|
|
1117
|
-
const blockNumber =
|
|
1131
|
+
const blockNumber = indexToBlockNumber.get(index);
|
|
1118
1132
|
if (blockNumber === undefined) {
|
|
1119
|
-
|
|
1133
|
+
throw new Error(`Block number not found for leaf index ${index} in tree ${MerkleTreeId[treeId]}`);
|
|
1120
1134
|
}
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
return undefined;
|
|
1135
|
+
const blockHash = blockNumberToHash.get(blockNumber);
|
|
1136
|
+
if (blockHash === undefined) {
|
|
1137
|
+
throw new Error(`Block hash not found for block number ${blockNumber}`);
|
|
1125
1138
|
}
|
|
1126
1139
|
return {
|
|
1127
|
-
l2BlockNumber:
|
|
1140
|
+
l2BlockNumber: blockNumber,
|
|
1128
1141
|
l2BlockHash: new BlockHash(blockHash),
|
|
1129
1142
|
data: index
|
|
1130
1143
|
};
|
|
1131
1144
|
});
|
|
1132
1145
|
}
|
|
1133
1146
|
async getBlockHashMembershipWitness(referenceBlock, blockHash) {
|
|
1134
|
-
|
|
1147
|
+
// Block 0 (the initial block) has an empty archive, so no membership witness can exist.
|
|
1148
|
+
if (referenceBlock === BlockNumber.ZERO) {
|
|
1149
|
+
return undefined;
|
|
1150
|
+
}
|
|
1151
|
+
if (BlockHash.isBlockHash(referenceBlock)) {
|
|
1152
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1153
|
+
if (referenceBlock.equals(initialBlockHash)) {
|
|
1154
|
+
return undefined;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
// The Noir circuit checks the archive membership proof against `anchor_block_header.last_archive.root`,
|
|
1158
|
+
// which is the archive tree root BEFORE the anchor block was added (i.e. the state after block N-1).
|
|
1159
|
+
// So we need the world state at block N-1, not block N, to produce a sibling path matching that root.
|
|
1160
|
+
const referenceBlockNumber = await this.resolveBlockNumber(referenceBlock);
|
|
1161
|
+
const committedDb = await this.getWorldState(BlockNumber(referenceBlockNumber - 1));
|
|
1135
1162
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.ARCHIVE, [
|
|
1136
1163
|
blockHash
|
|
1137
1164
|
]);
|
|
1138
1165
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1139
1166
|
}
|
|
1140
1167
|
async getNoteHashMembershipWitness(referenceBlock, noteHash) {
|
|
1141
|
-
const committedDb = await this
|
|
1168
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1142
1169
|
const [pathAndIndex] = await committedDb.findSiblingPaths(MerkleTreeId.NOTE_HASH_TREE, [
|
|
1143
1170
|
noteHash
|
|
1144
1171
|
]);
|
|
1145
1172
|
return pathAndIndex === undefined ? undefined : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
|
|
1146
1173
|
}
|
|
1147
1174
|
async getL1ToL2MessageMembershipWitness(referenceBlock, l1ToL2Message) {
|
|
1148
|
-
const db = await this
|
|
1175
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1149
1176
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [
|
|
1150
1177
|
l1ToL2Message
|
|
1151
1178
|
]);
|
|
@@ -1177,23 +1204,11 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1177
1204
|
*/ async getL2ToL1Messages(epoch) {
|
|
1178
1205
|
// Assumes `getCheckpointedBlocksForEpoch` returns blocks in ascending order of block number.
|
|
1179
1206
|
const checkpointedBlocks = await this.blockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
1180
|
-
const blocksInCheckpoints =
|
|
1181
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
1182
|
-
let checkpointIndex = -1;
|
|
1183
|
-
for (const checkpointedBlock of checkpointedBlocks){
|
|
1184
|
-
const block = checkpointedBlock.block;
|
|
1185
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
1186
|
-
if (slotNumber !== previousSlotNumber) {
|
|
1187
|
-
checkpointIndex++;
|
|
1188
|
-
blocksInCheckpoints.push([]);
|
|
1189
|
-
previousSlotNumber = slotNumber;
|
|
1190
|
-
}
|
|
1191
|
-
blocksInCheckpoints[checkpointIndex].push(block);
|
|
1192
|
-
}
|
|
1207
|
+
const blocksInCheckpoints = chunkBy(checkpointedBlocks, (cb)=>cb.block.header.globalVariables.slotNumber).map((group)=>group.map((cb)=>cb.block));
|
|
1193
1208
|
return blocksInCheckpoints.map((blocks)=>blocks.map((block)=>block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs)));
|
|
1194
1209
|
}
|
|
1195
1210
|
async getNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1196
|
-
const db = await this
|
|
1211
|
+
const db = await this.getWorldState(referenceBlock);
|
|
1197
1212
|
const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [
|
|
1198
1213
|
nullifier.toBuffer()
|
|
1199
1214
|
]);
|
|
@@ -1207,36 +1222,22 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1207
1222
|
}
|
|
1208
1223
|
return new NullifierMembershipWitness(index, leafPreimage, path);
|
|
1209
1224
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
* @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
|
|
1213
|
-
* (which contains the root of the nullifier tree in which we are searching for the nullifier).
|
|
1214
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
1215
|
-
* @returns The low nullifier membership witness (if found).
|
|
1216
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
1217
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
1218
|
-
* we are trying to prove non-inclusion for.
|
|
1219
|
-
*
|
|
1220
|
-
* Note: This function returns the membership witness of the nullifier itself and not the low nullifier when
|
|
1221
|
-
* the nullifier already exists in the tree. This is because the `getPreviousValueIndex` function returns the
|
|
1222
|
-
* index of the nullifier itself when it already exists in the tree.
|
|
1223
|
-
* TODO: This is a confusing behavior and we should eventually address that.
|
|
1224
|
-
*/ async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1225
|
-
const committedDb = await this.#getWorldState(referenceBlock);
|
|
1225
|
+
async getLowNullifierMembershipWitness(referenceBlock, nullifier) {
|
|
1226
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1226
1227
|
const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
1227
1228
|
if (!findResult) {
|
|
1228
1229
|
return undefined;
|
|
1229
1230
|
}
|
|
1230
1231
|
const { index, alreadyPresent } = findResult;
|
|
1231
1232
|
if (alreadyPresent) {
|
|
1232
|
-
|
|
1233
|
+
throw new Error(`Cannot prove nullifier non-inclusion: nullifier ${nullifier.toBigInt()} already exists in the tree`);
|
|
1233
1234
|
}
|
|
1234
1235
|
const preimageData = await committedDb.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, index);
|
|
1235
1236
|
const siblingPath = await committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, BigInt(index));
|
|
1236
1237
|
return new NullifierMembershipWitness(BigInt(index), preimageData, siblingPath);
|
|
1237
1238
|
}
|
|
1238
1239
|
async getPublicDataWitness(referenceBlock, leafSlot) {
|
|
1239
|
-
const committedDb = await this
|
|
1240
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1240
1241
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1241
1242
|
if (!lowLeafResult) {
|
|
1242
1243
|
return undefined;
|
|
@@ -1247,7 +1248,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1247
1248
|
}
|
|
1248
1249
|
}
|
|
1249
1250
|
async getPublicStorageAt(referenceBlock, contract, slot) {
|
|
1250
|
-
const committedDb = await this
|
|
1251
|
+
const committedDb = await this.getWorldState(referenceBlock);
|
|
1251
1252
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
1252
1253
|
const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
|
|
1253
1254
|
if (!lowLeafResult || !lowLeafResult.alreadyPresent) {
|
|
@@ -1348,6 +1349,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1348
1349
|
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1349
1350
|
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1350
1351
|
const blockNumber = BlockNumber(await this.blockSource.getBlockNumber() + 1);
|
|
1352
|
+
const l1Constants = await this.blockSource.getL1Constants();
|
|
1351
1353
|
const validator = createTxValidatorForAcceptingTxsOverRPC(db, this.contractDataSource, verifier, {
|
|
1352
1354
|
timestamp: nextSlotTimestamp,
|
|
1353
1355
|
blockNumber,
|
|
@@ -1359,7 +1361,10 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1359
1361
|
],
|
|
1360
1362
|
gasFees: await this.getCurrentMinFees(),
|
|
1361
1363
|
skipFeeEnforcement,
|
|
1362
|
-
txsPermitted: !this.config.disableTransactions
|
|
1364
|
+
txsPermitted: !this.config.disableTransactions,
|
|
1365
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1366
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1367
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas
|
|
1363
1368
|
}, this.log.getBindings());
|
|
1364
1369
|
return await validator.validateTx(tx);
|
|
1365
1370
|
}
|
|
@@ -1569,6 +1574,33 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1569
1574
|
this.keyStoreManager = newManager;
|
|
1570
1575
|
this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
|
|
1571
1576
|
}
|
|
1577
|
+
async mineBlock() {
|
|
1578
|
+
if (!this.sequencer) {
|
|
1579
|
+
throw new BadRequestError('Cannot mine block: no sequencer is running');
|
|
1580
|
+
}
|
|
1581
|
+
const currentBlockNumber = await this.getBlockNumber();
|
|
1582
|
+
// Use slot duration + 50% buffer as the timeout so this works on running networks too
|
|
1583
|
+
const { slotDuration } = await this.blockSource.getL1Constants();
|
|
1584
|
+
const timeoutSeconds = Math.ceil(slotDuration * 1.5);
|
|
1585
|
+
// Temporarily set minTxsPerBlock to 0 so the sequencer produces a block even with no txs
|
|
1586
|
+
const originalMinTxsPerBlock = this.sequencer.getSequencer().getConfig().minTxsPerBlock;
|
|
1587
|
+
this.sequencer.updateConfig({
|
|
1588
|
+
minTxsPerBlock: 0
|
|
1589
|
+
});
|
|
1590
|
+
try {
|
|
1591
|
+
// Trigger the sequencer to produce a block immediately
|
|
1592
|
+
void this.sequencer.trigger();
|
|
1593
|
+
// Wait for the new L2 block to appear
|
|
1594
|
+
await retryUntil(async ()=>{
|
|
1595
|
+
const newBlockNumber = await this.getBlockNumber();
|
|
1596
|
+
return newBlockNumber > currentBlockNumber ? true : undefined;
|
|
1597
|
+
}, 'mineBlock', timeoutSeconds, 0.1);
|
|
1598
|
+
} finally{
|
|
1599
|
+
this.sequencer.updateConfig({
|
|
1600
|
+
minTxsPerBlock: originalMinTxsPerBlock
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1572
1604
|
#getInitialHeaderHash() {
|
|
1573
1605
|
if (!this.initialHeaderHashPromise) {
|
|
1574
1606
|
this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
|
|
@@ -1579,7 +1611,7 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1579
1611
|
* Returns an instance of MerkleTreeOperations having first ensured the world state is fully synched
|
|
1580
1612
|
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
1581
1613
|
* @returns An instance of a committed MerkleTreeOperations
|
|
1582
|
-
*/ async
|
|
1614
|
+
*/ async getWorldState(block) {
|
|
1583
1615
|
let blockSyncedTo = BlockNumber.ZERO;
|
|
1584
1616
|
try {
|
|
1585
1617
|
// Attempt to sync the world state if necessary
|
|
@@ -1591,6 +1623,8 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1591
1623
|
this.log.debug(`Using committed db for block 'latest', world state synced upto ${blockSyncedTo}`);
|
|
1592
1624
|
return this.worldStateSynchronizer.getCommitted();
|
|
1593
1625
|
}
|
|
1626
|
+
// Get the block number, either directly from the parameter or by quering the archiver with the block hash
|
|
1627
|
+
let blockNumber;
|
|
1594
1628
|
if (BlockHash.isBlockHash(block)) {
|
|
1595
1629
|
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1596
1630
|
if (block.equals(initialBlockHash)) {
|
|
@@ -1601,19 +1635,41 @@ _dec = trackSpan('AztecNodeService.simulatePublicCalls', (tx)=>({
|
|
|
1601
1635
|
if (!header) {
|
|
1602
1636
|
throw new Error(`Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1603
1637
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1608
|
-
//
|
|
1609
|
-
{
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1638
|
+
blockNumber = header.getBlockNumber();
|
|
1639
|
+
} else {
|
|
1640
|
+
blockNumber = block;
|
|
1641
|
+
}
|
|
1642
|
+
// Check it's within world state sync range
|
|
1643
|
+
if (blockNumber > blockSyncedTo) {
|
|
1644
|
+
throw new Error(`Queried block ${block} not yet synced by the node (node is synced upto ${blockSyncedTo}).`);
|
|
1645
|
+
}
|
|
1646
|
+
this.log.debug(`Using snapshot for block ${blockNumber}, world state synced upto ${blockSyncedTo}`);
|
|
1647
|
+
const snapshot = this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1648
|
+
// Double-check world-state synced to the same block hash as was requested
|
|
1649
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1650
|
+
const blockHash = await snapshot.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(blockNumber));
|
|
1651
|
+
if (!blockHash || !new BlockHash(blockHash).equals(block)) {
|
|
1652
|
+
throw new Error(`Block hash ${block.toString()} not found in world state at block number ${blockNumber}. If the node API has been queried with anchor block hash possibly a reorg has occurred.`);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
return snapshot;
|
|
1656
|
+
}
|
|
1657
|
+
/** Resolves a block parameter to a block number. */ async resolveBlockNumber(block) {
|
|
1658
|
+
if (block === 'latest') {
|
|
1659
|
+
return BlockNumber(await this.blockSource.getBlockNumber());
|
|
1660
|
+
}
|
|
1661
|
+
if (BlockHash.isBlockHash(block)) {
|
|
1662
|
+
const initialBlockHash = await this.#getInitialHeaderHash();
|
|
1663
|
+
if (block.equals(initialBlockHash)) {
|
|
1664
|
+
return BlockNumber.ZERO;
|
|
1665
|
+
}
|
|
1666
|
+
const header = await this.blockSource.getBlockHeaderByHash(block);
|
|
1667
|
+
if (!header) {
|
|
1668
|
+
throw new Error(`Block hash ${block.toString()} not found.`);
|
|
1613
1669
|
}
|
|
1614
|
-
|
|
1615
|
-
return this.worldStateSynchronizer.getSnapshot(blockNumber);
|
|
1670
|
+
return header.getBlockNumber();
|
|
1616
1671
|
}
|
|
1672
|
+
return block;
|
|
1617
1673
|
}
|
|
1618
1674
|
/**
|
|
1619
1675
|
* Ensure we fully sync the world state
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
2
3
|
import type { P2PClient } from '@aztec/p2p';
|
|
3
4
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
4
5
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
6
6
|
import type { SentinelConfig } from './config.js';
|
|
7
7
|
import { Sentinel } from './sentinel.js';
|
|
8
8
|
export declare function createSentinel(epochCache: EpochCache, archiver: L2BlockSource, p2p: P2PClient, config: SentinelConfig & DataStoreConfig & SlasherConfig, logger?: import("@aztec/foundation/log").Logger): Promise<Sentinel | undefined>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlbnRpbmVsL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQzVDLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRXJFLE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNsRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBR3pDLHdCQUFzQixjQUFjLENBQ2xDLFVBQVUsRUFBRSxVQUFVLEVBQ3RCLFFBQVEsRUFBRSxhQUFhLEVBQ3ZCLEdBQUcsRUFBRSxTQUFTLEVBQ2QsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLEdBQUcsYUFBYSxFQUN4RCxNQUFNLHlDQUFnQyxHQUNyQyxPQUFPLENBQUMsUUFBUSxHQUFHLFNBQVMsQ0FBQyxDQVkvQiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/sentinel/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,wBAAsB,cAAc,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,cAAc,GAAG,eAAe,GAAG,aAAa,EACxD,MAAM,yCAAgC,GACrC,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAY/B"}
|
|
@@ -229,10 +229,10 @@ export class Sentinel extends EventEmitter {
|
|
|
229
229
|
this.logger.trace(`Refusing to process slot ${targetSlot} given initial slot ${this.initialSlot}`);
|
|
230
230
|
return false;
|
|
231
231
|
}
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
232
|
+
const syncedSlot = await this.archiver.getSyncedL2SlotNumber();
|
|
233
|
+
if (syncedSlot === undefined || syncedSlot < targetSlot) {
|
|
234
234
|
this.logger.debug(`Waiting for archiver to sync with L2 slot ${targetSlot}`, {
|
|
235
|
-
|
|
235
|
+
syncedSlot,
|
|
236
236
|
targetSlot
|
|
237
237
|
});
|
|
238
238
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec-node",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.fff30aa",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -65,32 +65,32 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
69
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
70
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
71
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
72
|
-
"@aztec/constants": "0.0.1-commit.
|
|
73
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
78
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
79
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
80
|
-
"@aztec/node-lib": "0.0.1-commit.
|
|
81
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
82
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
83
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
84
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
85
|
-
"@aztec/prover-node": "0.0.1-commit.
|
|
86
|
-
"@aztec/sequencer-client": "0.0.1-commit.
|
|
87
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
88
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
89
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
90
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
91
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
92
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
93
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
68
|
+
"@aztec/archiver": "0.0.1-commit.fff30aa",
|
|
69
|
+
"@aztec/bb-prover": "0.0.1-commit.fff30aa",
|
|
70
|
+
"@aztec/blob-client": "0.0.1-commit.fff30aa",
|
|
71
|
+
"@aztec/blob-lib": "0.0.1-commit.fff30aa",
|
|
72
|
+
"@aztec/constants": "0.0.1-commit.fff30aa",
|
|
73
|
+
"@aztec/epoch-cache": "0.0.1-commit.fff30aa",
|
|
74
|
+
"@aztec/ethereum": "0.0.1-commit.fff30aa",
|
|
75
|
+
"@aztec/foundation": "0.0.1-commit.fff30aa",
|
|
76
|
+
"@aztec/kv-store": "0.0.1-commit.fff30aa",
|
|
77
|
+
"@aztec/l1-artifacts": "0.0.1-commit.fff30aa",
|
|
78
|
+
"@aztec/merkle-tree": "0.0.1-commit.fff30aa",
|
|
79
|
+
"@aztec/node-keystore": "0.0.1-commit.fff30aa",
|
|
80
|
+
"@aztec/node-lib": "0.0.1-commit.fff30aa",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.fff30aa",
|
|
82
|
+
"@aztec/p2p": "0.0.1-commit.fff30aa",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.fff30aa",
|
|
84
|
+
"@aztec/prover-client": "0.0.1-commit.fff30aa",
|
|
85
|
+
"@aztec/prover-node": "0.0.1-commit.fff30aa",
|
|
86
|
+
"@aztec/sequencer-client": "0.0.1-commit.fff30aa",
|
|
87
|
+
"@aztec/simulator": "0.0.1-commit.fff30aa",
|
|
88
|
+
"@aztec/slasher": "0.0.1-commit.fff30aa",
|
|
89
|
+
"@aztec/stdlib": "0.0.1-commit.fff30aa",
|
|
90
|
+
"@aztec/telemetry-client": "0.0.1-commit.fff30aa",
|
|
91
|
+
"@aztec/validator-client": "0.0.1-commit.fff30aa",
|
|
92
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.fff30aa",
|
|
93
|
+
"@aztec/world-state": "0.0.1-commit.fff30aa",
|
|
94
94
|
"koa": "^2.16.1",
|
|
95
95
|
"koa-router": "^13.1.1",
|
|
96
96
|
"tslib": "^2.4.0",
|
package/src/aztec-node/config.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethe
|
|
|
3
3
|
import { type L1ContractAddresses, l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
4
4
|
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
6
7
|
import {
|
|
7
8
|
type KeyStore,
|
|
8
9
|
type ValidatorKeyStore,
|
|
@@ -26,7 +27,6 @@ import { slasherConfigMappings } from '@aztec/slasher';
|
|
|
26
27
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
27
28
|
import { type NodeRPCConfig, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
28
29
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
29
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
30
30
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
31
31
|
import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
|
|
32
32
|
|