Repository navigation
feat(view)!: serve the view service over HTTP with the gRPC messages and one client - #2222
Conversation
…and one client The web listener mounts POST /v1/ViewService/ProcessCommand and the WebSocket GET /v1/ViewService/StreamCommand. Both carry protojson SignedCommand and SignedCommandResponse messages, frame streams as the gRPC stream does, and call the view service instance that serves gRPC, so authentication, binding, replay protection, the view timeout and response signing are one implementation for both transports, and a command accepted on one is a replay on the other. Every decodable command gets 200 and a SignedCommandResponse, failures included. The routes read at most fsc.web.maxRecvMsgSize bytes per request body or WebSocket message (default 100 MiB), the web listener's own limit. The REST handler framework (HttpHandler, ReqContext, RequestHandler) and the services/web message package served only the removed routes and are deleted. The view client moves to platform/view/services/view/client and reaches the view service through a Transport, which only moves signed commands and responses; the client builds, signs and checks every message itself, so gRPC and HTTP give the same results and errors. Config.Transport selects one, empty meaning gRPC. The client accepts a response only if its header names the hash of the command it sent; the response signature is not verified, since TLS authenticates the node. A parity suite runs one view service on both transports and requires identical results and errors across successful and failing calls, timeouts, unknown signers, stale commands, streams and mutual TLS. nwo's web client calls views over the HTTP binding, signed as the node's own fsc.identity, and the pingpong REST spec checks that an unauthorized signer is rejected. Part of hyperledger-labs#2123. BREAKING CHANGE: PUT /v1/Views/{View} and GET /v1/Views/Stream/{View} are removed, and unsigned requests are rejected; view routes no longer require a client certificate. Import platform/view/services/view/client instead of platform/view/services/view/grpc/client; NewClient returns *client.Client, and ViewServiceClient and ViewServiceClientImpl are replaced by Transport. A response whose command hash does not match the command sent is an error. The fsc_view_services_view_grpc_client_* metric families are renamed fsc_view_services_view_client_*. web.InstallViewHandler is replaced by NewProcessCommandHandler and NewStreamCommandHandler, and sdk.NewWebServer takes the view service; web/server.HttpHandler, ReqContext, RequestHandler, WSStream and the services/web package are removed, and web/client keeps NewClient, Metrics and the WebSocket dial helpers. nwo api.GRPCClient is renamed api.RemoteViewClient, and api.WebClient's StreamCallView returns *client.Stream. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
|
Hey @mbrandenburger 👋 thanks for the PR! This comment updates automatically as you push changes -- think of it as your PR's live scoreboard! PR Checks✅ DCO Sign-off -- All commits have valid sign-offs. Nice work! ❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:
You'll need to sign your commits with GPG (e.g. ✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing! ✅ Issue Link -- Linked to #2206 (assigned to you). ⏳ All checks must pass before this PR can be reviewed. You've got this! |
SaidAltury-ibm
left a comment
There was a problem hiding this comment.
thank you @mbrandenburger , LGTM
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Remove exported symbols and sentinels in the public view packages that have no references in FSC or Panurus: - view.ErrPanic and view.ErrInvalidConfig: unused sentinels in errors.go. - client.MSPInfo: unused struct in client/config.go. - server.SigningIdentity (and server.Identity): unused interface in grpc/server/identity.go; server signs through sig.Signer. - server.GetService: legacy lookup function in grpc/server/service.go that panics because the service is registered via dig. (Note: web.ViewClient was already removed in hyperledger-labs#2222). BREAKING CHANGE: view.ErrPanic, view.ErrInvalidConfig, client.MSPInfo, server.SigningIdentity, server.Identity, and server.GetService are removed from the public API surface. Fixes hyperledger-labs#2020 Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Remove exported symbols and sentinels in the public view packages that have no references in FSC or Panurus: - view.ErrPanic and view.ErrInvalidConfig: unused sentinels in errors.go. - client.MSPInfo: unused struct in client/config.go. - server.SigningIdentity (and server.Identity): unused interface in grpc/server/identity.go; server signs through sig.Signer. - server.GetService: legacy lookup function in grpc/server/service.go that panics because the service is registered via dig. (Note: web.ViewClient was already removed in #2222). BREAKING CHANGE: view.ErrPanic, view.ErrInvalidConfig, client.MSPInfo, server.SigningIdentity, server.Identity, and server.GetService are removed from the public API surface. Fixes #2020 Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Closes #2206. Part of #2123, third of five stacked PRs (PR 1: #2212, PR 2: #2220).
Serve the view service over HTTP with the same signed messages as gRPC, and give applications one view client whose transport is a configuration choice.
HTTP binding. The web listener mounts
POST /v1/ViewService/ProcessCommandand the WebSocketGET /v1/ViewService/StreamCommand. Both carry protojsonSignedCommandandSignedCommandResponsemessages, frame streams as the gRPC stream does, and call the view service instance that serves gRPC. Authentication, binding, replay protection, the view timeout and response signing are therefore one implementation for both transports, and a command accepted on one is a replay on the other. Every decodable command gets HTTP 200 and aSignedCommandResponse, failures included; non-200 only before a command exists (400 undecodable body, 405 wrong method, 413 overfsc.web.maxRecvMsgSize, 500 when the service itself errors, WebSocket close 1011). The routes read at mostfsc.web.maxRecvMsgSizebytes per body or message (default 100 MiB). A stream closes when its request context ends, so a view waiting on the client cannot outlive the listener.One view client. The client moves to
platform/view/services/view/clientand reaches the view service through aTransport, which only moves signed commands and responses; the client builds, signs and checks every message itself, so gRPC and HTTP give the same results and errors.Config.Transportselectsgrpc(default) orhttp. The client accepts a response only if its header names the hash of the command it sent; the response signature is not verified, since TLS authenticates the node.The REST handler framework (
HttpHandler,ReqContext,RequestHandler) and theservices/webmessage package served only the removed REST routes and are deleted. nwo's web client calls views over the HTTP binding, signed as the node's ownfsc.identity.Breaking changes
PUT /v1/Views/{View}andGET /v1/Views/Stream/{View}are removed, and unsigned requests are rejected; view routes no longer require a client certificate.platform/view/services/view/clientinstead ofplatform/view/services/view/grpc/client.NewClientreturns*client.Client;ViewServiceClientandViewServiceClientImplare replaced byTransport. A response whose command hash does not match the command sent is an error.fsc_view_services_view_grpc_client_*metric families are renamedfsc_view_services_view_client_*.web.InstallViewHandleris replaced byNewProcessCommandHandler/NewStreamCommandHandler;sdk.NewWebServertakes the view service.web/server.HttpHandler,ReqContext,RequestHandler,WSStreamand theservices/webpackage are removed;web/clientkeepsNewClient,Metricsand the WebSocket dial helpers.api.GRPCClientis renamedapi.RemoteViewClient, andapi.WebClient'sStreamCallViewreturns*client.Stream.Panurus needs an update of its test harness:
integration/nwo/runner/rpc/user_provider.goimportsview/grpc/clientand builds a REST view client fromweb/client(switch toviewclient.NewClientwithTransport: TransportHTTP, or nwoclient.NewHTTPViewClient), andintegration/nwo/token/fabricx/factory.gousesapi.GRPCClient.Tests
view/client/parity_test.go): one view service on both transports with identical results and errors for a successful call, a failing view, an unknown view, a view timeout, an unknown signer, a stale command, a stream with messages both ways and a late client message, a failing stream, and mutual TLS with a command naming the wrong certificate; a command accepted on one transport is a replay on the other.view/web/service_test.go): status codes, the 413 body limit, a handler outliving the listener's write timeout, stream framing and close codes, the WebSocket read limit, TLS state reaching the view service, and a stream that ends when its request context is cancelled.command_hashchecks on unary calls and streams, and the HTTP transport's certificate rule.make checks,make unit-tests-root,make unit-tests-integration,make integration-tests-fsc-pingpong,make integration-tests-fsc-stoprestartandmake integration-tests-fabric-ioupass.