Commit Graph
763 Commits
Author SHA1 Message Date
j-berman 236ca60be0 cryptonote_basic: parse_and_validate_tx param to check max size
Simple API to check max blob size before parsing. This is useful
when reading blobs from untrusted sources.

@selsta pointed out that coinbase txs can technically be larger
than get_max_tx_size(), otherwise we could enforce it on all txs.
2026-08-13 09:12:10 -07:00
tobtoht d006bd463f Merge pull request #11049
20db2e7 blockchain: if block is known invalid, fail block verification (j-berman)

ACKs: jeffro256, selsta
2026-08-10 13:21:48 +00:00
j-berman 20db2e7162 blockchain: if block is known invalid, fail block verification 2026-08-04 13:57:57 -07: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
tobtoht e00908bc49 Merge pull request #10921
edea850 general: replace auto_scope_leave_caller with scope_guard (jeffro256)

ACKs: selsta, tobtoht
2026-07-22 16:31:31 +00:00
tobtoht da5d40d597 Merge pull request #10885
c9a18b9 blockchain: fix misleading request chain error logs (selsta)

ACKs: jpk68, plowsof
2026-07-16 13:41:18 +00:00
jeffro256 edea8505db general: replace auto_scope_leave_caller with scope_guard
And replace unused inclusions of misc_language.h
2026-07-15 19:54:58 -05:00
tobtoht d9d83b0d27 Merge pull request #10762
95b207f Blockchain: fix data race in get_dynamic_base_fee_estimate (Masamune)

ACKs: selsta, jeffro256
2026-07-15 19:50:54 +00:00
selsta c9a18b96cb blockchain: fix misleading request chain error logs 2026-07-10 16:26:06 +02:00
tobtoht 381fce8dde Merge pull request #10828
fecef76 Fix spelling typos in comments and string literals (Thomas)

ACKs: tobtoht, selsta
2026-07-02 13:18:56 +00:00
tobtoht 596d0a0363 Merge pull request #10780
c914c27 src: update checkpoints to match v0.18.5.1 (selsta)

ACKs: plowsof*, tobtoht
2026-06-30 10:05:22 +00:00
tobtoht 05b312799c Merge pull request #10837
265e95a blockchain: improve incoming block scan table handling (selsta)

ACKs: SChernykh, j-berman
2026-06-30 10:01:32 +00:00
selsta c914c27c46 src: update checkpoints to match v0.18.5.1 2026-06-29 18:28:41 +02:00
selsta 265e95a8b5 blockchain: improve incoming block scan table handling 2026-06-29 14:07:28 +02:00
Thomas fecef767c9 Fix spelling typos in comments and string literals 2026-06-27 09:53:48 +02:00
Thomas b5136b1a5d common: remove unused data_cache.h
Dead since 40eb82873 (2025-10) moved verRct caching into the mempool;
only a stale #include remained in blockchain.cpp.
2026-06-23 22:31:28 +02:00
Masamune 95b207f00f Blockchain: fix data race in get_dynamic_base_fee_estimate 2026-06-12 15:36:57 +07:00
akildemirandselsta 1bd4dfe43a rpc: return prunable hashes in pruned getblocks
Co-authored-by: selsta <selsta@sent.at>
2026-06-11 20:37:13 +02:00
tobtoht c113dee523 Merge pull request #10716
196078e Refactored tx verification NIC logic (SChernykh)
2026-06-10 17:10:21 +00:00
tobtoht acb83adf37 Merge pull request #10714
6f7ad2c Blockchain: fix wrong block_weight in handle_get_objects (SChernykh)
2026-06-09 17:53:48 +00:00
jeffro256 9dbce17bb5 Blockchain: option for fast manual block popping 2026-06-07 14:59:57 -05:00
SChernykh 196078ea0c Refactored tx verification NIC logic
Encapsulated `nic_verified_hf_version` and `txs_by_txid` to make it impossible for callers to skip updating it.
2026-06-04 09:55:38 +02:00
SChernykh 6f7ad2cdc9 Blockchain: fix wrong block_weight in handle_get_objects
- When there are missing IDs, blocks.size() != arg.blocks.size(), so arg.blocks can't be indexed by `i` - the indices will be wrong, the wrong weight will be returned to some peer and this peer will ban our node.

Use `bl.second` instead of `arg.blocks[i]`. Also it saves one DB query per returned block.
2026-06-04 07:37:53 +02:00
Thomas 2c327aa325 fix spelling in comments and docs 2026-05-13 21:20:05 +02:00
tobtoht dace76882d Merge pull request #10407
ccba74c src: update checkpoints to match v0.18.5.0 (selsta)
2026-05-03 19:24:17 +00:00
tobtoht b84aee62a4 Merge pull request #10143
4a2d6eb Daemon RPC: getblocks.bin block_ids_exclusive req param (j-berman)
2026-04-29 12:35:26 +00:00
tobtoht 172b4e1883 fix: warning: variable set but not used 2026-04-28 16:24:41 +02:00
selsta ccba74ce5e src: update checkpoints to match v0.18.5.0 2026-04-28 03:41:51 +02:00
tobtoht 6f284e8779 Merge pull request #10319
f459bd6 src: update checkpoints to match v0.18.4.6 (selsta)
2026-02-18 22:20:45 +00:00
selsta f459bd655e src: update checkpoints to match v0.18.4.6 2026-02-13 18:23:07 +01:00
tobtoht 087b97773a Merge pull request #10285
b90f455 blockchain_db: remove {add/get}_max_block_size() (jeffro256)
2026-02-03 18:56:49 +00:00
jeffro256 b90f455e6b blockchain_db: remove {add/get}_max_block_size() 2026-01-21 11:49:46 -06:00
tobtoht f65b286455 Merge pull request #10272
3f964fc blockchain_db/rpc: faster is_key_image_spent (jeffro256)
2026-01-17 03:41:46 +00:00
tobtoht ab2ea4763a Merge pull request #10166
a863bf7 BlockchainDB: rm `skip_coinbase` in `get_blocks_from()` (jeffro256)
2026-01-09 16:08:54 +00:00
jeffro256 3f964fcdb5 blockchain_db/rpc: faster is_key_image_spent
Does the following to speedup the `/is_key_image_spent` RPC endpoint:
  - Reads all on-chain key images in one LMDB read transacion
  - Uses `cryptonote_core::are_key_images_spent_in_pool()` instead of `cryptonote_core::get_pool_transactions_and_spent_keys_info()` for pool querying. This only does a LMDB read per key image if in the pool.
  - Filters known on-chain spent key images before querying for key images spent in pool

This RPC endpoint was causing major daemon slowdowns in the Carrot/FCMP++ Alpha Stressnet when using the `rescan_spent` command, especially for large wallets.
The effect was much worse if the mempool was full.
2026-01-07 00:49:44 -06: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
tobtoht 02357fe53f Merge pull request #10263
5905589 src: update checkpoints to match v0.18.4.5 (selsta)
2025-12-29 22:42:09 +00:00
selsta 590558960f src: update checkpoints to match v0.18.4.5 2025-12-29 22:29:17 +01:00
j-berman d7c5f95704 p2p: fix race causing dropped connections during sync
Without this commit:
1) read height from DB
2) add block to chain in separate thread
3) read chain for block id's and request them from peer
4) ERR in handle_response_chain_entry, peer's first block is the
one that was added to the chain, which has block idx=height from
step 1.

This commit reads the chain for height and highest block id's
in one go while holding the m_blockchain_lock to avoid the race.
2025-12-11 21:36:42 -08:00
tobtoht 337525d3d0 Merge pull request #10192
38bc627 Blockchain: cancel pop_blocks() operation on interupt (jeffro256)
2025-11-26 18:23:06 +00:00
selsta ef3fe664fd src: update checkpoints to match v0.18.4.4 2025-11-10 19:00:50 +01:00
jeffro256 38bc62741b Blockchain: cancel pop_blocks() operation on interupt
On SIGINT, `Blockchain::cancel()` is called, which sets `m_cancel` to `true`.
This commit stops attempting to pop blocks from the chain once that flag is
set. This should leave the blockchain in a well-define state, even if the
`pop_blocks()` operation itself did not "complete".
2025-11-07 13:21:00 -06:00
tobtoht fc6170a1f7 Merge pull request #10156
0fc5e87 cryptonote_core: rm confusing/redundant BP consensus rule (jeffro256)
2025-10-27 18:47:58 +00:00
jeffro256 a863bf7095 BlockchainDB: rm skip_coinbase in get_blocks_from()
Parameter `skip_coinbase` was always set to `true`, and didn't actually skip the coinbase transactions. The method broke when set to `false`.

Noticed by @akildemir
2025-10-13 16:03:44 -05:00
j-berman 4a2d6eb3da Daemon RPC: getblocks.bin block_ids_exclusive req param
When the request includes block_ids, the daemon uses
find_blockchain_supplement to identify the highest block hash
passed in block_ids that the daemon also knows about, and then
serves subsequent blocks contiguous to that block.

When block_ids_skip_exclusive is false (default current
behavior), the daemon includes the highest block requested in the
response, in addition to contiguous blocks after it.

When block_ids_skip_exclusive is true (new param), the daemon
serves blocks starting from the block 1 higher than the highest
known block included in block_ids. Thus, the daemon skips the
common block known to the client and daemon. Clients can make sure
the daemon is serving expected contiguous blocks to its highest
known block by checking the first block's prev_id included in the
response, and making sure it is equivalent to the block the client
already knows about that was included in block_ids. This avoids
the daemon serving 1 extra block it does not need to serve to the
client, since the client should already know about that block.

bl
2025-10-10 01:21:52 -07:00
jeffro256 0fc5e87f2c cryptonote_core: rm confusing/redundant BP consensus rule
This rule is confusing/redundant because before v8, no
bulletproofs whatsoever were allowed. And during and after
v8, ONLY multi-output bulletproofs were allowed, i.e.
exactly 1 bulletproof is allowed which proves the range of
all amount commitments in the transaction.

Sources:
  * No BP before v8:
    - https://github.com/monero-project/monero/blob/d32b5bfe18e2f5b979fa8dc3a8966c76159ca722/src/cryptonote_core/blockchain.cpp#L3021-L3032
  * Only 1 BP allowed:
    - https://github.com/monero-project/monero/blob/d32b5bfe18e2f5b979fa8dc3a8966c76159ca722/src/cryptonote_basic/cryptonote_format_utils.cpp#L174
    - https://github.com/monero-project/monero/blob/d32b5bfe18e2f5b979fa8dc3a8966c76159ca722/src/cryptonote_basic/cryptonote_format_utils.cpp#L150
  * BP must cover all outputs:
    - https://github.com/monero-project/monero/blob/d32b5bfe18e2f5b979fa8dc3a8966c76159ca722/src/cryptonote_basic/cryptonote_format_utils.cpp#L190-L194
    - https://github.com/monero-project/monero/blob/d32b5bfe18e2f5b979fa8dc3a8966c76159ca722/src/cryptonote_basic/cryptonote_format_utils.cpp#L166-L170
2025-10-09 15:57:54 -05:00
luigi1111 a5aa602dce Merge pull request #10147
292c053 Cleaner validation (faster and saner) (j-berman)
2025-10-07 15:22:35 -04:00
luigi1111 df90240542 Merge pull request #10107
0fb4a8f src: update checkpoints to match v0.18.4.3 (selsta)
2025-10-07 15:17:44 -04:00
selsta 0fb4a8f9b1 src: update checkpoints to match v0.18.4.3 2025-10-07 16:37:18 +02:00