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
3 changes: 1 addition & 2 deletions gittensor/cli/issue_commands/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def issues_submissions(
if pull_requests is None:
handle_exception(
as_json,
f'GitHub lookup failed for {repo_name}#{issue_number}; '
'submissions could not be determined. Please retry.',
f'GitHub lookup failed for {repo_name}#{issue_number}; submissions could not be determined. Please retry.',
'github_lookup_failed',
)

Expand Down
15 changes: 9 additions & 6 deletions gittensor/validator/issue_competitions/storage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
ISSUES_MAPPING_ROOT_KEY = '52789899'


def _decode_u128le(data: bytes, offset: int) -> int:
"""Decode a little-endian u128 (two u64 limbs) from ``data`` at ``offset``."""
lo, hi = struct.unpack_from('<QQ', data, offset)
return lo + (hi << 64)


@dataclass
class PackedContractStorage:
"""Decoded root packed storage layout for the issue competition contract."""
Expand Down Expand Up @@ -107,8 +113,7 @@ def decode_packed_contract_storage(data: bytes) -> Optional[PackedContractStorag
offset += 2
next_issue_id = struct.unpack_from('<Q', data, offset)[0]
offset += 8
alpha_pool_lo, alpha_pool_hi = struct.unpack_from('<QQ', data, offset)
alpha_pool = alpha_pool_lo + (alpha_pool_hi << 64)
alpha_pool = _decode_u128le(data, offset)
except (struct.error, IndexError) as e:
logger.debug('Failed to decode packed contract storage: %s', e)
return None
Expand Down Expand Up @@ -162,12 +167,10 @@ def decode_issue_from_storage(data: bytes) -> Optional[DecodedIssueStorage]:
issue_number = struct.unpack_from('<I', data, offset)[0]
offset += 4

bounty_lo, bounty_hi = struct.unpack_from('<QQ', data, offset)
bounty_amount = bounty_lo + (bounty_hi << 64)
bounty_amount = _decode_u128le(data, offset)
offset += 16

target_lo, target_hi = struct.unpack_from('<QQ', data, offset)
target_bounty = target_lo + (target_hi << 64)
target_bounty = _decode_u128le(data, offset)
offset += 16

status_byte = data[offset]
Expand Down
Loading