Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions gittensor/cli/issue_commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from gittensor.cli.issue_commands.tables import build_pr_table
from gittensor.cli.json_output import emit_error_json
from gittensor.constants import BASE_GITHUB_API_URL, MAX_ISSUE_ID, NETWORK_MAP
from gittensor.constants import ALPHA_DECIMALS, ALPHA_RAW_UNIT, BASE_GITHUB_API_URL, MAX_ISSUE_ID, NETWORK_MAP
from gittensor.validator.issue_competitions.storage_utils import (
ISSUES_MAPPING_ROOT_KEY,
compute_ink5_lazy_key,
Expand All @@ -36,8 +36,6 @@
CONFIG_FILE = GITTENSOR_DIR / 'config.json'

# ALPHA token conversion
ALPHA_DECIMALS = 9
ALPHA_RAW_UNIT = 10**ALPHA_DECIMALS
MIN_BOUNTY_ALPHA = 10
MAX_BOUNTY_ALPHA = 100_000_000
MAX_ISSUE_NUMBER = 2**32 - 1
Expand Down
4 changes: 4 additions & 0 deletions gittensor/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,7 @@
ISSUES_TREASURY_UID = 111 # UID of the smart contract neuron, if set to RECYCLE_UID then it's disabled
ISSUES_TREASURY_EMISSION_SHARE = 0.10 # % of emissions allocated to funding issues treasury
MAX_ISSUE_ID = 1_000_000 # sanity-check upper bound for any real deployment

# Alpha token denomination (raw u64 → display): 1 α = 10^ALPHA_DECIMALS raw units.
ALPHA_DECIMALS = 9
ALPHA_RAW_UNIT = 10**ALPHA_DECIMALS
9 changes: 1 addition & 8 deletions gittensor/utils/github_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,6 @@ def get_github_identity(token: str) -> GitHubIdentityResult:
"""


def _resolve_pr_state(raw_state: str, merged: bool = False) -> str:
"""Normalize PR state to uppercase GraphQL-style values."""
if merged:
return 'MERGED'
return (raw_state or '').upper() or 'OPEN'


def _closing_issue_numbers_for_repo(closing_ref: Optional[Dict[str, Any]], repo: str) -> List[int]:
"""Return only closing issue numbers whose GraphQL repository matches ``repo``."""
target_repo = repo.lower()
Expand Down Expand Up @@ -269,7 +262,7 @@ def _search_issue_referencing_prs_graphql(
if not pr_number:
continue

state = _resolve_pr_state(pr.get('state', ''), merged=bool(pr.get('merged', False)))
state = 'MERGED' if pr.get('merged') else (pr.get('state') or '').upper() or 'OPEN'
if open_only and state != 'OPEN':
continue

Expand Down
4 changes: 2 additions & 2 deletions gittensor/validator/issue_competitions/contract_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from substrateinterface import Keypair
from substrateinterface.exceptions import ExtrinsicNotFound

from gittensor.constants import MAX_ISSUE_ID
from gittensor.constants import ALPHA_RAW_UNIT, MAX_ISSUE_ID
from gittensor.validator.issue_competitions.storage_utils import (
ISSUES_MAPPING_ROOT_KEY,
compute_ink5_lazy_key,
Expand Down Expand Up @@ -603,7 +603,7 @@ def get_treasury_stake(self) -> int:
# Extract integer part (upper 64 bits of U64F64)
stake_raw = bits >> 64 if bits else 0

bt.logging.debug(f'Treasury stake (direct query): {stake_raw} ({stake_raw / 1e9:.4f} α)')
bt.logging.debug(f'Treasury stake (direct query): {stake_raw} ({stake_raw / ALPHA_RAW_UNIT:.4f} α)')
return stake_raw

except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion gittensor/validator/issue_competitions/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import bittensor as bt

from gittensor.classes import MinerEvaluation
from gittensor.constants import ALPHA_RAW_UNIT
from gittensor.utils.github_api_tools import check_github_issue_closed
from gittensor.utils.utils import get_contract_address
from gittensor.validator.issue_competitions.contract_client import IssueCompetitionContractClient, IssueStatus
Expand Down Expand Up @@ -84,7 +85,7 @@ async def issue_competitions(
errors = []

for issue in active_issues:
bounty_display = issue.bounty_amount / 1e9
bounty_display = issue.bounty_amount / ALPHA_RAW_UNIT
issue_label = (
f'{issue.repository_full_name}#{issue.issue_number} (id={issue.id}, bounty={bounty_display:.2f} ALPHA)'
)
Expand Down