@aztec/p2p 0.80.0 → 0.81.0
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.map +1 -1
- package/dest/bootstrap/bootstrap.js +5 -5
- package/dest/client/p2p_client.d.ts +2 -1
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +14 -3
- package/dest/config.d.ts +11 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +13 -17
- package/dest/enr/generate-enr.d.ts +1 -1
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +2 -2
- 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 +13 -7
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +5 -5
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/discv5/discV5_service.d.ts +4 -3
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +36 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +8 -11
- package/dest/test-helpers/make-enrs.d.ts.map +1 -1
- package/dest/test-helpers/make-enrs.js +3 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +2 -6
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +7 -8
- package/dest/testbench/worker_client_manager.d.ts +0 -4
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +3 -13
- package/dest/types/index.d.ts +2 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +1 -0
- package/dest/util.d.ts +2 -7
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +12 -57
- package/package.json +10 -10
- package/src/bootstrap/bootstrap.ts +6 -5
- package/src/client/p2p_client.ts +24 -6
- package/src/config.ts +24 -32
- package/src/enr/generate-enr.ts +3 -2
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +12 -7
- package/src/msg_validators/tx_validator/data_validator.ts +9 -7
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -2
- package/src/services/discv5/discV5_service.ts +36 -23
- package/src/services/libp2p/libp2p_service.ts +8 -9
- package/src/test-helpers/make-enrs.ts +3 -4
- package/src/test-helpers/make-test-p2p-clients.ts +2 -7
- package/src/test-helpers/reqresp-nodes.ts +6 -7
- package/src/testbench/worker_client_manager.ts +8 -17
- package/src/types/index.ts +1 -0
- package/src/util.ts +12 -72
|
@@ -20,10 +20,9 @@ import { setAztecEnrKey } from '../versioning.js';
|
|
|
20
20
|
*/ export async function makeEnr(p2pPrivateKey, port, config) {
|
|
21
21
|
const peerId = await createLibP2PPeerIdFromPrivateKey(p2pPrivateKey);
|
|
22
22
|
const enr = SignableENR.createFromPeerId(peerId);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const tcpPublicAddr = multiaddr(convertToMultiaddr(tcpAnnounceAddress, 'tcp'));
|
|
23
|
+
const p2pIp = `127.0.0.1`;
|
|
24
|
+
const udpPublicAddr = multiaddr(convertToMultiaddr(p2pIp, port, 'udp'));
|
|
25
|
+
const tcpPublicAddr = multiaddr(convertToMultiaddr(p2pIp, port, 'tcp'));
|
|
27
26
|
// ENRS must include the network and a discoverable address (udp for discv5)
|
|
28
27
|
setAztecEnrKey(enr, config);
|
|
29
28
|
enr.setLocationMultiaddr(udpPublicAddr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-test-p2p-clients.d.ts","sourceRoot":"","sources":["../../src/test-helpers/make-test-p2p-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM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M,iCAAiC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAM5D,UAAU,wBAAwB;IAChC,mBAAmB,EAAE,eAAe,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,UAAU,CAAC;IAC3B,cAAc,EAAE,sBAAsB,CAAC;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,EAAE,SAAS,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EAAE,EACf,EACE,kBAAyB,EACzB,aAAa,EACb,kBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,cAAc,EACd,MAAwC,GACzC,EAAE,wBAAwB,0CAyC5B;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,4CAiBnG"}
|
|
@@ -15,17 +15,13 @@ import { AlwaysFalseCircuitVerifier, AlwaysTrueCircuitVerifier } from './reqresp
|
|
|
15
15
|
* @param options - The options for the client.
|
|
16
16
|
* @returns The created client.
|
|
17
17
|
*/ export async function makeTestP2PClient(peerIdPrivateKey, port, peers, { alwaysTrueVerifier = true, p2pBaseConfig, p2pConfigOverrides = {}, mockAttestationPool, mockTxPool, mockEpochCache, mockWorldState, logger = createLogger('p2p-test-client') }) {
|
|
18
|
-
const addr = `127.0.0.1:${port}`;
|
|
19
|
-
const listenAddr = `0.0.0.0:${port}`;
|
|
20
18
|
// Filter nodes so that we only dial active peers
|
|
21
19
|
const config = {
|
|
22
20
|
...p2pBaseConfig,
|
|
23
21
|
p2pEnabled: true,
|
|
24
22
|
peerIdPrivateKey,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tcpAnnounceAddress: addr,
|
|
28
|
-
udpAnnounceAddress: addr,
|
|
23
|
+
p2pIp: `127.0.0.1`,
|
|
24
|
+
p2pPort: port,
|
|
29
25
|
bootstrapNodes: peers,
|
|
30
26
|
peerCheckIntervalMS: 1000,
|
|
31
27
|
maxPeerCount: 10,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqresp-nodes.d.ts","sourceRoot":"","sources":["../../src/test-helpers/reqresp-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,EAAE,KAAK,MAAM,EAAoC,MAAM,QAAQ,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,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BAOzE;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,eAAsC,EACjD,WAAW,GAAE,WAA8B,GAC1C,OAAO,CAAC,aAAa,CAAC,CAKxB"}
|
|
@@ -76,10 +76,8 @@ import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js
|
|
|
76
76
|
*/ export async function createTestLibP2PService(clientType, boostrapAddrs = [], l2BlockSource, worldStateSynchronizer, epochCache, mempools, telemetry, port = 0, peerId, chainConfig = emptyChainConfig) {
|
|
77
77
|
peerId = peerId ?? await createSecp256k1PeerId();
|
|
78
78
|
const config = {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
tcpListenAddress: `0.0.0.0:${port}`,
|
|
82
|
-
udpListenAddress: `0.0.0.0:${port}`,
|
|
79
|
+
p2pIp: `127.0.0.1`,
|
|
80
|
+
p2pPort: port,
|
|
83
81
|
bootstrapNodes: boostrapAddrs,
|
|
84
82
|
peerCheckIntervalMS: 1000,
|
|
85
83
|
maxPeerCount: 5,
|
|
@@ -169,12 +167,13 @@ export class AlwaysFalseCircuitVerifier {
|
|
|
169
167
|
export function createBootstrapNodeConfig(privateKey, port, chainConfig) {
|
|
170
168
|
return {
|
|
171
169
|
l1ChainId: chainConfig.l1ChainId,
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
p2pIp: '127.0.0.1',
|
|
171
|
+
p2pPort: port,
|
|
174
172
|
peerIdPrivateKey: privateKey,
|
|
175
173
|
dataDirectory: undefined,
|
|
176
174
|
dataStoreMapSizeKB: 0,
|
|
177
|
-
bootstrapNodes: []
|
|
175
|
+
bootstrapNodes: [],
|
|
176
|
+
listenAddress: '0.0.0.0'
|
|
178
177
|
};
|
|
179
178
|
}
|
|
180
179
|
export function createBootstrapNodeFromPrivateKey(privateKey, port, telemetry = getTelemetryClient(), chainConfig = emptyChainConfig) {
|
|
@@ -189,7 +188,7 @@ export function createBootstrapNodeFromPrivateKey(privateKey, port, telemetry =
|
|
|
189
188
|
*/ export async function getBootstrapNodeEnr(privateKey, port) {
|
|
190
189
|
const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
|
|
191
190
|
const enr = SignableENR.createFromPeerId(peerId);
|
|
192
|
-
const listenAddrUdp = multiaddr(convertToMultiaddr(
|
|
191
|
+
const listenAddrUdp = multiaddr(convertToMultiaddr('127.0.0.1', port, 'udp'));
|
|
193
192
|
enr.setLocationMultiaddr(listenAddrUdp);
|
|
194
193
|
return enr;
|
|
195
194
|
}
|
|
@@ -14,10 +14,6 @@ declare class WorkerClientManager {
|
|
|
14
14
|
private messageReceivedByClient;
|
|
15
15
|
constructor(logger: Logger, p2pConfig: Partial<P2PConfig>);
|
|
16
16
|
destroy(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Creates address strings from a port
|
|
19
|
-
*/
|
|
20
|
-
private getAddresses;
|
|
21
17
|
/**
|
|
22
18
|
* Creates a client configuration object
|
|
23
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker_client_manager.d.ts","sourceRoot":"","sources":["../../src/testbench/worker_client_manager.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,KAAK,YAAY,EAAQ,MAAM,eAAe,CAAC;AAIxD,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,cAAc,CAAC;AAQnE,QAAA,MAAM,eAAe,EAAE,WAMtB,CAAC;AAEF,cAAM,mBAAmB;IAChB,SAAS,EAAE,YAAY,EAAE,CAAM;IAC/B,iBAAiB,EAAE,MAAM,EAAE,CAAM;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAM;IACxB,KAAK,EAAE,MAAM,EAAE,CAAM;IAC5B,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,uBAA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WorkerClientManager {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Creates address strings from a port
|
|
39
|
-
*/ getAddresses(port) {
|
|
40
|
-
return {
|
|
41
|
-
addr: `127.0.0.1:${port}`,
|
|
42
|
-
listenAddr: `0.0.0.0:${port}`
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
38
|
* Creates a client configuration object
|
|
47
39
|
*/ createClientConfig(clientIndex, port, otherNodes) {
|
|
48
|
-
const { addr, listenAddr } = this.getAddresses(port);
|
|
49
40
|
return {
|
|
50
41
|
...getP2PDefaultConfig(),
|
|
51
42
|
p2pEnabled: true,
|
|
52
43
|
peerIdPrivateKey: this.peerIdPrivateKeys[clientIndex],
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
udpAnnounceAddress: addr,
|
|
44
|
+
listenAddress: '127.0.0.1',
|
|
45
|
+
p2pIp: '127.0.0.1',
|
|
46
|
+
p2pPort: port,
|
|
57
47
|
bootstrapNodes: [
|
|
58
48
|
...otherNodes
|
|
59
49
|
],
|
package/dest/types/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare enum PeerEvent {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare enum Discv5Event {
|
|
16
16
|
DISCOVERED = "discovered",
|
|
17
|
-
ENR_ADDED = "enrAdded"
|
|
17
|
+
ENR_ADDED = "enrAdded",
|
|
18
|
+
MULTIADDR_UPDATED = "multiaddrUpdated"
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Events emitted from the GossipSub protocol.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;qDAEqD;AAErD;;GAEG;AACH,oBAAY,SAAS;IACnB,UAAU,oBAAoB;IAC9B,SAAS,iBAAiB;IAC1B,YAAY,oBAAoB;CACjC;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,SAAS,aAAa;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;qDAEqD;AAErD;;GAEG;AACH,oBAAY,SAAS;IACnB,UAAU,oBAAoB;IAC9B,SAAS,iBAAiB;IAC1B,YAAY,oBAAoB;CACjC;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,SAAS,aAAa;IACtB,iBAAiB,qBAAqB;CACvC;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,OAAO,sBAAsB;CAC9B;AAED;;qDAEqD;AAErD;;GAEG;AACH,eAAO,MAAM,aAAa,UAAU,CAAC"}
|
package/dest/types/index.js
CHANGED
package/dest/util.d.ts
CHANGED
|
@@ -21,17 +21,12 @@ export interface PubSubLibp2p extends Libp2p {
|
|
|
21
21
|
* @param address - The address string to convert. Has to be in the format <addr>:<port>.
|
|
22
22
|
* @param protocol - The protocol to use in the multiaddr string.
|
|
23
23
|
* @returns A multiaddr compliant string. */
|
|
24
|
-
export declare function convertToMultiaddr(address: string, protocol: 'tcp' | 'udp'): string;
|
|
25
|
-
/**
|
|
26
|
-
* Splits an <address>:<port> string into its components.
|
|
27
|
-
* @returns The ip6 or ip4 address & port separately
|
|
28
|
-
*/
|
|
29
|
-
export declare function splitAddressPort(address: string, allowEmptyAddress: boolean): [string, string];
|
|
24
|
+
export declare function convertToMultiaddr(address: string, port: number, protocol: 'tcp' | 'udp'): string;
|
|
30
25
|
/**
|
|
31
26
|
* Queries the public IP address of the machine.
|
|
32
27
|
*/
|
|
33
28
|
export declare function getPublicIp(): Promise<string>;
|
|
34
|
-
export declare function resolveAddressIfNecessary(address: string): Promise<string>;
|
|
29
|
+
export declare function resolveAddressIfNecessary(address: string, port: string): Promise<string>;
|
|
35
30
|
export declare function configureP2PClientAddresses(_config: P2PConfig & DataStoreConfig): Promise<P2PConfig & DataStoreConfig>;
|
|
36
31
|
/**
|
|
37
32
|
* Get the peer id private key
|
package/dest/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,QAAQ,EAAE;QACR,MAAM,EAAE,SAAS,CAAC;QAClB,UAAU,EAAE;YACV,iBAAiB,EAAE,iBAAiB,CAAC;SACtC,CAAC;KACH,CAAC;CACH;AAED;;;;;;;6CAO6C;AAC7C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,QAAQ,EAAE;QACR,MAAM,EAAE,SAAS,CAAC;QAClB,UAAU,EAAE;YACV,iBAAiB,EAAE,iBAAiB,CAAC;SACtC,CAAC;KACH,CAAC;CACH;AAED;;;;;;;6CAO6C;AAC7C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAOjG;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAInD;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9F;AAcD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,SAAS,GAAG,eAAe,GACnC,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC,CActC;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS1F"}
|
package/dest/util.js
CHANGED
|
@@ -8,38 +8,12 @@ import { resolve } from 'dns/promises';
|
|
|
8
8
|
* const udpAddr = '[2001:db8::1]:8080' -> /ip6/2001:db8::1/udp/8080
|
|
9
9
|
* @param address - The address string to convert. Has to be in the format <addr>:<port>.
|
|
10
10
|
* @param protocol - The protocol to use in the multiaddr string.
|
|
11
|
-
* @returns A multiaddr compliant string. */ export function convertToMultiaddr(address, protocol) {
|
|
12
|
-
const
|
|
13
|
-
const multiaddrPrefix = addressToMultiAddressType(addr);
|
|
11
|
+
* @returns A multiaddr compliant string. */ export function convertToMultiaddr(address, port, protocol) {
|
|
12
|
+
const multiaddrPrefix = addressToMultiAddressType(address);
|
|
14
13
|
if (multiaddrPrefix === 'dns') {
|
|
15
14
|
throw new Error('Invalid address format. Expected an IPv4 or IPv6 address.');
|
|
16
15
|
}
|
|
17
|
-
return `/${multiaddrPrefix}/${
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Splits an <address>:<port> string into its components.
|
|
21
|
-
* @returns The ip6 or ip4 address & port separately
|
|
22
|
-
*/ export function splitAddressPort(address, allowEmptyAddress) {
|
|
23
|
-
let addr;
|
|
24
|
-
let port;
|
|
25
|
-
if (address.startsWith('[')) {
|
|
26
|
-
// IPv6 address enclosed in square brackets
|
|
27
|
-
const match = address.match(/^\[([^\]]+)\]:(\d+)$/);
|
|
28
|
-
if (!match) {
|
|
29
|
-
throw new Error(`Invalid IPv6 address format:${address}. Expected format: [<addr>]:<port>`);
|
|
30
|
-
}
|
|
31
|
-
[, addr, port] = match;
|
|
32
|
-
} else {
|
|
33
|
-
// IPv4 address
|
|
34
|
-
[addr, port] = address.split(':');
|
|
35
|
-
if (!addr && !allowEmptyAddress || !port) {
|
|
36
|
-
throw new Error(`Invalid address format: ${address}. Expected format: <addr>:<port>`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return [
|
|
40
|
-
addr,
|
|
41
|
-
port
|
|
42
|
-
];
|
|
16
|
+
return `/${multiaddrPrefix}/${address}/${protocol}/${port}`;
|
|
43
17
|
}
|
|
44
18
|
/**
|
|
45
19
|
* Queries the public IP address of the machine.
|
|
@@ -48,13 +22,12 @@ import { resolve } from 'dns/promises';
|
|
|
48
22
|
const text = await resp.text();
|
|
49
23
|
return text.trim();
|
|
50
24
|
}
|
|
51
|
-
export async function resolveAddressIfNecessary(address) {
|
|
52
|
-
const
|
|
53
|
-
const multiaddrPrefix = addressToMultiAddressType(addr);
|
|
25
|
+
export async function resolveAddressIfNecessary(address, port) {
|
|
26
|
+
const multiaddrPrefix = addressToMultiAddressType(address);
|
|
54
27
|
if (multiaddrPrefix === 'dns') {
|
|
55
|
-
const resolvedAddresses = await resolve(
|
|
28
|
+
const resolvedAddresses = await resolve(address);
|
|
56
29
|
if (resolvedAddresses.length === 0) {
|
|
57
|
-
throw new Error(`Could not resolve address: ${
|
|
30
|
+
throw new Error(`Could not resolve address: ${address}`);
|
|
58
31
|
}
|
|
59
32
|
return `${resolvedAddresses[0]}:${port}`;
|
|
60
33
|
} else {
|
|
@@ -76,33 +49,15 @@ export async function configureP2PClientAddresses(_config) {
|
|
|
76
49
|
const config = {
|
|
77
50
|
..._config
|
|
78
51
|
};
|
|
79
|
-
const {
|
|
80
|
-
config.tcpAnnounceAddress = configTcpAnnounceAddress ? await resolveAddressIfNecessary(configTcpAnnounceAddress) : undefined;
|
|
81
|
-
config.udpAnnounceAddress = configUdpAnnounceAddress ? await resolveAddressIfNecessary(configUdpAnnounceAddress) : undefined;
|
|
82
|
-
// create variable for re-use if needed
|
|
83
|
-
let publicIp;
|
|
52
|
+
const { p2pIp, queryForIp } = config;
|
|
84
53
|
// check if no announce IP was provided
|
|
85
|
-
|
|
86
|
-
if (splitTcpAnnounceAddress.length == 2 && splitTcpAnnounceAddress[0] === '') {
|
|
54
|
+
if (!p2pIp) {
|
|
87
55
|
if (queryForIp) {
|
|
88
|
-
publicIp = await getPublicIp();
|
|
89
|
-
|
|
90
|
-
config.tcpAnnounceAddress = tcpAnnounceAddress;
|
|
91
|
-
} else {
|
|
92
|
-
throw new Error(`Invalid announceTcpAddress provided: ${configTcpAnnounceAddress}. Expected format: <addr>:<port>`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const splitUdpAnnounceAddress = splitAddressPort(configUdpAnnounceAddress || '', true);
|
|
96
|
-
if (splitUdpAnnounceAddress.length == 2 && splitUdpAnnounceAddress[0] === '') {
|
|
97
|
-
// If announceUdpAddress is not provided, use announceTcpAddress
|
|
98
|
-
if (!queryForIp && config.tcpAnnounceAddress) {
|
|
99
|
-
config.udpAnnounceAddress = config.tcpAnnounceAddress;
|
|
100
|
-
} else if (queryForIp) {
|
|
101
|
-
const udpPublicIp = publicIp || await getPublicIp();
|
|
102
|
-
const udpAnnounceAddress = `${udpPublicIp}:${splitUdpAnnounceAddress[1]}`;
|
|
103
|
-
config.udpAnnounceAddress = udpAnnounceAddress;
|
|
56
|
+
const publicIp = await getPublicIp();
|
|
57
|
+
config.p2pIp = publicIp;
|
|
104
58
|
}
|
|
105
59
|
}
|
|
60
|
+
// TODO(md): guard against setting a local ip address as the announce ip
|
|
106
61
|
return config;
|
|
107
62
|
}
|
|
108
63
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/constants": "0.
|
|
69
|
-
"@aztec/epoch-cache": "0.
|
|
70
|
-
"@aztec/foundation": "0.
|
|
71
|
-
"@aztec/kv-store": "0.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
73
|
-
"@aztec/protocol-contracts": "0.
|
|
74
|
-
"@aztec/stdlib": "0.
|
|
75
|
-
"@aztec/telemetry-client": "0.
|
|
68
|
+
"@aztec/constants": "0.81.0",
|
|
69
|
+
"@aztec/epoch-cache": "0.81.0",
|
|
70
|
+
"@aztec/foundation": "0.81.0",
|
|
71
|
+
"@aztec/kv-store": "0.81.0",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.81.0",
|
|
73
|
+
"@aztec/protocol-contracts": "0.81.0",
|
|
74
|
+
"@aztec/stdlib": "0.81.0",
|
|
75
|
+
"@aztec/telemetry-client": "0.81.0",
|
|
76
76
|
"@chainsafe/discv5": "9.0.0",
|
|
77
77
|
"@chainsafe/enr": "3.0.0",
|
|
78
78
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"xxhash-wasm": "^1.1.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@aztec/archiver": "0.
|
|
104
|
+
"@aztec/archiver": "0.81.0",
|
|
105
105
|
"@jest/globals": "^29.5.0",
|
|
106
106
|
"@types/jest": "^29.5.0",
|
|
107
107
|
"@types/node": "^18.14.6",
|
|
@@ -31,18 +31,19 @@ export class BootstrapNode implements P2PBootstrapApi {
|
|
|
31
31
|
* @returns An empty promise.
|
|
32
32
|
*/
|
|
33
33
|
public async start(config: BootnodeConfig) {
|
|
34
|
-
const {
|
|
35
|
-
const listenAddrUdp = multiaddr(convertToMultiaddr(
|
|
34
|
+
const { p2pIp, p2pPort, listenAddress } = config;
|
|
35
|
+
const listenAddrUdp = multiaddr(convertToMultiaddr(listenAddress, p2pPort, 'udp'));
|
|
36
36
|
|
|
37
|
-
if (!
|
|
38
|
-
throw new Error('You need to provide a
|
|
37
|
+
if (!p2pIp) {
|
|
38
|
+
throw new Error('You need to provide a P2P IP address.');
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, this.store);
|
|
42
42
|
|
|
43
43
|
const { enr: ourEnr, peerId } = await createBootnodeENRandPeerId(
|
|
44
44
|
peerIdPrivateKey,
|
|
45
|
-
|
|
45
|
+
p2pIp,
|
|
46
|
+
p2pPort,
|
|
46
47
|
config.l1ChainId,
|
|
47
48
|
);
|
|
48
49
|
this.peerId = peerId;
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
L2Block,
|
|
6
|
+
L2BlockId,
|
|
7
|
+
L2BlockSource,
|
|
8
|
+
L2BlockStreamEvent,
|
|
9
|
+
L2Tips,
|
|
10
|
+
PublishedL2Block,
|
|
11
|
+
} from '@aztec/stdlib/block';
|
|
5
12
|
import type { P2PApi, PeerInfo, ProverCoordination } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import
|
|
13
|
+
import { BlockAttestation, type BlockProposal, ConsensusPayload, type P2PClientType } from '@aztec/stdlib/p2p';
|
|
7
14
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
8
15
|
import {
|
|
9
16
|
Attributes,
|
|
@@ -617,6 +624,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
617
624
|
}
|
|
618
625
|
}
|
|
619
626
|
|
|
627
|
+
private async addAttestationsToPool(blocks: PublishedL2Block[]): Promise<void> {
|
|
628
|
+
const attestations = blocks.flatMap(block => {
|
|
629
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
630
|
+
return block.signatures.filter(sig => !sig.isEmpty).map(signature => new BlockAttestation(payload, signature));
|
|
631
|
+
});
|
|
632
|
+
await this.attestationPool?.addAttestations(attestations);
|
|
633
|
+
const slots = blocks.map(b => b.block.header.getSlot()).sort((a, b) => Number(a - b));
|
|
634
|
+
this.log.debug(`Added ${attestations.length} attestations for slots ${slots[0]}-${slots.at(-1)} to the pool`);
|
|
635
|
+
}
|
|
636
|
+
|
|
620
637
|
/**
|
|
621
638
|
* Deletes txs from these blocks.
|
|
622
639
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
@@ -635,15 +652,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
635
652
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
636
653
|
* @returns Empty promise.
|
|
637
654
|
*/
|
|
638
|
-
private async handleLatestL2Blocks(blocks:
|
|
655
|
+
private async handleLatestL2Blocks(blocks: PublishedL2Block[]): Promise<void> {
|
|
639
656
|
if (!blocks.length) {
|
|
640
657
|
return Promise.resolve();
|
|
641
658
|
}
|
|
642
659
|
|
|
643
|
-
await this.markTxsAsMinedFromBlocks(blocks);
|
|
644
|
-
|
|
660
|
+
await this.markTxsAsMinedFromBlocks(blocks.map(b => b.block));
|
|
661
|
+
await this.addAttestationsToPool(blocks);
|
|
662
|
+
const lastBlockNum = blocks.at(-1)!.block.number;
|
|
645
663
|
await Promise.all(
|
|
646
|
-
blocks.map(async block => this.synchedBlockHashes.set(block.number, (await block.hash()).toString())),
|
|
664
|
+
blocks.map(async block => this.synchedBlockHashes.set(block.block.number, (await block.block.hash()).toString())),
|
|
647
665
|
);
|
|
648
666
|
await this.synchedLatestBlockNumber.set(lastBlockNum);
|
|
649
667
|
this.log.verbose(`Synched to latest block ${lastBlockNum}`);
|
package/src/config.ts
CHANGED
|
@@ -46,24 +46,19 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
|
|
|
46
46
|
l2QueueSize: number;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* The
|
|
49
|
+
* The port for the P2P service.
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
p2pPort: number;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* The
|
|
54
|
+
* The IP address for the P2P service.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
p2pIp?: string;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* The listen address
|
|
59
|
+
* The listen address.
|
|
60
60
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The listen address for UDP.
|
|
65
|
-
*/
|
|
66
|
-
udpListenAddress: string;
|
|
61
|
+
listenAddress: string;
|
|
67
62
|
|
|
68
63
|
/**
|
|
69
64
|
* An optional peer id private key. If blank, will generate a random key.
|
|
@@ -197,25 +192,19 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
197
192
|
description: 'Size of queue of L2 blocks to store.',
|
|
198
193
|
...numberConfigHelper(1_000),
|
|
199
194
|
},
|
|
200
|
-
|
|
201
|
-
env: '
|
|
202
|
-
defaultValue: '0.0.0.0
|
|
203
|
-
description: 'The listen address
|
|
195
|
+
listenAddress: {
|
|
196
|
+
env: 'P2P_LISTEN_ADDR',
|
|
197
|
+
defaultValue: '0.0.0.0',
|
|
198
|
+
description: 'The listen address. ipv4 address.',
|
|
204
199
|
},
|
|
205
|
-
|
|
206
|
-
env: '
|
|
207
|
-
|
|
208
|
-
|
|
200
|
+
p2pPort: {
|
|
201
|
+
env: 'P2P_PORT',
|
|
202
|
+
description: 'The port for the P2P service.',
|
|
203
|
+
...numberConfigHelper(40400),
|
|
209
204
|
},
|
|
210
|
-
|
|
211
|
-
env: '
|
|
212
|
-
description:
|
|
213
|
-
'The announce address for TCP. Format: <IP_ADDRESS>:<PORT>. Leave IP_ADDRESS blank to query for public IP.',
|
|
214
|
-
},
|
|
215
|
-
udpAnnounceAddress: {
|
|
216
|
-
env: 'P2P_UDP_ANNOUNCE_ADDR',
|
|
217
|
-
description:
|
|
218
|
-
'The announce address for UDP. Format: <IP_ADDRESS>:<PORT>. Leave IP_ADDRESS blank to query for public IP.',
|
|
205
|
+
p2pIp: {
|
|
206
|
+
env: 'P2P_IP',
|
|
207
|
+
description: 'The IP address for the P2P service. ipv4 address.',
|
|
219
208
|
},
|
|
220
209
|
peerIdPrivateKey: {
|
|
221
210
|
env: 'PEER_ID_PRIVATE_KEY',
|
|
@@ -361,15 +350,18 @@ export function getP2PDefaultConfig(): P2PConfig {
|
|
|
361
350
|
/**
|
|
362
351
|
* Required P2P config values for a bootstrap node.
|
|
363
352
|
*/
|
|
364
|
-
export type BootnodeConfig = Pick<
|
|
365
|
-
|
|
353
|
+
export type BootnodeConfig = Pick<
|
|
354
|
+
P2PConfig,
|
|
355
|
+
'p2pIp' | 'p2pPort' | 'peerIdPrivateKey' | 'bootstrapNodes' | 'listenAddress'
|
|
356
|
+
> &
|
|
357
|
+
Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> &
|
|
366
358
|
Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKB'> &
|
|
367
359
|
Pick<ChainConfig, 'l1ChainId'>;
|
|
368
360
|
|
|
369
361
|
const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
|
|
370
|
-
'
|
|
362
|
+
'p2pIp',
|
|
363
|
+
'p2pPort',
|
|
371
364
|
'peerIdPrivateKey',
|
|
372
|
-
'udpListenAddress',
|
|
373
365
|
'dataDirectory',
|
|
374
366
|
'dataStoreMapSizeKB',
|
|
375
367
|
'bootstrapNodes',
|
package/src/enr/generate-enr.ts
CHANGED
|
@@ -11,12 +11,13 @@ import { setAztecEnrKey } from '../versioning.js';
|
|
|
11
11
|
|
|
12
12
|
export async function createBootnodeENRandPeerId(
|
|
13
13
|
privateKey: string,
|
|
14
|
-
|
|
14
|
+
p2pIp: string,
|
|
15
|
+
p2pPort: number,
|
|
15
16
|
l1ChainId: number,
|
|
16
17
|
): Promise<{ enr: SignableENR; peerId: PeerId }> {
|
|
17
18
|
const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
|
|
18
19
|
const enr = SignableENR.createFromPeerId(peerId);
|
|
19
|
-
const publicAddr = multiaddr(convertToMultiaddr(
|
|
20
|
+
const publicAddr = multiaddr(convertToMultiaddr(p2pIp, p2pPort, 'udp'));
|
|
20
21
|
enr.setLocationMultiaddr(publicAddr);
|
|
21
22
|
|
|
22
23
|
const config: ChainConfig = {
|
|
@@ -67,7 +67,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
67
67
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
it('
|
|
70
|
+
it('should handle duplicate proposals in a slot', async () => {
|
|
71
71
|
const slotNumber = 420;
|
|
72
72
|
const archive = Fr.random();
|
|
73
73
|
const txs = [0, 1, 2, 3, 4, 5].map(() => TxHash.random());
|
|
@@ -79,6 +79,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
79
79
|
attestations.push(await mockAttestation(signer, slotNumber, archive, txs));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// Add them to store and check we end up with only one
|
|
82
83
|
await ap.addAttestations(attestations);
|
|
83
84
|
|
|
84
85
|
const retreivedAttestations = await ap.getAttestationsForSlot(BigInt(slotNumber), archive.toString());
|
|
@@ -86,9 +87,13 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
86
87
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestations[0].toBuffer());
|
|
87
88
|
expect(retreivedAttestations[0].payload.txHashes).toEqual(txs);
|
|
88
89
|
expect((await retreivedAttestations[0].getSender()).toString()).toEqual(signer.address.toString());
|
|
90
|
+
|
|
91
|
+
// Try adding them on another operation and check they are still not duplicated
|
|
92
|
+
await ap.addAttestations([attestations[0]]);
|
|
93
|
+
expect(await ap.getAttestationsForSlot(BigInt(slotNumber), archive.toString())).toHaveLength(1);
|
|
89
94
|
});
|
|
90
95
|
|
|
91
|
-
it('
|
|
96
|
+
it('should store attestations by differing slot', async () => {
|
|
92
97
|
const slotNumbers = [1, 2, 3, 4];
|
|
93
98
|
const attestations = await Promise.all(signers.map((signer, i) => mockAttestation(signer, slotNumbers[i])));
|
|
94
99
|
|
|
@@ -105,7 +110,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
105
110
|
}
|
|
106
111
|
});
|
|
107
112
|
|
|
108
|
-
it('
|
|
113
|
+
it('should store attestations by differing slot and archive', async () => {
|
|
109
114
|
const slotNumbers = [1, 1, 2, 3];
|
|
110
115
|
const archives = [Fr.random(), Fr.random(), Fr.random(), Fr.random()];
|
|
111
116
|
const attestations = await Promise.all(
|
|
@@ -125,7 +130,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
125
130
|
}
|
|
126
131
|
});
|
|
127
132
|
|
|
128
|
-
it('
|
|
133
|
+
it('should delete attestations', async () => {
|
|
129
134
|
const slotNumber = 420;
|
|
130
135
|
const archive = Fr.random();
|
|
131
136
|
const attestations = await Promise.all(signers.map(signer => mockAttestation(signer, slotNumber, archive)));
|
|
@@ -147,7 +152,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
147
152
|
expect(gottenAfterDelete.length).toBe(0);
|
|
148
153
|
});
|
|
149
154
|
|
|
150
|
-
it('
|
|
155
|
+
it('should blanket delete attestations per slot', async () => {
|
|
151
156
|
const slotNumber = 420;
|
|
152
157
|
const archive = Fr.random();
|
|
153
158
|
const attestations = await Promise.all(signers.map(signer => mockAttestation(signer, slotNumber, archive)));
|
|
@@ -165,7 +170,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
165
170
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
166
171
|
});
|
|
167
172
|
|
|
168
|
-
it('
|
|
173
|
+
it('should blanket delete attestations per slot and proposal', async () => {
|
|
169
174
|
const slotNumber = 420;
|
|
170
175
|
const archive = Fr.random();
|
|
171
176
|
const attestations = await Promise.all(signers.map(signer => mockAttestation(signer, slotNumber, archive)));
|
|
@@ -201,7 +206,7 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
201
206
|
compareAttestations(retreivedAttestationsAfterDeleteForOtherProposal, attestations2);
|
|
202
207
|
});
|
|
203
208
|
|
|
204
|
-
it('
|
|
209
|
+
it('should delete attestations older than a given slot', async () => {
|
|
205
210
|
const slotNumbers = [1, 2, 3, 69, 72, 74, 88, 420];
|
|
206
211
|
const attestations = (
|
|
207
212
|
await Promise.all(slotNumbers.map(slotNumber => createAttestationsForSlot(slotNumber)))
|