Commit Graph
260 Commits
Author SHA1 Message Date
tobtoht f706ba923a Merge pull request #11091
41e06a1 tx_pool: do expensive verify after potential no-drop offenses (j-berman)

ACKs: selsta, jpk68
2026-08-23 07:39:40 +00:00
tobtoht 5d4115e4ee Merge pull request #11058
77acf1f tx_pool: fix write abort and improve locking for relayable txs (jeffro256)

ACKs: j-berman, selsta
2026-08-12 13:31:13 +00:00
j-berman 41e06a1b5e tx_pool: do expensive verify after potential no-drop offenses 2026-08-11 13:54:51 -07:00
jeffro256 77acf1f9d3 tx_pool: fix write abort and improve locking for relayable txs 2026-08-07 14:17:18 -05:00
tobtoht 4605a02bcf Merge pull request #10991
e7278c0 cryptonote_core: remove dead code (Thomas)

ACKs: jpk68, selsta
2026-08-04 14:41:01 +00:00
tobtoht 215e16ef46 Merge pull request #10840
5a2bd89 txpool: re-relay txs that haven't been relayed and need to be (j-berman)

ACKs: selsta, vtnerd, jpk68
2026-08-04 05:19:05 +00:00
Thomas e7278c0add cryptonote_core: remove dead code
Never had a caller:
- Blockchain::init taking HardFork*&: added in 8f863e742, no caller in
  any revision since
- tx_memory_pool::get_txpool_weight, set_txpool_max_weight: added as
  get_txpool_size and set_txpool_max_size in bc61ae69b alongside
  --max-txpool-size, which is wired through tx_memory_pool::init
  instead; renamed size to weight in 5ffb2ff9b, still uncalled
- get_transaction_version: added in b750fb27b, no caller since

Dead when their last user went:
- core::get_blocks taking vector<pair<blobdata, block>>, both overloads:
  last caller removed in 9faef1f83; ed2c81ed9 later converted the
  already-dead signatures from std::list to std::vector. The
  vector<block> overload is still used by core_tests and is kept
- blocks_container: 9e82b694d removed the in-memory blockchain that
  used it
- tx_by_fee_and_receive_time_entry: 445319d3f replaced the sorted
  container it keyed with a boost::bimap
- m_store_blockchain_interval: its do_call went with the original
  blockchain_storage format in 9e82b694d
- m_fork_moaner: its do_call went with the "We are most likely forked"
  message in f0371210e

Also drops two break statements after a return in ver_mixed_rct_semantics
and the doc comments belonging to the removed declarations.
2026-07-28 07:43:43 +02:00
selsta 85b38a52a6 rpc: replace get_blocks.bin Levin pool budget
/get_blocks.bin is HTTP binary RPC serialized with portable storage, not a
P2P Levin message. The previously added pool limiter used
LEVIN_DEFAULT_MAX_PACKET_SIZE as a response budget, but that constant does
not apply to the RPC path.
2026-07-15 01:58:59 +02:00
j-berman 5a2bd895ca txpool: re-relay txs that haven't been relayed and need to be
Fixes the following circumstance:
1. Wallet submits tx to node.
2. Node adds tx to pool and queues for relay.
3. Node shuts off before the relay executes in the strand.
4. Node restarts.
5. Now, the fix ensures the node will re-relay the tx in the
get_relayable_transactions loop.

Also makes sure that stem txs don't have last_relayed_time set
to max, which would prevent them from ever being re-relayed on
a restart as well.

Context: https://github.com/seraphis-migration/monero/issues/365#issuecomment-4811722029
2026-06-29 17:54:11 -07:00
Thomas fecef767c9 Fix spelling typos in comments and string literals 2026-06-27 09:53:48 +02:00
tobtoht 9409d0ac36 Merge pull request #10709
b5f7330 tx_pool: fix use-after-free in prune() - txid was a reference to an item which was later deleted in remove_tx_from_transient_lists(), and txid was used after that (SChernykh)
2026-06-09 17:51:49 +00:00
tobtoht a8478d21b2 Merge pull request #10531
7af9009 zmq: apply restricted-mode privacy filtering to get_transaction_pool (greatjourney589)
2026-06-08 08:34:50 +00:00
SChernykh b5f7330e0b tx_pool: fix use-after-free in prune()
- txid was a reference to an item which was later deleted in remove_tx_from_transient_lists(), and txid was used after that
2026-06-03 20:47:05 +02:00
tobtoht c982fe1e51 Merge pull request #9473
1aea9cc tx_pool: track sensitive flag per-tx in added_txs_by_id (j-berman)
8cecfc8 src: fix rpc limit (Navid Rahimi)
2026-05-21 19:58:24 +00:00
j-bermanandNavid Rahimi 1aea9cc256 tx_pool: track sensitive flag per-tx in added_txs_by_id
Replace the plain time_t map value with an added_tx_info struct that
stores both receive_time and a sensitive flag. Thread the flag through
all add_tx_to_transient_lists call sites so incremental RPC queries
can skip sensitive transactions.

Reported-by: selsta
2026-05-21 20:37:59 +01:00
Navid Rahimiandjeffro256 8cecfc8d1b src: fix rpc limit
Co-authored-by: jeffro256 <jeffro256@tutanota.com>
2026-05-21 20:37:53 +01:00
Thomas 2c327aa325 fix spelling in comments and docs 2026-05-13 21:20:05 +02:00
greatjourney589 7af90094da zmq: apply restricted-mode privacy filtering to get_transaction_pool
Add an include_sensitive parameter to tx_memory_pool::get_pool_for_rpc
(and its core passthrough), mirroring the include_sensitive_data
parameter on the HTTP analog get_transactions_and_spent_keys_info.
When false, receive_time and last_relayed_time are zeroed using the
same masking already applied on the HTTP path.

The ZMQ handler in daemon_handler.cpp passes !m_restricted, so
--restricted-zmq-rpc callers now receive the same privacy-filtered view
as restricted HTTP callers instead of the unfiltered timing metadata
they previously got. Stem-phase txs continue to be excluded regardless
(relay_category::broadcasted filter unchanged).

Refs #10529.
2026-05-08 11:33:34 -04:00
j-berman d29ffb9616 tx_pool: notify txpool event when stem bumps to fluff 2026-04-24 09:02:45 -07:00
tobtoht 50da8bf8a5 Merge pull request #10186
0673c95 tx_memory_pool: speedup get_complement() for large requests (jeffro256)
2026-03-28 19:45:05 +00:00
tobtoht 4286fbe6cd Merge pull request #10157
022fb8e unit_tests: @j-berman unit tests for #10157 (jeffro256)
40eb828 cryptonote_core: cache input verification results directly in mempool (jeffro256)
2026-01-03 11:31:27 +00:00
jeffro256 40eb82873e cryptonote_core: cache input verification results directly in mempool
This replaces `ver_rct_non_semantics_simple_cached()` with an API that offloads
the responsibility of tracking input verification successes to the caller. The
main caller of this function in the codebase, `cryptonote::Blockchain()` instead
keeps track of the verification results for transaction in the mempool by
storing a "verification ID" in the mempool metadata table (with `txpool_tx_meta_t`).
This has several benefits, including:

* When the mempool is large (>8192 txs), we no longer experience cache misses and unnecessarily re-verify ring signatures. This greatly improves block propagation time for FCMP++ blocks under load
* For the same reason, reorg handling can be sped up by storing verification IDs of transactions popped from the chain
* Speeds up re-validating every mempool transaction on fork change (monerod revalidates the whole tx-pool on HFs #10142)
* Caches results for every single type of Monero transaction, not just latest RCT type
* Cache persists over a node restart
* Uses 512KiB less RAM (8192*2*32B)
* No additional storage or DB migration required since `txpool_tx_meta_t` already had padding allocated
* Moves more verification logic out of `cryptonote::Blockchain`

Furthermore, this opens the door to future multi-threaded block verification
speed-ups. Right now, transactions' input proof verification is limited to one
transaction at a time. However, one can imagine a scenario with verification IDs
where input proofs are optimistically multi-threaded in advance of block
processing. Then, even though ring member fetching and verification is
single-threaded inside of `cryptonote::Blockchain::check_tx_inputs()`, the
single thread can skip the CPU-intensive cryptographic code if the verification
ID allows it.

Also changes the default log category in `tx_verification_utils.cpp` from "blockchain" to "verify".
2026-01-02 15:47:19 -06:00
jeffro256 0673c957af tx_memory_pool: speedup get_complement() for large requests
Changes complexity from M*N to (2*N+M)*log2(M). The FCMP++ stressnet recently hit mempool sizes of ~55k txs.
If the requesting node's mempool is populated, this results in an average of (55000*55000)/2
(about 1.5 billion) comparisons for the responding node. Under this commit, this would be reduced to
(55000+55000)*log2(55000) comparisons (about 2.6 million), a 99.83% reduction.
2025-11-26 13:40:33 -06:00
j-berman a378b59628 tx pool: only increment m_txpool_weight for newly added pool txs
Otherwise we can end up double counting txs towards the weight,
which can over-state the pool weight. E.g. relay tx to node in
stem phase, add its weight to pool weight, then receive tx
from another node, then bump the pool weight again. That double
counts the tx towards the pool weight.

If the weight exceeds the max, the node will "prune" txs from the
pool. Thus, over-counting is probably a cause of, but perhaps
not the only cause of:
https://github.com/seraphis-migration/monero/issues/148
2025-11-11 16:31:01 -08:00
jeffro256 e9c89dc6ab wallet: kill support for deprecated ephemeral Boost messages
The commit kills support for deprecated ephemeral Boost messages: signed/unsigned transaction sets, pending transactions, reserve proofs, MMS messages, etc.
It does NOT kill support for loading very old wallets in Boost format, that should be supported indefinitely. These messages were deprecated 5 years ago. Since
then, we have had a hard fork to enable a new non-compatible transaction type (w/ view tags), and disable the old transaction type. This renders basically all
of the aforementioned messages before that HF useless, with the possible exception of reserve proofs.

This commit also cleans up dead inclusions of boost serialization headers.

This commit is part of upstreaming Carrot/FCMP++. Killing support for Boost messages now means less boilerplate Boost serialization review for Carrot/FCMP++.
2025-05-30 14:24:56 -05:00
jeffro256 c069c04ede blockchain sync: reduce disk writes from 2 to 1 per tx 2025-03-10 01:02:37 -05:00
luigi1111 25dcb8dc9f Merge pull request #9376
445319d src: update internal data structure to boost::bimap. startup speed up 2-5x because this PR changing O(n^2) operation to O(nlogn). (0xFFFC0000)
2024-12-23 10:27:17 -05:00
0xFFFC0000 445319d3f1 src: update internal data structure to boost::bimap.
startup speed up 2-5x because this PR changing
O(n^2) operation to O(nlogn).
2024-06-21 07:22:19 +00:00
copyCat 341771ac3e copyright: bump to 2024 2024-05-21 16:29:33 +00:00
luigi1111 cdd7fc09b4 Merge pull request #9151
ff49444 @tobtoht: undo rebase changes tx.dsts -> tx_dsts (jeffro256)
38f354e Enforce Tx unlock_time is Zero by Relay Rule (jeffro256)
2024-05-20 23:11:09 -05:00
SChernykh a01d7ccbfd Fixed mempool pruning
- Fixed undefined behavior after a call to `remove_tx_from_transient_lists` (it used an invalid iterator)
- Fixed `txCompare` (it wasn't strictly weak ordered)
2024-03-08 21:04:16 +01:00
luigi1111 d6d55b507a Merge pull request #9222
66e5081 get_block_template_backlog: better sorting logic (SChernykh)
2024-03-08 13:45:41 -05:00
SChernykh 66e5081eae get_block_template_backlog: better sorting logic
std::sort is unstable, so it can return random sets of transactions when mempool has many transactions with the same fee/byte. It can result in p2pool mining empty blocks sometimes because it doesn't pick up "new" transactions immediately.
2024-03-08 14:50:01 +01:00
jeffro256 7815023117 tx_memory_pool: make double spends a no-drop offense
Nodes who see different txs in a double spend attack will drop each other, splitting the network.
Issue found by @boog900.
2024-03-07 09:23:51 -06:00
jeffro256 38f354e89f Enforce Tx unlock_time is Zero by Relay Rule
Related to https://github.com/monero-project/research-lab/issues/78

Added a relay rule that enforces the `unlock_time` field is equal to 0 for non-coinbase transactions.

UIs changed:
* Removed `locked_transfer` and `locked_sweep_all` commands from `monero-wallet-cli`

APIs changed:
* Removed `unlock_time` parameters from `wallet2` transfer methods
* Wallet RPC transfer endpoints send error codes when requested unlock time is not 0
* Removed `unlock_time` parameters from `construct_tx*` cryptonote core functions
2024-02-24 14:27:17 -06:00
luigi1111 9bf06ea75d Merge pull request #8698
5b4fea7 Copyright: Update to 2023 (mj-xmr)
2023-04-25 11:12:56 -04:00
jeffro256andSChernykh caa7561705 cryptonote core/protocol: don't drop peers for soft offenses
Also: txs with tx_extra which is too large will not get published to ZMQ

Co-authored-by: SChernykh <sergey.v.chernykh@gmail.com>
2023-03-29 02:05:43 -05:00
luigi1111 76dd14dfb1 Merge pull request #8733
3771641 Add a size limit for tx_extra in tx pool (tevador)
2023-03-18 18:18:13 -04:00
luigi1111 a511202222 Merge pull request #8076
c4af33e Enforce restricted # pool txs served via RPC + optimize chunked reqs (j-berman)
9752116 wallet2, RPC: Optimize RPC calls for periodic refresh from 3 down to 1 call (rbrunner7)
2023-03-18 17:58:27 -04:00
j-bermanandrbrunner7 c4af33eded Enforce restricted # pool txs served via RPC + optimize chunked reqs
- `/getblocks.bin` respects the `RESTRICTED_TX_COUNT` (=100) when
returning pool txs via a restricted RPC daemon.
- A restricted RPC daemon includes a max of `RESTRICTED_TX_COUNT` txs
in the `added_pool_txs` field, and returns any remaining pool hashes
in the `remaining_added_pool_txids` field. The client then requests
the remaining txs via `/gettransactions` in chunks.
- `/gettransactions` no longer does expensive no-ops for ALL pool txs
if the client requests a subset of pool txs. Instead it searches for
the txs the client explicitly requests.
- Reset `m_pool_info_query_time` when a user:
  (1) rescans the chain (so the wallet re-requests the whole pool)
  (2) changes the daemon their wallets points to (a new daemon would
      have a different view of the pool)
- `/getblocks.bin` respects the `req.prune` field when returning
pool txs.
- Pool extension fields in response to `/getblocks.bin` are optional
with default 0'd values.
2023-03-07 20:35:45 +01:00
tevador 3771641fc5 Add a size limit for tx_extra in tx pool 2023-02-26 10:26:53 +01:00
mj-xmrandmj-xmr 5b4fea72cf Copyright: Update to 2023
Co-authored-by: plowsof <plowsof@protonmail.com>
extra files
2023-01-16 13:00:18 +01:00
rbrunner7 9752116ed3 wallet2, RPC: Optimize RPC calls for periodic refresh from 3 down to 1 call 2022-12-30 13:50:22 +01:00
Jeffrey Ryan 7a3a593a77 common: move boost_serialization_helper.h out and cleanup includes 2022-12-22 12:18:02 -06:00
luigi1111 ce80747c58 Merge pull request #8427
1fc60ca Publish submitted txs via zmq (j-berman)
2022-08-22 22:45:14 -05:00
luigi1111 645d752b19 Merge pull request #8415
628fdcd continue pool pruning even if a tx can't be found (j-berman)
2022-08-22 22:44:04 -05:00
SChernykh f79765579c Fixed get_block_template_backlog performance
Before the fix, it processed all transactions in the mempool which could be very slow when mempool grows to several MBs in size. I observed `get_block_template_backlog` taking up to 15 seconds of CPU time under high mempool load.

After the fix, only transactions that can potentially be mined in the next block will be processed (a bit more than the current block median weight).
2022-07-26 07:21:21 +02:00
j-berman 1fc60cac58 Publish submitted txs via zmq 2022-07-21 11:36:00 -07:00
j-berman 628fdcdd49 continue pool pruning even if a tx can't be found 2022-07-01 09:44:58 -07:00
j-berman b9d2c788bc fix backoff delay logic when re-relaying txs 2022-05-12 08:39:51 -07:00