Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty tx warnings #1563

Merged
merged 3 commits into from
Jun 13, 2022
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
3 changes: 3 additions & 0 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,9 @@ bool BlockchainLMDB::get_txpool_tx_blob(const crypto::hash& txid, std::string &b
if (result != 0)
throw1(DB_ERROR(lmdb_error("Error finding txpool tx blob: ", result).c_str()));

if (v.mv_size == 0)
throw1(DB_ERROR("Error finding txpool tx blob: tx is present, but data is empty"));

bd.assign(reinterpret_cast<const char*>(v.mv_data), v.mv_size);
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,12 @@ namespace cryptonote
tx_info.tvc.m_too_big = true;
return;
}
else if (tx_info.blob->empty())
{
LOG_PRINT_L1("WRONG TRANSACTION BLOB, blob is empty, rejected");
tx_info.tvc.m_verifivation_failed = true;
return;
}

tx_info.parsed = parse_and_validate_tx_from_blob(*tx_info.blob, tx_info.tx, tx_info.tx_hash);
if(!tx_info.parsed)
Expand Down
10 changes: 4 additions & 6 deletions src/cryptonote_protocol/cryptonote_protocol_handler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2579,17 +2579,15 @@ skip:
template<class t_core>
bool t_cryptonote_protocol_handler<t_core>::relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, cryptonote_connection_context& exclude_context)
{
for(auto& tx_blob : arg.txs)
m_core.on_transaction_relayed(tx_blob);

// no check for success, so tell core they're relayed unconditionally and snag a copy of the
// hash so that we can look up any associated blink data we should include.
std::vector<crypto::hash> relayed_txes;
relayed_txes.reserve(arg.txs.size());
for (auto &tx_blob : arg.txs)
relayed_txes.push_back(
m_core.on_transaction_relayed(tx_blob)
);
{
if (auto hash = m_core.on_transaction_relayed(tx_blob))
jagerman marked this conversation as resolved.
Show resolved Hide resolved
relayed_txes.push_back(hash);
}

// Rebuild arg.blinks from blink data that we have because we don't necessarily have the same
// blink data that got sent to us (we may have additional blink info, or may have rejected some
Expand Down