Skip to content

SY-4432: Refactor Distribution Proxy And Transport#2531

Merged
pjdotson merged 54 commits into
rcfrom
sy-4432-refactor-distribution-proxy-and-transport
Jun 26, 2026
Merged

SY-4432: Refactor Distribution Proxy And Transport#2531
pjdotson merged 54 commits into
rcfrom
sy-4432-refactor-distribution-proxy-and-transport

Conversation

@pjdotson

@pjdotson pjdotson commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Issue Pull Request

Linear Issue

SY-4432

Description

Consolidates the distribution layer's node-to-node transport wiring into a single distribution.Transport interface that exposes both Channel() channel.Transport and Framer() framer.Transport, replacing the previously separate ChannelTransport and FrameTransport config fields.

  • distribution.Transport interface added in layer.go. LayerConfig now takes one Transport field (validated/overridden as a unit) and wires cfg.Transport.Channel() / cfg.Transport.Framer() into the channel and framer services. All existing channel-domain configuration is preserved unchanged.
  • gRPC aggregator (transport/grpc/grpc.go): a Transport struct that composes the existing per-domain gRPC channel and framer transports, with New(pool), Channel(), Framer(), and BindableTransports() for server registration.
  • Unified mock (transport/mock): the previously flat mock package is restructured into mock/channel and mock/framer subpackages (each exposing a Network that provisions its domain Transport), plus a top-level mock.Network that bundles them into a single distribution.Transport per node. Retains shared in-memory network state across nodes.
  • Proxy (proxy/proxy.go): BatchFactory.Host is now private; construct via NewBatchFactory[T](host). Entry.Lease() now returns node.Key. All call sites adapted.
  • cmd/start and the mock cluster builder adapted to construct the single bundled transport.

The channel and framer transport interfaces, their proto definitions, and all channel-domain semantics (including CreateMessage.Opts) are untouched — the unified Transport only aggregates the existing per-domain transports.

A new mock transport suite covers provisioning, channel create routing, framer delete routing, and shared network state through the bundled distribution.Transport.

Basic Readiness

  • I have performed a self-review of my code.
  • I have added relevant, automated tests to cover the changes.
  • I have updated documentation to reflect the changes.

Greptile Summary

This PR consolidates Synnax's distribution-layer node-to-node transport into a single distribution.Transport interface that bundles Channel() and Framer() sub-transports, replacing the previously separate ChannelTransport and FrameTransport fields in LayerConfig. It also restructures the mock transport package into dedicated channel and framer subpackages, adds a gRPC aggregator struct (transport/grpc), makes BatchFactory.Host private via a NewBatchFactory constructor, and renames pool.Newpool.Open / factory.Newfactory.Open for consistency.

  • Transport unification: LayerConfig now exposes a single Transport field; all channel and framer sub-transports are wired from it in OpenLayer. The gRPC Transport struct aggregates per-domain gRPC implementations, and the mock Network mirrors this structure for in-memory tests.
  • Proto service renames: The channel services were renamed from ChannelCreateService / ChannelDeleteService / ChannelRenameService to CreateService / DeleteService / RenameService, changing their full gRPC method paths on the wire.
  • API improvements: BatchFactory.Host is now private (NewBatchFactory constructor required); pool.Factory.New was renamed to Open; type aliases like CreateTransportClient were simplified to CreateClient. Middleware is now correctly applied to rename endpoints (fixing an omission in the old channel transport's Use method).

Confidence Score: 4/5

Safe to merge if all cluster nodes are always upgraded atomically; the gRPC service renames will silently break channel create/delete/rename RPCs in any mixed-version deployment.

The proto service renames change the full gRPC method paths on the wire (e.g., ChannelCreateService/Exec → CreateService/Exec). A node running the pre-PR binary will receive a gRPC Unimplemented error when dialing a post-PR node on those three channel endpoints, and vice versa. All other structural changes — transport unification, BatchFactory encapsulation, pool API rename, mock restructuring — are mechanically correct and well-tested.

core/pkg/distribution/channel/pb/services.proto and its generated files (services.pb.go, services_grpc.pb.go) contain the wire-breaking service renames; confirm that no mixed-version node communication is possible before merging.

Important Files Changed

Filename Overview
core/pkg/distribution/layer.go Replaces separate ChannelTransport/FrameTransport fields with a single Transport interface; wiring and validation are consistent.
core/pkg/distribution/channel/pb/services.proto gRPC service renames (ChannelCreateService → CreateService, etc.) change the full wire-level method paths, breaking communication between nodes running different binary versions.
core/pkg/distribution/transport/grpc/transport.go New gRPC aggregator that bundles channel and framer transports and exposes BindableTransports() for server registration; clean implementation.
core/pkg/distribution/transport/mock/network.go New top-level mock Network that provisions a distribution.Transport per node; mirrors gRPC aggregator with shared in-memory state.
core/pkg/distribution/proxy/proxy.go BatchFactory.Host made private via NewBatchFactory constructor; Entry.Lease() now returns node.Key; all call sites updated correctly.
x/go/pool/pool.go Factory.New renamed to Open; pool constructor renamed New→Open; zero-value helper added for generic error return paths; all callers updated.
core/pkg/distribution/mock/cluster.go Simplifies cluster mock by replacing five separate network fields with a single transportNet; removes the now-redundant mockFramerTransport adapter struct.
core/pkg/distribution/transport/grpc/channel/transport.go Moves New() into this file; fixes pre-existing omission by applying middleware to rename endpoints in Use(); all interface assertions preserved.
core/cmd/start/start.go Adapts bootup to use the unified disttransport.New; BindableTransports() now supplies the gRPC server registrations correctly.
freighter/go/grpc/pool.go NewPool → OpenPool rename, factory.New → Open, and fixes a bug where an error from grpc.NewClient was swallowed (demand was initialized before checking the error).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    LC[LayerConfig.Transport\ndistribution.Transport] --> CH[Channel\nchannel.Transport]
    LC --> FR[Framer\nframer.Transport]

    CH --> CC[CreateClient / CreateServer]
    CH --> DC[DeleteClient / DeleteServer]
    CH --> RC[RenameClient / RenameServer]

    FR --> WR[Writer\nwriter.Transport]
    FR --> IT[Iterator\niterator.Transport]
    FR --> RL[Relay\nrelay.Transport]
    FR --> DL[Deleter\ndeleter.Transport]

    subgraph gRPC Implementation
        GT[grpc.Transport] --> GCH[grpc/channel.Transport]
        GT --> GFR[grpc/framer.Transport]
    end

    subgraph Mock Implementation
        MN[mock.Network] --> MCH[mock/channel.Network]
        MN --> MFR[mock/framer.Network]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    LC[LayerConfig.Transport\ndistribution.Transport] --> CH[Channel\nchannel.Transport]
    LC --> FR[Framer\nframer.Transport]

    CH --> CC[CreateClient / CreateServer]
    CH --> DC[DeleteClient / DeleteServer]
    CH --> RC[RenameClient / RenameServer]

    FR --> WR[Writer\nwriter.Transport]
    FR --> IT[Iterator\niterator.Transport]
    FR --> RL[Relay\nrelay.Transport]
    FR --> DL[Deleter\ndeleter.Transport]

    subgraph gRPC Implementation
        GT[grpc.Transport] --> GCH[grpc/channel.Transport]
        GT --> GFR[grpc/framer.Transport]
    end

    subgraph Mock Implementation
        MN[mock.Network] --> MCH[mock/channel.Network]
        MN --> MFR[mock/framer.Network]
    end
Loading

Reviews (2): Last reviewed commit: "update network_test.go" | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.15498% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.84%. Comparing base (8cbe798) to head (54334c9).
⚠️ Report is 1 commits behind head on rc.

Files with missing lines Patch % Lines
freighter/go/grpc/pool.go 75.00% 2 Missing and 1 partial ⚠️
x/go/pool/pool.go 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               rc    #2531      +/-   ##
==========================================
+ Coverage   68.77%   68.84%   +0.06%     
==========================================
  Files        2608     2622      +14     
  Lines      129273   129471     +198     
  Branches     9310     9302       -8     
==========================================
+ Hits        88912    89131     +219     
+ Misses      33649    33630      -19     
+ Partials     6712     6710       -2     
Flag Coverage Δ
alamos-go 55.25% <ø> (ø)
arc-go 77.85% <ø> (ø)
aspen 84.02% <100.00%> (+0.14%) ⬆️
cesium 82.65% <ø> (-0.03%) ⬇️
client-py 85.86% <ø> (-0.04%) ⬇️
client-ts 91.17% <ø> (ø)
console 32.10% <ø> (ø)
core 73.26% <100.00%> (+0.35%) ⬆️
freighter-go 68.09% <88.46%> (+0.52%) ⬆️
freighter-integration 53.19% <ø> (ø)
freighter-py 79.70% <ø> (ø)
freighter-ts 75.68% <ø> (ø)
oracle 62.97% <ø> (ø)
pluto 62.30% <ø> (+0.02%) ⬆️
x-go 82.80% <86.66%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread core/pkg/distribution/transport/mock/network_test.go Outdated
…o services

Bring over the new proxy and distribution transport test suites, document the
public transport types/methods, and fix bugs surfaced by the tests: the gRPC
framer deleter client had a nil Exec, the framer deleter server was never bound,
server-side (and deleter) middleware was never wired into Use, and channel Use
skipped rename. Mark internal node-to-node servers as Internal for richer error
encoding.

Rename the distribution channel gRPC services ChannelCreateService/
ChannelDeleteService/ChannelRenameService to CreateService/DeleteService/
RenameService and regenerate the protobuf stubs.
Add doc comments to the distribution channel Transport interface, its operation
transports, and the create/delete/rename request payloads (and their fields), and
to the channel proto services/messages in services.proto (regenerated). Document
the remaining exported methods across the distribution transport gRPC and mock
implementations so every public identifier carries a comment.
Drop the Transport infix and Unary prefix from the per-operation transport type
aliases: channel exposes CreateClient/CreateServer, DeleteClient/DeleteServer, and
RenameClient/RenameServer; the unary deleter exposes bare Client/Server. Group each
channel operation's payload with its client/server alias block.
Move Request above the Client/Server aliases and Transport interface that reference
it, so types flow from least to most dependent.
Rename StreamClient/StreamServer to bare Client/Server in the iterator, relay, and
writer packages (matching the deleter), keeping the ClientStream/ServerStream stream
handle aliases. Updates the definitions and the gRPC/mock implementations.
pjdotson added 2 commits June 25, 2026 15:42
Replace the explicit DeferCleanup(func() { Expect(pool.Close()).To(Succeed()) }) with
DeferClose at the OpenPool call site across the gRPC suite and transport tests, and
close the previously-unclosed pool in the construction test.
Comment thread core/pkg/distribution/channel/pb/services.proto

@emilbon99 emilbon99 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.

Approved after comments addressed.

Comment thread core/pkg/distribution/proxy/proxy.go Outdated
Comment thread x/go/pool/pool.go Outdated
Comment thread freighter/go/grpc/pool.go Outdated

// Pool is a pool of reusable gRPC client connections keyed by target address. Open one
// with [OpenPool] and acquire connections through the embedded [pool.Pool] interface.
type Pool struct {

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.

Do we even need this wrapper type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

made it just a type alias but kept so type parameters didn't have to get passed around everywhere.

Comment thread core/pkg/distribution/transport/grpc/grpc_suite_test.go Outdated
@pjdotson pjdotson merged commit 5f4f00c into rc Jun 26, 2026
41 checks passed
@pjdotson pjdotson deleted the sy-4432-refactor-distribution-proxy-and-transport branch June 26, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants