Skip to content

Commit 09d0f62

Browse files
authored
Update default env and some misc fixes (#1413)
A couple of useful misc fixes sitting on my local - Update my `.env.example` to simplify contents - Update README.md helm install section to fix location of umbrella chart ref - Update `postman.json` files to query `eth_getTransctionCount` - Update `sdkClient.ts`, `mirrorNodeClient.ts` and `eth.ts` use of `cache.set` to provide `requestId` for better logging - Update `server.spec.ts` to add cors header content checks Signed-off-by: Nana Essilfie-Conduah <nana@swirldslabs.com>
1 parent ad9ebf9 commit 09d0f62

File tree

8 files changed

+161
-71
lines changed

8 files changed

+161
-71
lines changed

.env.example

+5-46
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,7 @@
1-
HEDERA_NETWORK=
2-
OPERATOR_ID_MAIN=
3-
OPERATOR_KEY_MAIN=
1+
# mandatory env variables to run the relay successfully. See README.md for more details and ./docs/examples for HashIO previewnet, testnet and mainnet templates
42
CHAIN_ID=
53
MIRROR_NODE_URL=
6-
E2E_RELAY_HOST=
7-
# Relay methods variables
8-
FEE_HISTORY_MAX_RESULTS=
9-
DEFAULT_RATE_LIMIT =
10-
TIER_1_RATE_LIMIT =
11-
TIER_2_RATE_LIMIT =
12-
TIER_3_RATE_LIMIT =
13-
LIMIT_DURATION =
14-
HBAR_RATE_LIMIT_TINYBAR =
15-
HBAR_RATE_LIMIT_DURATION =
16-
RATE_LIMIT_DISABLED =
17-
ETH_GET_LOGS_BLOCK_RANGE_LIMIT =
18-
DEV_MODE =
19-
MIRROR_NODE_RETRIES =
20-
MIRROR_NODE_RETRY_DELAY =
21-
MIRROR_NODE_RETRIES_DEVMODE =
22-
MIRROR_NODE_RETRY_DELAY_DEVMODE =
23-
GAS_PRICE_TINY_BAR_BUFFER =
24-
MIRROR_NODE_LIMIT_PARAM =
25-
CLIENT_TRANSPORT_SECURITY=
26-
INPUT_SIZE_LIMIT=
27-
ETH_CALL_DEFAULT_TO_CONSENSUS_NODE=
28-
CONSENSUS_MAX_EXECUTION_TIME=
29-
ETH_CALL_CACHE_TTL=
30-
SDK_REQUEST_TIMEOUT=
31-
WS_POLLING_INTERVAL=
32-
SUBSCRIPTIONS_ENABLED=
33-
SERVER_PORT=
34-
WEB_SOCKET_PORT=
35-
WEB_SOCKET_HTTP_PORT=
36-
WS_CONNECTION_LIMIT=
37-
WS_MAX_CONNECTION_TTL=
38-
WS_CONNECTION_LIMIT_PER_IP=
39-
WS_SUBSCRIPTION_LIMIT=
40-
WS_MULTIPLE_ADDRESSES_ENABLED=
41-
ETH_BLOCK_NUMBER_CACHE_TTL_MS=
42-
ETH_GET_BALANCE_CACHE_TTL_MS=
43-
ETH_FEE_HISTORY_FIXED=
44-
WEB_SOCKET_METRICS_PORT=
45-
HAPI_CLIENT_TRANSACTION_RESET=
46-
HAPI_CLIENT_DURATION_RESET=
47-
HAPI_CLIENT_ERROR_RESET=
48-
FILE_APPEND_MAX_CHUNKS=
4+
HEDERA_NETWORK=
5+
#mandatory env variables to support queries and transactions to Consensus Node e.g. eth_sendRaTransaction and fallback scenarios on calls to Mirror Node
6+
OPERATOR_ID_MAIN=<AccountID e.g. 0.1.2, can be obtained from portal.hedera.com, wallet or exchange of choice>
7+
OPERATOR_KEY_MAIN=<DER Encoded Private Key, can be obtained from portal.hedera.com, wallet or exchange of choice>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ helm show values hedera-json-rpc-relay
193193
Deploy an installation with custom values file:
194194

195195
```
196-
helm install custom-hedera-json-rpc-relay -f path/to/values/file.yaml ./charts --debug
196+
helm install custom-hedera-json-rpc-relay -f path/to/values/file.yaml ./charts/hedera-json-rpc --debug
197197
```
198198

199199
##### Deploy Helm Chart locally on minikube

charts/hedera-json-rpc-relay/postman.json

+62
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"exec": [
1616
"pm.test(\"Success\", () => {",
1717
" var response = pm.response.json();",
18+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
1819
" pm.expect(response.result).to.be.an(\"array\");",
1920
" pm.expect(response.result).length(0);",
2021
" pm.expect(response.id).to.equal(\"test_id\");",
@@ -56,6 +57,7 @@
5657
"exec": [
5758
"pm.test(\"Success\", () => {",
5859
" var response = pm.response.json();",
60+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
5961
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
6062
" pm.expect(response.id).to.equal(\"test_id\");",
6163
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -96,6 +98,7 @@
9698
"exec": [
9799
"pm.test(\"Success\", () => {",
98100
" var response = pm.response.json();",
101+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
99102
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
100103
" pm.expect(response.id).to.equal(\"test_id\");",
101104
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -136,6 +139,7 @@
136139
"exec": [
137140
"pm.test(\"Success\", () => {",
138141
" var response = pm.response.json();",
142+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
139143
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
140144
" pm.expect(response.id).to.equal(\"test_id\");",
141145
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -176,6 +180,7 @@
176180
"exec": [
177181
"pm.test(\"Success\", () => {",
178182
" var response = pm.response.json();",
183+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
179184
" pm.expect(response.result.baseFeePerGas).to.be.an(\"array\");",
180185
" pm.expect(response.result.baseFeePerGas).length(4);",
181186
" pm.expect(response.result.gasUsedRatio).to.be.an(\"array\");",
@@ -222,6 +227,7 @@
222227
"exec": [
223228
"pm.test(\"Success\", () => {",
224229
" var response = pm.response.json();",
230+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
225231
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
226232
" pm.expect(response.id).to.equal(\"test_id\");",
227233
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -262,6 +268,7 @@
262268
"exec": [
263269
"pm.test(\"Success\", () => {",
264270
" var response = pm.response.json();",
271+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
265272
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
266273
" pm.expect(response.id).to.equal(\"test_id\");",
267274
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -302,6 +309,7 @@
302309
"exec": [
303310
"pm.test(\"Success\", () => {",
304311
" var response = pm.response.json();",
312+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
305313
" pm.expect(response.result.timestamp).to.match(/^0x[a-f0-9]+$/);",
306314
" pm.expect(response.result.difficulty).to.match(/^0x[a-f0-9]+$/);",
307315
" pm.expect(response.result.extraData).to.match(/^0x$/);",
@@ -362,6 +370,7 @@
362370
"exec": [
363371
"pm.test(\"Success\", () => {",
364372
" var response = pm.response.json();",
373+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
365374
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
366375
" pm.expect(response.id).to.equal(\"test_id\");",
367376
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -402,6 +411,7 @@
402411
"exec": [
403412
"pm.test(\"Success\", () => {",
404413
" var response = pm.response.json();",
414+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
405415
" pm.expect(response.result).to.be.null;",
406416
" pm.expect(response.id).to.equal(\"test_id\");",
407417
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -442,6 +452,7 @@
442452
"exec": [
443453
"pm.test(\"Success\", () => {",
444454
" var response = pm.response.json();",
455+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
445456
" pm.expect(response.result).to.be.null;",
446457
" pm.expect(response.id).to.equal(\"test_id\");",
447458
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -482,6 +493,7 @@
482493
"exec": [
483494
"pm.test(\"Success\", () => {",
484495
" var response = pm.response.json();",
496+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
485497
" pm.expect(response.result).to.be.null;",
486498
" pm.expect(response.id).to.equal(\"test_id\");",
487499
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -522,6 +534,7 @@
522534
"exec": [
523535
"pm.test(\"Success\", () => {",
524536
" var response = pm.response.json();",
537+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
525538
" pm.expect(response.result).to.equal(\"0x0\");",
526539
" pm.expect(response.id).to.equal(\"test_id\");",
527540
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -562,6 +575,7 @@
562575
"exec": [
563576
"pm.test(\"Success\", () => {",
564577
" var response = pm.response.json();",
578+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
565579
" pm.expect(response.result).to.equal(\"0x0\");",
566580
" pm.expect(response.id).to.equal(\"test_id\");",
567581
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -726,6 +740,7 @@
726740
"exec": [
727741
"pm.test(\"Success\", () => {",
728742
" var response = pm.response.json();",
743+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
729744
" pm.expect(response.result).to.equal(\"0x0\");",
730745
" pm.expect(response.id).to.equal(\"test_id\");",
731746
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -766,6 +781,7 @@
766781
"exec": [
767782
"pm.test(\"Success\", () => {",
768783
" var response = pm.response.json();",
784+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
769785
" pm.expect(response.result).to.equal(false);",
770786
" pm.expect(response.id).to.equal(\"test_id\");",
771787
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -806,6 +822,7 @@
806822
"exec": [
807823
"pm.test(\"Success\", () => {",
808824
" var response = pm.response.json();",
825+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
809826
" pm.expect(response.result).to.equal(false);",
810827
" pm.expect(response.id).to.equal(\"test_id\");",
811828
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -846,6 +863,7 @@
846863
"exec": [
847864
"pm.test(\"Success\", () => {",
848865
" var response = pm.response.json();",
866+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
849867
" pm.expect(response.result).to.equal(false);",
850868
" pm.expect(response.id).to.equal(\"test_id\");",
851869
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -886,6 +904,7 @@
886904
"exec": [
887905
"pm.test(\"Success\", () => {",
888906
" var response = pm.response.json();",
907+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
889908
" pm.expect(response.result).to.equal(\"false\");",
890909
" pm.expect(response.id).to.equal(\"test_id\");",
891910
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -926,6 +945,7 @@
926945
"exec": [
927946
"pm.test(\"Success\", () => {",
928947
" var response = pm.response.json();",
948+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
929949
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
930950
" pm.expect(response.id).to.equal(\"test_id\");",
931951
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -966,6 +986,7 @@
966986
"exec": [
967987
"pm.test(\"Success\", () => {",
968988
" var response = pm.response.json();",
989+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
969990
" pm.expect(response.result).to.match(/^relay[/]/);",
970991
" pm.expect(response.id).to.equal(\"test_id\");",
971992
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
@@ -996,6 +1017,47 @@
9961017
}
9971018
},
9981019
"response": []
1020+
},
1021+
{
1022+
"name": "eth_getTransactionCount",
1023+
"event": [
1024+
{
1025+
"listen": "test",
1026+
"script": {
1027+
"exec": [
1028+
"pm.test(\"Success\", () => {",
1029+
" var response = pm.response.json();",
1030+
" pm.expect(JSON.stringify(response.error)).to.equal(undefined);",
1031+
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
1032+
" pm.expect(response.id).to.equal(\"test_id\");",
1033+
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
1034+
"});",
1035+
""
1036+
],
1037+
"type": "text/javascript"
1038+
}
1039+
}
1040+
],
1041+
"request": {
1042+
"method": "POST",
1043+
"header": [],
1044+
"body": {
1045+
"mode": "raw",
1046+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getTransactionCount\",\n \"params\": [\n \"0x0000000000000000000000000000000000000062\", \"latest\"\n ]\n}",
1047+
"options": {
1048+
"raw": {
1049+
"language": "json"
1050+
}
1051+
}
1052+
},
1053+
"url": {
1054+
"raw": "{{baseUrl}}",
1055+
"host": [
1056+
"{{baseUrl}}"
1057+
]
1058+
}
1059+
},
1060+
"response": []
9991061
}
10001062
],
10011063
"event": [

packages/relay/src/lib/clients/mirrorNodeClient.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export class MirrorNodeClient {
465465
MirrorNodeClient.GET_BLOCK_ENDPOINT,
466466
requestId);
467467

468-
this.cache.set(cachedLabel, block);
468+
this.cache.set(cachedLabel, block, undefined, requestId);
469469
return block;
470470
}
471471

@@ -496,7 +496,7 @@ export class MirrorNodeClient {
496496
const contract = await this.getContractId(contractIdOrAddress, requestId);
497497
const valid = contract != null;
498498

499-
this.cache.set(cachedLabel, valid, constants.CACHE_TTL.ONE_DAY);
499+
this.cache.set(cachedLabel, valid, constants.CACHE_TTL.ONE_DAY, requestId);
500500
return valid;
501501
}
502502

@@ -513,7 +513,7 @@ export class MirrorNodeClient {
513513

514514
if (contract != null) {
515515
const id = contract.contract_id;
516-
this.cache.set(cachedLabel, id, constants.CACHE_TTL.ONE_DAY);
516+
this.cache.set(cachedLabel, id, constants.CACHE_TTL.ONE_DAY, requestId);
517517
return id;
518518
}
519519

@@ -533,7 +533,7 @@ export class MirrorNodeClient {
533533
requestId);
534534

535535
if(response != undefined && response.transaction_index != undefined && response.block_number != undefined && response.result === "SUCCESS") {
536-
this.cache.set(cacheKey, response, constants.CACHE_TTL.ONE_HOUR);
536+
this.cache.set(cacheKey, response, constants.CACHE_TTL.ONE_HOUR, requestId);
537537
}
538538

539539
return response;
@@ -658,7 +658,7 @@ export class MirrorNodeClient {
658658
const blocks = await this.getBlocks(undefined, undefined, this.getLimitOrderQueryParam(1, MirrorNodeClient.ORDER.ASC), requestId);
659659
if (blocks && blocks.blocks.length > 0) {
660660
const block = blocks.blocks[0];
661-
this.cache.set(cachedLabel, block, constants.CACHE_TTL.ONE_DAY);
661+
this.cache.set(cachedLabel, block, constants.CACHE_TTL.ONE_DAY, requestId);
662662
return block;
663663
}
664664

@@ -871,7 +871,7 @@ export class MirrorNodeClient {
871871
type: constants.TYPE_CONTRACT,
872872
entity: contract
873873
};
874-
this.cache.set(cachedLabel, response);
874+
this.cache.set(cachedLabel, response, undefined, requestId);
875875
return response;
876876
}
877877
}
@@ -912,7 +912,7 @@ export class MirrorNodeClient {
912912
type,
913913
entity: data.value
914914
};
915-
this.cache.set(cachedLabel, response);
915+
this.cache.set(cachedLabel, response, undefined, requestId);
916916
return response;
917917
}
918918

packages/relay/src/lib/clients/sdkClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class SDKClient {
179179
const exchangeRates = await this.getExchangeRate(callerName, requestId);
180180
const tinyBars = this.convertGasPriceToTinyBars(schedule.fees[0].servicedata, exchangeRates);
181181

182-
this.cache.set(constants.CACHE_KEY.GET_TINYBAR_GAS_FEE, tinyBars);
182+
this.cache.set(constants.CACHE_KEY.GET_TINYBAR_GAS_FEE, tinyBars, undefined, requestId);
183183
return tinyBars;
184184
}
185185
}

0 commit comments

Comments
 (0)