@aztec/p2p 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +9 -1
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +12 -9
- package/dest/client/interface.d.ts +6 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +11 -8
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +53 -17
- package/dest/config.d.ts +43 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -8
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +93 -55
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +258 -195
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +73 -83
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +18 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +3 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +13 -11
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +28 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +5 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -7
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/discv5/discV5_service.d.ts +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +10 -17
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -18
- package/dest/services/libp2p/libp2p_service.d.ts +19 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +147 -148
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/interface.d.ts +3 -10
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +0 -9
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +42 -24
- package/dest/services/reqresp/reqresp.d.ts +5 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +16 -206
- package/dest/services/service.d.ts +7 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -1
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +13 -7
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +12 -37
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +11 -15
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +19 -14
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -24
- package/dest/testbench/worker_client_manager.d.ts +3 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -8
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +20 -5
- package/src/client/interface.ts +6 -10
- package/src/client/p2p_client.ts +61 -36
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +94 -6
- package/src/errors/reqresp.error.ts +0 -25
- package/src/mem_pools/attestation_pool/attestation_pool.ts +309 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +73 -90
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -1
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +11 -7
- package/src/msg_validators/clock_tolerance.ts +13 -12
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +9 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +14 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +39 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +15 -6
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +12 -43
- package/src/services/libp2p/libp2p_service.ts +169 -167
- package/src/services/peer-manager/peer_manager.ts +1 -0
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/interface.ts +2 -38
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/reqresp.ts +11 -251
- package/src/services/service.ts +9 -30
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +1 -0
- package/src/test-helpers/mock-pubsub.ts +17 -60
- package/src/test-helpers/reqresp-nodes.ts +8 -20
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +23 -27
- package/src/testbench/p2p_client_testbench_worker.ts +16 -42
- package/src/testbench/worker_client_manager.ts +4 -19
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -318
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -357
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { FifoSet } from '@aztec/foundation/fifo-set';
|
|
2
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
4
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -11,6 +12,11 @@ import { TxPoolV2Instrumentation } from './instrumentation.js';
|
|
|
11
12
|
import { DEFAULT_TX_POOL_V2_CONFIG } from './interfaces.js';
|
|
12
13
|
import { buildTxMetaData, checkNullifierConflict } from './tx_metadata.js';
|
|
13
14
|
import { TxPoolIndices } from './tx_pool_indices.js';
|
|
15
|
+
/**
|
|
16
|
+
* Maximum number of full transactions to load into memory at once when finalizing a block.
|
|
17
|
+
* Bounds peak memory while archiving and hard-deleting mined txs (~23k txs/epoch at 10 TPS would
|
|
18
|
+
* otherwise OOM the node).
|
|
19
|
+
*/ const FINALIZE_BLOCK_CHUNK_SIZE = 100;
|
|
14
20
|
/**
|
|
15
21
|
* Implementation of TxPoolV2 logic.
|
|
16
22
|
*
|
|
@@ -33,7 +39,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
33
39
|
#evictionManager;
|
|
34
40
|
#dateProvider;
|
|
35
41
|
#instrumentation;
|
|
36
|
-
#evictedTxHashes
|
|
42
|
+
#evictedTxHashes;
|
|
37
43
|
#log;
|
|
38
44
|
#callbacks;
|
|
39
45
|
constructor(store, archiveStore, deps, callbacks, telemetry, config = {}, dateProvider, log){
|
|
@@ -47,6 +53,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
47
53
|
...DEFAULT_TX_POOL_V2_CONFIG,
|
|
48
54
|
...config
|
|
49
55
|
};
|
|
56
|
+
this.#evictedTxHashes = FifoSet.withLimit(this.#config.evictedTxCacheSize);
|
|
50
57
|
this.#archive = new TxArchive(archiveStore, this.#config.archivedTxLimit, log);
|
|
51
58
|
this.#deletedPool = new DeletedPool(store, this.#txsDB, log);
|
|
52
59
|
this.#dateProvider = dateProvider;
|
|
@@ -84,30 +91,63 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
84
91
|
*/ async hydrateFromDatabase() {
|
|
85
92
|
// Step 0: Hydrate deleted pool state
|
|
86
93
|
await this.#deletedPool.hydrateFromDatabase();
|
|
87
|
-
// Step 1:
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
// Step 1: Stream txs from DB, building metadata and mined status one at a time.
|
|
95
|
+
const minedMetas = [];
|
|
96
|
+
const pendingMetas = [];
|
|
97
|
+
const deserializationErrors = [];
|
|
98
|
+
for await (const [txHashStr, buffer] of this.#txsDB.entriesAsync()){
|
|
99
|
+
// Skip soft-deleted transactions - they stay in DB but not in indices
|
|
100
|
+
if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
let meta;
|
|
104
|
+
let txEffect;
|
|
105
|
+
try {
|
|
106
|
+
const tx = Tx.fromBuffer(buffer);
|
|
107
|
+
// Resolve allowed-setup-calls and the tx effect concurrently
|
|
108
|
+
// getTxEffect failures are non-fatal (we just treat the tx as not-yet-mined), so
|
|
109
|
+
// its rejection is swallowed before the Promise.all so it can't fail-fast the batch.
|
|
110
|
+
const txEffectPromise = this.#l2BlockSource.getTxEffect(tx.getTxHash()).catch((err)=>{
|
|
111
|
+
this.#log.warn(`Failed to check mined status for tx ${txHashStr}`, {
|
|
112
|
+
err
|
|
113
|
+
});
|
|
114
|
+
return undefined;
|
|
115
|
+
});
|
|
116
|
+
const [allowedSetupCalls, fetchedTxEffect] = await Promise.all([
|
|
117
|
+
this.#checkAllowedSetupCalls(tx),
|
|
118
|
+
txEffectPromise
|
|
119
|
+
]);
|
|
120
|
+
meta = await buildTxMetaData(tx, allowedSetupCalls);
|
|
121
|
+
txEffect = fetchedTxEffect;
|
|
122
|
+
} catch (err) {
|
|
123
|
+
this.#log.warn(`Failed to deserialize tx ${txHashStr}, deleting`, {
|
|
124
|
+
err
|
|
125
|
+
});
|
|
126
|
+
deserializationErrors.push(txHashStr);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (txEffect) {
|
|
130
|
+
meta.minedL2BlockId = {
|
|
131
|
+
number: txEffect.l2BlockNumber,
|
|
132
|
+
hash: txEffect.l2BlockHash.toString()
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (meta.minedL2BlockId !== undefined) {
|
|
136
|
+
minedMetas.push(meta);
|
|
97
137
|
} else {
|
|
98
|
-
|
|
138
|
+
pendingMetas.push(meta);
|
|
99
139
|
}
|
|
100
140
|
}
|
|
101
|
-
// Step
|
|
102
|
-
const { valid, invalid } = await this.#revalidateMetadata(
|
|
103
|
-
// Step
|
|
104
|
-
for (const meta of
|
|
141
|
+
// Step 2: Validate non-mined transactions
|
|
142
|
+
const { valid, invalid } = await this.#revalidateMetadata(pendingMetas, 'on startup');
|
|
143
|
+
// Step 3: Populate mined indices (these don't need conflict resolution)
|
|
144
|
+
for (const meta of minedMetas){
|
|
105
145
|
this.#indices.addMined(meta);
|
|
106
146
|
}
|
|
107
|
-
// Step
|
|
147
|
+
// Step 4: Rebuild pending pool by running pre-add rules for each tx
|
|
108
148
|
// This resolves nullifier conflicts, fee payer balance issues, and pool size limits
|
|
109
149
|
const { rejected } = await this.#rebuildPendingPool(valid);
|
|
110
|
-
// Step
|
|
150
|
+
// Step 5: Delete invalid and rejected txs from DB only (indices were never populated for these)
|
|
111
151
|
const toDelete = [
|
|
112
152
|
...deserializationErrors,
|
|
113
153
|
...invalid,
|
|
@@ -520,25 +560,28 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
520
560
|
const blockNumber = block.globalVariables.blockNumber;
|
|
521
561
|
// Step 1: Find mined txs at or before finalized block
|
|
522
562
|
const minedTxsToFinalize = this.#indices.findTxsMinedAtOrBefore(blockNumber);
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
563
|
+
// Step 2: Archive in chunks if archiving is enabled. Hydrating an entire epoch's worth of
|
|
564
|
+
// mined txs at once would OOM under load. When archiving is disabled there is no need to hydrate the txs at all.
|
|
565
|
+
if (this.#archive.isEnabled()) {
|
|
566
|
+
for(let i = 0; i < minedTxsToFinalize.length; i += FINALIZE_BLOCK_CHUNK_SIZE){
|
|
567
|
+
const chunk = minedTxsToFinalize.slice(i, i + FINALIZE_BLOCK_CHUNK_SIZE);
|
|
568
|
+
const txsToArchive = [];
|
|
569
|
+
for (const txHashStr of chunk){
|
|
528
570
|
const buffer = await this.#txsDB.getAsync(txHashStr);
|
|
529
571
|
if (buffer) {
|
|
530
572
|
txsToArchive.push(Tx.fromBuffer(buffer));
|
|
531
573
|
}
|
|
532
574
|
}
|
|
575
|
+
if (txsToArchive.length > 0) {
|
|
576
|
+
await this.#archive.archiveTxs(txsToArchive);
|
|
577
|
+
}
|
|
533
578
|
}
|
|
534
|
-
|
|
579
|
+
}
|
|
580
|
+
// Step 3: Delete mined txs from the active pool and finalize soft-deleted txs in one
|
|
581
|
+
// transaction. Only tx hashes are touched here, so memory is bounded and atomicity is preserved.
|
|
582
|
+
await this.#store.transactionAsync(async ()=>{
|
|
535
583
|
await this.#deleteTxsBatch(minedTxsToFinalize);
|
|
536
|
-
// Step 4: Finalize soft-deleted txs
|
|
537
584
|
await this.#deletedPool.finalizeBlock(blockNumber);
|
|
538
|
-
// Step 5: Archive mined txs
|
|
539
|
-
if (txsToArchive.length > 0) {
|
|
540
|
-
await this.#archive.archiveTxs(txsToArchive);
|
|
541
|
-
}
|
|
542
585
|
});
|
|
543
586
|
if (minedTxsToFinalize.length > 0) {
|
|
544
587
|
this.#log.info(`Finalized ${minedTxsToFinalize.length} mined txs from blocks up to ${blockNumber}`, {
|
|
@@ -710,18 +753,10 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
710
753
|
txHash: txHashStr,
|
|
711
754
|
reason
|
|
712
755
|
});
|
|
713
|
-
this.#
|
|
756
|
+
this.#evictedTxHashes.add(txHashStr);
|
|
714
757
|
}
|
|
715
758
|
await this.#deleteTxsBatch(txHashes);
|
|
716
759
|
}
|
|
717
|
-
/** Adds a tx hash to the bounded evicted cache, evicting the oldest entry if at capacity. */ #addToEvictedCache(txHashStr) {
|
|
718
|
-
if (this.#evictedTxHashes.size >= this.#config.evictedTxCacheSize) {
|
|
719
|
-
// FIFO eviction: remove the first (oldest) entry
|
|
720
|
-
const oldest = this.#evictedTxHashes.values().next().value;
|
|
721
|
-
this.#evictedTxHashes.delete(oldest);
|
|
722
|
-
}
|
|
723
|
-
this.#evictedTxHashes.add(txHashStr);
|
|
724
|
-
}
|
|
725
760
|
// ============================================================================
|
|
726
761
|
// PRIVATE HELPERS - Validation & Conflict Resolution
|
|
727
762
|
// ============================================================================
|
|
@@ -802,51 +837,6 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
802
837
|
hash: txEffect.l2BlockHash.toString()
|
|
803
838
|
};
|
|
804
839
|
}
|
|
805
|
-
/** Loads all transactions from the database, returning loaded txs and deserialization errors */ async #loadAllTxsFromDb() {
|
|
806
|
-
const loaded = [];
|
|
807
|
-
const errors = [];
|
|
808
|
-
for await (const [txHashStr, buffer] of this.#txsDB.entriesAsync()){
|
|
809
|
-
// Skip soft-deleted transactions - they stay in DB but not in indices
|
|
810
|
-
if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
811
|
-
continue;
|
|
812
|
-
}
|
|
813
|
-
try {
|
|
814
|
-
const tx = Tx.fromBuffer(buffer);
|
|
815
|
-
const allowedSetupCalls = await this.#checkAllowedSetupCalls(tx);
|
|
816
|
-
const meta = await buildTxMetaData(tx, allowedSetupCalls);
|
|
817
|
-
loaded.push({
|
|
818
|
-
tx,
|
|
819
|
-
meta
|
|
820
|
-
});
|
|
821
|
-
} catch (err) {
|
|
822
|
-
this.#log.warn(`Failed to deserialize tx ${txHashStr}, deleting`, {
|
|
823
|
-
err
|
|
824
|
-
});
|
|
825
|
-
errors.push(txHashStr);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
return {
|
|
829
|
-
loaded,
|
|
830
|
-
errors
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
/** Queries block source and marks mined status on transaction metadata */ async #markMinedStatusBatch(metas) {
|
|
834
|
-
for (const meta of metas){
|
|
835
|
-
try {
|
|
836
|
-
const txEffect = await this.#l2BlockSource.getTxEffect(TxHash.fromString(meta.txHash));
|
|
837
|
-
if (txEffect) {
|
|
838
|
-
meta.minedL2BlockId = {
|
|
839
|
-
number: txEffect.l2BlockNumber,
|
|
840
|
-
hash: txEffect.l2BlockHash.toString()
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
} catch (err) {
|
|
844
|
-
this.#log.warn(`Failed to check mined status for tx ${meta.txHash}`, {
|
|
845
|
-
err
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
840
|
/**
|
|
851
841
|
* Rebuilds the pending pool by processing each tx through pre-add rules.
|
|
852
842
|
* Starts with an empty pending pool and adds txs one by one, resolving conflicts.
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
|
-
import { type CheckpointAttestation, type P2PValidator, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { type CheckpointAttestation, type CoordinationSignatureContext, type P2PValidator, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
4
4
|
export declare class CheckpointAttestationValidator implements P2PValidator<CheckpointAttestation> {
|
|
5
5
|
protected epochCache: EpochCacheInterface;
|
|
6
6
|
protected logger: Logger;
|
|
7
7
|
private readonly pipeliningWindow;
|
|
8
|
+
protected readonly signatureContext: CoordinationSignatureContext;
|
|
8
9
|
constructor(epochCache: EpochCacheInterface, opts: {
|
|
9
10
|
l1PublishingTime?: number;
|
|
11
|
+
p2pPropagationTime?: number;
|
|
12
|
+
signatureContext: CoordinationSignatureContext;
|
|
10
13
|
});
|
|
11
14
|
validate(message: CheckpointAttestation): Promise<ValidationResult>;
|
|
12
15
|
}
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXR0ZXN0YXRpb25fdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbXNnX3ZhbGlkYXRvcnMvYXR0ZXN0YXRpb25fdmFsaWRhdG9yL2F0dGVzdGF0aW9uX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRTlELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyw0QkFBNEIsRUFDakMsS0FBSyxZQUFZLEVBRWpCLEtBQUssZ0JBQWdCLEVBRXRCLE1BQU0sbUJBQW1CLENBQUM7QUFJM0IscUJBQWEsOEJBQStCLFlBQVcsWUFBWSxDQUFDLHFCQUFxQixDQUFDO0lBQ3hGLFNBQVMsQ0FBQyxVQUFVLEVBQUUsbUJBQW1CLENBQUM7SUFDMUMsU0FBUyxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDekIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBbUI7SUFDcEQsU0FBUyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0IsRUFBRSw0QkFBNEIsQ0FBQztJQUVsRSxZQUNFLFVBQVUsRUFBRSxtQkFBbUIsRUFDL0IsSUFBSSxFQUFFO1FBQ0osZ0JBQWdCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDMUIsa0JBQWtCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDNUIsZ0JBQWdCLEVBQUUsNEJBQTRCLENBQUM7S0FDaEQsRUFTRjtJQUVLLFFBQVEsQ0FBQyxPQUFPLEVBQUUscUJBQXFCLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBNkV4RTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAEjB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EAEtB,MAAM,mBAAmB,CAAC;AAI3B,qBAAa,8BAA+B,YAAW,YAAY,CAAC,qBAAqB,CAAC;IACxF,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAC;IAElE,YACE,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE;QACJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,gBAAgB,EAAE,4BAA4B,CAAC;KAChD,EASF;IAEK,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA6ExE;CACF"}
|
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { PeerErrorSeverity, hasValidSignatureContext } from '@aztec/stdlib/p2p';
|
|
4
4
|
import { PipeliningWindow, isWithinClockTolerance } from '../clock_tolerance.js';
|
|
5
5
|
export class CheckpointAttestationValidator {
|
|
6
6
|
epochCache;
|
|
7
7
|
logger;
|
|
8
8
|
pipeliningWindow;
|
|
9
|
+
signatureContext;
|
|
9
10
|
constructor(epochCache, opts){
|
|
10
11
|
this.epochCache = epochCache;
|
|
11
12
|
this.pipeliningWindow = new PipeliningWindow(epochCache, {
|
|
12
|
-
l1PublishingTime: opts.l1PublishingTime
|
|
13
|
+
l1PublishingTime: opts.l1PublishingTime,
|
|
14
|
+
p2pPropagationTime: opts.p2pPropagationTime
|
|
13
15
|
});
|
|
16
|
+
this.signatureContext = opts.signatureContext;
|
|
14
17
|
this.logger = createLogger('p2p:checkpoint-attestation-validator');
|
|
15
18
|
}
|
|
16
19
|
async validate(message) {
|
|
17
20
|
const slotNumber = message.payload.header.slotNumber;
|
|
18
21
|
try {
|
|
22
|
+
// Cross-chain replay check: reject attestations that carry a foreign signing domain.
|
|
23
|
+
if (!hasValidSignatureContext(message.payload, this.signatureContext)) {
|
|
24
|
+
this.logger.warn(`Rejecting checkpoint attestation with foreign signature context for slot ${slotNumber}`, {
|
|
25
|
+
chainId: message.payload.signatureContext.chainId,
|
|
26
|
+
rollupAddress: message.payload.signatureContext.rollupAddress.toString(),
|
|
27
|
+
expectedChainId: this.signatureContext.chainId,
|
|
28
|
+
expectedRollupAddress: this.signatureContext.rollupAddress.toString()
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
result: 'reject',
|
|
32
|
+
severity: PeerErrorSeverity.LowToleranceError
|
|
33
|
+
};
|
|
34
|
+
}
|
|
19
35
|
// Use target slots since proposals target pipeline slots (slot + 1 when pipelining).
|
|
20
36
|
const { targetSlot, nextSlot } = this.epochCache.getTargetAndNextSlot();
|
|
21
37
|
if (slotNumber !== targetSlot && slotNumber !== nextSlot) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { type CheckpointAttestation, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
2
|
+
import { type CheckpointAttestation, type CoordinationSignatureContext, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import type { AttestationPoolApi } from '../../mem_pools/attestation_pool/attestation_pool.js';
|
|
5
5
|
import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
@@ -14,9 +14,11 @@ import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
|
14
14
|
export declare class FishermanAttestationValidator extends CheckpointAttestationValidator {
|
|
15
15
|
private attestationPool;
|
|
16
16
|
private invalidAttestationCounter;
|
|
17
|
-
constructor(epochCache: EpochCacheInterface, attestationPool: AttestationPoolApi, telemetryClient: TelemetryClient, opts
|
|
17
|
+
constructor(epochCache: EpochCacheInterface, attestationPool: AttestationPoolApi, telemetryClient: TelemetryClient, opts: {
|
|
18
18
|
l1PublishingTime?: number;
|
|
19
|
+
p2pPropagationTime?: number;
|
|
20
|
+
signatureContext: CoordinationSignatureContext;
|
|
19
21
|
});
|
|
20
22
|
validate(message: CheckpointAttestation): Promise<ValidationResult>;
|
|
21
23
|
}
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlzaGVybWFuX2F0dGVzdGF0aW9uX3ZhbGlkYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL21zZ192YWxpZGF0b3JzL2F0dGVzdGF0aW9uX3ZhbGlkYXRvci9maXNoZXJtYW5fYXR0ZXN0YXRpb25fdmFsaWRhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDOUQsT0FBTyxFQUNMLEtBQUsscUJBQXFCLEVBQzFCLEtBQUssNEJBQTRCLEVBRWpDLEtBQUssZ0JBQWdCLEVBQ3RCLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxFQUF1QixLQUFLLGVBQWUsRUFBa0MsTUFBTSx5QkFBeUIsQ0FBQztBQUVwSCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNEQUFzRCxDQUFDO0FBQy9GLE9BQU8sRUFBRSw4QkFBOEIsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBRTVFOzs7Ozs7O0dBT0c7QUFDSCxxQkFBYSw2QkFBOEIsU0FBUSw4QkFBOEI7SUFLN0UsT0FBTyxDQUFDLGVBQWU7SUFKekIsT0FBTyxDQUFDLHlCQUF5QixDQUFDO0lBRWxDLFlBQ0UsVUFBVSxFQUFFLG1CQUFtQixFQUN2QixlQUFlLEVBQUUsa0JBQWtCLEVBQzNDLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLElBQUksRUFBRTtRQUNKLGdCQUFnQixDQUFDLEVBQUUsTUFBTSxDQUFDO1FBQzFCLGtCQUFrQixDQUFDLEVBQUUsTUFBTSxDQUFDO1FBQzVCLGdCQUFnQixFQUFFLDRCQUE0QixDQUFDO0tBQ2hELEVBYUY7SUFFYyxRQUFRLENBQUMsT0FBTyxFQUFFLHFCQUFxQixHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQXFEakY7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fisherman_attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/fisherman_attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"fisherman_attestation_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/attestation_validator/fisherman_attestation_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EAEjC,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAuB,KAAK,eAAe,EAAkC,MAAM,yBAAyB,CAAC;AAEpH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAE5E;;;;;;;GAOG;AACH,qBAAa,6BAA8B,SAAQ,8BAA8B;IAK7E,OAAO,CAAC,eAAe;IAJzB,OAAO,CAAC,yBAAyB,CAAC;IAElC,YACE,UAAU,EAAE,mBAAmB,EACvB,eAAe,EAAE,kBAAkB,EAC3C,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE;QACJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,gBAAgB,EAAE,4BAA4B,CAAC;KAChD,EAaF;IAEc,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqDjF;CACF"}
|
|
@@ -11,7 +11,7 @@ import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
|
11
11
|
*/ export class FishermanAttestationValidator extends CheckpointAttestationValidator {
|
|
12
12
|
attestationPool;
|
|
13
13
|
invalidAttestationCounter;
|
|
14
|
-
constructor(epochCache, attestationPool, telemetryClient, opts
|
|
14
|
+
constructor(epochCache, attestationPool, telemetryClient, opts){
|
|
15
15
|
super(epochCache, opts), this.attestationPool = attestationPool;
|
|
16
16
|
this.logger = this.logger.createChild('[FISHERMAN]');
|
|
17
17
|
const meter = telemetryClient.getMeter('FishermanAttestationValidator');
|
|
@@ -41,8 +41,7 @@ import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
|
41
41
|
result: 'accept'
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
const proposal = await this.attestationPool.getCheckpointProposal(proposalId);
|
|
44
|
+
const proposal = await this.attestationPool.getCheckpointProposal(message.payload.header.slotNumber);
|
|
46
45
|
if (proposal) {
|
|
47
46
|
// Compare the attestation payload with the proposal payload
|
|
48
47
|
if (!message.payload.equals(proposal)) {
|
|
@@ -67,7 +66,7 @@ import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
|
67
66
|
}
|
|
68
67
|
} else {
|
|
69
68
|
// We might receive attestations before proposals in some cases
|
|
70
|
-
this.logger.debug(`Received attestation for slot ${slotNumberBigInt} but proposal not found yet
|
|
69
|
+
this.logger.debug(`Received attestation for slot ${slotNumberBigInt} but proposal not found yet.`);
|
|
71
70
|
}
|
|
72
71
|
return {
|
|
73
72
|
result: 'accept'
|
|
@@ -29,4 +29,4 @@ export declare class PipeliningWindow {
|
|
|
29
29
|
acceptsProposal(messageSlot: SlotNumber): boolean;
|
|
30
30
|
acceptsAttestation(messageSlot: SlotNumber): boolean;
|
|
31
31
|
}
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xvY2tfdG9sZXJhbmNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbXNnX3ZhbGlkYXRvcnMvY2xvY2tfdG9sZXJhbmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDOUQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRzdEOzs7Ozs7O0dBT0c7QUFDSCxlQUFPLE1BQU0saUNBQWlDLE1BQU0sQ0FBQztBQUVyRDs7Ozs7OztHQU9HO0FBQ0gsd0JBQWdCLHNCQUFzQixDQUNwQyxXQUFXLEVBQUUsVUFBVSxFQUN2QixXQUFXLEVBQUUsVUFBVSxFQUN2QixVQUFVLEVBQUUsbUJBQW1CLEdBQzlCLE9BQU8sQ0EwQlQ7QUFzQ0QscUJBQWEsZ0JBQWdCO0lBS3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsVUFBVTtJQUo3QixPQUFPLENBQUMsUUFBUSxDQUFDLDRCQUE0QixDQUFTO0lBQ3RELE9BQU8sQ0FBQyxRQUFRLENBQUMsK0JBQStCLENBQVM7SUFFekQsWUFDbUIsVUFBVSxFQUFFLG1CQUFtQixFQUNoRCxJQUFJLEdBQUU7UUFDSixrQkFBa0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztRQUM1QixnQkFBZ0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztLQUN0QixFQVlQO0lBRU0sZUFBZSxDQUFDLFdBQVcsRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUV2RDtJQUVNLGtCQUFrQixDQUFDLFdBQVcsRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUUxRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock_tolerance.d.ts","sourceRoot":"","sources":["../../src/msg_validators/clock_tolerance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,UAAU,EACvB,WAAW,EAAE,UAAU,EACvB,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CA0BT;
|
|
1
|
+
{"version":3,"file":"clock_tolerance.d.ts","sourceRoot":"","sources":["../../src/msg_validators/clock_tolerance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,UAAU,EACvB,WAAW,EAAE,UAAU,EACvB,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CA0BT;AAsCD,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAS;IACtD,OAAO,CAAC,QAAQ,CAAC,+BAA+B,CAAS;IAEzD,YACmB,UAAU,EAAE,mBAAmB,EAChD,IAAI,GAAE;QACJ,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KACtB,EAYP;IAEM,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAEvD;IAEM,kBAAkB,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAE1D;CACF"}
|
|
@@ -38,21 +38,23 @@ import { DEFAULT_P2P_PROPAGATION_TIME, createPipelinedCheckpointTimingModel } fr
|
|
|
38
38
|
return elapsedMs < MAXIMUM_GOSSIP_CLOCK_DISPARITY_MS;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Checks if a message
|
|
41
|
+
* Checks if a straggler message for the previous target slot should be accepted.
|
|
42
42
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* Proposals and attestations carry the target slot N. Most of the time the receiver is either
|
|
44
|
+
* still in the build slot N-1 (accepted via the main `slotNumber === targetSlot` match) or in the
|
|
45
|
+
* target slot N (accepted again via `targetSlot`). Stragglers that arrive after the receiver has
|
|
46
|
+
* rolled past the target slot fall to this check: accept `messageSlot === slotNow` while we're
|
|
47
|
+
* still within the first `windowSeconds + clock-disparity` of the slot.
|
|
48
|
+
*
|
|
49
|
+
* Under the early-pipelining schedule `windowSeconds` is small (0 for proposals,
|
|
50
|
+
* `2*p2pPropagationTime` for attestations) since the proposer collects everything
|
|
51
|
+
* before the slot boundary.
|
|
47
52
|
*
|
|
48
53
|
* @param messageSlot - The slot number from the received message
|
|
49
|
-
* @param epochCache - EpochCache to get timing
|
|
50
|
-
* @param windowSeconds -
|
|
51
|
-
* @returns true if
|
|
54
|
+
* @param epochCache - EpochCache to get timing state
|
|
55
|
+
* @param windowSeconds - How far into the current slot we still accept previous-target messages
|
|
56
|
+
* @returns true if the message is for the current wallclock slot and we're within the grace period
|
|
52
57
|
*/ function isWithinPipeliningWindow(messageSlot, epochCache, windowSeconds) {
|
|
53
|
-
if (!epochCache.isProposerPipeliningEnabled()) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
58
|
const currentSlot = epochCache.getSlotNow();
|
|
57
59
|
if (messageSlot !== currentSlot) {
|
|
58
60
|
return false;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import type { BlockProposal, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { BlockProposal, CoordinationSignatureContext, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
export declare class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
4
4
|
private proposalValidator;
|
|
5
5
|
constructor(epochCache: EpochCacheInterface, opts: {
|
|
6
6
|
txsPermitted: boolean;
|
|
7
7
|
maxTxsPerBlock?: number;
|
|
8
|
+
maxBlocksPerCheckpoint?: number;
|
|
8
9
|
p2pPropagationTime?: number;
|
|
10
|
+
skipSlotValidation?: boolean;
|
|
11
|
+
signatureContext: CoordinationSignatureContext;
|
|
9
12
|
});
|
|
10
13
|
validate(proposal: BlockProposal): Promise<ValidationResult>;
|
|
11
14
|
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfcHJvcG9zYWxfdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbXNnX3ZhbGlkYXRvcnMvcHJvcG9zYWxfdmFsaWRhdG9yL2Jsb2NrX3Byb3Bvc2FsX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSw0QkFBNEIsRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUlySCxxQkFBYSxzQkFBdUIsWUFBVyxZQUFZLENBQUMsYUFBYSxDQUFDO0lBQ3hFLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBb0I7SUFFN0MsWUFDRSxVQUFVLEVBQUUsbUJBQW1CLEVBQy9CLElBQUksRUFBRTtRQUNKLFlBQVksRUFBRSxPQUFPLENBQUM7UUFDdEIsY0FBYyxDQUFDLEVBQUUsTUFBTSxDQUFDO1FBQ3hCLHNCQUFzQixDQUFDLEVBQUUsTUFBTSxDQUFDO1FBQ2hDLGtCQUFrQixDQUFDLEVBQUUsTUFBTSxDQUFDO1FBQzVCLGtCQUFrQixDQUFDLEVBQUUsT0FBTyxDQUFDO1FBQzdCLGdCQUFnQixFQUFFLDRCQUE0QixDQUFDO0tBQ2hELEVBR0Y7SUFFSyxRQUFRLENBQUMsUUFBUSxFQUFFLGFBQWEsR0FBRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FNakU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/block_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"block_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/block_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrH,qBAAa,sBAAuB,YAAW,YAAY,CAAC,aAAa,CAAC;IACxE,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,YACE,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE;QACJ,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,gBAAgB,EAAE,4BAA4B,CAAC;KAChD,EAGF;IAEK,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMjE;CACF"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import type { CheckpointProposal, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { CheckpointProposal, CoordinationSignatureContext, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
export declare class CheckpointProposalValidator implements P2PValidator<CheckpointProposal> {
|
|
4
4
|
private proposalValidator;
|
|
5
5
|
constructor(epochCache: EpochCacheInterface, opts: {
|
|
6
6
|
txsPermitted: boolean;
|
|
7
7
|
maxTxsPerBlock?: number;
|
|
8
|
+
maxBlocksPerCheckpoint?: number;
|
|
8
9
|
p2pPropagationTime?: number;
|
|
10
|
+
skipSlotValidation?: boolean;
|
|
11
|
+
signatureContext: CoordinationSignatureContext;
|
|
9
12
|
});
|
|
10
13
|
validate(proposal: CheckpointProposal): Promise<ValidationResult>;
|
|
11
14
|
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludF9wcm9wb3NhbF92YWxpZGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tc2dfdmFsaWRhdG9ycy9wcm9wb3NhbF92YWxpZGF0b3IvY2hlY2twb2ludF9wcm9wb3NhbF92YWxpZGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFDVixrQkFBa0IsRUFDbEIsNEJBQTRCLEVBQzVCLFlBQVksRUFDWixnQkFBZ0IsRUFDakIsTUFBTSxtQkFBbUIsQ0FBQztBQUkzQixxQkFBYSwyQkFBNEIsWUFBVyxZQUFZLENBQUMsa0JBQWtCLENBQUM7SUFDbEYsT0FBTyxDQUFDLGlCQUFpQixDQUFvQjtJQUU3QyxZQUNFLFVBQVUsRUFBRSxtQkFBbUIsRUFDL0IsSUFBSSxFQUFFO1FBQ0osWUFBWSxFQUFFLE9BQU8sQ0FBQztRQUN0QixjQUFjLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDeEIsc0JBQXNCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDaEMsa0JBQWtCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDNUIsa0JBQWtCLENBQUMsRUFBRSxPQUFPLENBQUM7UUFDN0IsZ0JBQWdCLEVBQUUsNEJBQTRCLENBQUM7S0FDaEQsRUFHRjtJQUVLLFFBQVEsQ0FBQyxRQUFRLEVBQUUsa0JBQWtCLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBWXRFO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"checkpoint_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EACV,kBAAkB,EAClB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAI3B,qBAAa,2BAA4B,YAAW,YAAY,CAAC,kBAAkB,CAAC;IAClF,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,YACE,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE;QACJ,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,gBAAgB,EAAE,4BAA4B,CAAC;KAChD,EAGF;IAEK,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAYtE;CACF"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { type BlockProposal, type CheckpointProposalCore, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
2
|
+
import { type BlockProposal, type CheckpointProposalCore, type CoordinationSignatureContext, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
/** Validates header-level and tx-level fields of block and checkpoint proposals. */
|
|
4
4
|
export declare class ProposalValidator {
|
|
5
5
|
private epochCache;
|
|
6
6
|
private logger;
|
|
7
7
|
private txsPermitted;
|
|
8
8
|
private maxTxsPerBlock?;
|
|
9
|
+
private maxBlocksPerCheckpoint?;
|
|
9
10
|
private pipeliningWindow;
|
|
11
|
+
private skipSlotValidation;
|
|
12
|
+
private signatureContext;
|
|
10
13
|
constructor(epochCache: EpochCacheInterface, opts: {
|
|
11
14
|
txsPermitted: boolean;
|
|
12
15
|
maxTxsPerBlock?: number;
|
|
16
|
+
maxBlocksPerCheckpoint?: number;
|
|
13
17
|
p2pPropagationTime?: number;
|
|
18
|
+
skipSlotValidation?: boolean;
|
|
19
|
+
signatureContext: CoordinationSignatureContext;
|
|
14
20
|
}, loggerName: string);
|
|
15
21
|
/** Validates header-level fields: slot, signature, and proposer. */
|
|
16
22
|
validate(proposal: BlockProposal | CheckpointProposalCore): Promise<ValidationResult>;
|
|
17
23
|
/** Validates transaction-related fields of a block proposal. */
|
|
18
24
|
validateTxs(proposal: BlockProposal): Promise<ValidationResult>;
|
|
19
25
|
}
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbXNnX3ZhbGlkYXRvcnMvcHJvcG9zYWxfdmFsaWRhdG9yL3Byb3Bvc2FsX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRzlELE9BQU8sRUFDTCxLQUFLLGFBQWEsRUFDbEIsS0FBSyxzQkFBc0IsRUFDM0IsS0FBSyw0QkFBNEIsRUFFakMsS0FBSyxnQkFBZ0IsRUFFdEIsTUFBTSxtQkFBbUIsQ0FBQztBQUkzQixvRkFBb0Y7QUFDcEYscUJBQWEsaUJBQWlCO0lBQzVCLE9BQU8sQ0FBQyxVQUFVLENBQXNCO0lBQ3hDLE9BQU8sQ0FBQyxNQUFNLENBQVM7SUFDdkIsT0FBTyxDQUFDLFlBQVksQ0FBVTtJQUM5QixPQUFPLENBQUMsY0FBYyxDQUFDLENBQVM7SUFDaEMsT0FBTyxDQUFDLHNCQUFzQixDQUFDLENBQVM7SUFDeEMsT0FBTyxDQUFDLGdCQUFnQixDQUFtQjtJQUMzQyxPQUFPLENBQUMsa0JBQWtCLENBQVU7SUFDcEMsT0FBTyxDQUFDLGdCQUFnQixDQUErQjtJQUV2RCxZQUNFLFVBQVUsRUFBRSxtQkFBbUIsRUFDL0IsSUFBSSxFQUFFO1FBQ0osWUFBWSxFQUFFLE9BQU8sQ0FBQztRQUN0QixjQUFjLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDeEIsc0JBQXNCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDaEMsa0JBQWtCLENBQUMsRUFBRSxNQUFNLENBQUM7UUFDNUIsa0JBQWtCLENBQUMsRUFBRSxPQUFPLENBQUM7UUFDN0IsZ0JBQWdCLEVBQUUsNEJBQTRCLENBQUM7S0FDaEQsRUFDRCxVQUFVLEVBQUUsTUFBTSxFQVVuQjtJQUVELG9FQUFvRTtJQUN2RCxRQUFRLENBQUMsUUFBUSxFQUFFLGFBQWEsR0FBRyxzQkFBc0IsR0FBRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FrRWpHO0lBRUQsZ0VBQWdFO0lBQ25ELFdBQVcsQ0FBQyxRQUFRLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQXdDM0U7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EAEjC,KAAK,gBAAgB,EAEtB,MAAM,mBAAmB,CAAC;AAI3B,oFAAoF;AACpF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,sBAAsB,CAAC,CAAS;IACxC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,kBAAkB,CAAU;IACpC,OAAO,CAAC,gBAAgB,CAA+B;IAEvD,YACE,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE;QACJ,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,gBAAgB,EAAE,4BAA4B,CAAC;KAChD,EACD,UAAU,EAAE,MAAM,EAUnB;IAED,oEAAoE;IACvD,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkEjG;IAED,gEAAgE;IACnD,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwC3E;CACF"}
|
|
@@ -1,28 +1,47 @@
|
|
|
1
1
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { PeerErrorSeverity, hasValidSignatureContext } from '@aztec/stdlib/p2p';
|
|
4
4
|
import { PipeliningWindow, isWithinClockTolerance } from '../clock_tolerance.js';
|
|
5
5
|
/** Validates header-level and tx-level fields of block and checkpoint proposals. */ export class ProposalValidator {
|
|
6
6
|
epochCache;
|
|
7
7
|
logger;
|
|
8
8
|
txsPermitted;
|
|
9
9
|
maxTxsPerBlock;
|
|
10
|
+
maxBlocksPerCheckpoint;
|
|
10
11
|
pipeliningWindow;
|
|
12
|
+
skipSlotValidation;
|
|
13
|
+
signatureContext;
|
|
11
14
|
constructor(epochCache, opts, loggerName){
|
|
12
15
|
this.epochCache = epochCache;
|
|
13
16
|
this.txsPermitted = opts.txsPermitted;
|
|
14
17
|
this.maxTxsPerBlock = opts.maxTxsPerBlock;
|
|
18
|
+
this.maxBlocksPerCheckpoint = opts.maxBlocksPerCheckpoint;
|
|
15
19
|
this.pipeliningWindow = new PipeliningWindow(epochCache, {
|
|
16
20
|
p2pPropagationTime: opts.p2pPropagationTime
|
|
17
21
|
});
|
|
22
|
+
this.skipSlotValidation = opts.skipSlotValidation ?? false;
|
|
23
|
+
this.signatureContext = opts.signatureContext;
|
|
18
24
|
this.logger = createLogger(loggerName);
|
|
19
25
|
}
|
|
20
26
|
/** Validates header-level fields: slot, signature, and proposer. */ async validate(proposal) {
|
|
21
27
|
try {
|
|
28
|
+
// Cross-chain replay check: reject proposals that carry a foreign signing domain.
|
|
29
|
+
if (!hasValidSignatureContext(proposal, this.signatureContext)) {
|
|
30
|
+
this.logger.warn(`Penalizing peer for proposal with foreign signature context`, {
|
|
31
|
+
chainId: proposal.signatureContext.chainId,
|
|
32
|
+
rollupAddress: proposal.signatureContext.rollupAddress.toString(),
|
|
33
|
+
expectedChainId: this.signatureContext.chainId,
|
|
34
|
+
expectedRollupAddress: this.signatureContext.rollupAddress.toString()
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
result: 'reject',
|
|
38
|
+
severity: PeerErrorSeverity.LowToleranceError
|
|
39
|
+
};
|
|
40
|
+
}
|
|
22
41
|
// Slot check: use target slots since proposals target pipeline slots (slot + 1 when pipelining).
|
|
23
42
|
const { targetSlot, nextSlot } = this.epochCache.getTargetAndNextSlot();
|
|
24
43
|
const slotNumber = proposal.slotNumber;
|
|
25
|
-
if (slotNumber !== targetSlot && slotNumber !== nextSlot) {
|
|
44
|
+
if (!this.skipSlotValidation && slotNumber !== targetSlot && slotNumber !== nextSlot) {
|
|
26
45
|
// When pipelining, accept proposals for the current slot (built in the previous slot)
|
|
27
46
|
// if they're still within the shared proposal acceptance window.
|
|
28
47
|
if (this.pipeliningWindow.acceptsProposal(slotNumber)) {
|
|
@@ -64,6 +83,13 @@ import { PipeliningWindow, isWithinClockTolerance } from '../clock_tolerance.js'
|
|
|
64
83
|
severity: PeerErrorSeverity.MidToleranceError
|
|
65
84
|
};
|
|
66
85
|
}
|
|
86
|
+
if (this.maxBlocksPerCheckpoint !== undefined && 'indexWithinCheckpoint' in proposal && proposal.indexWithinCheckpoint >= this.maxBlocksPerCheckpoint) {
|
|
87
|
+
this.logger.warn(`Penalizing peer for proposal with indexWithinCheckpoint ${proposal.indexWithinCheckpoint} >= max ${this.maxBlocksPerCheckpoint}`);
|
|
88
|
+
return {
|
|
89
|
+
result: 'reject',
|
|
90
|
+
severity: PeerErrorSeverity.MidToleranceError
|
|
91
|
+
};
|
|
92
|
+
}
|
|
67
93
|
return {
|
|
68
94
|
result: 'accept'
|
|
69
95
|
};
|
|
@@ -4,4 +4,4 @@ export declare class AggregateTxValidator<T> implements TxValidator<T> {
|
|
|
4
4
|
constructor(...validators: TxValidator<T>[]);
|
|
5
5
|
validateTx(tx: T): Promise<TxValidationResult>;
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdncmVnYXRlX3R4X3ZhbGlkYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL21zZ192YWxpZGF0b3JzL3R4X3ZhbGlkYXRvci9hZ2dyZWdhdGVfdHhfdmFsaWRhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXhFLHFCQUFhLG9CQUFvQixDQUFDLENBQUMsQ0FBRSxZQUFXLFdBQVcsQ0FBQyxDQUFDLENBQUM7SUFDNUQsUUFBUSxDQUFDLFVBQVUsRUFBRSxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztJQUN0QyxZQUFZLEdBQUcsVUFBVSxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxFQU0xQztJQUVLLFVBQVUsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQVNuRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate_tx_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/aggregate_tx_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,YAAY,GAAG,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAM1C;IAEK,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"aggregate_tx_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/aggregate_tx_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,YAAY,GAAG,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAM1C;IAEK,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CASnD;CACF"}
|