Skip to main content

bt_ddos_shield_client

Validator-side client package for BT DDoS Shield.

The package resolves shielded miner endpoints from miner manifests and mutates validator-side neuron or metagraph data only when a miner publishes a valid encrypted entry for the validator hotkey.

Install

The base client supports Python 3.11 through 3.14.

pip install bt-ddos-shield-client

Install optional turbobt support with:

pip install "bt-ddos-shield-client[turbobt]"

The optional turbobt extra is currently limited to Python 3.11 through 3.13 because upstream turbobt depends on eciespy, which pulls coincurve.

Public API

  • bt_ddos_shield_client.ShieldMetagraph
  • bt_ddos_shield_client.ShieldTestRig
  • bt_ddos_shield_client.shielded_turbobt.ShieldedNeuronMutator

Certificate Handling

The client uses an Ed25519 ECIES-compatible key pair stored as a validator shield certificate. The public key is uploaded to the subnet certificate field when the local certificate does not match the value already stored on chain.

Certificate path resolution:

  1. Use VALIDATOR_SHIELD_CERTIFICATE_PATH when the environment variable is set.
  2. Otherwise store the certificate next to the wallet hotkey file as <hotkey>.cert.pem, for example ~/.bittensor/wallets/validator/hotkeys/default.cert.pem.

When the certificate file does not exist, the client creates it automatically.

ShieldMetagraph

Use ShieldMetagraph as the validator-side replacement for bittensor.core.metagraph.Metagraph:

from bt_ddos_shield_client import ShieldMetagraph

metagraph = ShieldMetagraph(wallet, netuid, subtensor=subtensor)

Constructor arguments mirror the common Bittensor metagraph flow:

ShieldMetagraph(
    wallet,
    netuid,
    network=None,
    lite=True,
    sync=True,
    block=None,
    subtensor=None,
)

On sync(), the client:

  1. syncs the underlying Bittensor metagraph through the package contact layer;
  2. ensures the validator's public certificate is present on chain;
  3. fetches each miner manifest from http://{axon_ip}:{axon_port}/shield_manifest.json;
  4. decrypts the manifest entry for the validator hotkey and miner hotkey;
  5. replaces the miner axon IP and port when the shield address is valid.

Fetch failures, redirects that fail, malformed manifests, missing entries, decryption failures, and invalid shield address strings leave that miner's original axon endpoint unchanged.

turbobt Integration

Use ShieldedNeuronMutator when validator code works with turbobt neurons:

from bt_ddos_shield_client.shielded_turbobt import ShieldedNeuronMutator

mutator = ShieldedNeuronMutator(
    wallet=wallet,
    netuid=netuid,
)

neurons = await bittensor.subnet(netuid).list_neurons()
await mutator.mutate_neurons(bittensor, neurons)

The mutator performs the same certificate reconciliation and manifest resolution as ShieldMetagraph, then updates each matching neuron's axon_info.ip and axon_info.port.

Testing Helpers

ShieldTestRig installs public-boundary fakes for downstream validator tests. It patches the package contact factories and mocks miner manifest HTTP responses while keeping certificate generation, manifest serialization, encryption, and address parsing real.

from bt_ddos_shield_client import ShieldTestRig

rig = ShieldTestRig(wallet=wallet)
rig.add_miner("miner-a", "198.51.100.10", 8080, shield_address="203.0.113.10:3030")
rig.add_miner("miner-b", "198.51.100.11", 8080, shield_address=None)

with rig.install():
    run_validator_code()

Enable turbobt test support explicitly:

rig = ShieldTestRig(wallet=wallet, with_turbobt=True)

shield_address=None makes the fixture return a missing manifest for that miner, so downstream tests can cover unshielded miners.

Tests

Run the default client test suite across every supported Python version from this directory:

uv tool run nox

Run one Python version with:

uv tool run nox -s tests-3.12

Pass pytest arguments after --:

uv tool run nox -s tests-3.12 -- tests/library -v

For a quick run against the current uv environment, use:

uv run --group test pytest tests -v

Default tests cover the public package boundary:

  • ShieldMetagraph
  • ShieldedNeuronMutator
  • certificate upload behavior through contact fakes
  • manifest fetching through aioresponses
  • downstream-facing ShieldTestRig behavior

Docker-backed real contact integration tests live under tests/contacts and are marked with subtensor_integration, so they are excluded by the default pytest configuration.

Run them explicitly with:

uv run --group test pytest tests/contacts -m subtensor_integration -v

The integration tests start a disposable local subtensor container, create test wallets and subnet state, and exercise the real BittensorSubtensorContact and TurboBittensorSubtensorContact public methods. They do not depend on manual_tests/.

The tests follow the active Docker context. SSH-based Docker contexts require paramiko, which is included in the test dependency group.

Metadata

Release files for bt-ddos-shield-client 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bt-ddos-shield-client 0.4.3
File Size Uploaded
bt_ddos_shield_client-0.4.3.tar.gz 28.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bt-ddos-shield-client 0.4.3
File Interpreter ABI Platform
bt_ddos_shield_client-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / bt_ddos_shield_client-0.4.3.tar.gz

Download URL bt_ddos_shield_client-0.4.3.tar.gz
Size 28.2 kB
Tags Source
SHA-256 checksum
How to use checksums
92c55eccf15674cb4a4322f7fda0a596549f115f883bb38131043b2198a7a47e
BLAKE2b-256 checksum
How to use checksums
4084a73db3e40cb5331ee9a94cf70e18823a2ef09c7436739951da7b40ed1153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 28, 2026.

Transparency log

Release files / bt_ddos_shield_client-0.4.3-py3-none-any.whl

Download URL bt_ddos_shield_client-0.4.3-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a2774475a29c0fb84404efb1d54a688b4bf9d4119aef03cf2a82da0d8253f3a
BLAKE2b-256 checksum
How to use checksums
e984ec616cebe8c5635485151d2ef71899430bb21a1a606477b264cb5dc56f69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page