@aztec/p2p 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/interface.d.ts +18 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +10 -13
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +449 -118
- package/dest/config.js +2 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +61 -42
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- 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 +237 -263
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -18
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +113 -108
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +17 -16
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +89 -128
- package/dest/mem_pools/attestation_pool/mocks.d.ts +9 -6
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +16 -12
- 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 +4 -13
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +15 -10
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +91 -50
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +19 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +59 -3
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +79 -5
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +47 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +122 -0
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +25 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +57 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +51 -18
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -14
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/index.d.ts +2 -2
- package/dest/msg_validators/index.d.ts.map +1 -1
- package/dest/msg_validators/index.js +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +9 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +6 -0
- package/dest/msg_validators/proposal_validator/index.d.ts +4 -0
- package/dest/msg_validators/proposal_validator/index.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/index.js +3 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.js +104 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +23 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -0
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +212 -0
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- 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/fee_payer_balance.d.ts +10 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +20 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +8 -14
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/size_validator.d.ts +6 -0
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/size_validator.js +20 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/services/dummy_service.d.ts +6 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +3 -0
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +6 -5
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +20 -73
- package/dest/services/libp2p/libp2p_service.d.ts +28 -11
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +711 -152
- package/dest/services/peer-manager/metrics.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -26
- package/dest/services/peer-manager/peer_manager.d.ts +2 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +0 -10
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +2 -5
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/constants.d.ts +12 -0
- package/dest/services/reqresp/constants.d.ts.map +1 -0
- package/dest/services/reqresp/constants.js +7 -0
- 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 +5 -21
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +7 -0
- package/dest/services/reqresp/protocols/status.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -1
- package/dest/services/reqresp/reqresp.js +402 -24
- package/dest/services/service.d.ts +16 -3
- package/dest/services/service.d.ts.map +1 -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 +4 -14
- package/dest/services/tx_collection/slow_tx_collection.d.ts +3 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +5 -5
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +6 -19
- package/dest/testbench/p2p_client_testbench_worker.js +30 -17
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +6 -1
- package/package.json +16 -16
- package/src/client/interface.ts +19 -4
- package/src/client/p2p_client.ts +82 -132
- package/src/config.ts +2 -2
- package/src/mem_pools/attestation_pool/attestation_pool.ts +68 -41
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +239 -287
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +162 -140
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +141 -164
- package/src/mem_pools/attestation_pool/mocks.ts +19 -13
- package/src/mem_pools/instrumentation.ts +9 -18
- package/src/mem_pools/tx_pool/README.md +28 -13
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +130 -75
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +66 -5
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +119 -4
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +162 -0
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +36 -21
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +13 -16
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/index.ts +1 -1
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +10 -0
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +13 -0
- package/src/msg_validators/proposal_validator/index.ts +3 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +92 -0
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +230 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +3 -1
- package/src/msg_validators/tx_validator/data_validator.ts +12 -4
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +40 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +8 -25
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/size_validator.ts +18 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +3 -1
- package/src/services/dummy_service.ts +6 -0
- package/src/services/encoding.ts +5 -4
- package/src/services/libp2p/instrumentation.ts +19 -73
- package/src/services/libp2p/libp2p_service.ts +351 -115
- package/src/services/peer-manager/metrics.ts +5 -26
- package/src/services/peer-manager/peer_manager.ts +1 -2
- package/src/services/peer-manager/peer_scoring.ts +1 -5
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +3 -1
- package/src/services/reqresp/constants.ts +14 -0
- package/src/services/reqresp/metrics.ts +7 -23
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +9 -0
- package/src/services/reqresp/protocols/status.ts +7 -4
- package/src/services/service.ts +19 -4
- package/src/services/tx_collection/instrumentation.ts +4 -21
- package/src/services/tx_collection/slow_tx_collection.ts +2 -2
- package/src/services/tx_collection/tx_collection.ts +4 -4
- package/src/services/tx_provider.ts +2 -2
- package/src/services/tx_provider_instrumentation.ts +11 -24
- package/src/testbench/p2p_client_testbench_worker.ts +40 -21
- package/src/testbench/worker_client_manager.ts +6 -1
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.js +0 -88
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +0 -12
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +0 -82
- package/dest/msg_validators/block_proposal_validator/index.d.ts +0 -2
- package/dest/msg_validators/block_proposal_validator/index.d.ts.map +0 -1
- package/dest/msg_validators/block_proposal_validator/index.js +0 -1
- package/src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts +0 -108
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +0 -97
- package/src/msg_validators/block_proposal_validator/index.ts +0 -1
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { GENESIS_BLOCK_HEADER_HASH
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type { AztecAsyncKVStore,
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
L2BlockSource,
|
|
5
|
+
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
6
|
+
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
7
|
+
import {
|
|
8
|
+
type EthAddress,
|
|
9
|
+
type L2Block,
|
|
10
|
+
type L2BlockSource,
|
|
11
11
|
L2BlockStream,
|
|
12
|
-
L2BlockStreamEvent,
|
|
13
|
-
L2Tips,
|
|
12
|
+
type L2BlockStreamEvent,
|
|
13
|
+
type L2Tips,
|
|
14
|
+
type L2TipsStore,
|
|
14
15
|
} from '@aztec/stdlib/block';
|
|
15
16
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
16
17
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
17
18
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import { BlockAttestation, type BlockProposal, type P2PClientType } from '@aztec/stdlib/p2p';
|
|
19
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
20
19
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} from '@aztec/telemetry-client';
|
|
20
|
+
type BlockProposal,
|
|
21
|
+
CheckpointAttestation,
|
|
22
|
+
type CheckpointProposal,
|
|
23
|
+
type P2PClientType,
|
|
24
|
+
} from '@aztec/stdlib/p2p';
|
|
25
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
26
|
+
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
28
27
|
|
|
29
28
|
import type { PeerId } from '@libp2p/interface';
|
|
30
29
|
import type { ENR } from '@nethermindeth/enr';
|
|
@@ -40,7 +39,7 @@ import {
|
|
|
40
39
|
type ReqRespSubProtocolValidators,
|
|
41
40
|
} from '../services/reqresp/interface.js';
|
|
42
41
|
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
43
|
-
import type { P2PBlockReceivedCallback, P2PService } from '../services/service.js';
|
|
42
|
+
import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback, P2PService } from '../services/service.js';
|
|
44
43
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
45
44
|
import { TxProvider } from '../services/tx_provider.js';
|
|
46
45
|
import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
@@ -62,10 +61,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
62
61
|
private provenBlockNumberAtStart = -1;
|
|
63
62
|
private finalizedBlockNumberAtStart = -1;
|
|
64
63
|
|
|
65
|
-
private
|
|
66
|
-
private synchedLatestBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
67
|
-
private synchedProvenBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
68
|
-
private synchedFinalizedBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
64
|
+
private l2Tips: L2TipsStore;
|
|
69
65
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
70
66
|
|
|
71
67
|
private txPool: TxPool;
|
|
@@ -114,7 +110,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
114
110
|
);
|
|
115
111
|
|
|
116
112
|
// Default to collecting all txs when we see a valid proposal
|
|
117
|
-
// This can be overridden by the validator client to
|
|
113
|
+
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
114
|
+
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
118
115
|
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
119
116
|
// validator-client code into here so we can validate a proposal is reasonable.
|
|
120
117
|
this.registerBlockProposalHandler(async (block, sender) => {
|
|
@@ -123,21 +120,17 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
123
120
|
const constants = this.txCollection.getConstants();
|
|
124
121
|
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
125
122
|
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
126
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.
|
|
123
|
+
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
127
124
|
if (!parentBlock) {
|
|
128
125
|
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
129
|
-
return;
|
|
126
|
+
return false;
|
|
130
127
|
}
|
|
131
128
|
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
132
129
|
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
133
|
-
return
|
|
130
|
+
return true;
|
|
134
131
|
});
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
this.synchedBlockHashes = store.openMap('p2p_pool_block_hashes');
|
|
138
|
-
this.synchedLatestBlockNumber = store.openSingleton('p2p_pool_last_l2_block');
|
|
139
|
-
this.synchedProvenBlockNumber = store.openSingleton('p2p_pool_last_proven_l2_block');
|
|
140
|
-
this.synchedFinalizedBlockNumber = store.openSingleton('p2p_pool_last_finalized_l2_block');
|
|
133
|
+
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
141
134
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
142
135
|
}
|
|
143
136
|
|
|
@@ -163,7 +156,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
163
156
|
}
|
|
164
157
|
|
|
165
158
|
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
166
|
-
return this.
|
|
159
|
+
return this.l2Tips.getL2BlockHash(number);
|
|
167
160
|
}
|
|
168
161
|
|
|
169
162
|
public updateP2PConfig(config: Partial<P2PConfig>): Promise<void> {
|
|
@@ -172,85 +165,45 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
172
165
|
return Promise.resolve();
|
|
173
166
|
}
|
|
174
167
|
|
|
175
|
-
public
|
|
176
|
-
|
|
177
|
-
let latestBlockHash: string | undefined;
|
|
178
|
-
|
|
179
|
-
const provenBlockNumber = await this.getSyncedProvenBlockNum();
|
|
180
|
-
let provenBlockHash: string | undefined;
|
|
181
|
-
|
|
182
|
-
const finalizedBlockNumber = await this.getSyncedFinalizedBlockNum();
|
|
183
|
-
let finalizedBlockHash: string | undefined;
|
|
184
|
-
|
|
185
|
-
if (latestBlockNumber > 0) {
|
|
186
|
-
latestBlockHash = await this.synchedBlockHashes.getAsync(latestBlockNumber);
|
|
187
|
-
if (typeof latestBlockHash === 'undefined') {
|
|
188
|
-
throw new Error(`Block hash for latest block ${latestBlockNumber} not found in p2p client`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (provenBlockNumber > 0) {
|
|
193
|
-
provenBlockHash = await this.synchedBlockHashes.getAsync(provenBlockNumber);
|
|
194
|
-
if (typeof provenBlockHash === 'undefined') {
|
|
195
|
-
throw new Error(`Block hash for proven block ${provenBlockNumber} not found in p2p client`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (finalizedBlockNumber > 0) {
|
|
200
|
-
finalizedBlockHash = await this.synchedBlockHashes.getAsync(finalizedBlockNumber);
|
|
201
|
-
if (typeof finalizedBlockHash === 'undefined') {
|
|
202
|
-
throw new Error(`Block hash for finalized block ${finalizedBlockNumber} not found in p2p client`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const genesisHash = GENESIS_BLOCK_HEADER_HASH.toString();
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
latest: { hash: latestBlockHash ?? genesisHash, number: latestBlockNumber },
|
|
210
|
-
proven: { hash: provenBlockHash ?? genesisHash, number: provenBlockNumber },
|
|
211
|
-
finalized: { hash: finalizedBlockHash ?? genesisHash, number: finalizedBlockNumber },
|
|
212
|
-
};
|
|
168
|
+
public getL2Tips(): Promise<L2Tips> {
|
|
169
|
+
return this.l2Tips.getL2Tips();
|
|
213
170
|
}
|
|
214
171
|
|
|
215
172
|
public async handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
216
173
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
174
|
+
|
|
217
175
|
switch (event.type) {
|
|
218
176
|
case 'blocks-added':
|
|
219
|
-
await this.handleLatestL2Blocks(event.blocks
|
|
177
|
+
await this.handleLatestL2Blocks(event.blocks);
|
|
220
178
|
break;
|
|
221
179
|
case 'chain-finalized': {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const from = BlockNumber((await this.getSyncedFinalizedBlockNum()) + 1);
|
|
180
|
+
const oldFinalizedBlockNum = await this.getSyncedFinalizedBlockNum();
|
|
181
|
+
const from = BlockNumber(oldFinalizedBlockNum + 1);
|
|
225
182
|
const limit = event.block.number - from + 1;
|
|
226
183
|
if (limit > 0) {
|
|
227
184
|
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
228
|
-
await this.handleFinalizedL2Blocks(oldBlocks
|
|
185
|
+
await this.handleFinalizedL2Blocks(oldBlocks);
|
|
229
186
|
}
|
|
230
187
|
break;
|
|
231
188
|
}
|
|
232
|
-
case 'chain-proven':
|
|
233
|
-
await this.setBlockHash(event.block);
|
|
189
|
+
case 'chain-proven':
|
|
234
190
|
this.txCollection.stopCollectingForBlocksUpTo(event.block.number);
|
|
235
|
-
await this.synchedProvenBlockNumber.set(event.block.number);
|
|
236
191
|
break;
|
|
237
|
-
}
|
|
238
192
|
case 'chain-pruned':
|
|
239
|
-
await this.setBlockHash(event.block);
|
|
240
193
|
this.txCollection.stopCollectingForBlocksAfter(event.block.number);
|
|
241
194
|
await this.handlePruneL2Blocks(event.block.number);
|
|
242
195
|
break;
|
|
196
|
+
case 'chain-checkpointed':
|
|
197
|
+
break;
|
|
243
198
|
default: {
|
|
244
199
|
const _: never = event;
|
|
245
200
|
break;
|
|
246
201
|
}
|
|
247
202
|
}
|
|
248
|
-
}
|
|
249
203
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
204
|
+
// Pass the event through to our l2 tips store
|
|
205
|
+
await this.l2Tips.handleBlockStreamEvent(event);
|
|
206
|
+
await this.startServiceIfSynched();
|
|
254
207
|
}
|
|
255
208
|
|
|
256
209
|
#assertIsReady() {
|
|
@@ -274,9 +227,9 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
274
227
|
|
|
275
228
|
// get the current latest block numbers
|
|
276
229
|
const latestBlockNumbers = await this.l2BlockSource.getL2Tips();
|
|
277
|
-
this.latestBlockNumberAtStart = latestBlockNumbers.
|
|
278
|
-
this.provenBlockNumberAtStart = latestBlockNumbers.proven.number;
|
|
279
|
-
this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.number;
|
|
230
|
+
this.latestBlockNumberAtStart = latestBlockNumbers.proposed.number;
|
|
231
|
+
this.provenBlockNumberAtStart = latestBlockNumbers.proven.block.number;
|
|
232
|
+
this.finalizedBlockNumberAtStart = latestBlockNumbers.finalized.block.number;
|
|
280
233
|
|
|
281
234
|
const syncedLatestBlock = (await this.getSyncedLatestBlockNum()) + 1;
|
|
282
235
|
const syncedProvenBlock = (await this.getSyncedProvenBlockNum()) + 1;
|
|
@@ -335,12 +288,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
335
288
|
private initBlockStream(startingBlock?: BlockNumber) {
|
|
336
289
|
if (!this.blockStream) {
|
|
337
290
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
338
|
-
this.blockStream = new
|
|
291
|
+
this.blockStream = new L2BlockStream(
|
|
339
292
|
this.l2BlockSource,
|
|
340
293
|
this,
|
|
341
294
|
this,
|
|
342
|
-
this.telemetry.getTracer('P2PL2BlockStream'),
|
|
343
|
-
'P2PL2BlockStream',
|
|
344
295
|
createLogger(`${this.log.module}:l2-block-stream`),
|
|
345
296
|
{ batchSize, pollIntervalMS, startingBlock },
|
|
346
297
|
);
|
|
@@ -380,23 +331,32 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
380
331
|
return this.p2pService.propagate(proposal);
|
|
381
332
|
}
|
|
382
333
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
334
|
+
@trackSpan('p2pClient.broadcastCheckpointProposal', async proposal => ({
|
|
335
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
336
|
+
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
337
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
338
|
+
}))
|
|
339
|
+
public broadcastCheckpointProposal(proposal: CheckpointProposal): Promise<void> {
|
|
340
|
+
this.log.verbose(`Broadcasting checkpoint proposal for slot ${proposal.slotNumber} to peers`);
|
|
341
|
+
return this.p2pService.propagate(proposal);
|
|
386
342
|
}
|
|
387
343
|
|
|
388
|
-
public async
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
: this.attestationPool.getAttestationsForSlot(slot));
|
|
344
|
+
public async broadcastCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
345
|
+
this.log.verbose(`Broadcasting ${attestations.length} checkpoint attestations to peers`);
|
|
346
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
392
347
|
}
|
|
393
348
|
|
|
394
|
-
public
|
|
395
|
-
|
|
349
|
+
public async getCheckpointAttestationsForSlot(
|
|
350
|
+
slot: SlotNumber,
|
|
351
|
+
proposalId?: string,
|
|
352
|
+
): Promise<CheckpointAttestation[]> {
|
|
353
|
+
return await (proposalId
|
|
354
|
+
? this.attestationPool.getCheckpointAttestationsForSlotAndProposal(slot, proposalId)
|
|
355
|
+
: this.attestationPool.getCheckpointAttestationsForSlot(slot));
|
|
396
356
|
}
|
|
397
357
|
|
|
398
|
-
public
|
|
399
|
-
return this.attestationPool.
|
|
358
|
+
public addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void> {
|
|
359
|
+
return this.attestationPool.addCheckpointAttestations(attestations);
|
|
400
360
|
}
|
|
401
361
|
|
|
402
362
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -405,6 +365,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
405
365
|
this.p2pService.registerBlockReceivedCallback(handler);
|
|
406
366
|
}
|
|
407
367
|
|
|
368
|
+
public registerCheckpointProposalHandler(handler: P2PCheckpointReceivedCallback): void {
|
|
369
|
+
this.p2pService.registerCheckpointReceivedCallback(handler);
|
|
370
|
+
}
|
|
371
|
+
|
|
408
372
|
/**
|
|
409
373
|
* Uses the batched Request Response protocol to request a set of transactions from the network.
|
|
410
374
|
*/
|
|
@@ -647,7 +611,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
647
611
|
* @returns Block number of latest L2 Block we've synced with.
|
|
648
612
|
*/
|
|
649
613
|
public async getSyncedLatestBlockNum(): Promise<BlockNumber> {
|
|
650
|
-
|
|
614
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
615
|
+
return tips.proposed.number;
|
|
651
616
|
}
|
|
652
617
|
|
|
653
618
|
/**
|
|
@@ -655,11 +620,13 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
655
620
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
656
621
|
*/
|
|
657
622
|
public async getSyncedProvenBlockNum(): Promise<BlockNumber> {
|
|
658
|
-
|
|
623
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
624
|
+
return tips.proven.block.number;
|
|
659
625
|
}
|
|
660
626
|
|
|
661
627
|
public async getSyncedFinalizedBlockNum(): Promise<BlockNumber> {
|
|
662
|
-
|
|
628
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
629
|
+
return tips.finalized.block.number;
|
|
663
630
|
}
|
|
664
631
|
|
|
665
632
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
@@ -692,7 +659,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
692
659
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
693
660
|
* @returns Empty promise.
|
|
694
661
|
*/
|
|
695
|
-
private async markTxsAsMinedFromBlocks(blocks:
|
|
662
|
+
private async markTxsAsMinedFromBlocks(blocks: L2Block[]): Promise<void> {
|
|
696
663
|
for (const block of blocks) {
|
|
697
664
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
698
665
|
await this.txPool.markAsMined(txHashes, block.header);
|
|
@@ -704,7 +671,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
704
671
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
705
672
|
* @returns Empty promise.
|
|
706
673
|
*/
|
|
707
|
-
private async handleLatestL2Blocks(blocks:
|
|
674
|
+
private async handleLatestL2Blocks(blocks: L2Block[]): Promise<void> {
|
|
708
675
|
if (!blocks.length) {
|
|
709
676
|
return Promise.resolve();
|
|
710
677
|
}
|
|
@@ -714,24 +681,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
714
681
|
await this.startCollectingMissingTxs(blocks);
|
|
715
682
|
|
|
716
683
|
const lastBlock = blocks.at(-1)!;
|
|
717
|
-
|
|
718
|
-
await Promise.all(
|
|
719
|
-
blocks.map(async block =>
|
|
720
|
-
this.setBlockHash({
|
|
721
|
-
number: block.number,
|
|
722
|
-
hash: await block.hash().then(h => h.toString()),
|
|
723
|
-
}),
|
|
724
|
-
),
|
|
725
|
-
);
|
|
726
|
-
|
|
727
|
-
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
728
684
|
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
729
685
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
730
|
-
await this.startServiceIfSynched();
|
|
731
686
|
}
|
|
732
687
|
|
|
733
688
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
734
|
-
private async startCollectingMissingTxs(blocks:
|
|
689
|
+
private async startCollectingMissingTxs(blocks: L2Block[]): Promise<void> {
|
|
735
690
|
try {
|
|
736
691
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
737
692
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -764,7 +719,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
764
719
|
* @param blocks - A list of finalized L2 blocks.
|
|
765
720
|
* @returns Empty promise.
|
|
766
721
|
*/
|
|
767
|
-
private async handleFinalizedL2Blocks(blocks:
|
|
722
|
+
private async handleFinalizedL2Blocks(blocks: L2Block[]): Promise<void> {
|
|
768
723
|
if (!blocks.length) {
|
|
769
724
|
return Promise.resolve();
|
|
770
725
|
}
|
|
@@ -778,12 +733,9 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
778
733
|
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
779
734
|
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
780
735
|
|
|
781
|
-
await this.attestationPool.
|
|
736
|
+
await this.attestationPool.deleteCheckpointAttestationsOlderThan(lastBlockSlot);
|
|
782
737
|
|
|
783
|
-
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
784
738
|
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
785
|
-
|
|
786
|
-
await this.startServiceIfSynched();
|
|
787
739
|
}
|
|
788
740
|
|
|
789
741
|
/**
|
|
@@ -831,18 +783,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
831
783
|
} else {
|
|
832
784
|
await this.txPool.markMinedAsPending(minedTxsFromReorg, latestBlock);
|
|
833
785
|
}
|
|
834
|
-
|
|
835
|
-
await this.synchedLatestBlockNumber.set(latestBlock);
|
|
836
|
-
// no need to update block hashes, as they will be updated as new blocks are added
|
|
837
786
|
}
|
|
838
787
|
|
|
839
788
|
private async startServiceIfSynched() {
|
|
840
789
|
if (this.currentState !== P2PClientState.SYNCHING) {
|
|
841
790
|
return;
|
|
842
791
|
}
|
|
843
|
-
const
|
|
844
|
-
const
|
|
845
|
-
const
|
|
792
|
+
const tips = await this.l2Tips.getL2Tips();
|
|
793
|
+
const syncedFinalizedBlock = tips.finalized.block.number;
|
|
794
|
+
const syncedProvenBlock = tips.proven.block.number;
|
|
795
|
+
const syncedLatestBlock = tips.proposed.number;
|
|
846
796
|
|
|
847
797
|
if (
|
|
848
798
|
syncedLatestBlock >= this.latestBlockNumberAtStart &&
|
package/src/config.ts
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
-
floatConfigHelper,
|
|
6
5
|
getConfigFromMappings,
|
|
7
6
|
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
8
|
+
percentageConfigHelper,
|
|
9
9
|
pickConfigMappings,
|
|
10
10
|
secretStringConfigHelper,
|
|
11
11
|
} from '@aztec/foundation/config';
|
|
@@ -407,7 +407,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
407
407
|
dropTransactionsProbability: {
|
|
408
408
|
env: 'P2P_DROP_TX_CHANCE',
|
|
409
409
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
410
|
-
...
|
|
410
|
+
...percentageConfigHelper(0),
|
|
411
411
|
},
|
|
412
412
|
disableTransactions: {
|
|
413
413
|
env: 'TRANSACTIONS_DISABLED',
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BlockProposal,
|
|
4
|
+
CheckpointAttestation,
|
|
5
|
+
CheckpointProposal,
|
|
6
|
+
CheckpointProposalCore,
|
|
7
|
+
} from '@aztec/stdlib/p2p';
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* An Attestation Pool contains attestations collected by a validator
|
|
@@ -32,75 +37,74 @@ export interface AttestationPool {
|
|
|
32
37
|
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
33
38
|
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
40
|
+
* Adds a checkpoint proposal to the pool.
|
|
36
41
|
*
|
|
37
|
-
*
|
|
42
|
+
* If the proposal contains a lastBlock, the BlockProposal is automatically extracted
|
|
43
|
+
* and stored separately via addBlockProposal. The checkpoint proposal is then stored
|
|
44
|
+
* without the lastBlock info (as CheckpointProposalCore).
|
|
45
|
+
*
|
|
46
|
+
* @param proposal - The checkpoint proposal to add
|
|
47
|
+
* @throws ProposalSlotCapExceededError if the slot has reached the maximum number of proposals
|
|
38
48
|
*/
|
|
39
|
-
|
|
49
|
+
addCheckpointProposal(proposal: CheckpointProposal): Promise<void>;
|
|
40
50
|
|
|
41
51
|
/**
|
|
42
|
-
*
|
|
52
|
+
* Get checkpoint proposal by its ID.
|
|
53
|
+
*
|
|
54
|
+
* Returns a CheckpointProposalCore (without lastBlock info) since the lastBlock
|
|
55
|
+
* is extracted and stored separately as a BlockProposal when added.
|
|
43
56
|
*
|
|
44
|
-
* @param
|
|
57
|
+
* @param id - The ID of the checkpoint proposal to retrieve (proposal.archive)
|
|
58
|
+
* @return The checkpoint proposal core if it exists, otherwise undefined.
|
|
45
59
|
*/
|
|
46
|
-
|
|
60
|
+
getCheckpointProposal(id: string): Promise<CheckpointProposalCore | undefined>;
|
|
47
61
|
|
|
48
62
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* Removes all attestations associated with a slot
|
|
63
|
+
* Check if a checkpoint proposal exists in the pool
|
|
52
64
|
*
|
|
53
|
-
* @param
|
|
65
|
+
* @param idOrProposal - The ID of the checkpoint proposal or the proposal itself
|
|
66
|
+
* @return True if the proposal exists, false otherwise.
|
|
54
67
|
*/
|
|
55
|
-
|
|
68
|
+
hasCheckpointProposal(idOrProposal: string | CheckpointProposal): Promise<boolean>;
|
|
56
69
|
|
|
57
70
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Removes all attestations associated with a slot
|
|
71
|
+
* Add checkpoint attestations to the pool
|
|
61
72
|
*
|
|
62
|
-
* @param
|
|
73
|
+
* @param attestations - Checkpoint attestations to add into the pool
|
|
63
74
|
*/
|
|
64
|
-
|
|
75
|
+
addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
|
|
65
76
|
|
|
66
77
|
/**
|
|
67
|
-
* Delete
|
|
68
|
-
*
|
|
69
|
-
* Removes all attestations associated with a slot and proposal
|
|
78
|
+
* Delete checkpoint attestations older than the given slot
|
|
70
79
|
*
|
|
71
|
-
* @param slot - The slot to
|
|
72
|
-
* @param proposalId - The proposal to delete.
|
|
80
|
+
* @param slot - The oldest slot to keep.
|
|
73
81
|
*/
|
|
74
|
-
|
|
82
|
+
deleteCheckpointAttestationsOlderThan(slot: SlotNumber): Promise<void>;
|
|
75
83
|
|
|
76
84
|
/**
|
|
77
|
-
* Get all
|
|
78
|
-
*
|
|
79
|
-
* Retrieve all of the attestations observed pertaining to a given slot
|
|
85
|
+
* Get all checkpoint attestations for a given slot
|
|
80
86
|
*
|
|
81
87
|
* @param slot - The slot to query
|
|
82
|
-
* @return
|
|
88
|
+
* @return CheckpointAttestations
|
|
83
89
|
*/
|
|
84
|
-
|
|
90
|
+
getCheckpointAttestationsForSlot(slot: SlotNumber): Promise<CheckpointAttestation[]>;
|
|
85
91
|
|
|
86
92
|
/**
|
|
87
|
-
* Get
|
|
88
|
-
*
|
|
89
|
-
* Retrieve all of the attestations observed pertaining to a given slot
|
|
93
|
+
* Get checkpoint attestations for slot and given proposal
|
|
90
94
|
*
|
|
91
95
|
* @param slot - The slot to query
|
|
92
96
|
* @param proposalId - The proposal to query
|
|
93
|
-
* @return
|
|
97
|
+
* @return CheckpointAttestations
|
|
94
98
|
*/
|
|
95
|
-
|
|
99
|
+
getCheckpointAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<CheckpointAttestation[]>;
|
|
96
100
|
|
|
97
101
|
/**
|
|
98
|
-
* Check if a specific attestation exists in the pool
|
|
102
|
+
* Check if a specific checkpoint attestation exists in the pool
|
|
99
103
|
*
|
|
100
104
|
* @param attestation - The attestation to check
|
|
101
105
|
* @return True if the attestation exists, false otherwise
|
|
102
106
|
*/
|
|
103
|
-
|
|
107
|
+
hasCheckpointAttestation(attestation: CheckpointAttestation): Promise<boolean>;
|
|
104
108
|
|
|
105
109
|
/**
|
|
106
110
|
* Returns whether adding this proposal is permitted at current capacity:
|
|
@@ -114,16 +118,39 @@ export interface AttestationPool {
|
|
|
114
118
|
canAddProposal(block: BlockProposal): Promise<boolean>;
|
|
115
119
|
|
|
116
120
|
/**
|
|
117
|
-
* Returns whether
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
+
* Returns whether adding this checkpoint proposal is permitted at current capacity.
|
|
122
|
+
*
|
|
123
|
+
* @param proposal - The checkpoint proposal to check
|
|
124
|
+
* @returns True if the proposal can be added, false otherwise.
|
|
125
|
+
*/
|
|
126
|
+
canAddCheckpointProposal(proposal: CheckpointProposal): Promise<boolean>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns whether a checkpoint attestation would be accepted for (slot, proposalId).
|
|
121
130
|
*
|
|
122
131
|
* @param attestation - The attestation to check
|
|
123
|
-
* @param committeeSize - Committee size for the attestation's slot
|
|
132
|
+
* @param committeeSize - Committee size for the attestation's slot
|
|
124
133
|
* @returns True if the attestation can be added, false otherwise.
|
|
125
134
|
*/
|
|
126
|
-
|
|
135
|
+
canAddCheckpointAttestation(attestation: CheckpointAttestation, committeeSize: number): Promise<boolean>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns whether the checkpoint proposal cap for the given slot has been reached.
|
|
139
|
+
*
|
|
140
|
+
* @param slot - The slot to check
|
|
141
|
+
* @returns True if the cap has been reached, false otherwise.
|
|
142
|
+
*/
|
|
143
|
+
hasReachedCheckpointProposalCap(slot: SlotNumber): Promise<boolean>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Returns whether the checkpoint attestation cap for the given slot and proposal has been reached.
|
|
147
|
+
*
|
|
148
|
+
* @param slot - The slot to check
|
|
149
|
+
* @param proposalId - The proposal to check
|
|
150
|
+
* @param committeeSize - Committee size for the slot
|
|
151
|
+
* @returns True if the cap has been reached, false otherwise.
|
|
152
|
+
*/
|
|
153
|
+
hasReachedCheckpointAttestationCap(slot: SlotNumber, proposalId: string, committeeSize: number): Promise<boolean>;
|
|
127
154
|
|
|
128
155
|
/** Returns whether the pool is empty. */
|
|
129
156
|
isEmpty(): Promise<boolean>;
|