Clawdbot commited on
Commit
c412eea
Β·
1 Parent(s): a890f8f

Rename mep_miner to mep_provider for legal safety

Browse files
node/{mep_miner.py β†’ mep_provider.py} RENAMED
@@ -17,7 +17,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
17
  HUB_URL = "http://localhost:8000"
18
  WS_URL = "ws://localhost:8000"
19
 
20
- class MEPMiner:
21
  def __init__(self, node_id: str):
22
  self.node_id = node_id
23
  self.balance = 0.0
@@ -154,18 +154,18 @@ Would you like me to elaborate on any specific aspect?"""
154
 
155
  async def main():
156
  # Create a miner with unique ID
157
- miner_id = f"mep-miner-{uuid.uuid4().hex[:8]}"
158
- miner = MEPMiner(miner_id)
159
 
160
  try:
161
  await miner.connect()
162
  except KeyboardInterrupt:
163
  miner.stop()
164
- print("\n[MEP] Mining stopped by user")
165
 
166
  if __name__ == "__main__":
167
  print("=" * 60)
168
  print("Miao Exchange Protocol (MEP) Miner")
169
- print("Earn SECONDS by processing tasks while you sleep")
170
  print("=" * 60)
171
  asyncio.run(main())
 
17
  HUB_URL = "http://localhost:8000"
18
  WS_URL = "ws://localhost:8000"
19
 
20
+ class MEPProvider:
21
  def __init__(self, node_id: str):
22
  self.node_id = node_id
23
  self.balance = 0.0
 
154
 
155
  async def main():
156
  # Create a miner with unique ID
157
+ provider_id = f"mep-provider-{uuid.uuid4().hex[:8]}"
158
+ miner = MEPProvider(provider_id)
159
 
160
  try:
161
  await miner.connect()
162
  except KeyboardInterrupt:
163
  miner.stop()
164
+ print("\n[MEP] Contribution stopped by user")
165
 
166
  if __name__ == "__main__":
167
  print("=" * 60)
168
  print("Miao Exchange Protocol (MEP) Miner")
169
+ print("Earn SECONDS by contributing idle compute")
170
  print("=" * 60)
171
  asyncio.run(main())
node/race_test.py CHANGED
@@ -13,7 +13,7 @@ import time
13
  HUB_URL = "http://localhost:8000"
14
  WS_URL = "ws://localhost:8000"
15
 
16
- class RacingMiner:
17
  def __init__(self, name, location):
18
  self.name = name
19
  self.location = location
@@ -43,7 +43,7 @@ class RacingMiner:
43
  self.response_time = time.time() - start_time
44
  print(f"[{self.name}] 🏁 GOT THE TASK! Response: {self.response_time:.3f}s")
45
 
46
- # Simulate processing (faster miners win)
47
  process_time = 0.1 if "fast" in self.name.lower() else 0.5
48
  await asyncio.sleep(process_time)
49
 
@@ -76,12 +76,12 @@ async def run_race():
76
  consumer_id = "race-test-consumer"
77
  requests.post(f"{HUB_URL}/register", json={"pubkey": consumer_id})
78
 
79
- # Create 4 miners in different "locations"
80
- miners = [
81
- RacingMiner("FastMiner-USA", "New York"),
82
- RacingMiner("SlowMiner-EU", "Berlin"),
83
- RacingMiner("QuickMiner-Asia", "Singapore"),
84
- RacingMiner("SteadyMiner-AU", "Sydney")
85
  ]
86
 
87
  # Submit a task
@@ -101,9 +101,9 @@ async def run_race():
101
  task_id = task_data["task_id"]
102
  print(f" Task ID: {task_id[:8]}...")
103
 
104
- # Start all miners simultaneously
105
- print("\n🏁 Starting miners...")
106
- tasks = [miner.compete(task_id, task_payload, bounty) for miner in miners]
107
  await asyncio.gather(*tasks)
108
 
109
  # Results
@@ -112,13 +112,13 @@ async def run_race():
112
  print("=" * 60)
113
 
114
  winner = None
115
- for miner in miners:
116
- status = "πŸ† WINNER" if miner.won_race else "❌ Lost"
117
- time_str = f"{miner.response_time:.3f}s" if miner.response_time else "N/A"
118
- print(f"{status} {miner.name:20} {miner.location:15} Response: {time_str:8} Balance: {miner.balance}")
119
 
120
- if miner.won_race:
121
- winner = miner
122
 
123
  if winner:
124
  print(f"\n🎯 The market chose: {winner.name} from {winner.location}")
 
13
  HUB_URL = "http://localhost:8000"
14
  WS_URL = "ws://localhost:8000"
15
 
16
+ class RacingProvider:
17
  def __init__(self, name, location):
18
  self.name = name
19
  self.location = location
 
43
  self.response_time = time.time() - start_time
44
  print(f"[{self.name}] 🏁 GOT THE TASK! Response: {self.response_time:.3f}s")
45
 
46
+ # Simulate processing (faster providers win)
47
  process_time = 0.1 if "fast" in self.name.lower() else 0.5
48
  await asyncio.sleep(process_time)
49
 
 
76
  consumer_id = "race-test-consumer"
77
  requests.post(f"{HUB_URL}/register", json={"pubkey": consumer_id})
78
 
79
+ # Create 4 providers in different "locations"
80
+ providers = [
81
+ RacingProvider("FastProvider-USA", "New York"),
82
+ RacingProvider("SlowProvider-EU", "Berlin"),
83
+ RacingProvider("QuickProvider-Asia", "Singapore"),
84
+ RacingProvider("SteadyProvider-AU", "Sydney")
85
  ]
86
 
87
  # Submit a task
 
101
  task_id = task_data["task_id"]
102
  print(f" Task ID: {task_id[:8]}...")
103
 
104
+ # Start all providers simultaneously
105
+ print("\n🏁 Starting providers...")
106
+ tasks = [provider.compete(task_id, task_payload, bounty) for provider in providers]
107
  await asyncio.gather(*tasks)
108
 
109
  # Results
 
112
  print("=" * 60)
113
 
114
  winner = None
115
+ for provider in providers:
116
+ status = "πŸ† WINNER" if provider.won_race else "❌ Lost"
117
+ time_str = f"{provider.response_time:.3f}s" if provider.response_time else "N/A"
118
+ print(f"{status} {provider.name:20} {provider.location:15} Response: {time_str:8} Balance: {provider.balance}")
119
 
120
+ if provider.won_race:
121
+ winner = provider
122
 
123
  if winner:
124
  print(f"\n🎯 The market chose: {winner.name} from {winner.location}")
node/race_test_fixed.py CHANGED
@@ -1,6 +1,6 @@
1
  #!/usr/bin/env python3
2
  """
3
- MEP Race Test FIXED: Ensure task is broadcast AFTER all miners connect.
4
  """
5
  import asyncio
6
  import websockets
@@ -12,7 +12,7 @@ import time
12
  HUB_URL = "http://localhost:8000"
13
  WS_URL = "ws://localhost:8000"
14
 
15
- class RacingMiner:
16
  def __init__(self, name, location):
17
  self.name = name
18
  self.location = location
@@ -71,18 +71,18 @@ async def run_race():
71
  print("MEP GLOBAL RACE TEST: Real Competition")
72
  print("=" * 60)
73
 
74
- # Create miners
75
- miners = [
76
- RacingMiner("FastMiner-USA", "New York"),
77
- RacingMiner("SlowMiner-EU", "Berlin"),
78
- RacingMiner("QuickMiner-Asia", "Singapore"),
79
- RacingMiner("SteadyMiner-AU", "Sydney")
80
  ]
81
 
82
- # Connect ALL miners first
83
- print("\nπŸ”— Connecting miners to hub...")
84
- for miner in miners:
85
- await miner.connect()
86
 
87
  await asyncio.sleep(0.5) # Ensure all connected
88
 
@@ -90,10 +90,10 @@ async def run_race():
90
  consumer_id = "race-consumer-v2"
91
  requests.post(f"{HUB_URL}/register", json={"pubkey": consumer_id})
92
 
93
- task_payload = "Which miner is fastest in the MEP race?"
94
  bounty = 7.5
95
 
96
- print(f"\nπŸ“€ Broadcasting task to {len(miners)} connected miners...")
97
  print(f" Task: {task_payload}")
98
  print(f" Bounty: {bounty} SECONDS")
99
 
@@ -106,20 +106,20 @@ async def run_race():
106
  task_id = resp.json()["task_id"]
107
  print(f" Task ID: {task_id[:8]}...")
108
 
109
- # All miners listen simultaneously
110
- print("\n🏁 ALL MINERS LISTENING... RACE STARTS!")
111
- results = await asyncio.gather(*[miner.listen_for_task(task_id, bounty) for miner in miners])
112
 
113
  # Close connections
114
- for miner in miners:
115
- await miner.close()
116
 
117
  # Results
118
  print("\n" + "=" * 60)
119
  print("RACE RESULTS:")
120
  print("=" * 60)
121
 
122
- winners = [m for m in miners if m.won_race]
123
 
124
  if winners:
125
  winner = winners[0] # First to finish
@@ -130,10 +130,10 @@ async def run_race():
130
 
131
  # Show all times
132
  print(f"\nπŸ“Š All response times:")
133
- for miner in miners:
134
- if miner.response_time:
135
- status = "βœ… WON" if miner.won_race else "❌ Lost"
136
- print(f" {status} {miner.name:20} {miner.response_time:.3f}s")
137
  else:
138
  print("❌ No winner - check hub logs")
139
 
 
1
  #!/usr/bin/env python3
2
  """
3
+ MEP Race Test FIXED: Ensure task is broadcast AFTER all providers connect.
4
  """
5
  import asyncio
6
  import websockets
 
12
  HUB_URL = "http://localhost:8000"
13
  WS_URL = "ws://localhost:8000"
14
 
15
+ class RacingProvider:
16
  def __init__(self, name, location):
17
  self.name = name
18
  self.location = location
 
71
  print("MEP GLOBAL RACE TEST: Real Competition")
72
  print("=" * 60)
73
 
74
+ # Create providers
75
+ providers = [
76
+ RacingProvider("FastProvider-USA", "New York"),
77
+ RacingProvider("SlowProvider-EU", "Berlin"),
78
+ RacingProvider("QuickProvider-Asia", "Singapore"),
79
+ RacingProvider("SteadyProvider-AU", "Sydney")
80
  ]
81
 
82
+ # Connect ALL providers first
83
+ print("\nπŸ”— Connecting providers to hub...")
84
+ for provider in providers:
85
+ await provider.connect()
86
 
87
  await asyncio.sleep(0.5) # Ensure all connected
88
 
 
90
  consumer_id = "race-consumer-v2"
91
  requests.post(f"{HUB_URL}/register", json={"pubkey": consumer_id})
92
 
93
+ task_payload = "Which provider is fastest in the MEP race?"
94
  bounty = 7.5
95
 
96
+ print(f"\nπŸ“€ Broadcasting task to {len(providers)} connected providers...")
97
  print(f" Task: {task_payload}")
98
  print(f" Bounty: {bounty} SECONDS")
99
 
 
106
  task_id = resp.json()["task_id"]
107
  print(f" Task ID: {task_id[:8]}...")
108
 
109
+ # All providers listen simultaneously
110
+ print("\n🏁 ALL PROVIDERS LISTENING... RACE STARTS!")
111
+ results = await asyncio.gather(*[provider.listen_for_task(task_id, bounty) for provider in providers])
112
 
113
  # Close connections
114
+ for provider in providers:
115
+ await provider.close()
116
 
117
  # Results
118
  print("\n" + "=" * 60)
119
  print("RACE RESULTS:")
120
  print("=" * 60)
121
 
122
+ winners = [m for m in providers if m.won_race]
123
 
124
  if winners:
125
  winner = winners[0] # First to finish
 
130
 
131
  # Show all times
132
  print(f"\nπŸ“Š All response times:")
133
+ for provider in providers:
134
+ if provider.response_time:
135
+ status = "βœ… WON" if provider.won_race else "❌ Lost"
136
+ print(f" {status} {provider.name:20} {provider.response_time:.3f}s")
137
  else:
138
  print("❌ No winner - check hub logs")
139
 
node/test_auction.py CHANGED
@@ -7,9 +7,9 @@ import uuid
7
  HUB_URL = "http://localhost:8000"
8
 
9
  async def test():
10
- miner = f'mep-miner-{uuid.uuid4().hex[:6]}'
11
- requests.post(f'{HUB_URL}/register', json={'pubkey': miner})
12
- async with websockets.connect(f'ws://localhost:8000/ws/{miner}') as ws:
13
  consumer = 'test-consumer'
14
  requests.post(f'{HUB_URL}/register', json={'pubkey': consumer})
15
  requests.post(f'{HUB_URL}/tasks/submit', json={'consumer_id': consumer, 'payload': 'Test payload', 'bounty': 1.0})
@@ -20,12 +20,12 @@ async def test():
20
 
21
  if data['event'] == 'rfc':
22
  task_id = data['data']['id']
23
- resp = requests.post(f'{HUB_URL}/tasks/bid', json={'task_id': task_id, 'provider_id': miner})
24
  print('Bid response:', resp.json())
25
 
26
  complete_resp = requests.post(f'{HUB_URL}/tasks/complete', json={
27
  'task_id': task_id,
28
- 'provider_id': miner,
29
  'result_payload': 'Done!'
30
  })
31
  print('Complete response:', complete_resp.json())
 
7
  HUB_URL = "http://localhost:8000"
8
 
9
  async def test():
10
+ provider = f'mep-provider-{uuid.uuid4().hex[:6]}'
11
+ requests.post(f'{HUB_URL}/register', json={'pubkey': provider})
12
+ async with websockets.connect(f'ws://localhost:8000/ws/{provider}') as ws:
13
  consumer = 'test-consumer'
14
  requests.post(f'{HUB_URL}/register', json={'pubkey': consumer})
15
  requests.post(f'{HUB_URL}/tasks/submit', json={'consumer_id': consumer, 'payload': 'Test payload', 'bounty': 1.0})
 
20
 
21
  if data['event'] == 'rfc':
22
  task_id = data['data']['id']
23
+ resp = requests.post(f'{HUB_URL}/tasks/bid', json={'task_id': task_id, 'provider_id': provider})
24
  print('Bid response:', resp.json())
25
 
26
  complete_resp = requests.post(f'{HUB_URL}/tasks/complete', json={
27
  'task_id': task_id,
28
+ 'provider_id': provider,
29
  'result_payload': 'Done!'
30
  })
31
  print('Complete response:', complete_resp.json())