Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Set proper limits for the redesigned HBAR limiter #3100

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/hedera-json-rpc-relay/value-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ config:
LIMIT_DURATION: 60000
HBAR_RATE_LIMIT_TINYBAR: 10000000000
HBAR_RATE_LIMIT_DURATION: 60000
HBAR_RATE_LIMIT_BASIC: 5000000000
ETH_GET_LOGS_BLOCK_RANGE_LIMIT: 1000
RATE_LIMIT_DISABLED: false
DEV_MODE: false
Expand Down
1 change: 1 addition & 0 deletions charts/hedera-json-rpc-relay/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config:
GAS_PRICE_TINY_BAR_BUFFER: 10000000000
HBAR_RATE_LIMIT_TINYBAR: 5000000000
HBAR_RATE_LIMIT_DURATION: 60000
HBAR_RATE_LIMIT_BASIC: 5000000000
# 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
HEDERA_NETWORK: ''
INPUT_SIZE_LIMIT: 1
Expand Down
3 changes: 2 additions & 1 deletion dapp-example/localDappCI.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ TIER_3_RATE_LIMIT = 1600
LIMIT_DURATION = 60000
HBAR_RATE_LIMIT_TINYBAR = 11000000000
HBAR_RATE_LIMIT_DURATION = 80000
HBAR_RATE_LIMIT_BASIC = 5000000000
RATE_LIMIT_DISABLED = false
DEV_MODE = false
MIRROR_NODE_RETRIES = 3
MIRROR_NODE_RETRY_DELAY = 500
MIRROR_NODE_RETRIES_DEVMODE = 5
MIRROR_NODE_RETRY_DELAY_DEVMODE = 200
GAS_PRICE_TINY_BAR_BUFFER = 10000000000
MIRROR_NODE_LIMIT_PARAM = 2
MIRROR_NODE_LIMIT_PARAM = 2
10 changes: 5 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Unless you need to set a non-default value, it is recommended to only populate o
| `ETH_FEE_HISTORY_FIXED` | "true" | Flag to set if eth_feeHistory should return a fixed fee for the set of results. |
| `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. |
| `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. |
| `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). |
| `HBAR_RATE_LIMIT_TINYBAR` | "11_000_000_000" | Total hbar budget in tinybars (110 hbars per 80 seconds). |
| `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) |
| `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) |
| `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) |
| `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. |
| `HBAR_RATE_LIMIT_TINYBAR` | "800000000000" | Total HBAR budget (in tinybars). Defaults to 8000 HBARs. |
| `HBAR_RATE_LIMIT_BASIC` | "1120000000" | Individual limit (in tinybars) for spending plans with a BASIC tier. Defaults to 11.2 HBARs. |
| `HBAR_RATE_LIMIT_EXTENDED` | "3200000000" | Individual limit (in tinybars) for spending plans with a EXTENDED tier. Defaults to 32 HBARs. |
| `HBAR_RATE_LIMIT_PRIVILEGED` | "8000000000" | Individual limit (in tinybars) for spending plans with a PRIVILEGED tier. Defaults to 80 HBARs. |
| `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. |
| `HAPI_CLIENT_DURATION_RESET` | "3600000" | Time until client reinitialization. (ms) |
| `HAPI_CLIENT_ERROR_RESET` | [21, 50] | Array of status codes, which when encountered will trigger a reinitialization. Status codes are availble [here](https:/hashgraph/hedera-protobufs/blob/main/services/response_code.proto). |
Expand Down
11 changes: 5 additions & 6 deletions packages/relay/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ export default {
DURATION: 60000,
},

// TODO: Replace with actual values - https:/hashgraph/hedera-json-rpc-relay/issues/2895
HBAR_RATE_LIMIT_DURATION: parseInt(process.env.HBAR_RATE_LIMIT_DURATION || '80000'), // 80 seconds
HBAR_RATE_LIMIT_TOTAL: BigNumber(process.env.HBAR_RATE_LIMIT_TINYBAR || '11000000000'), // 110 HBARs per 80 seconds
HBAR_RATE_LIMIT_BASIC: BigNumber(process.env.HBAR_RATE_LIMIT_BASIC || '92592592'), // Equivalent of 1000 HBARs per day
HBAR_RATE_LIMIT_EXTENDED: BigNumber(process.env.HBAR_RATE_LIMIT_EXTENDED || '925925925'), // Equivalent of 10000 HBARs per day
HBAR_RATE_LIMIT_PRIVILEGED: BigNumber(process.env.HBAR_RATE_LIMIT_PRIVILEGED || '1851851850'), // Equivalent of 20000 HBARs per day
HBAR_RATE_LIMIT_DURATION: parseInt(process.env.HBAR_RATE_LIMIT_DURATION || '86400000'), // 1 day
HBAR_RATE_LIMIT_TOTAL: BigNumber(process.env.HBAR_RATE_LIMIT_TINYBAR || '800000000000'), // 8000 HBARs
quiet-node marked this conversation as resolved.
Show resolved Hide resolved
HBAR_RATE_LIMIT_BASIC: BigNumber(process.env.HBAR_RATE_LIMIT_BASIC || '1120000000'), // 11.2 HBARs
HBAR_RATE_LIMIT_EXTENDED: BigNumber(process.env.HBAR_RATE_LIMIT_EXTENDED || '3200000000'), // 32 HBARs
HBAR_RATE_LIMIT_PRIVILEGED: BigNumber(process.env.HBAR_RATE_LIMIT_PRIVILEGED || '8000000000'), // 80 HBARs
GAS_PRICE_TINY_BAR_BUFFER: parseInt(process.env.GAS_PRICE_TINY_BAR_BUFFER || '10000000000'),
WEB_SOCKET_PORT: process.env.WEB_SOCKET_PORT || 8546,
WEB_SOCKET_HTTP_PORT: process.env.WEB_SOCKET_HTTP_PORT || 8547,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ describe('@tokencreate HTS Precompile Token Create Acceptance Tests', async func
});

it('should associate to a token with custom fees', async function () {
//delay for hbar rate limiter to reset
quiet-node marked this conversation as resolved.
Show resolved Hide resolved
await new Promise((r) => setTimeout(r, relayConstants.HBAR_RATE_LIMIT_DURATION));

const mainContractOwner = new ethers.Contract(mainContractAddress, TokenCreateJson.abi, accounts[0].wallet);
const txCO = await mainContractOwner.associateTokenPublic(
mainContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ describe('@tokenmanagement HTS Precompile Token Management Acceptance Tests', as
let tokenAddress, tokenContract, nftAddress;

before(async function () {
//delay for hbar rate limiter to reset
quiet-node marked this conversation as resolved.
Show resolved Hide resolved
await new Promise((r) => setTimeout(r, relayConstants.HBAR_RATE_LIMIT_DURATION));

// Create token and nft contracts
tokenAddress = await createHTSToken();
nftAddress = await createNftHTSToken();
Expand Down
3 changes: 3 additions & 0 deletions packages/server/tests/localAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ LIMIT_DURATION=90000
SERVER_REQUEST_TIMEOUT_MS=60000
MEMWATCH_ENABLED=true
WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs
3 changes: 3 additions & 0 deletions packages/server/tests/mainnetAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ MIRROR_NODE_URL_WEB3=https://mainnet.mirrornode.hedera.com
E2E_RELAY_HOST=https://mainnet.hashio.io/api
WS_RELAY_URL=wss://mainnet.hashio.io/ws
TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs
3 changes: 3 additions & 0 deletions packages/server/tests/previewnetAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ SERVER_REQUEST_TIMEOUT_MS=60000
MEMWATCH_ENABLED=false
WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs
3 changes: 3 additions & 0 deletions packages/server/tests/testnetAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ SERVER_REQUEST_TIMEOUT_MS=60000
MEMWATCH_ENABLED=false
WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=3000000000# 30 HBARs
Loading