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

proxyd: Fix error message in tests #3503

Merged
merged 3 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .changeset/sixty-eggs-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/proxyd': patch
---

Carry over custom limit message in batches
2 changes: 1 addition & 1 deletion proxyd/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var (
}
ErrOverRateLimit = &RPCErr{
Code: JSONRPCErrorInternal - 16,
Message: "rate limited",
Message: "over rate limit",
HTTPErrorCode: 429,
}

Expand Down
2 changes: 1 addition & 1 deletion proxyd/integration_tests/rate_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type resWithCode struct {
res []byte
}

const frontendOverLimitResponse = `{"error":{"code":-32016,"message":"over rate limit"},"id":null,"jsonrpc":"2.0"}`
const frontendOverLimitResponse = `{"error":{"code":-32016,"message":"over rate limit with special message"},"id":null,"jsonrpc":"2.0"}`

var ethChainID = "eth_chainId"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ eth_foobar = "main"
rate_per_second = 2
exempt_origins = ["exempt_origin"]
exempt_user_agents = ["exempt_agent"]
error_message = "over rate limit"
error_message = "over rate limit with special message"

[rate_limit.method_overrides.eth_foobar]
limit = 1
Expand Down
6 changes: 4 additions & 2 deletions proxyd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,10 @@ func (s *Server) handleBatchRPC(ctx context.Context, reqs []json.RawMessage, isL
"req_id", GetReqID(ctx),
"method", parsedReq.Method,
)
RecordRPCError(ctx, BackendProxyd, parsedReq.Method, ErrOverRateLimit)
responses[i] = NewRPCErrorRes(parsedReq.ID, ErrOverRateLimit)
rpcErr := ErrOverRateLimit.Clone()
rpcErr.Message = s.limConfig.ErrorMessage
mslipper marked this conversation as resolved.
Show resolved Hide resolved
RecordRPCError(ctx, BackendProxyd, parsedReq.Method, rpcErr)
responses[i] = NewRPCErrorRes(parsedReq.ID, rpcErr)
continue
}

Expand Down