@aztec/p2p 0.0.1-commit.5de5ca79e → 0.0.1-commit.6201a7b05
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/client/factory.d.ts +3 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +22 -20
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +3 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +30 -10
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -7
- package/dest/config.d.ts +106 -99
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -7
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +8 -5
- 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/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- 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/eviction/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +4 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +13 -6
- 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 +2 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +9 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +34 -10
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -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 +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +57 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +4 -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 +4 -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 +6 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +32 -9
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +2 -2
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -5
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +36 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +50 -33
- package/dest/msg_validators/tx_validator/phases_validator.js +1 -1
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/dummy_service.d.ts +6 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +21 -4
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +20 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +151 -110
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +33 -8
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -1
- 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 +3 -0
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +11 -2
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- 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 +4 -1
- package/dest/test-helpers/mock-pubsub.d.ts +11 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +36 -11
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +5 -3
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +1 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +72 -17
- package/dest/testbench/worker_client_manager.d.ts +8 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +49 -1
- package/package.json +14 -14
- package/src/client/factory.ts +31 -21
- package/src/client/interface.ts +9 -1
- package/src/client/p2p_client.ts +34 -11
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -6
- package/src/config.ts +27 -7
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +9 -5
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/interfaces.ts +3 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +20 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +2 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +38 -7
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +12 -2
- package/src/msg_validators/clock_tolerance.ts +75 -0
- package/src/msg_validators/proposal_validator/README.md +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +15 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +33 -7
- package/src/msg_validators/tx_validator/README.md +11 -3
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +10 -1
- package/src/msg_validators/tx_validator/gas_validator.ts +82 -33
- package/src/msg_validators/tx_validator/phases_validator.ts +1 -1
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +8 -2
- package/src/services/gossipsub/topic_score_params.ts +36 -4
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +155 -117
- package/src/services/peer-manager/peer_manager.ts +38 -8
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +3 -0
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +18 -1
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +2 -0
- package/src/test-helpers/mock-pubsub.ts +34 -5
- package/src/test-helpers/reqresp-nodes.ts +4 -2
- package/src/test-helpers/testbench-utils.ts +1 -0
- package/src/testbench/p2p_client_testbench_worker.ts +73 -12
- package/src/testbench/worker_client_manager.ts +55 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -123
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -402
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -163
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -321
- package/src/services/reqresp/protocols/block.ts +0 -37
package/src/client/factory.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
7
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
8
8
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
|
+
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
|
|
10
11
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
12
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
12
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -19,6 +20,7 @@ import type { TxPoolV2 } from '../mem_pools/tx_pool_v2/interfaces.js';
|
|
|
19
20
|
import { AztecKVTxPoolV2 } from '../mem_pools/tx_pool_v2/tx_pool_v2.js';
|
|
20
21
|
import {
|
|
21
22
|
createCheckAllowedSetupCalls,
|
|
23
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
22
24
|
createTxValidatorForTransactionsEnteringPendingTxPool,
|
|
23
25
|
getDefaultAllowedSetupFunctions,
|
|
24
26
|
} from '../msg_validators/index.js';
|
|
@@ -51,6 +53,7 @@ export async function createP2PClient(
|
|
|
51
53
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
52
54
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
53
55
|
epochCache: EpochCacheInterface,
|
|
56
|
+
blockMinFeesProvider: BlockMinFeesProvider,
|
|
54
57
|
packageVersion: string,
|
|
55
58
|
dateProvider: DateProvider = new DateProvider(),
|
|
56
59
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
@@ -73,7 +76,7 @@ export async function createP2PClient(
|
|
|
73
76
|
const store = deps.store ?? (await createStore(P2P_STORE_NAME, 2, config, bindings));
|
|
74
77
|
const archive = await createStore(P2P_ARCHIVE_STORE_NAME, 1, config, bindings);
|
|
75
78
|
const peerStore = await createStore(P2P_PEER_STORE_NAME, 1, config, bindings);
|
|
76
|
-
const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME,
|
|
79
|
+
const attestationStore = await createStore(P2P_ATTESTATION_STORE_NAME, 2, config, bindings);
|
|
77
80
|
const l1Constants = await archiver.getL1Constants();
|
|
78
81
|
|
|
79
82
|
const rollupAddress = inputConfig.l1Contracts.rollupAddress.toString().toLowerCase().replace(/^0x/, '');
|
|
@@ -89,23 +92,6 @@ export async function createP2PClient(
|
|
|
89
92
|
() => epochCache.getEpochAndSlotInNextL1Slot().ts,
|
|
90
93
|
);
|
|
91
94
|
|
|
92
|
-
const createTxValidator = async () => {
|
|
93
|
-
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
94
|
-
const currentBlockNumber = await archiver.getBlockNumber();
|
|
95
|
-
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
96
|
-
const l1Constants = await archiver.getL1Constants();
|
|
97
|
-
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
98
|
-
worldStateSynchronizer,
|
|
99
|
-
nextSlotTimestamp,
|
|
100
|
-
BlockNumber(currentBlockNumber + 1),
|
|
101
|
-
{
|
|
102
|
-
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
103
|
-
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
104
|
-
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
105
|
-
},
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
95
|
const txPool =
|
|
110
96
|
deps.txPool ??
|
|
111
97
|
new AztecKVTxPoolV2(
|
|
@@ -115,7 +101,24 @@ export async function createP2PClient(
|
|
|
115
101
|
l2BlockSource: archiver,
|
|
116
102
|
worldStateSynchronizer,
|
|
117
103
|
checkAllowedSetupCalls,
|
|
118
|
-
createTxValidator
|
|
104
|
+
createTxValidator: async () => {
|
|
105
|
+
const currentBlockNumber = await archiver.getBlockNumber();
|
|
106
|
+
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
107
|
+
const l1Constants = await archiver.getL1Constants();
|
|
108
|
+
const gasFees = await blockMinFeesProvider.getCurrentMinFees();
|
|
109
|
+
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
110
|
+
worldStateSynchronizer,
|
|
111
|
+
nextSlotTimestamp,
|
|
112
|
+
BlockNumber(currentBlockNumber + 1),
|
|
113
|
+
{
|
|
114
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
115
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
116
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
117
|
+
},
|
|
118
|
+
gasFees,
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
blockMinFeesProvider,
|
|
119
122
|
},
|
|
120
123
|
telemetry,
|
|
121
124
|
{
|
|
@@ -139,6 +142,7 @@ export async function createP2PClient(
|
|
|
139
142
|
proofVerifier,
|
|
140
143
|
worldStateSynchronizer,
|
|
141
144
|
epochCache,
|
|
145
|
+
blockMinFeesProvider,
|
|
142
146
|
store,
|
|
143
147
|
peerStore,
|
|
144
148
|
mempools,
|
|
@@ -148,9 +152,12 @@ export async function createP2PClient(
|
|
|
148
152
|
telemetry,
|
|
149
153
|
);
|
|
150
154
|
|
|
155
|
+
const txValidatorForTxCollection = createTxValidatorForReqResponseReceivedTxs(proofVerifier, config);
|
|
151
156
|
const nodeSources = [
|
|
152
|
-
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, config),
|
|
153
|
-
...(deps.rpcTxProviders ?? []).map(
|
|
157
|
+
...createNodeRpcTxSources(config.txCollectionNodeRpcUrls, txValidatorForTxCollection, config),
|
|
158
|
+
...(deps.rpcTxProviders ?? []).map(
|
|
159
|
+
(node, i) => new NodeRpcTxSource(node, txValidatorForTxCollection, `node-rpc-provider-${i}`),
|
|
160
|
+
),
|
|
154
161
|
...(deps.txCollectionNodeSources ?? []),
|
|
155
162
|
];
|
|
156
163
|
if (nodeSources.length > 0) {
|
|
@@ -162,6 +169,7 @@ export async function createP2PClient(
|
|
|
162
169
|
const fileStoreSources = await createFileStoreTxSources(
|
|
163
170
|
config.txCollectionFileStoreUrls,
|
|
164
171
|
txFileStoreBasePath,
|
|
172
|
+
txValidatorForTxCollection,
|
|
165
173
|
logger.createChild('file-store-tx-source'),
|
|
166
174
|
telemetry,
|
|
167
175
|
);
|
|
@@ -211,6 +219,7 @@ async function createP2PService(
|
|
|
211
219
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
212
220
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
213
221
|
epochCache: EpochCacheInterface,
|
|
222
|
+
blockMinFeesProvider: BlockMinFeesProvider,
|
|
214
223
|
store: AztecAsyncKVStore,
|
|
215
224
|
peerStore: AztecLMDBStoreV2,
|
|
216
225
|
mempools: MemPools,
|
|
@@ -238,6 +247,7 @@ async function createP2PService(
|
|
|
238
247
|
proofVerifier,
|
|
239
248
|
worldStateSynchronizer,
|
|
240
249
|
peerStore,
|
|
250
|
+
blockMinFeesProvider,
|
|
241
251
|
telemetry,
|
|
242
252
|
logger: logger.createChild(`libp2p_service`),
|
|
243
253
|
});
|
package/src/client/interface.ts
CHANGED
|
@@ -82,7 +82,15 @@ export type P2P = P2PClient & {
|
|
|
82
82
|
*
|
|
83
83
|
* @param handler - A function taking a received checkpoint proposal and producing attestations
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
registerValidatorCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Registers a callback that runs for ALL nodes (not just validators) when a checkpoint proposal is received.
|
|
89
|
+
* Used to set the proposed checkpoint number on the archiver so the sequencer can build on top of it.
|
|
90
|
+
*
|
|
91
|
+
* @param handler - A function taking a received checkpoint proposal
|
|
92
|
+
*/
|
|
93
|
+
registerAllNodesCheckpointProposalHandler(callback: P2PCheckpointReceivedCallback): void;
|
|
86
94
|
|
|
87
95
|
/**
|
|
88
96
|
* Registers a callback invoked when a duplicate proposal is detected (equivocation).
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
3
2
|
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -9,6 +8,7 @@ import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
|
9
8
|
import {
|
|
10
9
|
type CheckpointId,
|
|
11
10
|
type EthAddress,
|
|
11
|
+
GENESIS_BLOCK_HEADER_HASH,
|
|
12
12
|
type L2Block,
|
|
13
13
|
type L2BlockId,
|
|
14
14
|
type L2BlockSource,
|
|
@@ -257,7 +257,11 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
// Should never happen: all branches above call initBlockStream()
|
|
261
|
+
if (!this.blockStream) {
|
|
262
|
+
throw new Error('Block stream not initialized');
|
|
263
|
+
}
|
|
264
|
+
this.blockStream.start();
|
|
261
265
|
await this.txCollection.start();
|
|
262
266
|
this.txFileStore?.start();
|
|
263
267
|
|
|
@@ -319,7 +323,11 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
319
323
|
/** Triggers a sync to the archiver. Used for testing. */
|
|
320
324
|
public async sync() {
|
|
321
325
|
this.initBlockStream();
|
|
322
|
-
|
|
326
|
+
// Should never happen: initBlockStream() creates blockStream if absent
|
|
327
|
+
if (!this.blockStream) {
|
|
328
|
+
throw new Error('Block stream not initialized');
|
|
329
|
+
}
|
|
330
|
+
await this.blockStream.sync();
|
|
323
331
|
}
|
|
324
332
|
|
|
325
333
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
@@ -357,6 +365,8 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
357
365
|
// Store our own last-block proposal so we can respond to req/resp requests for it.
|
|
358
366
|
await this.attestationPool.tryAddBlockProposal(blockProposal);
|
|
359
367
|
}
|
|
368
|
+
// Gossipsub doesn't deliver own messages, so fire the all-nodes handler locally
|
|
369
|
+
await this.p2pService.notifyOwnCheckpointProposal(proposal.toCore());
|
|
360
370
|
return this.p2pService.propagate(proposal);
|
|
361
371
|
}
|
|
362
372
|
|
|
@@ -388,8 +398,12 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
388
398
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
389
399
|
}
|
|
390
400
|
|
|
391
|
-
public
|
|
392
|
-
this.p2pService.
|
|
401
|
+
public registerValidatorCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
402
|
+
this.p2pService.registerValidatorCheckpointReceivedCallback(handler);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public registerAllNodesCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
406
|
+
this.p2pService.registerAllNodesCheckpointReceivedCallback(handler);
|
|
393
407
|
}
|
|
394
408
|
|
|
395
409
|
public registerDuplicateProposalCallback(callback: (info: DuplicateProposalInfo) => void): void {
|
|
@@ -696,14 +710,23 @@ export class P2PClient extends WithTracer implements P2P {
|
|
|
696
710
|
|
|
697
711
|
/** Checks if the slot has changed and calls prepareForSlot if so. */
|
|
698
712
|
private async maybeCallPrepareForSlot(): Promise<void> {
|
|
699
|
-
// If we have a
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
|
|
713
|
+
// If we have a proposed checkpoint available, we want to prepare the target slot - otherwise we prepare the current slot
|
|
714
|
+
const l2Tips = await this.l2Tips.getL2Tips();
|
|
715
|
+
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
716
|
+
|
|
717
|
+
let slot;
|
|
718
|
+
if (this.epochCache.isProposerPipeliningEnabled() && hasProposedCheckpoint) {
|
|
719
|
+
const { targetSlot } = this.epochCache.getTargetAndNextSlot();
|
|
720
|
+
slot = targetSlot;
|
|
721
|
+
} else {
|
|
722
|
+
const { currentSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
723
|
+
slot = currentSlot;
|
|
724
|
+
}
|
|
725
|
+
if (slot <= this.lastSlotProcessed) {
|
|
703
726
|
return;
|
|
704
727
|
}
|
|
705
|
-
this.lastSlotProcessed =
|
|
706
|
-
await this.txPool.prepareForSlot(
|
|
728
|
+
this.lastSlotProcessed = slot;
|
|
729
|
+
await this.txPool.prepareForSlot(slot);
|
|
707
730
|
}
|
|
708
731
|
|
|
709
732
|
private async startServiceIfSynched() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MockL2BlockSource } from '@aztec/archiver/test';
|
|
2
|
-
import type { EpochCache } from '@aztec/epoch-cache';
|
|
3
2
|
import { SecretValue } from '@aztec/foundation/config';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
@@ -7,6 +6,7 @@ import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
|
7
6
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
9
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
10
10
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
11
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
12
12
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
@@ -15,7 +15,6 @@ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-clien
|
|
|
15
15
|
|
|
16
16
|
import type { PeerId } from '@libp2p/interface';
|
|
17
17
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
18
|
-
import { mock } from 'jest-mock-extended';
|
|
19
18
|
|
|
20
19
|
import type { P2PConfig } from '../../../config.js';
|
|
21
20
|
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
@@ -29,6 +28,7 @@ import {
|
|
|
29
28
|
InMemoryTxPool,
|
|
30
29
|
UNLIMITED_RATE_LIMIT_QUOTA,
|
|
31
30
|
calculateInternalTimeout,
|
|
31
|
+
createMockEpochCache,
|
|
32
32
|
createMockWorldStateSynchronizer,
|
|
33
33
|
} from '../../../test-helpers/index.js';
|
|
34
34
|
import { createP2PClient } from '../../index.js';
|
|
@@ -99,7 +99,7 @@ function sendMessage(message: WorkerResponse): Promise<void> {
|
|
|
99
99
|
async function startClient(config: P2PConfig, clientIndex: number) {
|
|
100
100
|
txPool = new InMemoryTxPool();
|
|
101
101
|
attestationPool = new InMemoryAttestationPool();
|
|
102
|
-
const epochCache =
|
|
102
|
+
const epochCache = createMockEpochCache();
|
|
103
103
|
const worldState = createMockWorldStateSynchronizer();
|
|
104
104
|
const l2BlockSource = new MockL2BlockSource();
|
|
105
105
|
const proofVerifier = new AlwaysTrueCircuitVerifier();
|
|
@@ -120,6 +120,7 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
120
120
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
121
121
|
worldState,
|
|
122
122
|
epochCache,
|
|
123
|
+
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
|
|
123
124
|
'proposal-tx-collector-bench-worker',
|
|
124
125
|
new DateProvider(),
|
|
125
126
|
telemetry as TelemetryClient,
|
|
@@ -260,9 +261,20 @@ async function stopClient() {
|
|
|
260
261
|
attestationPool = undefined;
|
|
261
262
|
}
|
|
262
263
|
|
|
264
|
+
function gracefulExit(code: number = 0) {
|
|
265
|
+
try {
|
|
266
|
+
if (process.connected) {
|
|
267
|
+
process.disconnect();
|
|
268
|
+
}
|
|
269
|
+
} catch {
|
|
270
|
+
// IPC channel already closed
|
|
271
|
+
}
|
|
272
|
+
setTimeout(() => process.exit(code), 5000).unref();
|
|
273
|
+
}
|
|
274
|
+
|
|
263
275
|
process.on('disconnect', () => {
|
|
264
276
|
ipcDisconnected = true;
|
|
265
|
-
void stopClient()
|
|
277
|
+
void stopClient();
|
|
266
278
|
});
|
|
267
279
|
|
|
268
280
|
process.on('error', err => {
|
|
@@ -326,7 +338,7 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
326
338
|
case 'STOP': {
|
|
327
339
|
await stopClient();
|
|
328
340
|
await sendMessage({ type: 'STOPPED', requestId });
|
|
329
|
-
|
|
341
|
+
gracefulExit(0);
|
|
330
342
|
break;
|
|
331
343
|
}
|
|
332
344
|
default: {
|
|
@@ -337,7 +349,8 @@ process.on('message', (msg: WorkerCommand) => {
|
|
|
337
349
|
} catch (err: any) {
|
|
338
350
|
await sendMessage({ type: 'ERROR', requestId, error: err?.message ?? String(err) });
|
|
339
351
|
if (msg.type === 'START') {
|
|
340
|
-
|
|
352
|
+
await stopClient();
|
|
353
|
+
gracefulExit(1);
|
|
341
354
|
}
|
|
342
355
|
}
|
|
343
356
|
})();
|
package/src/config.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getConfigFromMappings,
|
|
7
7
|
getDefaultConfig,
|
|
8
8
|
numberConfigHelper,
|
|
9
|
+
optionalNumberConfigHelper,
|
|
9
10
|
percentageConfigHelper,
|
|
10
11
|
pickConfigMappings,
|
|
11
12
|
secretStringConfigHelper,
|
|
@@ -39,7 +40,14 @@ export interface P2PConfig
|
|
|
39
40
|
ChainConfig,
|
|
40
41
|
TxCollectionConfig,
|
|
41
42
|
TxFileStoreConfig,
|
|
42
|
-
Pick<
|
|
43
|
+
Pick<
|
|
44
|
+
SequencerConfig,
|
|
45
|
+
| 'blockDurationMs'
|
|
46
|
+
| 'expectedBlockProposalsPerSlot'
|
|
47
|
+
| 'l1PublishingTime'
|
|
48
|
+
| 'maxTxsPerBlock'
|
|
49
|
+
| 'attestationPropagationTime'
|
|
50
|
+
> {
|
|
43
51
|
/** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
|
|
44
52
|
validateMaxTxsPerBlock?: number;
|
|
45
53
|
|
|
@@ -209,6 +217,9 @@ export interface P2PConfig
|
|
|
209
217
|
|
|
210
218
|
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
211
219
|
priceBumpPercentage: bigint;
|
|
220
|
+
|
|
221
|
+
/** Drop incoming block and checkpoint proposals at the libp2p dispatch layer (for testing only) */
|
|
222
|
+
skipIncomingProposals?: boolean;
|
|
212
223
|
}
|
|
213
224
|
|
|
214
225
|
export const DEFAULT_P2P_PORT = 40400;
|
|
@@ -218,23 +229,23 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
218
229
|
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
219
230
|
description:
|
|
220
231
|
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
221
|
-
|
|
232
|
+
...optionalNumberConfigHelper(),
|
|
222
233
|
},
|
|
223
234
|
validateMaxTxsPerCheckpoint: {
|
|
224
235
|
env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
|
|
225
236
|
description:
|
|
226
237
|
'Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set.',
|
|
227
|
-
|
|
238
|
+
...optionalNumberConfigHelper(),
|
|
228
239
|
},
|
|
229
240
|
validateMaxL2BlockGas: {
|
|
230
241
|
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
231
242
|
description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
232
|
-
|
|
243
|
+
...optionalNumberConfigHelper(),
|
|
233
244
|
},
|
|
234
245
|
validateMaxDABlockGas: {
|
|
235
246
|
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
236
247
|
description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
237
|
-
|
|
248
|
+
...optionalNumberConfigHelper(),
|
|
238
249
|
},
|
|
239
250
|
p2pEnabled: {
|
|
240
251
|
env: 'P2P_ENABLED',
|
|
@@ -364,7 +375,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
364
375
|
gossipsubMcacheLength: {
|
|
365
376
|
env: 'P2P_GOSSIPSUB_MCACHE_LENGTH',
|
|
366
377
|
description: 'The number of gossipsub interval message cache windows to keep.',
|
|
367
|
-
...numberConfigHelper(
|
|
378
|
+
...numberConfigHelper(12),
|
|
368
379
|
},
|
|
369
380
|
gossipsubMcacheGossip: {
|
|
370
381
|
env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
|
|
@@ -436,7 +447,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
436
447
|
},
|
|
437
448
|
p2pStoreMapSizeKb: {
|
|
438
449
|
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
439
|
-
|
|
450
|
+
...optionalNumberConfigHelper(),
|
|
440
451
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
441
452
|
},
|
|
442
453
|
txPublicSetupAllowListExtend: {
|
|
@@ -495,6 +506,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
495
506
|
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
496
507
|
...booleanConfigHelper(false),
|
|
497
508
|
},
|
|
509
|
+
l1PublishingTime: {
|
|
510
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
511
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
512
|
+
...optionalNumberConfigHelper(),
|
|
513
|
+
},
|
|
498
514
|
fishermanMode: {
|
|
499
515
|
env: 'FISHERMAN_MODE',
|
|
500
516
|
description:
|
|
@@ -506,6 +522,10 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
506
522
|
'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
|
|
507
523
|
...booleanConfigHelper(false),
|
|
508
524
|
},
|
|
525
|
+
skipIncomingProposals: {
|
|
526
|
+
description: 'Drop incoming block and checkpoint proposals at the libp2p dispatch layer (for testing only)',
|
|
527
|
+
...booleanConfigHelper(false),
|
|
528
|
+
},
|
|
509
529
|
minTxPoolAgeMs: {
|
|
510
530
|
env: 'P2P_MIN_TX_POOL_AGE_MS',
|
|
511
531
|
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Checkpoint Proposal Received Callback Not Registered Error
|
|
2
|
+
*
|
|
3
|
+
* Error triggered if the allNodesCheckpointReceivedCallback is not registered
|
|
4
|
+
* @category Errors
|
|
5
|
+
*/
|
|
6
|
+
export class CheckpointProposalReceivedCallbackNotRegisteredError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('FATAL (allNodesCheckpointReceivedCallback): All nodes should register a checkpoint proposal handler');
|
|
9
|
+
this.name = 'CheckpointProposalReceivedCallbackNotRegisteredError';
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './client/index.js';
|
|
|
6
6
|
export * from './enr/index.js';
|
|
7
7
|
export * from './config.js';
|
|
8
8
|
export * from './mem_pools/attestation_pool/index.js';
|
|
9
|
-
export * from './mem_pools/tx_pool/index.js';
|
|
10
9
|
export * from './mem_pools/tx_pool_v2/index.js';
|
|
11
10
|
export * from './msg_validators/index.js';
|
|
12
11
|
export * from './services/index.js';
|
|
@@ -154,14 +154,16 @@ export class AttestationPool {
|
|
|
154
154
|
/** Maximum indexWithinCheckpoint value (2^10 - 1 = 1023). */
|
|
155
155
|
private static readonly MAX_INDEX = (1 << AttestationPool.INDEX_BITS) - 1;
|
|
156
156
|
|
|
157
|
-
/** Creates a position key for block proposals:
|
|
157
|
+
/** Creates a position key for block proposals: slot * 1024 + indexWithinCheckpoint.
|
|
158
|
+
* Uses multiplication instead of bit-shift to avoid 32-bit signed integer overflow
|
|
159
|
+
* (bit-shift overflows after slot ~2^21, roughly 278 days of uptime). */
|
|
158
160
|
private getBlockPositionKey(slot: number, indexWithinCheckpoint: number): number {
|
|
159
161
|
if (indexWithinCheckpoint > AttestationPool.MAX_INDEX) {
|
|
160
162
|
throw new Error(
|
|
161
163
|
`Value for indexWithinCheckpoint ${indexWithinCheckpoint} exceeds maximum ${AttestationPool.MAX_INDEX}`,
|
|
162
164
|
);
|
|
163
165
|
}
|
|
164
|
-
return
|
|
166
|
+
return slot * (1 << AttestationPool.INDEX_BITS) + indexWithinCheckpoint;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
/**
|
|
@@ -278,7 +280,7 @@ export class AttestationPool {
|
|
|
278
280
|
* @returns Result indicating whether the proposal was added and duplicate detection info
|
|
279
281
|
*/
|
|
280
282
|
public async tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
|
|
281
|
-
|
|
283
|
+
const result = await this.store.transactionAsync(async () => {
|
|
282
284
|
const proposalId = proposal.archive.toString();
|
|
283
285
|
|
|
284
286
|
// Check if already exists
|
|
@@ -304,6 +306,8 @@ export class AttestationPool {
|
|
|
304
306
|
|
|
305
307
|
return { added: true, alreadyExists: false, count: count + 1 };
|
|
306
308
|
});
|
|
309
|
+
|
|
310
|
+
return result;
|
|
307
311
|
}
|
|
308
312
|
|
|
309
313
|
/** Internal method - must be called within a transaction. */
|
|
@@ -345,7 +349,7 @@ export class AttestationPool {
|
|
|
345
349
|
await this.store.transactionAsync(async () => {
|
|
346
350
|
for (const attestation of attestations) {
|
|
347
351
|
const slotNumber = attestation.payload.header.slotNumber;
|
|
348
|
-
const proposalId = attestation.archive;
|
|
352
|
+
const proposalId = attestation.archive.toString();
|
|
349
353
|
const sender = attestation.getSender();
|
|
350
354
|
|
|
351
355
|
// Skip attestations with invalid signatures
|
|
@@ -452,7 +456,7 @@ export class AttestationPool {
|
|
|
452
456
|
|
|
453
457
|
// Delete block proposals for slots < oldestSlot, using blockProposalsForSlotAndIndex as index
|
|
454
458
|
// Key format: (slot << INDEX_BITS) | indexWithinCheckpoint
|
|
455
|
-
const blockPositionEndKey = oldestSlot << AttestationPool.INDEX_BITS;
|
|
459
|
+
const blockPositionEndKey = oldestSlot * (1 << AttestationPool.INDEX_BITS);
|
|
456
460
|
for await (const positionKey of this.blockProposalsForSlotAndIndex.keysAsync({ end: blockPositionEndKey })) {
|
|
457
461
|
const proposalIds = await toArray(this.blockProposalsForSlotAndIndex.getValuesAsync(positionKey));
|
|
458
462
|
for (const proposalId of proposalIds) {
|
|
@@ -3,11 +3,12 @@ import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer'
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import {
|
|
5
5
|
CheckpointAttestation,
|
|
6
|
+
CheckpointProposal,
|
|
6
7
|
ConsensusPayload,
|
|
7
|
-
|
|
8
|
-
getHashedSignaturePayloadEthSignedMessage,
|
|
8
|
+
getHashedSignaturePayloadTypedData,
|
|
9
9
|
} from '@aztec/stdlib/p2p';
|
|
10
10
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
11
|
+
import { TEST_COORDINATION_SIGNATURE_CONTEXT } from '@aztec/stdlib/testing';
|
|
11
12
|
|
|
12
13
|
import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
13
14
|
|
|
@@ -37,15 +38,19 @@ export const mockCheckpointAttestation = (
|
|
|
37
38
|
feeAssetPriceModifier: bigint = 0n,
|
|
38
39
|
): CheckpointAttestation => {
|
|
39
40
|
header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
|
|
40
|
-
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
|
|
41
|
+
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier, TEST_COORDINATION_SIGNATURE_CONTEXT);
|
|
41
42
|
|
|
42
|
-
const attestationHash =
|
|
43
|
-
payload,
|
|
44
|
-
SignatureDomainSeparator.checkpointAttestation,
|
|
45
|
-
);
|
|
43
|
+
const attestationHash = getHashedSignaturePayloadTypedData(payload);
|
|
46
44
|
const attestationSignature = signer.sign(attestationHash);
|
|
47
45
|
|
|
48
|
-
const
|
|
46
|
+
const proposal = new CheckpointProposal(
|
|
47
|
+
header,
|
|
48
|
+
archive,
|
|
49
|
+
feeAssetPriceModifier,
|
|
50
|
+
attestationSignature,
|
|
51
|
+
TEST_COORDINATION_SIGNATURE_CONTEXT,
|
|
52
|
+
);
|
|
53
|
+
const proposalHash = getHashedSignaturePayloadTypedData(proposal);
|
|
49
54
|
const proposerSignature = signer.sign(proposalHash);
|
|
50
55
|
|
|
51
56
|
return new CheckpointAttestation(payload, attestationSignature, proposerSignature);
|
package/src/mem_pools/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
|
-
// Old TxPool exports - kept temporarily for external consumers
|
|
4
|
-
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
5
|
-
// New TxPoolV2 exports
|
|
6
3
|
export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
|
|
@@ -100,7 +100,11 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
100
100
|
|
|
101
101
|
this.addObjectCounter = createUpDownCounterWithDefault(this.meter, metricsLabels.itemsAdded);
|
|
102
102
|
|
|
103
|
-
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay
|
|
103
|
+
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay, {
|
|
104
|
+
advice: {
|
|
105
|
+
explicitBucketBoundaries: [100, 500, 1000, 5000, 10000, 30000, 60000, 300000, 600000, 1800000, 3600000],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
104
108
|
|
|
105
109
|
this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
|
|
106
110
|
}
|
|
@@ -21,6 +21,7 @@ export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
|
|
|
21
21
|
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';
|
|
22
22
|
|
|
23
23
|
// Post-event eviction rules
|
|
24
|
+
export { InsufficientFeePerGasEvictionRule } from './insufficient_fee_per_gas_eviction_rule.js';
|
|
24
25
|
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
|
|
25
26
|
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
|
|
26
27
|
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
|
|
3
|
+
|
|
4
|
+
import type { EvictionContext, EvictionResult, EvictionRule, PoolOperations } from './interfaces.js';
|
|
5
|
+
import { EvictionEvent } from './interfaces.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Eviction rule that removes transactions whose maxFeesPerGas no longer meets
|
|
9
|
+
* the projected minimum gas fees after a new block is mined.
|
|
10
|
+
* Uses the BlockMinFeesProvider (forward-looking) to get the projected minimum fees.
|
|
11
|
+
* Only triggers on BLOCK_MINED events.
|
|
12
|
+
*/
|
|
13
|
+
export class InsufficientFeePerGasEvictionRule implements EvictionRule {
|
|
14
|
+
public readonly name = 'InsufficientFeePerGas';
|
|
15
|
+
|
|
16
|
+
private log = createLogger('p2p:tx_pool_v2:insufficient_fee_per_gas_eviction_rule');
|
|
17
|
+
|
|
18
|
+
constructor(private blockMinFeesProvider: BlockMinFeesProvider) {}
|
|
19
|
+
|
|
20
|
+
async evict(context: EvictionContext, pool: PoolOperations): Promise<EvictionResult> {
|
|
21
|
+
if (context.event !== EvictionEvent.BLOCK_MINED) {
|
|
22
|
+
return {
|
|
23
|
+
reason: 'insufficient_fee_per_gas',
|
|
24
|
+
success: true,
|
|
25
|
+
txsEvicted: [],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const gasFees = await this.blockMinFeesProvider.getCurrentMinFees();
|
|
31
|
+
const txsToEvict: string[] = [];
|
|
32
|
+
const pendingTxs = pool.getPendingTxs();
|
|
33
|
+
|
|
34
|
+
for (const meta of pendingTxs) {
|
|
35
|
+
const maxFeesPerGas = meta.data.constants.txContext.gasSettings.maxFeesPerGas;
|
|
36
|
+
if (maxFeesPerGas.feePerDaGas < gasFees.feePerDaGas || maxFeesPerGas.feePerL2Gas < gasFees.feePerL2Gas) {
|
|
37
|
+
this.log.verbose(`Evicting tx ${meta.txHash} from pool due to insufficient fee per gas`, {
|
|
38
|
+
txMaxFeesPerGas: maxFeesPerGas.toInspect(),
|
|
39
|
+
blockGasFees: gasFees.toInspect(),
|
|
40
|
+
});
|
|
41
|
+
txsToEvict.push(meta.txHash);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (txsToEvict.length > 0) {
|
|
46
|
+
this.log.info(`Evicted ${txsToEvict.length} txs with insufficient fee per gas after block mined`);
|
|
47
|
+
await pool.deleteTxs(txsToEvict, this.name);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
reason: 'insufficient_fee_per_gas',
|
|
52
|
+
success: true,
|
|
53
|
+
txsEvicted: txsToEvict,
|
|
54
|
+
};
|
|
55
|
+
} catch (err) {
|
|
56
|
+
this.log.error('Failed to evict transactions with insufficient fee per gas', { err });
|
|
57
|
+
return {
|
|
58
|
+
reason: 'insufficient_fee_per_gas',
|
|
59
|
+
success: false,
|
|
60
|
+
txsEvicted: [],
|
|
61
|
+
error: new Error('Failed to evict txs with insufficient fee per gas', { cause: err }),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
3
3
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
5
|
|
|
@@ -33,14 +33,14 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
|
|
|
33
33
|
const pendingTxs = pool.getPendingTxs();
|
|
34
34
|
|
|
35
35
|
// Deduplicate block hashes to reduce redundant DB lookups
|
|
36
|
-
const uniqueBlockHashes = new Map<string,
|
|
36
|
+
const uniqueBlockHashes = new Map<string, BlockHash>();
|
|
37
37
|
const txsByBlockHash = new Map<string, string[]>();
|
|
38
38
|
|
|
39
39
|
for (const meta of pendingTxs) {
|
|
40
40
|
const blockHashStr = meta.anchorBlockHeaderHash;
|
|
41
41
|
if (!txsByBlockHash.has(blockHashStr)) {
|
|
42
42
|
txsByBlockHash.set(blockHashStr, []);
|
|
43
|
-
uniqueBlockHashes.set(blockHashStr,
|
|
43
|
+
uniqueBlockHashes.set(blockHashStr, BlockHash.fromString(blockHashStr));
|
|
44
44
|
}
|
|
45
45
|
txsByBlockHash.get(blockHashStr)!.push(meta.txHash);
|
|
46
46
|
}
|