Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate Subtensor signed extension error codes in BTCLI & BTSDK #2163

Closed
thewhaleking opened this issue Jul 23, 2024 · 0 comments
Closed

Comments

@thewhaleking
Copy link
Contributor

thewhaleking commented Jul 23, 2024

Task

As part of the BTCLI redesign, we would like to improve the user experience by providing relevant and meaningful error messages to the user. We should translate error codes from signed extensions from Subtensor into a meaningful message that is relevant for the user request.

Error code mappings

These error code mappings were provided by Nucleus team:

Custom Error Variants in Subtensor Signed Extension

This document describes the custom error variants used in the subtensor signed extension. The errors are presented to the user in the following format:

{'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: [Error Code]'}.

Custom error: 1

Description: The account (who) attempting the commit_weights call does not meet the minimum stake requirement for weights.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 1'}

Custom error: 2

Description: The account (who) attempting the reveal_weights call does not meet the minimum stake requirement for weights.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 2'}

Custom error: 3

Description: The account (who) attempting the set_weights call does not meet the minimum stake requirement for weights.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 3'}

Custom error: 4

Description: The hotkey account passed to the set_root_weights call does not meet the minimum stake requirement for weights.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 4'}

Custom error: 5

Description: The number of registrations for the current interval exceeds the maximum allowed for the given netuid. This applies to the register and burned_register calls.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 5'}

6 & 7 no longer needed

These were related to the hack and coldkey arbitration which is no longer required.

Custom error: 6
Description: An account (who) under arbitration is attempting to call dissolve_network.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 6'}

Custom error: 7
Description: The account (who) is attempting a balance transfer (either transfer_allow_death, transfer_keep_alive, or transfer_all) while under arbitration.

  • Error from Subtensor: {'code': 1010, 'message': 'Invalid Transaction', 'data': 'Custom error: 7'}

Background

The Subtensor signed extension contains the logic for handling incoming extrinsics before the enter the pool. When we handle these in the signed extension, substrate requires that we return a TransactionValidity which is defined as

pub type TransactionValidity = Result<ValidTransaction, TransactionValidityError>

Since the TransactionValidityError type is implemented by substrate Nucleus team are not able to implement any additional variants this way. This is the original reasoning behind returning the generic errors, like Nucleus do now, from the signed extension.

There exists a custom variant of the TransactionValidityError which takes a u8 which we can use to provide error codes to BTCLI / BTSDK.

The signed extension basically filters incoming extrinsics before they enter the transaction pool. After the extrinsics enter the pool they are executed. If the extrinsic fails during execution it will return an error from our errors.rs. If it is filtered before entering the pool it will return TransactionValidityError with an error code.

Subtensor related changes

Custom Errors for Signed Extensions (PR #700)
Technical Change: Added labels to signed extension errors.
Impact: Improved error handling and debugging capabilities.
Action Required: CLI team needs to implement decoding for these new error labels.
User-Facing: Yes
URL: opentensor/subtensor#700

Related Discord discussions

https://discord.com/channels/799672011265015819/1263701469110992989
https://discord.com/channels/799672011265015819/1267904639748280381

@arslan-ot arslan-ot changed the title Meaningful error messages in BTCLI Decode TransactionValidationError messages in BTCLI Aug 8, 2024
@arslan-ot arslan-ot changed the title Decode TransactionValidationError messages in BTCLI Decode TransactionValidityError messages in BTCLI Aug 8, 2024
@arslan-ot arslan-ot changed the title Decode TransactionValidityError messages in BTCLI Translate Subtensor signed extension error codes in BTCLI & BTSDK Aug 12, 2024
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

No branches or pull requests

1 participant