Skip to content
Merged
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
15 changes: 5 additions & 10 deletions bittensor/axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,11 @@ async def some_endpoint(body_dict: dict = Depends(verify_body_integrity)):

# Load the body dict and check if all required field hashes match
body_dict = json.loads(request_body)
field_hashes = []
for required_field in required_hash_fields:
# Hash the field in the body to compare against the header hashes
body_value = body_dict.get(required_field, None)
if body_value == None:
raise ValueError(f"Missing required field {required_field}")
field_hash = bittensor.utils.hash(str(body_value))
field_hashes.append(field_hash)

parsed_body_hash = bittensor.utils.hash("".join(field_hashes))

# Reconstruct the synapse object from the body dict and recompute the hash
syn = self.forward_class_types[request_name](**body_dict)
parsed_body_hash = syn.body_hash # Rehash the body from request

body_hash = request.headers.get("computed_body_hash", "")
if parsed_body_hash != body_hash:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion bittensor/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def body_hash(self) -> str:
hashes = []

# Getting the fields of the instance
instance_fields = self.__dict__
instance_fields = self.dict()

for field, value in instance_fields.items():
# If the field is required in the subclass schema, hash and add it.
Expand Down