Skip to content

Commit

Permalink
Update to python 3.12 (#113)
Browse files Browse the repository at this point in the history
Ran into some issues in PR #112 so decided to update the python version.

---------

Co-authored-by: Felix Henneke <felix.henneke@protonmail.com>
  • Loading branch information
harisang and fhenneke authored Aug 21, 2024
1 parent 97d0d8f commit 783bf5d
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11
FROM python:3.12
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Clone Repository: <br>
git clone https://github.com/cowprotocol/ebbo.git


Version python 3.10 is used. <br>
Version python 3.12 is used. <br>

### Dependencies:

Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/apis/auctioninstanceapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
API for fetching auction instances from AWS.
"""

# pylint: disable=logging-fstring-interpolation

from typing import Any, Optional
Expand Down
1 change: 1 addition & 0 deletions src/apis/coingeckoapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
CoingeckoAPI for fetching the price in usd of a given token.
"""

# pylint: disable=logging-fstring-interpolation

from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions src/apis/orderbookapi.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/apis/solverapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
API for calling an http solver with auction instances.
"""

# pylint: disable=logging-fstring-interpolation

from os import getenv
Expand Down
1 change: 1 addition & 0 deletions src/apis/tenderlyapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
TenderlyAPI for simulating transactions on tenderly.
"""

# pylint: disable=logging-fstring-interpolation

from os import getenv
Expand Down
1 change: 1 addition & 0 deletions src/apis/tokenlistapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
TokenListAPI for fetching a curated token list.
"""

# pylint: disable=logging-fstring-interpolation
from typing import Optional
import requests
Expand Down
3 changes: 2 additions & 1 deletion src/apis/web3api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Web3API for fetching relevant data using the web3 library.
"""

# pylint: disable=logging-fstring-interpolation

from os import getenv
Expand Down Expand Up @@ -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]:
"""
Expand Down
1 change: 1 addition & 0 deletions src/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
If a settlement failes a test, an error level message is logged.
"""

# pylint: disable=logging-fstring-interpolation

import time
Expand Down
1 change: 1 addition & 0 deletions src/helper_functions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This file contains some auxiliary functions
"""

from __future__ import annotations
import logging
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions src/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of trades, orders, and executions.
"""

from __future__ import annotations
from fractions import Fraction
from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/monitoring_tests/buffers_monitoring_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/cost_coverage_zero_signed_fee.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Computing cost coverage per solver.
"""

# pylint: disable=logging-fstring-interpolation

from typing import Any, Dict
Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/cowamm_commitment_test.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/mev_blocker_kickbacks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Cost coverage test for partially fillable orders.
"""

# pylint: disable=logging-fstring-interpolation

from web3.types import TxData, TxReceipt
Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/reference_solver_surplus_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Comparing order surplus to a reference solution.
"""

# pylint: disable=logging-fstring-interpolation
# pylint: disable=duplicate-code

Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/solver_competition_surplus_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Comparing order surplus accross different solutions.
"""

# pylint: disable=logging-fstring-interpolation

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/monitoring_tests/uniform_directed_prices_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 783bf5d

Please sign in to comment.