Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #73 from primevprotocol/fix-gw.0
Browse files Browse the repository at this point in the history
fix: gw response recorder
  • Loading branch information
aloknerurkar authored Oct 26, 2023
2 parents a834960 + 38d86e4 commit aebff1d
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 179 deletions.
2 changes: 1 addition & 1 deletion config/provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ rpc_port: 13524
secret: hello
log_fmt: text
log_level: debug
expose_provider_api: false
expose_provider_api: true
bootnodes:
- /ip4/<localhost>/tcp/13522/p2p/<p2p_ID>
151 changes: 75 additions & 76 deletions gen/go/rpc/providerapi/v1/providerapi.pb.go

Large diffs are not rendered by default.

175 changes: 87 additions & 88 deletions gen/go/rpc/userapi/v1/userapi.pb.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions gen/openapi/rpc/providerapi/v1/providerapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ definitions:
rpcproviderapiv1Bid:
type: object
example:
bid_amount: 1e+18
bid_digest: 9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==
block_number: 123456
tx_hash: 91a89B633194c0D86C539A1A5B14DCCacfD47094
bidAmount: 1e+18
bidDigest: 9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==
blockNumber: 123456
txHash: 91a89B633194c0D86C539A1A5B14DCCacfD47094
properties:
txHash:
type: string
Expand Down Expand Up @@ -109,7 +109,7 @@ definitions:
v1BidResponse:
type: object
example:
bid_digest: 9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==
bidDigest: 9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==
status: STATUS_ACCEPTED
properties:
bidDigest:
Expand Down
6 changes: 3 additions & 3 deletions gen/openapi/rpc/userapi/v1/userapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ definitions:
rpcseacherapiv1Bid:
type: object
example:
bid_amount: 1e+18
block_number: 123456
tx_hash: 91a89B633194c0D86C539A1A5B14DCCacfD47094
amount: 1e+18
blockNumber: 123456
txHash: 91a89B633194c0D86C539A1A5B14DCCacfD47094
properties:
txHash:
type: string
Expand Down
17 changes: 17 additions & 0 deletions pkg/apiserver/middleware.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package apiserver

import (
"bufio"
"log/slog"
"net"
"net/http"
"time"
)
Expand All @@ -16,6 +18,21 @@ func (r *responseStatusRecorder) WriteHeader(status int) {
r.ResponseWriter.WriteHeader(status)
}

// Hijack implements http.Hijacker.
func (r *responseStatusRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return r.ResponseWriter.(http.Hijacker).Hijack()
}

// Flush implements http.Flusher.
func (r *responseStatusRecorder) Flush() {
r.ResponseWriter.(http.Flusher).Flush()
}

// Push implements http.Pusher.
func (r *responseStatusRecorder) Push(target string, opts *http.PushOptions) error {
return r.ResponseWriter.(http.Pusher).Push(target, opts)
}

func newAccessLogHandler(log *slog.Logger) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
Expand Down
8 changes: 4 additions & 4 deletions rpc/providerapi/v1/providerapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ message Bid {
json_schema: {
title: "Bid message"
description: "Signed bid message from users to the provider."
required: ["tx_hash", "bid_amount", "block_number", "bid_digest"]
required: ["txHash", "bidAmount", "blockNumber", "bidDigest"]
}
example: "{\"tx_hash\": \"91a89B633194c0D86C539A1A5B14DCCacfD47094\", \"bid_amount\": 1000000000000000000, \"block_number\": 123456, \"bid_digest\": \"9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==\"}"
example: "{\"txHash\": \"91a89B633194c0D86C539A1A5B14DCCacfD47094\", \"bidAmount\": 1000000000000000000, \"blockNumber\": 123456, \"bidDigest\": \"9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==\"}"
};
string tx_hash = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Hex string encoding of the hash of the transaction that the user wants to include in the block."
Expand All @@ -69,9 +69,9 @@ message BidResponse {
json_schema: {
title: "Bid response"
description: "Response sent by the provider with the decision on the bid received."
required: ["bid_digest", "status"]
required: ["bidDigest", "status"]
}
example: "{\"bid_digest\": \"9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==\", \"status\": \"STATUS_ACCEPTED\"}"
example: "{\"bidDigest\": \"9dJinwL+FZ6B1xsIQQo8t8B0ZXJubJwY86l/Yu7yAH159QrPHU0qj2P+YFj+llbuI1ZygdxGsX8+P3byMEA5ig==\", \"status\": \"STATUS_ACCEPTED\"}"
};
bytes bid_digest = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Digest of the bid message signed by the user."
Expand Down
4 changes: 2 additions & 2 deletions rpc/userapi/v1/userapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ message Bid {
json_schema: {
title: "Bid message"
description: "Unsigned bid message from users to the user mev-commit node."
required: ["tx_hash", "amount", "block_number"]
required: ["txHash", "amount", "blockNumber"]
}
example: "{\"tx_hash\": \"91a89B633194c0D86C539A1A5B14DCCacfD47094\", \"bid_amount\": 1000000000000000000, \"block_number\": 123456}"
example: "{\"txHash\": \"91a89B633194c0D86C539A1A5B14DCCacfD47094\", \"amount\": 1000000000000000000, \"blockNumber\": 123456}"
};
string tx_hash = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Hex string encoding of the hash of the transaction that the user wants to include in the block."
Expand Down

0 comments on commit aebff1d

Please sign in to comment.