diff --git a/.env.defaults b/.env.defaults new file mode 100755 index 0000000000..b5aac35b88 --- /dev/null +++ b/.env.defaults @@ -0,0 +1,113 @@ +# Default configuration if not overridden. +# For a detailed description of all the fields see ./docs/configuration.md +# Some configuration can be overridden with a corresponding env variable. +# If you don't override a parameter, a default value is used instead, sometimes derived from the SDK. +# Here you can see all th possible override. +# The value you see here is the default used by the application if not overriding. +# Using this env file means settings all values equals to their default + +CACHE_MAX=1_000 # Number of entries +CACHE_TTL=3_600_000 # Seconds +CHAIN_ID=298 # Hex or decimal. Default value is 298 (0x12a) commonly used for a "local-node" network. +CLIENT_TRANSPORT_SECURITY="false" # Use "true" to enable. Any other value means "false" +CONSENSUS_MAX_EXECUTION_TIME=10000 # Milliseconds. Default derived by @hashgraph/sdk if not defined. +CONTRACT_QUERY_TIMEOUT_RETRIES=1 # Number of retries +DEBUG_API_ENABLED="false" # Use "true" to enable. Any other value means "false" +DEFAULT_RATE_LIMIT=200 # Total amount of requests available per IP +ESTIMATE_GAS_THROWS="true" # Use "true" to enable. Any other value means "false" +ETH_CALL_ACCEPTED_ERRORS="false" # Use "true" to enable. Any other value means "false" +ETH_CALL_DEFAULT_TO_CONSENSUS_NODE="false" # Use "false" to disable. Any other value means "true" +ETH_FEE_HISTORY_FIXED="true" # Use "true" to enable. Any other value means "false" +ETH_GET_LOGS_BLOCK_RANGE_LIMIT=1000 # Number of blocks +ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE=1000 # Number of transactions +ETH_POPULATE_SYNTHETIC_CONTRACT_RESULTS="true" # Use "true" to enable. Any other value means "false" +FEE_HISTORY_MAX_RESULTS=10 # Number of results +FILE_APPEND_MAX_CHUNKS=20 # number of chunks +FILTER_API_ENABLED="false" # Use "true" to enable. Any other value means "false" +FILTER_TTL=300000 # Milliseconds. +GAS_PRICE_TINY_BAR_BUFFER=10000000000 # Tinybars +HAPI_CLIENT_DURATION_RESET=0 # Milliseconds. 0 means the client never resets based on time +HAPI_CLIENT_ERROR_RESET="[50]" # Array of protobuf status codes +HAPI_CLIENT_TRANSACTION_RESET=0 # Number of transactions. + + +HAVEGED_IMAGE_TAG +HBAR_RATE_LIMIT_DURATION +HBAR_RATE_LIMIT_TINYBAR +HEDERA_NETWORK +INPUT_SIZE_LIMIT +LIMIT_DURATION +LOCAL_NODE +LOG_LEVEL +MIRROR_IMAGE_TAG +MIRROR_NODE_AGENT_CACHEABLE_DNS +MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX +MIRROR_NODE_CONTRACT_RESULTS_PG_MAX +MIRROR_NODE_HTTP_KEEP_ALIVE +MIRROR_NODE_HTTP_KEEP_ALIVE_MSECS +MIRROR_NODE_HTTP_MAX_SOCKETS +MIRROR_NODE_HTTP_MAX_TOTAL_SOCKETS +MIRROR_NODE_HTTP_SOCKET_TIMEOUT +MIRROR_NODE_LIMIT_PARAM +MIRROR_NODE_LIMIT_PARAM +MIRROR_NODE_MAX_REDIRECTS +MIRROR_NODE_RETRIES +MIRROR_NODE_RETRIES_DEVMODE +MIRROR_NODE_RETRY_CODES +MIRROR_NODE_RETRY_DELAY +MIRROR_NODE_RETRY_DELAY_DEVMODE +MIRROR_NODE_TIMEOUT +MIRROR_NODE_URL +MIRROR_NODE_URL +MIRROR_NODE_URL_HEADER_X_API_KEY +NETWORK_NODE_IMAGE_TAG +OPERATOR_ID +OPERATOR_ID_ETH_SENDRAWTRANSACTION +OPERATOR_ID_MAIN +OPERATOR_KEY +OPERATOR_KEY_ETH_SENDRAWTRANSACTION +OPERATOR_KEY_MAIN +PRIVATE_KEY +RATE_LIMIT_DISABLED +REDIS_ENABLED +REDIS_RECONNECT_DELAY_MS +REDIS_URL +RELAY_BASE_URL +REQUEST_ID_IS_OPTIONAL +SDK_REQUEST_TIMEOUT +SEND_RAW_TRANSACTION_SIZE_LIMIT +SERVER_PORT +SIGNED_TXS +SMART_CONTRACTS_AMOUNT +SUBSCRIPTIONS_ENABLED +TEST_ONLY_ENV_VAR_EMPTYSTRING +TEST_ONLY_ENV_VAR_NONNUMERICSTRING +TEST_ONLY_ENV_VAR_NUMERICSTRING +TEST_WS_SERVER +TIER_1_RATE_LIMIT +TIER_2_RATE_LIMIT +TIER_3_RATE_LIMIT +TX_DEFAULT_GAS +WALLETS_AMOUNT +WEB_SOCKET_HTTP_PORT +WEB_SOCKET_PORT +WS_CACHE_TTL +WS_CONNECTION_LIMIT +WS_CONNECTION_LIMIT_PER_IP +WS_MAX_INACTIVITY_TTL +WS_MULTIPLE_ADDRESSES_ENABLED +WS_PING_INTERVAL +WS_POLLING_INTERVAL +WS_RELAY_URL +WS_SUBSCRIPTION_LIMIT + +# Testing + +DEV_MODE="false" # Use "true" to enable. Any other value means "false" +E2E_RELAY_HOST="http://localhost:7546" # Remote JSON-RPC Relay URL to point to. +E2E_SERVER_PORT=7546 # Port for local testing, used in some acceptance tests. + + +# Development related +SEM_VER= +SNAPSHOT= diff --git a/docs/configuration.md b/docs/configuration.md index f8c77c718c..bc0d80aa40 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -26,13 +26,13 @@ Unless you need to set a non-default value, it is recommended to only populate o | Name | Default | Description | | -------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `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. | -| `HBAR_RATE_LIMIT_DURATION` | "60000" | hbar budget limit duration. This creates a timestamp, which resets all limits, when it's reached. Default is to 60000 (1 minute). | -| `HBAR_RATE_LIMIT_TINYBAR` | "5000_000_000" | total hbar budget in tinybars. | -| `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"}` | -| `INPUT_SIZE_LIMIT` | "1mb" | The [koa-jsonrpc](https://github.com/Bitclimb/koa-jsonrpc) maximum size allowed for requests | -| `MAX_BLOCK_RANGE` | "" | The maximum block number greater than the mirror node's latest block to query for | -| `OPERATOR_ID_MAIN` | "" | Operator account ID used to pay for transactions. In `S.R.N` format, e.g. `0.0.1001`. | +| `CHAIN_ID` | `298` | The network chain ID. Local networks (_local-node_) should use `0x12a` (298). Previewnet, Testnet and Mainnet should use `0x129` (297), `0x128` (296) and `0x127` (295) respectively. | +| `HBAR_RATE_LIMIT_DURATION` | "60000" | hbar budget limit duration. This creates a timestamp, which resets all limits, when it's reached. Default is to 60000 (1 minute). | +| `HBAR_RATE_LIMIT_TINYBAR` | "5000_000_000" | total hbar budget in tinybars. | +| `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"}` | +| `INPUT_SIZE_LIMIT` | "1mb" | The [koa-jsonrpc](https://github.com/Bitclimb/koa-jsonrpc) maximum size allowed for requests. | +| `MAX_BLOCK_RANGE` | "" | The maximum block number greater than the mirror node's latest block to query for. | +| `OPERATOR_ID_MAIN` | "" | Operator account ID used to pay for transactions. In `S.R.N` format, e.g. `0.0.1001`. | | `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`. | | `RATE_LIMIT_DISABLED` | "" | Flag to disable IP based rate limiting. | | `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,54 +43,58 @@ Unless you need to set a non-default value, it is recommended to only populate o The following table lists the available properties along with their default values for the [Relay package](/packages/relay/). Unless you need to set a non-default value, it is recommended to only populate overridden properties in the custom `.env`. -| Name | Default | Description | -| ------------------------------------------- |--------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `CACHE_MAX` | "1000" | The maximum number (or size) of items that remain in the cache (assuming no TTL pruning or explicit deletions). | -| `CACHE_TTL` | "3_600_000" | Max time to live in ms, for items before they are considered stale. Default is one hour in milliseconds | -| `CLIENT_TRANSPORT_SECURITY` | "false" | Flag to enable or disable TLS for both networks. | -| `CONTRACT_CALL_GAS_LIMIT` | "15_000_000" | Maximum gas limit applied to eth_call endpoint networks. | -| `CONSENSUS_MAX_EXECUTION_TIME` | "15000" | Maximum time in ms the SDK will wait when submitting a transaction/query before throwing a TIMEOUT error. | -| `DEFAULT_RATE_LIMIT` | "200" | default fallback rate limit, if no other is configured. | -| `ETH_CALL_CACHE_TTL` | "200" | Maximum time in ms to cache an eth_call response. | -| `ETH_BLOCK_NUMBER_CACHE_TTL_MS` | "1000" | Time in ms to cache response from mirror node | -| `ETH_GET_BALANCE_CACHE_TTL_MS` | "1000" | Time in ms to cache balance returned | -| `ETH_GET_BLOCK_BY_RESULTS_BATCH_SIZE` | "25" | The number of contract results to request from the Mirror Node per batch durin an eth_getBlockByHash or eth_getBlockByNumber call | -| `ETH_CALL_DEFAULT_TO_CONSENSUS_NODE ` | "false" | Flag to set if eth_call logic should first query the mirror node. | -| `ETH_GET_LOGS_BLOCK_RANGE_LIMIT` | "1000" | The maximum block number range to consider during an eth_getLogs call. | -| `ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE` | "1000" | The maximum number of transactions to return when running eth_getBlockByHash or eth_getBlockByNumber with transaction objects set to true call. | -| `FEE_HISTORY_MAX_RESULTS` | "10" | The maximum number of results to returns as part of `eth_feeHistory`. | -| `ETH_FEE_HISTORY_FIXED` | "true" | Flag to set if eth_feeHistory should return a fixed fee for the set of results. | -| `ETH_POPULATE_SYNTHETIC_CONTRACT_RESULTS` | "true" | Flag to set if the relay should populate the contract results for synthetic contracts. | -| `GAS_PRICE_TINY_BAR_BUFFER` | "10000000000" | The additional buffer range to allow during a relay precheck of gas price. This supports slight fluctuations in network gasprice calculations. | -| `HAPI_CLIENT_DURATION_RESET` | "3600000" | Time until client reinitialization. (ms) | -| `HAPI_CLIENT_ERROR_RESET` | [50] | Array of status codes, which when encountered will trigger a reinitialization. Status codes are availble [here](https://github.com/hashgraph/hedera-protobufs/blob/main/services/response_code.proto). | -| `HAPI_CLIENT_TRANSACTION_RESET` | "50" | Number of transaction executions, until client reinitialization. | -| `LIMIT_DURATION` | "60000" | The maximum duration in ms applied to IP-method based rate limits. | -| `MIRROR_NODE_CONTRACT_RESULTS_PG_MAX` | "25" | The maximum number of pages to be requested for contract results from the mirror node. | -| `MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX` | "50" | The maximum number of pages to be requested for contract results logs from the mirror node. (each page will contain a max of 100 results) | -| `MIRROR_NODE_LIMIT_PARAM` | "100" | The mirror node custom limit value to be set on GET requests. This optimizes the flow to reduce the number of calls made to the mirror node by setting a limit larger than it's default limit. | -| `MIRROR_NODE_RETRIES` | "3" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned. | -| `MIRROR_NODE_RETRY_CODES` | "[404]" | The acceptable error codes to retry on a request to the mirror node. If more than 1 error is defined value should be like ie: [400,404,500] | -| `MIRROR_NODE_RETRY_DELAY` | "250" | The delay in ms between retry requests. | -| `MIRROR_NODE_RETRIES_DEVMODE` | "5" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned in dev mode. | -| `MIRROR_NODE_RETRY_DELAY_DEVMODE` | "200" | The delay in ms between retry requests in dev mode. | -| `MIRROR_NODE_URL` | "" | The Mirror Node API endpoint. Official endpoints are Previewnet (https://previewnet.mirrornode.hedera.com), Testnet (https://testnet.mirrornode.hedera.com), Mainnet (https://mainnet-public.mirrornode.hedera.com). See [Mirror Node REST API](https://docs.hedera.com/hedera/sdks-and-apis/rest-api) | -| `MIRROR_NODE_URL_HEADER_X_API_KEY` | "" | Authentication for a `MIRROR_NODE_URL` that requires authentication via the `x-api-key` header. | -| `MIRROR_NODE_GET_CONTRACT_RESULTS_RETRIES` | "3" | Maximun amount of retries to repeat on `GetContractResults` `contracts/results/)` requests when fetching contract results after eth_sendRawTransaction submission. \*Note that this in addition and multiplies the configured Axios retries values. | -| `MIRROR_NODE_AGENT_CACHEABLE_DNS` | "true" | Flag to set if the mirror node agent should cacheable DNS lookups, using better-lookup library. | -| `SDK_REQUEST_TIMEOUT` | "10000" | The complete timeout for running the SDK `execute()` method. This controls the GRPC channel timeout config when querying with network nodes. | -| `CONTRACT_QUERY_TIMEOUT_RETRIES` | "3" | Maximum retries for failed contract call query with timeout exceeded error | -| `TIER_1_RATE_LIMIT` | "100" | Maximum restrictive request count limit used for expensive endpoints rate limiting. | -| `TIER_2_RATE_LIMIT` | "800" | Maximum moderate request count limit used for non expensive endpoints. | -| `TIER_3_RATE_LIMIT` | "1600" | Maximum relaxed request count limit used for static return endpoints. | -| `TX_DEFAULT_GAS` | "400000" | Default gas for transactions that do not specify gas. | -| `FILE_APPEND_MAX_CHUNKS` | "20" | Default maximum number of chunks for the `HAPI` `FileAppendTransaction` to use during contract creation submissions to consensus nodes as part of `eth_sendRawTransactionsaction`. | -| `FILTER_API_ENABLED` | "false" | Enables all filter related methods: `eth_newFilter`, `eth_uninstallFilter`, `eth_getFilterChanges`, `eth_getFilterLogs`, `eth_newBlockFilter` | -| `DEBUG_API_ENABLED` | "false" | Enables all debug related methods: `debug_traceTransaction` -| `REDIS_ENABLED` | "true" | Enable usage of Redis as shared cache | -| `REDIS_URL` | "redis://127.0.0.1:6379" | Sets the url for the Redis shared cache | -| `REDIS_RECONNECT_DELAY_MS` | "1000" | Sets the delay between reconnect retries from the Redis client in ms | +| Name | Default | Description | +| ------------------------------------------- |--------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `CACHE_MAX` | `1000` | The maximum number (or size) of items that remain in the cache (assuming no TTL pruning or explicit deletions). | +| `CACHE_TTL` | `3_600_000` | Max time to live in ms, for items before they are considered stale. Default is one hour in milliseconds | +| `CLIENT_TRANSPORT_SECURITY` | "false" | If "true", enable TLS with default port 50212 for communications with the validators network. For any other value, TLS is disabled and default port is 50211. | +| `CONTRACT_CALL_GAS_LIMIT` | "15_000_000" | Maximum gas limit applied to eth_call endpoint networks. | +| `CONSENSUS_MAX_EXECUTION_TIME` | `10000` | Maximum time in ms the SDK will wait when submitting a transaction/query before throwing a TIMEOUT error. | +| `DEFAULT_RATE_LIMIT` | `200` | default fallback rate limit, if no other is configured. | +| `ESTIMATE_GAS_THROWS` | `"true"` | TBD | +| `ETH_CALL_CACHE_TTL` | "200" | Maximum time in ms to cache an eth_call response. | +| `ETH_BLOCK_NUMBER_CACHE_TTL_MS` | "1000" | Time in ms to cache response from mirror node | +| `ETH_CALL_ACCEPTED_ERRORS` | `"false"` | TBD | +| `ETH_GET_BALANCE_CACHE_TTL_MS` | "1000" | Time in ms to cache balance returned | +| `ETH_GET_BLOCK_BY_RESULTS_BATCH_SIZE` | "25" | The number of contract results to request from the Mirror Node per batch during an `eth_getBlockByHash` or `eth_getBlockByNumber` call | +| `ETH_CALL_DEFAULT_TO_CONSENSUS_NODE` | `"false"` | Use `"false"` to let `eth_call` logic query the mirror node first. Any other values means `"true"` and consensus nodes will be used for queries. | +| `ETH_GET_LOGS_BLOCK_RANGE_LIMIT` | `1000` | The maximum block number range to consider during an `eth_getLogs` call. | +| `ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE` | `1000` | The maximum number of transactions to return when running `eth_getBlockByHash` or `eth_getBlockByNumber` with transaction objects set to true call. | +| `FEE_HISTORY_MAX_RESULTS` | `10` | The maximum number of results to returns as part of `eth_feeHistory`. | +| `ETH_FEE_HISTORY_FIXED` | `"true"` | If `"true"` `eth_feeHistory` returns a fixed fee for the set of results. | +| `ETH_POPULATE_SYNTHETIC_CONTRACT_RESULTS` | `"true"` | If `"true"` the relay populates the contract results for synthetic contracts. | +| `GAS_PRICE_TINY_BAR_BUFFER` | `10000000000` | The additional buffer range to allow during a relay precheck of gas price. This supports slight fluctuations in network gasprice calculations. | +| `HAPI_CLIENT_DURATION_RESET` | `0` | Time until client reinitialization, in milliseconds. `0` means the client never resets based on time. | +| `HAPI_CLIENT_ERROR_RESET` | `"[50]"` | Array of status codes, which when encountered will trigger a reinitialization. Status codes are available [here](https://github.com/hashgraph/hedera-protobufs/blob/main/services/response_code.proto). | +| `HAPI_CLIENT_TRANSACTION_RESET` | `0` | Number of transaction executions, until client reinitialization. | +| `LIMIT_DURATION` | "60000" | The maximum duration in ms applied to IP-method based rate limits. | +| `MIRROR_NODE_CONTRACT_RESULTS_PG_MAX` | "25" | The maximum number of pages to be requested for contract results from the mirror node. | +| `MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX` | "50" | The maximum number of pages to be requested for contract results logs from the mirror node. (each page will contain a max of 100 results) | +| `MIRROR_NODE_LIMIT_PARAM` | "100" | The mirror node custom limit value to be set on GET requests. This optimizes the flow to reduce the number of calls made to the mirror node by setting a limit larger than it's default limit. | +| `MIRROR_NODE_RETRIES` | "3" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned. | +| `MIRROR_NODE_RETRY_CODES` | "[404]" | The acceptable error codes to retry on a request to the mirror node. If more than 1 error is defined value should be like ie: [400,404,500] | +| `MIRROR_NODE_RETRY_DELAY` | "250" | The delay in ms between retry requests. | +| `MIRROR_NODE_RETRIES_DEVMODE` | "5" | The maximum number of retries on a GET request to the mirror node when an acceptable error code is returned in dev mode. | +| `MIRROR_NODE_RETRY_DELAY_DEVMODE` | "200" | The delay in ms between retry requests in dev mode. | +| `MIRROR_NODE_URL` | "" | The Mirror Node API endpoint. Official endpoints are Previewnet (), Testnet (), Mainnet (). See [Mirror Node REST API](https://docs.hedera.com/hedera/sdks-and-apis/rest-api) | +| `MIRROR_NODE_URL_HEADER_X_API_KEY` | "" | Authentication for a `MIRROR_NODE_URL` that requires authentication via the `x-api-key` header. | +| `MIRROR_NODE_GET_CONTRACT_RESULTS_RETRIES` | "3" | Maximum amount of retries to repeat on `GetContractResults` `contracts/results/)` requests when fetching contract results after eth_sendRawTransaction submission. \*Note that this in addition and multiplies the configured Axios retries values. | +| `MIRROR_NODE_AGENT_CACHEABLE_DNS` | "true" | Flag to set if the mirror node agent should cacheable DNS lookups, using better-lookup library. | +| `SDK_REQUEST_TIMEOUT` | "10000" | The complete timeout for running the SDK `execute()` method. This controls the GRPC channel timeout config when querying with network nodes. | +| `CONTRACT_QUERY_TIMEOUT_RETRIES` | `1` | Maximum retries for failed contract call query with timeout exceeded error. | +| `TIER_1_RATE_LIMIT` | "100" | Maximum restrictive request count limit used for expensive endpoints rate limiting. | +| `TIER_2_RATE_LIMIT` | "800" | Maximum moderate request count limit used for non expensive endpoints. | +| `TIER_3_RATE_LIMIT` | "1600" | Maximum relaxed request count limit used for static return endpoints. | +| `TX_DEFAULT_GAS` | "400000" | Default gas for transactions that do not specify gas. | +| `FILE_APPEND_MAX_CHUNKS` | `20` | Default maximum number of chunks for the `HAPI` `FileAppendTransaction` to use during contract creation submissions to consensus nodes as part of `eth_sendRawTransaction`. | +| `FILTER_API_ENABLED` | `"false"` | If `"true"` enables all filter related methods: `eth_newFilter`, `eth_uninstallFilter`, `eth_getFilterChanges`, `eth_getFilterLogs`, `eth_newBlockFilter` | +| `FILTER_TTL` | `300000` | Filters time to live before being deleted, in milliseconds | +| `DEBUG_API_ENABLED` | "false" | Enables all debug related methods: `debug_traceTransaction` | +| `REDIS_ENABLED` | "true" | Enable usage of Redis as shared cache | +| `REDIS_URL` | "redis://127.0.0.1:6379" | Sets the url for the Redis shared cache | +| `REDIS_RECONNECT_DELAY_MS` | "1000" | Sets the delay between reconnect retries from the Redis client in ms | | `SEND_RAW_TRANSACTION_SIZE_LIMIT` | "131072" | Sets the limit of the transaction size the relay accepts on eth_sendRawTransaction + ## WS-Server The following table lists the available properties along with their default values for the [Ws-server package](/packages/ws-server/). @@ -112,38 +116,38 @@ Unless you need to set a non-default value, it is recommended to only populate o ## Sample for connecting to Hedera Environments -**Hedera Mainnet** +### Hedera Mainnet ```.env -HEDERA_NETWORK=mainnet +HEDERA_NETWORK="mainnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x127 -MIRROR_NODE_URL=https://mainnet-public.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://mainnet-public.mirrornode.hedera.com/" ``` See [`.env.mainnet.sample`](./examples/.env.mainnet.sample). -**Hedera Testnet** +### Hedera Testnet ```.env -HEDERA_NETWORK=testnet +HEDERA_NETWORK="testnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x128 -MIRROR_NODE_URL=https://testnet.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://testnet.mirrornode.hedera.com/" ``` See [`.env.testnet.sample`](./examples/.env.testnet.sample). -**Hedera Previewnet** +### Hedera Previewnet ```.env -HEDERA_NETWORK=previewnet +HEDERA_NETWORK="previewnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x129 -MIRROR_NODE_URL=https://previewnet.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://previewnet.mirrornode.hedera.com/" ``` See [`.env.previewnet.sample`](./examples/.env.previewnet.sample). @@ -157,12 +161,13 @@ See [`.env.previewnet.sample`](./examples/.env.previewnet.sample). The following table lists the available properties along with their default values for the tests utilized in the [Server](/packages/server/) and [Relay](/packages/relay/) packages. Unless you need to set a non-default value, it is recommended to only populate overridden properties in the custom `.env`. -| Name | Default | Description | -| ---------------- | ------- | ------------------------------------------------------------ | -| `LOCAL_NODE` | "" | Flag if relay is hosted in the Hedera local node setup. | -| `E2E_RELAY_HOST` | "" | Remote relay url to point to. | -| `DEV_MODE` | "false" | Flag if relay should operate in developer optimization mode. | -| `TEST_WS_SERVER` | "false" | Flag config for enable or disable the WS server tests. | +| Name | Default | Description | +| ----------------- | ------------------------- | -------------------------------------------------------------------- | +| `LOCAL_NODE` | "" | Flag if relay is hosted in the Hedera local node setup. | +| `E2E_RELAY_HOST` | `"http://localhost:7546"` | Remote relay url to point to. | +| `E2E_SERVER_PORT` | `7546` | Port for local testing. | +| `DEV_MODE` | `"false"` | Set `"true"` if relay should operate in developer optimization mode. | +| `TEST_WS_SERVER` | "false" | Flag config for enable or disable the WS server tests. | For test context additional fields need to be set. The following example showcases a `hedera-local-node` instance (where values match those noted on [Local Node Network Variables](https://github.com/hashgraph/hedera-local-node#network-variables) @@ -206,5 +211,4 @@ MAX_CHUNKS=20 ``` > **_NOTE:_** Acceptance tests can be pointed at a remote locations (previewnet and testnet and custom environments). In this case configuration will require details for remote consensus node gRPC endpoints [previewnet / testnet](https://docs.hedera.com/hedera/networks/testnet/testnet-nodes) / [mainnet](https://docs.hedera.com/hedera/networks/mainnet/mainnet-nodes) and [Mirror Node REST API endpoints](https://docs.hedera.com/hedera/sdks-and-apis/rest-api), be sure to configure `HEDERA_NETWORK` and `MIRROR_NODE_URL` appropriately to point away from your local host and to valid deployed services. When pointing to previewnet and testnet, account Ids (`OPERATOR_ID_MAIN`) and private keys (`OPERATOR_KEY_MAIN`) for previewnet and tests may be obtained from the [Hedera Portal](http://portal.hedera.com). - > **_NOTE 2:_**: Read more about `DEV_MODE` [here](./dev-mode.md) diff --git a/docs/dev-mode.md b/docs/dev-mode.md index e91cce1b2e..dc60dd5151 100644 --- a/docs/dev-mode.md +++ b/docs/dev-mode.md @@ -1,14 +1,12 @@ # Development mode -`Developer mode` is intended to be used by users when developing and testing smart contracts. It allows `hardhat-chai-matchers` and other similar libraries to correctly assert revert messages of non-pure contract methods. -It will also be expanded with special settings to speed up the [local node](https://github.com/hashgraph/hedera-local-node). +`Developer mode` is intended to be used by users when developing and testing smart contracts. It allows `hardhat-chai-matchers` and other similar libraries to correctly assert revert messages of non-pure contract methods. It will also be expanded with special settings to speed up the [local node](https://github.com/hashgraph/hedera-local-node). ## Enabling To enable `dev mode` start the Relay with the environment variable `DEV_MODE` set to `true`. - -## Rationale +## Rationale In the example below `contract.call()` will make the following requests to the JSON RPC Relay: `eth_chainId, eth_estimateGas, eth_sendRawTransaction, eth_getTransactionByHash` @@ -16,6 +14,5 @@ In the example below `contract.call()` will make the following requests to the J await expect(contract.call()).to.be.revertedWith("Some revert message"); ``` -The asserting method expects to catch an error from any of the called API endpoints. Normally `eth_estimateGas` throws the error if the contract call is about to revert, -but that is currently not possible in the context of Hedera. Instead the error can be thrown by `eth_getTransactionByHash` after the transaction has gone through the consensus nodes. -Since that is not the normal desired behaviour it is only enabled in this mode. \ No newline at end of file +The asserting method expects to catch an error from any of the called API endpoints. Normally `eth_estimateGas` throws the error if the contract call is about to revert, but that is currently not possible in the context of Hedera. Instead the error can be thrown by `eth_getTransactionByHash` after the transaction has gone through the consensus nodes. +Since that is not the normal desired behaviour it is only enabled in this mode. diff --git a/docs/examples/.env.mainnet.sample b/docs/examples/.env.mainnet.sample index 231ed79825..42f679847e 100644 --- a/docs/examples/.env.mainnet.sample +++ b/docs/examples/.env.mainnet.sample @@ -1,5 +1,5 @@ -HEDERA_NETWORK=mainnet +HEDERA_NETWORK="mainnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x127 -MIRROR_NODE_URL=https://mainnet-public.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://mainnet-public.mirrornode.hedera.com/" diff --git a/docs/examples/.env.previewnet.sample b/docs/examples/.env.previewnet.sample index f3e77f4a3c..e9865b3d85 100644 --- a/docs/examples/.env.previewnet.sample +++ b/docs/examples/.env.previewnet.sample @@ -1,5 +1,5 @@ -HEDERA_NETWORK=previewnet +HEDERA_NETWORK="previewnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x129 -MIRROR_NODE_URL=https://previewnet.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://previewnet.mirrornode.hedera.com/" diff --git a/docs/examples/.env.testnet.sample b/docs/examples/.env.testnet.sample index 5194f9bed6..b82b600d43 100644 --- a/docs/examples/.env.testnet.sample +++ b/docs/examples/.env.testnet.sample @@ -1,5 +1,5 @@ -HEDERA_NETWORK=testnet +HEDERA_NETWORK="testnet" OPERATOR_ID_MAIN=<...redacted...> OPERATOR_KEY_MAIN=<...redacted...> CHAIN_ID=0x128 -MIRROR_NODE_URL=https://testnet.mirrornode.hedera.com/ +MIRROR_NODE_URL="https://testnet.mirrornode.hedera.com/" diff --git a/packages/relay/src/lib/clients/mirrorNodeClient.ts b/packages/relay/src/lib/clients/mirrorNodeClient.ts index 2e0f99f0ac..0935c0c434 100644 --- a/packages/relay/src/lib/clients/mirrorNodeClient.ts +++ b/packages/relay/src/lib/clients/mirrorNodeClient.ts @@ -282,7 +282,7 @@ export class MirrorNodeClient { ); this.cacheService = cacheService; - // set up eth call accepted error codes. + // set up eth call accepted error codes. if (process.env.ETH_CALL_ACCEPTED_ERRORS) { MirrorNodeClient.acceptedErrorStatusesResponsePerRequestPathMap.set( MirrorNodeClient.CONTRACT_CALL_ENDPOINT, diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 65e1ca4906..092174c9ef 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -1461,7 +1461,7 @@ export class EthImpl implements Eth { // ETH_CALL_DEFAULT_TO_CONSENSUS_NODE = false enables the use of Mirror node if ( process.env.ETH_CALL_DEFAULT_TO_CONSENSUS_NODE === undefined || - process.env.ETH_CALL_DEFAULT_TO_CONSENSUS_NODE == 'false' + process.env.ETH_CALL_DEFAULT_TO_CONSENSUS_NODE === 'false' ) { //temporary workaround until precompiles are implemented in Mirror node evm module // Execute the call and get the response diff --git a/packages/relay/src/lib/services/debugService/index.ts b/packages/relay/src/lib/services/debugService/index.ts index dee741c547..1105a0cbf4 100644 --- a/packages/relay/src/lib/services/debugService/index.ts +++ b/packages/relay/src/lib/services/debugService/index.ts @@ -72,7 +72,7 @@ export class DebugService implements IDebugService { * Checks if the Debug API is enabled * @public */ - public static readonly isDebugAPIEnabled = process.env.DEBUG_API_ENABLED; + public static readonly isDebugAPIEnabled = process.env.DEBUG_API_ENABLED || false; static requireDebugAPIEnabled(): void { if (!process.env.DEBUG_API_ENABLED || process.env.DEBUG_API_ENABLED !== 'true') {