Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e75f585
adds factory pattern for relay class, to support future redis client …
konstantinabl Oct 14, 2025
7d14b31
imports from dist
konstantinabl Oct 14, 2025
84a514c
fixes acceptance tests
konstantinabl Oct 15, 2025
3e06df5
fixes integration tests
konstantinabl Oct 15, 2025
1671238
fix relay logger
konstantinabl Oct 15, 2025
8ad1fdd
remove relay return
konstantinabl Oct 15, 2025
930a838
adds register clean
konstantinabl Oct 16, 2025
43ca2a8
fixes ws server tests and transforms them to unit
konstantinabl Oct 16, 2025
89916d5
removes eslint disable
konstantinabl Oct 16, 2025
782b71a
addresses PR comments
konstantinabl Oct 16, 2025
51cce80
fixes tests in server.spec
konstantinabl Oct 16, 2025
dd8477e
removes eslint disabled
konstantinabl Oct 16, 2025
a8ee86e
fixes comments
konstantinabl Oct 16, 2025
0063ff1
improves commenting
konstantinabl Oct 16, 2025
ffd9d08
removes unused variables
konstantinabl Oct 16, 2025
bd2f3bb
reverts check out of scope
konstantinabl Oct 16, 2025
09dad39
removes require from acceptance tests
konstantinabl Oct 16, 2025
d59e2d7
removes unused variable
konstantinabl Oct 16, 2025
96e560c
removes unused import
konstantinabl Oct 16, 2025
e7ea819
adds dynamic loading for tier variables in method config
konstantinabl Oct 16, 2025
dce661d
fixes relay init
konstantinabl Oct 16, 2025
002ddbb
fixes unit tests
konstantinabl Oct 17, 2025
894988c
turnoff unused expression rules for tests
konstantinabl Oct 17, 2025
5412778
removes unused var app
konstantinabl Oct 17, 2025
1af001d
fixes ws server tests
konstantinabl Oct 17, 2025
409cdeb
reverts changes to assertions
konstantinabl Oct 17, 2025
67f6e89
removes unused eslint disable
konstantinabl Oct 17, 2025
5138a52
improves integration test
konstantinabl Oct 17, 2025
3d7d9cd
removes all instantiations using new isntead of init from tests
konstantinabl Oct 17, 2025
dd4e210
removes unused methods
konstantinabl Oct 17, 2025
071aa7c
adds comment
konstantinabl Oct 17, 2025
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
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ module.exports = {
"sourceType": "script",
},
},
{
"files": [
"**/*.spec.ts",
"**/*.test.ts",
"**/tests/**/*.ts",
],
"rules": {
"@typescript-eslint/no-unused-expressions": "off",
},
},
],
"parserOptions": {
"ecmaVersion": "latest",
Expand All @@ -39,7 +49,6 @@ module.exports = {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/ban-types": "warn",
"no-trailing-spaces": "error",
"no-useless-escape": "warn",
"prefer-const": "error",
Expand Down
365 changes: 191 additions & 174 deletions packages/relay/src/lib/config/methodConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,181 +4,198 @@

import { MethodRateLimitConfiguration } from '../types';

const tier1rateLimit = ConfigService.get('TIER_1_RATE_LIMIT');
const tier2rateLimit = ConfigService.get('TIER_2_RATE_LIMIT');
const tier3rateLimit = ConfigService.get('TIER_3_RATE_LIMIT');
// Lazy getter function that reads config at call time (not module load time)
// This allows test environment overrides to work properly
export function getMethodConfiguration(): MethodRateLimitConfiguration {

Check warning on line 9 in packages/relay/src/lib/config/methodConfiguration.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

packages/relay/src/lib/config/methodConfiguration.ts#L9

Method getMethodConfiguration has 179 lines of code (limit is 50)
const tier1rateLimit = ConfigService.get('TIER_1_RATE_LIMIT');
const tier2rateLimit = ConfigService.get('TIER_2_RATE_LIMIT');
const tier3rateLimit = ConfigService.get('TIER_3_RATE_LIMIT');

// total requests per rate limit duration (default ex. 200 request per 60000ms)
export const methodConfiguration: MethodRateLimitConfiguration = {
web3_clientVersion: {
total: tier3rateLimit,
},
web3_sha3: {
total: tier3rateLimit,
},
net_listening: {
total: tier3rateLimit,
},
net_version: {
total: tier3rateLimit,
},
net_peerCount: {
total: tier3rateLimit,
},
ADMIN_CONFIG: {
total: tier3rateLimit,
},
eth_blockNumber: {
total: tier2rateLimit,
},
eth_call: {
total: tier1rateLimit,
},
eth_coinbase: {
total: tier2rateLimit,
},
eth_simulateV1: {
total: tier2rateLimit,
},
eth_blobBaseFee: {
total: tier2rateLimit,
},
eth_estimateGas: {
total: tier2rateLimit,
},
eth_gasPrice: {
total: tier2rateLimit,
},
eth_getBalance: {
total: tier2rateLimit,
},
eth_getBlockByHash: {
total: tier2rateLimit,
},
eth_getBlockByNumber: {
total: tier2rateLimit,
},
eth_getBlockReceipts: {
total: tier2rateLimit,
},
eth_getBlockTransactionCountByHash: {
total: tier2rateLimit,
},
eth_getBlockTransactionCountByNumber: {
total: tier2rateLimit,
},
eth_getCode: {
total: tier2rateLimit,
},
eth_chainId: {
total: tier2rateLimit,
},
eth_getFilterChanges: {
total: tier2rateLimit,
},
eth_getLogs: {
total: tier2rateLimit,
},
eth_getStorageAt: {
total: tier2rateLimit,
},
eth_getTransactionByBlockHashAndIndex: {
total: tier2rateLimit,
},
eth_getTransactionByBlockNumberAndIndex: {
total: tier2rateLimit,
},
eth_getTransactionByHash: {
total: tier2rateLimit,
},
eth_getTransactionCount: {
total: tier2rateLimit,
},
eth_getTransactionReceipt: {
total: tier2rateLimit,
},
eth_getUncleByBlockHashAndIndex: {
total: tier2rateLimit,
},
eth_getUncleByBlockNumberAndIndex: {
total: tier2rateLimit,
},
eth_getUncleCountByBlockHash: {
total: tier2rateLimit,
},
eth_getUncleCountByBlockNumber: {
total: tier2rateLimit,
},
eth_getWork: {
total: tier2rateLimit,
},
eth_feeHistory: {
total: tier2rateLimit,
},
eth_hashrate: {
total: tier1rateLimit,
},
eth_maxPriorityFeePerGas: {
total: tier1rateLimit,
},
eth_mining: {
total: tier1rateLimit,
},
eth_protocolVersion: {
total: tier2rateLimit,
},
eth_sendRawTransaction: {
total: tier1rateLimit,
},
eth_sendTransaction: {
total: tier1rateLimit,
},
eth_sign: {
total: tier1rateLimit,
},
eth_signTransaction: {
total: tier1rateLimit,
},
eth_submitHashrate: {
total: tier1rateLimit,
},
eth_submitWork: {
total: tier1rateLimit,
},
eth_syncing: {
total: tier1rateLimit,
},
eth_accounts: {
total: tier2rateLimit,
},
eth_newBlockFilter: {
total: tier2rateLimit,
},
eth_newPendingTransactionFilter: {
total: tier2rateLimit,
},
eth_newFilter: {
total: tier2rateLimit,
},
eth_uninstallFilter: {
total: tier2rateLimit,
},
eth_getFilterLogs: {
total: tier2rateLimit,
},
debug_traceTransaction: {
total: tier1rateLimit,
},
debug_traceBlockByNumber: {
total: tier1rateLimit,
},
batch_request: {
total: tier1rateLimit,
return {
web3_clientVersion: {
total: tier3rateLimit,
},
web3_sha3: {
total: tier3rateLimit,
},
net_listening: {
total: tier3rateLimit,
},
net_version: {
total: tier3rateLimit,
},
net_peerCount: {
total: tier3rateLimit,
},
ADMIN_CONFIG: {
total: tier3rateLimit,
},
eth_blockNumber: {
total: tier2rateLimit,
},
eth_call: {
total: tier1rateLimit,
},
eth_coinbase: {
total: tier2rateLimit,
},
eth_simulateV1: {
total: tier2rateLimit,
},
eth_blobBaseFee: {
total: tier2rateLimit,
},
eth_estimateGas: {
total: tier2rateLimit,
},
eth_gasPrice: {
total: tier2rateLimit,
},
eth_getBalance: {
total: tier2rateLimit,
},
eth_getBlockByHash: {
total: tier2rateLimit,
},
eth_getBlockByNumber: {
total: tier2rateLimit,
},
eth_getBlockReceipts: {
total: tier2rateLimit,
},
eth_getBlockTransactionCountByHash: {
total: tier2rateLimit,
},
eth_getBlockTransactionCountByNumber: {
total: tier2rateLimit,
},
eth_getCode: {
total: tier2rateLimit,
},
eth_chainId: {
total: tier2rateLimit,
},
eth_getFilterChanges: {
total: tier2rateLimit,
},
eth_getLogs: {
total: tier2rateLimit,
},
eth_getStorageAt: {
total: tier2rateLimit,
},
eth_getTransactionByBlockHashAndIndex: {
total: tier2rateLimit,
},
eth_getTransactionByBlockNumberAndIndex: {
total: tier2rateLimit,
},
eth_getTransactionByHash: {
total: tier2rateLimit,
},
eth_getTransactionCount: {
total: tier2rateLimit,
},
eth_getTransactionReceipt: {
total: tier2rateLimit,
},
eth_getUncleByBlockHashAndIndex: {
total: tier2rateLimit,
},
eth_getUncleByBlockNumberAndIndex: {
total: tier2rateLimit,
},
eth_getUncleCountByBlockHash: {
total: tier2rateLimit,
},
eth_getUncleCountByBlockNumber: {
total: tier2rateLimit,
},
eth_getWork: {
total: tier2rateLimit,
},
eth_feeHistory: {
total: tier2rateLimit,
},
eth_hashrate: {
total: tier1rateLimit,
},
eth_maxPriorityFeePerGas: {
total: tier1rateLimit,
},
eth_mining: {
total: tier1rateLimit,
},
eth_protocolVersion: {
total: tier2rateLimit,
},
eth_sendRawTransaction: {
total: tier1rateLimit,
},
eth_sendTransaction: {
total: tier1rateLimit,
},
eth_sign: {
total: tier1rateLimit,
},
eth_signTransaction: {
total: tier1rateLimit,
},
eth_submitHashrate: {
total: tier1rateLimit,
},
eth_submitWork: {
total: tier1rateLimit,
},
eth_syncing: {
total: tier1rateLimit,
},
eth_accounts: {
total: tier2rateLimit,
},
eth_newBlockFilter: {
total: tier2rateLimit,
},
eth_newPendingTransactionFilter: {
total: tier2rateLimit,
},
eth_newFilter: {
total: tier2rateLimit,
},
eth_uninstallFilter: {
total: tier2rateLimit,
},
eth_getFilterLogs: {
total: tier2rateLimit,
},
debug_traceTransaction: {
total: tier1rateLimit,
},
debug_traceBlockByNumber: {
total: tier1rateLimit,
},
batch_request: {
total: tier1rateLimit,
},
eth_getProof: {
total: tier2rateLimit,
},
eth_createAccessList: {
total: tier2rateLimit,
},
};
}

// Backwards compatibility: Export a Proxy that lazily calls getMethodConfiguration()
// This allows existing code to use `methodConfiguration.eth_chainId` without changes
export const methodConfiguration = new Proxy({} as MethodRateLimitConfiguration, {
get(target, prop) {
return getMethodConfiguration()[prop as keyof MethodRateLimitConfiguration];
},
eth_getProof: {
total: tier2rateLimit,
ownKeys() {
return Reflect.ownKeys(getMethodConfiguration());
},
eth_createAccessList: {
total: tier2rateLimit,
getOwnPropertyDescriptor(target, prop) {
return Reflect.getOwnPropertyDescriptor(getMethodConfiguration(), prop);
},
};
});
Loading
Loading