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

feat: Add OPERATOR tier #3316

Merged
merged 18 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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: 0 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Unless you need to set a non-default value, it is recommended to only populate o
| `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 |
| `GET_RECORD_DEFAULT_TO_CONSENSUS_NODE` | "false" | Flag to set if get transaction record logic should first query the mirror node (false) or consensus node via the SDK (true). |
| `HBAR_RATE_LIMIT_WHITELIST` | [""] | An array of EVM addresses that are allowed to bypass the HBAR rate limits |
victor-yanev marked this conversation as resolved.
Show resolved Hide resolved

## WS-Server

Expand Down
22 changes: 5 additions & 17 deletions packages/config-service/src/services/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,43 +283,31 @@ export class GlobalConfig {
envName: 'HBAR_RATE_LIMIT_BASIC',
type: 'number',
required: false,
defaultValue: null,
defaultValue: 1_120_000_000, // 11.2 hbar
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
},
HBAR_RATE_LIMIT_EXTENDED: {
envName: 'HBAR_RATE_LIMIT_EXTENDED',
type: 'number',
required: false,
defaultValue: null,
defaultValue: 3_200_000_000, // 32 hbar
},
HBAR_RATE_LIMIT_PRIVILEGED: {
envName: 'HBAR_RATE_LIMIT_PRIVILEGED',
type: 'number',
required: false,
defaultValue: null,
defaultValue: 8_000_000_000, // 80 hbar
},
HBAR_RATE_LIMIT_DURATION: {
envName: 'HBAR_RATE_LIMIT_DURATION',
type: 'number',
required: false,
defaultValue: null,
},
HBAR_RATE_LIMIT_PREEMPTIVE_CHECK: {
envName: 'HBAR_RATE_LIMIT_PREEMPTIVE_CHECK',
type: 'boolean',
required: false,
defaultValue: null,
defaultValue: 86_400_000, // 24 hours
},
HBAR_RATE_LIMIT_TINYBAR: {
envName: 'HBAR_RATE_LIMIT_TINYBAR',
type: 'number',
required: false,
defaultValue: null,
},
HBAR_RATE_LIMIT_WHITELIST: {
envName: 'HBAR_RATE_LIMIT_WHITELIST',
type: 'array',
required: false,
defaultValue: null,
defaultValue: 800_000_000_000, // 8000 hbar
},
HEDERA_NETWORK: {
envName: 'HEDERA_NETWORK',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ export enum SubscriptionTier {
* Trusted Partners
*/
PRIVILEGED = 'PRIVILEGED',

/**
* Relay Operators
*/
OPERATOR = 'OPERATOR',
victor-yanev marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 2 additions & 2 deletions packages/relay/src/lib/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { Client, Hbar } from '@hashgraph/sdk';
import { Client } from '@hashgraph/sdk';
import EventEmitter from 'events';
import { Logger } from 'pino';
import { Gauge, Registry } from 'prom-client';
Expand Down Expand Up @@ -160,13 +160,13 @@ export class RelayImpl implements Relay {
ipAddressHbarSpendingPlanRepository,
logger.child({ name: 'hbar-rate-limit' }),
register,
Hbar.fromTinybars(total),
duration,
);

const hapiService = new HAPIService(logger, register, this.cacheService, this.eventEmitter, hbarLimitService);

this.clientMain = hapiService.getMainClientInstance();
hbarLimitService.setOperatorAddress(this.clientMain.operatorAccountId!.toSolidityAddress());

this.web3Impl = new Web3Impl(this.clientMain);
this.netImpl = new NetImpl(this.clientMain);
Expand Down
18 changes: 10 additions & 8 deletions packages/relay/src/lib/services/hapiService/hapiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
*
*/

import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { AccountId, Client, PrivateKey } from '@hashgraph/sdk';
import dotenv from 'dotenv';
import { Logger } from 'pino';
import EventEmitter from 'events';
import findConfig from 'find-config';
import constants from '../../constants';
import { Utils } from './../../../utils';
import fs from 'fs';
import { Logger } from 'pino';
import { Counter, Registry } from 'prom-client';
import { SDKClient } from '../../clients/sdkClient';
import { HbarLimitService } from '../hbarLimitService';

import { Utils } from '../../../utils';
import { SDKClient } from '../../clients';
import constants from '../../constants';
import { CacheService } from '../cacheService/cacheService';
import { AccountId, Client, PrivateKey } from '@hashgraph/sdk';
import fs from 'fs';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import { HbarLimitService } from '../hbarLimitService';

export default class HAPIService {
/**
Expand Down Expand Up @@ -289,6 +290,7 @@ export default class HAPIService {
this.clientMain = this.initClient(this.logger, this.hederaNetwork);
this.client = this.initSDKClient(this.logger);
this.resetCounters();
this.hbarLimitService.setOperatorAddress(this.clientMain.operatorAccountId!.toString());
}

/**
Expand Down
Loading
Loading