Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/include/apihandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <csstats.hpp>

#include <atomic>
#include <deque>
#include <queue>
#include <tuple>
Expand Down Expand Up @@ -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
Expand All @@ -182,7 +183,7 @@ class APIHandler : public APIHandlerInterface {
cs::Executor& executor_;
cs::DumbCv dumbCv_;

bool isBDLoaded_{ false };
std::atomic<bool> isBDLoaded_{ false };

struct smart_trxns_queue {
cs::SpinLock lock{ATOMIC_FLAG_INIT};
Expand Down
8 changes: 6 additions & 2 deletions api/src/apihandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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{};
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions docs/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading