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
35 changes: 34 additions & 1 deletion api/src/apihandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,8 @@ void APIHandler::smartTransactionFlow(api::TransactionFlowResult& _return, const
//auto send_transaction = makeTransaction(transaction);
const auto smart_addr = blockchain_.getAddressByType(send_transaction.target(), BlockChain::AddressType::PublicKey);
if (solver_.smart_contracts().isBlacklisted(smart_addr)) {
// not an empty success: the caller must see that nothing ran
SetResponseStatus(_return.status, APIRequestStatusType::FAILURE, "contract is blacklisted");
return;
}
bool deploy = transaction.__isset.smartContract ? is_smart_deploy(input_smart) : false;
Expand All @@ -1178,7 +1180,13 @@ void APIHandler::smartTransactionFlow(api::TransactionFlowResult& _return, const
decltype(auto) lockedSmartOrigin = lockedReference(this->smart_origin);
auto it = lockedSmartOrigin->find(smart_addr);
if (it != lockedSmartOrigin->end()) {
origin_bytecode = fetch_smart(executor_.loadTransactionApi(it->second)).smartContractDeploy.byteCodeObjects;
// the deploy the smart contracts keep (in memory and in every checkpoint): a pruned node
// no longer has the deploy's block; the storage is the fallback, as in SmartContractGet
csdb::Transaction deploy_tr = solver_.smart_contracts().get_contract_deploy(smart_addr);
if (!deploy_tr.is_valid()) {
deploy_tr = executor_.loadTransactionApi(it->second);
}
origin_bytecode = fetch_smart(deploy_tr).smartContractDeploy.byteCodeObjects;
}
else {
SetResponseStatus(_return.status, APIRequestStatusType::FAILURE);
Expand Down Expand Up @@ -1227,6 +1235,12 @@ void APIHandler::smartTransactionFlow(api::TransactionFlowResult& _return, const
auto target_pk = blockchain_.getAddressByType(send_transaction.target(), BlockChain::AddressType::PublicKey).to_api_addr();
executor::ExecuteByteCodeResult api_resp;
const std::vector<general::ByteCodeObject>& bytecode = deploy ? input_smart.smartContractDeploy.byteCodeObjects : origin_bytecode;
if (!deploy && bytecode.empty()) {
// nothing to execute: an answer without a result must not read as a success
SetResponseStatus(_return.status, APIRequestStatusType::FAILURE, "contract byte code is not available on this node");
hashStateEntry->yield();
return;
}
if (!deploy || !input_smart.smartContractDeploy.byteCodeObjects.empty()) {
std::vector<executor::MethodHeader> methodHeaders;
{
Expand Down Expand Up @@ -2197,6 +2211,25 @@ size_t APIHandler::getMappedDeployerSmart(const csdb::Address& deployer, Mapper
auto begIt = element.begin() + offset;
for (auto trid = begIt; trid != begIt + limit && trid != element.end(); ++trid) {
auto tr = executor_.loadTransactionApi(*trid);
if (!tr.is_valid()) {
// a pruned node no longer has the deploy's block: the copy the smart contracts keep
csdb::Address contract;
{
decltype(auto) origins = lockedReference(this->smart_origin);
for (const auto& [address, id] : *origins) {
if (id == *trid) {
contract = address;
break;
}
}
}
if (contract.is_valid()) {
tr = solver_.smart_contracts().get_contract_deploy(contract);
}
if (!tr.is_valid()) {
continue;
}
}

if (cs::SmartContracts::get_contract_state(blockchain_, tr.target()).empty()) {
continue;
Expand Down
9 changes: 9 additions & 0 deletions api/src/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ void cs::Executor::executeByteCode(executor::ExecuteByteCodeResult& resp, const
if (auto optOriginRes = execute(address, smartContractBinary, methodHeader, isGetter, sequence)) {
resp = optOriginRes.value().resp;
}
else {
// as executeByteCodeMultiple: an unexecuted call is not a success without a result
resp.status.code = 1;
resp.status.message = "No executor connection!";
}
}
else {
resp.status.code = 1;
resp.status.message = "no contract byte code";
}
}

Expand Down
1 change: 1 addition & 0 deletions docs/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lines under the new release.
| #70 | csnode: bootstrap tables of 9 to 25 confidants are accepted (the official node silently drops them, so a network of 9 or more initial confidants never starts); the same choice as the official node up to 8 |
| #71 | csnode: a bootstrap round table is taken only for a round next to the node's own, and, unless signed with the blockchain key, only once the node's own round has stalled; the block-removal request it set (never effective) is gone |
| #73 | api: the executor version check asks every second up to `executor_check_version_delay` instead of once after it (the node starts as soon as its executor answers); with `executor_multi_instance` a stopping node no longer kills the other nodes' executors |
| #74 | api: contract getters and the deployer's contract list take the deploy the smart contracts keep (a pruned node no longer has its block, and answered getters with an empty success); a getter with nothing to execute, or no executor, now fails |

## community.9 — 2026-10-22

Expand Down
Loading