Skip to content

cuprated: auto config docs #418

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

Merged
merged 7 commits into from
Apr 5, 2025
Merged

cuprated: auto config docs #418

merged 7 commits into from
Apr 5, 2025

Conversation

Boog900
Copy link
Member

@Boog900 Boog900 commented Mar 22, 2025

What

closes #409

Adds a macro that generates toml comments from the doc comments.

Why

So we don't need to duplicate doc text.

Example output:

#     ____                      _
#    / ___|   _ _ __  _ __ __ _| |_ ___
#   | |  | | | | '_ \| '__/ _` | __/ _ \
#   | |__| |_| | |_) | | | (_| | ||  __/
#    \____\__,_| .__/|_|  \__,_|\__\___|
#              |_|
#
# All these config values can be set to their default by commenting them out with #.
# Some values are already commented out, to set the value remove the # at the start of the line.

## The network we should run on.
##
## Valid values: "Mainnet", "Testnet" and "Stagenet".
network = "Mainnet"
## Enable/disable fast sync.
##
## Fast sync skips verification of old blocks by comparing block hashes to a built-in hash file,
## disabling this will significantly increase sync time. New blocks are still fully validated.
fast_sync = true

## The stdout logging config.
[tracing.stdout]
## The default minimum log level.
level = "info"

## The file logging config.
[tracing.file]
## The default minimum log level.
level = "debug"
## The maximum amount of log files to keep, once this number is passed the oldest file
## will be deleted.
max_log_files = 7

## The [`tokio`] config.
##
## Tokio is the async threadpool, used for network operations and the major service inside `cuprated`.
[tokio]
## The amount of threads to spawn for the async thread-pool
#threads = 12

## The [`rayon`] config.
##
## Rayon is the CPU threadpool, used for CPU intensive tasks.
[rayon]
## The number of threads to use for the [`rayon::ThreadPool`].
#threads = 12

## The clear-net P2P config.
[p2p.clear_net]
## The IP address we should bind to to listen to connections on.
listen_on = "0.0.0.0"
## The number of outbound connections to make and try keep.
##
## Recommended to keep this value above 12.
#outbound_connections = 64
## The amount of extra connections we can make if we are under load from the rest of Cuprate.
#extra_outbound_connections = 8
## The maximum amount of inbound connections we should allow.
#max_inbound_connections = 128
## The percent of connections that should be to peers we haven't connected to before.
#gray_peers_percent = 0.7
## port to use to accept p2p connections.
##
## Set to 0 if you do not want to accept P2P connections.
p2p_port = 18080

## The address book config.
[p2p.clear_net.address_book_config]
## The size of the white peer list.
##
## The white list holds peers we have connected to before.
max_white_list_length = 1000
## The size of the gray peer list.
##
## The gray peer list holds peers we have been told about but not connected to ourself.
max_gray_list_length = 5000
## The time period between address book saves.
peer_save_period = { secs = 90, nanos = 0 }

## Block downloader config.
##
## The block downloader handles downloading old blocks from peers when we are behind.
[p2p.block_downloader]
## The size in bytes of the buffer between the block downloader and the place which
## is consuming the downloaded blocks (`cuprated`).
##
## This value is an absolute maximum, once this is reached the block downloader will pause.
#buffer_bytes = 1000000000
## The size of the in progress queue (in bytes) at which we stop requesting more blocks.
##
## The value is _NOT_ an absolute maximum, the in progress queue could get much larger. This value
## is only the value we stop requesting more blocks, if we still have requests in progress we will
## still accept the response and add the blocks to the queue.
#in_progress_queue_bytes = 500000000
## The target size of a single batch of blocks (in bytes).
##
## This value must be below 100_000_000, it is not recommended to set it above 30_000_000.
#target_batch_bytes = 10000000
## The [`Duration`] between checking the client pool for free peers.
check_client_pool_interval = { secs = 30, nanos = 0 }

## The storage config.
[storage]
## The amount of reader threads to spawn for the tx-pool and blockchain.
##
## The tx-pool and blockchain both share a single threadpool.
#reader_threads = 4

## The tx-pool config.
[storage.txpool]
## The [`SyncMode`] of the database.
##
## Changing this value could make the DB a lot slower when writing data, although
## using "Safe" makes the DB more durable if there was an unexpected crash.
##
## Valid values: ["Fast", "Safe"].
#sync_mode = "Fast"
## The maximum size of the tx-pool.
max_txpool_byte_size = 100000000

## The blockchain config.
[storage.blockchain]
## The [`SyncMode`] of the database.
##
## Changing this value could make the DB a lot slower when writing data, although
## using "Safe" makes the DB more durable if there was an unexpected crash.
##
## Valid values: ["Fast", "Safe"].
#sync_mode = "Fast"

## The filesystem config.
[fs]
## The data directory.
#data_directory = "/home/user/.local/share/cuprate"
## The cache directory.
#cache_directory = "/home/user/.cache/cuprate"

@github-actions github-actions bot added 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. A-binaries Area: Related to binaries. labels Mar 22, 2025
@Boog900 Boog900 marked this pull request as ready for review March 23, 2025 20:25
@Boog900
Copy link
Member Author

Boog900 commented Mar 23, 2025

@hinto-janai this is pretty much ready, just one question, what do you think we should do with the config folder. This PR would remove the need for per release files, as it is generated at runtime instead of having a static example config.

Part of me thinks we should keep them for testing backwards compatibility, just wanted to ask if you had a preference before I do anymore.

Copy link
Contributor

@hinto-janai hinto-janai left a comment

Choose a reason for hiding this comment

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

what do you think we should do with the config folder. This PR would remove the need for per release files

Having a linkable/copyable default config is still desired for reasons I mentioned before, and yeah for backwards testing compat too.

@github-actions github-actions bot added A-docs Area: Related to documentation. A-books Area: Related to Cuprate's books. A-book-user Area: Related to the User book. labels Mar 29, 2025
@Boog900 Boog900 requested a review from hinto-janai April 2, 2025 15:39
Copy link
Contributor

@hinto-janai hinto-janai left a comment

Choose a reason for hiding this comment

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

Automation is great, thanks for this.

Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
@Boog900 Boog900 merged commit 03363e3 into main Apr 5, 2025
7 of 12 checks passed
@Boog900 Boog900 deleted the doc-config branch April 5, 2025 14:34
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-book-user Area: Related to the User book. A-books Area: Related to Cuprate's books. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-docs Area: Related to documentation. 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.

Configure directories for data & cache
2 participants