Skip to content

Commit f12ab61

Browse files
chore: Set proper limits for the redesigned HBAR limiter (#3100)
* chore: Set proper limits for the redesigned HBAR limiter Signed-off-by: Victor Yanev <[email protected]> * chore: revert changes to package.json Signed-off-by: Victor Yanev <[email protected]> * fix: removed outdated comment Signed-off-by: Logan Nguyen <[email protected]> * fix: renamed HBAR_RATE_LIMIT_TINYBAR to HBAR_RATE_LIMIT_TOTAL Signed-off-by: Logan Nguyen <[email protected]> * fix: reverted "fix: renamed HBAR_RATE_LIMIT_TINYBAR to HBAR_RATE_LIMIT_TOTAL" This reverts commit 9119674. Signed-off-by: Logan Nguyen <[email protected]> * fix: removed delay Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Victor Yanev <[email protected]> Signed-off-by: Logan Nguyen <[email protected]> Co-authored-by: Logan Nguyen <[email protected]>
1 parent 7796aca commit f12ab61

File tree

11 files changed

+26
-18
lines changed

11 files changed

+26
-18
lines changed

charts/hedera-json-rpc-relay/value-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ config:
112112
LIMIT_DURATION: 60000
113113
HBAR_RATE_LIMIT_TINYBAR: 10000000000
114114
HBAR_RATE_LIMIT_DURATION: 60000
115+
HBAR_RATE_LIMIT_BASIC: 5000000000
115116
ETH_GET_LOGS_BLOCK_RANGE_LIMIT: 1000
116117
RATE_LIMIT_DISABLED: false
117118
DEV_MODE: false

charts/hedera-json-rpc-relay/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ config:
2323
GAS_PRICE_TINY_BAR_BUFFER: 10000000000
2424
HBAR_RATE_LIMIT_TINYBAR: 5000000000
2525
HBAR_RATE_LIMIT_DURATION: 60000
26+
HBAR_RATE_LIMIT_BASIC: 5000000000
2627
# Valid options are `previewnet`, `testnet`, and `mainnet` for remote options. For local use {"127.0.01:50211":"0.0.3"}. For IPs use {"$IPv4_ADDR_1:$PORT_1":"$ACCOUNT_ID_1"} form
2728
HEDERA_NETWORK: ''
2829
INPUT_SIZE_LIMIT: 1

dapp-example/localDappCI.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ TIER_3_RATE_LIMIT = 1600
2222
LIMIT_DURATION = 60000
2323
HBAR_RATE_LIMIT_TINYBAR = 11000000000
2424
HBAR_RATE_LIMIT_DURATION = 80000
25+
HBAR_RATE_LIMIT_BASIC = 5000000000
2526
RATE_LIMIT_DISABLED = false
2627
DEV_MODE = false
2728
MIRROR_NODE_RETRIES = 3
2829
MIRROR_NODE_RETRY_DELAY = 500
2930
MIRROR_NODE_RETRIES_DEVMODE = 5
3031
MIRROR_NODE_RETRY_DELAY_DEVMODE = 200
3132
GAS_PRICE_TINY_BAR_BUFFER = 10000000000
32-
MIRROR_NODE_LIMIT_PARAM = 2
33+
MIRROR_NODE_LIMIT_PARAM = 2

docs/configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ Unless you need to set a non-default value, it is recommended to only populate o
6767
| `ETH_FEE_HISTORY_FIXED` | "true" | Flag to set if eth_feeHistory should return a fixed fee for the set of results. |
6868
| `GAS_PRICE_PERCENTAGE_BUFFER` | "0" | The additional buffer that adds a percentage on top of the calculated network gasPrice. This may be used by operators to reduce the chances of `INSUFFICIENT_TX_FEE` errors experienced by users caused by minor fluctuations in the exchange rate. |
6969
| `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. |
70-
| `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). |
71-
| `HBAR_RATE_LIMIT_TINYBAR` | "11_000_000_000" | Total hbar budget in tinybars (110 hbars per 80 seconds). |
72-
| `HBAR_RATE_LIMIT_BASIC` | "92_592_592" | Individual limit in tinybars for spending plans with a BASIC tier. (equivalent of 1_000 HBARs per day for a duration of 80 seconds) |
73-
| `HBAR_RATE_LIMIT_EXTENDED` | "925_925_925" | Individual limit in tinybars for spending plans with a EXTENDED tier. (equivalent of 10_000 HBARs per day for a duration of 80 seconds) |
74-
| `HBAR_RATE_LIMIT_PRIVILEGED` | "1_851_851_850" | Individual limit in tinybars for spending plans with a PRIVILEGED tier. (equivalent of 20_000 HBARs per day for a duration of 80 seconds) |
70+
| `HBAR_RATE_LIMIT_DURATION` | "86400000" | HBAR budget limit duration. This creates a timestamp, which resets all limits, when it's reached. Defaults to 1 day. |
71+
| `HBAR_RATE_LIMIT_TINYBAR` | "800000000000" | Total HBAR budget (in tinybars). Defaults to 8000 HBARs. |
72+
| `HBAR_RATE_LIMIT_BASIC` | "1120000000" | Individual limit (in tinybars) for spending plans with a BASIC tier. Defaults to 11.2 HBARs. |
73+
| `HBAR_RATE_LIMIT_EXTENDED` | "3200000000" | Individual limit (in tinybars) for spending plans with a EXTENDED tier. Defaults to 32 HBARs. |
74+
| `HBAR_RATE_LIMIT_PRIVILEGED` | "8000000000" | Individual limit (in tinybars) for spending plans with a PRIVILEGED tier. Defaults to 80 HBARs. |
7575
| `HBAR_SPENDING_PLANS_CONFIG_FILE` | "spendingPlansConfig.json" | The name of the JSON file containing the pre-configured spending plans for supported projects and partner projects. |
7676
| `HAPI_CLIENT_DURATION_RESET` | "3600000" | Time until client reinitialization. (ms) |
7777
| `HAPI_CLIENT_ERROR_RESET` | [21, 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). |

packages/relay/src/lib/constants.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,11 @@ export default {
139139
DURATION: 60000,
140140
},
141141

142-
// TODO: Replace with actual values - https://github.com/hashgraph/hedera-json-rpc-relay/issues/2895
143-
HBAR_RATE_LIMIT_DURATION: parseInt(process.env.HBAR_RATE_LIMIT_DURATION || '80000'), // 80 seconds
144-
HBAR_RATE_LIMIT_TOTAL: BigNumber(process.env.HBAR_RATE_LIMIT_TINYBAR || '11000000000'), // 110 HBARs per 80 seconds
145-
HBAR_RATE_LIMIT_BASIC: BigNumber(process.env.HBAR_RATE_LIMIT_BASIC || '92592592'), // Equivalent of 1000 HBARs per day
146-
HBAR_RATE_LIMIT_EXTENDED: BigNumber(process.env.HBAR_RATE_LIMIT_EXTENDED || '925925925'), // Equivalent of 10000 HBARs per day
147-
HBAR_RATE_LIMIT_PRIVILEGED: BigNumber(process.env.HBAR_RATE_LIMIT_PRIVILEGED || '1851851850'), // Equivalent of 20000 HBARs per day
142+
HBAR_RATE_LIMIT_DURATION: parseInt(process.env.HBAR_RATE_LIMIT_DURATION || '86400000'), // 1 day
143+
HBAR_RATE_LIMIT_TOTAL: BigNumber(process.env.HBAR_RATE_LIMIT_TINYBAR || '800000000000'), // 8000 HBARs
144+
HBAR_RATE_LIMIT_BASIC: BigNumber(process.env.HBAR_RATE_LIMIT_BASIC || '1120000000'), // 11.2 HBARs
145+
HBAR_RATE_LIMIT_EXTENDED: BigNumber(process.env.HBAR_RATE_LIMIT_EXTENDED || '3200000000'), // 32 HBARs
146+
HBAR_RATE_LIMIT_PRIVILEGED: BigNumber(process.env.HBAR_RATE_LIMIT_PRIVILEGED || '8000000000'), // 80 HBARs
148147
GAS_PRICE_TINY_BAR_BUFFER: parseInt(process.env.GAS_PRICE_TINY_BAR_BUFFER || '10000000000'),
149148
WEB_SOCKET_PORT: process.env.WEB_SOCKET_PORT || 8546,
150149
WEB_SOCKET_HTTP_PORT: process.env.WEB_SOCKET_HTTP_PORT || 8547,

packages/server/tests/acceptance/htsPrecompile/tokenCreate.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ describe('@tokencreate HTS Precompile Token Create Acceptance Tests', async func
243243
});
244244

245245
it('should associate to a token with custom fees', async function () {
246-
//delay for hbar rate limiter to reset
247-
await new Promise((r) => setTimeout(r, relayConstants.HBAR_RATE_LIMIT_DURATION));
248-
249246
const mainContractOwner = new ethers.Contract(mainContractAddress, TokenCreateJson.abi, accounts[0].wallet);
250247
const txCO = await mainContractOwner.associateTokenPublic(
251248
mainContractAddress,

packages/server/tests/acceptance/htsPrecompile/tokenManagement.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ describe('@tokenmanagement HTS Precompile Token Management Acceptance Tests', as
181181
let tokenAddress, tokenContract, nftAddress;
182182

183183
before(async function () {
184-
//delay for hbar rate limiter to reset
185-
await new Promise((r) => setTimeout(r, relayConstants.HBAR_RATE_LIMIT_DURATION));
186-
187184
// Create token and nft contracts
188185
tokenAddress = await createHTSToken();
189186
nftAddress = await createNftHTSToken();

packages/server/tests/localAcceptance.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ LIMIT_DURATION=90000
2727
SERVER_REQUEST_TIMEOUT_MS=60000
2828
MEMWATCH_ENABLED=true
2929
WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
30+
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
31+
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
32+
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs

packages/server/tests/mainnetAcceptance.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ MIRROR_NODE_URL_WEB3=https://mainnet.mirrornode.hedera.com
55
E2E_RELAY_HOST=https://mainnet.hashio.io/api
66
WS_RELAY_URL=wss://mainnet.hashio.io/ws
77
TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
8+
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
9+
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
10+
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs

packages/server/tests/previewnetAcceptance.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ SERVER_REQUEST_TIMEOUT_MS=60000
2020
MEMWATCH_ENABLED=false
2121
WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
2222
TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
23+
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
24+
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
25+
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs

0 commit comments

Comments
 (0)