@aztec/p2p 1.0.0 → 1.1.2
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/bootstrap/bootstrap.js +1 -1
- package/dest/client/factory.js +1 -1
- package/dest/client/p2p_client.js +1 -1
- package/dest/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +11 -4
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +17 -10
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -2
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +2 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +3 -2
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +10 -3
- package/dest/msg_validators/tx_validator/factory.d.ts +2 -1
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +2 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +13 -7
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +4 -4
- package/dest/services/libp2p/instrumentation.d.ts +8 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +130 -2
- package/dest/services/libp2p/libp2p_service.d.ts +8 -3
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +34 -14
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +2 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +3 -2
- package/dest/testbench/p2p_client_testbench_worker.js +6 -0
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -1
- package/dest/util.d.ts +3 -2
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +6 -5
- package/package.json +13 -13
- package/src/bootstrap/bootstrap.ts +1 -1
- package/src/client/factory.ts +1 -1
- package/src/client/p2p_client.ts +1 -1
- package/src/config.ts +2 -1
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +22 -12
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +3 -3
- package/src/mem_pools/tx_pool/tx_pool.ts +3 -2
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +8 -4
- package/src/msg_validators/tx_validator/factory.ts +4 -1
- package/src/msg_validators/tx_validator/metadata_validator.ts +20 -9
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -2
- package/src/services/libp2p/instrumentation.ts +122 -3
- package/src/services/libp2p/libp2p_service.ts +41 -15
- package/src/test-helpers/make-test-p2p-clients.ts +2 -1
- package/src/test-helpers/reqresp-nodes.ts +3 -2
- package/src/testbench/p2p_client_testbench_worker.ts +1 -0
- package/src/testbench/worker_client_manager.ts +2 -1
- package/src/util.ts +8 -7
|
@@ -33,7 +33,7 @@ import { convertToMultiaddr, getPeerIdPrivateKey } from '../util.js';
|
|
|
33
33
|
}
|
|
34
34
|
const listenAddrUdp = multiaddr(convertToMultiaddr(listenAddress, config.p2pBroadcastPort, 'udp'));
|
|
35
35
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, this.store, this.logger);
|
|
36
|
-
const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey, p2pIp, config.p2pBroadcastPort, config.l1ChainId);
|
|
36
|
+
const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(peerIdPrivateKey.getValue(), p2pIp, config.p2pBroadcastPort, config.l1ChainId);
|
|
37
37
|
this.peerId = peerId;
|
|
38
38
|
this.logger.debug(`Starting bootstrap node ${peerId} listening on ${listenAddrUdp.toString()}`);
|
|
39
39
|
const metricsRegistry = new OtelMetricsAdapter(this.telemetry);
|
package/dest/client/factory.js
CHANGED
|
@@ -35,7 +35,7 @@ export const createP2PClient = async (clientType, _config, archiver, proofVerifi
|
|
|
35
35
|
config = await configureP2PClientAddresses(_config);
|
|
36
36
|
// Create peer discovery service
|
|
37
37
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
38
|
-
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey);
|
|
38
|
+
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
39
39
|
const p2pService = await (deps.p2pServiceFactory ?? LibP2PService.new)(clientType, config, peerId, {
|
|
40
40
|
packageVersion,
|
|
41
41
|
mempools,
|
|
@@ -518,7 +518,7 @@ import { P2PClientState } from './interface.js';
|
|
|
518
518
|
*/ async markTxsAsMinedFromBlocks(blocks) {
|
|
519
519
|
for (const block of blocks){
|
|
520
520
|
const txHashes = block.body.txEffects.map((txEffect)=>txEffect.txHash);
|
|
521
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
521
|
+
await this.txPool.markAsMined(txHashes, block.header);
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
/**
|
package/dest/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
1
|
+
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
2
2
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
3
|
import { type AllowedElement, type ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type P2PReqRespConfig } from './services/reqresp/config.js';
|
|
@@ -27,7 +27,7 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
|
|
|
27
27
|
/** The listen address. */
|
|
28
28
|
listenAddress: string;
|
|
29
29
|
/** An optional peer id private key. If blank, will generate a random key. */
|
|
30
|
-
peerIdPrivateKey?: string
|
|
30
|
+
peerIdPrivateKey?: SecretValue<string>;
|
|
31
31
|
/** An optional path to store generated peer id private keys. If blank, will default to storing any generated keys in the data directory. */
|
|
32
32
|
peerIdPrivateKeyPath?: string;
|
|
33
33
|
/** A list of bootstrap peers to connect to. */
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,WAAW,EAQZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAGlF,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAElG,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,8BAA8B,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,WAAW;IAC9D,oEAAoE;IACpE,UAAU,EAAE,OAAO,CAAC;IAEpB,yDAAyD;IACzD,oBAAoB,EAAE,MAAM,CAAC;IAE7B,uDAAuD;IACvD,qBAAqB,EAAE,MAAM,CAAC;IAE9B,oEAAoE;IACpE,6BAA6B,EAAE,OAAO,CAAC;IAEvC,qDAAqD;IACrD,mBAAmB,EAAE,MAAM,CAAC;IAE5B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,oCAAoC;IACpC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from '@aztec/foundation/log';
|
|
2
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
3
|
import type { MerkleTreeReadOperations, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
import { ArchiveCache } from '../../msg_validators/tx_validator/archive_cache.js';
|
|
7
7
|
import { GasTxValidator } from '../../msg_validators/tx_validator/gas_validator.js';
|
|
@@ -24,7 +24,14 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
24
24
|
constructor(store: AztecAsyncKVStore, archive: AztecAsyncKVStore, worldStateSynchronizer: WorldStateSynchronizer, telemetry?: TelemetryClient, config?: TxPoolOptions, log?: Logger);
|
|
25
25
|
private countTxs;
|
|
26
26
|
isEmpty(): Promise<boolean>;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Marks transactions as mined in a block and updates the pool state accordingly.
|
|
29
|
+
* Removes the transactions from the pending set and adds them to the mined set.
|
|
30
|
+
* Also evicts any transactions that become invalid after the block is mined.
|
|
31
|
+
* @param txHashes - Array of transaction hashes that were mined
|
|
32
|
+
* @param blockHeader - The header of the block the transactions were mined in
|
|
33
|
+
*/
|
|
34
|
+
markAsMined(txHashes: TxHash[], blockHeader: BlockHeader): Promise<void>;
|
|
28
35
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
29
36
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
30
37
|
getMinedTxHashes(): Promise<[TxHash, number][]>;
|
|
@@ -107,10 +114,10 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
107
114
|
* Eviction criteria includes:
|
|
108
115
|
* - txs with nullifiers that are already included in the mined block
|
|
109
116
|
* - txs with an insufficient fee payer balance
|
|
110
|
-
* - txs with
|
|
117
|
+
* - txs with an expiration timestamp lower than that of the mined block
|
|
111
118
|
*
|
|
112
119
|
* @param minedTxHashes - The tx hashes of the txs mined in the block.
|
|
113
|
-
* @param
|
|
120
|
+
* @param blockHeader - The header of the mined block.
|
|
114
121
|
* @returns The total number of txs evicted from the pool.
|
|
115
122
|
*/
|
|
116
123
|
private evictInvalidTxsAfterMining;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAA0D,MAAM,iBAAiB,CAAC;AAGjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAA0D,MAAM,iBAAiB,CAAC;AAGjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGpF,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D;;GAEG;AAC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M,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC/C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrE;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IASvC;;;OAGG;IACU,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKzC,YAAY,CAAC,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,EAAE,aAAa,GAAG,IAAI;IAwB3F,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,wBAAwB,GAAG,cAAc;IAI5E;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,wBAAwB,GAAG,YAAY;IAIxE;;;;;OAKG;YACW,kBAAkB;IAoBhC;;;;OAIG;YACW,UAAU;IAiCxB;;;;;;OAMG;YACW,mBAAmB;IA8CjC;;;;;;;;;;OAUG;YACW,0BAA0B;IA4DxC;;;;;OAKG;YACW,yBAAyB;YAqCzB,mBAAmB;YAMnB,sBAAsB;CAMrC"}
|
|
@@ -76,7 +76,13 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
76
76
|
}
|
|
77
77
|
return true;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Marks transactions as mined in a block and updates the pool state accordingly.
|
|
81
|
+
* Removes the transactions from the pending set and adds them to the mined set.
|
|
82
|
+
* Also evicts any transactions that become invalid after the block is mined.
|
|
83
|
+
* @param txHashes - Array of transaction hashes that were mined
|
|
84
|
+
* @param blockHeader - The header of the block the transactions were mined in
|
|
85
|
+
*/ async markAsMined(txHashes, blockHeader) {
|
|
80
86
|
if (txHashes.length === 0) {
|
|
81
87
|
return Promise.resolve();
|
|
82
88
|
}
|
|
@@ -86,7 +92,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
86
92
|
let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
|
|
87
93
|
for (const hash of txHashes){
|
|
88
94
|
const key = hash.toString();
|
|
89
|
-
await this.#minedTxHashToBlock.set(key, blockNumber);
|
|
95
|
+
await this.#minedTxHashToBlock.set(key, blockHeader.globalVariables.blockNumber);
|
|
90
96
|
const tx = await this.getPendingTxByHash(hash);
|
|
91
97
|
if (tx) {
|
|
92
98
|
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
@@ -97,7 +103,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
100
|
-
await this.evictInvalidTxsAfterMining(txHashes,
|
|
106
|
+
await this.evictInvalidTxsAfterMining(txHashes, blockHeader, minedNullifiers, minedFeePayers);
|
|
101
107
|
});
|
|
102
108
|
// We update this after the transaction above. This ensures that the non-evictable transactions are not evicted
|
|
103
109
|
// until any that have been mined are marked as such.
|
|
@@ -428,15 +434,16 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
428
434
|
* Eviction criteria includes:
|
|
429
435
|
* - txs with nullifiers that are already included in the mined block
|
|
430
436
|
* - txs with an insufficient fee payer balance
|
|
431
|
-
* - txs with
|
|
437
|
+
* - txs with an expiration timestamp lower than that of the mined block
|
|
432
438
|
*
|
|
433
439
|
* @param minedTxHashes - The tx hashes of the txs mined in the block.
|
|
434
|
-
* @param
|
|
440
|
+
* @param blockHeader - The header of the mined block.
|
|
435
441
|
* @returns The total number of txs evicted from the pool.
|
|
436
|
-
*/ async evictInvalidTxsAfterMining(minedTxHashes,
|
|
442
|
+
*/ async evictInvalidTxsAfterMining(minedTxHashes, blockHeader, minedNullifiers, minedFeePayers) {
|
|
437
443
|
if (minedTxHashes.length === 0) {
|
|
438
444
|
return 0;
|
|
439
445
|
}
|
|
446
|
+
const { blockNumber, timestamp } = blockHeader.globalVariables;
|
|
440
447
|
// Wait for world state to be synced to at least the mined block number
|
|
441
448
|
await this.#worldStateSynchronizer.syncImmediate(blockNumber);
|
|
442
449
|
const db = this.#worldStateSynchronizer.getCommitted();
|
|
@@ -460,10 +467,10 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
460
467
|
txsToEvict.push(TxHash.fromString(txHash));
|
|
461
468
|
continue;
|
|
462
469
|
}
|
|
463
|
-
// Evict pending txs with
|
|
464
|
-
const
|
|
465
|
-
if (
|
|
466
|
-
this.#log.verbose(`Evicting tx ${txHash} from pool due to
|
|
470
|
+
// Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
|
|
471
|
+
const includeByTimestamp = tx.data.rollupValidationRequests.includeByTimestamp;
|
|
472
|
+
if (includeByTimestamp.isSome && includeByTimestamp.value <= timestamp) {
|
|
473
|
+
this.#log.verbose(`Evicting tx ${txHash} from pool due to the tx being expired (includeByTimestamp: ${includeByTimestamp.value}, mined block timestamp: ${timestamp})`);
|
|
467
474
|
txsToEvict.push(TxHash.fromString(txHash));
|
|
468
475
|
continue;
|
|
469
476
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
1
|
+
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
2
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
import type { TxPool, TxPoolOptions } from './tx_pool.js';
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class InMemoryTxPool implements TxPool {
|
|
|
20
20
|
constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
21
21
|
private countTx;
|
|
22
22
|
isEmpty(): Promise<boolean>;
|
|
23
|
-
markAsMined(txHashes: TxHash[],
|
|
23
|
+
markAsMined(txHashes: TxHash[], blockHeader: BlockHeader): Promise<void>;
|
|
24
24
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
25
25
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
26
26
|
getMinedTxHashes(): Promise<[TxHash, number][]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/memory_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"memory_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/memory_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D;;GAEG;AACH,qBAAa,cAAe,YAAW,MAAM;IAgBzC,OAAO,CAAC,GAAG;IAfb;;OAEG;IACH,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,UAAU,CAAc;IAEhC,OAAO,CAAC,OAAO,CAA0B;IAEzC;;;OAGG;gBAED,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAA8B;IAQ3C,OAAO,CAAC,OAAO,CAOb;IAEK,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3B,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IASxE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB/C,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ7C,gBAAgB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAM/C,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAW5E;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAK3D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IAG7D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,mBAAmB,IAAI,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAIrD;;;;OAIG;IACU,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB/C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD;;;OAGG;IACI,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAIjC;;;OAGG;IACI,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1C,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAE1C,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -35,10 +35,10 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
35
35
|
isEmpty() {
|
|
36
36
|
return Promise.resolve(this.txs.size === 0);
|
|
37
37
|
}
|
|
38
|
-
markAsMined(txHashes,
|
|
38
|
+
markAsMined(txHashes, blockHeader) {
|
|
39
39
|
const keys = txHashes.map((x)=>x.toBigInt());
|
|
40
40
|
for (const key of keys){
|
|
41
|
-
this.minedTxs.set(key, blockNumber);
|
|
41
|
+
this.minedTxs.set(key, blockHeader.globalVariables.blockNumber);
|
|
42
42
|
this.pendingTxs.delete(key);
|
|
43
43
|
}
|
|
44
44
|
return Promise.resolve();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
1
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
2
2
|
export type TxPoolOptions = {
|
|
3
3
|
maxTxPoolSize?: number;
|
|
4
4
|
txPoolOverflowFactor?: number;
|
|
@@ -41,8 +41,9 @@ export interface TxPool {
|
|
|
41
41
|
/**
|
|
42
42
|
* Marks the set of txs as mined, as opposed to pending.
|
|
43
43
|
* @param txHashes - Hashes of the txs to flag as mined.
|
|
44
|
+
* @param blockHeader - The header of the mined block.
|
|
44
45
|
*/
|
|
45
|
-
markAsMined(txHashes: TxHash[],
|
|
46
|
+
markAsMined(txHashes: TxHash[], blockHeader: BlockHeader): Promise<void>;
|
|
46
47
|
/**
|
|
47
48
|
* Moves mined txs back to the pending set in the case of a reorg.
|
|
48
49
|
* Note: txs not known by this peer will be ignored.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;A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AAC,CAAC;IAEjE;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAEtE;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAE1C,yCAAyC;IACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE5B;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool_test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"tx_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool_test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,QA2KrD"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { unfreeze } from '@aztec/foundation/types';
|
|
2
2
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
3
3
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
4
|
+
import { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
4
5
|
/**
|
|
5
6
|
* Tests a TxPool implementation.
|
|
6
7
|
* @param getTxPool - Gets a fresh TxPool
|
|
7
8
|
*/ export function describeTxPool(getTxPool) {
|
|
8
9
|
let pool;
|
|
10
|
+
const minedBlockHeader = BlockHeader.empty({
|
|
11
|
+
globalVariables: GlobalVariables.empty({
|
|
12
|
+
blockNumber: 1,
|
|
13
|
+
timestamp: 0n
|
|
14
|
+
})
|
|
15
|
+
});
|
|
9
16
|
beforeEach(()=>{
|
|
10
17
|
pool = getTxPool();
|
|
11
18
|
});
|
|
@@ -43,7 +50,7 @@ import { mockTx } from '@aztec/stdlib/testing';
|
|
|
43
50
|
]);
|
|
44
51
|
await pool.markAsMined([
|
|
45
52
|
await tx1.getTxHash()
|
|
46
|
-
],
|
|
53
|
+
], minedBlockHeader);
|
|
47
54
|
await expect(pool.getTxByHash(await tx1.getTxHash())).resolves.toEqual(tx1);
|
|
48
55
|
await expect(pool.getTxStatus(await tx1.getTxHash())).resolves.toEqual('mined');
|
|
49
56
|
await expect(pool.getMinedTxHashes()).resolves.toEqual([
|
|
@@ -66,7 +73,7 @@ import { mockTx } from '@aztec/stdlib/testing';
|
|
|
66
73
|
]);
|
|
67
74
|
await pool.markAsMined([
|
|
68
75
|
await tx1.getTxHash()
|
|
69
|
-
],
|
|
76
|
+
], minedBlockHeader);
|
|
70
77
|
await pool.markMinedAsPending([
|
|
71
78
|
await tx1.getTxHash()
|
|
72
79
|
]);
|
|
@@ -91,7 +98,7 @@ import { mockTx } from '@aztec/stdlib/testing';
|
|
|
91
98
|
await pool.markAsMined([
|
|
92
99
|
await tx1.getTxHash(),
|
|
93
100
|
someTxHashThatThisPeerDidNotSee
|
|
94
|
-
],
|
|
101
|
+
], minedBlockHeader);
|
|
95
102
|
expect(await pool.getMinedTxHashes()).toEqual(expect.arrayContaining([
|
|
96
103
|
[
|
|
97
104
|
await tx1.getTxHash(),
|
|
@@ -4,11 +4,12 @@ import type { GasFees } from '@aztec/stdlib/gas';
|
|
|
4
4
|
import type { AllowedElement, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
6
6
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
7
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
7
8
|
export interface MessageValidator {
|
|
8
9
|
validator: {
|
|
9
10
|
validateTx(tx: Tx): Promise<TxValidationResult>;
|
|
10
11
|
};
|
|
11
12
|
severity: PeerErrorSeverity;
|
|
12
13
|
}
|
|
13
|
-
export declare function createTxMessageValidators(blockNumber: number, worldStateSynchronizer: WorldStateSynchronizer, gasFees: GasFees, l1ChainId: number, rollupVersion: number, protocolContractTreeRoot: Fr, contractDataSource: ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, allowedInSetup?: AllowedElement[]): Record<string, MessageValidator>[];
|
|
14
|
+
export declare function createTxMessageValidators(timestamp: UInt64, blockNumber: number, worldStateSynchronizer: WorldStateSynchronizer, gasFees: GasFees, l1ChainId: number, rollupVersion: number, protocolContractTreeRoot: Fr, contractDataSource: ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, allowedInSetup?: AllowedElement[]): Record<string, MessageValidator>[];
|
|
14
15
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAWlD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE;QACT,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;KACjD,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,wBAAwB,EAAE,EAAE,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,6BAA6B,EAC5C,cAAc,GAAE,cAAc,EAAO,GACpC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAsDpC"}
|
|
@@ -11,7 +11,7 @@ import { GasTxValidator } from './gas_validator.js';
|
|
|
11
11
|
import { MetadataTxValidator } from './metadata_validator.js';
|
|
12
12
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
13
13
|
import { TxProofValidator } from './tx_proof_validator.js';
|
|
14
|
-
export function createTxMessageValidators(blockNumber, worldStateSynchronizer, gasFees, l1ChainId, rollupVersion, protocolContractTreeRoot, contractDataSource, proofVerifier, allowedInSetup = []) {
|
|
14
|
+
export function createTxMessageValidators(timestamp, blockNumber, worldStateSynchronizer, gasFees, l1ChainId, rollupVersion, protocolContractTreeRoot, contractDataSource, proofVerifier, allowedInSetup = []) {
|
|
15
15
|
const merkleTree = worldStateSynchronizer.getCommitted();
|
|
16
16
|
return [
|
|
17
17
|
{
|
|
@@ -23,6 +23,7 @@ export function createTxMessageValidators(blockNumber, worldStateSynchronizer, g
|
|
|
23
23
|
validator: new MetadataTxValidator({
|
|
24
24
|
l1ChainId: new Fr(l1ChainId),
|
|
25
25
|
rollupVersion: new Fr(rollupVersion),
|
|
26
|
+
timestamp,
|
|
26
27
|
blockNumber,
|
|
27
28
|
protocolContractTreeRoot,
|
|
28
29
|
vkTreeRoot: getVKTreeRoot()
|
|
@@ -44,7 +45,7 @@ export function createTxMessageValidators(blockNumber, worldStateSynchronizer, g
|
|
|
44
45
|
severity: PeerErrorSeverity.HighToleranceError
|
|
45
46
|
},
|
|
46
47
|
phasesValidator: {
|
|
47
|
-
validator: new PhasesTxValidator(contractDataSource, allowedInSetup,
|
|
48
|
+
validator: new PhasesTxValidator(contractDataSource, allowedInSetup, timestamp),
|
|
48
49
|
severity: PeerErrorSeverity.MidToleranceError
|
|
49
50
|
},
|
|
50
51
|
blockHeaderValidator: {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type AnyTx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
3
4
|
export declare class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
4
5
|
#private;
|
|
5
6
|
private values;
|
|
6
7
|
constructor(values: {
|
|
7
8
|
l1ChainId: Fr;
|
|
8
9
|
rollupVersion: Fr;
|
|
10
|
+
timestamp: UInt64;
|
|
9
11
|
blockNumber: number;
|
|
10
12
|
vkTreeRoot: Fr;
|
|
11
13
|
protocolContractTreeRoot: Fr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,KAAK,EAOV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,KAAK,EAOV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,qBAAa,mBAAmB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;IAIvE,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE;QACd,SAAS,EAAE,EAAE,CAAC;QACd,aAAa,EAAE,EAAE,CAAC;QAGlB,SAAS,EAAE,MAAM,CAAC;QAElB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,EAAE,CAAC;QACf,wBAAwB,EAAE,EAAE,CAAC;KAC9B;IAGG,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4FrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { TX_ERROR_INCORRECT_L1_CHAIN_ID, TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT, TX_ERROR_INCORRECT_ROLLUP_VERSION, TX_ERROR_INCORRECT_VK_TREE_ROOT,
|
|
2
|
+
import { TX_ERROR_INCORRECT_L1_CHAIN_ID, TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT, TX_ERROR_INCORRECT_ROLLUP_VERSION, TX_ERROR_INCORRECT_VK_TREE_ROOT, TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class MetadataTxValidator {
|
|
4
4
|
values;
|
|
5
5
|
#log;
|
|
@@ -15,8 +15,8 @@ export class MetadataTxValidator {
|
|
|
15
15
|
if (!await this.#hasCorrectRollupVersion(tx)) {
|
|
16
16
|
errors.push(TX_ERROR_INCORRECT_ROLLUP_VERSION);
|
|
17
17
|
}
|
|
18
|
-
if (!await this.#
|
|
19
|
-
errors.push(
|
|
18
|
+
if (!await this.#isValidForTimestamp(tx)) {
|
|
19
|
+
errors.push(TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP);
|
|
20
20
|
}
|
|
21
21
|
if (!await this.#hasCorrectVkTreeRoot(tx)) {
|
|
22
22
|
errors.push(TX_ERROR_INCORRECT_VK_TREE_ROOT);
|
|
@@ -55,10 +55,16 @@ export class MetadataTxValidator {
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
async #
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
async #isValidForTimestamp(tx) {
|
|
59
|
+
const includeByTimestamp = tx.data.rollupValidationRequests.includeByTimestamp;
|
|
60
|
+
// If building block 1, we skip the expiration check. For details on why see the `validate_include_by_timestamp`
|
|
61
|
+
// function in `noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/components/validation_requests.nr`.
|
|
62
|
+
const buildingBlock1 = this.values.blockNumber === 1;
|
|
63
|
+
if (!buildingBlock1 && includeByTimestamp.isSome && includeByTimestamp.value < this.values.timestamp) {
|
|
64
|
+
if (tx.data.constants.historicalHeader.globalVariables.blockNumber === 0) {
|
|
65
|
+
this.#log.warn(`A tx built against a genesis block failed to be included in block 1 which is the only block in which txs built against a genesis block are allowed to be included.`);
|
|
66
|
+
}
|
|
67
|
+
this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp.value}, timestamp: ${this.values.timestamp}.`);
|
|
62
68
|
return false;
|
|
63
69
|
} else {
|
|
64
70
|
return true;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
2
2
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
3
3
|
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
5
|
export declare class PhasesTxValidator implements TxValidator<Tx> {
|
|
5
6
|
#private;
|
|
6
7
|
private setupAllowList;
|
|
7
|
-
private
|
|
8
|
+
private timestamp;
|
|
8
9
|
private contractsDB;
|
|
9
|
-
constructor(contracts: ContractDataSource, setupAllowList: AllowedElement[],
|
|
10
|
+
constructor(contracts: ContractDataSource, setupAllowList: AllowedElement[], timestamp: UInt64);
|
|
10
11
|
validateTx(tx: Tx): Promise<TxValidationResult>;
|
|
11
12
|
private isOnAllowList;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAIL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAIL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,qBAAa,iBAAkB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAMrD,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,SAAS;IALnB,OAAO,CAAC,WAAW,CAAoB;gBAGrC,SAAS,EAAE,kBAAkB,EACrB,cAAc,EAAE,cAAc,EAAE,EAChC,SAAS,EAAE,MAAM;IAKrB,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAqCvC,aAAa;CAiD5B"}
|
|
@@ -3,12 +3,12 @@ import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/si
|
|
|
3
3
|
import { TX_ERROR_DURING_VALIDATION, TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
export class PhasesTxValidator {
|
|
5
5
|
setupAllowList;
|
|
6
|
-
|
|
6
|
+
timestamp;
|
|
7
7
|
#log;
|
|
8
8
|
contractsDB;
|
|
9
|
-
constructor(contracts, setupAllowList,
|
|
9
|
+
constructor(contracts, setupAllowList, timestamp){
|
|
10
10
|
this.setupAllowList = setupAllowList;
|
|
11
|
-
this.
|
|
11
|
+
this.timestamp = timestamp;
|
|
12
12
|
this.#log = createLogger('sequencer:tx_validator:tx_phases');
|
|
13
13
|
this.contractsDB = new PublicContractsDB(contracts);
|
|
14
14
|
}
|
|
@@ -71,7 +71,7 @@ export class PhasesTxValidator {
|
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const contractClass = await this.contractsDB.getContractInstance(contractAddress, this.
|
|
74
|
+
const contractClass = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
|
|
75
75
|
if (!contractClass) {
|
|
76
76
|
throw new Error(`Contract not found: ${contractAddress}`);
|
|
77
77
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import
|
|
2
|
+
import { TopicType } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
export declare class P2PInstrumentation {
|
|
5
5
|
private messageValidationDuration;
|
|
6
6
|
private messagePrevalidationCount;
|
|
7
|
+
private messageLatency;
|
|
8
|
+
private aggLatencyHisto;
|
|
9
|
+
private aggValidationHisto;
|
|
10
|
+
private aggLatencyMetrics;
|
|
11
|
+
private aggValidationMetrics;
|
|
7
12
|
constructor(client: TelemetryClient, name: string);
|
|
8
13
|
recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
9
14
|
incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined): void;
|
|
15
|
+
recordMessageLatency(topicName: TopicType, timerOrMs: Timer | number): void;
|
|
16
|
+
private aggregate;
|
|
10
17
|
}
|
|
11
18
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAML,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;IACjD,OAAO,CAAC,cAAc,CAAY;IAElC,OAAO,CAAC,eAAe,CAA6C;IACpE,OAAO,CAAC,kBAAkB,CAA6C;IAEvE,OAAO,CAAC,iBAAiB,CAAiE;IAC1F,OAAO,CAAC,oBAAoB,CAAiE;gBAEjF,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAkF1C,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAavE,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS;IAI/E,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAa3E,OAAO,CAAC,SAAS,CAkBf;CACH"}
|