@aztec/p2p 3.0.0-devnet.6 → 3.0.0-devnet.6-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +4 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +8 -26
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +31 -24
- package/dest/config.d.ts +60 -54
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -2
- package/dest/enr/generate-enr.d.ts +1 -1
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +43 -6
- 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 +67 -34
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +15 -6
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +57 -18
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +13 -6
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +51 -7
- package/dest/mem_pools/attestation_pool/mocks.d.ts +226 -5
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +3 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +11 -2
- package/dest/mem_pools/interface.d.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +5 -38
- 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 +9 -3
- package/dest/mem_pools/tx_pool/index.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +5 -3
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +7 -0
- package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +10 -3
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +5 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +12 -12
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +22 -10
- package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
- package/dest/msg_validators/index.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +2 -2
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +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/double_spend_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.d.ts +4 -3
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +1 -1
- 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/index.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -1
- package/dest/msg_validators/tx_validator/test_utils.d.ts +2 -2
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/dummy_service.d.ts +1 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/encoding.d.ts +25 -4
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +74 -6
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +1 -1
- 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 +9 -2
- package/dest/services/libp2p/libp2p_service.d.ts +25 -74
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +308 -84
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -0
- package/dest/services/peer-manager/peer_manager.d.ts +1 -32
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +4 -2
- 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 +40 -2
- package/dest/services/reqresp/config.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +1 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/index.d.ts +1 -1
- package/dest/services/reqresp/interface.d.ts +2 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -1
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +2 -2
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.js +2 -2
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +3 -2
- 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/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +4 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +1 -1
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts +1 -1
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -1
- package/dest/services/reqresp/protocols/ping.d.ts +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +6 -5
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -3
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -41
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +2 -2
- package/dest/services/reqresp/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +1 -1
- package/dest/services/tx_collection/config.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -9
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/index.d.ts +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/slow_tx_collection.d.ts +6 -7
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +2 -1
- package/dest/services/tx_collection/tx_collection.d.ts +11 -11
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +3 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_provider.d.ts +5 -4
- 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/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts +2 -2
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.d.ts +2 -2
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +14 -8
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +2 -2
- package/dest/testbench/worker_client_manager.d.ts +1 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/types/index.d.ts +1 -1
- package/dest/util.d.ts +2 -1
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +11 -2
- package/dest/versioning.d.ts +1 -1
- package/package.json +19 -18
- package/src/client/interface.ts +4 -1
- package/src/client/p2p_client.ts +51 -43
- package/src/config.ts +19 -2
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +46 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +84 -34
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +87 -24
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +77 -15
- package/src/mem_pools/attestation_pool/mocks.ts +3 -3
- package/src/mem_pools/instrumentation.ts +13 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +15 -9
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +13 -6
- package/src/mem_pools/tx_pool/tx_pool.ts +10 -2
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +5 -4
- package/src/msg_validators/attestation_validator/attestation_validator.ts +14 -16
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +26 -10
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
- package/src/msg_validators/tx_validator/factory.ts +3 -2
- package/src/msg_validators/tx_validator/metadata_validator.ts +1 -1
- package/src/msg_validators/tx_validator/phases_validator.ts +3 -1
- package/src/msg_validators/tx_validator/test_utils.ts +1 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +2 -1
- package/src/services/encoding.ts +81 -6
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +334 -91
- package/src/services/peer-manager/metrics.ts +10 -0
- package/src/services/peer-manager/peer_manager.ts +4 -2
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/interface.ts +1 -1
- package/src/services/reqresp/protocols/auth.ts +2 -2
- package/src/services/reqresp/protocols/block.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +1 -1
- package/src/services/reqresp/protocols/status.ts +9 -8
- package/src/services/reqresp/reqresp.ts +2 -2
- package/src/services/tx_collection/fast_tx_collection.ts +3 -2
- package/src/services/tx_collection/slow_tx_collection.ts +7 -6
- package/src/services/tx_collection/tx_collection.ts +10 -9
- package/src/services/tx_provider.ts +4 -3
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +11 -5
- package/src/testbench/testbench.ts +2 -2
- package/src/util.ts +12 -2
|
@@ -15,6 +15,7 @@ export class PeerManagerMetrics {
|
|
|
15
15
|
private sentGoodbyes: UpDownCounter;
|
|
16
16
|
private receivedGoodbyes: UpDownCounter;
|
|
17
17
|
private peerCount: Gauge;
|
|
18
|
+
private lowScoreDisconnects: UpDownCounter;
|
|
18
19
|
|
|
19
20
|
public readonly tracer: Tracer;
|
|
20
21
|
|
|
@@ -40,6 +41,11 @@ export class PeerManagerMetrics {
|
|
|
40
41
|
unit: 'peers',
|
|
41
42
|
valueType: ValueType.INT,
|
|
42
43
|
});
|
|
44
|
+
this.lowScoreDisconnects = meter.createUpDownCounter(Metrics.PEER_MANAGER_LOW_SCORE_DISCONNECTS, {
|
|
45
|
+
description: 'Number of peers disconnected due to low score',
|
|
46
|
+
unit: 'peers',
|
|
47
|
+
valueType: ValueType.INT,
|
|
48
|
+
});
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
public recordGoodbyeSent(reason: GoodByeReason) {
|
|
@@ -53,4 +59,8 @@ export class PeerManagerMetrics {
|
|
|
53
59
|
public recordPeerCount(count: number) {
|
|
54
60
|
this.peerCount.record(count);
|
|
55
61
|
}
|
|
62
|
+
|
|
63
|
+
public recordLowScoreDisconnect(scoreState: 'Banned' | 'Disconnect') {
|
|
64
|
+
this.lowScoreDisconnects.add(1, { [Attributes.P2P_PEER_SCORE_STATE]: scoreState });
|
|
65
|
+
}
|
|
56
66
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { makeEthSignDigest, tryRecoverAddress } from '@aztec/foundation/crypto';
|
|
2
|
+
import { makeEthSignDigest, tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
7
7
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -577,9 +577,11 @@ export class PeerManager implements PeerManagerInterface {
|
|
|
577
577
|
const score = this.peerScoring.getScoreState(peer.remotePeer.toString());
|
|
578
578
|
switch (score) {
|
|
579
579
|
case PeerScoreState.Banned:
|
|
580
|
+
this.metrics.recordLowScoreDisconnect('Banned');
|
|
580
581
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.BANNED);
|
|
581
582
|
break;
|
|
582
583
|
case PeerScoreState.Disconnect:
|
|
584
|
+
this.metrics.recordLowScoreDisconnect('Disconnect');
|
|
583
585
|
void this.goodbyeAndDisconnectPeer(peer.remotePeer, GoodByeReason.LOW_SCORE);
|
|
584
586
|
break;
|
|
585
587
|
case PeerScoreState.Healthy:
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { median } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
|
+
import {
|
|
5
|
+
Attributes,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
type UpDownCounter,
|
|
9
|
+
ValueType,
|
|
10
|
+
getTelemetryClient,
|
|
11
|
+
} from '@aztec/telemetry-client';
|
|
4
12
|
|
|
5
13
|
import type { PeerId } from '@libp2p/interface';
|
|
6
14
|
|
|
@@ -30,7 +38,9 @@ export class PeerScoring {
|
|
|
30
38
|
private decayFactor = 0.9;
|
|
31
39
|
peerPenalties: { [key in PeerErrorSeverity]: number };
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
private peerStateCounter: UpDownCounter;
|
|
42
|
+
|
|
43
|
+
constructor(config: P2PConfig, telemetry: TelemetryClient = getTelemetryClient()) {
|
|
34
44
|
const orderedValues = config.peerPenaltyValues?.sort((a, b) => a - b);
|
|
35
45
|
this.peerPenalties = {
|
|
36
46
|
[PeerErrorSeverity.HighToleranceError]:
|
|
@@ -40,6 +50,13 @@ export class PeerScoring {
|
|
|
40
50
|
[PeerErrorSeverity.LowToleranceError]:
|
|
41
51
|
orderedValues?.[2] ?? DefaultPeerPenalties[PeerErrorSeverity.LowToleranceError],
|
|
42
52
|
};
|
|
53
|
+
|
|
54
|
+
const meter = telemetry.getMeter('PeerScoring');
|
|
55
|
+
|
|
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
|
+
});
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
public penalizePeer(peerId: PeerId, penalty: PeerErrorSeverity) {
|
|
@@ -99,7 +116,33 @@ export class PeerScoring {
|
|
|
99
116
|
return PeerScoreState.Healthy;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
getStats(): { medianScore: number } {
|
|
103
|
-
|
|
119
|
+
getStats(): { medianScore: number; healthyCount: number; disconnectCount: number; bannedCount: number } {
|
|
120
|
+
const stateCounts = { healthy: 0, disconnect: 0, banned: 0 };
|
|
121
|
+
|
|
122
|
+
for (const peerId of this.scores.keys()) {
|
|
123
|
+
const state = this.getScoreState(peerId);
|
|
124
|
+
switch (state) {
|
|
125
|
+
case PeerScoreState.Healthy:
|
|
126
|
+
stateCounts.healthy++;
|
|
127
|
+
break;
|
|
128
|
+
case PeerScoreState.Disconnect:
|
|
129
|
+
stateCounts.disconnect++;
|
|
130
|
+
break;
|
|
131
|
+
case PeerScoreState.Banned:
|
|
132
|
+
stateCounts.banned++;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.peerStateCounter.add(stateCounts.healthy, { [Attributes.P2P_PEER_SCORE_STATE]: 'Healthy' });
|
|
138
|
+
this.peerStateCounter.add(stateCounts.disconnect, { [Attributes.P2P_PEER_SCORE_STATE]: 'Disconnect' });
|
|
139
|
+
this.peerStateCounter.add(stateCounts.banned, { [Attributes.P2P_PEER_SCORE_STATE]: 'Banned' });
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
medianScore: median(Array.from(this.scores.values())) ?? 0,
|
|
143
|
+
healthyCount: stateCounts.healthy,
|
|
144
|
+
disconnectCount: stateCounts.disconnect,
|
|
145
|
+
bannedCount: stateCounts.banned,
|
|
146
|
+
};
|
|
104
147
|
}
|
|
105
148
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256 } from '@aztec/foundation/crypto';
|
|
2
|
+
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
6
|
|
|
7
7
|
import { StatusMessage } from './status.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
4
|
|
|
4
5
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -27,7 +28,7 @@ export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubPro
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
try {
|
|
30
|
-
const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
|
|
31
|
+
const foundBlock = await l2BlockSource.getBlock(BlockNumber(Number(blockNumber)));
|
|
31
32
|
return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
|
|
32
33
|
} catch (err: any) {
|
|
33
34
|
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, { cause: err });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -15,9 +16,9 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
15
16
|
export class StatusMessage {
|
|
16
17
|
constructor(
|
|
17
18
|
readonly compressedComponentsVersion: string,
|
|
18
|
-
readonly latestBlockNumber:
|
|
19
|
+
readonly latestBlockNumber: BlockNumber,
|
|
19
20
|
readonly latestBlockHash: string,
|
|
20
|
-
readonly finalizedBlockNumber:
|
|
21
|
+
readonly finalizedBlockNumber: BlockNumber,
|
|
21
22
|
//TODO: add finalizedBlockHash
|
|
22
23
|
//readonly finalizedBlockHash: string,
|
|
23
24
|
) {}
|
|
@@ -31,9 +32,9 @@ export class StatusMessage {
|
|
|
31
32
|
const reader = BufferReader.asReader(buffer);
|
|
32
33
|
return new StatusMessage(
|
|
33
34
|
reader.readString(), // compressedComponentsVersion
|
|
34
|
-
reader.readNumber(), // latestBlockNumber
|
|
35
|
+
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
35
36
|
reader.readString(), // latestBlockHash
|
|
36
|
-
reader.readNumber(), // finalizedBlockNumber
|
|
37
|
+
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
37
38
|
//TODO: add finalizedBlockHash
|
|
38
39
|
//reader.readString(), // finalizedBlockHash
|
|
39
40
|
);
|
|
@@ -63,9 +64,9 @@ export class StatusMessage {
|
|
|
63
64
|
static fromWorldStateSyncStatus(version: string, syncStatus: WorldStateSyncStatus): StatusMessage {
|
|
64
65
|
return new StatusMessage(
|
|
65
66
|
version,
|
|
66
|
-
syncStatus.latestBlockNumber,
|
|
67
|
+
BlockNumber(syncStatus.latestBlockNumber),
|
|
67
68
|
syncStatus.latestBlockHash,
|
|
68
|
-
syncStatus.finalizedBlockNumber,
|
|
69
|
+
BlockNumber(syncStatus.finalizedBlockNumber),
|
|
69
70
|
//TODO: add finalizedBlockHash
|
|
70
71
|
);
|
|
71
72
|
}
|
|
@@ -73,9 +74,9 @@ export class StatusMessage {
|
|
|
73
74
|
static random(): StatusMessage {
|
|
74
75
|
return new StatusMessage(
|
|
75
76
|
'1.0.0',
|
|
76
|
-
Math.floor(Math.random() * 100),
|
|
77
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
77
78
|
Buffer32.random().toString(),
|
|
78
|
-
Math.floor(Math.random() * 100),
|
|
79
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
79
80
|
//TODO: add finalizedBlockHash
|
|
80
81
|
);
|
|
81
82
|
}
|
|
@@ -489,7 +489,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
const messageData = Buffer.concat(chunks);
|
|
492
|
-
const message: Buffer = this.snappyTransform.
|
|
492
|
+
const message: Buffer = this.snappyTransform.inboundTransformData(messageData);
|
|
493
493
|
|
|
494
494
|
return {
|
|
495
495
|
status: status ?? ReqRespStatus.UNKNOWN,
|
|
@@ -618,7 +618,7 @@ export class ReqResp implements ReqRespInterface {
|
|
|
618
618
|
stream.metadata.written = true; // Mark the stream as written to;
|
|
619
619
|
|
|
620
620
|
yield SUCCESS;
|
|
621
|
-
yield snappy.
|
|
621
|
+
yield snappy.outboundTransformData(response);
|
|
622
622
|
}
|
|
623
623
|
},
|
|
624
624
|
stream.sink,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { times } from '@aztec/foundation/collection';
|
|
2
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
3
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -316,7 +317,7 @@ export class FastTxCollection {
|
|
|
316
317
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
317
318
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
318
319
|
*/
|
|
319
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
320
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
320
321
|
for (const request of this.requests) {
|
|
321
322
|
if (request.blockInfo.blockNumber <= blockNumber) {
|
|
322
323
|
request.promise.reject(new AbortError(`Stopped collecting txs up to block ${blockNumber}`));
|
|
@@ -329,7 +330,7 @@ export class FastTxCollection {
|
|
|
329
330
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
330
331
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
331
332
|
*/
|
|
332
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
333
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
333
334
|
for (const request of this.requests) {
|
|
334
335
|
if (request.blockInfo.blockNumber > blockNumber) {
|
|
335
336
|
request.promise.reject(new AbortError(`Stopped collecting txs after block ${blockNumber}`));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { chunk } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { boundInclusive } from '@aztec/foundation/number';
|
|
4
5
|
import { RunningPromise } from '@aztec/foundation/promise';
|
|
5
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
-
import type {
|
|
7
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
7
8
|
import { type L1RollupConstants, getEpochAtSlot, getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
|
8
9
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
9
10
|
|
|
@@ -75,7 +76,7 @@ export class SlowTxCollection {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/** Starts collecting the given tx hashes for the given L2Block in the slow loop */
|
|
78
|
-
public startCollecting(block:
|
|
79
|
+
public startCollecting(block: L2BlockNew, txHashes: TxHash[]) {
|
|
79
80
|
const slot = block.header.getSlot();
|
|
80
81
|
const deadline = this.getDeadlineForSlot(slot);
|
|
81
82
|
if (+deadline < this.dateProvider.now()) {
|
|
@@ -202,7 +203,7 @@ export class SlowTxCollection {
|
|
|
202
203
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
203
204
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
204
205
|
*/
|
|
205
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
206
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
206
207
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
207
208
|
if (info.blockNumber <= blockNumber) {
|
|
208
209
|
this.missingTxs.delete(txHash);
|
|
@@ -214,7 +215,7 @@ export class SlowTxCollection {
|
|
|
214
215
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
215
216
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
216
217
|
*/
|
|
217
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
218
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
218
219
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
219
220
|
if (info.blockNumber > blockNumber) {
|
|
220
221
|
this.missingTxs.delete(txHash);
|
|
@@ -223,9 +224,9 @@ export class SlowTxCollection {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
/** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
|
|
226
|
-
private getDeadlineForSlot(slotNumber:
|
|
227
|
+
private getDeadlineForSlot(slotNumber: SlotNumber): Date {
|
|
227
228
|
const epoch = getEpochAtSlot(slotNumber, this.constants);
|
|
228
|
-
const submissionEndEpoch = epoch +
|
|
229
|
+
const submissionEndEpoch = EpochNumber(epoch + this.constants.proofSubmissionEpochs);
|
|
229
230
|
const submissionEndTimestamp = getTimestampRangeForEpoch(submissionEndEpoch, this.constants)[1];
|
|
230
231
|
return new Date(Number(submissionEndTimestamp) * 1000);
|
|
231
232
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { type PromiseWithResolvers, RunningPromise } from '@aztec/foundation/promise';
|
|
4
5
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type {
|
|
6
|
+
import type { L2BlockInfo, L2BlockNew } from '@aztec/stdlib/block';
|
|
6
7
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
7
8
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
8
9
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -21,11 +22,11 @@ import type { TxSource } from './tx_source.js';
|
|
|
21
22
|
|
|
22
23
|
export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | 'slow-req-resp' | 'slow-node-rpc';
|
|
23
24
|
|
|
24
|
-
export type MissingTxInfo = { blockNumber:
|
|
25
|
+
export type MissingTxInfo = { blockNumber: BlockNumber; deadline: Date; readyForReqResp: boolean };
|
|
25
26
|
|
|
26
27
|
export type FastCollectionRequestInput =
|
|
27
|
-
| { type: 'block'; block:
|
|
28
|
-
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber:
|
|
28
|
+
| { type: 'block'; block: L2BlockNew }
|
|
29
|
+
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
|
|
29
30
|
|
|
30
31
|
export type FastCollectionRequest = FastCollectionRequestInput & {
|
|
31
32
|
missingTxHashes: Set<string>;
|
|
@@ -145,14 +146,14 @@ export class TxCollection {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
/** Starts collecting the given tx hashes for the given L2Block in the slow loop */
|
|
148
|
-
public startCollecting(block:
|
|
149
|
+
public startCollecting(block: L2BlockNew, txHashes: TxHash[]) {
|
|
149
150
|
return this.slowCollection.startCollecting(block, txHashes);
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
/** Collects the set of txs for the given block proposal as fast as possible */
|
|
153
154
|
public collectFastForProposal(
|
|
154
155
|
blockProposal: BlockProposal,
|
|
155
|
-
blockNumber:
|
|
156
|
+
blockNumber: BlockNumber,
|
|
156
157
|
txHashes: TxHash[] | string[],
|
|
157
158
|
opts: { deadline: Date; pinnedPeer?: PeerId },
|
|
158
159
|
) {
|
|
@@ -161,7 +162,7 @@ export class TxCollection {
|
|
|
161
162
|
|
|
162
163
|
/** Collects the set of txs for the given mined block as fast as possible */
|
|
163
164
|
public collectFastForBlock(
|
|
164
|
-
block:
|
|
165
|
+
block: L2BlockNew,
|
|
165
166
|
txHashes: TxHash[] | string[],
|
|
166
167
|
opts: { deadline: Date; pinnedPeer?: PeerId },
|
|
167
168
|
) {
|
|
@@ -187,7 +188,7 @@ export class TxCollection {
|
|
|
187
188
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
188
189
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
189
190
|
*/
|
|
190
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
191
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
191
192
|
this.slowCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
192
193
|
this.fastCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
193
194
|
}
|
|
@@ -196,7 +197,7 @@ export class TxCollection {
|
|
|
196
197
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
197
198
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
198
199
|
*/
|
|
199
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
200
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
200
201
|
this.slowCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
201
202
|
this.fastCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
202
203
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { elapsed } from '@aztec/foundation/timer';
|
|
4
|
-
import type {
|
|
5
|
+
import type { L2BlockInfo, L2BlockNew } from '@aztec/stdlib/block';
|
|
5
6
|
import type { ITxProvider } from '@aztec/stdlib/interfaces/server';
|
|
6
7
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
7
8
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -55,7 +56,7 @@ export class TxProvider implements ITxProvider {
|
|
|
55
56
|
/** Gathers txs from the tx pool, proposal body, remote rpc nodes, and reqresp. */
|
|
56
57
|
public getTxsForBlockProposal(
|
|
57
58
|
blockProposal: BlockProposal,
|
|
58
|
-
blockNumber:
|
|
59
|
+
blockNumber: BlockNumber,
|
|
59
60
|
opts: { pinnedPeer: PeerId | undefined; deadline: Date },
|
|
60
61
|
): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
61
62
|
return this.getOrderedTxsFromAllSources(
|
|
@@ -67,7 +68,7 @@ export class TxProvider implements ITxProvider {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/** Gathers txs from the tx pool, remote rpc nodes, and reqresp. */
|
|
70
|
-
public getTxsForBlock(block:
|
|
71
|
+
public getTxsForBlock(block: L2BlockNew, opts: { deadline: Date }): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
71
72
|
return this.getOrderedTxsFromAllSources(
|
|
72
73
|
{ type: 'block', block },
|
|
73
74
|
block.toBlockInfo(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
3
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
4
4
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { MockL2BlockSource } from '@aztec/archiver/test';
|
|
7
7
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
8
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
10
11
|
import { sleep } from '@aztec/foundation/sleep';
|
|
@@ -52,6 +53,7 @@ function mockTxPool(): TxPool {
|
|
|
52
53
|
getTxStatus: () => Promise.resolve(TxStatus.PENDING),
|
|
53
54
|
getTxsByHash: () => Promise.resolve([]),
|
|
54
55
|
hasTxs: () => Promise.resolve([]),
|
|
56
|
+
hasTx: () => Promise.resolve(false),
|
|
55
57
|
updateConfig: () => {},
|
|
56
58
|
markTxsAsNonEvictable: () => Promise.resolve(),
|
|
57
59
|
cleanupDeletedMinedTxs: () => Promise.resolve(0),
|
|
@@ -71,23 +73,27 @@ function mockAttestationPool(): AttestationPool {
|
|
|
71
73
|
getAttestationsForSlotAndProposal: () => Promise.resolve([]),
|
|
72
74
|
addBlockProposal: () => Promise.resolve(),
|
|
73
75
|
getBlockProposal: () => Promise.resolve(undefined),
|
|
76
|
+
hasBlockProposal: () => Promise.resolve(false),
|
|
77
|
+
hasAttestation: () => Promise.resolve(false),
|
|
78
|
+
canAddProposal: () => Promise.resolve(true),
|
|
79
|
+
canAddAttestation: () => Promise.resolve(true),
|
|
74
80
|
};
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
function mockEpochCache(): EpochCacheInterface {
|
|
78
84
|
return {
|
|
79
|
-
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch:
|
|
85
|
+
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO }),
|
|
80
86
|
getProposerIndexEncoding: () => '0x' as `0x${string}`,
|
|
81
|
-
getEpochAndSlotNow: () => ({ epoch:
|
|
87
|
+
getEpochAndSlotNow: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n }),
|
|
82
88
|
computeProposerIndex: () => 0n,
|
|
83
89
|
getProposerAttesterAddressInCurrentOrNextSlot: () =>
|
|
84
90
|
Promise.resolve({
|
|
85
91
|
currentProposer: EthAddress.ZERO,
|
|
86
92
|
nextProposer: EthAddress.ZERO,
|
|
87
|
-
currentSlot:
|
|
88
|
-
nextSlot:
|
|
93
|
+
currentSlot: SlotNumber.ZERO,
|
|
94
|
+
nextSlot: SlotNumber.ZERO,
|
|
89
95
|
}),
|
|
90
|
-
getEpochAndSlotInNextL1Slot: () => ({ epoch:
|
|
96
|
+
getEpochAndSlotInNextL1Slot: () => ({ epoch: EpochNumber.ZERO, slot: SlotNumber.ZERO, ts: 0n, now: 0n }),
|
|
91
97
|
isInCommittee: () => Promise.resolve(false),
|
|
92
98
|
getRegisteredValidators: () => Promise.resolve([]),
|
|
93
99
|
filterInCommittee: () => Promise.resolve([]),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { sleep } from '@aztec/foundation/sleep';
|
|
3
|
-
import {
|
|
3
|
+
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
4
4
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
5
5
|
|
|
6
6
|
import assert from 'assert';
|
|
@@ -35,7 +35,7 @@ async function main() {
|
|
|
35
35
|
|
|
36
36
|
// Send tx from client 0
|
|
37
37
|
const tx = await mockTx(1, {
|
|
38
|
-
|
|
38
|
+
chonkProof: ChonkProof.random(),
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
workerClientManager.processes[0].send({ type: 'SEND_TX', tx: tx.toBuffer() });
|
package/src/util.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { createFromPrivKey } from '@libp2p/peer-id-factory';
|
|
|
12
12
|
import { resolve } from 'dns/promises';
|
|
13
13
|
import { promises as fs } from 'fs';
|
|
14
14
|
import type { Libp2p } from 'libp2p';
|
|
15
|
+
import net from 'net';
|
|
15
16
|
import path from 'path';
|
|
16
17
|
|
|
17
18
|
import type { P2PConfig } from './config.js';
|
|
@@ -56,9 +57,18 @@ export function convertToMultiaddr(address: string, port: number, protocol: 'tcp
|
|
|
56
57
|
* Queries the public IP address of the machine.
|
|
57
58
|
*/
|
|
58
59
|
export async function getPublicIp(): Promise<string> {
|
|
59
|
-
const resp = await fetch('
|
|
60
|
+
const resp = await fetch('https://checkip.amazonaws.com/');
|
|
60
61
|
const text = await resp.text();
|
|
61
|
-
|
|
62
|
+
const address = text.trim();
|
|
63
|
+
if (!isValidIpAddress(address)) {
|
|
64
|
+
throw new Error(`Received invalid IP address from checkip service: ${address}`);
|
|
65
|
+
}
|
|
66
|
+
return address;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isValidIpAddress(address: string): boolean {
|
|
70
|
+
const netType = net.isIP(address);
|
|
71
|
+
return netType === 4;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
export async function resolveAddressIfNecessary(address: string, port: string): Promise<string> {
|