Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 35 additions & 1 deletion MODERNIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,41 @@ exactly that. So consolidation walks the dependency chain from the top:
Verified: Release build, dht tests 83/83 (incl. the two new PR #43
race tests), tn 12+1, proxyclient 15/15, standalone builds of the
whole chain, lint green over all module units.
4. C-4 streamr-proto-rpc
4. **C-4 streamr-proto-rpc** ✅ — the step that removed the LAST textual
dependency chain in the tree: the protoc plugin's generated RPC stub
headers (`*.client.pb.h` / `*.server.pb.h`), which `#include`d
`RpcCommunicator.hpp` and thereby dragged the whole proto-rpc +
logger header web into every package that uses generated stubs.
**The plugin now emits C++ module units instead of headers**
(`PluginCodeGenerator.hpp` rewritten): for each proto service file it
generates `X.client.cppm` / `X.server.cppm`, named
`<prefix>.XClient` / `<prefix>.XServer` where the consuming package
passes its module family as a protoc plugin parameter
(`--streamr_out=module_prefix=streamr.dht:./modules/gen`). Server
stubs are pure interfaces (no proto-rpc dependency at all); client
stubs `import streamr.protorpc.RpcCommunicator;`. Generated units
land in `modules/gen/` (library packages — picked up by the existing
recursive module glob, excluded from linting like all generated
code) or next to the generated message code (proto-rpc tests and
examples). The six proto-rpc public headers became named sub-modules
under `modules/` per the settled architecture; include/ deleted; the
plugin's own sources moved to `src/` (host tooling, not a public
API). Two headers survive INTENTIONALLY, both generated message
code: `*.pb.h` stays textual (`#include` in global module fragments)
because protoc emits headers — exactly the end-state carve-out the
consolidation decision defined.
One duplicate-stub hazard removed: trackerless-network used to
REGENERATE the dht stubs into its own tree (harmless as textual
headers, an ODR violation as module-attached classes) — its proto.sh
now generates DhtRpc message types only, and dht's own stub modules
are the single definition. Tests and examples import the generated
stub modules directly (`streamr.protorpc.test.*`,
`streamr.protorpc.examples.*`), and the last `import
streamr.protorpc;` umbrella consumers (4 dht units, 5 proto-rpc
test/example files, 1 dht test) flipped to narrow imports.
Verified: whole-tree build, 309/309 tests, standalone chain
(proto-rpc → dht → trackerless-network → proxyclient), lint green
over the module units.
5. C-5 streamr-utils
6. C-6 streamr-logger
7. C-7 streamr-json
Expand Down
5 changes: 4 additions & 1 deletion packages/streamr-dht/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ echo "Running clang-format --dry-run on $FILES"
# clangd-tidy as the source of truth (the consolidated units carry no
# export-using re-export blocks, which caused the earlier clangd false
# positives).
MODULE_FILES=$(find ./modules -type f -name "*.cppm" 2>/dev/null | xargs echo)
# modules/gen/ holds protoc-plugin GENERATED module units (RPC stubs):
# excluded from linting like all generated code (see the src/proto
# exclusion above); the compiler builds them on every platform.
MODULE_FILES=$(find ./modules -type f -name "*.cppm" ! -path './modules/gen/*' 2>/dev/null | xargs echo)
if [ -n "$MODULE_FILES" ]; then
echo "Running clangd-tidy on $MODULE_FILES"
clangd-tidy -p ./build $MODULE_FILES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module;
#include <functional>
#include <optional>
#include "packages/dht/protos/DhtRpc.pb.h"
#include "packages/dht/protos/DhtRpc.server.pb.h"

#include <string>

export module streamr.dht.ConnectionLockRpcLocal;

import streamr.dht.DhtRpcServer;
import streamr.logger;
import streamr.dht.ConnectionLockStates;
import streamr.dht.DhtCallContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module;
#include <chrono>
#include <optional>
#include <folly/experimental/coro/Task.h>
#include "packages/dht/protos/DhtRpc.client.pb.h"
#include "packages/dht/protos/DhtRpc.pb.h"

#include <string>

export module streamr.dht.ConnectionLockRpcRemote;

import streamr.dht.DhtRpcClient;
import streamr.logger;
import streamr.dht.ConnectionLockStates;
import streamr.dht.DhtCallContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module;

export module streamr.dht.ConnectionManager;

import streamr.protorpc;
import streamr.protorpc.RpcCommunicator;
import streamr.dht.ConnectionLockStates;
import streamr.logger;
import streamr.utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export module streamr.dht.ConnectorFacade;

import streamr.dht.Identifiers;
import streamr.logger;
import streamr.protorpc;
import streamr.protorpc.RpcCommunicator;
import streamr.dht.IPendingConnection;
import streamr.dht.ListeningRpcCommunicator;
import streamr.dht.PendingConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module;

#include <functional>
#include "packages/dht/protos/DhtRpc.pb.h"
#include "packages/dht/protos/DhtRpc.server.pb.h"

#include <string>

export module streamr.dht.WebsocketClientConnectorRpcLocal;

import streamr.dht.DhtRpcServer;
import streamr.utils;
import streamr.dht.DhtCallContext;
import streamr.dht.IPendingConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
module;

#include <folly/experimental/coro/Task.h>
#include "packages/dht/protos/DhtRpc.client.pb.h"
#include "packages/dht/protos/DhtRpc.pb.h"

export module streamr.dht.WebsocketClientConnectorRpcRemote;

import streamr.dht.DhtRpcClient;
import streamr.protorpc.RpcCommunicator;
import streamr.logger;
import streamr.dht.DhtCallContext;
import streamr.dht.Identifiers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// generated by the protocol buffer streamr pluging. DO NOT EDIT!
// generated from protobuf file "packages/dht/protos/DhtRpc.proto"

#ifndef STREAMR_PROTORPC_DHTRPC_CLIENT_PB_H
#define STREAMR_PROTORPC_DHTRPC_CLIENT_PB_H
module;

#include <folly/experimental/coro/Task.h>
#include <chrono>
#include <optional>
#include "DhtRpc.pb.h" // NOLINT
#include "streamr-proto-rpc/RpcCommunicator.hpp"
#include "packages/dht/protos/DhtRpc.pb.h" // NOLINT


namespace dht {
export module streamr.dht.DhtRpcClient;

import streamr.protorpc.RpcCommunicator;

using streamr::protorpc::RpcCommunicator;

export namespace dht {
template <typename CallContextType>
class DhtNodeRpcClient {
private:
Expand Down Expand Up @@ -138,5 +141,3 @@ RpcCommunicator<CallContextType>& communicator;
}; // class ExternalApiRpcClient
}; // namespace dht

#endif // STREAMR_PROTORPC_DHTRPC_CLIENT_PB_H

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Generated by the protocol buffer streamr pluging. DO NOT EDIT!
// Generated from protobuf file "packages/dht/protos/DhtRpc.proto"

#ifndef STREAMR_PROTORPC_DHTRPC_SERVER_PB_H
#define STREAMR_PROTORPC_DHTRPC_SERVER_PB_H
module;

#include "DhtRpc.pb.h" // NOLINT
#include "packages/dht/protos/DhtRpc.pb.h" // NOLINT
#include <folly/experimental/coro/Task.h>

namespace dht {
export module streamr.dht.DhtRpcServer;

export namespace dht {
template <typename CallContextType>
class DhtNodeRpc {
public:
Expand Down Expand Up @@ -75,5 +76,3 @@ class ExternalApiRpc {
}; // class ExternalApiRpc
}; // namespace dht

#endif // STREAMR_PROTORPC_DHTRPC_SERVER_PB_H

38 changes: 8 additions & 30 deletions packages/streamr-dht/modules/streamr.dht-protos.cppm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// :protos partition — wraps the GENERATED DhtRpc protobuf trio (messages,
// enums, and the protoc-plugin-generated client/server stubs) in the
// global module fragment and re-exports the types used across this
// package's public APIs. Generated protobuf code stays #include-based
// permanently; this partition is how importers see the types without
// re-parsing the 12k-line header stack.
// Wraps the GENERATED DhtRpc protobuf messages and enums in the global
// module fragment and re-exports the types used across this package's
// public APIs. Generated protobuf MESSAGE code stays #include-based
// permanently; this module is how importers see the types without
// re-parsing the 12k-line header stack. The RPC client/server stubs are
// no longer here: the protoc plugin now emits them as their own module
// units (streamr.dht.DhtRpcClient / streamr.dht.DhtRpcServer under
// modules/gen/) — import those directly where the stubs are used.
module;

#include "packages/dht/protos/DhtRpc.client.pb.h"
#include "packages/dht/protos/DhtRpc.pb.h"
#include "packages/dht/protos/DhtRpc.server.pb.h"

export module streamr.dht.protos;

Expand Down Expand Up @@ -65,26 +65,4 @@ using enum ::dht::RouteMessageError;
using ::dht::RpcResponseError;
using enum ::dht::RpcResponseError;

// generated client stubs
using ::dht::ConnectionLockRpcClient;
using ::dht::DhtNodeRpcClient;
using ::dht::ExternalApiRpcClient;
using ::dht::RecursiveOperationRpcClient;
using ::dht::RecursiveOperationSessionRpcClient;
using ::dht::RouterRpcClient;
using ::dht::StoreRpcClient;
using ::dht::WebrtcConnectorRpcClient;
using ::dht::WebsocketClientConnectorRpcClient;

// generated server stubs
using ::dht::ConnectionLockRpc;
using ::dht::DhtNodeRpc;
using ::dht::ExternalApiRpc;
using ::dht::RecursiveOperationRpc;
using ::dht::RecursiveOperationSessionRpc;
using ::dht::RouterRpc;
using ::dht::StoreRpc;
using ::dht::WebrtcConnectorRpc;
using ::dht::WebsocketClientConnectorRpc;

} // namespace dht
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module;
export module streamr.dht.ListeningRpcCommunicator;

import streamr.eventemitter;
import streamr.protorpc;
import streamr.protorpc.Errors;
import streamr.protorpc.RpcCommunicator;
import streamr.dht.RoutingRpcCommunicator;
import streamr.dht.Transport;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module;
export module streamr.dht.RoutingRpcCommunicator;

import streamr.logger;
import streamr.protorpc;
import streamr.protorpc.RpcCommunicator;
import streamr.protorpc.protos;
import streamr.utils;
import streamr.dht.DhtCallContext;
import streamr.dht.Identifiers;
Expand Down
6 changes: 5 additions & 1 deletion packages/streamr-dht/proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ mkdir -p protos/packages/proto-rpc/protos
mkdir -p protos/packages/dht/protos
cp -r ../streamr-proto-rpc/protos/* protos/packages/proto-rpc/protos
cp protos/DhtRpc.proto protos/packages/dht/protos
${PROTOC} --plugin=protoc-gen-streamr=${PLUGIN} --streamr_out=./src/proto/packages/dht/protos --proto_path=./protos --cpp_out=./src/proto packages/dht/protos/DhtRpc.proto
mkdir -p ./modules/gen
# The plugin emits C++ module units (Phase 2.6): module_prefix names the
# module family; the units land under modules/gen so the module FILE_SET
# glob picks them up.
${PROTOC} --plugin=protoc-gen-streamr=${PLUGIN} "--streamr_out=module_prefix=streamr.dht:./modules/gen" --proto_path=./protos --cpp_out=./src/proto packages/dht/protos/DhtRpc.proto
${PROTOC} --proto_path=./protos --cpp_out=./src/proto packages/proto-rpc/protos/ProtoRpc.proto
rm -rf protos/packages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import streamr.dht.DhtCallContext;
import streamr.dht.WebsocketClientConnectorRpcRemote;
import streamr.dht.protos;
import streamr.protorpc;
import streamr.dht.DhtRpcClient;
import streamr.protorpc.RpcCommunicator;

using ::dht::PeerDescriptor;
using ::dht::WebsocketClientConnectorRpcClient;
Expand Down
52 changes: 38 additions & 14 deletions packages/streamr-proto-rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ add_library(streamr-proto-rpc)
set_property(TARGET streamr-proto-rpc PROPERTY CXX_STANDARD 26)
add_library(streamr::streamr-proto-rpc ALIAS streamr-proto-rpc)

# Module façade (MODERNIZATION.md Part 2), added to the existing library
# (it also compiles the generated ProtoRpc.pb.cc). :protos wraps the
# generated header; the other partitions mirror the public headers.
# CONSOLIDATED (MODERNIZATION.md Phase 2.6): one named sub-module per
# former public header (settled architecture: no umbrella; consumers and
# tests import the individual sub-modules), plus streamr.protorpc.protos
# over the generated ProtoRpc types. The library also compiles the
# generated ProtoRpc.pb.cc.
file(GLOB_RECURSE STREAMR_PROTORPC_MODULE_UNITS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/modules/*.cppm)
streamr_target_module_sources(streamr-proto-rpc
FILES
modules/streamr.protorpc.cppm
modules/streamr.protorpc-protos.cppm
modules/streamr.protorpc-all.cppm)
target_include_directories(streamr-proto-rpc
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>
FILES ${STREAMR_PROTORPC_MODULE_UNITS})
# Only the generated protobuf code remains a header consumers may need
# textually.
target_include_directories(streamr-proto-rpc
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/proto>
PUBLIC $<INSTALL_INTERFACE:include>
)

target_sources(streamr-proto-rpc
Expand Down Expand Up @@ -101,7 +101,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/streamr-proto-rpc-config.cmake"
# SDK/sysroot — see homebrewClang.cmake), so CMAKE_CROSSCOMPILING is
# FALSE there; IOS is set by toolchains/ios.toolchain.cmake.
if(NOT IOS AND NOT CMAKE_CROSSCOMPILING)
add_executable(protobuf-streamr-plugin src/PluginCodeGeneratorMain.cpp include/streamr-proto-rpc/PluginCodeGenerator.hpp)
add_executable(protobuf-streamr-plugin src/PluginCodeGeneratorMain.cpp src/PluginCodeGenerator.hpp)

target_include_directories(
protobuf-streamr-plugin PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -157,13 +157,23 @@ if(NOT IOS AND STREAMR_MODULES_SUPPORTED)

add_executable(streamr-proto-rpc-test-integration
test/proto/HelloRpc.pb.cc
test/proto/HelloRpc.client.pb.h
test/proto/TestProtos.pb.cc
test/proto/TestProtos.pb.cc
test/proto/WakeUpRpc.pb.cc
test/integration/ProtoRpcTest.cpp
)

streamr_enable_imports(streamr-proto-rpc-test-integration)
# The protoc plugin emits the RPC stubs as module units next to the
# generated message code; the test imports them directly
# (streamr.protorpc.test.*). PRIVATE: test-only modules, not part of
# any export.
file(GLOB STREAMR_PROTORPC_TEST_STUB_UNITS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/test/proto/*.cppm)
target_sources(streamr-proto-rpc-test-integration
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/test/proto
FILES ${STREAMR_PROTORPC_TEST_STUB_UNITS})
target_include_directories(streamr-proto-rpc-test-integration
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test/proto>
)
Expand Down Expand Up @@ -194,6 +204,13 @@ if(NOT IOS AND STREAMR_MODULES_SUPPORTED)
)

streamr_enable_imports(streamr-proto-rpc-example-hello)
file(GLOB STREAMR_PROTORPC_HELLO_STUB_UNITS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/examples/hello/proto/*.cppm)
target_sources(streamr-proto-rpc-example-hello
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello/proto
FILES ${STREAMR_PROTORPC_HELLO_STUB_UNITS})
target_include_directories(streamr-proto-rpc-example-hello
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/examples/hello/proto>
)
Expand All @@ -209,6 +226,13 @@ if(NOT IOS AND STREAMR_MODULES_SUPPORTED)
)

streamr_enable_imports(streamr-proto-rpc-example-routed-hello)
file(GLOB STREAMR_PROTORPC_ROUTED_STUB_UNITS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/examples/routed-hello/proto/*.cppm)
target_sources(streamr-proto-rpc-example-routed-hello
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/examples/routed-hello/proto
FILES ${STREAMR_PROTORPC_ROUTED_STUB_UNITS})
target_include_directories(streamr-proto-rpc-example-routed-hello
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/examples/routed-hello/proto>
)
Expand Down
8 changes: 5 additions & 3 deletions packages/streamr-proto-rpc/examples/hello/hello.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include <exception>
#include <iostream>
#include <folly/experimental/coro/BlockingWait.h>
#include "HelloRpc.client.pb.h"
#include "HelloRpc.pb.h"
#include "HelloRpc.server.pb.h"

import streamr.protorpc;
import streamr.protorpc.ProtoCallContext;
import streamr.protorpc.RpcCommunicator;
import streamr.protorpc.protos;
import streamr.protorpc.examples.HelloRpcClient;
import streamr.protorpc.examples.HelloRpcServer;

using streamr::protorpc::HelloRpcService;
using streamr::protorpc::HelloRpcServiceClient;
Expand Down
Loading
Loading