fix(cli): honor configured wallet/hotkey for vote/admin/harvest signing#1425
Open
statxc wants to merge 1 commit into
Open
fix(cli): honor configured wallet/hotkey for vote/admin/harvest signing#1425statxc wants to merge 1 commit into
statxc wants to merge 1 commit into
Conversation
anderdc
requested changes
Jun 1, 2026
Collaborator
anderdc
left a comment
There was a problem hiding this comment.
remove the tests, it's a simple fix
Vote, admin, and harvest commands constructed bt.Wallet(...) from raw Click defaults, so a user with a configured wallet/hotkey in ~/.gittensor/config.json could silently sign with the wrong key (vote/admin: default/default; harvest: validator/default) — only `issues register` honored config. Add a shared resolve_wallet_config() helper that applies the same priority order used for other config keys (entrius#1035, entrius#1200, entrius#1364): explicit CLI flags win, then config, then the command's own default. Explicit vs omitted is detected via Click's ParameterSource rather than comparing against "default", so harvest's non-"default" fallback (validator) is distinguishable from an explicit value and `--wallet default` still beats config. Wire it into the shared _make_contract_client() path (vote/admin) and harvest's inline wallet construction; harvest's displayed wallet now reflects the resolved key. `issues register` is left unchanged (already honors config).
b85abe1 to
4ec6c8d
Compare
Contributor
Author
|
Hi @anderdc how are you? I've removed all test. Thanks for the review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gitt config set wallet/hotkeywrites canonical keys to~/.gittensor/config.json,and
gitt issues registeralready honors them when wallet flags are omitted. Theother signed issue-contract write commands did not —
gitt vote *,gitt admin *,and
gitt harvestpassed their raw Click defaults straight intobt.Wallet(...), soa user with a configured wallet/hotkey could silently sign with the wrong key (or fail
because the command's fallback wallet doesn't exist) for irreversible on-chain actions.
This is the wallet/hotkey member of the CLI config-priority family already fixed for
adjacent keys in #1035, #1200, and #1364.
Closes #1424
Affected commands
Shared
_make_contract_client(...)path:gitt vote solution,gitt vote cancel,gitt admin cancel-issue,gitt admin payout-issue,gitt admin set-owner,gitt admin set-treasury,gitt admin add-vali,gitt admin remove-vali.Inline wallet construction:
gitt harvest.Fix
Adds a shared
resolve_wallet_config(...)helper applying the documented priority:--wallet-name/--wallet-hotkeyCLI flags win.~/.gittensor/config.jsonwallet/hotkeywhen the flag is omitted.Whether a flag was supplied is detected via Click's
ParameterSource, not a!= "default"comparison. This matters becausegitt harvestcarries a non-"default"fallback (
validator), so a value comparison would mistake that fallback for an explicitvalue and never consult config — and only a parameter-source check lets an explicit
--wallet defaultwin over config. A no-Click-context fallback (value comparison) keepsthe helper usable in direct unit calls.
Wired into:
_make_contract_client(...)— the shared vote/admin path (default/defaultfallback).gitt harvest— inline construction (validator/defaultfallback); the displayedWallet:line now reflects the resolved key.gitt issues registeris intentionally left unchanged — it already honors config and hasspecial
//Alicelocal-dev handling.Tests
New
TestWalletConfigResolutioncovering every scenario:wallet/hotkey--wallet default --hotkey defaultstill beats configdefault/defaultharvestwithout flags uses configuredwallet/hotkeyharvestwithout config preservesvalidator/defaultharvestexplicit flags winVerification
uv run pytest tests/→ 918 passed (+8 new)config.jsonfile-read path