From 84249520eb6ded533696e63d9a73dd1406750e88 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Wed, 7 Oct 2026 17:01:47 +0200 Subject: [PATCH 1/5] tests: fix two stale csnode tests so nodetests builds again The nodetests target no longer compiled, so none of the csnode unit tests could run. Test-only change: production code is untouched. - conveyer_tests: PoolMetaInfo gained a `reward` field after `timestamp`, so the aggregate initializer was shifted by one. Pass an empty reward; applyCharacteristic adds the reward user field only when it is non-empty, so expectations are unchanged. - poolsynchronizer_tests: PoolSynchronizer::neighbours() was removed in 3ed6b98b (new synchronization algorithm). Neighbours are now a private unordered_map, so the "sorted by sequence" invariant no longer exists. Drop the helper and its assertion from the already DISABLED test, with a comment explaining why. Result with ENABLE_TESTS=ON (GCC 13, Boost 1.83 static): nodetests 110/110, lmdbxxtests 13/13 and lib_system 49/49 pass. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/csnode/conveyer_tests.cpp | 2 +- tests/csnode/poolsynchronizer_tests.cpp | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/tests/csnode/conveyer_tests.cpp b/tests/csnode/conveyer_tests.cpp index 4e0adfc5f..0d3582123 100644 --- a/tests/csnode/conveyer_tests.cpp +++ b/tests/csnode/conveyer_tests.cpp @@ -251,7 +251,7 @@ TEST(Conveyer, MainLogic) { csdb::PoolHash ph; cs::Bytes tmpCharacteristic; - cs::PoolMetaInfo poolMetaInfo{ { tmpCharacteristic }, "1542617459297", ph, kRoundNumber, cs::Bytes{}, std::vector{}}; + cs::PoolMetaInfo poolMetaInfo{ { tmpCharacteristic }, "1542617459297", std::string{}, ph, kRoundNumber, cs::Bytes{}, std::vector{}}; auto pool{conveyer.applyCharacteristic(poolMetaInfo)}; diff --git a/tests/csnode/poolsynchronizer_tests.cpp b/tests/csnode/poolsynchronizer_tests.cpp index 491b9547f..3fe3a2806 100644 --- a/tests/csnode/poolsynchronizer_tests.cpp +++ b/tests/csnode/poolsynchronizer_tests.cpp @@ -22,18 +22,6 @@ const csdb::Address startAddress = csdb::Address::from_string("00000000000000000 class PoolSynchronizerTest : public cs::PoolSynchronizer { public: explicit PoolSynchronizerTest(BlockChain* blockchain):PoolSynchronizer(blockchain) {} - - bool isCorrect() const { - auto n = neighbours(); - - for (const auto& e : n) { - std::cout << "Neighbour " << cs::Utils::byteStreamToHex(e.first) << ", " << e.second << std::endl; - } - - return std::is_sorted(std::begin(n), std::end(n), [](const auto& lhs, const auto& rhs) { - return lhs.second > rhs.second; - }); - } }; static std::unique_ptr createPoolSynchronizer() { @@ -73,7 +61,8 @@ TEST(PoolSynchronizer, DISABLED_TestNeighbours) { auto& [key, sequence] = *iter; sequence += sequenceStep; + // neighbours are no longer kept sorted (unordered_map since 3ed6b98b), so only + // check that ping handling does not fail synchronizer->onPingReceived(sequence, key); - ASSERT_TRUE(synchronizer->isCorrect()); } } From 1a4b071ce4c5d18db747e5a1e3073244bd31c4a1 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Wed, 7 Oct 2026 17:03:30 +0200 Subject: [PATCH 2/5] ci: build the node and run tests with GitHub Actions Adds one workflow that builds the node on Linux and runs the unit tests: - on push to master, i.e. when a PR is merged; - on pull requests to master, so a change is checked before merge; - on demand (workflow_dispatch). Nothing outside .github/ changes. Build recipe (same as the one verified locally): - Ubuntu 24.04, GCC 13, Ninja + ccache, Release, ENABLE_TESTS=ON. - Boost 1.83 is built from the verified source tarball as static libs with a static runtime, because the CMake files set Boost_USE_STATIC_RUNTIME, which distro packages do not provide. It is cached between runs. - Submodules are initialised by explicit path: the orphan third-party/rocksdb gitlink (no .gitmodules entry) makes a plain recursive update fail. - CMAKE_CXX_FLAGS "-include cstdint -include cstddef" works around missing includes that GCC 13 exposes in third-party base58 and csnode/bitheap.hpp, without touching the sources. - Tests run with ctest. The node binary is uploaded as an artifact (30 days). Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4f4fe3092 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,105 @@ +name: Build node + +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + BOOST_VERSION: 1.83.0 + BOOST_SHA256: 6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e + BOOST_PREFIX: /home/runner/boost + CCACHE_DIR: /home/runner/.ccache + +jobs: + linux: + name: Linux (GCC, Release) + runs-on: ubuntu-24.04 + timeout-minutes: 180 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + # third-party/rocksdb is a gitlink with no .gitmodules entry, so a plain + # `git submodule update --init --recursive` fails: list the submodules explicitly. + - name: Checkout submodules + run: | + git submodule update --init -- cscrypto p2p \ + third-party/berkeleydb third-party/thrift third-party/thrift-interface-definitions \ + third-party/googletest third-party/lmdb third-party/lmdbxx third-party/nameof + git -C cscrypto submodule update --init + git -C p2p submodule update --init + + - name: Install build tools + run: | + sudo apt-get update -qq + sudo apt-get install -y -qq cmake ninja-build flex bison autoconf automake libtool pkg-config ccache + + # The project links Boost statically with a static runtime (Boost_USE_STATIC_RUNTIME), + # which distro packages do not provide, so Boost is built once and cached. + - name: Cache Boost + id: cache-boost + uses: actions/cache@v4 + with: + path: ${{ env.BOOST_PREFIX }} + key: boost-${{ env.BOOST_VERSION }}-static-rt-ubuntu-24.04-v1 + + - name: Build Boost + if: steps.cache-boost.outputs.cache-hit != 'true' + run: | + v=${BOOST_VERSION//./_} + curl -sSfL -o boost.tar.bz2 "https://archives.boost.io/release/${BOOST_VERSION}/source/boost_${v}.tar.bz2" + echo "${BOOST_SHA256} boost.tar.bz2" | sha256sum -c + tar xjf boost.tar.bz2 + cd "boost_${v}" + ./bootstrap.sh --with-libraries=system,filesystem,program_options,date_time,regex,log,iostreams,thread,serialization,atomic,chrono + ./b2 -j"$(nproc)" -d0 variant=release link=static runtime-link=static threading=multi \ + cxxflags=-fPIC --layout=tagged -sNO_BZIP2=1 -sNO_ZSTD=1 -sNO_LZMA=1 \ + install --prefix="${BOOST_PREFIX}" + + - name: Cache ccache + uses: actions/cache@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-ubuntu-24.04-${{ github.sha }} + restore-keys: ccache-ubuntu-24.04- + + # -include cstdint/cstddef: some sources (third-party base58, csnode/bitheap.hpp) + # rely on headers that GCC 13 no longer includes transitively. + - name: Configure + run: | + cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_TESTS=ON \ + -DBoost_ROOT="${BOOST_PREFIX}" \ + -DBoost_NO_SYSTEM_PATHS=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_FLAGS="-include cstdint -include cstddef" + + - name: Build + run: | + ccache --max-size=2G + cmake --build build -j"$(nproc)" + ccache --show-stats + + - name: Test + working-directory: build + run: ctest --output-on-failure + + - name: Upload node binary + uses: actions/upload-artifact@v4 + with: + name: node-linux-x64-${{ github.sha }} + path: build/client/node + retention-days: 30 From c90996701ce9892fd70abeb1698a7b44a8849fb0 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Wed, 7 Oct 2026 17:20:34 +0200 Subject: [PATCH 3/5] ci: disable Thrift Haskell lib, keep caches on failure, report disk usage First CI run: every node and test target built (365/366). The one failure was Thrift's Haskell library. The ubuntu-24.04 image ships GHC/cabal, so Thrift turns WITH_HASKELL on by itself. The node does not use it, so pass -DWITH_HASKELL=OFF from the workflow; the project's CMake files are unchanged. Also: - Split actions/cache into restore + save, so the Boost and ccache caches are kept even when a later step fails (the post-step save is skipped on failure). - Add a final "Disk usage" step (always runs) that prints free space and the size of the workspace, the build dir, Boost and ccache. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f4fe3092..d3cb04162 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,9 +47,9 @@ jobs: # The project links Boost statically with a static runtime (Boost_USE_STATIC_RUNTIME), # which distro packages do not provide, so Boost is built once and cached. - - name: Cache Boost + - name: Restore Boost id: cache-boost - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: path: ${{ env.BOOST_PREFIX }} key: boost-${{ env.BOOST_VERSION }}-static-rt-ubuntu-24.04-v1 @@ -67,8 +67,16 @@ jobs: cxxflags=-fPIC --layout=tagged -sNO_BZIP2=1 -sNO_ZSTD=1 -sNO_LZMA=1 \ install --prefix="${BOOST_PREFIX}" - - name: Cache ccache - uses: actions/cache@v4 + # Saved right away (not in a post step) so a later failing step does not lose it. + - name: Save Boost + if: steps.cache-boost.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: ${{ env.BOOST_PREFIX }} + key: ${{ steps.cache-boost.outputs.cache-primary-key }} + + - name: Restore ccache + uses: actions/cache/restore@v4 with: path: ${{ env.CCACHE_DIR }} key: ccache-ubuntu-24.04-${{ github.sha }} @@ -76,6 +84,8 @@ jobs: # -include cstdint/cstddef: some sources (third-party base58, csnode/bitheap.hpp) # rely on headers that GCC 13 no longer includes transitively. + # WITH_HASKELL=OFF: the runner image ships GHC/cabal, which makes Thrift try to + # build its Haskell library (not used by the node, and it fails there). - name: Configure run: | cmake -S . -B build -G Ninja \ @@ -85,7 +95,8 @@ jobs: -DBoost_NO_SYSTEM_PATHS=ON \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_FLAGS="-include cstdint -include cstddef" + -DCMAKE_CXX_FLAGS="-include cstdint -include cstddef" \ + -DWITH_HASKELL=OFF - name: Build run: | @@ -93,6 +104,13 @@ jobs: cmake --build build -j"$(nproc)" ccache --show-stats + - name: Save ccache + if: always() + uses: actions/cache/save@v4 + with: + path: ${{ env.CCACHE_DIR }} + key: ccache-ubuntu-24.04-${{ github.sha }} + - name: Test working-directory: build run: ctest --output-on-failure @@ -103,3 +121,9 @@ jobs: name: node-linux-x64-${{ github.sha }} path: build/client/node retention-days: 30 + + - name: Disk usage + if: always() + run: | + df -h "${GITHUB_WORKSPACE}" + du -sh "${GITHUB_WORKSPACE}" build "${BOOST_PREFIX}" "${CCACHE_DIR}" 2>/dev/null || true From 771ca37165b839bc3d9b760ef3503138ff419312 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Wed, 7 Oct 2026 17:52:04 +0200 Subject: [PATCH 4/5] ci: add per-test timeout so a hanging test fails with its output In run 37643122295 the build passed, but the Test step was still running after more than 20 minutes. Locally the same three suites finish in about 35 s, also on 2 cores with no stdin. GitHub does not expose the job log until the job ends, so make the hang visible: - ctest --timeout 300 kills a stuck test and --output-on-failure prints what it logged up to that point; - step timeout-minutes: 20 so the runner is not held for the job's 3 hours. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3cb04162..81b01ba59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,9 +111,12 @@ jobs: path: ${{ env.CCACHE_DIR }} key: ccache-ubuntu-24.04-${{ github.sha }} + # Locally the whole suite runs in about 35 s: a per-test timeout makes a hang fail + # fast and print the output of the stuck test instead of holding the runner. - name: Test working-directory: build - run: ctest --output-on-failure + timeout-minutes: 20 + run: ctest --output-on-failure --timeout 300 - name: Upload node binary uses: actions/upload-artifact@v4 From f353b09308720c22b14e3e9649a699548cd61706 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Wed, 7 Oct 2026 18:17:57 +0200 Subject: [PATCH 5/5] tests: fix LockFreeChanger.BaseUsageSimple infinite loop This made the `system` suite hang on the GitHub runner (ctest timeout at 300 s in run 37647459022). Test-only change: production code is untouched. - The writer generated a value "different from previous" with `do { ... } while (randomValue != previous.data())`. The condition is inverted: on the first pass previous is 0 and values are drawn from [1, INT_MAX], so the loop never ends. Locally the writer thread usually started after `isRunning` was already false, which hid the bug; on the runner it started first and spun forever. Use `==`. - With the loop fixed, a second race became visible: the reader's wait_for(250 ms) can time out before the writer stored anything, and then `desired != previous` compares 0 with 0. Only assert once a value has been written. Locally: 3000/3000 repetitions pass, and 1000/1000 with every core busy. Before the fix it hung within 4 repetitions. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/lib_system/lib_system_tests.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/lib_system/lib_system_tests.cpp b/tests/lib_system/lib_system_tests.cpp index 862dd38c1..43289438d 100644 --- a/tests/lib_system/lib_system_tests.cpp +++ b/tests/lib_system/lib_system_tests.cpp @@ -703,7 +703,7 @@ TEST(LockFreeChanger, BaseUsageSimple) { do { randomValue = cs::Random::generateValue(1, std::numeric_limits::max()); - } while (randomValue != previous.data()); + } while (randomValue == previous.data()); changer.exchange(randomValue); @@ -724,8 +724,11 @@ TEST(LockFreeChanger, BaseUsageSimple) { auto desired = changer.data(); - ASSERT_EQ(desired.data(), current.data()); - ASSERT_TRUE(desired.data() != previous.data()); + // the wait above can time out before the writer stored anything (all values still 0) + if (current.data() != 0) { + ASSERT_EQ(desired.data(), current.data()); + ASSERT_TRUE(desired.data() != previous.data()); + } writerVariable.notify_one(); }