Skip to content

Commit 73f5147

Browse files
committed
Fix: Prefix removal was wrong
1 parent ff03e9c commit 73f5147

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/aleph/vm/orchestrator/views/operator.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ class SignedPubKeyHeader(BaseModel):
6666
@validator("signature")
6767
def signature_must_be_hex(cls, v: bytes) -> bytes:
6868
"""Convert the signature from hexadecimal to bytes"""
69-
v = v.strip(b"0x")
70-
return bytes.fromhex(v.decode())
69+
return bytes.fromhex(v.removeprefix(b"0x").decode())
7170

7271
@validator("payload")
7372
def payload_must_be_hex(cls, v: bytes) -> bytes:
@@ -110,8 +109,12 @@ class SignedOperation(BaseModel):
110109
@validator("signature")
111110
def signature_must_be_hex(cls, v) -> bytes:
112111
"""Convert the signature from hexadecimal to bytes"""
113-
v = v.strip(b"0x")
114-
return bytes.fromhex(v.decode())
112+
try:
113+
return bytes.fromhex(v.removeprefix(b"0x").decode())
114+
except pydantic.ValidationError as error:
115+
print(v)
116+
logger.warning(v)
117+
raise error
115118

116119
@validator("payload")
117120
def payload_must_be_hex(cls, v) -> bytes:

0 commit comments

Comments
 (0)