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..a24951ddb 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 | +| #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 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