Skip to content

feat(view)!: serve the view service over HTTP with the gRPC messages and one client - #2222

Merged
mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:feat/view-service-http
Oct 22, 2026
Merged

mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:feat/view-service-http

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

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/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. 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 a SignedCommandResponse, failures included; non-200 only before a command exists (400 undecodable body, 405 wrong method, 413 over fsc.web.maxRecvMsgSize, 500 when the service itself errors, WebSocket close 1011). The routes read at most fsc.web.maxRecvMsgSize bytes 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/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 grpc (default) or http. 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 the services/web message 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 own fsc.identity.

Breaking changes

  • 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; 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/NewStreamCommandHandler; sdk.NewWebServer takes the view service. web/server.HttpHandler, ReqContext, RequestHandler, WSStream and the services/web package are removed; 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.

Panurus needs an update of its test harness: integration/nwo/runner/rpc/user_provider.go imports view/grpc/client and builds a REST view client from web/client (switch to viewclient.NewClient with Transport: TransportHTTP, or nwo client.NewHTTPViewClient), and integration/nwo/token/fabricx/factory.go uses api.GRPCClient.

Tests

  • Parity suite (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.
  • HTTP adapter (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.
  • Client: response command_hash checks 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-stoprestart and make integration-tests-fabric-iou pass.

…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>
@mbrandenburger mbrandenburger self-assigned this Oct 22, 2026
@github-actions

Copy link
Copy Markdown

Hey @mbrandenburger 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


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:

  • 7df2d0e feat(view)!: serve the view service over HTTP with the gRPC messages and one client

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ 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!

@github-actions github-actions Bot added the status: needs revision The pull request requires changes from the author before it can be reviewed or merged label Oct 22, 2026
@mbrandenburger mbrandenburger added this to the 26Q4 milestone Oct 22, 2026
@mbrandenburger mbrandenburger added status: needs review The pull request is ready for maintainer review and removed status: needs revision The pull request requires changes from the author before it can be reviewed or merged labels Oct 22, 2026

@SaidAltury-ibm SaidAltury-ibm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @mbrandenburger , LGTM

@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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.

@mbrandenburger
mbrandenburger merged commit a8cad76 into hyperledger-labs:main Oct 22, 2026
@mbrandenburger
mbrandenburger deleted the feat/view-service-http branch October 22, 2026 13:29
SurbhiAgarwal1 added a commit to SurbhiAgarwal1/fabric-smart-client that referenced this pull request Nov 1, 2026
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>
SaidAltury-ibm pushed a commit that referenced this pull request Nov 1, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs review The pull request is ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serve the view service over HTTP with the gRPC messages, and one view client

2 participants