Skip to content

feature/DAH-1286-subnet-integrate-collateral-contracts #436

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

Open
wants to merge 186 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
88a12a4
feat: integrate smart contract with debug feature flag, miner account…
Royalone94 May 14, 2025
cfe6494
fix: logging error when set weight
Royalone94 May 14, 2025
b138ce6
feat: update validator to get validator ethereum key from dotenv
Royalone94 May 16, 2025
64d8a4d
feat: deposit when add executor and reclaim when remove executor, add…
Royalone94 May 16, 2025
ebf3cff
feat: map validator ethereum address to hotkey on contract when run v…
Royalone94 May 16, 2025
5adf68a
chore: update miner README
Royalone94 May 16, 2025
d837e61
feat: raise error when ethereum address does not match deposited ethe…
Royalone94 May 16, 2025
c4e4bfa
fix: executor uuid is missing when remove executor
Royalone94 May 16, 2025
8f7a2c0
feat: allow deposit collateral even when there is db connection issue
Royalone94 May 16, 2025
3acba34
feat: implement get eligible executors in miner cli
Royalone94 May 16, 2025
718f0b8
feat: get eth address from hot key method in miner cli
Royalone94 May 16, 2025
4764949
chore: modify miner_ethereum_key to eth_private_key in cli params
Royalone94 May 16, 2025
55f0d3c
chore: update README
Royalone94 May 16, 2025
fdf0831
feat: get miner address mapped to miner hotkey from collateral contra…
Royalone94 May 16, 2025
2f1cf3a
add exception handlers in collateral contract related methods on vali…
Royalone94 May 16, 2025
d1be5af
fix: add missing miner_hotkey in slash_collateral method usage in val…
Royalone94 May 16, 2025
24eb007
feat: add REQUIRED_TAO_COLLATERAL in config in validator
Royalone94 May 16, 2025
8e1506a
feat: update validator address on contract in miner cli switch_valida…
Royalone94 May 19, 2025
98a5378
feat: add deposit collateral command in miner cli
Royalone94 May 19, 2025
6c8e713
feat: update contract address on validator
Royalone94 May 19, 2025
705c0f7
feat: update get eligible executors command in miner cli
Royalone94 May 19, 2025
aebc3ae
chore: fix and optimize miner cli
Royalone94 May 19, 2025
5e0311d
feat: bump collateral contract versions
Royalone94 May 19, 2025
2980753
fix: mapping validator account hotkey is not working in validator
Royalone94 May 20, 2025
1b7537c
feat: fix add executor bug and update remove executor command in mine…
Royalone94 May 20, 2025
4e7f58d
feat: update handle_reclaim_requests method logs
Royalone94 May 20, 2025
d837949
feat: remove executor only when there is no collateral
Royalone94 May 20, 2025
6f9002c
chore: update log in remove executor command in miner cli
Royalone94 May 20, 2025
76f7458
feat: remove VALIDATOR_KEY in miner config
Royalone94 May 21, 2025
e86ef79
feat: embed ethereum private key in env instead of cli parameter in m…
Royalone94 May 22, 2025
85d334b
feat: remove mapping hotkey to ethereum address from contract
Royalone94 May 22, 2025
f007405
feat: include miner ethereum address information in ExecutorSSHInfo
Royalone94 May 22, 2025
90e7b94
feat: modify all contract code to asynchronous
Royalone94 May 22, 2025
f0e694a
feat: use ethereum address from ExecutorSSHInfo instead of mapHotkey …
Royalone94 May 22, 2025
c43bdc1
feat: implement get_collateral_contract method in validator utils
Royalone94 May 22, 2025
a545b84
feat: modify logs for contract methods in validator
Royalone94 May 22, 2025
e25d44f
feat: pass over ethereum address when send pubkeys to executor in miner
Royalone94 May 22, 2025
711dcac
feat: slash with executor collateral amount
Royalone94 May 22, 2025
1e4fcb2
fix: log in slash_collateral method in validator
Royalone94 May 22, 2025
c4c6f53
fix: several issues in miner cli after switch to localnet for testing
Royalone94 May 22, 2025
3ee2e8c
feat: add get executor collateral command in miner cli
Royalone94 May 23, 2025
cf4ede2
feat: send validator ethereum address in payload when connect to ws i…
Royalone94 May 23, 2025
64d5349
feat: implement get_collateral_contract method in utils in miner
Royalone94 May 23, 2025
b73d257
feat: configure contract address and network map for local, test, pro…
Royalone94 May 23, 2025
9d1f72a
chore: bump collateral contract version
Royalone94 May 23, 2025
6100dc6
bump contract version
Royalone94 May 27, 2025
35d31bf
feat: update contract addressees map
Royalone94 May 27, 2025
37cb599
feat: update get eligible executors command in miner cli
Royalone94 May 27, 2025
bbc4e1b
feat: DAH-1286 - update get_eth_address_from_hotkey function
LegendWorrier May 28, 2025
5b83f3b
Merge branch 'feature/DAH-1286-subnet-integrate-collateral-contracts'…
LegendWorrier May 28, 2025
1c8783f
feat: implement register eth address on validator
Royalone94 May 28, 2025
37cb83e
Merge branch 'main' into feature/DAH-1286-subnet-integrate-collateral…
Royalone94 May 28, 2025
f0889fa
fix: connection to backend issue in validator connector
Royalone94 May 28, 2025
a7b22c2
ffix: register ethereum address url
Royalone94 May 28, 2025
d59d04b
fix: get_eth_address_from_hotkey method to use correct url and modify…
Royalone94 May 28, 2025
a770086
fix merge conflict
Royalone94 May 28, 2025
efec488
fix: remove executor cli command
Royalone94 May 28, 2025
a9df58d
fix some config issues
pyon12 May 28, 2025
abcd654
Merge branch 'feature/DAH-1286-subnet-integrate-collateral-contracts'…
pyon12 May 28, 2025
ad953d1
fix: remove executor cli command
Royalone94 May 28, 2025
9da8d6a
Merge pull request #450 from Datura-ai/fix/DAH-1286-collateral-contract
Royalone94 May 28, 2025
4441730
fix: getting eligible executors
Royalone94 May 29, 2025
829102d
bump contract version and add testnet contract address in .env.template
Royalone94 May 29, 2025
eda19f7
chore: add missing COMPUTE_REST_API_URL .env.template
Royalone94 May 29, 2025
8bdfb7d
update cli
pyon12 May 29, 2025
ff243ab
chore: add logs
Royalone94 May 29, 2025
427d8ad
update log
Royalone94 May 29, 2025
fb0dbd3
update the flow
pyon12 May 29, 2025
1f98758
resolve conflict
pyon12 May 29, 2025
6b32ff3
Merge branch 'feature/DAH-1286-subnet-integrate-collateral-contracts'…
pyon12 May 29, 2025
1420728
hotfix: DAH-1286 - fix UUID to str
LegendWorrier May 29, 2025
eb092b1
Merge pull request #454 from Datura-ai/fix/DAH-1286-collateral-contract
Royalone94 May 30, 2025
b758c10
feat: remove reclaim amount from reclaim command in miner cli
Royalone94 May 30, 2025
a6f9bd1
merge main
Royalone94 Jun 10, 2025
0cb4f48
feat: integrate only one owner based contract system
Royalone94 Jun 10, 2025
d8eda32
feat: implement miner reclaim requests command in miner cli
Royalone94 Jun 10, 2025
4ccfce5
feat: add finalize reclaim request command in miner cli
Royalone94 Jun 11, 2025
41a307c
feat: update is_eligible_executor method to check executor collateral…
Royalone94 Jun 11, 2025
8b67c3f
feat: modify config and .env variables
Royalone94 Jun 11, 2025
e50b2f3
Merge branch 'main' into feature/DAH-1286-subnet-integrate-collateral…
Royalone94 Jun 11, 2025
cbeb5e4
fix: several bugs in collateral contract service
Royalone94 Jun 11, 2025
de45959
bump contract versions
Royalone94 Jun 11, 2025
25d173f
feat: update testnet contract addresses
Royalone94 Jun 11, 2025
d2295e8
fix: contract network
Royalone94 Jun 12, 2025
cfb38fb
feat: slash and deny reclaim using backend endpoint and remove owner …
Royalone94 Jun 12, 2025
6fec722
feat: remove slash and deny reclaim request method in collateral cont…
Royalone94 Jun 12, 2025
f97b2c0
fix: comparing executor collateral and required deposit amount compar…
Royalone94 Jun 12, 2025
d9334f4
feat: update miner README
Royalone94 Jun 12, 2025
1debe42
feat: minor fix
Royalone94 Jun 12, 2025
579f471
feat: optimize collateral contract service
Royalone94 Jun 12, 2025
f205746
chore: bump contract version
Royalone94 Jun 13, 2025
e0135fb
chore: bump contract version
Royalone94 Jun 13, 2025
fa916de
feat: update miner cli according to contract change
Royalone94 Jun 16, 2025
48aa78a
feat: update get_miner_collateral method in miner cli
Royalone94 Jun 16, 2025
ca1a7af
feat: update testnet contract address
Royalone94 Jun 16, 2025
173f6b9
bump contract version
Royalone94 Jun 16, 2025
8e90a5b
feat: update testnet contract address
Royalone94 Jun 16, 2025
426655e
bump contract version
Royalone94 Jun 16, 2025
a9e3915
feat: minor fix
Royalone94 Jun 16, 2025
660c68b
bump contract version
Royalone94 Jun 16, 2025
f7eb9d0
hotfix: fix get miner collateral cli command
Royalone94 Jun 16, 2025
1527fdc
feat: remove unused env variables in config
Royalone94 Jun 16, 2025
bd11dc1
bump collateral contract version
Royalone94 Jun 16, 2025
c748f00
feat: compare deposit amount as usd rate
Royalone94 Jun 16, 2025
afcbc52
feat: implement reclaim collateral cli command
Royalone94 Jun 16, 2025
b59254f
fix: clear_verified_job_info=True for nvidia_driver mismatching
pyon12 Jun 16, 2025
19053b7
feat: modify log messages in contract service
Royalone94 Jun 17, 2025
a677c1e
feat: check if executor is eligible at the begining of synthetic job …
Royalone94 Jun 17, 2025
e534281
update config
pyon12 Jun 18, 2025
0ec488d
feat: DAH-1286 - updated logs with collateral status
Jun 18, 2025
02d0bc8
feat(validator): DAH-1286 - update logic for required deposit amount …
Jun 18, 2025
ffd72dc
feat: bump contract version
Royalone94 Jun 19, 2025
34da4c0
feat: remove passing over miner ethereum address when send pubkey to …
Royalone94 Jun 19, 2025
bb51c62
update min REQUIRED_TAO_COLLATERAL
pyon12 Jun 19, 2025
8cdb114
fix issues
pyon12 Jun 19, 2025
ba4c349
feat: get associated evm address to hotkey in validator to check elig…
Royalone94 Jun 19, 2025
6ee79ed
feat: add private key param in all miner cli commands related to cont…
Royalone94 Jun 19, 2025
8676037
feat: implement CliService and add associate evm address cli command …
Royalone94 Jun 19, 2025
072aa4e
feat: bump contract version
Royalone94 Jun 19, 2025
a17fdbb
feat: update contract address
Royalone94 Jun 19, 2025
694433d
fix: circular import issue in collateral contract service
Royalone94 Jun 19, 2025
91a9a6f
bump contract version
Royalone94 Jun 19, 2025
e5ac693
fix: get_associated_evm_address is not working properly
Royalone94 Jun 19, 2025
000bd7e
fix: associate validator miner hotkey instead of validator key
Royalone94 Jun 19, 2025
0c3e282
fix: get associate evm address with hex value correctly
Royalone94 Jun 20, 2025
21cff58
chore: update _get_gpu_required_deposit method params
Royalone94 Jun 20, 2025
d905f77
bump contract version
Royalone94 Jun 20, 2025
77a7dc6
feat: compare evm address on chain and miner address on contract for …
Royalone94 Jun 20, 2025
cc1a75f
feat: update hotkey to evm address address map when fetch miners in c…
Royalone94 Jun 20, 2025
d797e0e
add sbutensor_client
pyon12 Jun 20, 2025
32cb672
feat: update miner README
Royalone94 Jun 20, 2025
517700a
resolve conflict
pyon12 Jun 20, 2025
2e11ed9
update
pyon12 Jun 20, 2025
ecb2007
Merge pull request #481 from Datura-ai/feat/subtensor-service
pyon12 Jun 20, 2025
a0de2d9
fix: get_collateral_contract method in miner
Royalone94 Jun 23, 2025
703a408
fix: finalize reclaim request command in miner cli is not working
Royalone94 Jun 23, 2025
eb24a78
fix issue
pyon12 Jun 23, 2025
20ba6e9
fix set weight issue
pyon12 Jun 23, 2025
c6c736b
update subtensor
pyon12 Jun 23, 2025
6a395bb
update subtensor
pyon12 Jun 23, 2025
c513ac2
update subtensor and fix miner_scores issue
pyon12 Jun 23, 2025
4cee373
fix subtensor initialize issue
pyon12 Jun 23, 2025
bd5ed74
fix potential issues
pyon12 Jun 23, 2025
fb85ffb
feat: DAH-1268 - update logs for non-eligible executor
Jun 23, 2025
4e45865
Merge branch 'feature/DAH-1286-subnet-integrate-collateral-contracts'…
Jun 23, 2025
e7b7cd5
bump contract version
Royalone94 Jun 23, 2025
483ee44
feat: update logs in miner cli
Royalone94 Jun 23, 2025
84b1a2a
feat: use log_info instead of log_error for logging, fix evm address …
Royalone94 Jun 23, 2025
593f984
chore: pass over executor_uuid instead of ExecutorSSHInfo in is_eligi…
Royalone94 Jun 23, 2025
9efb689
chore: cleanup collateral contract service
Royalone94 Jun 23, 2025
f8d92f0
chore: add logs when evm address is none
Royalone94 Jun 23, 2025
64f3f23
optimize collateral contract service
Royalone94 Jun 23, 2025
7bc902a
update validator cli
pyon12 Jun 23, 2025
4681e37
Merge branch 'feature/DAH-1286-subnet-integrate-collateral-contracts'…
pyon12 Jun 23, 2025
6335f80
feat: optimize collateral contract service
Royalone94 Jun 23, 2025
5b9438e
feat: remove wallet name in associated eth cli command
Royalone94 Jun 23, 2025
112d5de
update miner associate_eth cli
pyon12 Jun 23, 2025
3985e96
resolve conflict and merge
pyon12 Jun 23, 2025
a8c0fa8
fix: bug in miner associate_eth cli
Royalone94 Jun 23, 2025
04c0d3c
chore: update make_associate_evm_key_extrinsic method
Royalone94 Jun 23, 2025
7488c2b
feat: implement update_evm_address_map_for_miners method
Royalone94 Jun 23, 2025
14530c6
feat: optimize collateral contract service
Royalone94 Jun 24, 2025
cb887ab
chore: update miner README
Royalone94 Jun 24, 2025
42f7f41
update subtensor client
pyon12 Jun 24, 2025
6244b60
update subtensor client
pyon12 Jun 24, 2025
e9fcc31
fix subtensor warm up issue
pyon12 Jun 24, 2025
c916a3f
chore: update contract addresses
Royalone94 Jun 24, 2025
a139aae
chore: update default contract addresses in config
Royalone94 Jun 24, 2025
f8cc856
feat: remove private key param from get executor collateral and get m…
Royalone94 Jun 24, 2025
9716ff4
chore: update miner README
Royalone94 Jun 24, 2025
66ecabd
feat: update get_reclaim_requests cli command to filter out only mine…
Royalone94 Jun 24, 2025
a12da38
chore: update github action
Royalone94 Jun 24, 2025
589c0ef
chore: add master branch to ci/cd files
Royalone94 Jun 24, 2025
c4fba1e
chore: remove current branch from ci/cd files
Royalone94 Jun 24, 2025
ac07cdc
fix: DAH-1286 - github cd for dev
Jun 24, 2025
313b7a8
Merge branch 'main' into feature/DAH-1286-subnet-integrate-collateral…
Jun 25, 2025
caad1c7
feat: update miner README
Royalone94 Jun 25, 2025
3160ab2
feat: optimize cliService and miner cli commands
Royalone94 Jun 25, 2025
867c191
bump contract version
Royalone94 Jun 25, 2025
a7392ef
chore: update miner README
Royalone94 Jun 25, 2025
7903742
fix: get executor collateral command
Royalone94 Jun 25, 2025
b1bbfb5
update validator
Royalone94 Jun 25, 2025
6aaebaa
feat: show reclaim requests in table format
Royalone94 Jun 25, 2025
3cccc55
bump contract version
Royalone94 Jun 25, 2025
eb11515
revert: get reclaim requests cli command display format as json
Royalone94 Jun 26, 2025
db795b5
feat: refactor add executor and deposit collateral to deposit collate…
Royalone94 Jun 26, 2025
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: 2 additions & 1 deletion neurons/miners/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ SQLALCHEMY_DATABASE_URI=postgresql://postgres:password@localhost:7432/compute-su

BITTENSOR_NETUID=51
BITTENSOR_NETWORK=finney
COLLATERAL_CONTRACT_ADDRESS=0x7DCCb5659c70Ce2104A9bb79E9E257473ECbe628

EXTERNAL_IP_ADDRESS= # pro tip: use `curl ifconfig.me` to find this out
INTERNAL_PORT=8000
EXTERNAL_PORT=8000 # make sure this port is open to external connections

HOST_WALLET_DIR=/home/ubuntu/.bittensor/wallets
HOST_WALLET_DIR=/home/ubuntu/.bittensor/wallets
96 changes: 82 additions & 14 deletions neurons/miners/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ Fill in your information for:
cd neurons/miners && docker compose up -d
```

### Associating Your Ethereum Address

Before managing executors, you need to associate your Ethereum address with your Bittensor hotkey. This is a one-time setup requirement. Use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py associate_eth --private-key <ethereum-private-key>
```

- `<ethereum-private-key>`: Your Ethereum private key that will be associated with your Bittensor hotkey.

You will be prompted to enter your Bittensor wallet password to complete the association.

## Managing Executors

### What is a Validator Hotkey?
Expand All @@ -88,12 +100,14 @@ Executors are machines running on GPUs that you can add to your central miner. T
2. Use the following command to add an executor to the central miner:

```bash
docker exec <container-id or name> pdm run /root/app/src/cli.py add-executor --address <executor-ip-address> --port <executor-port> --validator <validator-hotkey>
docker exec -it <container-id or name> pdm run /root/app/src/cli.py add-executor --address <executor-ip-address> --port <executor-port> --validator <validator-hotkey> --deposit_amount <deposit-amount> --private-key <ethereum-private-key>
```

- `<executor-ip-address>`: The IP address of the executor machine.
- `<executor-port>`: The port number used for the executor (default: `8001`).
- `<validator-hotkey>`: The validator hotkey that you want to give access to this executor. Which validator hotkey should you pick? Follow [this guide](assigning_validator_hotkeys.md)
- `<validator-hotkey>`: The validator hotkey that you want to give access to this executor. Which validator hotkey should you pick? Follow [this guide](assigning_validator_hotkeys.md).
- `<deposit-amount>`: The amount of TAO to deposit as collateral for this executor (must meet minimum required collateral).
- `<ethereum-private-key>`: The Ethereum private key for the miner (used for collateral transactions).

### List Executors

Expand All @@ -102,30 +116,84 @@ To list added executors from the central miner, follow these steps:
1. run following command:

```bash
docker exec <docker instance> pdm run /root/app/src/cli.py show-executors
docker exec -it <docker instance> pdm run /root/app/src/cli.py show-executors
```

### Removing an Executor

To remove an executor from the central miner, follow these steps:
1. Run the following command to remove the executor:
1. Run the following command to remove the executor:

```bash
docker exec -i <docker instance> pdm run /root/app/src/cli.py remove-executor --address <executor public ip> --port <executor external port>
docker exec -it <container-id or name> pdm run /root/app/src/cli.py remove-executor --address <executor public ip> --port <executor external port>
```
2. Type "y" and click enter in the interactive shell

### Switch Validator
- `<executor public ip>`: The public IP address of the executor machine.
- `<executor external port>`: The external port number used for the executor.

If you need to change validator hotkey of an executor, follow these steps:
1. run following command to switch validator hotkey:
2. Type "y" and click enter in the interactive shell.

```bash
docker exec -i <docker instance> pdm run /root/app/src/cli.py switch-validator --address <executor-ip-address> --port <executor-port> --validator <validator-hotkey>
```
2. Type "y" and click enter in the interactive shell
### Getting Miner Collateral

To check the total collateral deposited by the miner, use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py get-miner-collateral
```

This will display the total TAO collateral that miner has deposited.


### Depositing Collateral for an Executor

To deposit additional collateral for an existing executor, use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py deposit-collateral --address <executor-ip-address> --port <executor-port> --deposit_amount <deposit-amount> --private-key <ethereum-private-key>
```

- `<executor-ip-address>`: The IP address of the executor machine.
- `<executor-port>`: The port number used for the executor.
- `<deposit-amount>`: The amount of TAO to deposit as additional collateral for this executor.
- `<ethereum-private-key>`: The Ethereum private key for the miner (used for collateral transactions).

This command allows you to increase the collateral for an executor already registered in the database.

### Getting Executor Collateral

To check the collateral amount for a specific executor, use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py get-executor-collateral --address <executor-ip-address> --port <executor-port>
```

- `<executor-ip-address>`: The IP address of the executor machine.
- `<executor-port>`: The port number used for the executor.

This will display the TAO collateral associated with the specified executor.

### Getting Miner Reclaim Requests

To view all reclaim requests for the current miner, use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py get-reclaim-requests
```

This will print a JSON list of all reclaim requests made by the miner, including their status and details.

### Finalizing a Reclaim Request

To finalize a reclaim request and reclaim your collateral, use the following command:

```bash
docker exec -it <container-id or name> pdm run /root/app/src/cli.py finalize-reclaim-request --reclaim-request-id <reclaim-request-id> --private-key <ethereum-private-key>
```

- `<reclaim-request-id>`: The ID of the reclaim request you wish to finalize.
- `<ethereum-private-key>`: The Ethereum private key for the miner (used for collateral contract transactions).

Note: We are not recommending to switch validator hotkey and this may lead to unexpected results.
This command will finalize the reclaim request and return the collateral to your account.

### Monitoring earnings

Expand Down
Loading