From be763227ed42e4a59779170cc1ecc862306eec8d Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 13:26:14 +0300 Subject: [PATCH 1/7] add copium kickbacks --- src/constants.py | 3 ++- .../mev_blocker_kickbacks_test.py | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/constants.py b/src/constants.py index 07e1dd9..b5f5c98 100644 --- a/src/constants.py +++ b/src/constants.py @@ -39,7 +39,8 @@ # relevant addresses SETTLEMENT_CONTRACT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" -MEV_BLOCKER_KICKBACKS_ADDRESS = "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b" +COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS = "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b" +COPIUM_MEV_BlOCKER_KICKBACKS_ADDRESS = "0x008300082C3000009e63680088f8c7f4D3ff2E87" # requests REQUEST_TIMEOUT = 5 diff --git a/src/monitoring_tests/mev_blocker_kickbacks_test.py b/src/monitoring_tests/mev_blocker_kickbacks_test.py index e5573a0..1d3a64a 100644 --- a/src/monitoring_tests/mev_blocker_kickbacks_test.py +++ b/src/monitoring_tests/mev_blocker_kickbacks_test.py @@ -7,7 +7,8 @@ from src.monitoring_tests.base_test import BaseTest from src.apis.web3api import Web3API from src.constants import ( - MEV_BLOCKER_KICKBACKS_ADDRESS, + COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS, + COPIUM_MEV_BLOCKER_KICKBACKS_ADDRESS, KICKBACKS_ALERT_THRESHOLD, ) @@ -31,19 +32,28 @@ def run(self, tx_hash: str) -> bool: if block_number is None: return False - total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( - block_number, block_number, MEV_BLOCKER_KICKBACKS_ADDRESS + cow_dao_total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( + block_number, block_number, COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS ) - if total_eth_kickbacks is None: + copium_total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( + block_number, block_number, COPIUM_MEV_BLOCKER_KICKBACKS_ADDRESS + ) + eth_kickbacks = None + if cow_dao_total_eth_kickbacks is not None: + eth_kickbacks = cow_dao_total_eth_kickbacks + if copium_total_eth_kickbacks is not None: + eth_kickbacks = copium_total_eth_kickbacks + + if eth_kickbacks is None: return False log_output = "\t".join( [ "MEV Blocker kickbacks test:", f"Tx Hash: {tx_hash}", - f"Kickback: {total_eth_kickbacks:.5f}ETH", + f"Kickback: {eth_kickbacks:.5f}ETH", ] ) - if total_eth_kickbacks >= KICKBACKS_ALERT_THRESHOLD: + if eth_kickbacks >= KICKBACKS_ALERT_THRESHOLD: self.alert(log_output) else: self.logger.info(log_output) From e8a4698c3180bd7bbfb24f2246694c04d5576c2b Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 15:09:26 +0300 Subject: [PATCH 2/7] minor rename --- src/constants.py | 2 +- src/monitoring_tests/mev_blocker_kickbacks_test.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/constants.py b/src/constants.py index b5f5c98..a40de49 100644 --- a/src/constants.py +++ b/src/constants.py @@ -40,7 +40,7 @@ # relevant addresses SETTLEMENT_CONTRACT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS = "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b" -COPIUM_MEV_BlOCKER_KICKBACKS_ADDRESS = "0x008300082C3000009e63680088f8c7f4D3ff2E87" +COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS = "0x008300082C3000009e63680088f8c7f4D3ff2E87" # requests REQUEST_TIMEOUT = 5 diff --git a/src/monitoring_tests/mev_blocker_kickbacks_test.py b/src/monitoring_tests/mev_blocker_kickbacks_test.py index 1d3a64a..59b268b 100644 --- a/src/monitoring_tests/mev_blocker_kickbacks_test.py +++ b/src/monitoring_tests/mev_blocker_kickbacks_test.py @@ -8,7 +8,7 @@ from src.apis.web3api import Web3API from src.constants import ( COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS, - COPIUM_MEV_BLOCKER_KICKBACKS_ADDRESS, + COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS, KICKBACKS_ALERT_THRESHOLD, ) @@ -35,14 +35,16 @@ def run(self, tx_hash: str) -> bool: cow_dao_total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( block_number, block_number, COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS ) - copium_total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( - block_number, block_number, COPIUM_MEV_BLOCKER_KICKBACKS_ADDRESS + copium_capital_total_eth_kickbacks = ( + self.web3_api.get_eth_transfers_by_block_range( + block_number, block_number, COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS + ) ) eth_kickbacks = None if cow_dao_total_eth_kickbacks is not None: eth_kickbacks = cow_dao_total_eth_kickbacks - if copium_total_eth_kickbacks is not None: - eth_kickbacks = copium_total_eth_kickbacks + if copium_capital_total_eth_kickbacks is not None: + eth_kickbacks = copium_capital_total_eth_kickbacks if eth_kickbacks is None: return False From e31aa4474704ae26a47663a8339c7cbb4be4a560 Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 15:11:49 +0300 Subject: [PATCH 3/7] black fix --- src/constants.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/constants.py b/src/constants.py index a40de49..81f69d1 100644 --- a/src/constants.py +++ b/src/constants.py @@ -40,7 +40,9 @@ # relevant addresses SETTLEMENT_CONTRACT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS = "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b" -COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS = "0x008300082C3000009e63680088f8c7f4D3ff2E87" +COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS = ( + "0x008300082C3000009e63680088f8c7f4D3ff2E87" +) # requests REQUEST_TIMEOUT = 5 From e0953898aef4a68c9ba084a22135bb3e424f9d8f Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 16:16:07 +0300 Subject: [PATCH 4/7] Address comments --- src/constants.py | 9 ++++---- .../mev_blocker_kickbacks_test.py | 22 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/constants.py b/src/constants.py index 81f69d1..e419313 100644 --- a/src/constants.py +++ b/src/constants.py @@ -39,10 +39,11 @@ # relevant addresses SETTLEMENT_CONTRACT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" -COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS = "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b" -COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS = ( - "0x008300082C3000009e63680088f8c7f4D3ff2E87" -) +MEV_BLOCKER_REFUND_ADDRESSES = [ + "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b", # CoW DAO + "0x008300082C3000009e63680088f8c7f4D3ff2E87", # Copium Capital + "0xbAda55BaBEE5D2B7F3B551f9da846838760E068C", # Project Blanc +] # requests REQUEST_TIMEOUT = 5 diff --git a/src/monitoring_tests/mev_blocker_kickbacks_test.py b/src/monitoring_tests/mev_blocker_kickbacks_test.py index 59b268b..a1f90d6 100644 --- a/src/monitoring_tests/mev_blocker_kickbacks_test.py +++ b/src/monitoring_tests/mev_blocker_kickbacks_test.py @@ -7,8 +7,7 @@ from src.monitoring_tests.base_test import BaseTest from src.apis.web3api import Web3API from src.constants import ( - COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS, - COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS, + MEV_BLOCKER_KICKBACKS_ADDRESSES, KICKBACKS_ALERT_THRESHOLD, ) @@ -32,19 +31,14 @@ def run(self, tx_hash: str) -> bool: if block_number is None: return False - cow_dao_total_eth_kickbacks = self.web3_api.get_eth_transfers_by_block_range( - block_number, block_number, COW_DAO_MEV_BLOCKER_KICKBACKS_ADDRESS - ) - copium_capital_total_eth_kickbacks = ( - self.web3_api.get_eth_transfers_by_block_range( - block_number, block_number, COPIUM_CAPITAL_MEV_BLOCKER_KICKBACKS_ADDRESS - ) - ) eth_kickbacks = None - if cow_dao_total_eth_kickbacks is not None: - eth_kickbacks = cow_dao_total_eth_kickbacks - if copium_capital_total_eth_kickbacks is not None: - eth_kickbacks = copium_capital_total_eth_kickbacks + for address in MEV_BLOCKER_KICKBACKS_ADDRESSES: + kickback = self.web3_api.get_eth_transfers_by_block_range( + block_number, block_number, address + ) + if kickback is not None: + eth_kickbacks = kickback + break if eth_kickbacks is None: return False From a4e70e4a502440a5cfd654071e4dc99c7a8c3059 Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 16:17:46 +0300 Subject: [PATCH 5/7] fix name --- src/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.py b/src/constants.py index e419313..7752f1e 100644 --- a/src/constants.py +++ b/src/constants.py @@ -39,7 +39,7 @@ # relevant addresses SETTLEMENT_CONTRACT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" -MEV_BLOCKER_REFUND_ADDRESSES = [ +MEV_BLOCKER_KICKBACKS_ADDRESSES = [ "0xCe91228789B57DEb45e66Ca10Ff648385fE7093b", # CoW DAO "0x008300082C3000009e63680088f8c7f4D3ff2E87", # Copium Capital "0xbAda55BaBEE5D2B7F3B551f9da846838760E068C", # Project Blanc From 50d4e82ce6aeef9652102c8ce6f41b84dd9bed4b Mon Sep 17 00:00:00 2001 From: Haris Angelidakis <64154020+harisang@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:52:44 +0300 Subject: [PATCH 6/7] Update to python 3.12 (#113) Ran into some issues in PR #112 so decided to update the python version. --------- Co-authored-by: Felix Henneke --- .github/workflows/pull_request.yaml | 4 ++-- Dockerfile | 2 +- README.md | 2 +- requirements.txt | 18 +++++++++--------- src/apis/auctioninstanceapi.py | 1 + src/apis/coingeckoapi.py | 1 + src/apis/orderbookapi.py | 1 + src/apis/solverapi.py | 1 + src/apis/tenderlyapi.py | 1 + src/apis/tokenlistapi.py | 1 + src/apis/web3api.py | 3 ++- src/daemon.py | 1 + src/helper_functions.py | 1 + src/models.py | 1 + src/monitoring_tests/base_test.py | 1 + .../buffers_monitoring_test.py | 10 +++++----- .../cost_coverage_zero_signed_fee.py | 1 + src/monitoring_tests/cowamm_commitment_test.py | 1 + .../mev_blocker_kickbacks_test.py | 1 + .../partially_fillable_cost_coverage_test.py | 1 + .../reference_solver_surplus_test.py | 1 + .../solver_competition_surplus_test.py | 1 + .../uniform_directed_prices_test.py | 1 + tests/e2e/test.py | 1 + 24 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 6302260..4326509 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,10 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup Python 3.10 + - name: Setup Python 3.12 uses: actions/setup-python@v3 with: - python-version: '3.10' + python-version: '3.12' - name: Install Requirements run: pip install -r requirements.txt diff --git a/Dockerfile b/Dockerfile index 83f765f..afaa66a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11 +FROM python:3.12 COPY requirements.txt . RUN python -m pip install -r requirements.txt COPY . . diff --git a/README.md b/README.md index ed8a5b6..8a49d3e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Clone Repository:
git clone https://github.com/cowprotocol/ebbo.git -Version python 3.10 is used.
+Version python 3.12 is used.
### Dependencies: diff --git a/requirements.txt b/requirements.txt index 342be59..e8df969 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -black==23.3.0 -mypy==1.4.1 -pylint==2.17.4 -pytest==7.4.0 -python-dotenv>=0.20.0 -web3==6.5.0 -types-requests +black dune-client -hexbytes~=0.3.1 -requests~=2.31.0 +hexbytes +mypy +pylint +pytest +python-dotenv +requests +types-requests +web3 diff --git a/src/apis/auctioninstanceapi.py b/src/apis/auctioninstanceapi.py index 7f65d9f..e563b70 100644 --- a/src/apis/auctioninstanceapi.py +++ b/src/apis/auctioninstanceapi.py @@ -1,6 +1,7 @@ """ API for fetching auction instances from AWS. """ + # pylint: disable=logging-fstring-interpolation from typing import Any, Optional diff --git a/src/apis/coingeckoapi.py b/src/apis/coingeckoapi.py index b3b50c3..d646f3a 100644 --- a/src/apis/coingeckoapi.py +++ b/src/apis/coingeckoapi.py @@ -1,6 +1,7 @@ """ CoingeckoAPI for fetching the price in usd of a given token. """ + # pylint: disable=logging-fstring-interpolation from typing import Optional diff --git a/src/apis/orderbookapi.py b/src/apis/orderbookapi.py index f8a0054..7f7af86 100644 --- a/src/apis/orderbookapi.py +++ b/src/apis/orderbookapi.py @@ -1,6 +1,7 @@ """ OrderbookAPI for fetching relevant data using the CoW Swap Orderbook API. """ + # pylint: disable=logging-fstring-interpolation from typing import Any, Optional diff --git a/src/apis/solverapi.py b/src/apis/solverapi.py index f0aa545..c22f01e 100644 --- a/src/apis/solverapi.py +++ b/src/apis/solverapi.py @@ -1,6 +1,7 @@ """ API for calling an http solver with auction instances. """ + # pylint: disable=logging-fstring-interpolation from os import getenv diff --git a/src/apis/tenderlyapi.py b/src/apis/tenderlyapi.py index 8c978e4..2cdcc52 100644 --- a/src/apis/tenderlyapi.py +++ b/src/apis/tenderlyapi.py @@ -1,6 +1,7 @@ """ TenderlyAPI for simulating transactions on tenderly. """ + # pylint: disable=logging-fstring-interpolation from os import getenv diff --git a/src/apis/tokenlistapi.py b/src/apis/tokenlistapi.py index ed415af..6faf75d 100644 --- a/src/apis/tokenlistapi.py +++ b/src/apis/tokenlistapi.py @@ -1,6 +1,7 @@ """ TokenListAPI for fetching a curated token list. """ + # pylint: disable=logging-fstring-interpolation from typing import Optional import requests diff --git a/src/apis/web3api.py b/src/apis/web3api.py index f475f11..4664cc6 100644 --- a/src/apis/web3api.py +++ b/src/apis/web3api.py @@ -1,6 +1,7 @@ """ Web3API for fetching relevant data using the web3 library. """ + # pylint: disable=logging-fstring-interpolation from os import getenv @@ -139,7 +140,7 @@ def get_settlement(self, transaction: TxData) -> dict[str, Any]: """ Decode settlement from transaction using the settlement contract. """ - return self.get_settlement_from_calldata(transaction["input"]) + return self.get_settlement_from_calldata(transaction["input"].hex()) def get_settlement_from_calldata(self, calldata: str) -> dict[str, Any]: """ diff --git a/src/daemon.py b/src/daemon.py index 7e8c7af..7bb29d2 100644 --- a/src/daemon.py +++ b/src/daemon.py @@ -4,6 +4,7 @@ If a settlement failes a test, an error level message is logged. """ + # pylint: disable=logging-fstring-interpolation import time diff --git a/src/helper_functions.py b/src/helper_functions.py index a211307..bb800df 100644 --- a/src/helper_functions.py +++ b/src/helper_functions.py @@ -1,6 +1,7 @@ """ This file contains some auxiliary functions """ + from __future__ import annotations import logging from typing import Optional diff --git a/src/models.py b/src/models.py index 3034576..53f7178 100644 --- a/src/models.py +++ b/src/models.py @@ -1,6 +1,7 @@ """ Definition of trades, orders, and executions. """ + from __future__ import annotations from fractions import Fraction from dataclasses import dataclass diff --git a/src/monitoring_tests/base_test.py b/src/monitoring_tests/base_test.py index 7e366e5..05c4ece 100644 --- a/src/monitoring_tests/base_test.py +++ b/src/monitoring_tests/base_test.py @@ -2,6 +2,7 @@ In this file, we introduce the BaseTest class, whose purpose is to be used as the basis for all tests developed. """ + # pylint: disable=logging-fstring-interpolation from abc import ABC, abstractmethod diff --git a/src/monitoring_tests/buffers_monitoring_test.py b/src/monitoring_tests/buffers_monitoring_test.py index b7115a0..0cdeb5e 100644 --- a/src/monitoring_tests/buffers_monitoring_test.py +++ b/src/monitoring_tests/buffers_monitoring_test.py @@ -2,6 +2,7 @@ Checks the value of buffers every 150 settlements by invoking the ehtplorer api, and in some cases, coingecko. """ + # pylint: disable=logging-fstring-interpolation import requests from src.monitoring_tests.base_test import BaseTest @@ -55,9 +56,7 @@ def compute_buffers_value(self) -> bool: decimals = int(token["tokenInfo"]["decimals"]) if token["tokenInfo"]["price"] is not False: price_in_usd = token["tokenInfo"]["price"]["rate"] - token_buffer_value_in_usd = ( - balance / 10**decimals - ) * price_in_usd + token_buffer_value_in_usd = (balance / 10**decimals) * price_in_usd # in case some price is way off and it blows a lot the total value held in the # smart contract we use a second price feed, from coingecko, to correct in case # the initial price is indeed off @@ -70,8 +69,9 @@ def compute_buffers_value(self) -> bool: coingecko_value_in_usd = ( balance / 10**decimals ) * coingecko_price_in_usd - if coingecko_value_in_usd < token_buffer_value_in_usd: - token_buffer_value_in_usd = coingecko_value_in_usd + token_buffer_value_in_usd = min( + token_buffer_value_in_usd, coingecko_value_in_usd + ) value_in_usd += token_buffer_value_in_usd log_output = f"Buffer value is {value_in_usd} USD" if value_in_usd > BUFFERS_VALUE_USD_THRESHOLD: diff --git a/src/monitoring_tests/cost_coverage_zero_signed_fee.py b/src/monitoring_tests/cost_coverage_zero_signed_fee.py index 8c52557..be0ed8e 100644 --- a/src/monitoring_tests/cost_coverage_zero_signed_fee.py +++ b/src/monitoring_tests/cost_coverage_zero_signed_fee.py @@ -1,6 +1,7 @@ """ Computing cost coverage per solver. """ + # pylint: disable=logging-fstring-interpolation from typing import Any, Dict diff --git a/src/monitoring_tests/cowamm_commitment_test.py b/src/monitoring_tests/cowamm_commitment_test.py index 2ba9b31..63651be 100644 --- a/src/monitoring_tests/cowamm_commitment_test.py +++ b/src/monitoring_tests/cowamm_commitment_test.py @@ -1,6 +1,7 @@ """ Checks that commitments for custom CoW AMM of CoW AMM orders are reset. """ + # pylint: disable=duplicate-code from typing import Any diff --git a/src/monitoring_tests/mev_blocker_kickbacks_test.py b/src/monitoring_tests/mev_blocker_kickbacks_test.py index a1f90d6..904d23d 100644 --- a/src/monitoring_tests/mev_blocker_kickbacks_test.py +++ b/src/monitoring_tests/mev_blocker_kickbacks_test.py @@ -3,6 +3,7 @@ It generates an alert when kickbacks due to a specific settlement are more than KICKBACKS_ALERT_THRESHOLD """ + # pylint: disable=logging-fstring-interpolation from src.monitoring_tests.base_test import BaseTest from src.apis.web3api import Web3API diff --git a/src/monitoring_tests/partially_fillable_cost_coverage_test.py b/src/monitoring_tests/partially_fillable_cost_coverage_test.py index 0364170..390c704 100644 --- a/src/monitoring_tests/partially_fillable_cost_coverage_test.py +++ b/src/monitoring_tests/partially_fillable_cost_coverage_test.py @@ -1,6 +1,7 @@ """ Cost coverage test for partially fillable orders. """ + # pylint: disable=logging-fstring-interpolation from web3.types import TxData, TxReceipt diff --git a/src/monitoring_tests/reference_solver_surplus_test.py b/src/monitoring_tests/reference_solver_surplus_test.py index c28cd60..a2d1c21 100644 --- a/src/monitoring_tests/reference_solver_surplus_test.py +++ b/src/monitoring_tests/reference_solver_surplus_test.py @@ -1,6 +1,7 @@ """ Comparing order surplus to a reference solution. """ + # pylint: disable=logging-fstring-interpolation # pylint: disable=duplicate-code diff --git a/src/monitoring_tests/solver_competition_surplus_test.py b/src/monitoring_tests/solver_competition_surplus_test.py index 20f372b..6840429 100644 --- a/src/monitoring_tests/solver_competition_surplus_test.py +++ b/src/monitoring_tests/solver_competition_surplus_test.py @@ -1,6 +1,7 @@ """ Comparing order surplus accross different solutions. """ + # pylint: disable=logging-fstring-interpolation from typing import Any diff --git a/src/monitoring_tests/uniform_directed_prices_test.py b/src/monitoring_tests/uniform_directed_prices_test.py index 9142b01..bdee44b 100644 --- a/src/monitoring_tests/uniform_directed_prices_test.py +++ b/src/monitoring_tests/uniform_directed_prices_test.py @@ -1,6 +1,7 @@ """ Checks the uniform directed prices constraint that was introduced with CIP-38 """ + # pylint: disable=duplicate-code from typing import Any from fractions import Fraction diff --git a/tests/e2e/test.py b/tests/e2e/test.py index 43a1b23..9ee46f8 100644 --- a/tests/e2e/test.py +++ b/tests/e2e/test.py @@ -1,6 +1,7 @@ """ File to run historical block/hash testing for EBBO """ + import unittest from src.monitoring_tests.competition_endpoint_test.endpoint_test import EndpointTest from src.monitoring_tests.fee_monitoring.fee_monitoring import FeeMonitoring From 25e0a6e0ac6ecba234df60097dc965b0f2ad1691 Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 21 Aug 2024 17:59:58 +0300 Subject: [PATCH 7/7] Revert "Update to python 3.12 (#113)" This reverts commit 783bf5d4a7ac91032b006a09d8885142628a9536. --- .github/workflows/pull_request.yaml | 4 ++-- Dockerfile | 2 +- README.md | 2 +- requirements.txt | 18 +++++++++--------- src/apis/auctioninstanceapi.py | 1 - src/apis/coingeckoapi.py | 1 - src/apis/orderbookapi.py | 1 - src/apis/solverapi.py | 1 - src/apis/tenderlyapi.py | 1 - src/apis/tokenlistapi.py | 1 - src/apis/web3api.py | 3 +-- src/daemon.py | 1 - src/helper_functions.py | 1 - src/models.py | 1 - src/monitoring_tests/base_test.py | 1 - .../buffers_monitoring_test.py | 10 +++++----- .../cost_coverage_zero_signed_fee.py | 1 - src/monitoring_tests/cowamm_commitment_test.py | 1 - .../mev_blocker_kickbacks_test.py | 1 - .../partially_fillable_cost_coverage_test.py | 1 - .../reference_solver_surplus_test.py | 1 - .../solver_competition_surplus_test.py | 1 - .../uniform_directed_prices_test.py | 1 - tests/e2e/test.py | 1 - 24 files changed, 19 insertions(+), 38 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 4326509..6302260 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -8,10 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Setup Python 3.12 + - name: Setup Python 3.10 uses: actions/setup-python@v3 with: - python-version: '3.12' + python-version: '3.10' - name: Install Requirements run: pip install -r requirements.txt diff --git a/Dockerfile b/Dockerfile index afaa66a..83f765f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12 +FROM python:3.11 COPY requirements.txt . RUN python -m pip install -r requirements.txt COPY . . diff --git a/README.md b/README.md index 8a49d3e..ed8a5b6 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Clone Repository:
git clone https://github.com/cowprotocol/ebbo.git -Version python 3.12 is used.
+Version python 3.10 is used.
### Dependencies: diff --git a/requirements.txt b/requirements.txt index e8df969..342be59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -black -dune-client -hexbytes -mypy -pylint -pytest -python-dotenv -requests +black==23.3.0 +mypy==1.4.1 +pylint==2.17.4 +pytest==7.4.0 +python-dotenv>=0.20.0 +web3==6.5.0 types-requests -web3 +dune-client +hexbytes~=0.3.1 +requests~=2.31.0 diff --git a/src/apis/auctioninstanceapi.py b/src/apis/auctioninstanceapi.py index e563b70..7f65d9f 100644 --- a/src/apis/auctioninstanceapi.py +++ b/src/apis/auctioninstanceapi.py @@ -1,7 +1,6 @@ """ API for fetching auction instances from AWS. """ - # pylint: disable=logging-fstring-interpolation from typing import Any, Optional diff --git a/src/apis/coingeckoapi.py b/src/apis/coingeckoapi.py index d646f3a..b3b50c3 100644 --- a/src/apis/coingeckoapi.py +++ b/src/apis/coingeckoapi.py @@ -1,7 +1,6 @@ """ CoingeckoAPI for fetching the price in usd of a given token. """ - # pylint: disable=logging-fstring-interpolation from typing import Optional diff --git a/src/apis/orderbookapi.py b/src/apis/orderbookapi.py index 7f7af86..f8a0054 100644 --- a/src/apis/orderbookapi.py +++ b/src/apis/orderbookapi.py @@ -1,7 +1,6 @@ """ OrderbookAPI for fetching relevant data using the CoW Swap Orderbook API. """ - # pylint: disable=logging-fstring-interpolation from typing import Any, Optional diff --git a/src/apis/solverapi.py b/src/apis/solverapi.py index c22f01e..f0aa545 100644 --- a/src/apis/solverapi.py +++ b/src/apis/solverapi.py @@ -1,7 +1,6 @@ """ API for calling an http solver with auction instances. """ - # pylint: disable=logging-fstring-interpolation from os import getenv diff --git a/src/apis/tenderlyapi.py b/src/apis/tenderlyapi.py index 2cdcc52..8c978e4 100644 --- a/src/apis/tenderlyapi.py +++ b/src/apis/tenderlyapi.py @@ -1,7 +1,6 @@ """ TenderlyAPI for simulating transactions on tenderly. """ - # pylint: disable=logging-fstring-interpolation from os import getenv diff --git a/src/apis/tokenlistapi.py b/src/apis/tokenlistapi.py index 6faf75d..ed415af 100644 --- a/src/apis/tokenlistapi.py +++ b/src/apis/tokenlistapi.py @@ -1,7 +1,6 @@ """ TokenListAPI for fetching a curated token list. """ - # pylint: disable=logging-fstring-interpolation from typing import Optional import requests diff --git a/src/apis/web3api.py b/src/apis/web3api.py index 4664cc6..f475f11 100644 --- a/src/apis/web3api.py +++ b/src/apis/web3api.py @@ -1,7 +1,6 @@ """ Web3API for fetching relevant data using the web3 library. """ - # pylint: disable=logging-fstring-interpolation from os import getenv @@ -140,7 +139,7 @@ def get_settlement(self, transaction: TxData) -> dict[str, Any]: """ Decode settlement from transaction using the settlement contract. """ - return self.get_settlement_from_calldata(transaction["input"].hex()) + return self.get_settlement_from_calldata(transaction["input"]) def get_settlement_from_calldata(self, calldata: str) -> dict[str, Any]: """ diff --git a/src/daemon.py b/src/daemon.py index 7bb29d2..7e8c7af 100644 --- a/src/daemon.py +++ b/src/daemon.py @@ -4,7 +4,6 @@ If a settlement failes a test, an error level message is logged. """ - # pylint: disable=logging-fstring-interpolation import time diff --git a/src/helper_functions.py b/src/helper_functions.py index bb800df..a211307 100644 --- a/src/helper_functions.py +++ b/src/helper_functions.py @@ -1,7 +1,6 @@ """ This file contains some auxiliary functions """ - from __future__ import annotations import logging from typing import Optional diff --git a/src/models.py b/src/models.py index 53f7178..3034576 100644 --- a/src/models.py +++ b/src/models.py @@ -1,7 +1,6 @@ """ Definition of trades, orders, and executions. """ - from __future__ import annotations from fractions import Fraction from dataclasses import dataclass diff --git a/src/monitoring_tests/base_test.py b/src/monitoring_tests/base_test.py index 05c4ece..7e366e5 100644 --- a/src/monitoring_tests/base_test.py +++ b/src/monitoring_tests/base_test.py @@ -2,7 +2,6 @@ In this file, we introduce the BaseTest class, whose purpose is to be used as the basis for all tests developed. """ - # pylint: disable=logging-fstring-interpolation from abc import ABC, abstractmethod diff --git a/src/monitoring_tests/buffers_monitoring_test.py b/src/monitoring_tests/buffers_monitoring_test.py index 0cdeb5e..b7115a0 100644 --- a/src/monitoring_tests/buffers_monitoring_test.py +++ b/src/monitoring_tests/buffers_monitoring_test.py @@ -2,7 +2,6 @@ Checks the value of buffers every 150 settlements by invoking the ehtplorer api, and in some cases, coingecko. """ - # pylint: disable=logging-fstring-interpolation import requests from src.monitoring_tests.base_test import BaseTest @@ -56,7 +55,9 @@ def compute_buffers_value(self) -> bool: decimals = int(token["tokenInfo"]["decimals"]) if token["tokenInfo"]["price"] is not False: price_in_usd = token["tokenInfo"]["price"]["rate"] - token_buffer_value_in_usd = (balance / 10**decimals) * price_in_usd + token_buffer_value_in_usd = ( + balance / 10**decimals + ) * price_in_usd # in case some price is way off and it blows a lot the total value held in the # smart contract we use a second price feed, from coingecko, to correct in case # the initial price is indeed off @@ -69,9 +70,8 @@ def compute_buffers_value(self) -> bool: coingecko_value_in_usd = ( balance / 10**decimals ) * coingecko_price_in_usd - token_buffer_value_in_usd = min( - token_buffer_value_in_usd, coingecko_value_in_usd - ) + if coingecko_value_in_usd < token_buffer_value_in_usd: + token_buffer_value_in_usd = coingecko_value_in_usd value_in_usd += token_buffer_value_in_usd log_output = f"Buffer value is {value_in_usd} USD" if value_in_usd > BUFFERS_VALUE_USD_THRESHOLD: diff --git a/src/monitoring_tests/cost_coverage_zero_signed_fee.py b/src/monitoring_tests/cost_coverage_zero_signed_fee.py index be0ed8e..8c52557 100644 --- a/src/monitoring_tests/cost_coverage_zero_signed_fee.py +++ b/src/monitoring_tests/cost_coverage_zero_signed_fee.py @@ -1,7 +1,6 @@ """ Computing cost coverage per solver. """ - # pylint: disable=logging-fstring-interpolation from typing import Any, Dict diff --git a/src/monitoring_tests/cowamm_commitment_test.py b/src/monitoring_tests/cowamm_commitment_test.py index 63651be..2ba9b31 100644 --- a/src/monitoring_tests/cowamm_commitment_test.py +++ b/src/monitoring_tests/cowamm_commitment_test.py @@ -1,7 +1,6 @@ """ Checks that commitments for custom CoW AMM of CoW AMM orders are reset. """ - # pylint: disable=duplicate-code from typing import Any diff --git a/src/monitoring_tests/mev_blocker_kickbacks_test.py b/src/monitoring_tests/mev_blocker_kickbacks_test.py index 904d23d..a1f90d6 100644 --- a/src/monitoring_tests/mev_blocker_kickbacks_test.py +++ b/src/monitoring_tests/mev_blocker_kickbacks_test.py @@ -3,7 +3,6 @@ It generates an alert when kickbacks due to a specific settlement are more than KICKBACKS_ALERT_THRESHOLD """ - # pylint: disable=logging-fstring-interpolation from src.monitoring_tests.base_test import BaseTest from src.apis.web3api import Web3API diff --git a/src/monitoring_tests/partially_fillable_cost_coverage_test.py b/src/monitoring_tests/partially_fillable_cost_coverage_test.py index 390c704..0364170 100644 --- a/src/monitoring_tests/partially_fillable_cost_coverage_test.py +++ b/src/monitoring_tests/partially_fillable_cost_coverage_test.py @@ -1,7 +1,6 @@ """ Cost coverage test for partially fillable orders. """ - # pylint: disable=logging-fstring-interpolation from web3.types import TxData, TxReceipt diff --git a/src/monitoring_tests/reference_solver_surplus_test.py b/src/monitoring_tests/reference_solver_surplus_test.py index a2d1c21..c28cd60 100644 --- a/src/monitoring_tests/reference_solver_surplus_test.py +++ b/src/monitoring_tests/reference_solver_surplus_test.py @@ -1,7 +1,6 @@ """ Comparing order surplus to a reference solution. """ - # pylint: disable=logging-fstring-interpolation # pylint: disable=duplicate-code diff --git a/src/monitoring_tests/solver_competition_surplus_test.py b/src/monitoring_tests/solver_competition_surplus_test.py index 6840429..20f372b 100644 --- a/src/monitoring_tests/solver_competition_surplus_test.py +++ b/src/monitoring_tests/solver_competition_surplus_test.py @@ -1,7 +1,6 @@ """ Comparing order surplus accross different solutions. """ - # pylint: disable=logging-fstring-interpolation from typing import Any diff --git a/src/monitoring_tests/uniform_directed_prices_test.py b/src/monitoring_tests/uniform_directed_prices_test.py index bdee44b..9142b01 100644 --- a/src/monitoring_tests/uniform_directed_prices_test.py +++ b/src/monitoring_tests/uniform_directed_prices_test.py @@ -1,7 +1,6 @@ """ Checks the uniform directed prices constraint that was introduced with CIP-38 """ - # pylint: disable=duplicate-code from typing import Any from fractions import Fraction diff --git a/tests/e2e/test.py b/tests/e2e/test.py index 9ee46f8..43a1b23 100644 --- a/tests/e2e/test.py +++ b/tests/e2e/test.py @@ -1,7 +1,6 @@ """ File to run historical block/hash testing for EBBO """ - import unittest from src.monitoring_tests.competition_endpoint_test.endpoint_test import EndpointTest from src.monitoring_tests.fee_monitoring.fee_monitoring import FeeMonitoring