@aztec/p2p 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2
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 +13 -8
- 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 +17 -4
- 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 +77 -4
- 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 +115 -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 +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- 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 +12 -10
- 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 +7 -10
- 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/{block_proposal_validator/block_proposal_validator.js → proposal_validator/proposal_validator.js} +19 -21
- 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 +183 -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/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/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/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 +4 -2
- 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 +27 -10
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +696 -137
- 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/interface.d.ts +3 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +2 -2
- 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_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 +27 -12
- 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 +78 -128
- 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 +128 -73
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +64 -4
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +117 -3
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +159 -0
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +75 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +16 -13
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +9 -12
- 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/{block_proposal_validator/block_proposal_validator.ts → proposal_validator/proposal_validator.ts} +23 -28
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +206 -0
- 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/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/timestamp_validator.ts +3 -1
- package/src/services/dummy_service.ts +6 -0
- package/src/services/encoding.ts +3 -1
- package/src/services/libp2p/instrumentation.ts +19 -73
- package/src/services/libp2p/libp2p_service.ts +326 -102
- 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/interface.ts +2 -2
- 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_provider_instrumentation.ts +11 -24
- package/src/testbench/p2p_client_testbench_worker.ts +35 -12
- 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/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/index.ts +0 -1
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
type TelemetryClient,
|
|
7
7
|
type Tracer,
|
|
8
8
|
type UpDownCounter,
|
|
9
|
-
ValueType,
|
|
10
9
|
getTelemetryClient,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
@@ -32,31 +31,11 @@ export class PeerManagerMetrics {
|
|
|
32
31
|
this.tracer = telemetryClient.getTracer(name);
|
|
33
32
|
|
|
34
33
|
const meter = telemetryClient.getMeter(name);
|
|
35
|
-
this.sentGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_SENT
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.receivedGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_RECEIVED, {
|
|
41
|
-
description: 'Number of goodbyes received from peers',
|
|
42
|
-
unit: 'peers',
|
|
43
|
-
valueType: ValueType.INT,
|
|
44
|
-
});
|
|
45
|
-
this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT, {
|
|
46
|
-
description: 'Number of peers',
|
|
47
|
-
unit: 'peers',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
50
|
-
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
51
|
-
description: 'Number of peers disconnected due to low score',
|
|
52
|
-
unit: 'peers',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
55
|
-
this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION, {
|
|
56
|
-
description: 'Time duration between peer connection and disconnection',
|
|
57
|
-
unit: 'ms',
|
|
58
|
-
valueType: ValueType.INT,
|
|
59
|
-
});
|
|
34
|
+
this.sentGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_SENT);
|
|
35
|
+
this.receivedGoodbyes = meter.createUpDownCounter(Metrics.PEER_MANAGER_GOODBYES_RECEIVED);
|
|
36
|
+
this.peerCount = meter.createGauge(Metrics.PEER_MANAGER_PEER_COUNT);
|
|
37
|
+
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS);
|
|
38
|
+
this.peerConnectionDuration = meter.createHistogram(Metrics.PEER_MANAGER_PEER_CONNECTION_DURATION);
|
|
60
39
|
}
|
|
61
40
|
|
|
62
41
|
public recordGoodbyeSent(reason: GoodByeReason) {
|
|
@@ -7,7 +7,7 @@ import { bufferToHex } from '@aztec/foundation/string';
|
|
|
7
7
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
8
8
|
import type { PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
9
9
|
import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
10
|
-
import {
|
|
10
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
11
11
|
|
|
12
12
|
import type { Connection, PeerId } from '@libp2p/interface';
|
|
13
13
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
@@ -161,7 +161,6 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
161
161
|
return this.metrics.tracer;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
@trackSpan('PeerManager.heartbeat')
|
|
165
164
|
public async heartbeat() {
|
|
166
165
|
this.heartbeatCounter++;
|
|
167
166
|
this.peerScoring.decayAllScores();
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
Metrics,
|
|
7
7
|
type TelemetryClient,
|
|
8
8
|
type UpDownCounter,
|
|
9
|
-
ValueType,
|
|
10
9
|
getTelemetryClient,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
@@ -53,10 +52,7 @@ export class PeerScoring {
|
|
|
53
52
|
|
|
54
53
|
const meter = telemetry.getMeter('PeerScoring');
|
|
55
54
|
|
|
56
|
-
this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT
|
|
57
|
-
description: 'Count of peers by state (Healthy, Disconnect, Banned)',
|
|
58
|
-
valueType: ValueType.INT,
|
|
59
|
-
});
|
|
55
|
+
this.peerStateCounter = meter.createUpDownCounter(Metrics.P2P_PEER_STATE_COUNT);
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
|
|
@@ -261,7 +261,9 @@ export class ConnectionSampler {
|
|
|
261
261
|
}
|
|
262
262
|
} catch (error) {
|
|
263
263
|
this.logger.error(
|
|
264
|
-
`Error cleaning up stale connection to peer ${stream.metadata.peerId?.toString() ?? 'unknown'} stream ${
|
|
264
|
+
`Error cleaning up stale connection to peer ${stream.metadata.peerId?.toString() ?? 'unknown'} stream ${
|
|
265
|
+
stream.id
|
|
266
|
+
}`,
|
|
265
267
|
{ error },
|
|
266
268
|
);
|
|
267
269
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for P2P message deserialization bounds checking.
|
|
3
|
+
* These constants define maximum allowed sizes during deserialization
|
|
4
|
+
* to prevent DoS attacks via maliciously crafted messages.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Max transactions per block for deserialization validation (~300x default of 32) */
|
|
8
|
+
export { MAX_TXS_PER_BLOCK } from '@aztec/stdlib/deserialization';
|
|
9
|
+
|
|
10
|
+
/** Max version string length (e.g., "1.0.0-alpha.123") */
|
|
11
|
+
export const MAX_VERSION_STRING_LENGTH = 64;
|
|
12
|
+
|
|
13
|
+
/** Max block hash string length (hex: 0x + 64 chars, with generous headroom) */
|
|
14
|
+
export const MAX_BLOCK_HASH_STRING_LENGTH = 128;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import {
|
|
2
|
+
import { L2BlockNew } from '@aztec/stdlib/block';
|
|
3
3
|
import { TxArray, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -198,7 +198,7 @@ export const subProtocolMap = {
|
|
|
198
198
|
},
|
|
199
199
|
[ReqRespSubProtocol.BLOCK]: {
|
|
200
200
|
request: Fr, // block number
|
|
201
|
-
response:
|
|
201
|
+
response: L2BlockNew,
|
|
202
202
|
},
|
|
203
203
|
[ReqRespSubProtocol.AUTH]: {
|
|
204
204
|
request: AuthRequest,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Request response metrics
|
|
2
|
-
import { Attributes, Metrics
|
|
2
|
+
import { Attributes, Metrics } from '@aztec/telemetry-client';
|
|
3
3
|
import type { TelemetryClient, Tracer, UpDownCounter } from '@aztec/telemetry-client';
|
|
4
4
|
|
|
5
5
|
export class ReqRespMetrics {
|
|
@@ -18,28 +18,12 @@ export class ReqRespMetrics {
|
|
|
18
18
|
this.tracer = telemetryClient.getTracer(name);
|
|
19
19
|
|
|
20
20
|
const meter = telemetryClient.getMeter(name);
|
|
21
|
-
this.sentRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_SENT_REQUESTS
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
description: 'Number of requests received from peers',
|
|
28
|
-
unit: 'requests',
|
|
29
|
-
valueType: ValueType.INT,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
this.failedOutboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS, {
|
|
33
|
-
description: 'Number of failed outbound requests - nodes not getting valid responses',
|
|
34
|
-
unit: 'requests',
|
|
35
|
-
valueType: ValueType.INT,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
this.failedInboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS, {
|
|
39
|
-
description: 'Number of failed inbound requests - node failing to respond to requests',
|
|
40
|
-
unit: 'requests',
|
|
41
|
-
valueType: ValueType.INT,
|
|
42
|
-
});
|
|
21
|
+
this.sentRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_SENT_REQUESTS);
|
|
22
|
+
this.receivedRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_RECEIVED_REQUESTS);
|
|
23
|
+
|
|
24
|
+
this.failedOutboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_OUTBOUND_REQUESTS);
|
|
25
|
+
|
|
26
|
+
this.failedInboundRequests = meter.createUpDownCounter(Metrics.P2P_REQ_RESP_FAILED_INBOUND_REQUESTS);
|
|
43
27
|
}
|
|
44
28
|
|
|
45
29
|
public recordRequestSent(protocol: string) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
2
|
|
|
3
|
+
import { MAX_TXS_PER_BLOCK } from '../../constants.js';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* BitVector helper class for representing and serializing bit vectors
|
|
5
7
|
*/
|
|
@@ -80,6 +82,13 @@ export class BitVector {
|
|
|
80
82
|
const reader = BufferReader.asReader(buffer);
|
|
81
83
|
const length = reader.readNumber();
|
|
82
84
|
|
|
85
|
+
if (length < 0) {
|
|
86
|
+
throw new Error(`BitVector length ${length} cannot be negative`);
|
|
87
|
+
}
|
|
88
|
+
if (length > MAX_TXS_PER_BLOCK) {
|
|
89
|
+
throw new Error(`BitVector length ${length} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
83
92
|
const bitBuffer = reader.readBytes(BitVector.byteLength(length));
|
|
84
93
|
return new BitVector(bitBuffer, length);
|
|
85
94
|
}
|
|
@@ -7,6 +7,8 @@ import type { WorldStateSyncStatus, WorldStateSynchronizer } from '@aztec/stdlib
|
|
|
7
7
|
|
|
8
8
|
import type { PeerId } from '@libp2p/interface';
|
|
9
9
|
|
|
10
|
+
import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_VERSION_STRING_LENGTH } from '../constants.js';
|
|
11
|
+
|
|
10
12
|
/*
|
|
11
13
|
* P2P Status Message
|
|
12
14
|
* It is used to establish Status handshake between to peers
|
|
@@ -19,9 +21,10 @@ export class StatusMessage {
|
|
|
19
21
|
readonly latestBlockNumber: BlockNumber,
|
|
20
22
|
readonly latestBlockHash: string,
|
|
21
23
|
readonly finalizedBlockNumber: BlockNumber,
|
|
24
|
+
) {
|
|
22
25
|
//TODO: add finalizedBlockHash
|
|
23
26
|
//readonly finalizedBlockHash: string,
|
|
24
|
-
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* Deserializes the StatusMessage object from a Buffer.
|
|
@@ -31,12 +34,12 @@ export class StatusMessage {
|
|
|
31
34
|
static fromBuffer(buffer: Buffer | BufferReader): StatusMessage {
|
|
32
35
|
const reader = BufferReader.asReader(buffer);
|
|
33
36
|
return new StatusMessage(
|
|
34
|
-
reader.readString(), // compressedComponentsVersion
|
|
37
|
+
reader.readString(MAX_VERSION_STRING_LENGTH), // compressedComponentsVersion
|
|
35
38
|
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
36
|
-
reader.readString(), // latestBlockHash
|
|
39
|
+
reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // latestBlockHash
|
|
37
40
|
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
38
41
|
//TODO: add finalizedBlockHash
|
|
39
|
-
//reader.readString(), // finalizedBlockHash
|
|
42
|
+
//reader.readString(MAX_BLOCK_HASH_STRING_LENGTH), // finalizedBlockHash
|
|
40
43
|
);
|
|
41
44
|
}
|
|
42
45
|
|
package/src/services/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposalCore, Gossipable } from '@aztec/stdlib/p2p';
|
|
4
4
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -22,10 +22,23 @@ export enum PeerDiscoveryState {
|
|
|
22
22
|
STOPPED = 'stopped',
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Callback for when a block proposal is received.
|
|
27
|
+
* Validators validate but DO NOT attest to individual blocks - attestations are only for checkpoints.
|
|
28
|
+
* @returns true if the proposal is valid, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
export type P2PBlockReceivedCallback = (block: BlockProposal, sender: PeerId) => Promise<boolean>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Callback for when a checkpoint proposal is received.
|
|
34
|
+
* The checkpoint proposal is passed as CheckpointProposalCore (without lastBlock) since
|
|
35
|
+
* the lastBlock is extracted and stored separately as a BlockProposal, and the block
|
|
36
|
+
* callback is invoked and awaited before this checkpoint callback.
|
|
37
|
+
*/
|
|
38
|
+
export type P2PCheckpointReceivedCallback = (
|
|
39
|
+
checkpoint: CheckpointProposalCore,
|
|
27
40
|
sender: PeerId,
|
|
28
|
-
) => Promise<
|
|
41
|
+
) => Promise<CheckpointAttestation[] | undefined>;
|
|
29
42
|
|
|
30
43
|
export type AuthReceivedCallback = (peerId: PeerId, authRequest: AuthRequest) => Promise<AuthResponse | undefined>;
|
|
31
44
|
|
|
@@ -70,6 +83,8 @@ export interface P2PService {
|
|
|
70
83
|
// Leaky abstraction: fix https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
71
84
|
registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
|
|
72
85
|
|
|
86
|
+
registerCheckpointReceivedCallback(callback: P2PCheckpointReceivedCallback): void;
|
|
87
|
+
|
|
73
88
|
getEnr(): ENR | undefined;
|
|
74
89
|
|
|
75
90
|
getPeers(includePending?: boolean): PeerInfo[];
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attributes,
|
|
3
|
-
type Histogram,
|
|
4
|
-
Metrics,
|
|
5
|
-
type TelemetryClient,
|
|
6
|
-
type UpDownCounter,
|
|
7
|
-
ValueType,
|
|
8
|
-
} from '@aztec/telemetry-client';
|
|
1
|
+
import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
|
|
9
2
|
|
|
10
3
|
import type { CollectionMethod } from './tx_collection.js';
|
|
11
4
|
|
|
@@ -17,21 +10,11 @@ export class TxCollectionInstrumentation {
|
|
|
17
10
|
constructor(client: TelemetryClient, name: string) {
|
|
18
11
|
const meter = client.getMeter(name);
|
|
19
12
|
|
|
20
|
-
this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT
|
|
21
|
-
description: 'The number of txs collected',
|
|
22
|
-
});
|
|
13
|
+
this.txsCollected = meter.createUpDownCounter(Metrics.TX_COLLECTOR_COUNT);
|
|
23
14
|
|
|
24
|
-
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX
|
|
25
|
-
unit: 'ms',
|
|
26
|
-
description: 'Average duration per tx of an individual tx collection request',
|
|
27
|
-
valueType: ValueType.INT,
|
|
28
|
-
});
|
|
15
|
+
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|
|
29
16
|
|
|
30
|
-
this.collectionDurationPerRequest = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_REQUEST
|
|
31
|
-
unit: 'ms',
|
|
32
|
-
description: 'Total duration of an individual tx collection request',
|
|
33
|
-
valueType: ValueType.INT,
|
|
34
|
-
});
|
|
17
|
+
this.collectionDurationPerRequest = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_REQUEST);
|
|
35
18
|
}
|
|
36
19
|
|
|
37
20
|
increaseTxsFor(what: CollectionMethod, count: number, duration: number) {
|
|
@@ -12,30 +12,17 @@ export class TxProviderInstrumentation {
|
|
|
12
12
|
constructor(client: TelemetryClient, name: string) {
|
|
13
13
|
const meter = client.getMeter(name);
|
|
14
14
|
|
|
15
|
-
this.txFromProposalCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_PROPOSALS_COUNT
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.missingTxsCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_MISSING_TXS_COUNT, {
|
|
28
|
-
description: 'The number of txs not found anywhere',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
this.fractionOfTxsRequestedFromP2P = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUESTED_FRACTION, {
|
|
32
|
-
description: 'The fraction of transaction requested from peers',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
this.txsRequestDelay = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUEST_DELAY, {
|
|
36
|
-
unit: 'ms',
|
|
37
|
-
description: 'The time it took to request missing transactions from p2p',
|
|
38
|
-
});
|
|
15
|
+
this.txFromProposalCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_PROPOSALS_COUNT);
|
|
16
|
+
|
|
17
|
+
this.txFromMempoolCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_MEMPOOL_COUNT);
|
|
18
|
+
|
|
19
|
+
this.txFromP2PCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_TXS_FROM_P2P_COUNT);
|
|
20
|
+
|
|
21
|
+
this.missingTxsCount = meter.createUpDownCounter(Metrics.TX_PROVIDER_MISSING_TXS_COUNT);
|
|
22
|
+
|
|
23
|
+
this.fractionOfTxsRequestedFromP2P = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUESTED_FRACTION);
|
|
24
|
+
|
|
25
|
+
this.txsRequestDelay = meter.createHistogram(Metrics.TX_PROVIDER_P2P_TXS_REQUEST_DELAY);
|
|
39
26
|
}
|
|
40
27
|
|
|
41
28
|
incTxsFromProposals(count: number) {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { MockL2BlockSource } from '@aztec/archiver/test';
|
|
7
7
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
8
8
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
9
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
12
|
import { sleep } from '@aztec/foundation/sleep';
|
|
@@ -65,25 +66,29 @@ function mockTxPool(): TxPool {
|
|
|
65
66
|
function mockAttestationPool(): AttestationPool {
|
|
66
67
|
return {
|
|
67
68
|
isEmpty: () => Promise.resolve(false),
|
|
68
|
-
addAttestations: () => Promise.resolve(),
|
|
69
|
-
deleteAttestations: () => Promise.resolve(),
|
|
70
|
-
deleteAttestationsOlderThan: () => Promise.resolve(),
|
|
71
|
-
deleteAttestationsForSlot: () => Promise.resolve(),
|
|
72
|
-
deleteAttestationsForSlotAndProposal: () => Promise.resolve(),
|
|
73
|
-
getAttestationsForSlot: () => Promise.resolve([]),
|
|
74
|
-
getAttestationsForSlotAndProposal: () => Promise.resolve([]),
|
|
75
69
|
addBlockProposal: () => Promise.resolve(),
|
|
76
70
|
getBlockProposal: () => Promise.resolve(undefined),
|
|
77
71
|
hasBlockProposal: () => Promise.resolve(false),
|
|
78
|
-
hasAttestation: () => Promise.resolve(false),
|
|
79
72
|
canAddProposal: () => Promise.resolve(true),
|
|
80
|
-
|
|
73
|
+
// Checkpoint attestation methods
|
|
74
|
+
addCheckpointProposal: () => Promise.resolve(),
|
|
75
|
+
getCheckpointProposal: () => Promise.resolve(undefined),
|
|
76
|
+
hasCheckpointProposal: () => Promise.resolve(false),
|
|
77
|
+
addCheckpointAttestations: () => Promise.resolve(),
|
|
78
|
+
getCheckpointAttestationsForSlot: () => Promise.resolve([]),
|
|
79
|
+
getCheckpointAttestationsForSlotAndProposal: () => Promise.resolve([]),
|
|
80
|
+
deleteCheckpointAttestationsOlderThan: () => Promise.resolve(),
|
|
81
|
+
hasReachedCheckpointProposalCap: () => Promise.resolve(false),
|
|
82
|
+
hasReachedCheckpointAttestationCap: () => Promise.resolve(false),
|
|
83
|
+
canAddCheckpointProposal: () => Promise.resolve(true),
|
|
84
|
+
canAddCheckpointAttestation: () => Promise.resolve(true),
|
|
85
|
+
hasCheckpointAttestation: () => Promise.resolve(false),
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
function mockEpochCache(): EpochCacheInterface {
|
|
85
90
|
return {
|
|
86
|
-
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO }),
|
|
91
|
+
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO, isEscapeHatchOpen: false }),
|
|
87
92
|
getProposerIndexEncoding: () => '0x' as `0x${string}`,
|
|
88
93
|
getEpochAndSlotNow: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n }),
|
|
89
94
|
computeProposerIndex: () => 0n,
|
|
@@ -94,6 +99,7 @@ function mockEpochCache(): EpochCacheInterface {
|
|
|
94
99
|
currentSlot: SlotNumber.ZERO,
|
|
95
100
|
nextSlot: SlotNumber.ZERO,
|
|
96
101
|
}),
|
|
102
|
+
getProposerAttesterAddressInSlot: () => Promise.resolve(undefined),
|
|
97
103
|
getEpochAndSlotInNextL1Slot: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n, now: 0n }),
|
|
98
104
|
isInCommittee: () => Promise.resolve(false),
|
|
99
105
|
getRegisteredValidators: () => Promise.resolve([]),
|
|
@@ -189,9 +195,25 @@ class TestLibP2PService<T extends P2PClientType = P2PClientType.Full> extends Li
|
|
|
189
195
|
|
|
190
196
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
191
197
|
process.on('message', async msg => {
|
|
192
|
-
|
|
198
|
+
// Note: peerIdPrivateKey comes as a raw string (not SecretValue) because
|
|
199
|
+
// SecretValue's private fields can't be serialized via IPC
|
|
200
|
+
const {
|
|
201
|
+
type,
|
|
202
|
+
config: rawConfig,
|
|
203
|
+
clientIndex,
|
|
204
|
+
} = msg as {
|
|
205
|
+
type: string;
|
|
206
|
+
config: Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey?: string };
|
|
207
|
+
clientIndex: number;
|
|
208
|
+
};
|
|
193
209
|
try {
|
|
194
210
|
if (type === 'START') {
|
|
211
|
+
// Re-wrap the peerIdPrivateKey with SecretValue
|
|
212
|
+
const config: P2PConfig = {
|
|
213
|
+
...rawConfig,
|
|
214
|
+
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined,
|
|
215
|
+
} as P2PConfig;
|
|
216
|
+
|
|
195
217
|
const txPool = mockTxPool();
|
|
196
218
|
const attestationPool = mockAttestationPool();
|
|
197
219
|
const epochCache = mockEpochCache();
|
|
@@ -224,14 +246,15 @@ process.on('message', async msg => {
|
|
|
224
246
|
);
|
|
225
247
|
|
|
226
248
|
// Create test service with validation disabled
|
|
249
|
+
// Note: Parameter order must match LibP2PService constructor
|
|
227
250
|
const testService = new TestLibP2PService(
|
|
228
251
|
P2PClientType.Full,
|
|
229
252
|
config,
|
|
230
253
|
(client as any).p2pService.node,
|
|
231
254
|
(client as any).p2pService.peerDiscoveryService,
|
|
232
|
-
(client as any).p2pService.mempools,
|
|
233
255
|
(client as any).p2pService.reqresp,
|
|
234
256
|
(client as any).p2pService.peerManager,
|
|
257
|
+
(client as any).p2pService.mempools,
|
|
235
258
|
(client as any).p2pService.archiver,
|
|
236
259
|
epochCache,
|
|
237
260
|
proofVerifier,
|
|
@@ -73,7 +73,12 @@ class WorkerClientManager {
|
|
|
73
73
|
clientIndex: number,
|
|
74
74
|
): [ChildProcess, Promise<void>] {
|
|
75
75
|
const childProcess = fork(workerPath);
|
|
76
|
-
|
|
76
|
+
// Extract the raw peerIdPrivateKey value since SecretValue can't be serialized via IPC
|
|
77
|
+
const serializedConfig = {
|
|
78
|
+
...config,
|
|
79
|
+
peerIdPrivateKey: config.peerIdPrivateKey?.getValue(),
|
|
80
|
+
};
|
|
81
|
+
childProcess.send({ type: 'START', config: serializedConfig, clientIndex });
|
|
77
82
|
|
|
78
83
|
// Handle unexpected child process exit
|
|
79
84
|
childProcess.on('exit', (code, signal) => {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
|
|
2
|
-
import type { TxPoolOptions } from '../tx_pool.js';
|
|
3
|
-
import { type EvictionContext, type EvictionResult, type EvictionRule, type TxPoolOperations } from './eviction_strategy.js';
|
|
4
|
-
export declare class InsufficientFeePayerBalanceRule implements EvictionRule {
|
|
5
|
-
private worldState;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly reason: string;
|
|
8
|
-
constructor(worldState: ReadonlyWorldStateAccess);
|
|
9
|
-
private log;
|
|
10
|
-
evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult>;
|
|
11
|
-
private evictTxs;
|
|
12
|
-
private createGasTxValidator;
|
|
13
|
-
updateConfig(_config: TxPoolOptions): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdWZmaWNpZW50X2ZlZV9wYXllcl9iYWxhbmNlX3J1bGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbC9ldmljdGlvbi9pbnN1ZmZpY2llbnRfZmVlX3BheWVyX2JhbGFuY2VfcnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBS2hGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNuRCxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBRXBCLEtBQUssY0FBYyxFQUNuQixLQUFLLFlBQVksRUFFakIsS0FBSyxnQkFBZ0IsRUFDdEIsTUFBTSx3QkFBd0IsQ0FBQztBQUVoQyxxQkFBYSwrQkFBZ0MsWUFBVyxZQUFZO0lBSS9DLE9BQU8sQ0FBQyxVQUFVO0lBSHJDLFNBQWdCLElBQUksU0FBaUM7SUFDckQsU0FBZ0IsTUFBTSxTQUE0QjtJQUVsRCxZQUEyQixVQUFVLEVBQUUsd0JBQXdCLEVBQUk7SUFFbkUsT0FBTyxDQUFDLEdBQUcsQ0FBMkU7SUFFaEYsS0FBSyxDQUFDLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxFQUFFLGdCQUFnQixHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FrQ3ZGO1lBRWEsUUFBUTtJQXdDdEIsT0FBTyxDQUFDLG9CQUFvQjtJQUk1QixZQUFZLENBQUMsT0FBTyxFQUFFLGFBQWEsR0FBRyxJQUFJLENBQUc7Q0FDOUMifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insufficient_fee_payer_balance_rule.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool/eviction/insufficient_fee_payer_balance_rule.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAKhF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,+BAAgC,YAAW,YAAY;IAI/C,OAAO,CAAC,UAAU;IAHrC,SAAgB,IAAI,SAAiC;IACrD,SAAgB,MAAM,SAA4B;IAElD,YAA2B,UAAU,EAAE,wBAAwB,EAAI;IAEnE,OAAO,CAAC,GAAG,CAA2E;IAEhF,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAkCvF;YAEa,QAAQ;IAwCtB,OAAO,CAAC,oBAAoB;IAI5B,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAG;CAC9C"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
4
|
-
import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
5
|
-
import { GasTxValidator } from '../../../msg_validators/index.js';
|
|
6
|
-
import { EvictionEvent } from './eviction_strategy.js';
|
|
7
|
-
export class InsufficientFeePayerBalanceRule {
|
|
8
|
-
worldState;
|
|
9
|
-
name;
|
|
10
|
-
reason;
|
|
11
|
-
constructor(worldState){
|
|
12
|
-
this.worldState = worldState;
|
|
13
|
-
this.name = 'InsufficientFeePayerBalance';
|
|
14
|
-
this.reason = 'insufficient_fee_juice';
|
|
15
|
-
this.log = createLogger('p2p:mempool:tx_pool:insufficient_fee_payer_balance_rule');
|
|
16
|
-
}
|
|
17
|
-
log;
|
|
18
|
-
async evict(context, txPool) {
|
|
19
|
-
try {
|
|
20
|
-
if (context.event === EvictionEvent.CHAIN_PRUNED) {
|
|
21
|
-
const affectedTxs = await txPool.getPendingTxInfos();
|
|
22
|
-
return this.evictTxs(affectedTxs, context.blockNumber, txPool);
|
|
23
|
-
}
|
|
24
|
-
if (context.event === EvictionEvent.BLOCK_MINED) {
|
|
25
|
-
const affectedTxs = await txPool.getPendingTxsWithFeePayer(context.minedFeePayers);
|
|
26
|
-
// TODO: fix this edge-case
|
|
27
|
-
// This can lead to a race condition if we are catching up in the p2p client.
|
|
28
|
-
// Let's say we have 3 txs for the same fee payer, which get mined in blocks 1, 2, 3.
|
|
29
|
-
// Tx1 consumes fee juice, tx2 increases it, tx3 consumes it again. We see block1 with tx1 first, run this rule, and evict tx3.
|
|
30
|
-
// But tx3 was valid (due to tx2) and mined on block3. And we have just removed from the mempool a tx we needed for proving/reexec.
|
|
31
|
-
// -----
|
|
32
|
-
// Proposed fix: evict only if node is synched
|
|
33
|
-
return this.evictTxs(affectedTxs, context.block.getBlockNumber(), txPool);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
reason: this.reason,
|
|
37
|
-
success: true,
|
|
38
|
-
txsEvicted: []
|
|
39
|
-
};
|
|
40
|
-
} catch (err) {
|
|
41
|
-
this.log.error('Failed to evict invalid transactions after mining', {
|
|
42
|
-
err
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
reason: this.reason,
|
|
46
|
-
success: false,
|
|
47
|
-
txsEvicted: [],
|
|
48
|
-
error: new Error('Failed to evict invalid txs after mining', {
|
|
49
|
-
cause: err
|
|
50
|
-
})
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async evictTxs(candidateTxs, blockNumber, txPool) {
|
|
55
|
-
const txsToEvict = [];
|
|
56
|
-
const gasValidator = this.createGasTxValidator(this.worldState.getSnapshot(blockNumber));
|
|
57
|
-
for (const { txHash, isEvictable } of candidateTxs){
|
|
58
|
-
if (!isEvictable) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const tx = await txPool.getTxByHash(txHash);
|
|
62
|
-
if (!tx) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
this.log.debug(`Validating tx balance ${txHash}`);
|
|
66
|
-
if ((await gasValidator.validateTxFee(tx)).result === 'invalid') {
|
|
67
|
-
this.log.verbose(`Evicting tx ${txHash} from pool due to an insufficient fee payer balance`);
|
|
68
|
-
txsToEvict.push(txHash);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (txsToEvict.length > 0) {
|
|
73
|
-
await txPool.deleteTxs(txsToEvict);
|
|
74
|
-
}
|
|
75
|
-
this.log.verbose(`Evicted ${txsToEvict.length} invalid txs after block mined`, {
|
|
76
|
-
txsToEvict
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
reason: this.reason,
|
|
80
|
-
success: true,
|
|
81
|
-
txsEvicted: txsToEvict
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
createGasTxValidator(db) {
|
|
85
|
-
return new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, GasFees.empty());
|
|
86
|
-
}
|
|
87
|
-
updateConfig(_config) {}
|
|
88
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { type BlockProposal, type P2PValidator, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
-
export declare class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
4
|
-
private epochCache;
|
|
5
|
-
private logger;
|
|
6
|
-
private txsPermitted;
|
|
7
|
-
constructor(epochCache: EpochCacheInterface, opts: {
|
|
8
|
-
txsPermitted: boolean;
|
|
9
|
-
});
|
|
10
|
-
validate(block: BlockProposal): Promise<PeerErrorSeverity | undefined>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfcHJvcG9zYWxfdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbXNnX3ZhbGlkYXRvcnMvYmxvY2tfcHJvcG9zYWxfdmFsaWRhdG9yL2Jsb2NrX3Byb3Bvc2FsX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRzlELE9BQU8sRUFBRSxLQUFLLGFBQWEsRUFBRSxLQUFLLFlBQVksRUFBRSxpQkFBaUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRTdGLHFCQUFhLHNCQUF1QixZQUFXLFlBQVksQ0FBQyxhQUFhLENBQUM7SUFDeEUsT0FBTyxDQUFDLFVBQVUsQ0FBc0I7SUFDeEMsT0FBTyxDQUFDLE1BQU0sQ0FBUztJQUN2QixPQUFPLENBQUMsWUFBWSxDQUFVO0lBRTlCLFlBQVksVUFBVSxFQUFFLG1CQUFtQixFQUFFLElBQUksRUFBRTtRQUFFLFlBQVksRUFBRSxPQUFPLENBQUE7S0FBRSxFQUkzRTtJQUVLLFFBQVEsQ0FBQyxLQUFLLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsR0FBRyxTQUFTLENBQUMsQ0ErRTNFO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block_proposal_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/block_proposal_validator/block_proposal_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7F,qBAAa,sBAAuB,YAAW,YAAY,CAAC,aAAa,CAAC;IACxE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAU;IAE9B,YAAY,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,EAI3E;IAEK,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA+E3E;CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export * from './block_proposal_validator.js';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tc2dfdmFsaWRhdG9ycy9ibG9ja19wcm9wb3NhbF92YWxpZGF0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywrQkFBK0IsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/block_proposal_validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './block_proposal_validator.js';
|