@lodestar/reqresp 1.41.0-dev.ef310100c0 → 1.41.0-dev.f2caa915ab
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/README.md +1 -1
- package/lib/ReqResp.d.ts +3 -3
- package/lib/ReqResp.js +4 -4
- package/lib/ReqResp.js.map +1 -1
- package/lib/encoders/requestDecode.d.ts +2 -3
- package/lib/encoders/requestDecode.d.ts.map +1 -1
- package/lib/encoders/requestDecode.js +28 -11
- package/lib/encoders/requestDecode.js.map +1 -1
- package/lib/encoders/requestEncode.d.ts +1 -1
- package/lib/encoders/requestEncode.d.ts.map +1 -1
- package/lib/encoders/requestEncode.js +1 -1
- package/lib/encoders/requestEncode.js.map +1 -1
- package/lib/encoders/responseDecode.d.ts +10 -10
- package/lib/encoders/responseDecode.d.ts.map +1 -1
- package/lib/encoders/responseDecode.js +63 -60
- package/lib/encoders/responseDecode.js.map +1 -1
- package/lib/encoders/responseEncode.d.ts +2 -4
- package/lib/encoders/responseEncode.d.ts.map +1 -1
- package/lib/encoders/responseEncode.js +13 -22
- package/lib/encoders/responseEncode.js.map +1 -1
- package/lib/encodingStrategies/index.d.ts +4 -3
- package/lib/encodingStrategies/index.d.ts.map +1 -1
- package/lib/encodingStrategies/index.js +4 -4
- package/lib/encodingStrategies/index.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/decode.d.ts +5 -4
- package/lib/encodingStrategies/sszSnappy/decode.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/decode.js +83 -52
- package/lib/encodingStrategies/sszSnappy/decode.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.d.ts +2 -2
- package/lib/encodingStrategies/sszSnappy/encode.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.js +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/errors.d.ts +0 -8
- package/lib/encodingStrategies/sszSnappy/errors.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/errors.js +0 -2
- package/lib/encodingStrategies/sszSnappy/errors.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/index.d.ts +0 -1
- package/lib/encodingStrategies/sszSnappy/index.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/index.js +0 -1
- package/lib/encodingStrategies/sszSnappy/index.js.map +1 -1
- package/lib/metrics.d.ts +1 -7
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +1 -17
- package/lib/metrics.js.map +1 -1
- package/lib/request/errors.d.ts +1 -7
- package/lib/request/errors.d.ts.map +1 -1
- package/lib/request/errors.js +1 -5
- package/lib/request/errors.js.map +1 -1
- package/lib/request/index.d.ts +0 -3
- package/lib/request/index.d.ts.map +1 -1
- package/lib/request/index.js +58 -70
- package/lib/request/index.js.map +1 -1
- package/lib/response/index.d.ts +1 -1
- package/lib/response/index.d.ts.map +1 -1
- package/lib/response/index.js +46 -50
- package/lib/response/index.js.map +1 -1
- package/lib/types.d.ts +1 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -2
- package/lib/types.js.map +1 -1
- package/lib/utils/collectMaxResponse.d.ts.map +1 -1
- package/lib/utils/collectMaxResponse.js +1 -2
- package/lib/utils/collectMaxResponse.js.map +1 -1
- package/lib/utils/errorMessage.d.ts +3 -3
- package/lib/utils/errorMessage.d.ts.map +1 -1
- package/lib/utils/errorMessage.js +14 -13
- package/lib/utils/errorMessage.js.map +1 -1
- package/lib/utils/index.d.ts +1 -3
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/protocolId.d.ts +2 -2
- package/lib/utils/protocolId.js +2 -2
- package/lib/utils/snappyCompress.d.ts +1 -1
- package/lib/utils/snappyCompress.d.ts.map +1 -1
- package/lib/utils/snappyCompress.js +1 -1
- package/lib/utils/snappyCompress.js.map +1 -1
- package/lib/utils/snappyIndex.d.ts +1 -1
- package/lib/utils/snappyIndex.d.ts.map +1 -1
- package/lib/utils/snappyIndex.js +1 -1
- package/lib/utils/snappyIndex.js.map +1 -1
- package/lib/utils/snappyUncompress.d.ts +7 -11
- package/lib/utils/snappyUncompress.d.ts.map +1 -1
- package/lib/utils/snappyUncompress.js +68 -68
- package/lib/utils/snappyUncompress.js.map +1 -1
- package/lib/utils/stream.d.ts +6 -0
- package/lib/utils/stream.d.ts.map +1 -0
- package/lib/utils/stream.js +21 -0
- package/lib/utils/stream.js.map +1 -0
- package/package.json +14 -16
- package/src/ReqResp.ts +4 -4
- package/src/encoders/requestDecode.ts +32 -16
- package/src/encoders/requestEncode.ts +1 -1
- package/src/encoders/responseDecode.ts +68 -72
- package/src/encoders/responseEncode.ts +17 -29
- package/src/encodingStrategies/index.ts +8 -6
- package/src/encodingStrategies/sszSnappy/decode.ts +111 -53
- package/src/encodingStrategies/sszSnappy/encode.ts +2 -2
- package/src/encodingStrategies/sszSnappy/errors.ts +0 -4
- package/src/encodingStrategies/sszSnappy/index.ts +0 -1
- package/src/metrics.ts +1 -17
- package/src/request/errors.ts +1 -6
- package/src/request/index.ts +74 -86
- package/src/response/index.ts +55 -61
- package/src/types.ts +1 -3
- package/src/utils/collectMaxResponse.ts +1 -2
- package/src/utils/errorMessage.ts +14 -13
- package/src/utils/index.ts +1 -3
- package/src/utils/protocolId.ts +2 -2
- package/src/utils/snappyCompress.ts +1 -1
- package/src/utils/snappyIndex.ts +1 -1
- package/src/utils/snappyUncompress.ts +73 -75
- package/src/utils/stream.ts +34 -0
- package/lib/utils/abortableSource.d.ts +0 -12
- package/lib/utils/abortableSource.d.ts.map +0 -1
- package/lib/utils/abortableSource.js +0 -69
- package/lib/utils/abortableSource.js.map +0 -1
- package/lib/utils/bufferedSource.d.ts +0 -16
- package/lib/utils/bufferedSource.d.ts.map +0 -1
- package/lib/utils/bufferedSource.js +0 -40
- package/lib/utils/bufferedSource.js.map +0 -1
- package/lib/utils/onChunk.d.ts +0 -6
- package/lib/utils/onChunk.d.ts.map +0 -1
- package/lib/utils/onChunk.js +0 -13
- package/lib/utils/onChunk.js.map +0 -1
- package/lib/utils/snappy.d.ts +0 -3
- package/lib/utils/snappy.d.ts.map +0 -1
- package/lib/utils/snappy.js +0 -3
- package/lib/utils/snappy.js.map +0 -1
- package/src/utils/abortableSource.ts +0 -80
- package/src/utils/bufferedSource.ts +0 -46
- package/src/utils/onChunk.ts +0 -12
- package/src/utils/snappy.ts +0 -2
package/lib/request/index.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import { pipe } from "it-pipe";
|
|
2
1
|
import { ErrorAborted, TimeoutError, withTimeout } from "@lodestar/utils";
|
|
3
2
|
import { requestEncode } from "../encoders/requestEncode.js";
|
|
4
3
|
import { responseDecode } from "../encoders/responseDecode.js";
|
|
5
4
|
import { ResponseError } from "../response/index.js";
|
|
6
|
-
import {
|
|
5
|
+
import { prettyPrintPeerId, sendChunks } from "../utils/index.js";
|
|
7
6
|
import { RequestError, RequestErrorCode, responseStatusErrorToRequestError } from "./errors.js";
|
|
8
7
|
export { RequestError, RequestErrorCode };
|
|
9
|
-
//
|
|
8
|
+
// https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#the-reqresp-domain
|
|
10
9
|
export const DEFAULT_DIAL_TIMEOUT = 5 * 1000; // 5 sec
|
|
11
10
|
export const DEFAULT_REQUEST_TIMEOUT = 5 * 1000; // 5 sec
|
|
12
|
-
export const DEFAULT_TTFB_TIMEOUT = 5 * 1000; // 5 sec
|
|
13
11
|
export const DEFAULT_RESP_TIMEOUT = 10 * 1000; // 10 sec
|
|
12
|
+
function getStreamNotFullyConsumedError() {
|
|
13
|
+
return new Error("ReqResp stream was not fully consumed");
|
|
14
|
+
}
|
|
15
|
+
function scheduleStreamAbortIfNotClosed(stream, timeoutMs) {
|
|
16
|
+
const onClose = () => {
|
|
17
|
+
clearTimeout(timeout);
|
|
18
|
+
};
|
|
19
|
+
const timeout = setTimeout(() => {
|
|
20
|
+
stream.removeEventListener("close", onClose);
|
|
21
|
+
if (stream.status === "open" && stream.remoteWriteStatus === "writable") {
|
|
22
|
+
stream.abort(getStreamNotFullyConsumedError());
|
|
23
|
+
}
|
|
24
|
+
}, timeoutMs);
|
|
25
|
+
stream.addEventListener("close", onClose, { once: true });
|
|
26
|
+
}
|
|
14
27
|
/**
|
|
15
28
|
* Sends ReqResp request to a peer. Throws on error. Logs each step of the request lifecycle.
|
|
16
29
|
*
|
|
@@ -28,7 +41,6 @@ export async function* sendRequest({ logger, libp2p, metrics, peerClient }, peer
|
|
|
28
41
|
}
|
|
29
42
|
const DIAL_TIMEOUT = opts?.dialTimeoutMs ?? DEFAULT_DIAL_TIMEOUT;
|
|
30
43
|
const REQUEST_TIMEOUT = opts?.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT;
|
|
31
|
-
const TTFB_TIMEOUT = opts?.ttfbTimeoutMs ?? DEFAULT_TTFB_TIMEOUT;
|
|
32
44
|
const RESP_TIMEOUT = opts?.respTimeoutMs ?? DEFAULT_RESP_TIMEOUT;
|
|
33
45
|
const peerIdStrShort = prettyPrintPeerId(peerId);
|
|
34
46
|
const { method, encoding, version } = protocols[0];
|
|
@@ -42,16 +54,6 @@ export async function* sendRequest({ logger, libp2p, metrics, peerClient }, peer
|
|
|
42
54
|
// On stream negotiation `libp2p.dialProtocol` will pick the available protocol and return
|
|
43
55
|
// the picked protocol in `connection.protocol`
|
|
44
56
|
const protocolsMap = new Map(protocols.map((protocol, i) => [protocolIDs[i], protocol]));
|
|
45
|
-
// As of October 2020 we can't rely on libp2p.dialProtocol timeout to work so
|
|
46
|
-
// this function wraps the dialProtocol promise with an extra timeout
|
|
47
|
-
//
|
|
48
|
-
// > The issue might be: you add the peer's addresses to the AddressBook,
|
|
49
|
-
// which will result in autoDial to kick in and dial your peer. In parallel,
|
|
50
|
-
// you do a manual dial and it will wait for the previous one without using
|
|
51
|
-
// the abort signal:
|
|
52
|
-
//
|
|
53
|
-
// https://github.com/ChainSafe/lodestar/issues/1597#issuecomment-703394386
|
|
54
|
-
// DIAL_TIMEOUT: Non-spec timeout from dialing protocol until stream opened
|
|
55
57
|
const stream = await withTimeout(async (timeoutAndParentSignal) => {
|
|
56
58
|
const protocolIds = Array.from(protocolsMap.keys());
|
|
57
59
|
const conn = await libp2p.dialProtocol(peerId, protocolIds, { signal: timeoutAndParentSignal });
|
|
@@ -65,8 +67,6 @@ export async function* sendRequest({ logger, libp2p, metrics, peerClient }, peer
|
|
|
65
67
|
throw new RequestError({ code: RequestErrorCode.DIAL_ERROR, error: e });
|
|
66
68
|
});
|
|
67
69
|
metrics?.outgoingOpenedStreams?.inc({ method });
|
|
68
|
-
// TODO: Does the TTFB timer start on opening stream or after receiving request
|
|
69
|
-
const timerTTFB = metrics?.outgoingResponseTTFB.startTimer({ method });
|
|
70
70
|
// Parse protocol selected by the responder
|
|
71
71
|
const protocolId = stream.protocol ?? "unknown";
|
|
72
72
|
const protocol = protocolsMap.get(protocolId);
|
|
@@ -76,11 +76,12 @@ export async function* sendRequest({ logger, libp2p, metrics, peerClient }, peer
|
|
|
76
76
|
logCtx.version = protocol.version;
|
|
77
77
|
logger.debug("Req sending request", logCtx);
|
|
78
78
|
// Spec: The requester MUST close the write side of the stream once it finishes writing the request message
|
|
79
|
-
// Impl: stream.sink is closed automatically by js-libp2p-mplex when piped source is exhausted
|
|
80
79
|
// REQUEST_TIMEOUT: Non-spec timeout from sending request until write stream closed by responder
|
|
81
|
-
// Note: libp2p.stop() will close all connections, so not necessary to abort this
|
|
82
|
-
await withTimeout(
|
|
83
|
-
|
|
80
|
+
// Note: libp2p.stop() will close all connections, so not necessary to abort this send on parent stop
|
|
81
|
+
await withTimeout(async (timeoutAndParentSignal) => {
|
|
82
|
+
await sendChunks(stream, requestEncode(protocol, requestBody), timeoutAndParentSignal);
|
|
83
|
+
await stream.close({ signal: timeoutAndParentSignal });
|
|
84
|
+
}, REQUEST_TIMEOUT, signal).catch((e) => {
|
|
84
85
|
stream.abort(e);
|
|
85
86
|
if (e instanceof TimeoutError) {
|
|
86
87
|
throw new RequestError({ code: RequestErrorCode.REQUEST_TIMEOUT });
|
|
@@ -93,62 +94,49 @@ export async function* sendRequest({ logger, libp2p, metrics, peerClient }, peer
|
|
|
93
94
|
if (protocol.ignoreResponse) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let timeoutRESP = null;
|
|
103
|
-
const timeoutTTFB = setTimeout(() => {
|
|
104
|
-
// If we abort on first byte delay, don't need to abort for response delay
|
|
105
|
-
if (timeoutRESP)
|
|
106
|
-
clearTimeout(timeoutRESP);
|
|
107
|
-
ttfbTimeoutController.abort();
|
|
108
|
-
}, TTFB_TIMEOUT);
|
|
109
|
-
const restartRespTimeout = () => {
|
|
110
|
-
if (timeoutRESP)
|
|
111
|
-
clearTimeout(timeoutRESP);
|
|
112
|
-
timeoutRESP = setTimeout(() => respTimeoutController.abort(), RESP_TIMEOUT);
|
|
113
|
-
};
|
|
97
|
+
// RESP_TIMEOUT: Maximum time for complete response transfer
|
|
98
|
+
const respSignal = signal
|
|
99
|
+
? AbortSignal.any([signal, AbortSignal.timeout(RESP_TIMEOUT)])
|
|
100
|
+
: AbortSignal.timeout(RESP_TIMEOUT);
|
|
101
|
+
let responseError = null;
|
|
102
|
+
let responseFullyConsumed = false;
|
|
114
103
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
signal: respTimeoutController.signal,
|
|
123
|
-
getError: () => new RequestError({ code: RequestErrorCode.RESP_TIMEOUT }),
|
|
124
|
-
},
|
|
125
|
-
]),
|
|
126
|
-
// Transforms `Buffer` chunks to yield `ResponseBody` chunks
|
|
127
|
-
responseDecode(protocol, {
|
|
128
|
-
onFirstHeader() {
|
|
129
|
-
// On first byte, cancel the single use TTFB_TIMEOUT, and start RESP_TIMEOUT
|
|
130
|
-
clearTimeout(timeoutTTFB);
|
|
131
|
-
timerTTFB?.();
|
|
132
|
-
restartRespTimeout();
|
|
133
|
-
},
|
|
134
|
-
onFirstResponseChunk() {
|
|
135
|
-
// On <response_chunk>, cancel this chunk's RESP_TIMEOUT and start next's
|
|
136
|
-
restartRespTimeout();
|
|
137
|
-
},
|
|
138
|
-
}));
|
|
104
|
+
yield* responseDecode(protocol, stream, {
|
|
105
|
+
signal: respSignal,
|
|
106
|
+
getError: () => signal?.aborted ? new ErrorAborted("sendRequest") : new RequestError({ code: RequestErrorCode.RESP_TIMEOUT }),
|
|
107
|
+
});
|
|
108
|
+
responseFullyConsumed = true;
|
|
139
109
|
// NOTE: Only log once per request to verbose, intermediate steps to debug
|
|
140
110
|
// NOTE: Do not log the response, logs get extremely cluttered
|
|
141
111
|
// NOTE: add double space after "Req " to align log with the "Resp " log
|
|
142
112
|
logger.verbose("Req done", logCtx);
|
|
143
113
|
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
responseError = e;
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
144
118
|
finally {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
119
|
+
// On decode/timeout failures abort immediately so mplex can reclaim stream state.
|
|
120
|
+
// On normal early consumer exit, close gracefully to avoid stream-id desync with peers.
|
|
121
|
+
if (responseError !== null || signal?.aborted) {
|
|
122
|
+
stream.abort(responseError ?? new ErrorAborted("sendRequest"));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
await stream.close().catch((e) => {
|
|
126
|
+
stream.abort(e);
|
|
127
|
+
});
|
|
128
|
+
if (!responseFullyConsumed) {
|
|
129
|
+
// Stop buffering unread inbound data after caller exits early.
|
|
130
|
+
// mplex does not support propagating closeRead to the remote, so still
|
|
131
|
+
// abort later if the remote never closes write.
|
|
132
|
+
await stream.closeRead().catch(() => {
|
|
133
|
+
// Ignore closeRead errors - close/abort path below will reclaim stream.
|
|
134
|
+
});
|
|
135
|
+
if (stream.remoteWriteStatus === "writable") {
|
|
136
|
+
scheduleStreamAbortIfNotClosed(stream, RESP_TIMEOUT);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
152
140
|
metrics?.outgoingClosedStreams?.inc({ method });
|
|
153
141
|
logger.verbose("Req stream closed", logCtx);
|
|
154
142
|
}
|
package/lib/request/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,YAAY,EAAU,YAAY,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAE,iCAAiC,EAAC,MAAM,aAAa,CAAC;AAE9F,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,CAAC;AAExC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,QAAQ;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,QAAQ;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAExD,SAAS,8BAA8B;IACrC,OAAO,IAAI,KAAK,CAAC,uCAAuC,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AK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBAC/B,MAAM,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;gBAC3B,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,qBAAqB,EAAE,CAAC;oBAC3B,+DAA+D;oBAC/D,uEAAuE;oBACvE,gDAAgD;oBAChD,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;wBAClC,wEAAwE;oBAC1E,CAAC,CAAC,CAAC;oBAEH,IAAI,MAAM,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;wBAC5C,8BAA8B,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;oBACvD,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,CAAU,CAAC,CAAC;QAEjD,IAAI,CAAC,YAAY,aAAa,EAAE,CAAC;YAC/B,MAAM,IAAI,YAAY,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
package/lib/response/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface HandleRequestOpts {
|
|
|
18
18
|
requestId?: number;
|
|
19
19
|
/** Peer client type for logging and metrics: 'prysm' | 'lighthouse' */
|
|
20
20
|
peerClient?: string;
|
|
21
|
-
/**
|
|
21
|
+
/** Timeout for reading the incoming request payload */
|
|
22
22
|
requestTimeoutMs?: number;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,MAAM,EAA4B,MAAM,iBAAiB,CAAC;AAIlE,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAC,QAAQ,EAAiB,MAAM,aAAa,CAAC;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAC,CAAC;AAGvB,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,kBAAkB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,WAAW,EACX,MAAM,EACN,SAAa,EACb,UAAsB,EACtB,gBAAgB,GACjB,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoFnC"}
|
package/lib/response/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { pipe } from "it-pipe";
|
|
2
1
|
import { TimeoutError, withTimeout } from "@lodestar/utils";
|
|
3
2
|
import { requestDecode } from "../encoders/requestDecode.js";
|
|
4
3
|
import { responseEncodeError, responseEncodeSuccess } from "../encoders/responseEncode.js";
|
|
5
4
|
import { RespStatus } from "../interface.js";
|
|
6
5
|
import { RequestError, RequestErrorCode } from "../request/errors.js";
|
|
7
|
-
import { prettyPrintPeerId } from "../utils/index.js";
|
|
6
|
+
import { prettyPrintPeerId, sendChunks } from "../utils/index.js";
|
|
8
7
|
import { ResponseError } from "./errors.js";
|
|
9
8
|
export { ResponseError };
|
|
10
|
-
//
|
|
9
|
+
// https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#the-reqresp-domain
|
|
11
10
|
export const DEFAULT_REQUEST_TIMEOUT = 5 * 1000; // 5 sec
|
|
12
11
|
/**
|
|
13
12
|
* Handles a ReqResp request from a peer. Throws on error. Logs each step of the response lifecycle.
|
|
@@ -30,57 +29,54 @@ export async function handleRequest({ logger, metrics, stream, peerId, protocol,
|
|
|
30
29
|
};
|
|
31
30
|
metrics?.incomingOpenedStreams.inc({ method: protocol.method });
|
|
32
31
|
let responseError = null;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
let streamSendError = null;
|
|
33
|
+
try {
|
|
34
|
+
// Yields success chunks and error chunks in the same generator
|
|
35
|
+
// This syntax allows to recycle stream to send success and error chunks without returning
|
|
36
|
+
// in case request whose body is a List fails at chunk_i > 0, without breaking out of the for..await..of
|
|
37
|
+
await sendChunks(stream, (async function* requestHandlerSource() {
|
|
38
|
+
try {
|
|
39
|
+
const requestBody = await withTimeout((timeoutAndParentSignal) => requestDecode(protocol, stream, timeoutAndParentSignal), REQUEST_TIMEOUT, signal).catch((e) => {
|
|
40
|
+
if (e instanceof TimeoutError) {
|
|
41
|
+
throw e; // Let outer catch re-type the error as SERVER_ERROR
|
|
42
|
+
}
|
|
43
|
+
throw new ResponseError(RespStatus.INVALID_REQUEST, e.message);
|
|
44
|
+
});
|
|
45
|
+
logger.debug("Req received", logCtx);
|
|
46
|
+
// Max count by request for byRange and byRoot
|
|
47
|
+
const requestCount = protocol?.inboundRateLimits?.getRequestCount?.(requestBody) ?? 1;
|
|
48
|
+
if (!rateLimiter.allows(peerId, protocolID, requestCount)) {
|
|
49
|
+
throw new RequestError({ code: RequestErrorCode.REQUEST_RATE_LIMITED });
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const requestChunk = {
|
|
52
|
+
data: requestBody,
|
|
53
|
+
version: protocol.version,
|
|
54
|
+
};
|
|
55
|
+
yield* responseEncodeSuccess(protocol, protocol.handler(requestChunk, peerId, peerClient));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
const status = e instanceof ResponseError ? e.status : RespStatus.SERVER_ERROR;
|
|
59
|
+
yield* responseEncodeError(protocol, status, e.message);
|
|
60
|
+
responseError = e;
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// onChunk(() => logger.debug("Resp sending chunk", logCtx)),
|
|
63
|
-
responseEncodeSuccess(protocol, {
|
|
64
|
-
onChunk(chunkIndex) {
|
|
65
|
-
if (chunkIndex === 0)
|
|
66
|
-
timerTTFB?.();
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
62
|
+
})(), signal);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
streamSendError = e;
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
if (streamSendError) {
|
|
70
|
+
stream.abort(streamSendError);
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// throw e;
|
|
75
|
-
responseError = e;
|
|
72
|
+
else {
|
|
73
|
+
await stream.close().catch((e) => {
|
|
74
|
+
stream.abort(e);
|
|
75
|
+
});
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
// To ensure the stream.source it-pushable instance is always closed, stream.close() is called always
|
|
81
|
-
await stream.close();
|
|
82
|
-
metrics?.incomingClosedStreams.inc({ method: protocol.method });
|
|
83
|
-
// TODO: It may happen that stream.sink returns before returning stream.source first,
|
|
77
|
+
metrics?.incomingClosedStreams.inc({ method: protocol.method });
|
|
78
|
+
}
|
|
79
|
+
// TODO: It may happen that the response write completes before the request is fully read,
|
|
84
80
|
// so you never see "Resp received request" in the logs and the response ends without
|
|
85
81
|
// sending any chunk, triggering EMPTY_RESPONSE error on the requesting side
|
|
86
82
|
// It has only happened when doing a request too fast upon immediate connection on inbound peer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/response/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,YAAY,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAC,mBAAmB,EAAE,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAC,iBAAiB,EAAE,U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,CAAC;YAAS,CAAC;QACT,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC/B,MAAM,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAC,CAAC,CAAC;IAChE,CAAC;IAED,0FAA0F;IAC1F,qFAAqF;IACrF,4EAA4E;IAC5E,+FAA+F;IAC/F,+CAA+C;IAE/C,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,aAAa,CAAC;IACtB,CAAC;IACD,0EAA0E;IAC1E,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -3,10 +3,9 @@ import { BeaconConfig, ForkBoundary } from "@lodestar/config";
|
|
|
3
3
|
import { ForkName } from "@lodestar/params";
|
|
4
4
|
import { LodestarError } from "@lodestar/utils";
|
|
5
5
|
import { RateLimiterQuota } from "./rate_limiter/rateLimiterGRCA.js";
|
|
6
|
-
export declare const protocolPrefix = "/eth2/beacon_chain/req";
|
|
7
6
|
/**
|
|
8
7
|
* Available request/response encoding strategies:
|
|
9
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.1
|
|
8
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#encoding-strategies
|
|
10
9
|
*/
|
|
11
10
|
export declare enum Encoding {
|
|
12
11
|
SSZ_SNAPPY = "ssz_snappy"
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAEnE;;;GAGG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAA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EAAE,0BAA0B,CAAC,oBAAoB,CAAA;CAAC,CAAC;AAEjG,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,0BAA0B,CAAC;CAAG;AAExF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/lib/types.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { LodestarError } from "@lodestar/utils";
|
|
2
|
-
export const protocolPrefix = "/eth2/beacon_chain/req";
|
|
3
2
|
/**
|
|
4
3
|
* Available request/response encoding strategies:
|
|
5
|
-
* https://github.com/ethereum/consensus-specs/blob/v1.1
|
|
4
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#encoding-strategies
|
|
6
5
|
*/
|
|
7
6
|
export var Encoding;
|
|
8
7
|
(function (Encoding) {
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C;;;GAGG;AACH,MAAM,CAAN,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,qCAAyB,CAAA;AAC3B,CAAC,EAFW,QAAQ,KAAR,QAAQ,QAEnB;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AA+HlD,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,oCAAoC;IACpC,yDAAK,CAAA;IACL,iJAAiJ;IACjJ,mEAAU,CAAA;AACZ,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED,MAAM,CAAN,IAAY,0BAEX;AAFD,WAAY,0BAA0B;IACpC,2EAA6C,CAAA;AAC/C,CAAC,EAFW,0BAA0B,KAA1B,0BAA0B,QAErC;AAID,MAAM,OAAO,sBAAuB,SAAQ,aAAyC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectMaxResponse.d.ts","sourceRoot":"","sources":["../../src/utils/collectMaxResponse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"collectMaxResponse.d.ts","sourceRoot":"","sources":["../../src/utils/collectMaxResponse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAUxG"}
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* Collects a bounded list of responses up to `maxResponses`
|
|
7
7
|
*/
|
|
8
8
|
export async function collectMaxResponse(source, maxResponses) {
|
|
9
|
-
// else: zero or more responses
|
|
10
9
|
const responses = [];
|
|
11
10
|
for await (const response of source) {
|
|
12
11
|
responses.push(response);
|
|
13
|
-
if (
|
|
12
|
+
if (responses.length >= maxResponses) {
|
|
14
13
|
break;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectMaxResponse.js","sourceRoot":"","sources":["../../src/utils/collectMaxResponse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAI,MAAwB,EAAE,YAAoB;IACxF
|
|
1
|
+
{"version":3,"file":"collectMaxResponse.js","sourceRoot":"","sources":["../../src/utils/collectMaxResponse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAI,MAAwB,EAAE,YAAoB;IACxF,MAAM,SAAS,GAAQ,EAAE,CAAC;IAC1B,IAAI,KAAK,EAAE,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;QACpC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,SAAS,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YACrC,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -2,14 +2,14 @@ import { Encoding } from "../types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Encodes a UTF-8 string to 256 bytes max
|
|
4
4
|
*/
|
|
5
|
-
export declare function encodeErrorMessage(errorMessage: string, encoding: Encoding):
|
|
5
|
+
export declare function encodeErrorMessage(errorMessage: string, encoding: Encoding): Generator<Buffer>;
|
|
6
6
|
/**
|
|
7
7
|
* Encodes a UTF-8 error message string into a single buffer (max 256 bytes before encoding).
|
|
8
8
|
* Unlike `encodeErrorMessage`, this collects all encoded chunks into one buffer.
|
|
9
9
|
*/
|
|
10
|
-
export declare function encodeErrorMessageToBuffer(errorMessage: string, encoding: Encoding):
|
|
10
|
+
export declare function encodeErrorMessageToBuffer(errorMessage: string, encoding: Encoding): Buffer;
|
|
11
11
|
/**
|
|
12
12
|
* Decodes error message from network bytes and removes non printable, non ascii characters.
|
|
13
13
|
*/
|
|
14
|
-
export declare function decodeErrorMessage(encodedErrorMessage: Uint8Array):
|
|
14
|
+
export declare function decodeErrorMessage(encodedErrorMessage: Uint8Array): string;
|
|
15
15
|
//# sourceMappingURL=errorMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../src/utils/errorMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../../src/utils/errorMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAcrC;;GAEG;AACH,wBAAiB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAW/F;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAM3F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,mBAAmB,EAAE,UAAU,GAAG,MAAM,CAgB1E"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { decode as varintDecode, encodingLength as varintEncodingLength } from "uint8-varint";
|
|
2
|
-
import { Uint8ArrayList } from "uint8arraylist";
|
|
3
2
|
import { writeSszSnappyPayload } from "../encodingStrategies/sszSnappy/encode.js";
|
|
4
3
|
import { Encoding } from "../types.js";
|
|
5
|
-
import {
|
|
4
|
+
import { decodeSnappyFrames } from "./snappyIndex.js";
|
|
6
5
|
// ErrorMessage schema:
|
|
7
6
|
//
|
|
8
7
|
// (
|
|
@@ -12,25 +11,28 @@ import { SnappyFramesUncompress } from "./snappyIndex.js";
|
|
|
12
11
|
// By convention, the error_message is a sequence of bytes that MAY be interpreted as a
|
|
13
12
|
// UTF-8 string (for debugging purposes). Clients MUST treat as valid any byte sequences
|
|
14
13
|
//
|
|
15
|
-
//
|
|
14
|
+
// https://github.com/ethereum/consensus-specs/blob/v1.6.1/specs/phase0/p2p-interface.md#responding-side
|
|
16
15
|
/**
|
|
17
16
|
* Encodes a UTF-8 string to 256 bytes max
|
|
18
17
|
*/
|
|
19
|
-
export
|
|
18
|
+
export function* encodeErrorMessage(errorMessage, encoding) {
|
|
20
19
|
const encoder = new TextEncoder();
|
|
21
20
|
const bytes = encoder.encode(errorMessage).slice(0, 256);
|
|
22
21
|
switch (encoding) {
|
|
23
22
|
case Encoding.SSZ_SNAPPY:
|
|
24
23
|
yield* writeSszSnappyPayload(bytes);
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
throw Error("Unsupported encoding");
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Encodes a UTF-8 error message string into a single buffer (max 256 bytes before encoding).
|
|
29
31
|
* Unlike `encodeErrorMessage`, this collects all encoded chunks into one buffer.
|
|
30
32
|
*/
|
|
31
|
-
export
|
|
33
|
+
export function encodeErrorMessageToBuffer(errorMessage, encoding) {
|
|
32
34
|
const chunks = [];
|
|
33
|
-
for
|
|
35
|
+
for (const chunk of encodeErrorMessage(errorMessage, encoding)) {
|
|
34
36
|
chunks.push(chunk);
|
|
35
37
|
}
|
|
36
38
|
return Buffer.concat(chunks);
|
|
@@ -38,23 +40,22 @@ export async function encodeErrorMessageToBuffer(errorMessage, encoding) {
|
|
|
38
40
|
/**
|
|
39
41
|
* Decodes error message from network bytes and removes non printable, non ascii characters.
|
|
40
42
|
*/
|
|
41
|
-
export
|
|
42
|
-
const
|
|
43
|
+
export function decodeErrorMessage(encodedErrorMessage) {
|
|
44
|
+
const decoder = new TextDecoder();
|
|
43
45
|
let sszDataLength;
|
|
44
46
|
try {
|
|
45
47
|
sszDataLength = varintDecode(encodedErrorMessage);
|
|
46
|
-
const decompressor = new SnappyFramesUncompress();
|
|
47
48
|
const varintBytes = varintEncodingLength(sszDataLength);
|
|
48
|
-
const errorMessage =
|
|
49
|
-
if (errorMessage
|
|
49
|
+
const errorMessage = decodeSnappyFrames(encodedErrorMessage.subarray(varintBytes));
|
|
50
|
+
if (errorMessage.length !== sszDataLength) {
|
|
50
51
|
throw new Error("Malformed input: data length mismatch");
|
|
51
52
|
}
|
|
52
53
|
// remove non ascii characters from string
|
|
53
|
-
return
|
|
54
|
+
return decoder.decode(errorMessage.subarray(0)).replace(/[^\x20-\x7F]/g, "");
|
|
54
55
|
}
|
|
55
56
|
catch (_e) {
|
|
56
57
|
// remove non ascii characters from string
|
|
57
|
-
return
|
|
58
|
+
return decoder.decode(encodedErrorMessage.slice(0, 256)).replace(/[^\x20-\x7F]/g, "");
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
//# sourceMappingURL=errorMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMessage.js","sourceRoot":"","sources":["../../src/utils/errorMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,YAAY,EAAE,cAAc,IAAI,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"errorMessage.js","sourceRoot":"","sources":["../../src/utils/errorMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,YAAY,EAAE,cAAc,IAAI,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAC,qBAAqB,EAAC,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AAEpD,uBAAuB;AACvB,EAAE;AACF,IAAI;AACJ,mCAAmC;AACnC,IAAI;AACJ,EAAE;AACF,uFAAuF;AACvF,wFAAwF;AACxF,EAAE;AACF,wGAAwG;AAExG;;GAEG;AACH,MAAM,SAAS,CAAC,CAAC,kBAAkB,CAAC,YAAoB,EAAE,QAAkB;IAC1E,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEzD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC,UAAU;YACtB,KAAK,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM;QACR;YACE,MAAM,KAAK,CA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@
|
|
|
1
|
-
export * from "./abortableSource.js";
|
|
2
|
-
export * from "./bufferedSource.js";
|
|
3
1
|
export * from "./collectExactOne.js";
|
|
4
2
|
export * from "./collectMaxResponse.js";
|
|
5
3
|
export * from "./errorMessage.js";
|
|
6
|
-
export * from "./onChunk.js";
|
|
7
4
|
export * from "./peerId.js";
|
|
8
5
|
export * from "./protocolId.js";
|
|
9
6
|
export * from "./snappyIndex.js";
|
|
7
|
+
export * from "./stream.js";
|
|
10
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
package/lib/utils/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export * from "./abortableSource.js";
|
|
2
|
-
export * from "./bufferedSource.js";
|
|
3
1
|
export * from "./collectExactOne.js";
|
|
4
2
|
export * from "./collectMaxResponse.js";
|
|
5
3
|
export * from "./errorMessage.js";
|
|
6
|
-
export * from "./onChunk.js";
|
|
7
4
|
export * from "./peerId.js";
|
|
8
5
|
export * from "./protocolId.js";
|
|
9
6
|
export * from "./snappyIndex.js";
|
|
7
|
+
export * from "./stream.js";
|
|
10
8
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|