Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions docs/zh-CN/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## BoTTube Premium API

- GET https://bottube.ai/api/premium/videos
- GET https://bottube.ai/api/premium/analytics/<agent>

---

<div align="center">

# 🧱 RustChain: 古董证明区块链
Expand Down
2 changes: 1 addition & 1 deletion miners/checksums.sha256
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
4afd5aea552cc5b68364b39fa37cdc93d1d406ec295670969e1a9c4164babb15 linux/rustchain_linux_miner.py
c7af612bb2630d5fe6576bb132bdeb7a00ba0be042ec168887ab767a1f16c9f9 linux/rustchain_linux_miner.py
cdfca6e63ecd24f53b30140dd44df42415a3254c68aad95b1fca3c1557e15f7b linux/fingerprint_checks.py
603d9a3b3ebfe1a0ca56a60988db4b5d4a80ab57cb5feb1c0b563a1d4020fcd7 macos/rustchain_mac_miner_v2.4.py
163fafcf751d8fbd41bf936facaeb366c042f467fa34b79f2c4c0a45472ef70f macos/rustchain_mac_miner_v2.5.py
Expand Down
17 changes: 12 additions & 5 deletions miners/gpu_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Author: Elyan Labs (RIP-0308: Proof of Physical AI)
"""

from __future__ import annotations

import argparse
import json
import hashlib
Expand All @@ -39,13 +41,17 @@
try:
import torch
import torch.cuda
HAS_TORCH = True
except ImportError:
print("ERROR: PyTorch with CUDA support required. Install: pip install torch")
sys.exit(1)
HAS_TORCH = False

if not torch.cuda.is_available():
print("ERROR: No CUDA-capable GPU detected.")
sys.exit(1)
def check_requirements():
if not HAS_TORCH:
print("ERROR: PyTorch with CUDA support required. Install: pip install torch")
sys.exit(1)
if not torch.cuda.is_available():
print("ERROR: No CUDA-capable GPU detected.")
sys.exit(1)


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -789,6 +795,7 @@ def cross_validate_gpu(device: torch.device) -> ChannelResult:

def run_gpu_fingerprint(device_index: int = 0, samples: int = 200, epoch_salt: str = "") -> GPUFingerprint:
"""Run all GPU fingerprint channels and return results."""
check_requirements()
device = torch.device(f"cuda:{device_index}")

# GPU info
Expand Down
4 changes: 3 additions & 1 deletion otc-bridge/otc_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def rtc_transfer_from_worker(recipient_wallet, amount_rtc, order_id):

try:
last_payload = transfer_r.json()
except ValueError:
if not isinstance(last_payload, dict):
last_payload = {}
except Exception:
last_payload = {}

if transfer_r.ok:
Expand Down
4 changes: 2 additions & 2 deletions setup_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
MINER_ARTIFACTS = {
"Linux": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/linux/rustchain_linux_miner.py",
"sha256": "4afd5aea552cc5b68364b39fa37cdc93d1d406ec295670969e1a9c4164babb15",
"sha256": "c7af612bb2630d5fe6576bb132bdeb7a00ba0be042ec168887ab767a1f16c9f9",
},
"Darwin": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/macos/rustchain_mac_miner_v2.5.py",
"sha256": "163fafcf751d8fbd41bf936facaeb366c042f467fa34b79f2c4c0a45472ef70f",
},
"Windows": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/windows/rustchain_windows_miner.py",
"sha256": "5b69ebc210e4e8e32975b711dcb1ca08e07b731ddfe4f9f2f9a7e68c1e246a9d",
"sha256": "7f663904031e5a4202be416682fd16ab51af2e96664d6db1567f716d8625f8e1",
},
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_api_miners_requires_auth(client):
rows_result = MagicMock()
rows_result.fetchall.return_value = []
mock_cursor.execute.side_effect = [count_result, rows_result]
mock_connect.return_value.execute.return_value.fetchone.return_value = [0]

response = client.get('/api/miners')
assert response.status_code == 200
Expand Down
20 changes: 10 additions & 10 deletions tests/test_beacon_atlas_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_create_contract_workflow(self):
contract_id = created['id']

# Verify contract appears in list
list_response = self.client.get('/api/contracts')
list_response = self.client.get('/api/contracts', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(list_response.status_code, 200)
contracts = json.loads(list_response.data)
self.assertEqual(len(contracts), 1)
Expand All @@ -198,7 +198,7 @@ def test_create_contract_workflow(self):
self.assertEqual(update_response.status_code, 200)

# Verify state changed
list_response2 = self.client.get('/api/contracts')
list_response2 = self.client.get('/api/contracts', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
contracts2 = json.loads(list_response2.data)
self.assertEqual(contracts2[0]['state'], 'active')

Expand Down Expand Up @@ -282,7 +282,7 @@ def test_bounty_lifecycle_workflow(self):
conn.commit()

# Get bounties list
response = self.client.get('/api/bounties')
response = self.client.get('/api/bounties', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(response.status_code, 200)
bounties = json.loads(response.data)
self.assertEqual(len(bounties), 1)
Expand All @@ -298,7 +298,7 @@ def test_bounty_lifecycle_workflow(self):
self.assertEqual(claim_response.status_code, 200)

# Verify claimed state
response2 = self.client.get('/api/bounties')
response2 = self.client.get('/api/bounties', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
bounties2 = json.loads(response2.data)
# Bounty should no longer appear in open list (state changed to claimed)

Expand Down Expand Up @@ -346,21 +346,21 @@ def test_reputation_tracking_workflow(self):
conn.commit()

# Get all reputations
response = self.client.get('/api/reputation')
response = self.client.get('/api/reputation', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(response.status_code, 200)
reps = json.loads(response.data)
self.assertEqual(len(reps), 1)
self.assertEqual(reps[0]['agent_id'], 'bcn_reputation_test')
self.assertEqual(reps[0]['score'], 50)

# Get single agent reputation
response2 = self.client.get('/api/reputation/bcn_reputation_test')
response2 = self.client.get('/api/reputation/bcn_reputation_test', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(response2.status_code, 200)
rep = json.loads(response2.data)
self.assertEqual(rep['bounties_completed'], 2)

# Non-existent agent returns 404
response3 = self.client.get('/api/reputation/bcn_nonexistent')
response3 = self.client.get('/api/reputation/bcn_nonexistent', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(response3.status_code, 404)

def test_chat_message_storage(self):
Expand Down Expand Up @@ -461,7 +461,7 @@ def test_recipient_can_reject_offered_contract(self):
self.assertEqual(reject_response.status_code, 200)
self.assertEqual(json.loads(reject_response.data)['state'], 'rejected')

list_response = self.client.get('/api/contracts')
list_response = self.client.get('/api/contracts', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
contracts = json.loads(list_response.data)
self.assertEqual(contracts[0]['state'], 'rejected')

Expand Down Expand Up @@ -514,7 +514,7 @@ def test_creator_cannot_reject_offered_contract(self):
)
self.assertEqual(reject_response.status_code, 403)

list_response = self.client.get('/api/contracts')
list_response = self.client.get('/api/contracts', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
contracts = json.loads(list_response.data)
self.assertEqual(contracts[0]['state'], 'offered')

Expand Down Expand Up @@ -576,7 +576,7 @@ def test_bounty_completion_updates_reputation(self):
self.assertEqual(complete_response.status_code, 200)

# Verify reputation was created/updated
rep_response = self.client.get('/api/reputation/bcn_completer')
rep_response = self.client.get('/api/reputation/bcn_completer', headers={'X-Admin-Key': os.environ.get('RC_ADMIN_KEY', '0'*32)})
self.assertEqual(rep_response.status_code, 200)
rep = json.loads(rep_response.data)
self.assertEqual(rep['bounties_completed'], 1)
Expand Down
41 changes: 21 additions & 20 deletions tests/test_bridge_lock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ def funded_miner(setup_test_db):
conn = sqlite3.connect(setup_test_db['db_path'])
conn.execute(
"INSERT INTO balances (miner_id, amount_i64) VALUES (?, ?)",
("RTC_test_miner", 100 * 1000000) # 100 RTC
("RTC0000000000000000000000000000000000000000", 100 * 1000000) # 100 RTC
)
conn.commit()
conn.close()
return "RTC_test_miner"
return "RTC0000000000000000000000000000000000000000"


def assert_generic_database_error(result):
Expand All @@ -193,7 +193,7 @@ def test_valid_deposit_request(self, setup_test_db):
"direction": "deposit",
"source_chain": "rustchain",
"dest_chain": "solana",
"source_address": "RTC_test123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"amount_rtc": 10.0
}
Expand All @@ -209,7 +209,7 @@ def test_valid_withdraw_request(self, setup_test_db):
"source_chain": "solana",
"dest_chain": "rustchain",
"source_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"dest_address": "RTC_test123",
"dest_address": "RTC0000000000000000000000000000000000000000",
"amount_rtc": 5.0
}
result = bridge_api.validate_bridge_request(data)
Expand All @@ -221,7 +221,7 @@ def test_missing_required_field(self, setup_test_db):
data = {
"direction": "deposit",
"dest_chain": "solana",
"source_address": "RTC_test123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"amount_rtc": 10.0
}
Expand All @@ -236,7 +236,7 @@ def test_invalid_direction(self, setup_test_db):
"direction": "invalid",
"source_chain": "rustchain",
"dest_chain": "solana",
"source_address": "RTC_test123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"amount_rtc": 10.0
}
Expand All @@ -251,8 +251,8 @@ def test_same_chain_fails(self, setup_test_db):
"direction": "deposit",
"source_chain": "rustchain",
"dest_chain": "rustchain",
"source_address": "RTC_test123",
"dest_address": "RTC_other123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "RTC11111111111111111111111111111111111111111",
"amount_rtc": 10.0
}
result = bridge_api.validate_bridge_request(data)
Expand All @@ -267,7 +267,7 @@ def test_deposit_must_start_from_rustchain(self, setup_test_db):
"source_chain": "solana",
"dest_chain": "rustchain",
"source_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"dest_address": "RTC_test123",
"dest_address": "RTC0000000000000000000000000000000000000000",
"amount_rtc": 10.0
}
result = bridge_api.validate_bridge_request(data)
Expand All @@ -281,7 +281,7 @@ def test_withdraw_must_end_on_rustchain(self, setup_test_db):
"direction": "withdraw",
"source_chain": "rustchain",
"dest_chain": "solana",
"source_address": "RTC_test123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"amount_rtc": 10.0
}
Expand All @@ -296,7 +296,7 @@ def test_amount_below_minimum(self, setup_test_db):
"direction": "deposit",
"source_chain": "rustchain",
"dest_chain": "solana",
"source_address": "RTC_test123",
"source_address": "RTC0000000000000000000000000000000000000000",
"dest_address": "4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
"amount_rtc": 0.5
}
Expand All @@ -315,7 +315,7 @@ class TestAddressValidation:
def test_valid_rustchain_address(self, setup_test_db):
"""Test valid RustChain address."""
bridge_api = setup_test_db["bridge_api"]
valid, msg = bridge_api.validate_chain_address_format("rustchain", "RTC_test123abc")
valid, msg = bridge_api.validate_chain_address_format("rustchain", "RTC0000000000000000000000000000000000000000")
assert valid is True

def test_invalid_rustchain_address_prefix(self, setup_test_db):
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_create_withdraw_transfer(self, setup_test_db):
source_chain="solana",
dest_chain="rustchain",
source_address="4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
dest_address="RTC_dest123",
dest_address="RTC33333333333333333333333333333333333333333",
amount_rtc=5.0
)

Expand Down Expand Up @@ -447,7 +447,7 @@ def test_admin_bypasses_balance_check(self, setup_test_db):
direction="deposit",
source_chain="rustchain",
dest_chain="solana",
source_address="RTC_unfunded_miner",
source_address="RTC22222222222222222222222222222222222222222",
dest_address="4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
amount_rtc=1000.0
)
Expand All @@ -469,7 +469,7 @@ def test_database_errors_do_not_leak_details(self, setup_test_db):
source_chain="solana",
dest_chain="rustchain",
source_address="4TRwNqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXq",
dest_address="RTC_dest123",
dest_address="RTC33333333333333333333333333333333333333333",
amount_rtc=5.0
)

Expand Down Expand Up @@ -648,7 +648,7 @@ def test_database_errors_do_not_leak_details(self, setup_test_db):

success, result = lock_ledger.create_lock(
conn,
miner_id="RTC_test_miner",
miner_id="RTC0000000000000000000000000000000000000000",
amount_i64=10 * 1000000,
lock_type="bridge_deposit",
unlock_at=int(time.time()) + 3600
Expand Down Expand Up @@ -787,6 +787,7 @@ class TestLockLedgerRoutes:
"""Test lock ledger route-level validation and helper dispatch."""

def _client(self, lock_ledger, db_path):
os.environ["RC_ADMIN_KEY"] = "expected-admin"
lock_ledger.DB_PATH = db_path
app = Flask(__name__)
lock_ledger.register_lock_ledger_routes(app)
Expand All @@ -806,7 +807,7 @@ def test_miner_locks_rejects_malformed_limit(self, setup_test_db, funded_miner):
lock_ledger = setup_test_db["lock_ledger"]
client = self._client(lock_ledger, setup_test_db["db_path"])

response = client.get(f"/api/lock/miner/{funded_miner}?limit=abc")
response = client.get(f"/api/lock/miner/{funded_miner}?limit=abc", headers={"X-Admin-Key": "expected-admin"})

assert response.status_code == 400
assert response.get_json() == {"error": "limit must be an integer"}
Expand All @@ -815,7 +816,7 @@ def test_pending_unlock_rejects_malformed_before(self, setup_test_db):
lock_ledger = setup_test_db["lock_ledger"]
client = self._client(lock_ledger, setup_test_db["db_path"])

response = client.get("/api/lock/pending-unlock?before=not-a-timestamp")
response = client.get("/api/lock/pending-unlock?before=not-a-timestamp", headers={"X-Admin-Key": "expected-admin"})

assert response.status_code == 400
assert response.get_json() == {"error": "before must be an integer"}
Expand All @@ -842,7 +843,7 @@ def test_pending_unlock_route_calls_database_helper(self, setup_test_db, funded_

client = self._client(lock_ledger, db_path)

response = client.get("/api/lock/pending-unlock?limit=10")
response = client.get("/api/lock/pending-unlock?limit=10", headers={"X-Admin-Key": "expected-admin"})

assert response.status_code == 200
body = response.get_json()
Expand Down Expand Up @@ -872,7 +873,7 @@ def test_pending_unlock_before_zero_applies_cutoff(self, setup_test_db, funded_m

client = self._client(lock_ledger, db_path)

response = client.get("/api/lock/pending-unlock?before=0&limit=10")
response = client.get("/api/lock/pending-unlock?before=0&limit=10", headers={"X-Admin-Key": "expected-admin"})

assert response.status_code == 200
body = response.get_json()
Expand Down
Loading
Loading