Skip to content

pruning: add pruning option - #681

Open
p4xxus wants to merge 48 commits into
Cuprate:mainfrom
p4xxus:pruning-support
Open

pruning: add pruning option#681
p4xxus wants to merge 48 commits into
Cuprate:mainfrom
p4xxus:pruning-support

Conversation

@p4xxus

@p4xxus p4xxus commented Aug 11, 2026

Copy link
Copy Markdown

What

Closes #657

  • a new metadata file stores the pruning seed, which is accessible via the db struct
  • a new db entry called prunable_tip contains the transactions of the top 5500 blocks by TxId to blob
  • if pruned:
    • new blocks are added in the prunable tip
    • retrieval of txs and blocks searches in this tip

Why

to use less space for a monero node

Where

  • DB: 2 new fields (prunable_tip (Keyspace) and metadata (Metadata)), updated prunable_blob to use optional tape for prunable part
  • config options
  • cli argument
  • adding and retrieving blocks as well as transactions
  • ContextCache
  • persited file structure: new metadata file containing pruning seed and db version (= 0)

How

  • a new metadata file stores the pruning seed
    • the seed is accessible via the db struct
    • it's populated via a config option in the config file or via a cli arg
  • if the metadata file says not prune but the config / cli arg says prune, create a random seed, add the top 5500 blocks to the prunable tip and delete the other tapes

incoming block:

  • if we prune:
    • only add the blob to the desired stripe
    • remove old txs in the prunable_tip so after adding the new blocks we're back to 5500 blocks
    • add the new blocks to the prunable_tip

retrieval of tx (read_prunable_tape):

  • if we prune:
    • if the tx is in the top 5500 blocks, look in the prunable_tip
    • otherwise, return NotFound error

I used Gemini Pro 3.1 to find bugs and general help. It was thoroughly reviewed though.

p4xxus and others added 27 commits July 26, 2026 19:48
if pruning selected:
- we fist look that file up -> if it doesn't exist, create a random pruning-stripe and insert the corresponding seed
- delete tape files for all other stripes

it doesn't compile yet, as the prunable_blob type has changed and I still need to do some work there
- passing pruning_seed to `TimedSyncedRequest`, which doesn't use 0 as the default anymore
- added `PruningSeed` as a `BlockChainRequest` and ..`Response`
…ouldn't retrieve the metadata if it already existed
- return [`BlockchainError::NotFound`] if it get's read (via [`BlockchainReadRequest`])
- basically ignore the pruned ones whenever we write (via [`BlockchainWriteRequest`])
* cuprated: add custom allocators

* default to jemalloc on musl

* add mimalloc-secure flag

* opt in jemalloc
* cuprated: Dockerfile

* enable Alpine in CI

the monerod from github is compiled with glibc, which doesnt work well on alpine due to it's usage of musl, even with gcompat

* update randomx-rs to a876ab6

* fix typo in alpine comment

* update randomx-rs to 76c2385

Fixes OpenBSD builds
* update repo for 0.1.0-preview

* update RPC docs

* fix minor doc errors

* include changelog

how did I forget

* fix download links
…te#663)

* cuprated: add p2p.clear_net.seed_nodes config option

Add a `seed_nodes` field to `ClearNetConfig`, appended to the network's
built-in seed list in `clearnet_p2p_config()`.

`Network::FakeChain` ships no built-in seeds, so a regtest or otherwise
isolated network currently has no way to bootstrap — the first node panics
in `connection_maintainer` with "No seed nodes available to get peers from".
This option lets such a network point its nodes at each other.

The field is commented out in the generated config and defaults to empty,
so behaviour on Mainnet/Testnet/Stagenet is unchanged.

Useful for regtest, integration testing, and private networks. Verified:
`cuprated --regtest` with `seed_nodes = ["<addr>"]` loads the value, dials
the configured address and completes a handshake.

* cuprated: add --seed-node argument

Adds a repeatable `--seed-node <IP:PORT>` argument that appends to
`p2p.clear_net.seed_nodes`, following the existing `--outbound-connections`
override pattern.

This makes a multi-node regtest reachable without writing a config file:

    cuprated --regtest --seed-node 127.0.0.1:18080

`apply_args` loses its `const` qualifier, as extending a `Vec` is not a
const operation.
- also added helper method for tx_id retrieval
- can/will be further optimized
…e not writing to the tip blocks if we're not pruned
- added function read_prunable_tape that reads the tape if it exists
- had to remove check if txs are correct, since it cannot retrieve the tx if it's pruned
- removed 2 db calls by just looking up the first value in the tip instead of calculating it
- it now deletes from the smallest tx upwards, instead of calculating and fetching the tx id from the db
- in order to sort correctly, big endianness of tx_id in prunable_tip is required
…e the tapes if we have them but are now pruning
@github-actions github-actions Bot added A-p2p Area: Related to P2P. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. labels Aug 11, 2026
@p4xxus
p4xxus marked this pull request as draft August 11, 2026 19:43

@Boog900 Boog900 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. The code looks great. This is only an initial review but I do have some suggestions.

Comment thread binaries/cuprated/src/config/storage.rs Outdated
Comment thread consensus/context/src/lib.rs Outdated
Comment thread consensus/context/src/task.rs Outdated
Comment thread p2p/p2p-core/src/client/request_handler.rs Outdated
Comment thread storage/blockchain/src/metadata.rs Outdated
Comment thread types/types/src/blockchain.rs Outdated
Comment thread storage/blockchain/src/service/write.rs Outdated
Comment thread storage/blockchain/src/ops/block.rs Outdated
Comment thread storage/blockchain/src/ops/block.rs Outdated
Comment thread storage/blockchain/src/ops/block.rs Outdated
p4xxus added 5 commits August 12, 2026 17:51
- adding tx to tip is part of `add_tx_info_to_dynamic_tables`
- removing from tip is part of `add_block_to_dynamic_tables`
- height to remove to is passed as a param to `add_block_to_dynamic_tables`
@p4xxus
p4xxus requested a review from Boog900 August 12, 2026 20:36
p4xxus added 5 commits August 14, 2026 18:30
…iate pruning:

- stripe indicies are indexed at 1 but I didn't do that
- now storing `Metadata` instead of just the `PruningSeed` in the db struct
- added logic for populating the `pruning_tip`
- generally some refactoring
- now passing it down from `launch` to the `CoreSvcService`
- stripe_idx wasn't correctly increased
- now correctly opening prunable_blobs
- created fn `add_blocks_to_dynamic_tables` to first remove tip and then do the rest
- changed `prunable_tip` from be to le bytes
@p4xxus
p4xxus marked this pull request as ready for review August 14, 2026 21:19
@github-actions github-actions Bot removed the A-consensus Area: Related to consensus. label Aug 15, 2026
p4xxus and others added 3 commits August 15, 2026 16:32
…re's nothing to read

thus fixed failing tests
This PR has some simplifications and bug fixes
@Boog900 Boog900 added this to the cuprated v0.1.0 preview 2 milestone Aug 20, 2026
@github-actions github-actions Bot added the A-consensus Area: Related to consensus. label Sep 3, 2026
@github-actions github-actions Bot removed the A-consensus Area: Related to consensus. label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-net Area: Related to networking. A-p2p Area: Related to P2P. A-pruning Area: Related to pruning. A-storage Area: Related to storage. A-types Area: Related to types. A-workspace Area: Changes to a root workspace file or general repo file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pruning for Cuprate

4 participants