Skip to content

[WIP] Fallback Chains #2829

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

Closed
wants to merge 6 commits into from
Closed

Conversation

thewhaleking
Copy link
Contributor

@thewhaleking thewhaleking commented Apr 15, 2025

Resolves #2533

Requires opentensor/async-substrate-interface#96

Currently Proof of concept for fallback networks. Not tested or working with Async. Not perfect with sync.

@basfroman
Copy link
Contributor

basfroman commented Apr 19, 2025

RetrySubstrate class should be implemented in async-substrate-interface package as it is a wrapper for Async/SubstrateInterface classes.
Also, I'd implemented new class like

from dataclasses import dataclass

@dataclass()
class RetrySubstrateArgs:
    main_endpoint: str  # initial endpoint
    fallback_chains: list[str]  # endpoints for reconnection
    retry_attempts: int  # amount of connections before fail (if 0 then infinite)

Subtensor class will accept some new argument. For example:

safety_substrate: Optional["RetrySubstrateArgs"] = None`

for __init__() and from this will decide something like

if safety_substrate and is_instance(safety_substrate, RetrySubstrateArgs):
  self.substrate = RetrySubstrate(..., safety_substrate: "RetrySubstrateArgs" = safety_substrate)
else:
  self.substrate = SubstrateInterface(...)

Since the use of safety_substrate is optional, it is OK to have a combined argument instead of a primitive. In this case, the user decides which option suits him better, SDK does not contain any non-native logic, everything is implemented cleanly and in Python style. Also, SDK does not need to constantly monitor changes of Async/SubstrateInterface classes.

Let's move logic RetrySubstrate from SDK to async-substrate-interface.
Only 1 argument and 1 if condition for its processing will be added to the Async/Subtensor class. (small changes)

@thewhaleking
Copy link
Contributor Author

RetrySubstrate class should be implemented in async-substrate-interface package as it is a wrapper for Async/SubstrateInterface classes. Also, I'd implemented new class like

from dataclasses import dataclass

@dataclass()
class RetrySubstrateArgs:
    main_endpoint: str  # initial endpoint
    fallback_chains: list[str]  # endpoints for reconnection
    retry_attempts: int  # amount of connections before fail (if 0 then infinite)

Subtensor class will accept some new argument. For example:

safety_substrate: Optional["RetrySubstrateArgs"] = None`

for __init__() and from this will decide something like

if safety_substrate and is_instance(safety_substrate, RetrySubstrateArgs):
  self.substrate = RetrySubstrate(..., safety_substrate: "RetrySubstrateArgs" = safety_substrate)
else:
  self.substrate = SubstrateInterface(...)

Since the use of safety_substrate is optional, it is OK to have a combined argument instead of a primitive. In this case, the user decides which option suits him better, SDK does not contain any non-native logic, everything is implemented cleanly and in Python style. Also, SDK does not need to constantly monitor changes of Async/SubstrateInterface classes.

Let's move logic RetrySubstrate from SDK to async-substrate-interface. Only 1 argument and 1 if condition for its processing will be added to the Async/Subtensor class. (small changes)

Will move majority of that logic to opentensor/async-substrate-interface#100

@thewhaleking
Copy link
Contributor Author

Moved the entire thing to opentensor/async-substrate-interface#100

@thewhaleking thewhaleking deleted the feat/thewhaleking/retry-chains branch May 6, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants