Skip to content

Commit

Permalink
remove rpc server rate limits
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Jan 15, 2025
1 parent fae35e7 commit 13992bb
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions apps/hubble/src/rpc/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,18 +933,18 @@ export default class Server {
getOnChainEvents: async (call, callback) => this.getOnChainEventsRPC(call, callback),
submitMessage: async (call, callback) => {
// Identify peer that is calling, if available. This is used for rate limiting.
const peer = Result.fromThrowable(
() => call.getPeer(),
(e) => e,
)().unwrapOr("unavailable");
// const peer = Result.fromThrowable(
// () => call.getPeer(),
// (e) => e,
// )().unwrapOr("unavailable");
statsd().increment("rpc.open_request_count", { method: "submitMessage" });

const rateLimitResult = await rateLimitByIp(peer, this.submitMessageRateLimiter);
if (rateLimitResult.isErr()) {
logger.warn({ peer }, "submitMessage rate limited");
callback(toServiceError(new HubError("unavailable", "API rate limit exceeded")));
return;
}
// const rateLimitResult = await rateLimitByIp(peer, this.submitMessageRateLimiter);
// if (rateLimitResult.isErr()) {
// logger.warn({ peer }, "submitMessage rate limited");
// callback(toServiceError(new HubError("unavailable", "API rate limit exceeded")));
// return;
// }

// Authentication
const authResult = authenticateUser(call.metadata, this.rpcUsers);
Expand Down Expand Up @@ -972,19 +972,19 @@ export default class Server {
},
submitBulkMessages: async (call, callback) => {
// Identify peer that is calling, if available. This is used for rate limiting.
const peer = Result.fromThrowable(
() => call.getPeer(),
(e) => e,
)().unwrapOr("unavailable");
// const peer = Result.fromThrowable(
// () => call.getPeer(),
// (e) => e,
// )().unwrapOr("unavailable");
statsd().increment("rpc.open_request_count", { method: "submitBulkMessages" });

// Check for rate limits
const rateLimitResult = await rateLimitByIp(peer, this.submitMessageRateLimiter);
if (rateLimitResult.isErr()) {
logger.warn({ peer }, "submitBulkMessages rate limited");
callback(toServiceError(new HubError("unavailable", "API rate limit exceeded")));
return;
}
// const rateLimitResult = await rateLimitByIp(peer, this.submitMessageRateLimiter);
// if (rateLimitResult.isErr()) {
// logger.warn({ peer }, "submitBulkMessages rate limited");
// callback(toServiceError(new HubError("unavailable", "API rate limit exceeded")));
// return;
// }

// Authentication
const authResult = authenticateUser(call.metadata, this.rpcUsers);
Expand Down

0 comments on commit 13992bb

Please sign in to comment.