Skip to content

chore: document NodeConfig parameters #6000

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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

Jiloc
Copy link
Contributor

@Jiloc Jiloc commented Apr 8, 2025

Description

Add documentation for all NodeConfig paramters

Applicable issues

Additional info (benefits, drawbacks, caveats)

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo
  • New integration test(s) added to bitcoin-tests.yml

@Jiloc Jiloc requested a review from a team as a code owner April 8, 2025 19:00
@Jiloc Jiloc requested a review from wileyj April 8, 2025 19:06
@wileyj
Copy link
Collaborator

wileyj commented Apr 8, 2025

few minor nits, but overall this is a great start!

@obycode obycode self-requested a review April 9, 2025 14:46
@Jiloc Jiloc self-assigned this Apr 11, 2025
pub miner: bool,
/// Flag indicating whether this node is configured to operate with Stacker responsibilities,
/// such as participating in (PoX) by signaling support via StackerDB interactions.
/// Setting this to `true` requires also running a signer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting this to true is required if you are running a signer, but setting it to true does not require running a signer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed in e8cca43

Comment on lines 1729 to 1730
/// Flag indicating whether this node is configured to operate with Stacker responsibilities,
/// such as participating in (PoX) by signaling support via StackerDB interactions.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be more correct to say that setting this flag to true sets the node up to replicate the miner and signer Stacker DBs required for signing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed in e8cca43

Comment on lines 1735 to 1737
/// Enables a simulated mining mode, primarily for local testing and development.
/// When `true`, the node may generate blocks locally without participating in the real
/// burn chain consensus or P2P block production process.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add a note that miner must also be set to true to enable mock-mining.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed in e8cca43

pub wait_time_for_microblocks: u64,
/// Maximum time (in milliseconds) to wait between mining blocks.
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is related to mining after new blocks are seen in the network. I'm not quite sure what it should say though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed in e8cca43

@aldur aldur added this to the 3.1.0.0.9 milestone May 2, 2025
@aldur aldur moved this to Status: 💻 In Progress in Stacks Core Eng May 2, 2025
@aldur aldur moved this from Status: 💻 In Progress to Status: In Review in Stacks Core Eng May 2, 2025
@aldur aldur requested a review from obycode May 2, 2025 14:38
@aldur aldur modified the milestones: 3.1.0.0.9, 3.1.0.0.10 May 6, 2025
@aldur aldur requested a review from wileyj May 6, 2025 14:50
pub stacker: bool,
/// Enables a simulated mining mode, primarily for local testing and development.
/// When `true`, *and* [`NodeConfig::miner`] is also `true`, the node may generate blocks
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// When `true`, *and* [`NodeConfig::miner`] is also `true`, the node may generate blocks
/// When `true`, *and* [`node::miner`] is also `true`, the node may generate blocks

i'm not sure if we should document this using the function name vs the toml name of node

Copy link
Contributor

Choose a reason for hiding this comment

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

or maybe just "and miner is also true", since the context should be clear that it is referring to the above field.

Copy link
Contributor Author

@Jiloc Jiloc May 7, 2025

Choose a reason for hiding this comment

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

That's a really good point about how this will look in the config.toml!

So, the reason I went with [`NodeConfig::miner`] in the Rust comments is because it's super handy for us developers. cargo docs automatically generates links to the fields or even in the IDE and it jumps you straight to where miner is defined. But you're right, we definitely need to think about the final config.toml docs that users will see. Here’s what I’m thinking:

  • In the Rust code comments, let's stick to [`StructName::field_name`] everywhere. So, we'd always write [`NodeConfig::miner`] or [`BurnchainConfig::whatever`]. It's just one simple rule to follow.
  • Then, we'll need a sort of script for auto-generating the TOML docs from the Configs. The original idea was to have this script ingest directly the rustdoc output. When it's creating the docs for the NodeConfig struct and it sees [`NodeConfig::miner`], it'll just put miner in the TOML doc. Nice and clean for the TOML.

And if we reference something from another struct, say NodeConfig talks about [`BurnchainConfig::some_setting`], the script could turn that into something like [burnchain].some_setting (I am open to better suggestions for it though!) in the TOML. So it clearly points to the right spot in the TOML.

Basically, we keep the full [`StructName::field_name`] in the code for our own benefit (the links!). Then, the script takes care of making the final TOML documentation look good and easy to understand for anyone reading that.
This way, we get those useful developer links and clean TOML docs without having to write comments differently all the time.

What do you all think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining. Your plan sounds good to me!

Copy link
Contributor

Choose a reason for hiding this comment

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

In VS Code, I see that these link to the https://docs.rs site, not to the local definition. If that's the case, we should also make an effort to publish a crate so that our docs are available on https://docs.rs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Glad the plan sounds good! That's interesting about VS Code linking to docs.rs for you. On my setup, when I Ctrl+Click on a link like [`NodeConfig::miner`] directly within the code comments, VS Code with Rust Analyzer jumps directly to the local definition of miner within the NodeConfig struct in my workspace. But maybe I'm misunderstanding the specific context where you saw it?

Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

This looks good, I just had some minor comments.

I think these descriptive comments should also be added to the NodeConfigFile struct, since this would be the one that would be most important to extract into documentation for users. Maybe it is less important to document the default values on NodeConfig and more important to show that on NodeConfigFile, since it would be shown to users trying to understand the config file.

pub stacker: bool,
/// Enables a simulated mining mode, primarily for local testing and development.
/// When `true`, *and* [`NodeConfig::miner`] is also `true`, the node may generate blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

or maybe just "and miner is also true", since the context should be clear that it is referring to the above field.

pub mine_microblocks: bool,
/// How often to attempt producing microblocks, in milliseconds (pre-Nakamoto).
/// Only applies when `mine_microblocks` is true and before Epoch 3.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

Microblocks were disabled in 2.5 (See #4561). This applies to other mentions about 3.0 and microblocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the info! I didn't know, I just thought they were deprecated because of Nakamoto! Changed in 723f16e

///
/// Default value of 10 seconds is reasonable in mainnet (where bitcoin blocks are ~10 minutes),
/// but environments where burn blocks are more frequent may want to decrease this value.
/// Default: `10_000` (10 seconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make this consistent -- either include the (X seconds) on all of the ms parameters, or on none of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to all, 723f16e

@obycode
Copy link
Contributor

obycode commented May 7, 2025

I think these descriptive comments should also be added to the NodeConfigFile struct, since this would be the one that would be most important to extract into documentation for users. Maybe it is less important to document the default values on NodeConfig and more important to show that on NodeConfigFile, since it would be shown to users trying to understand the config file.

Per discussion in the Nakamoto sync, let's leave the comments as-is for now, and in a separate issue, we will work on merging the two versions of the config structs.

@Jiloc Jiloc requested a review from a team as a code owner May 7, 2025 21:50
@Jiloc
Copy link
Contributor Author

Jiloc commented May 7, 2025

I think these descriptive comments should also be added to the NodeConfigFile struct, since this would be the one that would be most important to extract into documentation for users. Maybe it is less important to document the default values on NodeConfig and more important to show that on NodeConfigFile, since it would be shown to users trying to understand the config file.

Per discussion in the Nakamoto sync, let's leave the comments as-is for now, and in a separate issue, we will work on merging the two versions of the config structs.

@obycode Unfortunately, I couldn't attend today's sync :( , but your first comment is interesting because I actually came to a similar conclusion about where the docs might best live. When I worked on ConnectionOptionsFile in PR #6062, I realized that documenting the *File struct directly made more sense for user-facing TOML documentation, especially since the internal ConnectionOptions struct had tens fields not exposed in the config file that didn't make any sense to document this way.

Given that, I'd be open to move the documentation to the *File structs now, I'm happy to make that change for this PR (and the other 2). It should be a quick refactor on my end. This would give us more user-focused docs in the short term.

Of course, I'm also perfectly fine sticking to the plan from the sync if that's preferred, and then we can address it all during the struct merge.

Either way, great idea merging the two struct versions in the long run. It'll definitely simplify things and make the config handling clearer. We'll just have to decine on a strategy for the internal-only fields, but that's for the future discussion.

@Jiloc
Copy link
Contributor Author

Jiloc commented May 9, 2025

I think these descriptive comments should also be added to the NodeConfigFile struct, since this would be the one that would be most important to extract into documentation for users. Maybe it is less important to document the default values on NodeConfig and more important to show that on NodeConfigFile, since it would be shown to users trying to understand the config file.

Per discussion in the Nakamoto sync, let's leave the comments as-is for now, and in a separate issue, we will work on merging the two versions of the config structs.

@obycode Unfortunately, I couldn't attend today's sync :( , but your first comment is interesting because I actually came to a similar conclusion about where the docs might best live. When I worked on ConnectionOptionsFile in PR #6062, I realized that documenting the *File struct directly made more sense for user-facing TOML documentation, especially since the internal ConnectionOptions struct had tens fields not exposed in the config file that didn't make any sense to document this way.

Given that, I'd be open to move the documentation to the *File structs now, I'm happy to make that change for this PR (and the other 2). It should be a quick refactor on my end. This would give us more user-focused docs in the short term.

Of course, I'm also perfectly fine sticking to the plan from the sync if that's preferred, and then we can address it all during the struct merge.

Either way, great idea merging the two struct versions in the long run. It'll definitely simplify things and make the config handling clearer. We'll just have to decine on a strategy for the internal-only fields, but that's for the future discussion.

As per discussion in today's Naka sync, we'll keep the comments in the "non-file" structs, because the comments will be useful for the developers. We'll try to achieve the merging of the Config structs in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants