-
Notifications
You must be signed in to change notification settings - Fork 4
feat!: initial sdk release #4
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: Publish to crates.io | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish bittensor-rs | ||
| runs-on: ubuntu-latest | ||
| # Only run if this is a bittensor-rs release | ||
| if: startsWith(github.event.release.tag_name, 'bittensor-rs-v') | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-action@stable | ||
| with: | ||
| components: rustfmt, clippy | ||
|
|
||
| - name: Install protoc | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y protobuf-compiler | ||
|
|
||
| - name: Cache cargo registry | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| target | ||
| key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo-publish- | ||
|
|
||
| - name: Verify package | ||
| working-directory: bittensor-rs | ||
| run: | | ||
| cargo publish --dry-run | ||
|
|
||
| - name: Publish to crates.io | ||
| working-directory: bittensor-rs | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
| run: | | ||
| cargo publish --no-verify | ||
|
|
||
| # Notify on failure | ||
| notify-failure: | ||
| name: Notify on Failure | ||
| runs-on: ubuntu-latest | ||
| needs: publish | ||
| if: failure() | ||
| steps: | ||
| - name: Create issue on failure | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `Failed to publish ${context.payload.release.tag_name} to crates.io`, | ||
| body: `The publish workflow failed for release ${context.payload.release.tag_name}.\n\nPlease check the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`, | ||
| labels: ['bug', 'ci'] | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Release Please | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| release-please: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| release_created: ${{ steps.release.outputs.release_created }} | ||
| tag_name: ${{ steps.release.outputs.tag_name }} | ||
| bittensor-rs--release_created: ${{ steps.release.outputs['bittensor-rs--release_created'] }} | ||
| steps: | ||
| - uses: googleapis/release-please-action@v4 | ||
| id: release | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| config-file: release-please-config.json | ||
| manifest-file: .release-please-manifest.json | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "bittensor-rs": "0.1.0" | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # Bittensor Rust SDK | ||
|
|
||
| [](https://github.com/one-covenant/bittensor-rs/actions) | ||
| [](https://opensource.org/licenses/MIT) | ||
|
|
||
| A collection of Rust crates for interacting with the [Bittensor](https://bittensor.com) blockchain network. | ||
|
|
||
| ## Workspace Structure | ||
|
|
||
| This monorepo contains the following crates: | ||
|
|
||
| | Crate | Description | Crates.io | | ||
| |-------|-------------|-----------| | ||
| | [`bittensor-rs`](./bittensor-rs) | Core SDK for Bittensor chain interactions | [](https://crates.io/crates/bittensor-rs) | | ||
| | [`bittensor-wallet`](./bittensor-wallet) | Wallet management with Python bindings | - | | ||
| | [`lightning-tensor`](./lightning-tensor) | Terminal UI for Bittensor | - | | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Using bittensor-rs | ||
|
|
||
| Add to your `Cargo.toml`: | ||
|
|
||
| ```toml | ||
| [dependencies] | ||
| bittensor-rs = "0.1" | ||
| ``` | ||
|
|
||
| ```rust | ||
| use bittensor::{config::BittensorConfig, Service}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| // Connect to Finney mainnet | ||
| let config = BittensorConfig::finney("my_wallet", "my_hotkey", 1); | ||
| let service = Service::new(config).await?; | ||
|
|
||
| // Query metagraph | ||
| let metagraph = service.get_metagraph(1).await?; | ||
| println!("Found {} neurons", metagraph.hotkeys.len()); | ||
|
|
||
| Ok(()) | ||
| } | ||
| ``` | ||
|
Comment on lines
+29
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Import path inconsistency with crate name. The example shows This inconsistency will cause compilation errors for users following the Quick Start guide. 🔎 Proposed fix-use bittensor::{config::BittensorConfig, Service};
+use bittensor_rs::{config::BittensorConfig, Service};🤖 Prompt for AI Agents |
||
|
|
||
| ## Development | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Rust 1.70 or later | ||
| - Protocol Buffers compiler (`protoc`) | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| # Build all crates | ||
| cargo build --workspace | ||
|
|
||
| # Build with all features | ||
| cargo build --workspace --all-features | ||
|
|
||
| # Run tests | ||
| cargo test --workspace | ||
|
|
||
| # Run specific crate tests | ||
| cargo test -p bittensor-rs | ||
| ``` | ||
|
|
||
| ### Using Just (Recommended) | ||
|
|
||
| This project includes a [justfile](./justfile) for common tasks: | ||
|
|
||
| ```bash | ||
| # Install just: https://github.com/casey/just | ||
| cargo install just | ||
|
|
||
| # See available commands | ||
| just --list | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [bittensor-rs API docs](https://docs.rs/bittensor-rs) - Full API documentation on docs.rs | ||
| - [bittensor-wallet README](./bittensor-wallet/README.md) - Wallet crate documentation | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions are welcome! Please follow these guidelines: | ||
|
|
||
| 1. **Conventional Commits**: Use [conventional commit](https://www.conventionalcommits.org/) format: | ||
| - `feat: add new feature` | ||
| - `fix: resolve bug` | ||
| - `docs: update documentation` | ||
| - `chore: maintenance task` | ||
|
|
||
| 2. **Pull Requests**: All changes should go through PR review | ||
|
|
||
| 3. **Testing**: Add tests for new functionality | ||
|
|
||
| ## Release Process | ||
|
|
||
| This repository uses [release-please](https://github.com/googleapis/release-please) for automated releases: | ||
|
|
||
| 1. Merge PRs with conventional commits to `main` | ||
| 2. Release-please automatically creates/updates a release PR with changelog | ||
| 3. Merge the release PR to trigger a GitHub release | ||
| 4. The publish workflow automatically publishes to crates.io | ||
|
|
||
| ## License | ||
|
|
||
| MIT License - see [LICENSE](LICENSE) for details. | ||
|
|
||
| ## Related Projects | ||
|
|
||
| - [Bittensor](https://github.com/opentensor/bittensor) - Python SDK and CLI | ||
| - [Subtensor](https://github.com/opentensor/subtensor) - Bittensor blockchain node | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [0.1.0] - Initial Release | ||
|
|
||
| ### Features | ||
|
|
||
| - **Connection Management** | ||
| - Connection pooling with configurable pool size | ||
| - Automatic health checks and connection monitoring | ||
| - Circuit breaker pattern for cascade failure prevention | ||
| - Exponential backoff retry logic with jitter | ||
|
|
||
| - **Chain Queries** | ||
| - `get_metagraph` / `get_selective_metagraph` - Subnet metagraph data | ||
| - `get_neuron` / `get_neuron_lite` - Neuron information | ||
| - `get_balance` / `get_stake` - Account balances and stake | ||
| - `get_subnet_info` / `get_subnet_hyperparameters` - Subnet configuration | ||
| - `get_total_subnets` / `subnet_exists` - Subnet enumeration | ||
|
|
||
| - **Extrinsics (Transactions)** | ||
| - Staking: `add_stake`, `remove_stake`, `delegate_stake`, `undelegate_stake` | ||
| - Weights: `set_weights`, `commit_weights`, `reveal_weights` | ||
| - Transfer: `transfer`, `transfer_keep_alive`, `transfer_all` | ||
| - Registration: `serve_axon`, `serve_prometheus`, `burned_register` | ||
| - Subnet: `register_network`, `set_subnet_identity` | ||
| - Children: `set_children`, `set_childkey_take`, `revoke_children` | ||
| - Root: `root_register`, `set_root_weights` | ||
|
|
||
| - **Wallet Management** | ||
| - Load wallets from Bittensor CLI format (`~/.bittensor/wallets`) | ||
| - Create wallets from mnemonic or hex seed | ||
| - Sign and verify messages | ||
| - Subxt-compatible signer for transactions | ||
|
|
||
| - **Error Handling** | ||
| - Comprehensive error types with categories | ||
| - Retry configuration per error category | ||
| - Detailed error messages with context | ||
|
|
||
| - **Configuration** | ||
| - Network presets: Finney, Testnet, Local | ||
| - Custom endpoint configuration | ||
| - Connection pool settings | ||
| - Read-only mode support | ||
|
|
||
| ### Dependencies | ||
|
|
||
| - `subxt` 0.44.0 for Substrate interactions | ||
| - `tokio` for async runtime | ||
| - `sp-core` / `sp-runtime` for cryptography | ||
|
|
||
| [Unreleased]: https://github.com/one-covenant/bittensor-rs/compare/bittensor-rs-v0.1.0...HEAD | ||
| [0.1.0]: https://github.com/one-covenant/bittensor-rs/releases/tag/bittensor-rs-v0.1.0 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 covenant.ai | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
dtolnay rust-toolchain github action💡 Result:
dtolnay/rust-toolchain is a concise GitHub Action that installs a Rust toolchain via rustup. Key points:
Sources:
[1] dtolnay/rust-toolchain (README & action.yml).
[2] GitHub Marketplace: Setup Rust Toolchain for GitHub CI (actions-rust-lang).
[3] dtolnay/rust-toolchain repository Actions page.
🌐 Web query:
dtolnay/rust-action github💡 Result:
You likely mean dtolnay/rust-toolchain — a concise GitHub Action that installs a Rust toolchain via rustup (usage: e.g. uses: dtolnay/rust-toolchain@stable). (github.com)
Citations:
🏁 Script executed:
Repository: one-covenant/bittensor-rs
Length of output: 226
Invalid GitHub Action reference - workflow will fail.
The action
dtolnay/rust-action@stabledoes not exist. The correct action isdtolnay/rust-toolchain@stable.🤖 Prompt for AI Agents