Skip to content
Open
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
2 changes: 1 addition & 1 deletion bt_automata/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def add_args(cls, parser):
"--blacklist.force_validator_permit",
action="store_true",
help="If set, we will force incoming requests to have a permit.",
default=False,
default=True,
)

parser.add_argument(
Expand Down
20 changes: 13 additions & 7 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,22 @@ async def blacklist(
Otherwise, allow the request to be processed further.
"""
# TODO(developer): Define how miners should blacklist requests.
if synapse.dendrite.hotkey not in self.metagraph.hotkeys:
# Ignore requests from unrecognized entities.
uid = self.metagraph.hotkeys.index( synapse.dendrite.hotkey)
if not self.config.blacklist.allow_non_registered and synapse.dendrite.hotkey not in self.metagraph.hotkeys:
# Ignore requests from un-registered entities.
bt.logging.trace(
f"Blacklisting unrecognized hotkey {synapse.dendrite.hotkey}"
f"Blacklisting un-registered hotkey {synapse.dendrite.hotkey}"
)
return True, "Unrecognized hotkey"

bt.logging.trace(
f"Not Blacklisting recognized hotkey {synapse.dendrite.hotkey}"
)

if self.config.blacklist.force_validator_permit:
# If the config is set to force validator permit, then we should only allow requests from validators.
if not self.metagraph.validator_permit[uid]:
bt.logging.warning(
f"Blacklisting a request from non-validator hotkey {synapse.dendrite.hotkey}"
)
return True, "Non-validator hotkey"

return False, "Hotkey recognized!"

async def priority(self, synapse: bt_automata.protocol.CAsynapse) -> float:
Expand Down
20 changes: 20 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import cellpylib as cpl
import pprint

cellular_automaton = cpl.init_simple(50)

cellular_automaton = cpl.evolve(cellular_automaton, timesteps=50, memoize=True,
apply_rule=lambda n, c, t: cpl.nks_rule(n, 110))

#cpl.plot(cellular_automaton)

# Define the characters for visualization
char_1 = "\033[92m#\033[0m" # Green color for 1's
char_0 = "." # No color for 0's

# Convert the binary array to a string representation
visualization = "\n".join("".join(char_1 if cell == 1 else char_0 for cell in row) for row in cellular_automaton)

# Print the visualization with smooth margins
#pprint.pprint(visualization, width=30)
print(f"echo -e '{visualization}'")