Skip to content

docs(subtensor): fix stale faucet() docstring + remove dead cfg branch#2600

Open
ArtificialXai wants to merge 1 commit intoopentensor:mainfrom
ArtificialXai:artificialxai/faucet-docstring-accuracy
Open

docs(subtensor): fix stale faucet() docstring + remove dead cfg branch#2600
ArtificialXai wants to merge 1 commit intoopentensor:mainfrom
ArtificialXai:artificialxai/faucet-docstring-accuracy

Conversation

@ArtificialXai
Copy link
Copy Markdown

Closes #2591.

Context

The faucet() dispatchable in pallets/subtensor/src/macros/dispatches.rs carries this docstring:

/// Facility extrinsic for user to get taken from faucet
/// It is only available when pow-faucet feature enabled
/// Just deployed in testnet and devnet for testing purpose

The last line is stale. The call is #[cfg(feature = \"pow-faucet\")]-gated, and the pow-faucet feature is only enabled in the local_builder Docker stage (Dockerfile L86). The public testnet and devnet runtimes are built without it, so the dispatchable is absent from the on-chain Call enum on both networks (per the metadata evidence in #2591). Downstream tooling that trusts the docstring builds a working PoW pipeline only to fail at submission time with a pallet-call-not-found error.

Changes

  1. Docstring rewrite — replaces the stale last line with an explicit note that the call is only compiled into runtimes built with --features pow-faucet, that the public testnet/devnet images do not include it, and that it is intended for local development runtimes.

  2. Dead-code removal inside the function body:

    // before
    pub fn faucet(...) -> DispatchResult {
        if cfg!(feature = \"pow-faucet\") {
            return Self::do_faucet(origin, block_number, nonce, work);
        }
        Err(Error::<T>::FaucetDisabled.into())
    }

    The function is already #[cfg(feature = \"pow-faucet\")] at the item level, so cfg!(feature = \"pow-faucet\") inside the body is unconditionally true and the Err arm is unreachable. Simplified to a direct Self::do_faucet(...) call.

    FaucetDisabled is left in Error<T> for backward compatibility — it is also referenced by a commented-out guard in subnets/registration.rs and removing it could break downstream error-decoding clients.

Behavioral impact

None. Builds without pow-faucet don't see the dispatchable; builds with it exercise the same Self::do_faucet(...) path that was always reached. #[pallet::call_index(60)] and the weight attribute are preserved, so on-chain extrinsic compatibility is unchanged.

Out of scope

Option (b) from #2591 (enabling pow-faucet on the testnet Docker build) is not addressed here — that's a policy call about whether the public testnet runtime should ship a dispatchable that mints TAO, and the filer explicitly said either fix is acceptable. Happy to follow up in a separate PR if maintainers want to restore the historical btcli wallet faucet UX against testnet.

Closes opentensor#2591.

The `faucet()` dispatchable in `pallets/subtensor/src/macros/dispatches.rs`
carries a docstring that states:

    /// Just deployed in testnet and devnet for testing purpose

This is no longer accurate. The call is gated behind
`#[cfg(feature = "pow-faucet")]`, and the `pow-faucet` feature is only
enabled in the `local_builder` Docker stage (`Dockerfile` L86). The
public testnet and devnet runtimes are built without that feature, so
the dispatchable is genuinely absent from the on-chain `Call` enum on
both networks. Downstream tooling that trusts the docstring builds a
working PoW pipeline only to fail at submission time with a
`pallet-call-not-found` error (the issue cites a concrete instance in
`ErgodicLabs/btt` where the faucet command had to be reverted after the
docstring sent reviewers in the wrong direction).

Replaces the docstring with an accurate description of when the call
is compiled in, and explicitly notes that the public testnet/devnet
images do not include it.

While here, remove the `if cfg!(feature = "pow-faucet") { ... } else {
Err(FaucetDisabled) }` wrapper inside the function body: the function
is already `#[cfg(feature = "pow-faucet")]` at the item level, so the
`cfg!` check is unconditionally true and the `Err` arm is unreachable.
`FaucetDisabled` remains defined in `Error<T>` for backward-compatible
error handling (also referenced in a commented-out guard in
`subnets/registration.rs`).

No behavioral change: builds without `pow-faucet` are unaffected (the
dispatchable does not exist in the `Call` enum); builds with the
feature flag behave identically since the only reachable path was
always `Self::do_faucet(...)`. The `pallet::call_index(60)` and weight
attribute are preserved, so on-chain extrinsic compatibility is
unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docstring: pallets/subtensor/src/macros/dispatches.rs faucet() claims testnet deployment but is cfg-gated behind pow-faucet feature

1 participant