diff --git a/flake.lock b/flake.lock index 81272c25..ad4683c9 100644 --- a/flake.lock +++ b/flake.lock @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779102034, - "narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=", + "lastModified": 1780453794, + "narHash": "sha256-bXMRa9VTsHSPXL4Cw8R6JJLQeY3Y/IP4+YJCYVmQ7FY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "687f05a9184cad4eaf905c48b63649e3a86f5433", + "rev": "6b316287bae2ee04c9b93c8c858d930fd07d7338", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.11", + "ref": "nixos-26.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index a78937e3..e0ddedcc 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "BlockSci analysis tool for blockchains"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -12,20 +12,14 @@ nixpkgs, flake-utils, }: - flake-utils.lib.eachSystem [ "x86_64-linux" ] ( + flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; overlays = [ (final: prev: { - libjson-rpc-cpp = prev.libjson-rpc-cpp.overrideAttrs (old: { - postPatch = (old.postPatch or "") + '' - substituteInPlace CMakeLists.txt \ - --replace-fail 'option(WITH_COVERAGE "Build with code coverage flags" ON)' \ - 'option(WITH_COVERAGE "Build with code coverage flags" OFF)' - ''; - }); + libjson-rpc-cpp = final.callPackage ./nix/libjson-rpc-cpp.nix {}; }) ]; }; @@ -162,8 +156,17 @@ export PATH="$LOCAL_PIP/bin:$PATH" export CMAKE_PREFIX_PATH="$PWD/.nix-install:$CMAKE_PREFIX_PATH" - export LD_LIBRARY_PATH="$PWD/.nix-install/lib64:$LD_LIBRARY_PATH" - ''; + '' + + ( + if pkgs.stdenv.isDarwin then + '' + export DYLD_LIBRARY_PATH="$PWD/.nix-install/lib:$DYLD_LIBRARY_PATH" + '' + else + '' + export LD_LIBRARY_PATH="$PWD/.nix-install/lib64:$LD_LIBRARY_PATH" + '' + ); }; packages.bitcoin-api-cpp = pkgs.stdenv.mkDerivation { @@ -180,6 +183,11 @@ nativeBuildInputs = with pkgs; [ cmake ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail "set(CMAKE_CXX_STANDARD 14)" "set(CMAKE_CXX_STANDARD 17)" + ''; buildInputs = with pkgs; [ curl diff --git a/nix/libjson-rpc-cpp.nix b/nix/libjson-rpc-cpp.nix new file mode 100644 index 00000000..298f39af --- /dev/null +++ b/nix/libjson-rpc-cpp.nix @@ -0,0 +1,130 @@ +{ + lib, + stdenv, + fetchFromGitHub, + pkg-config, + cmake, + argtable, + catch2, + curl, + doxygen, + hiredis, + jsoncpp, + libmicrohttpd, + patchelf, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "libjson-rpc-cpp"; + version = "1.4.1"; + + src = fetchFromGitHub { + owner = "cinemast"; + repo = "libjson-rpc-cpp"; + sha256 = "sha256-YCCZN4y88AixQeo24pk6YHfSCsJz8jJ97Dg40KM08cQ="; + rev = "v${finalAttrs.version}"; + }; + + env.NIX_CFLAGS_COMPILE = "-I${catch2}/include/catch2"; + + nativeBuildInputs = [ + pkg-config + cmake + doxygen + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + patchelf + ]; + + buildInputs = [ + argtable + catch2 + curl + hiredis + jsoncpp + libmicrohttpd + ]; + + postPatch = '' + for f in cmake/FindArgtable.cmake \ + src/stubgenerator/stubgenerator.cpp \ + src/stubgenerator/stubgeneratorfactory.cpp + do + sed -i -re 's/argtable2/argtable3/g' $f + done + + sed -i -re 's#MATCHES "jsoncpp"#MATCHES ".*/jsoncpp/json$"#g' cmake/FindJsoncpp.cmake + + substituteInPlace CMakeLists.txt \ + --replace-fail "cmake_minimum_required(VERSION 3.0)" "cmake_minimum_required(VERSION 3.10)" \ + --replace-fail "cmake_policy(SET CMP0042 OLD)" "" + + # jsoncpp 1.9.7 dropped char const*/String const& overloads in favor of std::string_view. + substituteInPlace cmake/CMakeCompilerSettings.cmake \ + --replace-fail "-std=c++11" "-std=c++17" + ''; + + preConfigure = '' + mkdir -p Build/Install + pushd Build + ''; + + # this hack is needed because the cmake scripts + # require write permission to absolute paths + configurePhase = '' + runHook preConfigure + cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/Install \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_COVERAGE=OFF \ + ${lib.optionalString stdenv.hostPlatform.isDarwin "-DCMAKE_INSTALL_NAME_DIR=$out/lib -DCMAKE_INSTALL_RPATH=$out/lib"} + runHook postConfigure + ''; + + preInstall = + lib.optionalString stdenv.hostPlatform.isLinux '' + function fixRunPath { + p=$(patchelf --print-rpath $1) + q="$p:${ + lib.makeLibraryPath [ + jsoncpp + argtable + libmicrohttpd + curl + ] + }:$out/lib" + patchelf --set-rpath $q $1 + } + '' + + '' + mkdir -p $out + ''; + + postInstall = '' + sed -i -re "s#-([LI]).*/Build/Install(.*)#-\1$out\2#g" Install/lib*/pkgconfig/*.pc + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + for f in Install/lib*/*.so* $(find Install/bin -executable -type f); do + fixRunPath $f + done + '' + + '' + cp -r Install/* $out + ''; + + installPhase = '' + runHook preInstall + make install + runHook postInstall + ''; + + meta = { + description = "C++ framework for json-rpc (json remote procedure call)"; + mainProgram = "jsonrpcstub"; + homepage = "https://github.com/cinemast/libjson-rpc-cpp"; + license = lib.licenses.mit; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; + maintainers = with lib.maintainers; [ robertrichter ]; + }; +}) diff --git a/tools/parser/address_state.hpp b/tools/parser/address_state.hpp index 461855b5..d0c8baec 100644 --- a/tools/parser/address_state.hpp +++ b/tools/parser/address_state.hpp @@ -36,10 +36,10 @@ template struct NonDudupAddressInfo { uint32_t addressNum; }; -template constexpr int startingCount = 0; -template <> constexpr int startingCount = 600'000'000; -template <> constexpr int startingCount = 100'000'000; -template <> constexpr int startingCount = 100'000'000; +template inline constexpr int startingCount = 0; +template <> inline constexpr int startingCount = 600'000'000; +template <> inline constexpr int startingCount = 100'000'000; +template <> inline constexpr int startingCount = 100'000'000; class AddressState { static constexpr auto AddressFalsePositiveRate = .05; diff --git a/tools/parser/block_processor.cpp b/tools/parser/block_processor.cpp index 188f05f2..0a15cf37 100644 --- a/tools/parser/block_processor.cpp +++ b/tools/parser/block_processor.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/tools/parser/chain_index.cpp b/tools/parser/chain_index.cpp index d20250e3..f387e125 100644 --- a/tools/parser/chain_index.cpp +++ b/tools/parser/chain_index.cpp @@ -19,7 +19,6 @@ #include #include -#include #include