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
1 change: 1 addition & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ lines under the new release.
| PR | Change |
|---|---|
| #82 | csnode: a node still syncing logs a missing round table of the network's current round as a warning (the block comes with the sync); an error only when it is not behind |
| #83 | packaging, solver: `compatible_version=true` in the mainnet `config.ini` (the binary's default; the official file's `false` stops a syncing node for good at a block whose transaction its replayed balances reject); a warning when a contract state declared by a block is not available while replaying |

## community.10 — 2026-10-23

Expand Down
14 changes: 13 additions & 1 deletion docs/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ quick-starts after a conversion.
memory and retries.
- **Pruned storage.** A pruned node answers NoSuchBlocks for blocks it has pruned, so a peer
asks another node for them. `TransactionsListGet` skips pruned blocks.
- **Contract replay.** A node that syncs re-executes contract calls to recover their states.
For some contracts this is not reproducible (official behaviour): a game that reads its own
balance sees it after the block's payout. The state then stays out of date, and the fee of a
later payout of the contract can be charged to an earlier caller. Such a node can disagree with
the network on a caller's balance by a fee, and mainnet nodes already disagree among themselves
on some of these wallets. The node now logs a warning when a state declared by a block is not
available; with `compatible_version=false` it would stop at the first block whose transaction
its own balances reject.

## Security and correctness fixes

Expand Down Expand Up @@ -158,9 +166,13 @@ rounds for both).

Each package includes the JDK of the official release and the community build of the contract
executor.
- **`config.ini` in the packages.** It is the official one, with three changes:
- **`config.ini` in the packages.** It is the official one, with four changes:
- `[event_report]` is commented out (it reports node events to a fixed address);
- `executor_commit_max` accepts the community executor;
- `compatible_version=true`, the default of the node binary (the official file sets `false`):
a synced block that fails the node's own transaction check is logged
(`skip block validation`) and stored, instead of stopping the node at it for good. See
"Contract replay" below;
- the pruned package adds a `[storage]` section.

The executor listens on 127.0.0.1 only.
Expand Down
6 changes: 5 additions & 1 deletion packaging/mainnet/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ hosts_filename=known_hosts.txt
init_trusted_filename=default_confidants.txt
ipv6=false
min_compatible_version=503
compatible_version=false
; true (the default of the node binary): a synced block that fails this node's own transaction
; check is logged ("skip block validation") and stored. With false the node stops at it for good:
; replaying some contracts (games that read their own balance) is not reproducible, so a syncing
; node can disagree with the network on a few balances by a fee and would then reject valid blocks
compatible_version=true

[host_input]
port=9510
Expand Down
13 changes: 12 additions & 1 deletion solver/src/smartcontracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,8 @@ csdb::Transaction SmartContracts::get_actual_state(const csdb::Transaction& hash

std::string hash_string = fld.value<std::string>();
cs::Hash hash;
// the block declares a new state that this node has to obtain (cache, execution or network)
bool state_expected = false;
csdb::Transaction tr_state(0, hashed_state.source(), hashed_state.target(), hashed_state.currency(),
hashed_state.amount(), hashed_state.max_fee(), hashed_state.counted_fee(), hashed_state.signature());

Expand All @@ -1255,6 +1257,7 @@ csdb::Transaction SmartContracts::get_actual_state(const csdb::Transaction& hash
else {
std::copy(hash_string.cbegin(), hash_string.cend(), hash.begin());
if (hash != cs::Zero::hash) {
state_expected = true;
fld = hashed_state.user_field(new_state::RefStart);
if (!fld.is_valid()) {
cserror() << kLogPrefix << "hashed_state does not refer to start transaction, use empty new_state";
Expand Down Expand Up @@ -1349,7 +1352,7 @@ csdb::Transaction SmartContracts::get_actual_state(const csdb::Transaction& hash
<< " has updated, stored hash is OK, new size is " << state.size();
}
else {
csdebug() << kLogPrefix << to_base58(req_abs_addr) << " state after " << ref_start
cswarning() << kLogPrefix << to_base58(req_abs_addr) << " state after " << ref_start
<< " has updated, stored hash is WRONG: " << cs::Utils::byteStreamToHex(hash.data(), hash.size())
<< " (expected " << cs::Utils::byteStreamToHex(actual_hash.data(), actual_hash.size())
<< "), new size is " << state.size();
Expand Down Expand Up @@ -1389,6 +1392,14 @@ csdb::Transaction SmartContracts::get_actual_state(const csdb::Transaction& hash
if (tr_state.user_field_ids().count(new_state::Value) == 0) {
tr_state.add_user_field(new_state::Value, std::string{});
}
// a contract whose execution is not reproducible (e.g. one that reads its own balance) leaves its
// state unknown here, and the fees of its later emitted transactions can then be charged to an
// earlier initiator: this node's balances may differ from the network's by such fees
if (state_expected && tr_state.user_field(new_state::Value).value<std::string>().empty()) {
cswarning() << kLogPrefix << "state of " << to_base58(absolute_address(hashed_state.target()))
<< " declared by the block is not available" << (reading_db ? " while reading the blockchain" : "")
<< ", the contract state is out of date";
}
return tr_state;
}

Expand Down
Loading