Skip to content

Commit

Permalink
Merge pull request #1662 from darcys22/follow-smart-contract
Browse files Browse the repository at this point in the history
Follow smart contract
  • Loading branch information
darcys22 committed May 8, 2024
2 parents 7bda65c + 51a5c50 commit a67822f
Show file tree
Hide file tree
Showing 89 changed files with 5,373 additions and 319 deletions.
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
[submodule "external/date"]
path = external/date
url = https://github.com/HowardHinnant/date.git
[submodule "external/oxen-encoding"]
path = external/oxen-encoding
url = https://github.com/oxen-io/oxen-encoding.git
[submodule "external/oxen-logging"]
path = external/oxen-logging
url = https://github.com/oxen-io/oxen-logging
Expand All @@ -47,3 +44,9 @@
path = external/pybind11
url = https://github.com/pybind/pybind11
branch = stable
[submodule "external/ethyl"]
path = external/ethyl
url = https://github.com/oxen-io/ethyl.git
[submodule "external/bls"]
path = external/bls
url = https://github.com/herumi/bls.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ if(NOT MANUAL_SUBMODULES)
check_submodule(external/rapidjson)
check_submodule(external/trezor-common)
check_submodule(external/randomx)
check_submodule(external/oxen-mq cppzmq)
check_submodule(external/oxen-mq cppzmq oxen-encoding)
check_submodule(external/SQLiteCpp)
if(BUILD_TESTS)
check_submodule(external/googletest)
Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,28 @@ sources are also used for statically-linked builds because distribution
packages often include only shared library binaries (`.so`) but not static
library archives (`.a`).

| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Fedora | Optional | Purpose |
| ------------ | ------------- | -------- | ---------------------- | ------------ | ------------------- | -------- | ---------------- |
| GCC | 8.1.0 | NO | `g++`[1] | `base-devel` | `gcc` | NO | |
| CMake | 3.13 | NO | `cmake` | `cmake` | `cmake` | NO | |
| pkg-config | any | NO | `pkg-config` | `base-devel` | `pkgconf` | NO | |
| Boost | 1.65 | NO | `libboost-all-dev`[2] | `boost` | `boost-devel` | NO | C++ libraries |
| libzmq | 4.3.0 | YES | `libzmq3-dev` | `zeromq` | `zeromq-devel` | NO | ZeroMQ library |
| sqlite3 | 3.24.0 | YES | `libsqlite3-dev` | `sqlite` | `sqlite-devel` | NO | ONS, batching |
| libsodium | 1.0.9 | YES | `libsodium-dev` | `libsodium` | `libsodium-devel` | NO | cryptography |
| libcurl | 4.0 | NO | `libcurl4-dev` | `curl` | `curl-devel` | NO | HTTP RPC |
| libuv (Win) | any | NO | (Windows only) | -- | -- | NO | RPC event loop |
| libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | YES | Stack traces |
| liblzma | any | NO | `liblzma-dev` | `xz` | `xz-devel` | YES | For libunwind |
| libreadline | 6.3.0 | NO | `libreadline-dev` | `readline` | `readline-devel` | YES | Input editing |
| Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | YES | Documentation |
| Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | YES | Documentation |
| Qt tools | 5.x | NO | `qttools5-dev` | `qt5-tools` | `qt5-linguist` | YES | Translations |
| libhidapi | ? | NO | `libhidapi-dev` | `hidapi` | `hidapi-devel` | YES | Hardware wallet |
| libusb | ? | NO | `libusb-dev` | `libusb` | `libusb-devel` | YES | Hardware wallet |
| libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | YES | Hardware wallet |
| protoc | ? | NO | `protobuf-compiler` | `protobuf` | `protobuf-compiler` | YES | Hardware wallet |
| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Fedora | Optional | Purpose |
| ------------ | ------------- | -------- | ---------------------- | ------------ | ------------------- | -------- | ---------------- |
| GCC | 8.1.0 | NO | `g++`[1] | `base-devel` | `gcc` | NO | |
| CMake | 3.13 | NO | `cmake` | `cmake` | `cmake` | NO | |
| pkg-config | any | NO | `pkg-config` | `base-devel` | `pkgconf` | NO | |
| Boost | 1.65 | NO | `libboost-all-dev`[2] | `boost` | `boost-devel` | NO | C++ libraries |
| libzmq | 4.3.0 | YES | `libzmq3-dev` | `zeromq` | `zeromq-devel` | NO | ZeroMQ library |
| sqlite3 | 3.24.0 | YES | `libsqlite3-dev` | `sqlite` | `sqlite-devel` | NO | ONS, batching |
| libsodium | 1.0.9 | YES | `libsodium-dev` | `libsodium` | `libsodium-devel` | NO | cryptography |
| libcurl | 4.0 | NO | `libcurl4-dev` | `curl` | `curl-devel` | NO | HTTP RPC |
| libuv (Win) | any | NO | (Windows only) | -- | -- | NO | RPC event loop |
| libgmp | any | NO | `libgmp-dev` | -- | -- | NO | BLS precision math |
| libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | YES | Stack traces |
| liblzma | any | NO | `liblzma-dev` | `xz` | `xz-devel` | YES | For libunwind |
| libreadline | 6.3.0 | NO | `libreadline-dev` | `readline` | `readline-devel` | YES | Input editing |
| Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | YES | Documentation |
| Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | YES | Documentation |
| Qt tools | 5.x | NO | `qttools5-dev` | `qt5-tools` | `qt5-linguist` | YES | Translations |
| libhidapi | ? | NO | `libhidapi-dev` | `hidapi` | `hidapi-devel` | YES | Hardware wallet |
| libusb | ? | NO | `libusb-dev` | `libusb` | `libusb-devel` | YES | Hardware wallet |
| libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | YES | Hardware wallet |
| protoc | ? | NO | `protobuf-compiler` | `protobuf` | `protobuf-compiler` | YES | Hardware wallet |


[1] On Ubuntu Bionic you will need the g++-8 package instead of g++ (which is version 7) and will
Expand Down
2 changes: 1 addition & 1 deletion cmake/StaticBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ set(ZMQ_HASH SHA512=e198ef9f82d392754caadd547537666d4fba0afd7d027749b3adae450516
CACHE STRING "libzmq source hash")

set(ZLIB_VERSION 1.2.13 CACHE STRING "zlib version")
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://zlib.net
set(ZLIB_MIRROR ${LOCAL_MIRROR} https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}
CACHE STRING "zlib mirror(s)")
set(ZLIB_SOURCE zlib-${ZLIB_VERSION}.tar.xz)
set(ZLIB_HASH SHA256=d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98
Expand Down
22 changes: 22 additions & 0 deletions cmake/system_or_submodule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

macro(system_or_submodule BIGNAME smallname pkgconf subdir)
option(FORCE_${BIGNAME}_SUBMODULE "force using ${smallname} submodule" OFF)
if(NOT BUILD_STATIC_DEPS AND NOT FORCE_${BIGNAME}_SUBMODULE AND NOT FORCE_ALL_SUBMODULES)
pkg_check_modules(${BIGNAME} ${pkgconf} IMPORTED_TARGET)
endif()
if(${BIGNAME}_FOUND)
add_library(${smallname} INTERFACE)
if(NOT TARGET PkgConfig::${BIGNAME} AND CMAKE_VERSION VERSION_LESS "3.21")
# Work around cmake bug 22180 (PkgConfig::THING not set if no flags needed)
else()
target_link_libraries(${smallname} INTERFACE PkgConfig::${BIGNAME})
endif()
message(STATUS "Found system ${smallname} ${${BIGNAME}_VERSION}")
else()
message(STATUS "using ${smallname} submodule")
add_subdirectory(${subdir} EXCLUDE_FROM_ALL)
endif()
if(NOT TARGET ${smallname}::${smallname})
add_library(${smallname}::${smallname} ALIAS ${smallname})
endif()
endmacro()
1 change: 1 addition & 0 deletions contrib/epee/include/epee/storages/parserse_base_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <string>
#include <string_view>
#include <cstdint>

namespace epee::misc_utils::parse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace epee
}
//-----------------------------------------------------------------------------------------------------------
template<class t_struct>
bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, size_t indent = 0)
bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, [[maybe_unused]]size_t indent = 0)
{
portable_storage ps;
str_in.store(ps);
Expand Down
5 changes: 5 additions & 0 deletions contrib/epee/src/memwipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#endif
#include "epee/memwipe.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"

#if defined(_MSC_VER)
#define SCARECROW \
__asm;
Expand Down Expand Up @@ -112,4 +115,6 @@ void *memwipe(void *ptr, size_t n)
return ptr;
}

#pragma GCC diagnostic pop

#endif
31 changes: 9 additions & 22 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,18 @@ if(NOT STATIC AND NOT BUILD_STATIC_DEPS)
find_package(PkgConfig REQUIRED)
endif()

macro(system_or_submodule BIGNAME smallname pkgconf subdir)
option(FORCE_${BIGNAME}_SUBMODULE "force using ${smallname} submodule" OFF)
if(NOT STATIC AND NOT FORCE_${BIGNAME}_SUBMODULE)
pkg_check_modules(${BIGNAME} ${pkgconf} IMPORTED_TARGET)
endif()
if(${BIGNAME}_FOUND)
add_library(${smallname} INTERFACE)
if(NOT TARGET PkgConfig::${BIGNAME} AND CMAKE_VERSION VERSION_LESS "3.21")
# Work around cmake bug 22180 (PkgConfig::THING not set if no flags needed)
else()
target_link_libraries(${smallname} INTERFACE PkgConfig::${BIGNAME})
endif()
message(STATUS "Found system ${smallname} ${${BIGNAME}_VERSION}")
else()
message(STATUS "using ${smallname} submodule")
add_subdirectory(${subdir})
endif()
if(NOT TARGET ${smallname}::${smallname})
add_library(${smallname}::${smallname} ALIAS ${smallname})
endif()
endmacro()
include(system_or_submodule)

system_or_submodule(OXENC oxenc liboxenc>=1.0.3 oxen-encoding)
system_or_submodule(OXENMQ oxenmq liboxenmq>=1.2.13 oxen-mq)
system_or_submodule(OXENC oxenc liboxenc>=1.0.3 oxen-mq/oxen-encoding)

add_subdirectory(db_drivers)
add_subdirectory(randomx EXCLUDE_FROM_ALL)
add_subdirectory(date EXCLUDE_FROM_ALL)

set(BLS_ETH ON CACHE BOOL "" FORCE)
add_subdirectory(bls)

set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_MultipleHeaders ON CACHE BOOL "") # Allows multi-header nlohmann use
add_subdirectory(nlohmann-json EXCLUDE_FROM_ALL)
Expand Down Expand Up @@ -175,3 +158,7 @@ if(BUILD_PYBIND)
add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
endif()


set(ethyl_ENABLE_CRYPTO_LIBRARY FALSE CACHE BOOL "" FORCE)
add_subdirectory(ethyl)

1 change: 1 addition & 0 deletions external/bls
Submodule bls added at c6fb52
1 change: 1 addition & 0 deletions external/ethyl
Submodule ethyl added at bb3fbf
1 change: 0 additions & 1 deletion external/oxen-encoding
Submodule oxen-encoding deleted from f6c516
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

# warnings are cleared only for GCC on Linux
if (NOT (MINGW OR APPLE OR FREEBSD OR OPENBSD OR DRAGONFLY))
add_compile_options("${WARNINGS_AS_ERRORS_FLAG}") # applies only to targets that follow
message(STATUS "Setting warnings as errors")
#add_compile_options("${WARNINGS_AS_ERRORS_FLAG}") # applies only to targets that follow
endif()

set_property(GLOBAL PROPERTY oxen_executable_targets "")
Expand All @@ -55,6 +56,8 @@ add_subdirectory(cryptonote_basic)
add_subdirectory(cryptonote_core)
add_subdirectory(logging)
add_subdirectory(lmdb)
add_subdirectory(l2_tracker)
add_subdirectory(bls)
add_subdirectory(multisig)
add_subdirectory(net)
add_subdirectory(mnemonics)
Expand Down
1 change: 1 addition & 0 deletions src/blockchain_db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ target_link_libraries(blockchain_db
filesystem
Boost::thread
logging
ethyl
extra)

target_compile_definitions(blockchain_db PRIVATE
Expand Down
7 changes: 6 additions & 1 deletion src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void throw0(const T& e) {

template <typename T>
void throw1(const T& e) {
log::info(logcat, e.what());
log::error(logcat, e.what());
throw e;
}

Expand Down Expand Up @@ -1985,6 +1985,9 @@ void BlockchainLMDB::unlock() {
void BlockchainLMDB::add_txpool_tx(
const crypto::hash& txid, const std::string& blob, const txpool_tx_meta_t& meta) {
log::trace(logcat, "BlockchainLMDB::{}", __func__);
if (blob.size() == 0)
throw1(DB_ERROR("Attempting to add txpool tx with empty blob"));

check_open();
mdb_txn_cursors* m_cursors = &m_wcursors;

Expand All @@ -2002,6 +2005,8 @@ void BlockchainLMDB::add_txpool_tx(
.c_str()));
}
MDB_val_sized(blob_val, blob);
if (blob_val.mv_size == 0)
throw1(DB_ERROR("Error adding txpool tx blob: tx is present, but data is empty"));
if (auto result = mdb_cursor_put(m_cur_txpool_blob, &k, &blob_val, MDB_NODUPDATA)) {
if (result == MDB_KEYEXIST)
throw1(DB_ERROR("Attempting to add txpool tx blob that's already in the db"));
Expand Down
Loading

0 comments on commit a67822f

Please sign in to comment.