mirror of
https://github.com/logos-blockchain/logos-blockchain-module.git
synced 2026-07-14 02:59:52 +00:00
Remove circuits directory setup
This commit is contained in:
parent
4c8df12492
commit
00d2b35715
@ -1,6 +1,6 @@
|
||||
# Logos Blockchain Module
|
||||
|
||||
A Logos core module that wraps the [logos-blockchain](https://github.com/logos-blockchain/logos-blockchain) C bindings and ships the zk circuit binaries needed at runtime.
|
||||
A Logos core module that wraps the [logos-blockchain](https://github.com/logos-blockchain/logos-blockchain) C bindings.
|
||||
|
||||
### Build and inspect
|
||||
|
||||
|
||||
28
flake.nix
28
flake.nix
@ -22,35 +22,7 @@
|
||||
mockCLibs = [ "logos_blockchain" ];
|
||||
};
|
||||
|
||||
preConfigure = { externalLibs }:
|
||||
if externalLibs ? logos_blockchain then ''
|
||||
if [ -d "${externalLibs.logos_blockchain}/circuits" ]; then
|
||||
echo "Staging zk circuits from logos-blockchain..."
|
||||
cp -r "${externalLibs.logos_blockchain}/circuits" ./circuits
|
||||
chmod -R u+w ./circuits
|
||||
else
|
||||
echo "WARNING: no circuits/ found in logos-blockchain derivation"
|
||||
fi
|
||||
'' else ''
|
||||
echo "Skipping zk circuits staging (logos_blockchain mocked for tests)"
|
||||
'';
|
||||
|
||||
# Logos Core Edge-case
|
||||
# The current version of Logos Core expects circuits' binaries under `lib/circuits/`.
|
||||
# Until we address this in Logos Core, we use this hook to include to ensure the circuits' binaries
|
||||
# are included in the binary bundle and avoid the circuits being mangled by Nix (which did that when
|
||||
# copying them in a previous phase).
|
||||
postInstall = ''
|
||||
if [ -d "$LOGOS_MODULE_SOURCE_DIR/circuits" ]; then
|
||||
cp -r "$LOGOS_MODULE_SOURCE_DIR/circuits" "$out/lib/circuits"
|
||||
chmod -R u+w "$out/lib/circuits"
|
||||
|
||||
if [ -f "$out/lib/circuits/lib/libgmp.a" ]; then
|
||||
echo "Removing loose static library libgmp.a from staged circuits..."
|
||||
rm "$out/lib/circuits/lib/libgmp.a"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove nix references to make the module portable.
|
||||
find "$out" -type f | while read -r binary; do
|
||||
if file "$binary" | grep -E -q "Mach-O|shared library|executable|archive"; then
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
"liblogos_blockchain.dll",
|
||||
"liblogos_blockchain_module_plugin.dylib",
|
||||
"liblogos_blockchain_module_plugin.so",
|
||||
"liblogos_blockchain_module_plugin.dll",
|
||||
"circuits"
|
||||
"liblogos_blockchain_module_plugin.dll"
|
||||
],
|
||||
|
||||
"nix": {
|
||||
|
||||
@ -6,12 +6,10 @@
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using json = nlohmann::json;
|
||||
|
||||
// Define static member
|
||||
@ -224,37 +222,6 @@ namespace {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace environment {
|
||||
constexpr auto LOGOS_BLOCKCHAIN_CIRCUITS = "LOGOS_BLOCKCHAIN_CIRCUITS";
|
||||
|
||||
bool is_circuits_path_valid(const std::string& path) {
|
||||
std::error_code ec;
|
||||
if (!fs::is_directory(path, ec))
|
||||
return false;
|
||||
for (const auto& entry : fs::directory_iterator(path, ec)) { // NOLINT(*-use-anyofallof)
|
||||
if (entry.is_regular_file())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup_circuits_path(const std::string& module_path) {
|
||||
const fs::path circuits_path = fs::path(module_path) / "circuits";
|
||||
const std::string circuits_str = circuits_path.string();
|
||||
|
||||
if (!is_circuits_path_valid(circuits_str)) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"FATAL: The LOGOS_BLOCKCHAIN_CIRCUITS environment variable is not set or does not contain any files.\n"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
setenv("LOGOS_BLOCKCHAIN_CIRCUITS", circuits_str.c_str(), 1);
|
||||
fprintf(stderr, "LOGOS_BLOCKCHAIN_CIRCUITS set to: %s\n", circuits_str.c_str());
|
||||
}
|
||||
} // namespace environment
|
||||
|
||||
void LogosBlockchainModule::on_new_block_callback(const char* block) {
|
||||
if (s_instance) {
|
||||
fprintf(stderr, "Received new block: %s\n", block);
|
||||
@ -308,13 +275,6 @@ StdLogosResult LogosBlockchainModule::start(const std::string& config_path, cons
|
||||
return result::err("The node is already running.");
|
||||
}
|
||||
|
||||
const char* module_path_env = std::getenv("LOGOS_MODULE_PATH");
|
||||
if (module_path_env && *module_path_env) {
|
||||
environment::setup_circuits_path(module_path_env);
|
||||
} else {
|
||||
fprintf(stderr, "Warning: LOGOS_MODULE_PATH not set, skipping circuits' path setup.\n");
|
||||
}
|
||||
|
||||
std::string effective_config_path = config_path;
|
||||
|
||||
if (effective_config_path.empty()) {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
@ -40,16 +39,7 @@ struct TempDir {
|
||||
};
|
||||
|
||||
// Helper: create a module with a running (mocked) node.
|
||||
// Sets up circuits directory, LOGOS_MODULE_PATH env, and calls start().
|
||||
static LogosBlockchainModule* createStartedModule(LogosTestContext& t, TempDir& tmpDir) {
|
||||
fs::create_directories(tmpDir.path / "circuits");
|
||||
{
|
||||
std::ofstream f((tmpDir.path / "circuits" / "dummy.bin").string());
|
||||
f << "x";
|
||||
}
|
||||
|
||||
setenv("LOGOS_MODULE_PATH", tmpDir.path.string().c_str(), 1);
|
||||
|
||||
auto* module = new LogosBlockchainModule();
|
||||
|
||||
t.mockCFunction("start_lb_node").returns(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user