diff --git a/pyproject.toml b/pyproject.toml index b1f91345..1650588c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,13 +18,13 @@ schema = "^0.7.5" websocket-client = "^1.4.1" confluent-kafka = "^2.2.0" web3 = "^6.10.0" -pre-commit = "^3.8.0" [tool.poetry.group.dev.dependencies] ruff = "^0.4.4" pytest = "^8.2.0" pytest-cov = "^5.0.0" pyright = "^1.1.362" +pre-commit = "^3.8.0" [tool.pytest.ini_options] pythonpath = [ diff --git a/src/cryptography/verify_signature.py b/src/cryptography/verify_signature.py index a8863e2d..2384a393 100644 --- a/src/cryptography/verify_signature.py +++ b/src/cryptography/verify_signature.py @@ -35,6 +35,7 @@ def recover_vs(vs: str) -> tuple[VRS, VRS]: def compute_vs(v: int, s: str) -> str: """Returns aggregated _vs value.""" if v < V_OFFSET and v not in [0, 1]: + logger.error({'msg': 'Signature invalid v byte.', 'data': str(v)}) raise ValueError('Signature invalid v byte.') if v < V_OFFSET: v += V_OFFSET diff --git a/src/transport/msg_types/common.py b/src/transport/msg_types/common.py index aa038e81..863e39dd 100644 --- a/src/transport/msg_types/common.py +++ b/src/transport/msg_types/common.py @@ -5,6 +5,7 @@ from cryptography.verify_signature import recover_vs, verify_message_with_signature from eth_account.account import VRS from metrics.metrics import UNEXPECTED_EXCEPTIONS +from transport.msg_providers.rabbit import MessageType from transport.msg_types.deposit import DepositMessage from transport.msg_types.pause import PauseMessage from transport.msg_types.unvet import UnvetMessage @@ -46,11 +47,11 @@ def _vrs(msg: DepositMessage | PauseMessage | UnvetMessage) -> tuple[VRS, VRS, V def _select_label(msg: DepositMessage | PauseMessage | UnvetMessage) -> str: t = msg['type'] - if t == 'pause': + if t == MessageType.PAUSE: return 'pause_message_verification_failed' - elif t == 'unvet': - return 'get_unvet_messages_sign_filter' - elif t == 'deposit': + elif t == MessageType.UNVET: + return 'unvet_message_verification_failed' + elif t == MessageType.DEPOSIT: return 'deposit_message_verification_failed' else: raise ValueError('Unsupported message type') @@ -58,13 +59,13 @@ def _select_label(msg: DepositMessage | PauseMessage | UnvetMessage) -> str: def _verification_data(web3: Web3, msg: DepositMessage | PauseMessage | UnvetMessage) -> tuple[List[Any], List[str]]: t = msg['type'] - if t == 'pause': + if t == MessageType.PAUSE: prefix = web3.lido.deposit_security_module.get_pause_message_prefix() return _verification_data_pause(prefix, msg) - elif t == 'unvet': + elif t == MessageType.UNVET: prefix = web3.lido.deposit_security_module.get_unvet_message_prefix() return _verification_data_unvet(prefix, msg) - elif t == 'deposit': + elif t == MessageType.DEPOSIT: prefix = web3.lido.deposit_security_module.get_attest_message_prefix() return _verification_data_deposit(prefix, msg) else: