mirror of
https://github.com/logos-blockchain/logos-blockchain-module.git
synced 2026-01-02 05:03:08 +00:00
Fix plugin compilation.
This commit is contained in:
parent
8ac0122295
commit
8a19f7cf43
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,4 +9,5 @@ cmake_install.cmake
|
||||
cmake-build-debug
|
||||
|
||||
# Artifacts
|
||||
libblockchainmodulelib.so
|
||||
liblogos-blockchain-module.so
|
||||
liblogos-blockchain-module.log
|
||||
|
||||
138
CMakeLists.txt
138
CMakeLists.txt
@ -4,72 +4,43 @@ project(logos-blockchain-module LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# -------------------------
|
||||
# Options / Inputs
|
||||
# -------------------------
|
||||
option(UNTITLED_USE_QT "Enable Qt6 dependency" ON)
|
||||
option(COPY_PLUGIN_TO_SOURCE_DIR "Copy built plugin to source dir root (dev convenience)" ON)
|
||||
option(COPY_PLUGIN_TO_SOURCE_DIR "Copy built plugin to repo root (dev convenience)" ON)
|
||||
option(LOGOS_BUILD_DEPS_BY_DEFAULT "Always stage+build Rust deps when building the plugin" OFF)
|
||||
|
||||
# Default OFF: keep normal builds fast; deps are built when needed by link step,
|
||||
# and you can force-refresh via your Justfile update target.
|
||||
option(LOGOS_BUILD_DEPS_BY_DEFAULT "Force stage+cargo targets as explicit deps of the plugin" OFF)
|
||||
set(LOGOS_CPP_SDK_ROOT "" CACHE PATH "Path to logos-cpp-sdk root")
|
||||
set(LOGOS_BLOCKCHAIN_ROOT "" CACHE PATH "Path to logos-blockchain source root")
|
||||
|
||||
set(LOGOS_CPP_SDK_ROOT "" CACHE PATH "Path to logos-cpp-sdk package root (must contain include/core and include/cpp)")
|
||||
set(LOGOS_BLOCKCHAIN_ROOT "" CACHE PATH "Path to logos-blockchain source root (read-only in Nix store is OK)")
|
||||
|
||||
if(NOT DEFINED LOGOS_CPP_SDK_ROOT OR LOGOS_CPP_SDK_ROOT STREQUAL "")
|
||||
if(LOGOS_CPP_SDK_ROOT STREQUAL "")
|
||||
message(FATAL_ERROR "LOGOS_CPP_SDK_ROOT not set. Pass -DLOGOS_CPP_SDK_ROOT=/path/to/logos-cpp-sdk")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED LOGOS_BLOCKCHAIN_ROOT OR LOGOS_BLOCKCHAIN_ROOT STREQUAL "")
|
||||
if(LOGOS_BLOCKCHAIN_ROOT STREQUAL "")
|
||||
message(FATAL_ERROR "LOGOS_BLOCKCHAIN_ROOT not set. Pass -DLOGOS_BLOCKCHAIN_ROOT=/path/to/logos-blockchain")
|
||||
endif()
|
||||
|
||||
# -------------------------
|
||||
# Qt6
|
||||
# -------------------------
|
||||
if(UNTITLED_USE_QT)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
else()
|
||||
message(FATAL_ERROR "UNTITLED_USE_QT=OFF is not supported for this module (it's a Qt plugin).")
|
||||
endif()
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
# -------------------------
|
||||
# Writable stage of logos-blockchain source
|
||||
# (Fixes: build.rs/cbindgen writing into source dir inside /nix/store)
|
||||
# -------------------------
|
||||
# ---- writable stage (Nix store is read-only) ----
|
||||
set(LOGOS_BLOCKCHAIN_WORKDIR "${CMAKE_BINARY_DIR}/logos_blockchain_src")
|
||||
set(LOGOS_BLOCKCHAIN_STAGE_STAMP "${LOGOS_BLOCKCHAIN_WORKDIR}/.staged")
|
||||
|
||||
# NOTE:
|
||||
# - We do NOT rm -rf here; normal builds stay stable.
|
||||
# - Force refresh is handled by deleting workdir/stamp in your Justfile update target.
|
||||
add_custom_command(
|
||||
OUTPUT "${LOGOS_BLOCKCHAIN_STAGE_STAMP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Staging logos-blockchain into writable dir: ${LOGOS_BLOCKCHAIN_WORKDIR}"
|
||||
OUTPUT "${LOGOS_BLOCKCHAIN_STAGE_STAMP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${LOGOS_BLOCKCHAIN_WORKDIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${LOGOS_BLOCKCHAIN_ROOT}" "${LOGOS_BLOCKCHAIN_WORKDIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${LOGOS_BLOCKCHAIN_ROOT}" "${LOGOS_BLOCKCHAIN_WORKDIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${LOGOS_BLOCKCHAIN_STAGE_STAMP}"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(logos_blockchain_stage DEPENDS "${LOGOS_BLOCKCHAIN_STAGE_STAMP}")
|
||||
|
||||
# Not ALL: only runs when required.
|
||||
add_custom_target(logos_blockchain_stage
|
||||
DEPENDS "${LOGOS_BLOCKCHAIN_STAGE_STAMP}"
|
||||
)
|
||||
# ---- build + stage nomos-c (Rust) ----
|
||||
set(LOGOS_INSTALL_DIR "${CMAKE_BINARY_DIR}/logos_stage")
|
||||
file(MAKE_DIRECTORY "${LOGOS_INSTALL_DIR}/include" "${LOGOS_INSTALL_DIR}/lib")
|
||||
|
||||
# -------------------------
|
||||
# Build nomos-c (Rust) and stage outputs
|
||||
# -------------------------
|
||||
set(LOGOS_STAGE_DIR "${CMAKE_BINARY_DIR}/logos_stage")
|
||||
set(LOGOS_INSTALL_DIR "${LOGOS_STAGE_DIR}")
|
||||
file(MAKE_DIRECTORY "${LOGOS_INSTALL_DIR}/include")
|
||||
file(MAKE_DIRECTORY "${LOGOS_INSTALL_DIR}/lib")
|
||||
set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/cargo-target")
|
||||
|
||||
# Platform naming
|
||||
if(APPLE)
|
||||
set(NOMOS_EXT ".dylib")
|
||||
elseif(WIN32)
|
||||
@ -78,36 +49,28 @@ else()
|
||||
set(NOMOS_EXT ".so")
|
||||
endif()
|
||||
|
||||
# What cargo produces and what we stage as
|
||||
set(NOMOS_C_SOURCE_DYLIB_NAME "liblibnomos${NOMOS_EXT}" CACHE STRING "Shared library filename produced by cargo in target/release")
|
||||
set(NOMOS_C_STAGED_DYLIB_NAME "libnomos${NOMOS_EXT}" CACHE STRING "Staged shared library filename")
|
||||
set(NOMOS_C_HEADER_NAME "libnomos.h" CACHE STRING "Header file name (in nomos-c crate root)")
|
||||
set(NOMOS_C_SOURCE_DYLIB_NAME "liblibnomos${NOMOS_EXT}" CACHE STRING "Filename produced by cargo")
|
||||
set(NOMOS_C_STAGED_DYLIB_NAME "libnomos${NOMOS_EXT}" CACHE STRING "Filename staged next to plugin")
|
||||
set(NOMOS_C_HEADER_NAME "libnomos.h" CACHE STRING "Header in nomos-c crate root")
|
||||
|
||||
set(NOMOS_STAGED_DYLIB "${LOGOS_INSTALL_DIR}/lib/${NOMOS_C_STAGED_DYLIB_NAME}")
|
||||
set(NOMOS_STAGED_HEADER "${LOGOS_INSTALL_DIR}/include/${NOMOS_C_HEADER_NAME}")
|
||||
|
||||
# Build output dir for cargo (writable)
|
||||
set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/cargo-target")
|
||||
|
||||
# Linux-only SONAME patching command list
|
||||
set(PATCHELF_COMMANDS "")
|
||||
if(UNIX AND NOT APPLE AND NOT WIN32)
|
||||
find_program(PATCHELF_EXE patchelf REQUIRED)
|
||||
set(PATCHELF_COMMANDS
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Patching SONAME of ${NOMOS_C_STAGED_DYLIB_NAME}"
|
||||
COMMAND ${PATCHELF_EXE} --set-soname "${NOMOS_C_STAGED_DYLIB_NAME}" "${NOMOS_STAGED_DYLIB}"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${NOMOS_STAGED_DYLIB}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Building nomos-c (Rust) from writable copy: ${LOGOS_BLOCKCHAIN_WORKDIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${CARGO_TARGET_DIR}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
CARGO_TERM_COLOR=always
|
||||
CARGO_TARGET_DIR=${CARGO_TARGET_DIR}
|
||||
cargo build --release --package nomos-c
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${LOGOS_INSTALL_DIR}/lib"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${CARGO_TARGET_DIR}/release/${NOMOS_C_SOURCE_DYLIB_NAME}"
|
||||
"${NOMOS_STAGED_DYLIB}"
|
||||
@ -119,8 +82,6 @@ add_custom_command(
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${NOMOS_STAGED_HEADER}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Staging ${NOMOS_C_HEADER_NAME} from writable copy"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${LOGOS_INSTALL_DIR}/include"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${LOGOS_BLOCKCHAIN_WORKDIR}/nomos-c/${NOMOS_C_HEADER_NAME}"
|
||||
"${NOMOS_STAGED_HEADER}"
|
||||
@ -128,24 +89,16 @@ add_custom_command(
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Not ALL: only runs when required.
|
||||
add_custom_target(logos_cargo_build
|
||||
DEPENDS "${NOMOS_STAGED_DYLIB}" "${NOMOS_STAGED_HEADER}"
|
||||
)
|
||||
add_custom_target(logos_cargo_build DEPENDS "${NOMOS_STAGED_DYLIB}" "${NOMOS_STAGED_HEADER}")
|
||||
|
||||
# Imported library for consumers (this is what the plugin links)
|
||||
add_library(nomos_c SHARED IMPORTED GLOBAL)
|
||||
set_target_properties(nomos_c PROPERTIES
|
||||
IMPORTED_LOCATION "${NOMOS_STAGED_DYLIB}"
|
||||
IMPORTED_LOCATION "${NOMOS_STAGED_DYLIB}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LOGOS_INSTALL_DIR}/include"
|
||||
)
|
||||
|
||||
# Ensure the imported target is materialized before consumers link
|
||||
add_dependencies(nomos_c logos_cargo_build)
|
||||
|
||||
# -------------------------
|
||||
# logos-cpp-sdk headers (viewer-style)
|
||||
# -------------------------
|
||||
# ---- logos-cpp-sdk ----
|
||||
add_library(logos_cpp_sdk INTERFACE)
|
||||
target_include_directories(logos_cpp_sdk INTERFACE
|
||||
"${LOGOS_CPP_SDK_ROOT}/include/core"
|
||||
@ -153,13 +106,20 @@ target_include_directories(logos_cpp_sdk INTERFACE
|
||||
"${LOGOS_CPP_SDK_ROOT}/include"
|
||||
)
|
||||
|
||||
# -------------------------
|
||||
# Qt plugin target
|
||||
# -------------------------
|
||||
set(PLUGIN_TARGET blockchainmodulelib)
|
||||
add_library(logos_core STATIC IMPORTED)
|
||||
set_target_properties(logos_core PROPERTIES
|
||||
IMPORTED_LOCATION "${LOGOS_CPP_SDK_ROOT}/lib/liblogos_sdk.a"
|
||||
)
|
||||
|
||||
qt_add_plugin(${PLUGIN_TARGET}
|
||||
CLASS_NAME LogosBlockchainModule
|
||||
# ---- plugin ----
|
||||
set(MODULE_ID "liblogos-blockchain-module")
|
||||
set(PLUGIN_TARGET "${MODULE_ID}")
|
||||
|
||||
qt_add_plugin(${PLUGIN_TARGET} CLASS_NAME LogosBlockchainModule)
|
||||
|
||||
# Keep the filename expected by the viewer/tooling (if you still want it this way)
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES
|
||||
OUTPUT_NAME "logos-blockchain-module"
|
||||
)
|
||||
|
||||
target_sources(${PLUGIN_TARGET} PRIVATE
|
||||
@ -171,51 +131,33 @@ target_link_libraries(${PLUGIN_TARGET} PRIVATE
|
||||
Qt6::Core
|
||||
nomos_c
|
||||
logos_cpp_sdk
|
||||
logos_core
|
||||
)
|
||||
|
||||
target_compile_definitions(${PLUGIN_TARGET} PRIVATE USING_QT)
|
||||
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTOUIC ON
|
||||
AUTORCC ON
|
||||
)
|
||||
|
||||
# Optional: force deps as explicit build dependencies of the plugin target.
|
||||
# This is mainly useful if you want "build plugin" to always stage+build first.
|
||||
if(LOGOS_BUILD_DEPS_BY_DEFAULT)
|
||||
add_dependencies(${PLUGIN_TARGET} logos_blockchain_stage logos_cargo_build)
|
||||
endif()
|
||||
|
||||
# Runtime: prefer libnomos next to the plugin
|
||||
if(APPLE)
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES
|
||||
BUILD_RPATH "@loader_path"
|
||||
INSTALL_RPATH "@loader_path"
|
||||
)
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES BUILD_RPATH "@loader_path" INSTALL_RPATH "@loader_path")
|
||||
elseif(UNIX)
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES
|
||||
BUILD_RPATH "$ORIGIN"
|
||||
INSTALL_RPATH "$ORIGIN"
|
||||
)
|
||||
set_target_properties(${PLUGIN_TARGET} PROPERTIES BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN")
|
||||
endif()
|
||||
|
||||
# Copy libnomos next to plugin in build output for runtime loading
|
||||
add_custom_command(TARGET ${PLUGIN_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${NOMOS_STAGED_DYLIB}"
|
||||
"$<TARGET_FILE_DIR:${PLUGIN_TARGET}>/${NOMOS_C_STAGED_DYLIB_NAME}"
|
||||
COMMENT "Copying ${NOMOS_C_STAGED_DYLIB_NAME} next to plugin for runtime loading"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Dev convenience: copy the plugin to repo root
|
||||
if(COPY_PLUGIN_TO_SOURCE_DIR)
|
||||
add_custom_command(TARGET ${PLUGIN_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"$<TARGET_FILE:${PLUGIN_TARGET}>"
|
||||
"${CMAKE_SOURCE_DIR}/$<TARGET_FILE_NAME:${PLUGIN_TARGET}>"
|
||||
COMMENT "Copying plugin to source root"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
182
config.yaml
Normal file
182
config.yaml
Normal file
@ -0,0 +1,182 @@
|
||||
tracing:
|
||||
logger: !Stdout
|
||||
tracing: None
|
||||
filter: None
|
||||
metrics: None
|
||||
console: None
|
||||
level: DEBUG
|
||||
network:
|
||||
backend:
|
||||
swarm:
|
||||
host: 0.0.0.0
|
||||
port: 3000
|
||||
node_key: ea1e1dcc31612bd20987f017f0ca435cd2a59a4bd9fd6e14883b4803ae3b803d
|
||||
initial_peers: [ ]
|
||||
blend:
|
||||
non_ephemeral_signing_key: 32e4b52b78e0e8273f31e2ae0826d09b0348d4c66824af4f51ec4ef338082211
|
||||
recovery_path_prefix: ./recovery/blend
|
||||
core:
|
||||
backend:
|
||||
listening_address: /ip4/127.0.0.1/udp/3001/quic-v1
|
||||
core_peering_degree:
|
||||
start: 4
|
||||
end: 8
|
||||
edge_node_connection_timeout:
|
||||
secs: 1
|
||||
nanos: 0
|
||||
max_edge_node_incoming_connections: 300
|
||||
max_dial_attempts_per_peer: 3
|
||||
zk:
|
||||
secret_key_kms_id: 32e4b52b78e0e8273f31e2ae0826d09b0348d4c66824af4f51ec4ef338082211
|
||||
edge:
|
||||
backend:
|
||||
max_dial_attempts_per_peer_per_message: 1
|
||||
replication_factor: 1
|
||||
deployment: mainnet
|
||||
da_network:
|
||||
backend:
|
||||
node_key: ea1e1dcc31612bd20987f017f0ca435cd2a59a4bd9fd6e14883b4803ae3b803d
|
||||
listening_address: /ip4/127.0.0.1/udp/8716/quic-v1
|
||||
policy_settings:
|
||||
min_dispersal_peers: 1
|
||||
min_replication_peers: 1
|
||||
max_dispersal_failures: 3
|
||||
max_sampling_failures: 3
|
||||
max_replication_failures: 3
|
||||
malicious_threshold: 5
|
||||
monitor_settings:
|
||||
failure_time_window: "10.0"
|
||||
time_decay_factor: "0.8"
|
||||
balancer_interval:
|
||||
secs: 5
|
||||
nanos: 0
|
||||
redial_cooldown:
|
||||
secs: 5
|
||||
nanos: 0
|
||||
replication_settings:
|
||||
seen_message_cache_size: 1000
|
||||
seen_message_ttl: "3600.0"
|
||||
subnets_settings:
|
||||
num_of_subnets: 20
|
||||
shares_retry_limit: 5
|
||||
commitments_retry_limit: 5
|
||||
membership:
|
||||
replication_factor: 2
|
||||
subnetwork_size: 2
|
||||
api_adapter_settings:
|
||||
api_port: 8722
|
||||
is_secure: false
|
||||
subnet_refresh_interval:
|
||||
secs: 30
|
||||
nanos: 0
|
||||
subnet_threshold: 2048
|
||||
min_session_members: 2
|
||||
da_verifier:
|
||||
share_verifier_settings:
|
||||
global_params_path: ./tests/kzgrs/kzgrs_test_params
|
||||
domain_size: 2
|
||||
tx_verifier_settings: null
|
||||
network_adapter_settings: null
|
||||
storage_adapter_settings:
|
||||
blob_storage_directory: ./
|
||||
mempool_trigger_settings:
|
||||
publish_threshold: 0.8
|
||||
share_duration: [ 5, 0 ]
|
||||
prune_duration: [ 30, 0 ]
|
||||
prune_interval: [ 5, 0 ]
|
||||
da_sampling:
|
||||
share_verifier_settings:
|
||||
global_params_path: ./tests/kzgrs/kzgrs_test_params
|
||||
domain_size: 2
|
||||
sampling_settings:
|
||||
num_samples: 1
|
||||
num_subnets: 2
|
||||
old_blobs_check_interval:
|
||||
secs: 5
|
||||
nanos: 0
|
||||
blobs_validity_duration:
|
||||
secs: 18446744073709551615
|
||||
nanos: 0
|
||||
commitments_wait_duration:
|
||||
secs: 2
|
||||
nanos: 0
|
||||
sdp_blob_trigger_sampling_delay:
|
||||
secs: 5
|
||||
nanos: 0
|
||||
http:
|
||||
backend_settings:
|
||||
address: 127.0.0.1:8722
|
||||
cors_origins: [ ]
|
||||
time:
|
||||
chain_start_time: [ 2025, 41, 9, 38, 29, 993653000, 0, 0, 0 ]
|
||||
backend:
|
||||
update_interval: [ 16, 0 ]
|
||||
ntp_server: pool.ntp.org
|
||||
ntp_client_settings:
|
||||
timeout: [ 5, 0 ]
|
||||
listening_interface: 0.0.0.0
|
||||
cryptarchia:
|
||||
service:
|
||||
starting_state: !Genesis
|
||||
genesis_tx:
|
||||
mantle_tx:
|
||||
ops:
|
||||
- opcode: 0
|
||||
payload:
|
||||
channel_id: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
inscription: [ 103, 101, 110, 101, 115, 105, 115 ] # "genesis" in bytes
|
||||
parent: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
signer: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
ledger_tx:
|
||||
inputs: []
|
||||
outputs:
|
||||
- value: 1
|
||||
pk: d204000000000000000000000000000000000000000000000000000000000000
|
||||
execution_gas_price: 0
|
||||
storage_gas_price: 0
|
||||
ops_proofs: [NoProof]
|
||||
ledger_tx_proof:
|
||||
pi_a: [
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]
|
||||
pi_b: [
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]
|
||||
pi_c: [
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]
|
||||
recovery_file: ./recovery/cryptarchia.json
|
||||
bootstrap:
|
||||
prolonged_bootstrap_period: [ 86400, 0 ]
|
||||
force_bootstrap: false
|
||||
offline_grace_period:
|
||||
grace_period: [ 1200, 0 ]
|
||||
state_recording_interval: [ 60, 0 ]
|
||||
network:
|
||||
bootstrap:
|
||||
ibd:
|
||||
peers: [ ]
|
||||
sync:
|
||||
orphan:
|
||||
max_orphan_cache_size: 5
|
||||
leader:
|
||||
pk: "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
sk: 3cf3335017304dcfce45124a0633829f00000000000000000000000000000000
|
||||
storage:
|
||||
db_path: nomos_db
|
||||
read_only: false
|
||||
column_family: blocks
|
||||
mempool:
|
||||
recovery_path: ./recovery/mempool.json
|
||||
sdp:
|
||||
wallet:
|
||||
known_keys:
|
||||
- "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
key_management:
|
||||
keys:
|
||||
leader_key: !Zk 3cf3335017304dcfce45124a0633829f00000000000000000000000000000000
|
||||
12
justfile
12
justfile
@ -4,27 +4,29 @@ configure:
|
||||
test -n "${LOGOS_CPP_SDK_ROOT}" || (echo "LOGOS_CPP_SDK_ROOT not set" && exit 1)
|
||||
test -n "${LOGOS_BLOCKCHAIN_ROOT}" || (echo "LOGOS_BLOCKCHAIN_ROOT not set" && exit 1)
|
||||
cmake -S . -B build -G Ninja \
|
||||
-DUNTITLED_USE_QT=ON \
|
||||
-DLOGOS_CPP_SDK_ROOT="${LOGOS_CPP_SDK_ROOT}" \
|
||||
-DLOGOS_BLOCKCHAIN_ROOT="${LOGOS_BLOCKCHAIN_ROOT}" \
|
||||
-DCOPY_PLUGIN_TO_SOURCE_DIR=ON
|
||||
|
||||
build:
|
||||
cmake --build build --parallel --target blockchainmodulelib
|
||||
cmake --build build --parallel --target liblogos-blockchain-module
|
||||
|
||||
update:
|
||||
rm -rf build/logos_blockchain_src
|
||||
rm -f build/logos_blockchain_src/.staged
|
||||
rm -rf build/logos_stage
|
||||
cmake --build build --parallel --target logos_blockchain_stage
|
||||
cmake --build build --parallel --target logos_cargo_build
|
||||
just build
|
||||
|
||||
clean:
|
||||
rm -f build/liblogos-blockchain-module.so
|
||||
rm -f liblogos-blockchain-module.so
|
||||
rm -f liblogos-blockchain-module.log
|
||||
|
||||
clean-full: clean
|
||||
rm -rf build
|
||||
rm -f libblockchainmodulelib.so
|
||||
|
||||
rebuild: clean configure build
|
||||
|
||||
run:
|
||||
../logos-module-viewer/result/bin/logos-module-viewer --module libblockchainmodulelib.so > libblockchainmodulelib.log 2>&1
|
||||
../logos-module-viewer/result/bin/logos-module-viewer --module liblogos-blockchain-module.so > liblogos-blockchain-module.log 2>&1
|
||||
|
||||
57
library.cpp
57
library.cpp
@ -1,59 +1,55 @@
|
||||
#include "library.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QDebug>
|
||||
#include <core/interface.h>
|
||||
|
||||
class LogosBlockchainModule : public QObject, public LogosBlockchainModuleAPI {
|
||||
class LogosBlockchainModule : public LogosBlockchainModuleAPI {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID LogosBlockchainModuleInterface_iid FILE "metadata.json")
|
||||
Q_INTERFACES(LogosBlockchainModuleAPI PluginInterface)
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
private:
|
||||
NomosNode* node = nullptr;
|
||||
|
||||
public:
|
||||
LogosBlockchainModule() : node(nullptr) {
|
||||
LogosBlockchainModule() = default;
|
||||
|
||||
~LogosBlockchainModule() override {
|
||||
if (node) stop();
|
||||
}
|
||||
|
||||
virtual ~LogosBlockchainModule() {
|
||||
if (node != nullptr) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
// PluginInterface implementation
|
||||
QString name() const override { return "logos-blockchain-module"; }
|
||||
QString name() const override { return "liblogos-blockchain-module"; }
|
||||
QString version() const override { return "1.0.0"; }
|
||||
|
||||
void initLogos(LogosAPI* logosAPIInstance) {
|
||||
void initLogos(LogosAPI* logosAPIInstance) override {
|
||||
logosAPI = logosAPIInstance;
|
||||
// logos = new LogosModules(logosAPI); // generated wrappers aggregator
|
||||
// logos->core_manager.setEventSource(this); // enable trigger() helper
|
||||
}
|
||||
|
||||
Q_INVOKABLE void start(const QString &config_path) override {
|
||||
if (node != nullptr) {
|
||||
Q_INVOKABLE int start(const QString& config_path) override {
|
||||
if (node) {
|
||||
qWarning() << "Node already started";
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
QByteArray configPathBytes = config_path.toUtf8();
|
||||
InitializedNomosNodeResult result = start_nomos_node(configPathBytes.constData());
|
||||
const QByteArray path = config_path.toUtf8();
|
||||
InitializedNomosNodeResult result = start_nomos_node(path.constData());
|
||||
|
||||
if (!is_ok(&result.error)) {
|
||||
qCritical() << "Failed to start Nomos node. Error code:" << result.error;
|
||||
return;
|
||||
return 2;
|
||||
}
|
||||
|
||||
node = result.value;
|
||||
qInfo() << "Nomos node started successfully";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_INVOKABLE void stop() override {
|
||||
if (node == nullptr) {
|
||||
Q_INVOKABLE void stop() override {
|
||||
if (!node) {
|
||||
qWarning() << "Node not running";
|
||||
return;
|
||||
}
|
||||
|
||||
OperationStatus status = stop_node(node);
|
||||
|
||||
const OperationStatus status = stop_node(node);
|
||||
if (is_ok(&status)) {
|
||||
qInfo() << "Nomos node stopped successfully";
|
||||
} else {
|
||||
@ -62,13 +58,6 @@ public:
|
||||
|
||||
node = nullptr;
|
||||
}
|
||||
|
||||
signals:
|
||||
// Required for event forwarding between modules
|
||||
void eventResponse(const QString &eventName, const QVariantList &data);
|
||||
|
||||
private:
|
||||
NomosNode *node;
|
||||
};
|
||||
|
||||
#include "library.moc" // Required. Must be at the bottom.
|
||||
#include "library.moc"
|
||||
|
||||
29
library.h
29
library.h
@ -1,5 +1,5 @@
|
||||
#ifndef UNTITLED_LIBRARY_H
|
||||
#define UNTITLED_LIBRARY_H
|
||||
#ifndef LOGOS_BLOCKCHAIN_MODULE_API_H
|
||||
#define LOGOS_BLOCKCHAIN_MODULE_API_H
|
||||
|
||||
#include <core/interface.h>
|
||||
|
||||
@ -8,26 +8,25 @@ extern "C" {
|
||||
#endif
|
||||
#include <libnomos.h>
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
class LogosBlockchainModuleAPI: public PluginInterface {
|
||||
private:
|
||||
NomosNode* node;
|
||||
class LogosBlockchainModuleAPI : public QObject, public PluginInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~LogosBlockchainModuleAPI() {}
|
||||
using QObject::QObject;
|
||||
~LogosBlockchainModuleAPI() override = default;
|
||||
|
||||
// Public API methods - must be Q_INVOKABLE for remote access
|
||||
Q_INVOKABLE virtual void start(const QString& config_path) = 0;
|
||||
Q_INVOKABLE virtual int start(const QString& config_path) = 0;
|
||||
Q_INVOKABLE virtual void stop() = 0;
|
||||
|
||||
Q_INVOKABLE void initLogos(LogosAPI* logosAPIInstance);
|
||||
Q_INVOKABLE virtual void initLogos(LogosAPI* logosAPIInstance) = 0;
|
||||
|
||||
signals:
|
||||
// Required for event forwarding between modules
|
||||
void eventResponse(const QString &eventName, const QVariantList &data);
|
||||
void eventResponse(const QString& eventName, const QVariantList& data);
|
||||
};
|
||||
// Register interface with Qt's meta-object system
|
||||
|
||||
#define LogosBlockchainModuleInterface_iid "org.logos.blockchaininterface"
|
||||
Q_DECLARE_INTERFACE(LogosBlockchainModuleAPI, LogosBlockchainModuleInterface_iid)
|
||||
#endif // UNTITLED_LIBRARY_H
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "logos-blockchain-module",
|
||||
"name": "liblogos-blockchain-module",
|
||||
"version": "1.0.0",
|
||||
"description": "Logos blockchain node for logos-core",
|
||||
"author": "Logos Blockchain Team",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user