mirror of
https://github.com/logos-co/logos-verified-proxy-module.git
synced 2026-08-27 04:51:08 +00:00
Grows the typed surface from 8 methods to 60: all 30 eth_* the library dispatches, plus the 30 op_* mirrors. Everything was already reachable through rpc(); what was missing was discoverability — `lm methods`, the LIDL contract, and a caller's type checker. Generated, not hand-written. Each wrapper is three lines over the same shared path, so sixty-one of them by hand is sixty-one chances to transpose an argument; the table is extracted from the library's OWN dispatch table (the `case $name` in c_frontend.nim), including each parameter's real type — which is how ethGetBlockByNumber gets a bool, ethFeeHistory a uint64 and a list, and eth_call an object rather than everything being a string. They are still committed as literal text: the module's code generator parses verified_proxy_impl.h as TEXT to build the LIDL contract, so anything hidden behind a macro would simply not exist to it. `--check` proves the committed blocks still match, and fails on a one-character edit (verified). eth_syncing is deliberately excluded from the typed surface — the runtime issues it as its own keep-alive and a wrapper would invite callers to fight it. Still reachable through rpc(). CI is new for this repo, which had none: build on Linux and macOS, unit tests (the check derivation runs the suite as part of building it), and the codegen drift check. Named explicitly rather than via `nix flake check`, which would also evaluate the x86_64-windows pseudo-system. Verified live on sepolia through a real logoscore daemon: ethGasPrice, ethMaxPriorityFeePerGas, ethBlobBaseFee, ethGetBlockTransactionCountByNumber, ethGetUncleCountByBlockNumber and ethGetBlockByNumber all answer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
87 lines
3.9 KiB
CMake
87 lines
3.9 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
project(VerifiedProxyModulePlugin LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
if(DEFINED ENV{LOGOS_MODULE_BUILDER_ROOT})
|
|
include($ENV{LOGOS_MODULE_BUILDER_ROOT}/cmake/LogosModule.cmake)
|
|
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/LogosModule.cmake")
|
|
include(cmake/LogosModule.cmake)
|
|
else()
|
|
message(FATAL_ERROR "LogosModule.cmake not found. Set LOGOS_MODULE_BUILDER_ROOT.")
|
|
endif()
|
|
|
|
# Universal module — generated_code/ is picked up automatically.
|
|
logos_module(
|
|
NAME verified_proxy_module
|
|
SOURCES
|
|
src/verified_proxy_impl.h
|
|
src/verified_proxy_impl.cpp
|
|
src/verified_proxy_rpc.cpp
|
|
src/proxy_config.h
|
|
src/proxy_config.cpp
|
|
src/proxy_runtime.h
|
|
src/proxy_runtime.cpp
|
|
src/rpc_http_server.h
|
|
src/rpc_http_server.cpp
|
|
src/beacon_client.h
|
|
src/beacon_client.cpp
|
|
EXTERNAL_LIBS
|
|
verifproxy
|
|
INCLUDE_DIRS
|
|
lib
|
|
)
|
|
|
|
# Embedded JSON-RPC endpoint: libmicrohttpd, the same server openmetrics-module
|
|
# uses. libverifproxy deliberately ships none — the HTTP/WS frontend lives only
|
|
# in the standalone nimbus_verified_proxy binary and its symbols are absent from
|
|
# the archive we link — so the endpoint is ours.
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(MHD REQUIRED IMPORTED_TARGET libmicrohttpd)
|
|
target_link_libraries(verified_proxy_module_module_plugin PRIVATE PkgConfig::MHD)
|
|
|
|
# Outbound HTTP for fetchFinalizedRoot(). Only ever used for that one request:
|
|
# all verified traffic goes through the library's own chronos-based clients, so
|
|
# curl is not on any hot path.
|
|
pkg_check_modules(CURL REQUIRED IMPORTED_TARGET libcurl)
|
|
target_link_libraries(verified_proxy_module_module_plugin PRIVATE PkgConfig::CURL)
|
|
|
|
# Inject the module version from metadata.json so moduleVersion() reports it
|
|
# without parsing JSON at runtime.
|
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/metadata.json" _vp_metadata_json)
|
|
string(JSON VERIFIED_PROXY_MODULE_VERSION GET "${_vp_metadata_json}" version)
|
|
target_compile_definitions(verified_proxy_module_module_plugin
|
|
PRIVATE VERIFIED_PROXY_MODULE_VERSION="${VERIFIED_PROXY_MODULE_VERSION}")
|
|
|
|
# Native libraries libverifproxy.a leaves undefined. Copied from nimbus-eth1's
|
|
# own consumer recipe (Makefile VERIFPROXY_LDFLAGS), whose `libverifproxy_test`
|
|
# target links `-lverifproxy` PLAIN — no --whole-archive / -force_load — and
|
|
# then RUNS the result. That is the upstream proof that ordinary archive
|
|
# linking suffices here.
|
|
#
|
|
# These go here and NOT in metadata.json's nix.cmake.extra_link_libraries:
|
|
# that key is parsed (parseMetadata.nix:97) and read by no builder code path,
|
|
# so putting flags there links nothing at all.
|
|
if(APPLE)
|
|
# -framework Security is load-bearing AND cannot be inferred: LogosModule
|
|
# puts `-undefined dynamic_lookup` on every macOS plugin, so omitting it
|
|
# yields a plugin that LINKS CLEANLY and then fails at dlopen.
|
|
# No explicit -lc++: CMake already links the C++ runtime for a CXX target,
|
|
# and naming it again only produces a "duplicate libraries" warning.
|
|
target_link_libraries(verified_proxy_module_module_plugin PRIVATE
|
|
"-framework Security")
|
|
elseif(WIN32)
|
|
# Upstream says -lc++ because their dist build uses llvm-mingw; logos-nix's
|
|
# cross is gcc-mingw, so it is libstdc++ here. A static Nim archive records
|
|
# no imports, so the plugin must name the Win32 set itself.
|
|
target_link_libraries(verified_proxy_module_module_plugin PRIVATE
|
|
stdc++ ws2_32 bcrypt iphlpapi userenv ntdll dbghelp winpthread)
|
|
else()
|
|
target_link_libraries(verified_proxy_module_module_plugin PRIVATE stdc++ m)
|
|
# Do not re-export anything the archive carries (bearssl, secp256k1, blst,
|
|
# a vendored zlib/sqlite) into the host's global namespace.
|
|
target_link_options(verified_proxy_module_module_plugin PRIVATE
|
|
-Wl,--exclude-libs,ALL)
|
|
endif()
|