Skip to content

Commit

Permalink
Merge branch 'main' into snyk-upgrade-24f1de6e9842bcf53f2034e2eec0b1fd
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Badiere <[email protected]>
  • Loading branch information
ebadiere authored Jul 8, 2024
2 parents a7d09da + 892d69e commit afb03b3
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 1,215 deletions.
1,399 changes: 195 additions & 1,204 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prepare": "husky install"
},
"dependencies": {
"@hashgraph/hedera-local": "^2.26.2",
"@hashgraph/hedera-local": "^2.27.0",
"@open-rpc/schema-utils-js": "^1.16.1",
"@types/find-config": "^1.0.4",
"@types/sinon": "^10.0.20",
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@ethersproject/asm": "^5.7.0",
"@hashgraph/sdk": "2.46.0",
"@hashgraph/sdk": "^2.48.1",
"@keyvhq/core": "^1.6.9",
"axios": "^1.4.0",
"axios-retry": "^3.5.1",
Expand Down
16 changes: 14 additions & 2 deletions packages/relay/src/lib/hbarlimiter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Hedera JSON RPC Relay
*
* Copyright (C) 2023 Hedera Hashgraph, LLC
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@
*/

import { Logger } from 'pino';
import { Registry, Counter } from 'prom-client';
import { Registry, Counter, Gauge } from 'prom-client';

export default class HbarLimit {
private enabled: boolean = false;
Expand All @@ -29,6 +29,7 @@ export default class HbarLimit {
private reset: number;
private logger: Logger;
private hbarLimitCounter: Counter;
private hbarLimitRemainingGauge: Gauge;
private readonly register: Registry;

constructor(logger: Logger, currentDateNow: number, total: number, duration: number, register: Registry) {
Expand All @@ -52,6 +53,16 @@ export default class HbarLimit {
registers: [register],
labelNames: ['mode', 'methodName'],
});
this.hbarLimitCounter.inc(0);

const rateLimiterRemainingGaugeName = 'rpc_relay_hbar_rate_remaining';
register.removeSingleMetric(rateLimiterRemainingGaugeName);
this.hbarLimitRemainingGauge = new Gauge({
name: rateLimiterRemainingGaugeName,
help: 'Relay Hbar rate limit remaining budget',
registers: [register],
});
this.hbarLimitRemainingGauge.set(this.remainingBudget);
}

/**
Expand Down Expand Up @@ -89,6 +100,7 @@ export default class HbarLimit {
this.resetLimiter(currentDateNow);
}
this.remainingBudget -= cost;
this.hbarLimitRemainingGauge.set(this.remainingBudget);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class CacheService {
* @private
* @returns {boolean} Returns true if Redis caching is enabled, otherwise false.
*/
private isRedisEnabled(): boolean {
public isRedisEnabled(): boolean {
const redisEnabled = process.env.REDIS_ENABLED && process.env.REDIS_ENABLED === 'true';
const redisUrlValid = process.env.REDIS_URL && process.env.REDIS_URL !== '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export class FilterService implements IFilterService {
FilterService.requireFiltersEnabled();

const cacheKey = `${constants.CACHE_KEY.FILTERID}_${filterId}`;
const filter = await this.cacheService.getAsync(cacheKey, this.ethGetFilterChanges, requestIdPrefix);
const filter = this.cacheService.isRedisEnabled()
? await this.cacheService.getAsync(cacheKey, this.ethGetFilterChanges, requestIdPrefix)
: await this.cacheService.get(cacheKey, this.ethGetFilterChanges, requestIdPrefix);

if (!filter) {
throw predefined.FILTER_NOT_FOUND;
Expand Down
4 changes: 2 additions & 2 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"@hashgraph/hedera-local": "^2.22.0",
"@hashgraph/sdk": "2.44.0",
"@hashgraph/hedera-local": "^2.27.0",
"@hashgraph/sdk": "^2.48.1",
"@koa/cors": "^5.0.0",
"@types/chai": "^4.3.0",
"@types/cors": "^2.8.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/ws-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"pnpm": "8.15.8"
},
"devDependencies": {
"@hashgraph/hedera-local": "^2.22.0",
"@hashgraph/sdk": "2.44.0",
"@hashgraph/hedera-local": "^2.27.0",
"@hashgraph/sdk": "^2.48.1",
"@koa/cors": "^5.0.0",
"@types/chai": "^4.3.0",
"@types/cors": "^2.8.12",
Expand Down
2 changes: 1 addition & 1 deletion tools/golang-json-rpc-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ func main() {
testGetLogs(client, contractAddress, nil)
testStorageAt(client, contractAddress, "0x0")
testGetTransactionByHash(client, signedTx.Hash().Hex())
testGetTransactionCount(client)
testGetTransactionReceipt(client, signedTx.Hash().Hex())
if *wss {
return;
}

// https only methods
testGetTransactionCount(client)
testFeeHistory(client, 5, blockNumber, []float64{10, 50, 90})
testGetAccounts(client)
testGetBlockTransactionCountByHash(client, blockHash)
Expand Down

0 comments on commit afb03b3

Please sign in to comment.