diff --git a/.github/workflows/build-release-tags.yml b/.github/workflows/build-release-tags.yml
index 9db80aea3..1ff306c91 100644
--- a/.github/workflows/build-release-tags.yml
+++ b/.github/workflows/build-release-tags.yml
@@ -296,6 +296,39 @@ jobs:
- name: Add Android toolchain
if: ${{ matrix.target == 'Android' }}
run: |
+ # Setup Android SDK
+ ANDROID_SDK_ROOT="$HOME/android-sdk"
+
+ # Download command-line tools if not present
+ if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
+ echo "Downloading Android command-line tools..."
+ mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
+ wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdline-tools.zip
+ unzip -q cmdline-tools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
+ mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
+ rm cmdline-tools.zip
+ else
+ echo "Android command-line tools already exist"
+ fi
+
+ # Always accept licenses and install/update required SDK components
+ echo "Installing/updating Android SDK components..."
+ yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses || true
+ "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" "platform-tools" "platforms;android-34" "build-tools;34.0.0"
+
+ # Set environment variables
+ echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
+ echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
+ echo "$ANDROID_SDK_ROOT/platform-tools" >> $GITHUB_PATH
+ echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" >> $GITHUB_PATH
+
+ # Verify SDK installation
+ echo "=== Android SDK Setup ==="
+ echo "ANDROID_HOME: $ANDROID_SDK_ROOT"
+ echo "SDK contents:"
+ ls -la "$ANDROID_SDK_ROOT"
+
+ # Download and setup Android NDK
NDK_VERSION="r27b"
NDK_DIR="$HOME/android-ndk-$NDK_VERSION"
@@ -308,6 +341,8 @@ jobs:
echo "Android NDK already exists at $NDK_DIR, skipping download"
fi
+ echo "ANDROID_HOME=$ANDROID_SDK_ROOT"
+ echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
echo "ANDROID_NDK_HOME=$NDK_DIR" >> $GITHUB_ENV
rustup target add aarch64-linux-android
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 57a160fa9..3212643e0 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -449,6 +449,39 @@ jobs:
- name: Add Android toolchain
if: ${{ matrix.target == 'Android' }}
run: |
+ # Setup Android SDK
+ ANDROID_SDK_ROOT="$HOME/android-sdk"
+
+ # Download command-line tools if not present
+ if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
+ echo "Downloading Android command-line tools..."
+ mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
+ wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdline-tools.zip
+ unzip -q cmdline-tools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
+ mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
+ rm cmdline-tools.zip
+ else
+ echo "Android command-line tools already exist"
+ fi
+
+ # Always accept licenses and install/update required SDK components
+ echo "Installing/updating Android SDK components..."
+ yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses || true
+ "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" "platform-tools" "platforms;android-34" "build-tools;34.0.0"
+
+ # Set environment variables
+ echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
+ echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
+ echo "$ANDROID_SDK_ROOT/platform-tools" >> $GITHUB_PATH
+ echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" >> $GITHUB_PATH
+
+ # Verify SDK installation
+ echo "=== Android SDK Setup ==="
+ echo "ANDROID_HOME: $ANDROID_SDK_ROOT"
+ echo "SDK contents:"
+ ls -la "$ANDROID_SDK_ROOT"
+
+ # Download and setup Android NDK
NDK_VERSION="r27b"
NDK_DIR="$HOME/android-ndk-$NDK_VERSION"
@@ -459,6 +492,8 @@ jobs:
rm ndk.zip
fi
+ echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
+ echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=$NDK_DIR" >> $GITHUB_ENV
rustup target add aarch64-linux-android
diff --git a/.gitignore b/.gitignore
index 6f3e25696..1d9073e6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,4 +73,67 @@ CRDT.Datastore.TEST/
#Data files for deepseek test
example/BpeTokenizer/data/**/*.mnn
example/BpeTokenizer/data/**/*.mnn.weight
-example/BpeTokenizer/data/**/*.json
\ No newline at end of file
+example/BpeTokenizer/data/**/*.json
+
+# Local environment / secrets — never commit
+.env
+.env.*
+!.env.example
+examples/.env
+examples/.env.*
+!examples/.env.example
+
+# Build outputs
+build/
+
+# macOS
+.DS_Store
+
+# Test log files
+/tmp/eth_watch_*.log
+examples/*.log
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# github copilot
+.idea/**/copilot*
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# CMake
+cmake-build-*/
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+### CLion+iml Patch ###
+# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
+
+*.iml
+modules.xml
+.idea/misc.xml
+*.ipr
+
diff --git a/.gitmodules b/.gitmodules
index 885238514..9dfeeb470 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -14,3 +14,6 @@
[submodule "docs"]
path = docs
url = ../sg-docs
+[submodule "evmrelay"]
+ path = evmrelay
+ url = ../evmrelay
diff --git a/AgentDocs/CLAUDE.md b/AgentDocs/CLAUDE.md
index c13739496..95715dc85 100644
--- a/AgentDocs/CLAUDE.md
+++ b/AgentDocs/CLAUDE.md
@@ -61,10 +61,15 @@ Your default mode is “tiny, surgical insertion into existing code”.
- Always run the linter before committing.
- Always run the formatter before committing.
- Always run the build before committing.
-- Always run in interactive mode with the user on a step by step basis
+- Always run in interactive mode with the user on a step-by-step basis
- Always look in AgentDocs for other instructions.
- The files can include SPRINT_PLAN.md, Architecture.md, CHECKPOINT.md, AGENT_MISTAKES.md
-
+- Always look in AgentDocs for other instructions.
+ - The files can include SPRINT_PLAN.md, Architecture.md, CHECKPOINT.md, AGENT_MISTAKES.md
+- Always make sure to only use C++17 features and below.
+ - For instance boost::coroutines only work in C++20, do NOT use it.
+ - Make sure not to use other C++ versions' features above C++17
+
## Build Commands
> **See `README.md` → "Building the Project" for the full authoritative build instructions.**
diff --git a/GeniusKDF b/GeniusKDF
index 529077413..f93495c27 160000
--- a/GeniusKDF
+++ b/GeniusKDF
@@ -1 +1 @@
-Subproject commit 529077413dfaddceb7df5f46ae3c36e9256c9b0d
+Subproject commit f93495c27d8dadf689ec73f00ae0a212c71323d2
diff --git a/ProofSystem b/ProofSystem
index 50f86f4cc..99593ca66 160000
--- a/ProofSystem
+++ b/ProofSystem
@@ -1 +1 @@
-Subproject commit 50f86f4cc507aa79281d21aca1ad1683623ce9ab
+Subproject commit 99593ca662d996869273f5e7414157e1d502ccf2
diff --git a/SGProcessingManager b/SGProcessingManager
index b08326de8..2f0c7a307 160000
--- a/SGProcessingManager
+++ b/SGProcessingManager
@@ -1 +1 @@
-Subproject commit b08326de8e0ac7ef8db99b1ca0348db5f4d15b1e
+Subproject commit 2f0c7a307874fb928844d992c886eeaa48c2ee42
diff --git a/build/Android/CMakeLists.txt b/build/Android/CMakeLists.txt
index 074c1e4f9..c798e83ab 100644
--- a/build/Android/CMakeLists.txt
+++ b/build/Android/CMakeLists.txt
@@ -49,8 +49,14 @@ set(PROTOC_EXECUTABLE "${_THIRDPARTY_BUILD_DIR}/protobuf_host/bin/protoc${CMAKE_
set(TESTING OFF)
-find_library(log-lib log)
-find_library(android-lib android)
+add_library(android::log INTERFACE IMPORTED GLOBAL)
+set_target_properties(android::log PROPERTIES IMPORTED_LIBNAME "log")
+
+add_library(android::android INTERFACE IMPORTED GLOBAL)
+set_target_properties(android::android PROPERTIES IMPORTED_LIBNAME "android")
# Include common build parameters
include(../CommonBuildParameters.cmake)
+
+# Add Android AAR build for secure storage
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/securestorage ${CMAKE_BINARY_DIR}/android_aar)
diff --git a/build/Android/securestorage/.gitignore b/build/Android/securestorage/.gitignore
new file mode 100644
index 000000000..25d94c1b2
--- /dev/null
+++ b/build/Android/securestorage/.gitignore
@@ -0,0 +1,18 @@
+# Gradle build outputs
+.gradle/
+build/
+library/build/
+
+# Gradle wrapper (download on demand)
+.gradle-wrapper.jar
+gradlew
+gradlew.bat
+gradle/
+
+# Local configuration
+local.properties
+
+# IDE files
+.idea/
+*.iml
+.DS_Store
diff --git a/build/Android/securestorage/CMakeLists.txt b/build/Android/securestorage/CMakeLists.txt
new file mode 100644
index 000000000..c5243f452
--- /dev/null
+++ b/build/Android/securestorage/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Android AAR build for KeyStoreHelper
+cmake_minimum_required(VERSION 3.22)
+
+# Check if Gradle wrapper exists, if not, set it up
+set(GRADLEW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gradlew")
+if(NOT EXISTS "${GRADLEW_PATH}")
+ message(STATUS "Gradle wrapper not found, running setup script...")
+ execute_process(
+ COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/setup-gradle-wrapper.sh
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE SETUP_RESULT
+ )
+ if(NOT SETUP_RESULT EQUAL 0)
+ message(FATAL_ERROR "Failed to set up Gradle wrapper. Please check your internet connection.")
+ endif()
+ message(STATUS "Gradle wrapper setup complete")
+endif()
+
+# Custom target to build the AAR using Gradle
+add_custom_target(build_android_aar ALL
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gradlew :library:assembleRelease
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Building securestorage AAR with Gradle"
+ BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/library/build/outputs/aar/library-release.aar
+)
+
+# Install the AAR to the installation directory
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/library/build/outputs/aar/library-release.aar
+ DESTINATION lib/android
+ RENAME securestorage-release.aar
+ OPTIONAL
+)
diff --git a/build/Android/securestorage/README.md b/build/Android/securestorage/README.md
new file mode 100644
index 000000000..34a4093be
--- /dev/null
+++ b/build/Android/securestorage/README.md
@@ -0,0 +1,78 @@
+# Android Secure Storage AAR
+
+This directory contains the Android Gradle project for building the SuperGenius secure storage AAR.
+
+## Overview
+
+The AAR contains:
+- `ai.gnus.sdk.KeyStoreHelper` - Java class providing secure key storage using Android KeyStore
+
+**Source Location**: The Java source is maintained in `src/local_secure_storage/impl/KeyStoreHelper.java` and referenced by the Gradle build. This ensures a single source of truth alongside the C++ implementation.
+
+## Building
+
+### Via CMake (Recommended)
+When building the Android version of SuperGenius, the AAR will be built automatically during `make`:
+
+```bash
+cd build/OSX
+mkdir -p Android && cd Android
+cmake ../.. \
+ -DCMAKE_ANDROID_NDK=/path/to/ndk \
+ -DANDROID_ABI=arm64-v8a \
+ -DCMAKE_BUILD_TYPE=Release
+make
+make install
+```
+
+The Gradle wrapper will be set up automatically if needed during the CMake configure step.
+The AAR will be built during `make` and installed to `${CMAKE_INSTALL_PREFIX}/lib/android/securestorage-release.aar` during `make install`.
+
+### Via Gradle Directly
+You can also build the AAR directly using Gradle:
+
+```bash
+cd build/Android/securestorage
+./gradlew :library:assembleRelease
+```
+
+Output: `build/Android/securestorage/library/build/outputs/aar/library-release.aar`
+
+## Usage in Unity/GeniusSDK
+
+1. Include the AAR in your Unity project's `Assets/Plugins/Android/` directory
+2. Include your SDK `.so` file in `Assets/Plugins/Android/libs/[ABI]/`
+3. Initialize KeyStoreHelper before using native secure storage:
+
+```java
+import ai.gnus.sdk.KeyStoreHelper;
+
+public class YourUnityActivity extends UnityPlayerActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // This must be called AFTER the native SDK .so is loaded
+ // It caches the class reference using the app's ClassLoader
+ KeyStoreHelper.initialize(this);
+ }
+}
+```
+
+**Important**: The AAR's `nativeInit` method is implemented in your SDK's `.so` file. Make sure Unity loads the native library before calling `KeyStoreHelper.initialize()`.
+
+## JNI Contract
+
+The C++ code in `src/local_secure_storage/impl/Android.cpp`:
+- Implements: `Java_ai_gnus_sdk_KeyStoreHelper_nativeInit` - Caches class reference using app ClassLoader
+- Calls these static Java methods:
+ - `ai.gnus.sdk.KeyStoreHelper.load()Ljava/lang/String;`
+ - `ai.gnus.sdk.KeyStoreHelper.save(Ljava/lang/String;)Z`
+ - `ai.gnus.sdk.KeyStoreHelper.delete(Ljava/lang/String;)Z`
+
+**ClassLoader Fix**: The native code now uses the app's ClassLoader (via the Context passed to `initialize()`) instead of the system ClassLoader, which fixes crashes when secure storage is accessed from worker threads.
+
+## Requirements
+
+- Android SDK 33
+- Min SDK 28 (Android 9.0)
+- Gradle 8.1+
diff --git a/build/Android/securestorage/build.gradle b/build/Android/securestorage/build.gradle
new file mode 100644
index 000000000..6d2af6ec1
--- /dev/null
+++ b/build/Android/securestorage/build.gradle
@@ -0,0 +1,21 @@
+// Top-level build file
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:8.1.0'
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/build/Android/securestorage/gradle.properties b/build/Android/securestorage/gradle.properties
new file mode 100644
index 000000000..dbe66c699
--- /dev/null
+++ b/build/Android/securestorage/gradle.properties
@@ -0,0 +1,4 @@
+# Project-wide Gradle settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+android.useAndroidX=true
+android.enableJetifier=false
diff --git a/build/Android/securestorage/library/build.gradle b/build/Android/securestorage/library/build.gradle
new file mode 100644
index 000000000..5f2d318b8
--- /dev/null
+++ b/build/Android/securestorage/library/build.gradle
@@ -0,0 +1,40 @@
+plugins {
+ id 'com.android.library'
+}
+
+android {
+ namespace 'ai.gnus.sdk'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 28
+ targetSdk 33
+
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ sourceSets {
+ main {
+ java {
+ srcDirs = ['../../../../src/local_secure_storage/impl']
+ }
+ manifest.srcFile 'src/main/AndroidManifest.xml'
+ }
+ }
+}
+
+dependencies {
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+}
diff --git a/build/Android/securestorage/library/consumer-rules.pro b/build/Android/securestorage/library/consumer-rules.pro
new file mode 100644
index 000000000..b1f65d7a6
--- /dev/null
+++ b/build/Android/securestorage/library/consumer-rules.pro
@@ -0,0 +1,4 @@
+# Consumer ProGuard rules for securestorage library
+-keep class ai.gnus.sdk.KeyStoreHelper {
+ public static *;
+}
diff --git a/build/Android/securestorage/library/proguard-rules.pro b/build/Android/securestorage/library/proguard-rules.pro
new file mode 100644
index 000000000..f33fe4cd9
--- /dev/null
+++ b/build/Android/securestorage/library/proguard-rules.pro
@@ -0,0 +1,4 @@
+# Keep KeyStoreHelper class and all its methods for JNI access
+-keep class ai.gnus.sdk.KeyStoreHelper {
+ public static *;
+}
diff --git a/build/Android/securestorage/library/src/main/AndroidManifest.xml b/build/Android/securestorage/library/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..7d00b808e
--- /dev/null
+++ b/build/Android/securestorage/library/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/build/Android/securestorage/settings.gradle b/build/Android/securestorage/settings.gradle
new file mode 100644
index 000000000..a10833bc3
--- /dev/null
+++ b/build/Android/securestorage/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'SuperGenius'
+include ':library'
diff --git a/build/Android/securestorage/setup-gradle-wrapper.sh b/build/Android/securestorage/setup-gradle-wrapper.sh
new file mode 100755
index 000000000..501a930ec
--- /dev/null
+++ b/build/Android/securestorage/setup-gradle-wrapper.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Script to set up Gradle wrapper for the Android AAR build
+
+set -e
+
+cd "$(dirname "$0")"
+
+# Check if gradlew already exists
+if [ -f gradlew ]; then
+ echo "Gradle wrapper already exists"
+ exit 0
+fi
+
+GRADLE_VERSION="8.2"
+
+# Check if gradle is installed and what version
+if command -v gradle &> /dev/null; then
+ GRADLE_VER=$(gradle --version | grep "^Gradle" | awk '{print $2}')
+ echo "Found Gradle $GRADLE_VER"
+
+ # Check if version is at least 6.0
+ if [ "$(printf '%s\n' "6.0" "$GRADLE_VER" | sort -V | head -n1)" = "6.0" ]; then
+ echo "Using installed Gradle to create wrapper..."
+ gradle wrapper --gradle-version $GRADLE_VERSION
+ exit 0
+ else
+ echo "Warning: Gradle $GRADLE_VER is too old (need 6.0+)"
+ fi
+fi
+
+echo "Downloading Gradle wrapper files directly..."
+
+# Create gradle/wrapper directory
+mkdir -p gradle/wrapper
+
+# Download gradle-wrapper.jar
+curl -L "https://raw.githubusercontent.com/gradle/gradle/v${GRADLE_VERSION}.0/gradle/wrapper/gradle-wrapper.jar" \
+ -o gradle/wrapper/gradle-wrapper.jar
+
+# Download gradlew
+curl -L "https://raw.githubusercontent.com/gradle/gradle/v${GRADLE_VERSION}.0/gradlew" \
+ -o gradlew
+
+# Download gradlew.bat
+curl -L "https://raw.githubusercontent.com/gradle/gradle/v${GRADLE_VERSION}.0/gradlew.bat" \
+ -o gradlew.bat
+
+# Create gradle-wrapper.properties
+cat > gradle/wrapper/gradle-wrapper.properties << EOF
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+EOF
+
+chmod +x gradlew
+
+echo "Gradle wrapper setup complete"
diff --git a/build/CommonBuildParameters.cmake b/build/CommonBuildParameters.cmake
index a912a41a4..400c6c416 100644
--- a/build/CommonBuildParameters.cmake
+++ b/build/CommonBuildParameters.cmake
@@ -49,6 +49,14 @@ if(NOT DEFINED Protobuf_DIR)
set(Protobuf_DIR "${_THIRDPARTY_BUILD_DIR}/protobuf/lib/cmake/protobuf")
endif()
+if(NOT DEFINED grpc_INCLUDE_DIR)
+ set(grpc_INCLUDE_DIR "${_THIRDPARTY_BUILD_DIR}/grpc/include")
+endif()
+
+if(NOT DEFINED Protobuf_INCLUDE_DIR)
+ set(Protobuf_INCLUDE_DIR "${grpc_INCLUDE_DIR}/google/protobuf")
+endif()
+
find_package(Protobuf CONFIG REQUIRED)
if(NOT DEFINED PROTOC_EXECUTABLE)
@@ -149,6 +157,7 @@ set(Boost_DIR "${Boost_LIB_DIR}/cmake/Boost-${BOOST_VERSION}")
set(boost_atomic_DIR "${Boost_LIB_DIR}/cmake/boost_atomic-${BOOST_VERSION}")
set(boost_chrono_DIR "${Boost_LIB_DIR}/cmake/boost_chrono-${BOOST_VERSION}")
set(boost_container_DIR "${Boost_LIB_DIR}/cmake/boost_container-${BOOST_VERSION}")
+set(boost_context_DIR "${Boost_LIB_DIR}/cmake/boost_context-${BOOST_VERSION}")
set(boost_date_time_DIR "${Boost_LIB_DIR}/cmake/boost_date_time-${BOOST_VERSION}")
set(boost_filesystem_DIR "${Boost_LIB_DIR}/cmake/boost_filesystem-${BOOST_VERSION}")
set(boost_headers_DIR "${Boost_LIB_DIR}/cmake/boost_headers-${BOOST_VERSION}")
@@ -160,11 +169,37 @@ set(boost_random_DIR "${Boost_LIB_DIR}/cmake/boost_random-${BOOST_VERSION}")
set(boost_regex_DIR "${Boost_LIB_DIR}/cmake/boost_regex-${BOOST_VERSION}")
set(boost_system_DIR "${Boost_LIB_DIR}/cmake/boost_system-${BOOST_VERSION}")
set(boost_thread_DIR "${Boost_LIB_DIR}/cmake/boost_thread-${BOOST_VERSION}")
+set(boost_context_DIR "${Boost_LIB_DIR}/cmake/boost_context-${BOOST_VERSION}")
+set(boost_coroutine_DIR "${Boost_LIB_DIR}/cmake/boost_coroutine-${BOOST_VERSION}")
set(boost_unit_test_framework_DIR "${Boost_LIB_DIR}/cmake/boost_unit_test_framework-${BOOST_VERSION}")
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_NO_SYSTEM_PATHS ON)
option(Boost_USE_STATIC_RUNTIME "Use static runtimes" ON)
+set(_BOOST_CACHE_ARGS
+ -DBOOST_ROOT:PATH=${_BOOST_ROOT}
+ -DBoost_DIR:PATH=${Boost_DIR}/Boost-${BOOST_VERSION}
+ -DBoost_INCLUDE_DIR:PATH=${Boost_INCLUDE_DIR}
+ -Dboost_headers_DIR:PATH=${Boost_DIR}/boost_headers-${BOOST_VERSION}
+ -Dboost_date_time_DIR:PATH=${Boost_DIR}/boost_date_time-${BOOST_VERSION}
+ -Dboost_filesystem_DIR:PATH=${Boost_DIR}/boost_filesystem-${BOOST_VERSION}
+ -Dboost_program_options_DIR:PATH=${Boost_DIR}/boost_program_options-${BOOST_VERSION}
+ -Dboost_random_DIR:PATH=${Boost_DIR}/boost_random-${BOOST_VERSION}
+ -Dboost_regex_DIR:PATH=${Boost_DIR}/boost_regex-${BOOST_VERSION}
+ -Dboost_system_DIR:PATH=${Boost_DIR}/boost_system-${BOOST_VERSION}
+ -Dboost_context_DIR:PATH=${Boost_DIR}/boost_context-${BOOST_VERSION}
+ -Dboost_coroutine_DIR:PATH=${Boost_DIR}/boost_coroutine-${BOOST_VERSION}
+ -Dboost_thread_DIR:PATH=${Boost_DIR}/boost_thread-${BOOST_VERSION}
+ -Dboost_log_DIR:PATH=${Boost_DIR}/boost_log-${BOOST_VERSION}
+ -Dboost_log_setup_DIR:PATH=${Boost_DIR}/boost_log_setup-${BOOST_VERSION}
+ -Dboost_unit_test_framework_DIR:PATH=${Boost_DIR}/boost_unit_test_framework-${BOOST_VERSION}
+ -Dboost_json_DIR:PATH=${Boost_DIR}/boost_json-${BOOST_VERSION}
+ -DBoost_USE_STATIC_RUNTIME:BOOL=ON
+ -DBoost_NO_SYSTEM_PATHS:BOOL=ON
+ -DBoost_USE_MULTITHREADED:BOOL=ON
+ -DBoost_USE_STATIC_LIBS:BOOL=ON
+ -DBoost_USE_STATIC_RUNTIME:BOOL=ON
+)
option(SGNS_STACKTRACE_BACKTRACE "Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)
@@ -176,8 +211,10 @@ if(SGNS_STACKTRACE_BACKTRACE)
endif()
endif()
-# header only libraries must not be added here
-find_package(Boost REQUIRED COMPONENTS container date_time filesystem random regex system thread log log_setup program_options unit_test_framework json)
+if(POLICY CMP0167)
+ cmake_policy(SET CMP0167 OLD)
+endif()
+find_package(Boost REQUIRED COMPONENTS container date_time filesystem random regex system thread log log_setup program_options unit_test_framework json context coroutine)
include_directories(${Boost_INCLUDE_DIRS})
# SQLiteModernCpp project
@@ -234,6 +271,9 @@ find_package(ipfs-bitswap-cpp CONFIG REQUIRED)
set(ed25519_DIR "${_THIRDPARTY_BUILD_DIR}/ed25519/lib/cmake/ed25519")
find_package(ed25519 CONFIG REQUIRED)
+set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS ON CACHE BOOL "Suppress developer warnings" FORCE)
+# Globally suppress ALL CMake deprecation warnings (including from third-party Config.cmake files)
+set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecation warnings" FORCE)
# RapidJSON
set(RapidJSON_DIR "${_THIRDPARTY_BUILD_DIR}/rapidjson/lib/cmake/RapidJSON")
find_package(RapidJSON CONFIG REQUIRED)
@@ -366,15 +406,19 @@ endif()
include_directories(
${PROJECT_ROOT}/src
)
+
include_directories(
- ${PROJECT_ROOT}/GeniusKDF
+ ${PROJECT_ROOT}/ProofSystem/include
)
+
include_directories(
- ${PROJECT_ROOT}/ProofSystem
+ ${PROJECT_ROOT}/SGProcessingManager/include
)
+
include_directories(
- ${PROJECT_ROOT}/SGProcessingManager
+ ${PROJECT_ROOT}/evmrelay/include
)
+
include_directories(
${PROJECT_ROOT}/app
)
@@ -397,14 +441,13 @@ link_directories(
${ipfs-lite-cpp_LIB_DIR}
)
+add_subdirectory(${PROJECT_ROOT}/ProofSystem ${CMAKE_BINARY_DIR}/ProofSystem)
+add_subdirectory(${PROJECT_ROOT}/SGProcessingManager ${CMAKE_BINARY_DIR}/SGProcessingManager)
+add_subdirectory(${PROJECT_ROOT}/evmrelay ${CMAKE_BINARY_DIR}/evmrelay)
add_subdirectory(${PROJECT_ROOT}/src ${CMAKE_BINARY_DIR}/src)
#add_subdirectory(${PROJECT_ROOT}/GeniusKDF ${CMAKE_BINARY_DIR}/GeniusKDF)
-add_subdirectory(${PROJECT_ROOT}/ProofSystem ${CMAKE_BINARY_DIR}/ProofSystem)
-add_subdirectory(${PROJECT_ROOT}/SGProcessingManager ${CMAKE_BINARY_DIR}/SGProcessingManager)
-
-# add_subdirectory(${PROJECT_ROOT}/app ${CMAKE_BINARY_DIR}/app)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(${PROJECT_ROOT}/test ${CMAKE_BINARY_DIR}/test)
@@ -436,40 +479,40 @@ write_basic_package_version_file(
)
# install header files
-install_hfile(${PROJECT_ROOT}/src/api)
-install_hfile(${PROJECT_ROOT}/src/authorship)
-install_hfile(${PROJECT_ROOT}/src/application)
-install_hfile(${PROJECT_ROOT}/src/base)
-install_hfile(${PROJECT_ROOT}/src/blockchain)
-install_hfile(${PROJECT_ROOT}/src/clock)
-install_hfile(${PROJECT_ROOT}/src/crdt)
-install_hfile(${PROJECT_ROOT}/src/crypto)
-install_hfile(${PROJECT_ROOT}/src/extensions)
-install_hfile(${PROJECT_ROOT}/src/injector)
-install_hfile(${PROJECT_ROOT}/src/macro)
-install_hfile(${PROJECT_ROOT}/src/network)
-install_hfile(${PROJECT_ROOT}/src/outcome)
-install_hfile(${PROJECT_ROOT}/src/processing)
-install_hfile(${PROJECT_ROOT}/src/primitives)
-install_hfile(${PROJECT_ROOT}/src/runtime)
-install_hfile(${PROJECT_ROOT}/src/scale)
-install_hfile(${PROJECT_ROOT}/src/storage)
-install_hfile(${PROJECT_ROOT}/src/subscription)
-install_hfile(${PROJECT_ROOT}/src/transaction_pool)
-install_hfile(${PROJECT_ROOT}/src/verification)
-install_hfile(${PROJECT_ROOT}/src/account)
-install_hfile(${PROJECT_ROOT}/app/integration)
-install_hfile(${PROJECT_ROOT}/src/local_secure_storage)
-install_hfile(${PROJECT_ROOT}/src/singleton)
-install_hfile(${PROJECT_ROOT}/src/coinprices)
-install_hfile(${PROJECT_ROOT}/ProcessingSchema/generated)
-
-# install proto header files
-install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/crdt)
-install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/processing)
-install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/account)
-install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/blockchain)
-install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/proof)
+#install_hfile(${PROJECT_ROOT}/src/api)
+#install_hfile(${PROJECT_ROOT}/src/authorship)
+#install_hfile(${PROJECT_ROOT}/src/application)
+#install_hfile(${PROJECT_ROOT}/src/base)
+#install_hfile(${PROJECT_ROOT}/src/blockchain)
+#install_hfile(${PROJECT_ROOT}/src/clock)
+#install_hfile(${PROJECT_ROOT}/src/crdt)
+#install_hfile(${PROJECT_ROOT}/src/crypto)
+#install_hfile(${PROJECT_ROOT}/src/extensions)
+#install_hfile(${PROJECT_ROOT}/src/injector)
+#install_hfile(${PROJECT_ROOT}/src/macro)
+#install_hfile(${PROJECT_ROOT}/src/network)
+#install_hfile(${PROJECT_ROOT}/src/outcome)
+#install_hfile(${PROJECT_ROOT}/src/processing)
+#install_hfile(${PROJECT_ROOT}/src/primitives)
+#install_hfile(${PROJECT_ROOT}/src/runtime)
+#install_hfile(${PROJECT_ROOT}/src/scale)
+#install_hfile(${PROJECT_ROOT}/src/storage)
+#install_hfile(${PROJECT_ROOT}/src/subscription)
+#install_hfile(${PROJECT_ROOT}/src/transaction_pool)
+#install_hfile(${PROJECT_ROOT}/src/verification)
+#install_hfile(${PROJECT_ROOT}/src/account)
+#install_hfile(${PROJECT_ROOT}/app/integration)
+#install_hfile(${PROJECT_ROOT}/src/local_secure_storage)
+#install_hfile(${PROJECT_ROOT}/src/singleton)
+#install_hfile(${PROJECT_ROOT}/src/coinprices)
+#install_hfile(${PROJECT_ROOT}/ProcessingSchema/generated)
+#
+## install proto header files
+#install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/crdt)
+#install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/processing)
+#install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/account)
+#install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/blockchain)
+#install_hfile(${CMAKE_CURRENT_BINARY_DIR}/generated/proof)
# install the configuration file
install(FILES
diff --git a/build/CommonCompilerOptions.cmake b/build/CommonCompilerOptions.cmake
index 074513ba0..2112a7211 100644
--- a/build/CommonCompilerOptions.cmake
+++ b/build/CommonCompilerOptions.cmake
@@ -19,19 +19,20 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-if(DEFINED SANITIZE_CODE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZE_CODE}")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZE_CODE}")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZE_CODE}")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${SANITIZE_CODE}")
- add_compile_options("-fsanitize=${SANITIZE_CODE}")
- add_link_options("-fsanitize=${SANITIZE_CODE}")
-endif()
-
-#TODO Remove this once we update gRPC, its dependencies, fix libp2p and change some of our internal projects
-
-if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-template-arg-list-after-template-kw")
+if (DEFINED SANITIZE_CODE)
+ message(STATUS "Building with sanitizer: ${SANITIZE_CODE}")
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZE_CODE}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZE_CODE}")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZE_CODE}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${SANITIZE_CODE}")
+ add_compile_options("-fsanitize=${SANITIZE_CODE}")
+ add_link_options("-fsanitize=${SANITIZE_CODE}")
+ elseif (MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=${SANITIZE_CODE}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=${SANITIZE_CODE}")
+ add_compile_options("/fsanitize=${SANITIZE_CODE}")
+ endif()
endif()
include(GNUInstallDirs)
@@ -47,6 +48,11 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
+if(WIN32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=0x0A00 -DNOMINMAX")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0A00 -DNOMINMAX")
+endif()
+
# Define zkllvm directory
if(NOT DEFINED ZKLLVM_BUILD_DIR)
get_filename_component(BUILD_PLATFORM_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
diff --git a/build/CompilationFlags.cmake b/build/CompilationFlags.cmake
index 78685fef6..6ce404a35 100644
--- a/build/CompilationFlags.cmake
+++ b/build/CompilationFlags.cmake
@@ -25,6 +25,8 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang|GNU)$")
add_flag(-Wno-unused-but-set-variable)
add_flag(-Wno-macro-redefined)
add_flag(-Wno-deprecated-copy-with-user-provided-copy)
+ # dumb crypto3 warnings
+ add_flag(-Wno-reorder-ctor)
if(APPLE)
add_link_options(-Wl,-no_warn_duplicate_libraries)
endif()
diff --git a/cmake/functions.cmake b/cmake/functions.cmake
index 6997e0b9b..2df24a30a 100644
--- a/cmake/functions.cmake
+++ b/cmake/functions.cmake
@@ -87,7 +87,6 @@ endif()
function(add_proto_library NAME)
set(SOURCES "")
set(HEADERS "")
- set(PB_REL_PATH "")
foreach(PROTO IN ITEMS ${ARGN})
compile_proto_to_cpp(H C PB_REL_PATH ${PROTO})
@@ -110,14 +109,14 @@ function(add_proto_library NAME)
# target_include_directories(${NAME} PUBLIC
# ${CMAKE_BINARY_DIR}/generated/
# )
+ install(TARGETS ${NAME} EXPORT supergeniusTargets)
+
foreach(H IN ITEMS ${HEADERS})
- set_target_properties(${NAME} PROPERTIES PUBLIC_HEADER "${H}")
+ file(RELATIVE_PATH H_REL_PATH "${CMAKE_BINARY_DIR}/generated" "${H}")
+ get_filename_component(H_REL_DIR "${H_REL_PATH}" DIRECTORY)
+ install(FILES "${H}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${H_REL_DIR}")
endforeach()
- install(TARGETS ${NAME} EXPORT supergeniusTargets
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PB_REL_PATH}
- )
-
disable_clang_tidy(${NAME})
add_dependencies(generated ${NAME})
diff --git a/evmrelay b/evmrelay
new file mode 160000
index 000000000..8acae379b
--- /dev/null
+++ b/evmrelay
@@ -0,0 +1 @@
+Subproject commit 8acae379b6cd37e5903de71e8dadb55ae72cffb4
diff --git a/example/account_handling/AccountHandling.cpp b/example/account_handling/AccountHandling.cpp
index 908eb9861..5925ab419 100644
--- a/example/account_handling/AccountHandling.cpp
+++ b/example/account_handling/AccountHandling.cpp
@@ -71,7 +71,7 @@ void MintTokens( const std::vector &args, sgns::TransactionManager
std::cerr << "Invalid process command format.\n";
return;
}
- transaction_manager.MintFunds( std::stoull( args[1] ), "", "", sgns::TokenID::FromBytes( { 0x00 } ) );
+ transaction_manager.MintFunds( std::stoull( args[1] ), "", "", sgns::TokenID::FromBytes( { 0x00 } ) );
}
void PrintAccountInfo( const std::vector &args, sgns::TransactionManager &transaction_manager )
diff --git a/example/account_handling/AccountHelper.cpp b/example/account_handling/AccountHelper.cpp
index fdfed98e1..636469662 100644
--- a/example/account_handling/AccountHelper.cpp
+++ b/example/account_handling/AccountHelper.cpp
@@ -1,6 +1,6 @@
/**
* @file AccountHelper.cpp
- * @brief
+ * @brief
* @date 2024-05-15
* @author Henrique A. Klein (hklein@gnus.ai)
*/
@@ -83,7 +83,7 @@ namespace sgns
crdt::KeyPairFileStorage( pubsubKeyPath ).GetKeyPair().value() );
pubsub_->Start( 40001, {} );
- auto scheduler = std::make_shared( io_, libp2p::protocol::SchedulerConfig{} );
+ auto scheduler = std::make_shared( std::make_shared( io_ ), libp2p::basic::Scheduler::Config{ std::chrono::milliseconds( 100 ) } );
auto graphsyncnetwork = std::make_shared( pubsub_->GetHost(),
scheduler );
auto generator = std::make_shared();
@@ -141,14 +141,14 @@ namespace sgns
std::vector hash( SHA256_DIGEST_LENGTH );
SHA256( inputBytes.data(), inputBytes.size(), hash.data() );
//Provide CID
- libp2p::protocol::kademlia::ContentId key( hash );
+ auto key = libp2p::multi::ContentIdentifierCodec::encodeCIDV0( hash.data(), hash.size() );
pubsub_->GetDHT()->Start();
pubsub_->GetDHT()->ProvideCID( key, true );
- auto cidtest = libp2p::multi::ContentIdentifierCodec::decode( key.data );
+ auto cidtest = libp2p::multi::ContentIdentifierCodec::decode( key );
auto cidstring = libp2p::multi::ContentIdentifierCodec::toString( cidtest.value() );
- std::cout << "CID Test::" << cidstring.value() << std::endl;
+ std::cout << "CID Test::" << cidstring.value() << '\n';
//Also Find providers
pubsub_->StartFindingPeers( key );
diff --git a/example/account_handling/CMakeLists.txt b/example/account_handling/CMakeLists.txt
index 195f161a2..7c402d5f4 100644
--- a/example/account_handling/CMakeLists.txt
+++ b/example/account_handling/CMakeLists.txt
@@ -10,11 +10,6 @@ include_directories(
target_include_directories(account_handling PRIVATE ${GSL_INCLUDE_DIR} ${TrustWalletCore_INCLUDE_DIR})
target_link_libraries(account_handling PRIVATE
-# ipfs-lite-cpp::ipfs_datastore_rocksdb
-# ipfs-lite-cpp::buffer
-# ipfs-lite-cpp::ipld_node
-# ipfs-lite-cpp::ipfs_merkledag_service
-# ipfs-lite-cpp::graphsync
genius_node
blockchain_common
block_header_repository
@@ -34,7 +29,6 @@ target_link_libraries(account_handling PRIVATE
Boost::Boost.DI
Boost::program_options
ipfs-bitswap-cpp
- ipfs-pubsub
rapidjson
${WIN_CRYPT_LIBRARY}
)
diff --git a/example/crdt_globaldb/globaldb_app.cpp b/example/crdt_globaldb/globaldb_app.cpp
index 8afa1442e..a42d7e2f4 100644
--- a/example/crdt_globaldb/globaldb_app.cpp
+++ b/example/crdt_globaldb/globaldb_app.cpp
@@ -13,9 +13,10 @@
#include
#include
+#include
+#include
#include
#include
-#include
using Buffer = sgns::base::Buffer;
using HierarchicalKey = sgns::crdt::HierarchicalKey;
@@ -119,13 +120,14 @@ int main( int argc, char **argv )
sgns::crdt::KeyPairFileStorage( strDatabasePath + "/pubsub" ).GetKeyPair().value() );
pubsub->Start( pubsubListeningPort, pubsubBootstrapPeers );
- auto scheduler = std::make_shared( io, libp2p::protocol::SchedulerConfig{} );
+ auto scheduler = std::make_shared(
+ std::make_shared( io ),
+ libp2p::basic::Scheduler::Config{ std::chrono::milliseconds( 100 ) } );
auto graphsyncnetwork = std::make_shared( pubsub->GetHost(), scheduler );
auto generator = std::make_shared();
auto crdtOptions = sgns::crdt::CrdtOptions::DefaultOptions();
crdtOptions->logger = logger;
-
auto globaldb_ret =
sgns::crdt::GlobalDB::New( io, strDatabasePath, pubsub, crdtOptions, graphsyncnetwork, scheduler, generator );
diff --git a/example/graphsync_app/CMakeLists.txt b/example/graphsync_app/CMakeLists.txt
index f0cbe7fa1..9d825c334 100644
--- a/example/graphsync_app/CMakeLists.txt
+++ b/example/graphsync_app/CMakeLists.txt
@@ -6,7 +6,6 @@ add_executable(graphsync_app
target_link_libraries(graphsync_app
ipfs-lite-cpp::graphsync
ipfs-lite-cpp::ipfs_merkledag_service
- p2p::asio_scheduler
Boost::program_options
${WIN_CRYPT_LIBRARY}
)
diff --git a/example/graphsync_app/graphsync_acceptance_common.cpp b/example/graphsync_app/graphsync_acceptance_common.cpp
index 0f71764f4..ab3bd3d70 100644
--- a/example/graphsync_app/graphsync_acceptance_common.cpp
+++ b/example/graphsync_app/graphsync_acceptance_common.cpp
@@ -3,7 +3,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -32,7 +32,7 @@ createNodeObjects(std::shared_ptr io)
{
// [boost::di::override] allows for creating multiple hosts for testing
// purposes
- auto injector =
+ auto injector =
libp2p::injector::makeHostInjector(
boost::di::bind.to(io)[boost::di::override]);
@@ -40,8 +40,8 @@ createNodeObjects(std::shared_ptr io)
std::pair, std::shared_ptr>
objects;
objects.second = injector.template create>();
- auto scheduler = std::make_shared(
- io, libp2p::protocol::SchedulerConfig{});
+ auto scheduler = std::make_shared(
+ std::make_shared(io), libp2p::basic::Scheduler::Config{ std::chrono::milliseconds(100) });
auto graphsyncnetwork = std::make_shared( objects.second, scheduler );
auto generator = std::make_shared();
objects.first =
@@ -54,7 +54,7 @@ createNodeObjects(std::shared_ptr io, libp2p::crypto::K
{
// [boost::di::override] allows for creating multiple hosts for testing
// purposes
- auto injector =
+ auto injector =
libp2p::injector::makeHostInjector(
boost::di::bind.to(io)[boost::di::override],
boost::di::bind.to(std::move(keyPair))[boost::di::override]);
@@ -63,8 +63,8 @@ createNodeObjects(std::shared_ptr io, libp2p::crypto::K
std::pair, std::shared_ptr>
objects;
objects.second = injector.template create>();
- auto scheduler = std::make_shared(
- io, libp2p::protocol::SchedulerConfig{});
+ auto scheduler = std::make_shared(
+ std::make_shared(io), libp2p::basic::Scheduler::Config{ std::chrono::milliseconds(100) });
auto graphsyncnetwork = std::make_shared( objects.second, scheduler );
auto generator = std::make_shared();
objects.first = std::make_shared( objects.second,
diff --git a/example/ipfs_client/ipfs.cpp b/example/ipfs_client/ipfs.cpp
index 1e805f5ad..2b505a3b0 100644
--- a/example/ipfs_client/ipfs.cpp
+++ b/example/ipfs_client/ipfs.cpp
@@ -6,7 +6,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -207,7 +207,7 @@ int main(int argc, char* argv[])
//auto peer_id = libp2p::peer::PeerId::fromBase58("QmRXP6S7qwSH4vjSrZeJUGT68ww8rQVhoFWU5Kp7UkVkPN").value();
//auto peer_id = libp2p::peer::PeerId::fromBase58("QmTigmvYEhvcwEpZMuXHcC5HGQG4iKDCKaNeZuoy69QsJw").value();
- // Peers addresses:
+ // Peers addresses:
// /ip4/127.0.0.1/udp/4001/quic;
// /ip4/54.89.142.24/udp/4001/quic;
// /ip4/54.89.142.24/tcp/1031;
@@ -219,7 +219,7 @@ int main(int argc, char* argv[])
// /ip4/10.0.65.121/tcp/4001;
// /ip4/127.0.0.1/tcp/4001;
// /ip4/54.89.142.24/tcp/1024;
- auto peer_address =
+ auto peer_address =
libp2p::multi::Multiaddress::create(
//"/ip4/10.0.65.121/tcp/4001/p2p/QmRXP6S7qwSH4vjSrZeJUGT68ww8rQVhoFWU5Kp7UkVkPN"
//"/ip4/54.89.142.24/tcp/4001/p2p/QmRXP6S7qwSH4vjSrZeJUGT68ww8rQVhoFWU5Kp7UkVkPN"
diff --git a/example/ipfs_client/ipfs_dht.cpp b/example/ipfs_client/ipfs_dht.cpp
index 88df91e06..963c7f6fa 100644
--- a/example/ipfs_client/ipfs_dht.cpp
+++ b/example/ipfs_client/ipfs_dht.cpp
@@ -28,20 +28,10 @@ void IpfsDHT::FindProviders(
const libp2p::multi::ContentIdentifier& cid,
std::function> onProvidersFound)> onProvidersFound)
{
- auto kadCID = libp2p::protocol::kademlia::ContentId::fromWire(
+ auto kadCID = libp2p::protocol::kademlia::ContentId(
libp2p::multi::ContentIdentifierCodec::encode(cid).value());
- if (!kadCID)
- {
- logger_->error("Wrong CID {}",
- libp2p::peer::PeerId::fromHash(cid.content_address).value().toBase58());
- // TODO: pass an error to callback
- //onProvidersFound(ERROR);
- }
- else
- {
- [[maybe_unused]] auto res = kademlia_->findProviders(
- kadCID.value(), 0, onProvidersFound);
- }
+
+ [[maybe_unused]] auto res = kademlia_->findProviders(kadCID, 0, std::move(onProvidersFound));
}
std::vector IpfsDHT::GetBootstrapNodes() const
diff --git a/example/ipfs_client/ping_session.cpp b/example/ipfs_client/ping_session.cpp
index 7bf347777..b73d987c7 100644
--- a/example/ipfs_client/ping_session.cpp
+++ b/example/ipfs_client/ping_session.cpp
@@ -1,4 +1,5 @@
#include "ping_session.hpp"
+#include
#include
PingSession::PingSession(std::shared_ptr io, std::shared_ptr host)
@@ -19,8 +20,8 @@ void PingSession::Init()
});
host_->setProtocolHandler(
- ping_->getProtocolId(),
- [ctx = shared_from_this()](libp2p::protocol::BaseProtocol::StreamResult rstream) {
+ {ping_->getProtocolId()},
+ [ctx = shared_from_this()](libp2p::StreamAndProtocol rstream) {
ctx->ping_->handle(std::move(rstream));
});
}
diff --git a/example/ipfs_client2/testipfs.cpp b/example/ipfs_client2/testipfs.cpp
index 7578b0583..86c13b126 100644
--- a/example/ipfs_client2/testipfs.cpp
+++ b/example/ipfs_client2/testipfs.cpp
@@ -15,7 +15,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -336,7 +336,7 @@ int main(int argc, char *argv[]) {
auto cid = libp2p::multi::ContentIdentifierCodec::fromString("QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D").value();
auto content_id = libp2p::protocol::kademlia::ContentId::fromWire(
libp2p::multi::ContentIdentifierCodec::encode(cid).value());
- auto &scheduler = injector.create();
+ auto &scheduler = injector.create();
std::function find_providers = [&] {
[[maybe_unused]] auto res1 = kademlia->findProviders(
@@ -344,7 +344,7 @@ int main(int argc, char *argv[]) {
[&](libp2p::outcome::result>
res) {
scheduler
- .schedule(libp2p::protocol::scheduler::toTicks(
+ .schedule(libp2p::basic::Scheduler::toTicks(
kademlia_config.randomWalk.interval),
find_providers)
.detach();
@@ -368,7 +368,7 @@ int main(int argc, char *argv[]) {
kademlia->provide(content_id.value(), !kademlia_config.passiveMode);
scheduler
- .schedule(libp2p::protocol::scheduler::toTicks(
+ .schedule(libp2p::basic::Scheduler::toTicks(
kademlia_config.randomWalk.interval),
provide)
.detach();
diff --git a/example/ipfs_pubsub/CMakeLists.txt b/example/ipfs_pubsub/CMakeLists.txt
index 39bddbb58..379db2620 100644
--- a/example/ipfs_pubsub/CMakeLists.txt
+++ b/example/ipfs_pubsub/CMakeLists.txt
@@ -1,25 +1,20 @@
add_executable(ipfs_pubsub
ipfs_pubsub.cpp
- )
+)
# Copy the required headers to install directory
include_directories(
${PROJECT_SOURCE_DIR}/src
- )
+)
target_include_directories(ipfs_pubsub PRIVATE ${GSL_INCLUDE_DIR})
target_link_libraries(ipfs_pubsub
-# ipfs-lite-cpp::ipfs_datastore_rocksdb
-# ipfs-lite-cpp::buffer
-# ipfs-lite-cpp::ipld_node
-# ipfs-lite-cpp::ipfs_merkledag_service
-# ipfs-lite-cpp::graphsync
logger
- crdt_globaldb
- processing_service
+ crdt_globaldb
+ processing_service
p2p::p2p_basic_host
p2p::p2p_default_network
p2p::p2p_peer_repository
@@ -30,10 +25,10 @@ target_link_libraries(ipfs_pubsub
p2p::p2p_kademlia
p2p::p2p_identify
p2p::p2p_ping
- p2p::p2p_logger
+ p2p::p2p_logger
Boost::Boost.DI
Boost::program_options
ipfs-bitswap-cpp
- ipfs-pubsub
+ ipfs-pubsub
${WIN_CRYPT_LIBRARY}
- )
+)
diff --git a/example/node_test/NodeExample.cpp b/example/node_test/NodeExample.cpp
index 04ba65034..3c280f398 100644
--- a/example/node_test/NodeExample.cpp
+++ b/example/node_test/NodeExample.cpp
@@ -153,7 +153,10 @@ void MintTokens( const std::vector &args, std::shared_ptrMintTokens( std::stoull( args[1] ), "", "", sgns::TokenID::FromBytes( { 0x00 } ) );
+ genius_node->MintTokens( std::stoull( args[1] ),
+ "",
+ "",
+ sgns::TokenID::FromBytes( { 0x00 } ) );
}
void TransferTokens( const std::vector &args, std::shared_ptr genius_node )
@@ -352,9 +355,10 @@ void status_polling_thread( std::shared_ptr genius_node )
}
auto status = genius_node->GetProcessingStatus();
-
+
std::string status_str;
- switch (status.status) {
+ switch ( status.status )
+ {
case sgns::processing::ProcessingServiceImpl::Status::DISABLED:
status_str = "DISABLED";
break;
@@ -365,10 +369,10 @@ void status_polling_thread( std::shared_ptr genius_node )
status_str = "PROCESSING";
break;
}
-
+
// Simple output without terminal manipulation
- std::cout << "[Status: " << status_str << " | Progress: "
- << std::fixed << std::setprecision(2) << status.percentage << "%]" << std::endl;
+ std::cout << "[Status: " << status_str << " | Progress: " << std::fixed << std::setprecision( 2 )
+ << status.percentage << "%]" << std::endl;
}
}
@@ -738,7 +742,7 @@ int main( int argc, char *argv[] )
{
input_thread.join();
}
-
+
if ( status_thread.joinable() )
{
status_thread.join();
diff --git a/example/processing_dapp/processing_dapp.cpp b/example/processing_dapp/processing_dapp.cpp
index 547c8be02..9eca8db70 100644
--- a/example/processing_dapp/processing_dapp.cpp
+++ b/example/processing_dapp/processing_dapp.cpp
@@ -3,6 +3,7 @@
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"
+#include
#include
#include
#include
@@ -13,7 +14,7 @@
#include
#include
#include
-#include
+#include
using namespace sgns::processing;
@@ -235,7 +236,7 @@ int main( int argc, char *argv[] )
auto io = std::make_shared();
auto crdtOptions = sgns::crdt::CrdtOptions::DefaultOptions();
- auto scheduler = std::make_shared( io, libp2p::protocol::SchedulerConfig{} );
+ auto scheduler = std::make_shared( std::make_shared( io ), libp2p::basic::Scheduler::Config{ std::chrono::milliseconds( 100 ) } );
auto graphsyncnetwork = std::make_shared( pubs->GetHost(), scheduler );
auto generator = std::make_shared();
diff --git a/example/processing_dapp/processing_dapp_processor.cpp b/example/processing_dapp/processing_dapp_processor.cpp
index 5f0e453ef..0e9e08377 100644
--- a/example/processing_dapp/processing_dapp_processor.cpp
+++ b/example/processing_dapp/processing_dapp_processor.cpp
@@ -12,7 +12,8 @@
#include "crdt/globaldb/globaldb.hpp"
#include
#include
-#include
+#include
+#include
using namespace sgns::processing;
@@ -286,7 +287,7 @@ int main( int argc, char *argv[] )
auto io = std::make_shared();
auto crdtOptions = sgns::crdt::CrdtOptions::DefaultOptions();
- auto scheduler = std::make_shared( io, libp2p::protocol::SchedulerConfig{} );
+ auto scheduler = std::make_shared( std::make_shared( io ), libp2p::basic::Scheduler::Config{ std::chrono::milliseconds( 100 ) } );
auto graphsyncnetwork = std::make_shared( pubs->GetHost(), scheduler );
auto generator = std::make_shared();
auto globaldb_ret = sgns::crdt::GlobalDB::New(
diff --git a/example/processing_room/CMakeLists.txt b/example/processing_room/CMakeLists.txt
index 9184d56da..ff20bbe51 100644
--- a/example/processing_room/CMakeLists.txt
+++ b/example/processing_room/CMakeLists.txt
@@ -1,20 +1,20 @@
add_executable(processing_app
- processing_app.cpp
- )
+ processing_app.cpp
+)
# Copy the required headers to install directory
include_directories(
- ${PROJECT_SOURCE_DIR}/src
- )
+ ${PROJECT_SOURCE_DIR}/src
+)
target_include_directories(processing_app PRIVATE ${GSL_INCLUDE_DIR})
target_link_libraries(processing_app
- SGProcessingProto
- processing_service
- logger
- Boost::program_options
- ipfs-pubsub
+ SGProcessingProto
+ processing_service
+ logger
+ Boost::program_options
+ ipfs-pubsub
)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 034c5dd47..cc2280d4f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,3 +15,10 @@ add_subdirectory(singleton)
add_subdirectory(watcher)
add_subdirectory(coinprices)
add_subdirectory(proof)
+
+install(
+ DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ FILES_MATCHING PATTERN "*.h*"
+)
+
diff --git a/src/account/AccountMessenger.cpp b/src/account/AccountMessenger.cpp
index a8fceffd4..4a3b53a5d 100644
--- a/src/account/AccountMessenger.cpp
+++ b/src/account/AccountMessenger.cpp
@@ -1,6 +1,6 @@
/**
* @file AccountMessenger.cpp
- * @brief
+ * @brief
* @date 2025-07-22
* @author Henrique A. Klein (hklein@gnus.ai)
*/
@@ -289,7 +289,7 @@ namespace sgns
}
std::vector serialized_vec( encoded.begin(), encoded.end() );
- OUTCOME_TRY( auto &&signature, methods_.sign_( serialized_vec ) );
+ BOOST_OUTCOME_TRY( auto signature, methods_.sign_( serialized_vec ) );
accountComm::SignedNonceRequest signed_req;
*signed_req.mutable_data() = req;
signed_req.set_signature( signature.data(), signature.size() );
@@ -407,7 +407,7 @@ namespace sgns
}
std::vector serialized_vec( encoded.begin(), encoded.end() );
- OUTCOME_TRY( auto &&signature, methods_.sign_( serialized_vec ) );
+ BOOST_OUTCOME_TRY( auto signature, methods_.sign_( serialized_vec ) );
accountComm::SignedBlockRequest signed_req;
*signed_req.mutable_data() = req;
@@ -436,7 +436,7 @@ namespace sgns
}
std::vector serialized_vec( encoded.begin(), encoded.end() );
- OUTCOME_TRY( auto &&signature, methods_.sign_( serialized_vec ) );
+ BOOST_OUTCOME_TRY( auto signature, methods_.sign_( serialized_vec ) );
accountComm::SignedBlockCidRequest signed_req;
*signed_req.mutable_data() = req;
@@ -466,7 +466,7 @@ namespace sgns
}
std::vector serialized_vec( encoded.begin(), encoded.end() );
- OUTCOME_TRY( auto &&signature, methods_.sign_( serialized_vec ) );
+ BOOST_OUTCOME_TRY( auto signature, methods_.sign_( serialized_vec ) );
accountComm::SignedTransactionRequest signed_req;
*signed_req.mutable_data() = req;
@@ -495,7 +495,7 @@ namespace sgns
}
std::vector serialized_vec( encoded.begin(), encoded.end() );
- OUTCOME_TRY( auto &&signature, methods_.sign_( serialized_vec ) );
+ BOOST_OUTCOME_TRY( auto signature, methods_.sign_( serialized_vec ) );
accountComm::SignedUTXORequest signed_req;
*signed_req.mutable_data() = req;
@@ -1025,7 +1025,7 @@ namespace sgns
first_response_time_.erase( req_id );
}
- OUTCOME_TRY( RequestNonce( req_id ) );
+ BOOST_OUTCOME_TRY( RequestNonce( req_id ) );
const auto start_time = std::chrono::steady_clock::now();
const auto full_timeout = std::chrono::milliseconds( timeout_ms );
diff --git a/src/account/CMakeLists.txt b/src/account/CMakeLists.txt
index f30b3f1df..3682843f6 100644
--- a/src/account/CMakeLists.txt
+++ b/src/account/CMakeLists.txt
@@ -15,11 +15,12 @@ add_library(sgns_genius_account
target_link_libraries(sgns_genius_account
PUBLIC
Boost::headers
- KeyGeneration
+ ProofSystem
outcome
logger
crdt_globaldb
ipfs-pubsub
+ TrustWalletCore
PRIVATE
hasher
json_secure_storage
@@ -29,7 +30,6 @@ target_link_libraries(sgns_genius_account
SGTransactionProto
${WIN_API_LIBRARY}
${USER_ENV_LIBRARY}
- TrustWalletCore
wallet_core_rs
TrezorCrypto
protobuf::libprotobuf
@@ -56,6 +56,7 @@ add_library(genius_node
IGeniusTransactions.cpp
TransferTransaction.cpp
MintTransaction.cpp
+ MintTransactionV2.cpp
ProcessingTransaction.cpp
EscrowTransaction.cpp
EscrowReleaseTransaction.cpp
@@ -74,7 +75,7 @@ set_target_properties(genius_node PROPERTIES UNITY_BUILD ON)
target_link_libraries(genius_node
PUBLIC
Boost::headers
- KeyGeneration
+ ProofSystem
outcome
logger
crdt_globaldb
@@ -83,6 +84,7 @@ target_link_libraries(genius_node
sgns_genius_account # Link to the GeniusAccount library
blockchain_genesis
ProcessingBase
+ evmrelay
PRIVATE
secure_storage
component_factory
@@ -117,7 +119,9 @@ target_link_libraries(genius_node
processing_proof
)
-set_target_properties(genius_node PROPERTIES PUBLIC_HEADER "GeniusNode.hpp")
+add_dependencies(genius_node rlp)
+
+#set_target_properties(genius_node PROPERTIES PU@)
if(MSVC)
target_compile_options(genius_node PUBLIC /constexpr:steps1500000)
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
@@ -127,4 +131,3 @@ endif()
# Install both libraries
supergenius_install(sgns_genius_account)
supergenius_install(genius_node)
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/../../ProofSystem/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h*")
diff --git a/src/account/EscrowReleaseTransaction.cpp b/src/account/EscrowReleaseTransaction.cpp
index 704ac4093..28884feba 100644
--- a/src/account/EscrowReleaseTransaction.cpp
+++ b/src/account/EscrowReleaseTransaction.cpp
@@ -69,7 +69,10 @@ namespace sgns
tx_struct.set_original_escrow_hash( original_escrow_hash_ );
size_t size = tx_struct.ByteSizeLong();
std::vector serialized_proto( size );
- tx_struct.SerializeToArray( serialized_proto.data(), static_cast( size ) );
+ if ( !tx_struct.SerializeToArray( serialized_proto.data(), static_cast( size ) ) )
+ {
+ std::cerr << "Failed to serialize transaction\n";
+ }
return serialized_proto;
}
@@ -79,7 +82,7 @@ namespace sgns
SGTransaction::EscrowReleaseTx tx_struct;
if ( !tx_struct.ParseFromArray( data.data(), static_cast( data.size() ) ) )
{
- std::cerr << "Failed to parse EscrowReleaseTx from array." << std::endl;
+ std::cerr << "Failed to parse EscrowReleaseTx from array.\n";
return nullptr;
}
std::vector inputs;
@@ -91,7 +94,7 @@ namespace sgns
auto maybe_hash = base::Hash256::fromReadableString( input_proto.tx_id_hash() );
if ( !maybe_hash )
{
- std::cerr << "Invalid hash in input" << std::endl;
+ std::cerr << "Invalid hash in input\n";
return nullptr;
}
curr.txid_hash_ = maybe_hash.value();
@@ -123,6 +126,16 @@ namespace sgns
return utxo_params_;
}
+ bool EscrowReleaseTransaction::HasUTXOParameters() const
+ {
+ return true;
+ }
+
+ std::optional EscrowReleaseTransaction::GetUTXOParametersOpt() const
+ {
+ return utxo_params_;
+ }
+
uint64_t EscrowReleaseTransaction::GetReleaseAmount() const
{
return release_amount_;
diff --git a/src/account/EscrowReleaseTransaction.hpp b/src/account/EscrowReleaseTransaction.hpp
index ed9aef592..a8b9fe28a 100644
--- a/src/account/EscrowReleaseTransaction.hpp
+++ b/src/account/EscrowReleaseTransaction.hpp
@@ -65,6 +65,18 @@ namespace sgns
*/
UTXOTxParameters GetUTXOParameters() const;
+ /**
+ * @brief Returns if transaction supports UTXOs
+ * @return True if supported, false otherwise
+ */
+ bool HasUTXOParameters() const override;
+
+ /**
+ * @brief Returns the UTXOs
+ * @return If exists, returns the UTXOs of the transaction
+ */
+ std::optional GetUTXOParametersOpt() const override;
+
/**
* @brief Gets the release amount.
*
diff --git a/src/account/EscrowTransaction.cpp b/src/account/EscrowTransaction.cpp
index bd99cbfa1..d51e0366f 100644
--- a/src/account/EscrowTransaction.cpp
+++ b/src/account/EscrowTransaction.cpp
@@ -20,7 +20,7 @@ namespace sgns
SGTransaction::DAGStruct dag ) :
IGeniusTransactions( "escrow-hold", SetDAGWithType( std::move( dag ), "escrow-hold" ) ),
utxo_params_( std::move( params ) ),
- amount_( std::move( amount ) ),
+ amount_( amount ),
dev_addr_( std::move( dev_addr ) ),
peers_cut_( peers_cut )
{
@@ -63,7 +63,11 @@ namespace sgns
size_t size = tx_struct.ByteSizeLong();
std::vector serialized_proto( size );
- tx_struct.SerializeToArray( serialized_proto.data(), serialized_proto.size() );
+ if ( !tx_struct.SerializeToArray( serialized_proto.data(), serialized_proto.size() ) )
+ {
+ std::cerr << "Failed to serialize transaction\n";
+ }
+
return serialized_proto;
}
diff --git a/src/account/EscrowTransaction.hpp b/src/account/EscrowTransaction.hpp
index bdc46797d..38652f79e 100644
--- a/src/account/EscrowTransaction.hpp
+++ b/src/account/EscrowTransaction.hpp
@@ -39,6 +39,24 @@ namespace sgns
return utxo_params_;
}
+ /**
+ * @brief Returns if transaction supports UTXOs
+ * @return True if supported, false otherwise
+ */
+ bool HasUTXOParameters() const override
+ {
+ return true;
+ }
+
+ /**
+ * @brief Returns the UTXOs
+ * @return If exists, returns the UTXOs of the transaction
+ */
+ std::optional GetUTXOParametersOpt() const override
+ {
+ return utxo_params_;
+ }
+
std::string GetDevAddress() const
{
return dev_addr_;
diff --git a/src/account/GeniusAccount.cpp b/src/account/GeniusAccount.cpp
index da90b6ff3..13bd42dcf 100644
--- a/src/account/GeniusAccount.cpp
+++ b/src/account/GeniusAccount.cpp
@@ -1,5 +1,9 @@
#include "GeniusAccount.hpp"
+#include
+#include
+#include
+#include
#include
#include
@@ -85,7 +89,7 @@ namespace
nil::crypto3::multiprecision::uint256_t key_seed( maybe_key->value.GetString() );
ethereum::EthereumKeyGenerator eth_key( key_seed );
auto pub_key = eth_key.GetEntirePubValue();
- OUTCOME_TRY( std::vector pub_key_vec, base::unhex( pub_key ) );
+ BOOST_OUTCOME_TRY( std::vector pub_key_vec, base::unhex( pub_key ) );
auto secure_storage = std::make_shared( std::string( SECURE_STORAGE_PREFIX ) +
libp2p::multi::detail::encodeBase58( pub_key_vec ) );
@@ -97,7 +101,7 @@ namespace
rj::Document new_doc;
new_doc.CopyFrom( maybe_field->value, new_doc.GetAllocator() );
- OUTCOME_TRY( secure_storage->SaveJSON( std::move( new_doc ) ) );
+ BOOST_OUTCOME_TRY( secure_storage->SaveJSON( std::move( new_doc ) ) );
genius_account_logger()->debug( "Successfully migrated JSON secure storage" );
return secure_storage;
@@ -137,6 +141,7 @@ namespace sgns
genius_account_logger()->info(
"Could not load Genius address from storage, attempting to generate from ethereum private key" );
+
auto response = GenerateGeniusAddress( eth_private_key, base_path );
if ( response.has_error() )
{
@@ -148,10 +153,10 @@ namespace sgns
return CreateInstanceFromResponse( token_id, std::move( response.value() ), full_node );
}
- std::shared_ptr GeniusAccount::New( TokenID token_id,
- const Credentials &credentials,
- const boost::filesystem::path &base_path,
- bool full_node )
+ std::shared_ptr GeniusAccount::NewFromMnemonic( TokenID token_id,
+ const std::string &mnemonic,
+ const boost::filesystem::path &base_path,
+ bool full_node )
{
if ( auto response = LoadGeniusAccount( base_path ); response.has_value() )
{
@@ -160,50 +165,52 @@ namespace sgns
}
genius_account_logger()->info(
- "Could not load Genius address from storage, attempting to generate from credentials" );
- auto response = GenerateGeniusAddress( credentials, base_path );
- if ( response.has_error() )
+ "Could not load Genius address from storage, attempting to generate from mnemonic" );
+
+ try
{
- genius_account_logger()->error( "Failed to generate Genius address from credentials" );
- return nullptr;
- }
+ TW::HDWallet wallet( mnemonic, "", true );
+ auto derivation_path = TW::derivationPath( TWCoinTypeEthereum );
+ TW::PrivateKey private_key = wallet.getKey( TWCoinTypeEthereum, derivation_path );
- genius_account_logger()->debug( "Generated a Genius address from credentials" );
- // Save credentials to storage
- auto &[storage, addresses] = response.value();
- storage->Save( "email", credentials.email );
- storage->Save( "password", credentials.password );
+ auto response = GenerateGeniusAddress( private_key, base_path );
+ if ( response.has_error() )
+ {
+ genius_account_logger()->error( "Failed to generate Genius address from private key" );
+ return nullptr;
+ }
- return CreateInstanceFromResponse( token_id, std::move( response.value() ), full_node );
+ genius_account_logger()->debug( "Generated a Genius address from private key" );
+ auto account = CreateInstanceFromResponse( token_id, std::move( response.value() ), full_node );
+
+ account->storage_->Save( "mnemonic", wallet.getMnemonic() );
+
+ return account;
+ }
+ catch ( const std::invalid_argument & )
+ {
+ genius_account_logger()->error( "Tried to create private key from invalid mnemonic" );
+ }
+
+ return nullptr;
}
std::shared_ptr GeniusAccount::New( TokenID token_id,
const boost::filesystem::path &base_path,
bool full_node )
{
- static std::string_view SUFFIX = "@gnus.ai";
- static std::mt19937_64 eng( ( std::random_device() )() );
-
if ( auto response = LoadGeniusAccount( base_path ); response.has_value() )
{
genius_account_logger()->debug( "Loaded existing Genius address" );
return CreateInstanceFromResponse( token_id, std::move( response.value() ), full_node );
}
- genius_account_logger()->info(
- "Could not find existing Genius address, generating one with random credentials" );
-
- std::uniform_int_distribution dist( 0, std::numeric_limits::max() );
- uint64_t num = dist( eng );
- std::string email = base::hex_lower(
- gsl::span( reinterpret_cast( &num ), sizeof( num ) ) );
- email.append( SUFFIX );
+ genius_account_logger()->error(
+ "Could not find existing Genius address, generating one from a random mnemonic" );
- num = dist( eng );
- std::string password = base::hex_lower(
- gsl::span( reinterpret_cast( &num ), sizeof( num ) ) );
+ TW::HDWallet wallet( 128, "" );
- return New( token_id, { std::move( email ), std::move( password ) }, base_path, full_node );
+ return GeniusAccount::NewFromMnemonic( token_id, wallet.getMnemonic(), base_path, full_node );
}
outcome::result GeniusAccount::LoadGeniusAccount(
@@ -224,7 +231,7 @@ namespace sgns
public_key.substr( 0, 16 ) + "...",
public_key.length() );
- OUTCOME_TRY( std::vector vec, base::unhex( public_key ) );
+ BOOST_OUTCOME_TRY( std::vector vec, base::unhex( public_key ) );
storage = std::make_shared( std::string( SECURE_STORAGE_PREFIX ) +
libp2p::multi::detail::encodeBase58( vec ) );
@@ -235,7 +242,7 @@ namespace sgns
else
{
genius_account_logger()->debug( "Secure storage ID file does not exist, will try migration" );
- OUTCOME_TRY( storage, MigrateSecureStorage( base_path ) );
+ BOOST_OUTCOME_TRY( storage, MigrateSecureStorage( base_path ) );
}
auto load_res = storage->Load( "sgns_key" );
@@ -266,39 +273,38 @@ namespace sgns
}
outcome::result GeniusAccount::GenerateGeniusAddress(
- const Credentials &credentials,
+ const char *eth_private_key,
const boost::filesystem::path &base_path )
{
- genius_account_logger()->trace( "Key seed from credentials" );
+ genius_account_logger()->trace( "Key seed from ethereum private key" );
- if ( credentials.email.empty() || credentials.password.empty() )
+ if ( eth_private_key == nullptr )
{
+ genius_account_logger()->error( "No ethereum address to generate from" );
return std::errc::invalid_argument;
}
- std::string s = credentials.email + credentials.password;
- auto hashed = TW::Hash::sha256( s );
- auto hexed = base::hex_lower( hashed );
+ auto private_key_vec = base::unhex( eth_private_key );
+ if ( private_key_vec.has_error() )
+ {
+ genius_account_logger()->error( "Could not extract private key from hexadecimal" );
+ return std::errc::invalid_argument;
+ }
- return GenerateGeniusAddress( hexed.data(), base_path );
+ TW::PrivateKey tw_private_key( private_key_vec.value() );
+
+ return GenerateGeniusAddress( tw_private_key, base_path );
}
outcome::result GeniusAccount::GenerateGeniusAddress(
- const char *eth_private_key,
+ const TW::PrivateKey &private_key,
const boost::filesystem::path &base_path )
{
- genius_account_logger()->trace( "Key seed from ethereum private key" );
-
- if ( eth_private_key == nullptr )
- {
- return outcome::failure( std::errc::invalid_argument );
- }
+ genius_account_logger()->trace( "Key seed from TW private key" );
- OUTCOME_TRY( auto pri_key_vec, base::unhex( eth_private_key ) );
- auto signed_secret = TW::PrivateKey( pri_key_vec )
- .sign(
- TW::Data( ELGAMAL_PUBKEY_PREDEFINED.cbegin(), ELGAMAL_PUBKEY_PREDEFINED.cend() ),
- TWCurveSECP256k1 );
+ auto signed_secret = private_key.sign(
+ TW::Data( ELGAMAL_PUBKEY_PREDEFINED.cbegin(), ELGAMAL_PUBKEY_PREDEFINED.cend() ),
+ TWCurveSECP256k1 );
if ( signed_secret.empty() )
{
@@ -311,7 +317,7 @@ namespace sgns
// Create storage and keys
ethereum::EthereumKeyGenerator eth_key( key_seed );
auto pub_key = eth_key.GetEntirePubValue();
- OUTCOME_TRY( std::vector pub_key_vec, base::unhex( pub_key ) );
+ BOOST_OUTCOME_TRY( std::vector pub_key_vec, base::unhex( pub_key ) );
auto storage = std::make_shared( std::string( SECURE_STORAGE_PREFIX ) +
libp2p::multi::detail::encodeBase58( pub_key_vec ) );
diff --git a/src/account/GeniusAccount.hpp b/src/account/GeniusAccount.hpp
index 0f7143c40..0d8e9ddb8 100644
--- a/src/account/GeniusAccount.hpp
+++ b/src/account/GeniusAccount.hpp
@@ -21,6 +21,8 @@
#include
#include
+#include
+#include
#include
#include
@@ -30,8 +32,6 @@
#include "outcome/outcome.hpp"
#include
-#include
-#include
namespace sgns
{
@@ -62,7 +62,7 @@ namespace sgns
};
static const std::array ELGAMAL_PUBKEY_PREDEFINED; ///< Predefined ElGamal public key
- static constexpr uint64_t NONCE_CACHE_DURATION_MS = 5000; ///< Cache nonce results for 5 seconds
+ static constexpr int64_t NONCE_CACHE_DURATION_MS = 5000; ///< Cache nonce results for 5 seconds
/**
* @brief Factory constructor of new GeniusAccount.
@@ -77,14 +77,10 @@ namespace sgns
const boost::filesystem::path &base_path,
bool full_node = false );
- /**
- * @brief Factory constructor of new GeniusAccount
- * @param[in] token_id Token ID of the account
- */
- static std::shared_ptr New( TokenID token_id,
- const Credentials &credentials,
- const boost::filesystem::path &base_path,
- bool full_node = false );
+ static std::shared_ptr NewFromMnemonic( TokenID token_id,
+ const std::string &mnemonic,
+ const boost::filesystem::path &base_path,
+ bool full_node = false );
/**
* @brief Factory constructor of new GeniusAccount
@@ -256,7 +252,7 @@ namespace sgns
static outcome::result GenerateGeniusAddress( const char *eth_private_key,
const boost::filesystem::path &base_path );
- static outcome::result GenerateGeniusAddress( const Credentials &credentials,
+ static outcome::result GenerateGeniusAddress( const TW::PrivateKey &private_key,
const boost::filesystem::path &base_path );
protected:
@@ -286,12 +282,12 @@ namespace sgns
StorageWithAddress response_value,
bool full_node );
- TokenID token; ///< Token ID of the account
- bool is_full_node_; ///< Whether this account is a full node
+ TokenID token; ///< Token ID of the account
+ std::shared_ptr storage_; ///< Secure storage instance
+ bool is_full_node_; ///< Whether this account is a full node
std::shared_ptr eth_keypair_; ///< Ethereum keypair
std::shared_ptr elgamal_address_; ///< ElGamal keypair
- std::shared_ptr storage_; ///< Secure storage instance
std::unordered_map confirmed_nonces_; ///< Map of the confirmed nonces from peers
mutable std::shared_mutex nonce_mutex_; ///< Mutex for the nonce map
std::set pending_nonces_; ///< Reserved but not confirmed nonces
diff --git a/src/account/GeniusNode.cpp b/src/account/GeniusNode.cpp
index 26ba64c38..44e31f4c1 100644
--- a/src/account/GeniusNode.cpp
+++ b/src/account/GeniusNode.cpp
@@ -5,7 +5,6 @@
* @author Henrique A. Klein (hklein@gnus.ai)
*/
-#include
#include
#include
#include
@@ -24,7 +23,9 @@
#include
#include
#include
-#include
+#include
+#include
+#include
#include "base/sgns_version.hpp"
#include "account/TokenAmount.hpp"
@@ -171,29 +172,46 @@ namespace sgns
return instance;
}
- std::shared_ptr GeniusNode::New( const DevConfig_st &dev_config,
- const GeniusAccount::Credentials &credentials,
- bool autodht,
- bool isprocessor,
- uint16_t base_port,
- bool is_full_node,
- bool use_upnp )
+ std::shared_ptr GeniusNode::NewFromMnemonic( const DevConfig_st &dev_config,
+ const std::string &mnemonic,
+ bool autodht,
+ bool isprocessor,
+ uint16_t base_port,
+ bool is_full_node,
+ bool use_upnp )
{
- auto instance = std::shared_ptr( new GeniusNode(
- dev_config,
- GeniusAccount::New( dev_config.TokenID, credentials, dev_config.BaseWritePath, is_full_node ),
- autodht,
- isprocessor,
- base_port,
- is_full_node,
- use_upnp ) );
+ try
+ {
+ auto account = GeniusAccount::NewFromMnemonic( dev_config.TokenID,
+ mnemonic,
+ dev_config.BaseWritePath,
+ is_full_node );
- if ( instance )
+ if ( account == nullptr )
+ {
+ return nullptr;
+ }
+
+ auto instance = std::shared_ptr( new GeniusNode( dev_config,
+ std::move( account ),
+ autodht,
+ isprocessor,
+ base_port,
+ is_full_node,
+ use_upnp ) );
+
+ if ( instance )
+ {
+ instance->BeginDBInitialization();
+ }
+
+ return instance;
+ }
+ catch ( const std::invalid_argument &err )
{
- instance->BeginDBInitialization();
+ std::cerr << "Failed to generate address from mnemonic: " << err.what() << '\n';
}
-
- return instance;
+ return nullptr;
}
GeniusNode::GeniusNode( const DevConfig_st &dev_config,
@@ -223,7 +241,9 @@ namespace sgns
processing_channel_topic_( std::string( PROCESSING_CHANNEL ) ),
processing_grid_chanel_topic_( std::string( PROCESSING_GRID_CHANNEL ) ),
m_lastApiCall( std::chrono::system_clock::now() - m_minApiCallInterval ),
- scheduler_( std::make_shared( io_, libp2p::protocol::SchedulerConfig{} ) ),
+ scheduler_( std::make_shared(
+ std::make_shared( io_ ),
+ libp2p::basic::Scheduler::Config{ std::chrono::milliseconds( 100 ) } ) ),
generator_( std::make_shared() ),
processing_callback_pool_( std::make_unique( 1 ) ),
use_upnp_( use_upnp )
@@ -365,7 +385,8 @@ namespace sgns
strong->node_logger_->error( "Error starting blockchain: {}",
result.error().message() );
strong->node_logger_->info( "Scheduling blockchain retry after failure" );
- strong->account_->RequestHeads({std::string(blockchain::ValidatorRegistry::ValidatorTopic())});
+ strong->account_->RequestHeads(
+ { std::string( blockchain::ValidatorRegistry::ValidatorTopic() ) } );
strong->ScheduleBlockchainRetry();
return;
}
@@ -387,21 +408,23 @@ namespace sgns
}
// Move transaction initialization off the AccountMessenger worker thread.
- boost::asio::post( *strong->io_, [weak_self]()
- {
- if ( auto strong = weak_self.lock() )
+ boost::asio::post(
+ *strong->io_,
+ [weak_self]()
{
- auto current_state = strong->state_.load();
- if ( current_state != NodeState::INITIALIZING_BLOCKCHAIN )
+ if ( auto strong = weak_self.lock() )
{
- strong->node_logger_->debug(
- "Skipping transaction initialization, unexpected state: {}",
- NodeStateToString( current_state ) );
- return;
+ auto current_state = strong->state_.load();
+ if ( current_state != NodeState::INITIALIZING_BLOCKCHAIN )
+ {
+ strong->node_logger_->debug(
+ "Skipping transaction initialization, unexpected state: {}",
+ NodeStateToString( current_state ) );
+ return;
+ }
+ strong->StateTransition( NodeState::INITIALIZING_TRANSACTIONS );
}
- strong->StateTransition( NodeState::INITIALIZING_TRANSACTIONS );
- }
- } );
+ } );
}
} );
}
@@ -598,8 +621,8 @@ namespace sgns
std::vector hash( SHA256_DIGEST_LENGTH );
SHA256( inputBytes.data(), inputBytes.size(), hash.data() );
- libp2p::protocol::kademlia::ContentId key( hash );
- auto acc_cid = libp2p::multi::ContentIdentifierCodec::decode( key.data );
+ auto key = libp2p::multi::ContentIdentifierCodec::encodeCIDV0( hash.data(), hash.size() );
+ auto acc_cid = libp2p::multi::ContentIdentifierCodec::decode( key );
auto maybe_base58 = libp2p::multi::ContentIdentifierCodec::toString( acc_cid.value() );
if ( !maybe_base58 )
{
@@ -937,11 +960,11 @@ namespace sgns
std::vector hash( SHA256_DIGEST_LENGTH );
SHA256( inputBytes.data(), inputBytes.size(), hash.data() );
// Provide CID
- libp2p::protocol::kademlia::ContentId key( hash );
+ auto key = libp2p::multi::ContentIdentifierCodec::encodeCIDV0( hash.data(), hash.size() );
pubsub_->GetDHT()->Start();
pubsub_->ProvideCID( key );
- auto cidtest = libp2p::multi::ContentIdentifierCodec::decode( key.data );
+ auto cidtest = libp2p::multi::ContentIdentifierCodec::decode( key );
auto cidstring = libp2p::multi::ContentIdentifierCodec::toString( cidtest.value() );
node_logger_->info( "CID Test:: {}", cidstring.value() );
@@ -978,7 +1001,7 @@ namespace sgns
{
return outcome::failure( boost::system::error_code{} );
}
- OUTCOME_TRY( auto procmgr, sgns::sgprocessing::ProcessingManager::Create( jsondata ) );
+ BOOST_OUTCOME_TRY( auto procmgr, sgns::sgprocessing::ProcessingManager::Create( jsondata ) );
auto funds = GetProcessCost( procmgr );
if ( funds <= 0 )
@@ -1040,9 +1063,9 @@ namespace sgns
return outcome::failure( cut.error() );
}
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( ( auto &&, result_pair ),
- manager->HoldEscrow( funds, std::string( dev_config_.Addr ), cut.value(), uuidstring ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto result_pair,
+ manager->HoldEscrow( funds, std::string( dev_config_.Addr ), cut.value(), uuidstring ) );
auto [tx_id, escrow_data_pair] = result_pair;
@@ -1115,6 +1138,7 @@ namespace sgns
const std::string &transaction_hash,
const std::string &chainid,
TokenID tokenid,
+ std::string destination,
std::chrono::milliseconds timeout )
{
if ( GetTransactionManagerState() != TransactionManager::State::READY )
@@ -1123,9 +1147,13 @@ namespace sgns
return outcome::failure( boost::system::error_code{} );
}
auto start_time = std::chrono::steady_clock::now();
+ if ( destination.empty() )
+ {
+ destination = account_->GetAddress();
+ }
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( auto &&tx_id, manager->MintFunds( amount, transaction_hash, chainid, tokenid ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto tx_id, manager->MintFunds( amount, transaction_hash, chainid, tokenid, destination ) );
auto mint_result = manager->WaitForTransactionOutgoing( tx_id, timeout );
@@ -1153,8 +1181,8 @@ namespace sgns
}
auto start_time = std::chrono::steady_clock::now();
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( auto &&tx_id, manager->TransferFunds( amount, destination, token_id ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto tx_id, manager->TransferFunds( amount, destination, token_id ) );
auto transfer_result = manager->WaitForTransactionOutgoing( tx_id, timeout );
@@ -1180,8 +1208,8 @@ namespace sgns
return outcome::failure( boost::system::error_code{} );
}
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( auto &&tx_id, manager->TransferFunds( amount, destination, token_id ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto tx_id, manager->TransferFunds( amount, destination, token_id ) );
node_logger_->debug( "TransferFunds transaction {} sent", tx_id );
return tx_id;
@@ -1196,8 +1224,8 @@ namespace sgns
return outcome::failure( boost::system::error_code{} );
}
auto start_time = std::chrono::steady_clock::now();
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( auto &&tx_id, manager->TransferFunds( amount, dev_config_.Addr, token_id ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto tx_id, manager->TransferFunds( amount, dev_config_.Addr, token_id ) );
auto paydev_result = manager->WaitForTransactionOutgoing( tx_id, timeout );
@@ -1226,8 +1254,8 @@ namespace sgns
}
auto start_time = std::chrono::steady_clock::now();
- OUTCOME_TRY( auto &&manager, GetTransactionManager() );
- OUTCOME_TRY( auto &&tx_id, manager->PayEscrow( escrow_path, taskresult, std::move( crdt_transaction ) ) );
+ BOOST_OUTCOME_TRY( auto manager, GetTransactionManager() );
+ BOOST_OUTCOME_TRY( auto tx_id, manager->PayEscrow( escrow_path, taskresult, std::move( crdt_transaction ) ) );
auto payescrow_result = manager->WaitForTransactionOutgoing( tx_id, timeout );
diff --git a/src/account/GeniusNode.hpp b/src/account/GeniusNode.hpp
index 37edc6846..5190e8194 100644
--- a/src/account/GeniusNode.hpp
+++ b/src/account/GeniusNode.hpp
@@ -66,17 +66,17 @@ namespace sgns
bool is_full_node = false,
bool use_upnp = true );
- static std::shared_ptr New( const DevConfig_st &dev_config,
- const GeniusAccount::Credentials &credentials,
- bool autodht = true,
- bool isprocessor = true,
- uint16_t base_port = 40001,
- bool is_full_node = false,
- bool use_upnp = true );
+ static std::shared_ptr NewFromMnemonic( const DevConfig_st &dev_config,
+ const std::string &mnemonic,
+ bool autodht = true,
+ bool isprocessor = true,
+ uint16_t base_port = 40001,
+ bool is_full_node = false,
+ bool use_upnp = true );
~GeniusNode() override;
- enum class NodeState: uint8_t
+ enum class NodeState : uint8_t
{
CREATING = 0,
MIGRATING_DATABASE,
@@ -91,7 +91,7 @@ namespace sgns
/**
* @brief GeniusNode Error class
*/
- enum class Error: uint8_t
+ enum class Error : uint8_t
{
INSUFFICIENT_FUNDS = 1, ///< Insufficient funds for a transaction
DATABASE_WRITE_ERROR = 2, ///< Error writing data into the database
@@ -145,7 +145,8 @@ namespace sgns
const std::string &transaction_hash,
const std::string &chainid,
TokenID tokenid,
- std::chrono::milliseconds timeout = std::chrono::milliseconds( TIMEOUT_MINT ) );
+ std::string destination = "",
+ std::chrono::milliseconds timeout = std::chrono::milliseconds( TIMEOUT_MINT ) );
void AddPeer( const std::string &peer );
void RefreshUPNP( uint16_t pubsubport );
@@ -353,7 +354,7 @@ namespace sgns
std::thread upnp_thread;
std::atomic stop_upnp{ false };
std::string base58key_;
- std::shared_ptr scheduler_;
+ std::shared_ptr scheduler_;
std::shared_ptr generator_;
std::shared_ptr graphsyncnetwork_;
diff --git a/src/account/IGeniusTransactions.cpp b/src/account/IGeniusTransactions.cpp
index 9eda254d7..e27050f27 100644
--- a/src/account/IGeniusTransactions.cpp
+++ b/src/account/IGeniusTransactions.cpp
@@ -88,7 +88,10 @@ namespace sgns
dag_st.clear_signature();
auto size = dag_st.ByteSizeLong();
std::vector serialized( size );
- dag_st.SerializeToArray( serialized.data(), size );
+ if ( !dag_st.SerializeToArray( serialized.data(), size ) )
+ {
+ std::cerr << "Failed to serialize DAG struct\n";
+ }
dag_st.set_signature( str_signature );
return GeniusAccount::VerifySignature( dag_st.source_addr(), str_signature, serialized ) && CheckHash();
diff --git a/src/account/IGeniusTransactions.hpp b/src/account/IGeniusTransactions.hpp
index 890f96bb9..d97f70cd8 100644
--- a/src/account/IGeniusTransactions.hpp
+++ b/src/account/IGeniusTransactions.hpp
@@ -10,11 +10,13 @@
#include
#include
#include
+#include
#include
#include "outcome/outcome.hpp"
#include "account/proto/SGTransaction.pb.h"
+#include "account/UTXOStructs.hpp"
#include "GeniusAccount.hpp"
#include
@@ -57,6 +59,24 @@ namespace sgns
virtual std::vector SerializeByteVector() = 0;
+ /**
+ * @brief Returns if transaction supports UTXOs
+ * @return True if supported, false otherwise
+ */
+ virtual bool HasUTXOParameters() const
+ {
+ return false;
+ }
+
+ /**
+ * @brief Returns the UTXOs
+ * @return If exists, returns the UTXOs of the transaction
+ */
+ virtual std::optional GetUTXOParametersOpt() const
+ {
+ return std::nullopt;
+ }
+
virtual std::string GetTransactionSpecificPath() const = 0;
static std::string GetTransactionFullPath( const std::string &tx_hash )
diff --git a/src/account/Migration0_2_0To1_0_0.cpp b/src/account/Migration0_2_0To1_0_0.cpp
index ecc3267dc..f68d331ca 100644
--- a/src/account/Migration0_2_0To1_0_0.cpp
+++ b/src/account/Migration0_2_0To1_0_0.cpp
@@ -52,7 +52,7 @@ namespace sgns
std::shared_ptr ioContext,
std::shared_ptr pubSub,
std::shared_ptr graphsync,
- std::shared_ptr scheduler,
+ std::shared_ptr scheduler,
std::shared_ptr generator,
std::string writeBasePath,
std::string base58key ) :
@@ -99,7 +99,7 @@ namespace sgns
if ( db_0_0_2_out_ && db_0_0_2_in_ )
{
- OUTCOME_TRY( auto &&target_db, InitTargetDb() );
+ BOOST_OUTCOME_TRY( auto target_db, InitTargetDb() );
db_1_0_0_ = std::move( target_db );
}
@@ -178,7 +178,7 @@ namespace sgns
m_logger->debug( "Initializing legacy DB at path {}", fullPath );
- OUTCOME_TRY( auto &&db,
+ BOOST_OUTCOME_TRY( auto db,
crdt::GlobalDB::New( ioContext_,
fullPath,
pubSub_,
@@ -283,13 +283,13 @@ namespace sgns
m_logger->debug( "Need to remove previous transaction, since new one is older {}",
transaction_path );
- BOOST_OUTCOME_TRYV2( auto &&, crdt_transaction_->Erase( tx_key ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Erase( tx_key ) );
sgns::crdt::HierarchicalKey replicated_proof_key( BASE + BuildLegacyProofPath( *tx ) );
m_logger->debug( "Need to remove previous proof as well {}",
replicated_proof_key.GetKey() );
- BOOST_OUTCOME_TRYV2( auto &&, crdt_transaction_->Erase( replicated_proof_key ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Erase( replicated_proof_key ) );
}
else
{
@@ -302,12 +302,12 @@ namespace sgns
migrate_tx = true;
m_logger->debug( "Invalid transaction, deleting from migration {}", transaction_path );
- BOOST_OUTCOME_TRYV2( auto &&, crdt_transaction_->Erase( tx_key ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Erase( tx_key ) );
sgns::crdt::HierarchicalKey replicated_proof_key( BASE + BuildLegacyProofPath( *tx ) );
m_logger->debug( "Need to remove previous proof as well {}", replicated_proof_key.GetKey() );
- BOOST_OUTCOME_TRYV2( auto &&, crdt_transaction_->Erase( replicated_proof_key ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Erase( replicated_proof_key ) );
}
}
}
@@ -329,7 +329,7 @@ namespace sgns
sgns::crdt::GlobalDB::Buffer data_transaction;
data_transaction.put( tx->SerializeByteVector() );
- BOOST_OUTCOME_TRYV2( auto &&,
+ BOOST_OUTCOME_TRY(
crdt_transaction_->Put( std::move( tx_key ), std::move( data_transaction ) ) );
sgns::crdt::HierarchicalKey proof_crdt_key( BASE + BuildLegacyProofPath( *tx ) );
@@ -347,7 +347,7 @@ namespace sgns
++migrated_count;
if ( migrated_count >= BATCH_SIZE )
{
- OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
crdt_transaction_ = db_1_0_0_->BeginTransaction(); // start fresh
topics_.clear();
@@ -377,7 +377,7 @@ namespace sgns
topics_.emplace( std::string( TransactionManager::GNUS_FULL_NODES_TOPIC ) );
m_logger->debug( "Migrating output DB into new DB" );
- OUTCOME_TRY( auto &&remainder_outdb, MigrateDb( db_0_0_2_out_, db_1_0_0_ ) );
+ BOOST_OUTCOME_TRY( auto remainder_outdb, MigrateDb( db_0_0_2_out_, db_1_0_0_ ) );
if ( remainder_outdb > 0 )
{
@@ -385,7 +385,7 @@ namespace sgns
{
m_logger->debug( "Commiting migrating to topics {}", topic );
}
- OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
crdt_transaction_ = db_1_0_0_->BeginTransaction();
topics_.clear();
topics_.emplace( std::string( TransactionManager::GNUS_FULL_NODES_TOPIC ) );
@@ -393,7 +393,7 @@ namespace sgns
}
m_logger->debug( "Migrating input DB into new DB" );
- OUTCOME_TRY( auto &&remainder_indb, MigrateDb( db_0_0_2_in_, db_1_0_0_ ) );
+ BOOST_OUTCOME_TRY( auto remainder_indb, MigrateDb( db_0_0_2_in_, db_1_0_0_ ) );
if ( remainder_indb > 0 )
{
@@ -401,14 +401,14 @@ namespace sgns
{
m_logger->debug( "Commiting migrating to topics {}", topic );
}
- OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
}
sgns::crdt::GlobalDB::Buffer version_buffer;
sgns::crdt::GlobalDB::Buffer version_key;
version_key.put( std::string( MigrationManager::VERSION_INFO_KEY ) );
version_buffer.put( ToVersion() );
- OUTCOME_TRY( db_1_0_0_->GetDataStore()->put( version_key, version_buffer ) );
+ BOOST_OUTCOME_TRY( db_1_0_0_->GetDataStore()->put( version_key, version_buffer ) );
m_logger->debug( "Apply step of Migration0_2_0To1_0_0 finished successfully" );
diff --git a/src/account/Migration0_2_0To1_0_0.hpp b/src/account/Migration0_2_0To1_0_0.hpp
index 1ad752b6f..bd2ca6704 100644
--- a/src/account/Migration0_2_0To1_0_0.hpp
+++ b/src/account/Migration0_2_0To1_0_0.hpp
@@ -21,7 +21,7 @@
#include "outcome/outcome.hpp"
#include
#include
-#include
+#include
#include "IMigrationStep.hpp"
@@ -48,7 +48,7 @@ namespace sgns
Migration0_2_0To1_0_0( std::shared_ptr ioContext,
std::shared_ptr pubSub,
std::shared_ptr graphsync,
- std::shared_ptr scheduler,
+ std::shared_ptr scheduler,
std::shared_ptr generator,
std::string writeBasePath,
std::string base58key );
@@ -110,7 +110,7 @@ namespace sgns
std::shared_ptr ioContext_; ///< IO context for DB I/O.
std::shared_ptr pubSub_; ///< PubSub instance for legacy DB.
std::shared_ptr graphsync_; ///< GraphSync network.
- std::shared_ptr scheduler_; ///< libp2p scheduler.
+ std::shared_ptr scheduler_; ///< libp2p scheduler.
std::shared_ptr generator_; ///< Request ID generator.
std::shared_ptr crdt_transaction_; ///< CRDT transaction to make it all atomic
std::string writeBasePath_; ///< Base path for writing DB files.
diff --git a/src/account/Migration1_0_0To3_4_0.cpp b/src/account/Migration1_0_0To3_4_0.cpp
index 97ac60e0b..00e196172 100644
--- a/src/account/Migration1_0_0To3_4_0.cpp
+++ b/src/account/Migration1_0_0To3_4_0.cpp
@@ -1,6 +1,6 @@
/**
* @file Migration1_0_0To3_4_0.cpp
- * @brief
+ * @brief
* @date 2025-10-03
* @author Henrique A. Klein (hklein@gnus.ai)
*/
@@ -23,7 +23,7 @@ namespace sgns
std::shared_ptr ioContext,
std::shared_ptr pubSub,
std::shared_ptr graphsync,
- std::shared_ptr scheduler,
+ std::shared_ptr scheduler,
std::shared_ptr generator,
std::string writeBasePath,
std::string base58key ) :
@@ -84,11 +84,11 @@ namespace sgns
outcome::result Migration1_0_0To3_4_0::Init()
{
- OUTCOME_TRY( auto &&legacy_db, InitLegacyDb() );
+ BOOST_OUTCOME_TRY( auto legacy_db, InitLegacyDb() );
db_1_0_0_ = std::move( legacy_db );
if ( db_1_0_0_ )
{
- OUTCOME_TRY( auto &&new_db, InitTargetDb() );
+ BOOST_OUTCOME_TRY( auto new_db, InitTargetDb() );
db_3_4_0_ = std::move( new_db );
}
return outcome::success();
@@ -109,7 +109,7 @@ namespace sgns
topics_.emplace( std::string( TransactionManager::GNUS_FULL_NODES_TOPIC ) );
const std::string BASE = "/bc-963/";
- OUTCOME_TRY( auto &&entries, db_1_0_0_->QueryKeyValues( BASE, "*", "/tx" ) );
+ BOOST_OUTCOME_TRY( auto entries, db_1_0_0_->QueryKeyValues( BASE, "*", "/tx" ) );
logger_->debug( "Found {} transaction keys to migrate", entries.size() );
size_t migrated_count = 0;
size_t BATCH_SIZE = 50;
@@ -163,7 +163,7 @@ namespace sgns
sgns::crdt::GlobalDB::Buffer data_transaction;
data_transaction.put( tx->SerializeByteVector() );
- BOOST_OUTCOME_TRYV2( auto &&, crdt_transaction_->Put( transaction_key, std::move( data_transaction ) ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Put( transaction_key, std::move( data_transaction ) ) );
sgns::crdt::HierarchicalKey proof_crdt_key( BASE + BuildLegacyProofPath_1_0_0( *tx ) );
sgns::crdt::GlobalDB::Buffer proof_transaction;
@@ -176,7 +176,7 @@ namespace sgns
++migrated_count;
if ( migrated_count >= BATCH_SIZE )
{
- OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
crdt_transaction_ = db_3_4_0_->BeginTransaction(); // start fresh
topics_.clear();
@@ -187,7 +187,7 @@ namespace sgns
}
if ( migrated_count )
{
- OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
+ BOOST_OUTCOME_TRY( crdt_transaction_->Commit( topics_ ) );
logger_->debug( "Committed remaining {} transactions", migrated_count );
}
@@ -196,7 +196,7 @@ namespace sgns
version_key.put( std::string( MigrationManager::VERSION_INFO_KEY ) );
version_buffer.put( ToVersion() );
- OUTCOME_TRY( db_3_4_0_->GetDataStore()->put( version_key, version_buffer ) );
+ BOOST_OUTCOME_TRY( db_3_4_0_->GetDataStore()->put( version_key, version_buffer ) );
logger_->debug( "Migration from {} to {} completed successfully", FromVersion(), ToVersion() );
return outcome::success();
diff --git a/src/account/Migration1_0_0To3_4_0.hpp b/src/account/Migration1_0_0To3_4_0.hpp
index 79d63e989..ed5b83932 100644
--- a/src/account/Migration1_0_0To3_4_0.hpp
+++ b/src/account/Migration1_0_0To3_4_0.hpp
@@ -18,7 +18,7 @@ namespace sgns
{
/**
* @brief Migration step for version 1.0.0 to 3.4.0.
- * Changes the full node topic from CRDT heads
+ * Changes the full node topic from CRDT heads
*/
class Migration1_0_0To3_4_0 : public IMigrationStep
{
@@ -26,7 +26,7 @@ namespace sgns
Migration1_0_0To3_4_0( std::shared_ptr ioContext,
std::shared_ptr pubSub,
std::shared_ptr graphsync,
- std::shared_ptr scheduler,
+ std::shared_ptr scheduler,
std::shared_ptr generator,
std::string writeBasePath,
std::string base58key );
@@ -70,7 +70,7 @@ namespace sgns
std::shared_ptr ioContext_; ///< IO context for DB I/O.
std::shared_ptr pubSub_; ///< PubSub instance for legacy DB.
std::shared_ptr graphsync_; ///< GraphSync network.
- std::shared_ptr scheduler_; ///< libp2p scheduler.
+ std::shared_ptr scheduler_; ///< libp2p scheduler.
std::shared_ptr generator_; ///< Request ID generator.
std::string writeBasePath_; ///< Base path for writing DB files.
std::string base58key_; ///< Key to build legacy paths.
diff --git a/src/account/Migration3_4_0To3_5_0.cpp b/src/account/Migration3_4_0To3_5_0.cpp
index 8f3835766..d7ad9f863 100644
--- a/src/account/Migration3_4_0To3_5_0.cpp
+++ b/src/account/Migration3_4_0To3_5_0.cpp
@@ -1,6 +1,6 @@
/**
* @file Migration3_4_0To3_5_0.cpp
- * @brief
+ * @brief
* @date 2025-11-14
* @author Henrique A. Klein (hklein@gnus.ai)
*/
@@ -31,7 +31,7 @@ namespace sgns
std::shared_ptr ioContext,
std::shared_ptr pubSub,
std::shared_ptr