diff --git a/README.md b/README.md index 1cca043..9edbbd0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flake.nix b/flake.nix index 5980c94..0c98fd7 100644 --- a/flake.nix +++ b/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 diff --git a/metadata.json b/metadata.json index c289112..db97108 100644 --- a/metadata.json +++ b/metadata.json @@ -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": { diff --git a/src/logos_blockchain_module.cpp b/src/logos_blockchain_module.cpp index e6b9bf0..57ef34e 100644 --- a/src/logos_blockchain_module.cpp +++ b/src/logos_blockchain_module.cpp @@ -6,12 +6,10 @@ #include #include #include -#include #include #include #include -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()) { diff --git a/tests/test_blockchain.cpp b/tests/test_blockchain.cpp index 961d19c..6668a8e 100644 --- a/tests/test_blockchain.cpp +++ b/tests/test_blockchain.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -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);