Skip to content

Builder::data_dir has been a no-op since 0.2.0 #600

Description

@0xsiddharthks

Issue

Builder::data_dir accepts a path and documents it as the directory "where data should be stored", but nothing reads it. Node::new destructures the config and discards the field:

let Config {
    required_peers,
    white_list,
    whitelist_only,
    data_path: _,   // <-- src/node.rs
    chain_state,
    ...

Tracing it back, this looks vestigial rather than broken. 0.2.0 removed rusqlite "along with the underlying header and peer stores" and introduced ChainState on the builder in the same release, so consumer-supplied state replaced the internal stores by design. data_dir just outlived that change with its original doc comment. I confirmed the field is discarded identically in 0.5.0, 0.6.0 and 0.6.3.

The reason it is worth fixing rather than ignoring: the method reads as an opt-in to persistence, so it is easy to call it and assume chain data survives a Node rebuild. We did exactly that. Our supervisor rebuilds the node when it loses its peers, and because ChainState::Checkpoint rebuilds the block tree from the checkpoint alone, each rebuild re-syncs the entire range from that anchor. We had a data_dir configured the whole time and it did nothing.

Possible resolutions:

  • Remove Builder::data_dir (and Config::data_path) as part of a breaking release.
  • Keep it and mark it #[deprecated] with a note pointing at ChainState.

Happy to send a PR for any of these if useful.

Context on what I was doing:

we use ChainState::Checkpoint with an anchor resolved from a trusted Bitcoin Core node, because the header chain is what independently validates block hashes that node reports to us. ChainState::Snapshot looked like the way to avoid the re-sync, but SyncUpdate::recent_history only carries the last ten headers, so restoring from it would move the anchor up to tip-10 and drop the range we still need to verify against. Not a request for anything, just noting why the data_dir path looked attractive to us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions