matrix-compute-node 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/PKG-INFO +1 -1
  2. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/PKG-INFO +1 -1
  3. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/pyproject.toml +1 -1
  4. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/__init__.py +1 -1
  5. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/auth/l402_gate.py +19 -8
  6. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/main.py +51 -0
  7. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/p2p/servicer.py +26 -0
  8. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/LICENSE +0 -0
  9. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/README.md +0 -0
  10. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/SOURCES.txt +0 -0
  11. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/dependency_links.txt +0 -0
  12. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/entry_points.txt +0 -0
  13. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/requires.txt +0 -0
  14. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/matrix_compute_node.egg-info/top_level.txt +0 -0
  15. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/setup.cfg +0 -0
  16. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/setup.py +0 -0
  17. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/__init__.py +0 -0
  18. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/base.py +0 -0
  19. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/nvml_attest.py +0 -0
  20. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/sev_snp_attest.py +0 -0
  21. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/simulated.py +0 -0
  22. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/attestation/tdx_attest.py +0 -0
  23. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/auth/__init__.py +0 -0
  24. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/auth/hashcash.py +0 -0
  25. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/config/__init__.py +0 -0
  26. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/config/settings.py +0 -0
  27. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/crypto/__init__.py +0 -0
  28. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/crypto/signer.py +0 -0
  29. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/engine/__init__.py +0 -0
  30. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/engine/compute_core.py +0 -0
  31. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/engine/enclave_compute.py +0 -0
  32. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/engine/scheduler.py +0 -0
  33. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/engine/session_manager.py +0 -0
  34. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/p2p/__init__.py +0 -0
  35. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/p2p/tunnel_client.py +0 -0
  36. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/relay/__init__.py +0 -0
  37. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/relay/nostr_client.py +0 -0
  38. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/settings.py +0 -0
  39. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/test_doubles/__init__.py +0 -0
  40. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/test_doubles/mock_nostr_relay.py +0 -0
  41. {matrix_compute_node-0.1.0 → matrix_compute_node-0.1.1}/src/test_doubles/mock_settlement.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matrix-compute-node
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Decentralized worker daemon for Distributed Matrix Multiplication network
5
5
  Author: Distributed Matrix Multiply Team
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: matrix-compute-node
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Decentralized worker daemon for Distributed Matrix Multiplication network
5
5
  Author: Distributed Matrix Multiply Team
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "matrix-compute-node"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "Decentralized worker daemon for Distributed Matrix Multiplication network"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -45,7 +45,7 @@ def _ensure_contracts_linked() -> None:
45
45
  # Link matrix_contracts immediately upon package initialization
46
46
  _ensure_contracts_linked()
47
47
 
48
- __version__ = "0.1.0"
48
+ __version__ = "0.1.1"
49
49
 
50
50
  __all__ = [
51
51
  "__version__",
@@ -411,15 +411,26 @@ class L402PreAllocationGate:
411
411
  if not isinstance(caveats, dict) or not isinstance(signature, str):
412
412
  return False, "Malformed macaroon structure", "UNAUTHENTICATED"
413
413
 
414
- # Verify HMAC-SHA256
414
+ # Verify HMAC-SHA256 (accept primary verification_key plus prod/dev compatibility keys if default)
415
415
  caveat_str = json.dumps(caveats, sort_keys=True)
416
- expected_sig = hmac.new(
417
- self.verification_key.encode("utf-8"),
418
- caveat_str.encode("utf-8"),
419
- hashlib.sha256,
420
- ).hexdigest()
421
-
422
- if not hmac.compare_digest(signature, expected_sig):
416
+ candidate_keys = [self.verification_key]
417
+ if self.verification_key in ("settlement_secret_key_dev", "settlement_secret_key_prod"):
418
+ for compat_k in ("settlement_secret_key_prod", "settlement_secret_key_dev"):
419
+ if compat_k not in candidate_keys:
420
+ candidate_keys.append(compat_k)
421
+
422
+ sig_valid = False
423
+ for k_secret in candidate_keys:
424
+ expected_sig = hmac.new(
425
+ k_secret.encode("utf-8"),
426
+ caveat_str.encode("utf-8"),
427
+ hashlib.sha256,
428
+ ).hexdigest()
429
+ if hmac.compare_digest(signature, expected_sig):
430
+ sig_valid = True
431
+ break
432
+
433
+ if not sig_valid:
423
434
  return False, "Invalid macaroon HMAC signature", "UNAUTHENTICATED"
424
435
 
425
436
  # Step 3: Multi-Task Caveat Containment Check (Feature F6)
@@ -105,6 +105,55 @@ class WorkerDaemon:
105
105
  relays=config.nostr_relays,
106
106
  signer=self.signer,
107
107
  )
108
+ self._last_payout_snapshot: Optional[tuple] = None
109
+
110
+ def _log_payout_status(self, force: bool = False) -> None:
111
+ """Queries settlement /payouts/<address> and logs whenever accumulated or paid satoshis change."""
112
+ payout_addr = (
113
+ getattr(self.config, "worker_lightning_address", None)
114
+ or getattr(self.config, "lightning_routing_pubkey", None)
115
+ )
116
+ settlement_url = getattr(self.config, "settlement_api_url", None)
117
+ if not payout_addr or not settlement_url or not str(settlement_url).startswith(("http://", "https://")):
118
+ return
119
+ try:
120
+ import httpx
121
+ url = f"{str(settlement_url).rstrip('/')}/payouts/{payout_addr}"
122
+ with httpx.Client(timeout=5.0) as client:
123
+ resp = client.get(url)
124
+ if resp.status_code != 200:
125
+ return
126
+ data = resp.json()
127
+ if not isinstance(data, dict):
128
+ return
129
+ pending_gross = int(data.get("pending_gross_sats", 0))
130
+ est_net = int(data.get("estimated_pending_net_sats", pending_gross))
131
+ threshold = int(data.get("min_payout_threshold_sats", 1000))
132
+ total_paid = int(data.get("total_paid_net_sats", 0))
133
+ payout_count = int(data.get("payout_count", 0))
134
+ snapshot = (pending_gross, total_paid, payout_count)
135
+ if force or snapshot != self._last_payout_snapshot:
136
+ prev_paid = self._last_payout_snapshot[1] if self._last_payout_snapshot else 0
137
+ self._last_payout_snapshot = snapshot
138
+ if total_paid > prev_paid:
139
+ logger.info(
140
+ "[LIGHTNING PAYOUT SENT] Dispatched %d net sats to %s! (Lifetime paid: %d sats across %d payouts)",
141
+ total_paid - prev_paid,
142
+ payout_addr,
143
+ total_paid,
144
+ payout_count,
145
+ )
146
+ logger.info(
147
+ "[EARNINGS] Pending: %d / %d sats (~%d net sats) | Paid to %s: %d sats (%d payouts)",
148
+ pending_gross,
149
+ threshold,
150
+ est_net,
151
+ payout_addr,
152
+ total_paid,
153
+ payout_count,
154
+ )
155
+ except Exception as ex:
156
+ logger.debug("Payout status check skipped: %s", ex)
108
157
 
109
158
  def start(self) -> None:
110
159
  """Starts daemon services and registers announcement."""
@@ -130,6 +179,7 @@ class WorkerDaemon:
130
179
 
131
180
  # 3. Announce to Nostr relays
132
181
  self._announce_once()
182
+ self._log_payout_status(force=True)
133
183
 
134
184
  def _announce_once(self) -> bool:
135
185
  """Builds and publishes a fresh Kind 30000 announcement event."""
@@ -188,6 +238,7 @@ class WorkerDaemon:
188
238
  time.sleep(0.5)
189
239
  if time.time() - last_announce >= 30.0:
190
240
  self._announce_once()
241
+ self._log_payout_status(force=False)
191
242
  last_announce = time.time()
192
243
  except KeyboardInterrupt:
193
244
  pass
@@ -501,6 +501,32 @@ class MatrixComputeServicer(pb2_grpc.MatrixComputeServiceServicer):
501
501
  payload_to_sign = f"{task_id}:{c_hash}".encode("utf-8")
502
502
  sig = self.signer.sign_message(payload_to_sign)
503
503
 
504
+ locked_sats_display = "trial" if is_trial else "paid"
505
+ if not is_trial:
506
+ try:
507
+ import base64
508
+ import json
509
+ raw_m = base64.b64decode(macaroon_b64)
510
+ m_obj = json.loads(raw_m.decode("utf-8"))
511
+ m_cav = m_obj.get("caveats", {}) if isinstance(m_obj, dict) else {}
512
+ if "locked_sats" in m_cav:
513
+ locked_sats_display = str(m_cav["locked_sats"])
514
+ except Exception:
515
+ pass
516
+
517
+ logger.info(
518
+ "[TILE COMPLETED] task=%s (%dx%d @ %dx%d %s) in %d ms | batch_escrow=%s sats (hash=%s...)",
519
+ task_id,
520
+ m,
521
+ k,
522
+ k,
523
+ n,
524
+ dtype,
525
+ max(exec_time_ms, 1),
526
+ locked_sats_display,
527
+ payment_hash[:12],
528
+ )
529
+
504
530
  return pb2.TileResult(
505
531
  task_id=task_id,
506
532
  rows=session.m,