From 8fae773078d55a5a27a159ec23722ec15aec1c70 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Fri, 30 Oct 2026 09:41:18 +0100 Subject: [PATCH 1/2] api: contract results after a quick start at the last stored block A quick start from a checkpoint at the last stored block reads no block, so baseLoaded() never ran and isBDLoaded_ stayed false for the life of the node. The new_state of a call then never signals the TransactionFlow that waits for it: every contract call sent through that node's API answered "Transaction in progress" without its result, although the network executed it (seen on the private network: the node of the restart test, after a stop that saved its checkpoint at its last block). The stored blocks are read once the node runs: run() marks them so. isBDLoaded_ is atomic, read by the API threads and written by the reading and starting ones. --- api/include/apihandler.hpp | 5 +++-- api/src/apihandler.cpp | 8 ++++++-- docs/CHANGES.md | 1 + docs/differences.md | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/api/include/apihandler.hpp b/api/include/apihandler.hpp index 002d99655..ecba170a8 100644 --- a/api/include/apihandler.hpp +++ b/api/include/apihandler.hpp @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -173,7 +174,7 @@ class APIHandler : public APIHandlerInterface { return executor_; } - bool isBDLoaded() { return isBDLoaded_; } + bool isBDLoaded() { return isBDLoaded_.load(std::memory_order_acquire); } private: #ifdef USE_DEPRECATED_STATS @@ -182,7 +183,7 @@ class APIHandler : public APIHandlerInterface { cs::Executor& executor_; cs::DumbCv dumbCv_; - bool isBDLoaded_{ false }; + std::atomic isBDLoaded_{ false }; struct smart_trxns_queue { cs::SpinLock lock{ATOMIC_FLAG_INIT}; diff --git a/api/src/apihandler.cpp b/api/src/apihandler.cpp index d22504379..2d12664d8 100644 --- a/api/src/apihandler.cpp +++ b/api/src/apihandler.cpp @@ -70,6 +70,10 @@ void APIHandler::run() { stats.run(stats_); #endif state_updater_running.test_and_set(std::memory_order_acquire); + // the node runs once its stored blocks are read; a quick start at the last stored block reads + // none, so baseLoaded() never marks them read, and TransactionFlow would never get the result + // of a contract call (the signal at the new_state of the call needs isBDLoaded_) + isBDLoaded_.store(true, std::memory_order_release); } APIHandler::~APIHandler() { @@ -1870,7 +1874,7 @@ void APIHandler::store_block_slot(const csdb::Pool& pool) { void APIHandler::baseLoaded(const csdb::Pool& pool) { if (maxReadSequence && pool.sequence() == maxReadSequence) { - isBDLoaded_ = true; + isBDLoaded_.store(true, std::memory_order_release); #ifdef TOKENS_CACHE tm_.loadTokenInfo([&](const TokensMap& tokens, const HoldersMap&) { int count{}, i{}; @@ -1889,7 +1893,7 @@ void APIHandler::baseLoaded(const csdb::Pool& pool) { void APIHandler::maxBlocksCount(cs::Sequence lastBlockNum) { if (!lastBlockNum) { - isBDLoaded_ = true; + isBDLoaded_.store(true, std::memory_order_release); } maxReadSequence = lastBlockNum; diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 667f3db0c..0612caaa0 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -41,6 +41,7 @@ lines under the new release. |---|---| | #119 | ci: the release checks the Windows and macOS packages on mainnet before publishing them (a node of each system restores the published snapshot, syncs to the head, logs the same state digests as Linux and stops cleanly), and the same check runs weekly on the latest published release | | #120 | ci: a private network of 7 nodes (with the restart of one at block 300) runs on macOS and on Windows every night and on demand (`testnet-platforms.yml`): the nodes reach the same state digests as on Linux and a stopped node quick-starts again; Linux-only scenarios (network faults, slow nodes, full disks) stay on Linux | +| — | api: after a quick start at the last stored block, contract calls through the API returned "Transaction in progress" and never their result; the node now marks its stored blocks as read when it runs | ## community.14 — 2026-10-27 diff --git a/docs/differences.md b/docs/differences.md index 98323512d..11e93487c 100644 --- a/docs/differences.md +++ b/docs/differences.md @@ -172,6 +172,12 @@ What an operator sees and sets is in [snapshots.md](snapshots.md). - `[params] sync_contract_execution` (default `true`): `false` skips the re-execution while syncing altogether, and every state comes from the confidants. +- **Contract results after a quick start.** A node that quick-starts from a checkpoint at its last + stored block reads no block. The official node then never marks its stored blocks as read, and + every contract call sent through its API ends with "Transaction in progress" and no result, + even though the network executed the call. The community node marks the blocks as read when + it starts running. + ## Security and correctness fixes These were found by reviewing the official code. None of them changes the blocks or the From 0ba681c648ea44f4b9aebf6a7600b3c24aff95c9 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Fri, 30 Oct 2026 10:26:26 +0100 Subject: [PATCH 2/2] docs: CHANGES line for #126 --- docs/CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 0612caaa0..a24951ddb 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -41,7 +41,7 @@ lines under the new release. |---|---| | #119 | ci: the release checks the Windows and macOS packages on mainnet before publishing them (a node of each system restores the published snapshot, syncs to the head, logs the same state digests as Linux and stops cleanly), and the same check runs weekly on the latest published release | | #120 | ci: a private network of 7 nodes (with the restart of one at block 300) runs on macOS and on Windows every night and on demand (`testnet-platforms.yml`): the nodes reach the same state digests as on Linux and a stopped node quick-starts again; Linux-only scenarios (network faults, slow nodes, full disks) stay on Linux | -| — | api: after a quick start at the last stored block, contract calls through the API returned "Transaction in progress" and never their result; the node now marks its stored blocks as read when it runs | +| #126 | api: after a quick start at the last stored block, contract calls through the API returned "Transaction in progress" and never their result; the node now marks its stored blocks as read when it runs | ## community.14 — 2026-10-27