Skip to content

Commit a1d7632

Browse files
authored
feat: added support for batch request feature to WS server (#2461) (#2475)
* chore: added WS flags to configurations Signed-off-by: Logan Nguyen <[email protected]> * feat: added predefined errors, WS_BATCH_REQUESTS_DISABLED & WS_BATCH_REQUESTS_AMOUNT_MAX_EXCEEDED Signed-off-by: Logan Nguyen <[email protected]> * feat: added batch request feature to WS server Signed-off-by: Logan Nguyen <[email protected]> * test: added e2e test for batch requests feature Signed-off-by: Logan Nguyen <[email protected]> * fix: updated logging and fixed typo Signed-off-by: Logan Nguyen <[email protected]> * fix: enabled WS_BATCH_REQUESTS_ENABLED by default Signed-off-by: Logan Nguyen <[email protected]> * fix: moved validation logic to getRequestResult() Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Logan Nguyen <[email protected]>
1 parent e9193fb commit a1d7632

File tree

11 files changed

+508
-283
lines changed

11 files changed

+508
-283
lines changed

docs/configuration.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@ These properties are noted below and should be custom set per deployment.
2424
The following table lists the available properties along with their default values for the [Server package](/packages/server/).
2525
Unless you need to set a non-default value, it is recommended to only populate overridden properties in the custom `.env`.
2626

27-
| Name | Default | Description |
28-
| -------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29-
| `BATCH_REQUESTS_ENABLED` | "false" | Flag to disable or enable batch requests. |
30-
| `BATCH_REQUESTS_MAX_SIZE` | "100" | Maximum number of requests allowed in a batch. |
31-
| `CHAIN_ID` | "" | The network chain id. Local and previewnet envs should use `0x12a` (298). Previewnet, Testnet and Mainnet should use `0x129` (297), `0x128` (296) and `0x127` (295) respectively. |
32-
| `HBAR_RATE_LIMIT_DURATION` | "80000" | hbar budget limit duration. This creates a timestamp, which resets all limits, when it's reached. Default is to 80000 (80 seconds). |
33-
| `HBAR_RATE_LIMIT_TINYBAR` | "11_000_000_000" | total hbar budget in tinybars (110 hbars). |
34-
| `HEDERA_NETWORK` | "" | Which network to connect to. Automatically populates the main node & mirror node endpoints. Can be `previewnet`, `testnet`, `mainnet` or a map of network IPs -> node accountIds e.g. `{"127.0.0.1:50211":"0.0.3"}` |
35-
| `INPUT_SIZE_LIMIT` | "1mb" | The [koa-jsonrpc](https://github.com/Bitclimb/koa-jsonrpc) maximum size allowed for requests |
36-
| `MAX_BLOCK_RANGE` | "5" | The maximum block number greater than the mirror node's latest block to query for |
37-
| `OPERATOR_ID_MAIN` | "" | Operator account ID used to pay for transactions. In `S.R.N` format, e.g. `0.0.1001`. |
38-
| `OPERATOR_KEY_MAIN` | "" | Operator private key used to sign transactions in hex encoded DER format. This may be either an ED22519 private key or an ECDSA private key. The private key must be associated with/used to derive `OPERATOR_ID_MAIN`. |
39-
| `RATE_LIMIT_DISABLED` | "false" | Flag to disable IP based rate limiting. |
40-
| `REQUEST_ID_IS_OPTIONAL` | "" | Flag to set it the JSON RPC request id field in the body should be optional. Note, this breaks the API spec and is not advised and is provided for test purposes only where some wallets may be non compliant |
41-
| `SERVER_PORT` | "7546" | The RPC server port number to listen for requests on. Currently a static value defaulting to 7546. See [#955](https://github.com/hashgraph/hedera-json-rpc-relay/issues/955) |
27+
| Name | Default | Description |
28+
| ---------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| `BATCH_REQUESTS_ENABLED` | "true" | Flag to disable or enable batch requests. |
30+
| `BATCH_REQUESTS_MAX_SIZE` | "100" | Maximum number of requests allowed in a batch. |
31+
| `WS_BATCH_REQUESTS_ENABLED` | "true" | Flag to disable or enable batch requests on the websocket server. |
32+
| `WS_BATCH_REQUESTS_MAX_SIZE` | "20" | Maximum number of requests allowed in a batch on websocket server. |
33+
| `CHAIN_ID` | "" | The network chain id. Local and previewnet envs should use `0x12a` (298). Previewnet, Testnet and Mainnet should use `0x129` (297), `0x128` (296) and `0x127` (295) respectively. |
34+
| `HBAR_RATE_LIMIT_DURATION` | "80000" | hbar budget limit duration. This creates a timestamp, which resets all limits, when it's reached. Default is to 80000 (80 seconds). |
35+
| `HBAR_RATE_LIMIT_TINYBAR` | "11_000_000_000" | total hbar budget in tinybars (110 hbars). |
36+
| `HEDERA_NETWORK` | "" | Which network to connect to. Automatically populates the main node & mirror node endpoints. Can be `previewnet`, `testnet`, `mainnet` or a map of network IPs -> node accountIds e.g. `{"127.0.0.1:50211":"0.0.3"}` |
37+
| `INPUT_SIZE_LIMIT` | "1mb" | The [koa-jsonrpc](https://github.com/Bitclimb/koa-jsonrpc) maximum size allowed for requests |
38+
| `MAX_BLOCK_RANGE` | "5" | The maximum block number greater than the mirror node's latest block to query for |
39+
| `OPERATOR_ID_MAIN` | "" | Operator account ID used to pay for transactions. In `S.R.N` format, e.g. `0.0.1001`. |
40+
| `OPERATOR_KEY_MAIN` | "" | Operator private key used to sign transactions in hex encoded DER format. This may be either an ED22519 private key or an ECDSA private key. The private key must be associated with/used to derive `OPERATOR_ID_MAIN`. |
41+
| `RATE_LIMIT_DISABLED` | "false" | Flag to disable IP based rate limiting. |
42+
| `REQUEST_ID_IS_OPTIONAL` | "" | Flag to set it the JSON RPC request id field in the body should be optional. Note, this breaks the API spec and is not advised and is provided for test purposes only where some wallets may be non compliant |
43+
| `SERVER_PORT` | "7546" | The RPC server port number to listen for requests on. Currently a static value defaulting to 7546. See [#955](https://github.com/hashgraph/hedera-json-rpc-relay/issues/955) |
4244

4345
## Relay
4446

0 commit comments

Comments
 (0)