Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};

Expand All @@ -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 {};
})
];
};
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
130 changes: 130 additions & 0 deletions nix/libjson-rpc-cpp.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
})
8 changes: 4 additions & 4 deletions tools/parser/address_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ template <blocksci::AddressType::Enum type> struct NonDudupAddressInfo {
uint32_t addressNum;
};

template <blocksci::DedupAddressType::Enum> constexpr int startingCount = 0;
template <> constexpr int startingCount<blocksci::DedupAddressType::PUBKEY> = 600'000'000;
template <> constexpr int startingCount<blocksci::DedupAddressType::SCRIPTHASH> = 100'000'000;
template <> constexpr int startingCount<blocksci::DedupAddressType::MULTISIG> = 100'000'000;
template <blocksci::DedupAddressType::Enum> inline constexpr int startingCount = 0;
template <> inline constexpr int startingCount<blocksci::DedupAddressType::PUBKEY> = 600'000'000;
template <> inline constexpr int startingCount<blocksci::DedupAddressType::SCRIPTHASH> = 100'000'000;
template <> inline constexpr int startingCount<blocksci::DedupAddressType::MULTISIG> = 100'000'000;

class AddressState {
static constexpr auto AddressFalsePositiveRate = .05;
Expand Down
1 change: 0 additions & 1 deletion tools/parser/block_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <blocksci/core/raw_block.hpp>
#include <blocksci/core/typedefs.hpp>

#include <bits/chrono.h>
#include <boost/lockfree/policies.hpp>
#include <mio/mmap.hpp>

Expand Down
1 change: 0 additions & 1 deletion tools/parser/chain_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <blocksci/core/typedefs.hpp>

#include <bitcoinapi/exception.h>
#include <bits/chrono.h>

#include <tuple>

Expand Down