Skip to content

Commit

Permalink
Reactivate tests and remove dead code (#706)
Browse files Browse the repository at this point in the history
* Fix regression tests

* Update test phase with recordings

* Deprecate pkg_resources

* Deprecate distutils

* add packaging in requirements.txt (for docker)

* re-add setting of BlockApi in cfg parser, otherwise cant get_revelation

---------

Co-authored-by: Nicolas Ochem <nicolas.ochem@gmail.com>
  • Loading branch information
vkresch and nicolasochem authored Jul 10, 2024
1 parent 0a666c3 commit 726a3a7
Show file tree
Hide file tree
Showing 71 changed files with 1,269 additions and 21,119 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
python -m pip install -r requirements.txt
python -m pip install -r requirements_developers.txt
- name: Test with pytest
run: pytest tests/

build-documentation:
runs-on: ubuntu-latest
strategy:
Expand Down
6 changes: 0 additions & 6 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ Available configuration parameters are:
tz1RMmSzPSWPSSaKU193Voh4PosWSZx1C7Hs: Dexter #(indicates address is a dexter pool; TRD will send rewards to pool members)
mindelegation: TOE #(mindelegation will be shared with everyone)

**tzpro_api_key**
Generate a tzpro API key [here](https://tzpro.io/) if you want to use it as reward or block API.

Example::
tzpro_api_key: XXXXXXXXXX

**plugins**
Please consult the `plugins docs`_ for more details on the configuring the various plugins.

Expand Down
1 change: 0 additions & 1 deletion examples/tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ baking_address: tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889
payment_address: KT1KLQbYFtFZ5mAEnfEMZaWYuNtCsGuP5cLS
rewards_type: actual
service_fee: 4.5
tzpro_api_key: XXXXXXXX
founders_map:
{'tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889' : 0.3,
'KT1KLQbYFtFZ5mAEnfEMZaWYuNtCsGuP5cLS' : 0.7}
Expand Down
6 changes: 0 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ TRD supports complex payments, pays in batches, and supports three backends for

**Provider notes:**

### Blockwatch: TZPRO

The [terms and conditions](https://tzpro.io/terms) of TZPRO note that an account and API key are needed for the use of the API. Please review the [pricing](https://tzpro.io/#pricing) information. For further help contact hello@blockwatch.cc for more information.

In order to use your API key in the application add it to your configuration like tzpro_api_key: XXXXXXXXXX.

### TzKT

The [terms of use](https://api.tzkt.io/#section/Terms-of-Use) of TzKT API allow for commercial and non-commercial use.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ parse>=1.19.1
transitions>=0.9.0
tweepy>=4.14.0
pip>=23.3.1
packaging>=24.1
6 changes: 0 additions & 6 deletions src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@
CURRENT_TESTNET: "https://testnet.smartpy.io",
}

# TzPro
TZPRO_API_URL = {
"MAINNET": "https://api.tzpro.io",
CURRENT_TESTNET: "https://api.{}.tzpro.io".format(TESTNET_PREFIX.lower()),
}

# TzKT
TZKT_PUBLIC_API_URL = {
"MAINNET": "https://api.tzkt.io/v1",
Expand Down
2 changes: 0 additions & 2 deletions src/api/provider_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def newRewardApi(
node_url,
node_url_public="",
api_base_url=None,
tzpro_api_key="",
):
return TzKTRewardApiImpl(network_config, baking_address, base_url=api_base_url)

Expand All @@ -22,6 +21,5 @@ def newBlockApi(
network_config,
node_url,
api_base_url=None,
tzpro_api_key="",
):
return TzKTBlockApiImpl(network_config, base_url=api_base_url)
3 changes: 0 additions & 3 deletions src/cli/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from Constants import (
TEZOS_RPC_PORT,
PUBLIC_NODE_URL,
TZPRO_API_URL,
TZKT_PUBLIC_API_URL,
CURRENT_TESTNET,
PRIVATE_SIGNER_URL,
Expand All @@ -22,8 +21,6 @@
PUBLIC_NODE_URLS = [
PUBLIC_NODE_URL[CURRENT_TESTNET],
PUBLIC_NODE_URL["MAINNET"],
TZPRO_API_URL[CURRENT_TESTNET],
TZPRO_API_URL["MAINNET"],
TZKT_PUBLIC_API_URL[CURRENT_TESTNET],
TZKT_PUBLIC_API_URL["MAINNET"],
]
Expand Down
8 changes: 0 additions & 8 deletions src/config/yaml_baking_conf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,10 @@ def __init__(
self.clnt_mngr = clnt_mngr
self.network_config = network_config
if block_api is None:
# NOTE: We need to parse the config early to get the api key for tzpro if no block api was defined
# TODO: We might wanna disable the option to pass a None block_api parameter
tzpro_api_key = (
""
if provider_factory.provider != "tzpro"
else yaml.safe_load(yaml_text).get("tzpro_api_key", "")
)
block_api = provider_factory.newBlockApi(
network_config,
node_url,
api_base_url=api_base_url,
tzpro_api_key=tzpro_api_key,
)
self.block_api = block_api
self.dry_run = dry_run
Expand Down
32 changes: 26 additions & 6 deletions src/launch_common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import sys
import pkg_resources
import subprocess

from time import sleep
from datetime import date
from importlib.metadata import version, PackageNotFoundError
from packaging.version import parse

from Constants import (
PYTHON_MAJOR,
Expand All @@ -31,7 +32,7 @@ def python_version_ok(args=None):
)
else:
print(
"... installed Python version {}.{} is greater then minimum required version {}.{}. OK!\n".format(
"... installed Python version {}.{} is greater than the minimum required version {}.{}. OK!\n".format(
major,
minor,
PYTHON_MAJOR,
Expand Down Expand Up @@ -81,7 +82,7 @@ def new_protocol_not_live(args=None):
(
"Protocol {} could be live now. If it is live there are risks using this branch.\n"
"It is suggested to reach out to the community to confirm, and switch to the new test branch \n"
"or accept of the risks of using this branch".format(NEW_PROTOCOL_NAME)
"or accept the risks of using this branch".format(NEW_PROTOCOL_NAME)
)
)
return True
Expand Down Expand Up @@ -109,10 +110,29 @@ def requirements_installed(requirement_path=REQUIREMENTS_FILE_PATH):
try:
with open(requirement_path, "r") as requirements:
for requirement in requirements:
requirement = requirement.strip()
if not requirement or requirement.startswith("#"):
continue
try:
pkg_resources.require(requirement)
except Exception as e:
requirement = requirement.replace("\n", "")
if ">=" in requirement:
package_name, package_version = requirement.split(">=")
elif "==" in requirement:
package_name, package_version = requirement.split("==")
else:
package_name = requirement
package_version = None

installed_version = version(package_name)
if package_version and not parse(installed_version) >= parse(
package_version
):
missing_requirements.append(requirement)
print(
"... requirement {} was not met: installed version {}\n".format(
requirement, installed_version
)
)
except (PackageNotFoundError, ValueError) as e:
missing_requirements.append(requirement)
print(
"... requirement {} was not found: {}\n".format(requirement, e)
Expand Down
4 changes: 0 additions & 4 deletions src/model/baking_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
REWARDS_TYPE = "rewards_type"
PAY_DENUNCIATION_REWARDS = "pay_denunciation_rewards"
MIN_PAYMENT_AMT = "min_payment_amt"
TZPRO_API_KEY = "tzpro_api_key"

# extensions
FULL_SUPPORTERS_SET = "__full_supporters_set"
Expand Down Expand Up @@ -122,6 +121,3 @@ def __repr__(self) -> str:

def get_min_payment_amount(self):
return self.get_attribute(MIN_PAYMENT_AMT)

def get_tzpro_api_key(self):
return self.get_attribute(TZPRO_API_KEY, default=None)
39 changes: 18 additions & 21 deletions src/pay/payment_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def __init__(
retry_injected=False,
):
super(PaymentProducer, self).__init__()
self.exiting = False
self.nw_config = network_config
self.payments_root = payments_dir
self.calculations_dir = calculations_dir
self.run_mode = run_mode

self.payment_offset = payment_offset
self.payments_queue = payments_queue
self.life_cycle = life_cycle
self.dry_run = dry_run
self.consumer_failure = False

self.retry_fail_thread = threading.Thread(
target=self.retry_fail_run, name=self.name + "_retry_fail"
)
self.retry_fail_event = threading.Event()
self.retry_injected = retry_injected

self.event = threading.Event()
self.rules_model = RulesModel(
baking_cfg.get_excluded_set_tob(),
Expand All @@ -72,20 +90,17 @@ def __init__(

self.node_url = node_url
self.client_manager = client_manager
self.tzpro_api_key = baking_cfg.get_tzpro_api_key()
self.reward_api = self.provider_factory.newRewardApi(
network_config,
self.baking_address,
self.node_url,
node_url_public,
api_base_url,
self.tzpro_api_key,
)
self.block_api = self.provider_factory.newBlockApi(
network_config,
self.node_url,
api_base_url,
self.tzpro_api_key,
)

dexter_contracts_set = baking_cfg.get_contracts_set()
Expand All @@ -109,18 +124,6 @@ def __init__(

logger.info("Initial cycle set to {}".format(self.initial_payment_cycle))

self.nw_config = network_config
self.payments_root = payments_dir
self.calculations_dir = calculations_dir
self.run_mode = run_mode
self.exiting = False

self.payment_offset = payment_offset
self.payments_queue = payments_queue
self.life_cycle = life_cycle
self.dry_run = dry_run
self.consumer_failure = False

self.payment_calc = PhasedPaymentCalculator(
self.founders_map,
self.owners_map,
Expand All @@ -131,12 +134,6 @@ def __init__(
self.reward_api,
)

self.retry_fail_thread = threading.Thread(
target=self.retry_fail_run, name=self.name + "_retry_fail"
)
self.retry_fail_event = threading.Event()
self.retry_injected = retry_injected

self.retry_producer = RetryProducer(
self.payments_queue,
self.reward_api,
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 726a3a7

Please sign in to comment.