diff --git a/.flake8 b/.flake8 deleted file mode 100644 index ea38e9cb9918..000000000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 120 -exclude = ./typings/**/* -ignore = E203,W503 diff --git a/.flake8 b/.flake8 new file mode 120000 index 000000000000..10cc3cc249ed --- /dev/null +++ b/.flake8 @@ -0,0 +1 @@ +.github/linters/.flake8 \ No newline at end of file diff --git a/.github/linters/.isort.cfg b/.github/linters/.isort.cfg new file mode 100644 index 000000000000..d21b9f236f1b --- /dev/null +++ b/.github/linters/.isort.cfg @@ -0,0 +1,20 @@ +[settings] +profile= + +; vertical hanging indent mode also used in black configuration +multi_line_output = 3 + +; necessary because black expect the trailing comma +include_trailing_comma = true + +; black compatibility +force_grid_wrap = 0 + +; black compatibility +use_parentheses = True + +; black compatibility +ensure_newline_before_comments = True + +; we chose 120 as line length +line_length = 120 diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 891050c79ba9..918cf875e3d8 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -54,7 +54,6 @@ jobs: VALIDATE_ALL_CODEBASE: true DEFAULT_BRANCH: main LINTER_RULES_PATH: .github/linters - PYTHON_BLACK_CONFIG_FILE: .python-black VALIDATE_BASH: true VALIDATE_CSS: true VALIDATE_DOCKER: true @@ -68,6 +67,7 @@ jobs: VALIDATE_PYTHON_PYLINT: true VALIDATE_PYTHON_FLAKE8: true VALIDATE_PYTHON_BLACK: true +# VALIDATE_PYTHON_ISORT: true VALIDATE_SHELL_SHFMT: true VALIDATE_TYPESCRIPT_ES: true VALIDATE_YAML: true diff --git a/.isort.cfg b/.isort.cfg new file mode 120000 index 000000000000..00a153712e71 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1 @@ +.github/linters/.isort.cfg \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f506f3cb874..badfffb552d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not yet adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for setuptools_scm/PEP 440 reasons. +## Unreleased 1.0rc6 aka Release Candidate 6 - 2020-03-1? + +### Added + +## Changed + +- Remove `chia plots "-s" "--stripe_size"` - we now always use the best default of 64K + ## 1.0rc5 aka Release Candidate 5 - 2020-03-04 ### Added @@ -21,7 +29,6 @@ for setuptools_scm/PEP 440 reasons. ## Changed -- Remove `chia plots "-s" "--stripe_size"` - we now always use the best default of 64K - Testnets and mainnet now set their minimum `k` size and enforce it. RC5 testnet will reject plots of size less than k=32. - Sub slots now require 16 blocks instead of 12. - Thanks to @xdustinface of Dash, the BlS Signature library has been updated to 0.9 with clean ups and some speed ups. This changed how the G2 infinity element was handled and we now manage it inside of chia-blockchain, etc., instead of in blspy. diff --git a/setup.py b/setup.py index b4e53cbb943c..154cafd2e2eb 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ from setuptools import setup - dependencies = [ "aiter==0.13.20191203", # Used for async generator tools "blspy==0.9", # Signature library diff --git a/src/__init__.py b/src/__init__.py index f519f074ade4..45acb36d66fb 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,4 +1,4 @@ -from pkg_resources import get_distribution, DistributionNotFound +from pkg_resources import DistributionNotFound, get_distribution try: __version__ = get_distribution("chia-blockchain").version diff --git a/src/cmds/chia.py b/src/cmds/chia.py index 87ad78566f72..5c92e7ebc2c9 100644 --- a/src/cmds/chia.py +++ b/src/cmds/chia.py @@ -1,22 +1,21 @@ import asyncio -import click from pathlib import Path -from src import __version__ -from src.util.default_root import DEFAULT_ROOT_PATH -from src.daemon.server import async_run_daemon +import click +from src import __version__ +from src.cmds.configure import configure_cmd +from src.cmds.farm import farm_cmd from src.cmds.init import init_cmd from src.cmds.keys import keys_cmd +from src.cmds.netspace import netspace_cmd from src.cmds.plots import plots_cmd -from src.cmds.wallet import wallet_cmd -from src.cmds.configure import configure_cmd from src.cmds.show import show_cmd from src.cmds.start import start_cmd from src.cmds.stop import stop_cmd -from src.cmds.netspace import netspace_cmd -from src.cmds.farm import farm_cmd - +from src.cmds.wallet import wallet_cmd +from src.daemon.server import async_run_daemon +from src.util.default_root import DEFAULT_ROOT_PATH CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) diff --git a/src/cmds/configure.py b/src/cmds/configure.py index 4ee73ecb9992..fc6d5cd0cfe8 100644 --- a/src/cmds/configure.py +++ b/src/cmds/configure.py @@ -1,13 +1,10 @@ -import click from pathlib import Path - -from src.util.config import ( - load_config, - save_config, -) from typing import Dict + +import click + +from src.util.config import load_config, save_config, str2bool from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.config import str2bool def configure(root_path: Path, set_node_introducer: str, set_fullnode_port: str, set_log_level: str, enable_upnp: str): diff --git a/src/cmds/farm.py b/src/cmds/farm.py index 38e4df172f9b..4f4c7f15ec4f 100644 --- a/src/cmds/farm.py +++ b/src/cmds/farm.py @@ -1,17 +1,16 @@ -import math -from typing import Optional, Dict, Any, List import asyncio +import math from decimal import Decimal - -import click +from typing import Any, Dict, List, Optional import aiohttp +import click from src.consensus.block_record import BlockRecord -from src.rpc.wallet_rpc_client import WalletRpcClient -from src.rpc.harvester_rpc_client import HarvesterRpcClient -from src.rpc.full_node_rpc_client import FullNodeRpcClient from src.rpc.farmer_rpc_client import FarmerRpcClient +from src.rpc.full_node_rpc_client import FullNodeRpcClient +from src.rpc.harvester_rpc_client import HarvesterRpcClient +from src.rpc.wallet_rpc_client import WalletRpcClient from src.util.config import load_config from src.util.default_root import DEFAULT_ROOT_PATH from src.util.ints import uint16 diff --git a/src/cmds/init.py b/src/cmds/init.py index 1b44c2c45783..10dfff2f8c1f 100644 --- a/src/cmds/init.py +++ b/src/cmds/init.py @@ -1,31 +1,27 @@ -import click -from src import __version__ -from pathlib import Path import os import shutil +from pathlib import Path +from typing import Any, Dict, List, Tuple -from typing import List, Dict, Any, Tuple - -from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.keychain import Keychain +import click +import yaml -from src.util.config import unflatten_properties +from src import __version__ from src.consensus.coinbase import create_puzzlehash_for_pk -from src.util.ints import uint32 - +from src.ssl.create_ssl import generate_ca_signed_cert, get_chia_ca_crt_key, make_ca_cert +from src.util.bech32m import encode_puzzle_hash from src.util.config import ( create_default_chia_config, + initial_config_file, load_config, save_config, - initial_config_file, + unflatten_properties, ) +from src.util.default_root import DEFAULT_ROOT_PATH +from src.util.ints import uint32 +from src.util.keychain import Keychain from src.util.path import mkdir -import yaml - -from src.ssl.create_ssl import get_chia_ca_crt_key, generate_ca_signed_cert, make_ca_cert -from src.wallet.derive_keys import master_sk_to_wallet_sk, master_sk_to_pool_sk -from src.util.bech32m import encode_puzzle_hash - +from src.wallet.derive_keys import master_sk_to_pool_sk, master_sk_to_wallet_sk private_node_names = {"full_node", "wallet", "farmer", "harvester", "timelord", "daemon"} public_node_names = {"full_node", "wallet", "farmer", "introducer", "timelord"} diff --git a/src/cmds/keys.py b/src/cmds/keys.py index 575c52ff0306..efa49379afbc 100644 --- a/src/cmds/keys.py +++ b/src/cmds/keys.py @@ -1,27 +1,17 @@ -import click - from pathlib import Path from typing import List +import click from blspy import AugSchemeMPL, G1Element, G2Element from src.cmds.init import check_keys +from src.consensus.coinbase import create_puzzlehash_for_pk from src.util.bech32m import encode_puzzle_hash from src.util.config import load_config from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.keychain import ( - generate_mnemonic, - bytes_to_mnemonic, - Keychain, -) -from src.wallet.derive_keys import ( - master_sk_to_pool_sk, - master_sk_to_farmer_sk, - master_sk_to_wallet_sk, -) from src.util.ints import uint32 -from src.consensus.coinbase import create_puzzlehash_for_pk - +from src.util.keychain import Keychain, bytes_to_mnemonic, generate_mnemonic +from src.wallet.derive_keys import master_sk_to_farmer_sk, master_sk_to_pool_sk, master_sk_to_wallet_sk keychain: Keychain = Keychain() diff --git a/src/cmds/netspace.py b/src/cmds/netspace.py index 2e1e56239cea..747254f61255 100644 --- a/src/cmds/netspace.py +++ b/src/cmds/netspace.py @@ -1,13 +1,14 @@ -import click -import aiohttp import asyncio + +import aiohttp +import click + +from src.rpc.full_node_rpc_client import FullNodeRpcClient +from src.util.byte_types import hexstr_to_bytes from src.util.config import load_config from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.byte_types import hexstr_to_bytes from src.util.ints import uint16 -from src.rpc.full_node_rpc_client import FullNodeRpcClient - async def netstorge_async(rpc_port: int, delta_block_height: str, start: str) -> None: """ diff --git a/src/cmds/plots.py b/src/cmds/plots.py index 44b4455e1947..5ce839edecc9 100644 --- a/src/cmds/plots.py +++ b/src/cmds/plots.py @@ -1,18 +1,14 @@ -import click +import logging import sys - from pathlib import Path -import logging -from src.plotting.plot_tools import ( - add_plot_directory, - remove_plot_directory, - get_plot_directories, -) -from src.plotting.create_plots import create_plots + +import click + from src.plotting.check_plots import check_plots +from src.plotting.create_plots import create_plots +from src.plotting.plot_tools import add_plot_directory, get_plot_directories, remove_plot_directory from src.util.chia_logging import initialize_logging - DEFAULT_STRIPE_SIZE = 65536 log = logging.getLogger(__name__) diff --git a/src/cmds/show.py b/src/cmds/show.py index ff9ba0f985bc..c3b15d090ca1 100644 --- a/src/cmds/show.py +++ b/src/cmds/show.py @@ -1,21 +1,20 @@ -import click -import traceback - -import aiohttp import asyncio import time -from time import struct_time, localtime - +import traceback +from time import localtime, struct_time from typing import List, Optional +import aiohttp +import click + from src.consensus.block_record import BlockRecord +from src.rpc.full_node_rpc_client import FullNodeRpcClient from src.server.outbound_message import NodeType from src.types.full_block import FullBlock -from src.rpc.full_node_rpc_client import FullNodeRpcClient +from src.util.bech32m import encode_puzzle_hash from src.util.byte_types import hexstr_to_bytes from src.util.config import load_config from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.bech32m import encode_puzzle_hash from src.util.ints import uint16 diff --git a/src/cmds/start.py b/src/cmds/start.py index 46734154fba2..d29f2e1107de 100644 --- a/src/cmds/start.py +++ b/src/cmds/start.py @@ -1,11 +1,12 @@ -import click import asyncio import os import subprocess from pathlib import Path from typing import Optional -from src.daemon.client import connect_to_daemon_and_validate, DaemonProxy +import click + +from src.daemon.client import DaemonProxy, connect_to_daemon_and_validate from src.daemon.server import not_launched_error_message from src.util.service_groups import all_groups, services_for_groups diff --git a/src/cmds/stop.py b/src/cmds/stop.py index 8ce11c0bc96f..92d91a89c2f8 100644 --- a/src/cmds/stop.py +++ b/src/cmds/stop.py @@ -1,8 +1,9 @@ -import click -import sys import asyncio +import sys from pathlib import Path +import click + from src.daemon.client import connect_to_daemon_and_validate from src.util.service_groups import all_groups, services_for_groups diff --git a/src/cmds/wallet.py b/src/cmds/wallet.py index 855792a8d72a..0344fbbb5c64 100644 --- a/src/cmds/wallet.py +++ b/src/cmds/wallet.py @@ -1,23 +1,23 @@ -import click +import asyncio import sys import time from datetime import datetime -from typing import Tuple, Optional, Callable, List +from decimal import Decimal +from typing import Callable, List, Optional, Tuple import aiohttp -import asyncio +import click +from src.cmds.units import units from src.rpc.wallet_rpc_client import WalletRpcClient from src.server.start_wallet import SERVICE_NAME from src.util.bech32m import encode_puzzle_hash from src.util.byte_types import hexstr_to_bytes from src.util.config import load_config from src.util.default_root import DEFAULT_ROOT_PATH -from src.util.ints import uint64, uint16 +from src.util.ints import uint16, uint64 from src.wallet.transaction_record import TransactionRecord from src.wallet.util.wallet_types import WalletType -from src.cmds.units import units -from decimal import Decimal def print_transaction(tx: TransactionRecord, verbose: bool, name) -> None: diff --git a/src/consensus/block_body_validation.py b/src/consensus/block_body_validation.py index ee41fcbc882a..0d5b5c552e3e 100644 --- a/src/consensus/block_body_validation.py +++ b/src/consensus/block_body_validation.py @@ -1,40 +1,36 @@ import collections -from typing import Union, Optional, Set, List, Dict, Tuple +import logging +from typing import Dict, List, Optional, Set, Tuple, Union from blspy import AugSchemeMPL from chiabip158 import PyBIP158 from clvm.casts import int_from_bytes -from src.consensus.block_rewards import ( - calculate_pool_reward, - calculate_base_farmer_reward, -) +from src.consensus.block_record import BlockRecord +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward +from src.consensus.block_root_validation import validate_block_merkle_roots +from src.consensus.blockchain_check_conditions import blockchain_check_conditions_dict from src.consensus.blockchain_interface import BlockchainInterface -from src.consensus.coinbase import create_pool_coin, create_farmer_coin +from src.consensus.coinbase import create_farmer_coin, create_pool_coin from src.consensus.constants import ConsensusConstants +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.consensus.find_fork_point import find_fork_point_in_chain -from src.consensus.block_root_validation import validate_block_merkle_roots from src.consensus.network_type import NetworkType from src.full_node.block_store import BlockStore -from src.consensus.blockchain_check_conditions import blockchain_check_conditions_dict from src.full_node.coin_store import CoinStore -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult -from src.consensus.block_record import BlockRecord +from src.types.announcement import Announcement from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_record import CoinRecord -from src.types.announcement import Announcement from src.types.condition_opcodes import ConditionOpcode from src.types.condition_var_pair import ConditionVarPair from src.types.full_block import FullBlock, additions_for_npc, announcements_for_npc from src.types.name_puzzle_condition import NPC -from src.types.blockchain_format.sized_bytes import bytes32 from src.types.unfinished_block import UnfinishedBlock from src.util.condition_tools import pkm_pairs_for_conditions_dict from src.util.errors import Err from src.util.hash import std_hash -from src.util.ints import uint64, uint32 - -import logging +from src.util.ints import uint32, uint64 log = logging.getLogger(__name__) diff --git a/src/consensus/block_creation.py b/src/consensus/block_creation.py index 58787bfbe874..edf238212bff 100644 --- a/src/consensus/block_creation.py +++ b/src/consensus/block_creation.py @@ -1,44 +1,33 @@ import random from dataclasses import replace -from typing import Optional, Callable, Dict, List, Tuple +from typing import Callable, Dict, List, Optional, Tuple import blspy -from blspy import G2Element, G1Element +from blspy import G1Element, G2Element from chiabip158 import PyBIP158 -from src.consensus.block_rewards import ( - calculate_pool_reward, - calculate_base_farmer_reward, -) +from src.consensus.block_record import BlockRecord +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.consensus.blockchain_interface import BlockchainInterface -from src.consensus.coinbase import create_pool_coin, create_farmer_coin +from src.consensus.coinbase import create_farmer_coin, create_pool_coin from src.consensus.constants import ConsensusConstants +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.full_node.bundle_tools import best_solution_program -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult from src.full_node.signage_point import SignagePoint -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.coin import Coin, hash_coin_list -from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.types.blockchain_format.foliage import ( - Foliage, - FoliageTransactionBlock, - TransactionsInfo, - FoliageBlockData, -) -from src.types.full_block import FullBlock +from src.types.blockchain_format.foliage import Foliage, FoliageBlockData, FoliageTransactionBlock, TransactionsInfo from src.types.blockchain_format.pool_target import PoolTarget from src.types.blockchain_format.program import SerializedProgram from src.types.blockchain_format.proof_of_space import ProofOfSpace -from src.types.blockchain_format.reward_chain_block import ( - RewardChainBlockUnfinished, - RewardChainBlock, -) +from src.types.blockchain_format.reward_chain_block import RewardChainBlock, RewardChainBlockUnfinished from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.blockchain_format.vdf import VDFInfo, VDFProof +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.types.full_block import FullBlock from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock -from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.util.hash import std_hash -from src.util.ints import uint128, uint64, uint32, uint8 +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.merkle_set import MerkleSet from src.util.prev_transaction_block import get_prev_transaction_block from src.util.recursive_replace import recursive_replace diff --git a/src/consensus/block_header_validation.py b/src/consensus/block_header_validation.py index 5a924affd7d4..fed0b21323ec 100644 --- a/src/consensus/block_header_validation.py +++ b/src/consensus/block_header_validation.py @@ -1,38 +1,35 @@ import dataclasses import logging import time -from typing import Optional, List, Tuple +from typing import List, Optional, Tuple from blspy import AugSchemeMPL +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants from src.consensus.deficit import calculate_deficit from src.consensus.difficulty_adjustment import can_finish_sub_and_full_epoch -from src.consensus.get_block_challenge import ( - get_block_challenge, - final_eos_is_already_included, -) +from src.consensus.get_block_challenge import final_eos_is_already_included, get_block_challenge from src.consensus.make_sub_epoch_summary import make_sub_epoch_summary from src.consensus.pot_iterations import ( - is_overflow_block, calculate_ip_iters, - calculate_sp_iters, calculate_iterations_quality, calculate_sp_interval_iters, + calculate_sp_iters, + is_overflow_block, ) from src.consensus.vdf_info_computation import get_signage_point_vdf_info -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.slots import ChallengeChainSubSlot, RewardChainSubSlot, SubSlotProofs -from src.types.unfinished_header_block import UnfinishedHeaderBlock from src.types.blockchain_format.vdf import VDFInfo, VDFProof +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.types.header_block import HeaderBlock +from src.types.unfinished_header_block import UnfinishedHeaderBlock from src.util.errors import Err, ValidationError from src.util.hash import std_hash -from src.util.ints import uint32, uint64, uint128, uint8 +from src.util.ints import uint8, uint32, uint64, uint128 log = logging.getLogger(__name__) diff --git a/src/consensus/block_record.py b/src/consensus/block_record.py index 903742cbc195..8a4492fd6a94 100644 --- a/src/consensus/block_record.py +++ b/src/consensus/block_record.py @@ -1,14 +1,14 @@ from dataclasses import dataclass -from typing import Optional, List +from typing import List, Optional from src.consensus.constants import ConsensusConstants -from src.consensus.pot_iterations import calculate_sp_iters, calculate_ip_iters +from src.consensus.pot_iterations import calculate_ip_iters, calculate_sp_iters +from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary from src.util.ints import uint8, uint32, uint64, uint128 -from src.types.blockchain_format.sized_bytes import bytes32 from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.classgroup import ClassgroupElement @dataclass(frozen=True) diff --git a/src/consensus/blockchain.py b/src/consensus/blockchain.py index a7f53957a161..b4c63b2234bc 100644 --- a/src/consensus/blockchain.py +++ b/src/consensus/blockchain.py @@ -1,40 +1,34 @@ import asyncio import dataclasses import logging +import multiprocessing from concurrent.futures.process import ProcessPoolExecutor - -from src.consensus.multiprocess_validation import pre_validate_blocks_multiprocessing, PreValidationResult -from src.types.header_block import HeaderBlock -from src.types.weight_proof import SubEpochChallengeSegment -from src.util.streamable import recurse_jsonify from enum import Enum -import multiprocessing -from typing import Dict, List, Optional, Tuple, Set +from typing import Dict, List, Optional, Set, Tuple +from src.consensus.block_body_validation import validate_block_body +from src.consensus.block_header_validation import validate_finished_header_block, validate_unfinished_header_block +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.block_body_validation import validate_block_body +from src.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty +from src.consensus.find_fork_point import find_fork_point_in_chain +from src.consensus.full_block_to_block_record import block_to_block_record +from src.consensus.multiprocess_validation import PreValidationResult, pre_validate_blocks_multiprocessing from src.full_node.block_store import BlockStore from src.full_node.coin_store import CoinStore -from src.consensus.difficulty_adjustment import ( - get_next_sub_slot_iters_and_difficulty, -) -from src.consensus.full_block_to_block_record import block_to_block_record -from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.types.full_block import FullBlock from src.types.blockchain_format.sized_bytes import bytes32 -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.blockchain_format.vdf import VDFInfo +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock from src.types.unfinished_block import UnfinishedBlock -from src.util.errors import Err -from src.util.ints import uint32, uint64, uint128, uint16 -from src.consensus.find_fork_point import find_fork_point_in_chain -from src.consensus.block_header_validation import ( - validate_finished_header_block, - validate_unfinished_header_block, -) from src.types.unfinished_header_block import UnfinishedHeaderBlock -from src.types.blockchain_format.vdf import VDFInfo +from src.types.weight_proof import SubEpochChallengeSegment +from src.util.errors import Err +from src.util.ints import uint16, uint32, uint64, uint128 +from src.util.streamable import recurse_jsonify log = logging.getLogger(__name__) diff --git a/src/consensus/blockchain_check_conditions.py b/src/consensus/blockchain_check_conditions.py index c9742c30e92e..9f829277b8f1 100644 --- a/src/consensus/blockchain_check_conditions.py +++ b/src/consensus/blockchain_check_conditions.py @@ -1,12 +1,12 @@ -from typing import Optional, Dict, List, Set +from typing import Dict, List, Optional, Set -from src.types.condition_var_pair import ConditionVarPair -from src.types.coin_record import CoinRecord from src.types.announcement import Announcement +from src.types.coin_record import CoinRecord +from src.types.condition_var_pair import ConditionVarPair from src.util.clvm import int_from_bytes from src.util.condition_tools import ConditionOpcode from src.util.errors import Err -from src.util.ints import uint64, uint32 +from src.util.ints import uint32, uint64 def blockchain_assert_my_coin_id(condition: ConditionVarPair, unspent: CoinRecord) -> Optional[Err]: diff --git a/src/consensus/blockchain_interface.py b/src/consensus/blockchain_interface.py index e56ef9ebf7f1..934e95485af2 100644 --- a/src/consensus/blockchain_interface.py +++ b/src/consensus/blockchain_interface.py @@ -1,12 +1,12 @@ -from typing import List, Optional, Dict +from typing import Dict, List, Optional from src.consensus.block_record import BlockRecord -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.blockchain_format.vdf import VDFInfo +from src.types.header_block import HeaderBlock from src.types.weight_proof import SubEpochChallengeSegment from src.util.ints import uint32 -from src.types.blockchain_format.vdf import VDFInfo class BlockchainInterface: diff --git a/src/consensus/coinbase.py b/src/consensus/coinbase.py index 9f1b8057ddc9..445c51fad987 100644 --- a/src/consensus/coinbase.py +++ b/src/consensus/coinbase.py @@ -1,10 +1,10 @@ -from blspy import G1Element, PrivateKey, G2Element, AugSchemeMPL +from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey -from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint64, uint32 from src.types.blockchain_format.coin import Coin -from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_pk +from src.types.blockchain_format.sized_bytes import bytes32 from src.util.hash import std_hash +from src.util.ints import uint32, uint64 +from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_pk def create_puzzlehash_for_pk(pub_key: G1Element) -> bytes32: diff --git a/src/consensus/constants.py b/src/consensus/constants.py index 8cee3989c1d5..bb1c23d6afe3 100644 --- a/src/consensus/constants.py +++ b/src/consensus/constants.py @@ -2,7 +2,7 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.util.byte_types import hexstr_to_bytes -from src.util.ints import uint64, uint32, uint8, uint128 +from src.util.ints import uint8, uint32, uint64, uint128 @dataclasses.dataclass(frozen=True) diff --git a/src/consensus/cost_calculator.py b/src/consensus/cost_calculator.py index 2dcd34448d89..c97f383580fd 100644 --- a/src/consensus/cost_calculator.py +++ b/src/consensus/cost_calculator.py @@ -1,13 +1,13 @@ from dataclasses import dataclass -from typing import Optional, List +from typing import List, Optional from src.consensus.condition_costs import ConditionCost -from src.types.condition_opcodes import ConditionOpcode +from src.full_node.mempool_check_conditions import get_name_puzzle_conditions from src.types.blockchain_format.program import SerializedProgram +from src.types.condition_opcodes import ConditionOpcode from src.types.name_puzzle_condition import NPC -from src.util.ints import uint64, uint16 -from src.full_node.mempool_check_conditions import get_name_puzzle_conditions -from src.util.streamable import streamable, Streamable +from src.util.ints import uint16, uint64 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/consensus/default_constants.py b/src/consensus/default_constants.py index e13da3c343c9..a22c874a0de5 100644 --- a/src/consensus/default_constants.py +++ b/src/consensus/default_constants.py @@ -1,7 +1,8 @@ -from .constants import ConsensusConstants from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint64 +from .constants import ConsensusConstants + testnet_kwargs = { "SLOT_BLOCKS_TARGET": 32, "MIN_BLOCKS_PER_CHALLENGE_BLOCK": 16, # Must be less than half of SLOT_BLOCKS_TARGET diff --git a/src/consensus/deficit.py b/src/consensus/deficit.py index 8659929c0c73..12744025fb37 100644 --- a/src/consensus/deficit.py +++ b/src/consensus/deficit.py @@ -1,8 +1,8 @@ from typing import Optional -from src.consensus.constants import ConsensusConstants from src.consensus.block_record import BlockRecord -from src.util.ints import uint32, uint8 +from src.consensus.constants import ConsensusConstants +from src.util.ints import uint8, uint32 def calculate_deficit( diff --git a/src/consensus/difficulty_adjustment.py b/src/consensus/difficulty_adjustment.py index 24f2dac87c47..4f9b53cedddc 100644 --- a/src/consensus/difficulty_adjustment.py +++ b/src/consensus/difficulty_adjustment.py @@ -1,15 +1,11 @@ from typing import List, Optional, Tuple +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface - from src.consensus.constants import ConsensusConstants from src.types.blockchain_format.sized_bytes import bytes32 -from src.consensus.block_record import BlockRecord -from src.util.ints import uint32, uint64, uint128, uint8 -from src.util.significant_bits import ( - count_significant_bits, - truncate_to_significant_bits, -) +from src.util.ints import uint8, uint32, uint64, uint128 +from src.util.significant_bits import count_significant_bits, truncate_to_significant_bits def _get_blocks_at_height( diff --git a/src/consensus/find_fork_point.py b/src/consensus/find_fork_point.py index 5d4850083d8d..96d1d3789338 100644 --- a/src/consensus/find_fork_point.py +++ b/src/consensus/find_fork_point.py @@ -1,7 +1,7 @@ from typing import Union -from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.block_record import BlockRecord +from src.consensus.blockchain_interface import BlockchainInterface from src.types.header_block import HeaderBlock diff --git a/src/consensus/full_block_to_block_record.py b/src/consensus/full_block_to_block_record.py index 47783cd2f16d..16f80f97b848 100644 --- a/src/consensus/full_block_to_block_record.py +++ b/src/consensus/full_block_to_block_record.py @@ -1,19 +1,19 @@ -from typing import Optional, Union, List +from typing import List, Optional, Union +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.pot_iterations import is_overflow_block from src.consensus.deficit import calculate_deficit from src.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty +from src.consensus.make_sub_epoch_summary import make_sub_epoch_summary +from src.consensus.pot_iterations import is_overflow_block from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.slots import ChallengeBlockInfo -from src.types.full_block import FullBlock -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary -from src.util.ints import uint64, uint32, uint8 -from src.consensus.make_sub_epoch_summary import make_sub_epoch_summary +from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock +from src.util.ints import uint8, uint32, uint64 def block_to_block_record( diff --git a/src/consensus/get_block_challenge.py b/src/consensus/get_block_challenge.py index 570a17877d37..85fdadaa5454 100644 --- a/src/consensus/get_block_challenge.py +++ b/src/consensus/get_block_challenge.py @@ -1,16 +1,14 @@ +import logging from typing import List, Union +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.block_record import BlockRecord +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.full_block import FullBlock from src.types.header_block import HeaderBlock -from src.types.blockchain_format.sized_bytes import bytes32 from src.types.unfinished_block import UnfinishedBlock from src.types.unfinished_header_block import UnfinishedHeaderBlock - -import logging - from src.util.ints import uint64 log = logging.getLogger(__name__) diff --git a/src/consensus/make_sub_epoch_summary.py b/src/consensus/make_sub_epoch_summary.py index 773ee6d04d36..6b018cdcacd0 100644 --- a/src/consensus/make_sub_epoch_summary.py +++ b/src/consensus/make_sub_epoch_summary.py @@ -1,27 +1,22 @@ +import logging from typing import Optional, Union +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.pot_iterations import ( - calculate_ip_iters, - calculate_sp_iters, - is_overflow_block, -) from src.consensus.deficit import calculate_deficit from src.consensus.difficulty_adjustment import ( - get_next_sub_slot_iters_and_difficulty, _get_next_difficulty, _get_next_sub_slot_iters, - height_can_be_first_in_epoch, can_finish_sub_and_full_epoch, + get_next_sub_slot_iters_and_difficulty, + height_can_be_first_in_epoch, ) -from src.consensus.block_record import BlockRecord -from src.types.full_block import FullBlock +from src.consensus.pot_iterations import calculate_ip_iters, calculate_sp_iters, is_overflow_block from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.full_block import FullBlock from src.types.unfinished_block import UnfinishedBlock -from src.util.ints import uint32, uint64, uint8, uint128 - -import logging +from src.util.ints import uint8, uint32, uint64, uint128 log = logging.getLogger(__name__) diff --git a/src/consensus/multiprocess_validation.py b/src/consensus/multiprocess_validation.py index a779b89e6508..056c13f30892 100644 --- a/src/consensus/multiprocess_validation.py +++ b/src/consensus/multiprocess_validation.py @@ -3,9 +3,10 @@ import traceback from concurrent.futures.process import ProcessPoolExecutor from dataclasses import dataclass -from typing import List, Optional, Tuple, Dict, Union, Sequence +from typing import Dict, List, Optional, Sequence, Tuple, Union from src.consensus.block_header_validation import validate_finished_header_block +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants from src.consensus.cost_calculator import CostResult, calculate_cost_of_program @@ -13,16 +14,15 @@ from src.consensus.full_block_to_block_record import block_to_block_record from src.consensus.get_block_challenge import get_block_challenge from src.consensus.network_type import NetworkType -from src.consensus.pot_iterations import is_overflow_block, calculate_iterations_quality -from src.consensus.block_record import BlockRecord -from src.types.full_block import FullBlock -from src.types.header_block import HeaderBlock +from src.consensus.pot_iterations import calculate_iterations_quality, is_overflow_block from src.types.blockchain_format.program import SerializedProgram from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock from src.util.block_cache import BlockCache from src.util.errors import Err -from src.util.ints import uint64, uint16 -from src.util.streamable import dataclass_from_dict, streamable, Streamable +from src.util.ints import uint16, uint64 +from src.util.streamable import Streamable, dataclass_from_dict, streamable log = logging.getLogger(__name__) diff --git a/src/consensus/pos_quality.py b/src/consensus/pos_quality.py index 19c8dfc7b6ff..b044530ae049 100644 --- a/src/consensus/pos_quality.py +++ b/src/consensus/pos_quality.py @@ -1,6 +1,5 @@ -from src.util.ints import uint64 from src.types.blockchain_format.sized_bytes import bytes32 - +from src.util.ints import uint64 # The actual space in bytes of a plot, is _expected_plot_size(k) * UI_ACTUAL_SPACE_CONSTANT_FACTO # This is not used in consensus, only for display purposes diff --git a/src/consensus/pot_iterations.py b/src/consensus/pot_iterations.py index dd534543fe0d..d090d8744cf8 100644 --- a/src/consensus/pot_iterations.py +++ b/src/consensus/pot_iterations.py @@ -1,8 +1,8 @@ +from src.consensus.constants import ConsensusConstants +from src.consensus.pos_quality import quality_str_to_quality from src.types.blockchain_format.sized_bytes import bytes32 from src.util.hash import std_hash -from src.util.ints import uint64, uint128, uint8 -from src.consensus.pos_quality import quality_str_to_quality -from src.consensus.constants import ConsensusConstants +from src.util.ints import uint8, uint64, uint128 def is_overflow_block(constants: ConsensusConstants, signage_point_index: uint8) -> bool: diff --git a/src/consensus/vdf_info_computation.py b/src/consensus/vdf_info_computation.py index 4f83323a4f18..4197b3b9dd27 100644 --- a/src/consensus/vdf_info_computation.py +++ b/src/consensus/vdf_info_computation.py @@ -1,12 +1,12 @@ from typing import List, Optional +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint128, uint64 +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.util.ints import uint64, uint128 def get_signage_point_vdf_info( diff --git a/src/daemon/client.py b/src/daemon/client.py index 1b8001291566..9f01f4c12ec8 100644 --- a/src/daemon/client.py +++ b/src/daemon/client.py @@ -1,16 +1,16 @@ +import asyncio import json import ssl -from typing import Dict, Any, Optional from pathlib import Path +from typing import Any, Dict, Optional -import asyncio import websockets from src.server.server import ssl_context_for_client from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ws_message import create_payload_dict, WsRpcMessage -from src.util.json_util import dict_to_json_str from src.util.config import load_config +from src.util.json_util import dict_to_json_str +from src.util.ws_message import WsRpcMessage, create_payload_dict class DaemonProxy: diff --git a/src/daemon/server.py b/src/daemon/server.py index f23cc6b61995..2a3a2b746e94 100644 --- a/src/daemon/server.py +++ b/src/daemon/server.py @@ -5,31 +5,33 @@ import signal import subprocess import sys +import time import traceback -from pathlib import Path -from enum import Enum import uuid -import time -from typing import Dict, Any, List, Tuple, Optional, TextIO, cast from concurrent.futures import ThreadPoolExecutor -from websockets import serve, ConnectionClosedOK, WebSocketException, WebSocketServerProtocol +from enum import Enum +from pathlib import Path +from typing import Any, Dict, List, Optional, TextIO, Tuple, cast + +from websockets import ConnectionClosedOK, WebSocketException, WebSocketServerProtocol, serve + from src.cmds.init import chia_init from src.daemon.windows_signal import kill -from src.server.server import ssl_context_for_server, ssl_context_for_root +from src.server.server import ssl_context_for_root, ssl_context_for_server from src.ssl.create_ssl import get_mozzila_ca_crt -from src.util.setproctitle import setproctitle -from src.util.validate_alert import validate_alert -from src.util.ws_message import format_response, create_payload, WsRpcMessage -from src.util.json_util import dict_to_json_str -from src.util.config import load_config, save_config from src.util.chia_logging import initialize_logging +from src.util.config import load_config, save_config +from src.util.json_util import dict_to_json_str from src.util.path import mkdir from src.util.service_groups import validate_service +from src.util.setproctitle import setproctitle +from src.util.validate_alert import validate_alert +from src.util.ws_message import WsRpcMessage, create_payload, format_response io_pool_exc = ThreadPoolExecutor() try: - from aiohttp import web, ClientSession + from aiohttp import ClientSession, web except ModuleNotFoundError: print("Error: Make sure to run . ./activate from the project folder before starting Chia.") quit() diff --git a/src/daemon/windows_signal.py b/src/daemon/windows_signal.py index 2ccce72cbe44..340ac182b8ff 100644 --- a/src/daemon/windows_signal.py +++ b/src/daemon/windows_signal.py @@ -4,8 +4,8 @@ """ import os -import sys import signal +import sys if sys.platform != "win32" and sys.platform != "cygwin": kill = os.kill diff --git a/src/farmer/farmer.py b/src/farmer/farmer.py index 67ab79f55adb..7bdda4334f24 100644 --- a/src/farmer/farmer.py +++ b/src/farmer/farmer.py @@ -1,24 +1,22 @@ import asyncio import logging import time -from typing import Dict, List, Optional, Callable, Tuple, Any +from typing import Any, Callable, Dict, List, Optional, Tuple -import src.server.ws_connection as ws # lgtm [py/import-and-import-from] from blspy import G1Element -from src.protocols.protocol_message_types import ProtocolMessageTypes -from src.server.ws_connection import WSChiaConnection -from src.util.keychain import Keychain - +import src.server.ws_connection as ws # lgtm [py/import-and-import-from] from src.consensus.constants import ConsensusConstants - from src.protocols import farmer_protocol, harvester_protocol +from src.protocols.protocol_message_types import ProtocolMessageTypes from src.server.outbound_message import NodeType, make_msg +from src.server.ws_connection import WSChiaConnection from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 +from src.util.bech32m import decode_puzzle_hash from src.util.ints import uint64 +from src.util.keychain import Keychain from src.wallet.derive_keys import master_sk_to_farmer_sk, master_sk_to_pool_sk -from src.util.bech32m import decode_puzzle_hash log = logging.getLogger(__name__) diff --git a/src/farmer/farmer_api.py b/src/farmer/farmer_api.py index 906ccc02d896..b6281928402a 100644 --- a/src/farmer/farmer_api.py +++ b/src/farmer/farmer_api.py @@ -2,14 +2,11 @@ from typing import Callable, Optional from blspy import AugSchemeMPL, G2Element -import src.server.ws_connection as ws -from src.consensus.pot_iterations import ( - calculate_iterations_quality, - calculate_sp_interval_iters, -) +import src.server.ws_connection as ws +from src.consensus.pot_iterations import calculate_iterations_quality, calculate_sp_interval_iters from src.farmer.farmer import Farmer -from src.protocols import harvester_protocol, farmer_protocol +from src.protocols import farmer_protocol, harvester_protocol from src.protocols.protocol_message_types import ProtocolMessageTypes from src.server.outbound_message import NodeType, make_msg from src.types.blockchain_format.pool_target import PoolTarget diff --git a/src/full_node/block_store.py b/src/full_node/block_store.py index 1fba9c7f26e3..a7c57bbfabdb 100644 --- a/src/full_node/block_store.py +++ b/src/full_node/block_store.py @@ -1,14 +1,15 @@ import logging -import aiosqlite from typing import Dict, List, Optional, Tuple -from src.types.full_block import FullBlock -from src.types.header_block import HeaderBlock +import aiosqlite + +from src.consensus.block_record import BlockRecord from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary -from src.types.weight_proof import SubEpochSegments, SubEpochChallengeSegment +from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock +from src.types.weight_proof import SubEpochChallengeSegment, SubEpochSegments from src.util.ints import uint32 -from src.consensus.block_record import BlockRecord from src.util.lru_cache import LRUCache log = logging.getLogger(__name__) diff --git a/src/full_node/bundle_tools.py b/src/full_node/bundle_tools.py index 0d4651f83970..8111c8f35caa 100644 --- a/src/full_node/bundle_tools.py +++ b/src/full_node/bundle_tools.py @@ -1,5 +1,5 @@ -from clvm_tools import binutils from clvm import SExp +from clvm_tools import binutils from src.types.blockchain_format.program import SerializedProgram from src.types.spend_bundle import SpendBundle diff --git a/src/full_node/coin_store.py b/src/full_node/coin_store.py index 3ab7c5d576ce..d9f563f9c40c 100644 --- a/src/full_node/coin_store.py +++ b/src/full_node/coin_store.py @@ -1,9 +1,11 @@ -from typing import Dict, Optional, List +from typing import Dict, List, Optional + import aiosqlite -from src.types.full_block import FullBlock + from src.types.blockchain_format.coin import Coin -from src.types.coin_record import CoinRecord from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_record import CoinRecord +from src.types.full_block import FullBlock from src.util.ints import uint32, uint64 diff --git a/src/full_node/full_node.py b/src/full_node/full_node.py index 2a8215f4c312..e895ed1f9f93 100644 --- a/src/full_node/full_node.py +++ b/src/full_node/full_node.py @@ -5,22 +5,20 @@ import time import traceback from pathlib import Path -from typing import Optional, Dict, Callable, List, Tuple, Any, Union, Set +from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union import aiosqlite from blspy import AugSchemeMPL import src.server.ws_connection as ws # lgtm [py/import-and-import-from] from src.consensus.block_creation import unfinished_block_to_full_block +from src.consensus.block_record import BlockRecord from src.consensus.blockchain import Blockchain, ReceiveBlockResult from src.consensus.constants import ConsensusConstants -from src.consensus.difficulty_adjustment import ( - get_next_sub_slot_iters_and_difficulty, -) +from src.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty from src.consensus.make_sub_epoch_summary import next_sub_epoch_summary from src.consensus.multiprocess_validation import PreValidationResult from src.consensus.pot_iterations import calculate_sp_iters -from src.consensus.block_record import BlockRecord from src.full_node.block_store import BlockStore from src.full_node.coin_store import CoinStore from src.full_node.full_node_store import FullNodeStore @@ -28,31 +26,25 @@ from src.full_node.signage_point import SignagePoint from src.full_node.sync_store import SyncStore from src.full_node.weight_proof import WeightProofHandler -from src.protocols import ( - full_node_protocol, - timelord_protocol, - wallet_protocol, - farmer_protocol, -) -from src.protocols.full_node_protocol import RequestBlocks, RejectBlocks, RespondBlocks, RespondBlock +from src.protocols import farmer_protocol, full_node_protocol, timelord_protocol, wallet_protocol +from src.protocols.full_node_protocol import RejectBlocks, RequestBlocks, RespondBlock, RespondBlocks from src.protocols.protocol_message_types import ProtocolMessageTypes - from src.server.node_discovery import FullNodePeers from src.server.outbound_message import Message, NodeType, make_msg from src.server.server import ChiaServer -from src.types.full_block import FullBlock +from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.pool_target import PoolTarget from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.blockchain_format.vdf import CompressibleVDFField, VDFInfo, VDFProof +from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock -from src.types.blockchain_format.vdf import VDFInfo, VDFProof, CompressibleVDFField from src.util.errors import ConsensusError, Err -from src.util.ints import uint32, uint128, uint8, uint64 +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.path import mkdir, path_from_root -from src.types.header_block import HeaderBlock -from src.types.blockchain_format.classgroup import ClassgroupElement class FullNode: diff --git a/src/full_node/full_node_api.py b/src/full_node/full_node_api.py index 47632975b6e4..64ea7264d21c 100644 --- a/src/full_node/full_node_api.py +++ b/src/full_node/full_node_api.py @@ -1,51 +1,37 @@ import asyncio import dataclasses import time +from typing import Callable, Dict, List, Optional, Tuple -import src.server.ws_connection as ws -from typing import List, Optional, Tuple, Callable, Dict +from blspy import AugSchemeMPL, G2Element from chiabip158 import PyBIP158 -from blspy import G2Element, AugSchemeMPL +import src.server.ws_connection as ws from src.consensus.block_creation import create_unfinished_block -from src.consensus.pot_iterations import ( - calculate_ip_iters, - calculate_sp_iters, - calculate_iterations_quality, -) +from src.consensus.block_record import BlockRecord +from src.consensus.pot_iterations import calculate_ip_iters, calculate_iterations_quality, calculate_sp_iters from src.full_node.full_node import FullNode from src.full_node.mempool_check_conditions import get_puzzle_and_solution_for_coin from src.full_node.signage_point import SignagePoint -from src.consensus.block_record import BlockRecord - - -from src.protocols import ( - farmer_protocol, - full_node_protocol, - timelord_protocol, - wallet_protocol, - introducer_protocol, -) -from src.protocols.full_node_protocol import RejectBlocks, RejectBlock +from src.protocols import farmer_protocol, full_node_protocol, introducer_protocol, timelord_protocol, wallet_protocol +from src.protocols.full_node_protocol import RejectBlock, RejectBlocks from src.protocols.protocol_message_types import ProtocolMessageTypes -from src.protocols.wallet_protocol import RejectHeaderRequest, PuzzleSolutionResponse, RejectHeaderBlocks +from src.protocols.wallet_protocol import PuzzleSolutionResponse, RejectHeaderBlocks, RejectHeaderRequest from src.server.outbound_message import Message, NodeType, make_msg from src.types.blockchain_format.coin import Coin, hash_coin_list - +from src.types.blockchain_format.pool_target import PoolTarget +from src.types.blockchain_format.program import Program +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.full_block import FullBlock from src.types.header_block import HeaderBlock - from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.types.mempool_item import MempoolItem -from src.types.blockchain_format.pool_target import PoolTarget -from src.types.blockchain_format.program import Program -from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.peer_info import PeerInfo from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock from src.util.api_decorators import api_request, peer_required -from src.util.ints import uint64, uint128, uint8, uint32 -from src.types.peer_info import PeerInfo +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.merkle_set import MerkleSet diff --git a/src/full_node/full_node_store.py b/src/full_node/full_node_store.py index 7285bc661056..6f5fc5edd970 100644 --- a/src/full_node/full_node_store.py +++ b/src/full_node/full_node_store.py @@ -1,19 +1,19 @@ import dataclasses import logging -from typing import Dict, List, Optional, Tuple, Set +from typing import Dict, List, Optional, Set, Tuple +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants from src.consensus.multiprocess_validation import PreValidationResult from src.full_node.signage_point import SignagePoint -from src.consensus.block_record import BlockRecord from src.protocols import timelord_protocol from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.unfinished_block import UnfinishedBlock from src.types.blockchain_format.vdf import VDFInfo -from src.util.ints import uint32, uint8, uint64, uint128 +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.types.unfinished_block import UnfinishedBlock +from src.util.ints import uint8, uint32, uint64, uint128 log = logging.getLogger(__name__) diff --git a/src/full_node/mempool.py b/src/full_node/mempool.py index 9d437c74bda6..2e01835cc8cb 100644 --- a/src/full_node/mempool.py +++ b/src/full_node/mempool.py @@ -1,10 +1,10 @@ -from typing import List, Dict +from typing import Dict, List from sortedcontainers import SortedDict from src.types.blockchain_format.coin import Coin -from src.types.mempool_item import MempoolItem from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.mempool_item import MempoolItem class Mempool: diff --git a/src/full_node/mempool_check_conditions.py b/src/full_node/mempool_check_conditions.py index 53b79ddcc38b..7f08fd4c0a06 100644 --- a/src/full_node/mempool_check_conditions.py +++ b/src/full_node/mempool_check_conditions.py @@ -1,18 +1,18 @@ +import time import traceback -from typing import Optional, List, Dict +from typing import Dict, List, Optional -from src.types.condition_var_pair import ConditionVarPair -from src.types.spend_bundle import SpendBundle -from src.types.coin_record import CoinRecord -from src.types.name_puzzle_condition import NPC from src.types.blockchain_format.program import SerializedProgram from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_record import CoinRecord +from src.types.condition_var_pair import ConditionVarPair +from src.types.name_puzzle_condition import NPC +from src.types.spend_bundle import SpendBundle from src.util.clvm import int_from_bytes from src.util.condition_tools import ConditionOpcode, conditions_by_opcode from src.util.errors import Err -import time -from src.util.ints import uint64, uint32 -from src.wallet.puzzles.generator_loader import GENERATOR_MOD, GENERATOR_FOR_SINGLE_COIN_MOD +from src.util.ints import uint32, uint64 +from src.wallet.puzzles.generator_loader import GENERATOR_FOR_SINGLE_COIN_MOD, GENERATOR_MOD def mempool_assert_announcement_consumed(condition: ConditionVarPair, spend_bundle: SpendBundle) -> Optional[Err]: diff --git a/src/full_node/mempool_manager.py b/src/full_node/mempool_manager.py index 44e3e565b351..a4a8ab8678b5 100644 --- a/src/full_node/mempool_manager.py +++ b/src/full_node/mempool_manager.py @@ -1,36 +1,35 @@ import asyncio import collections import dataclasses +import logging import time from concurrent.futures.process import ProcessPoolExecutor -from typing import Dict, Optional, Tuple, List, Set -import logging +from typing import Dict, List, Optional, Set, Tuple +from blspy import AugSchemeMPL, G1Element from chiabip158 import PyBIP158 -from blspy import G1Element, AugSchemeMPL -from src.consensus.constants import ConsensusConstants from src.consensus.block_record import BlockRecord -from src.types.condition_opcodes import ConditionOpcode -from src.types.condition_var_pair import ConditionVarPair +from src.consensus.constants import ConsensusConstants +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.full_node.bundle_tools import best_solution_program +from src.full_node.coin_store import CoinStore +from src.full_node.mempool import Mempool +from src.full_node.mempool_check_conditions import mempool_check_conditions_dict from src.types.blockchain_format.coin import Coin -from src.types.full_block import additions_for_npc -from src.types.spend_bundle import SpendBundle +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_record import CoinRecord +from src.types.condition_opcodes import ConditionOpcode +from src.types.condition_var_pair import ConditionVarPair +from src.types.full_block import additions_for_npc +from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.types.mempool_item import MempoolItem -from src.full_node.mempool import Mempool -from src.types.blockchain_format.sized_bytes import bytes32 -from src.full_node.coin_store import CoinStore -from src.util.errors import Err +from src.types.spend_bundle import SpendBundle from src.util.clvm import int_from_bytes -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult -from src.full_node.mempool_check_conditions import mempool_check_conditions_dict from src.util.condition_tools import pkm_pairs_for_conditions_dict -from src.util.ints import uint64, uint32 -from src.types.mempool_inclusion_status import MempoolInclusionStatus - -from src.util.streamable import recurse_jsonify, dataclass_from_dict +from src.util.errors import Err +from src.util.ints import uint32, uint64 +from src.util.streamable import dataclass_from_dict, recurse_jsonify log = logging.getLogger(__name__) diff --git a/src/full_node/signage_point.py b/src/full_node/signage_point.py index 7cdb6a3e3805..97984ca13999 100644 --- a/src/full_node/signage_point.py +++ b/src/full_node/signage_point.py @@ -2,7 +2,7 @@ from typing import Optional from src.types.blockchain_format.vdf import VDFInfo, VDFProof -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/full_node/sync_store.py b/src/full_node/sync_store.py index c64aa01a182a..58fd725980a6 100644 --- a/src/full_node/sync_store.py +++ b/src/full_node/sync_store.py @@ -1,6 +1,6 @@ import asyncio import logging -from typing import Dict, List, Optional, Tuple, Set +from typing import Dict, List, Optional, Set, Tuple from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint32, uint128 diff --git a/src/full_node/weight_proof.py b/src/full_node/weight_proof.py index 0a95dfc529ce..aa308d05a6a9 100644 --- a/src/full_node/weight_proof.py +++ b/src/full_node/weight_proof.py @@ -1,46 +1,36 @@ import asyncio import dataclasses import logging +import math import random from concurrent.futures.process import ProcessPoolExecutor -from typing import Optional, List, Tuple, Dict - -import math +from typing import Dict, List, Optional, Tuple from src.consensus.block_header_validation import validate_finished_header_block +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants from src.consensus.deficit import calculate_deficit from src.consensus.full_block_to_block_record import header_block_to_sub_block_record - from src.consensus.pot_iterations import ( - calculate_iterations_quality, calculate_ip_iters, - is_overflow_block, + calculate_iterations_quality, calculate_sp_iters, + is_overflow_block, ) -from src.consensus.block_record import BlockRecord from src.consensus.vdf_info_computation import get_signage_point_vdf_info from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.blockchain_format.slots import RewardChainSubSlot, ChallengeChainSubSlot +from src.types.blockchain_format.slots import ChallengeChainSubSlot, RewardChainSubSlot from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary from src.types.blockchain_format.vdf import VDFInfo - from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.header_block import HeaderBlock - -from src.types.weight_proof import ( - WeightProof, - SubEpochData, - SubEpochChallengeSegment, - SubSlotData, -) +from src.types.weight_proof import SubEpochChallengeSegment, SubEpochData, SubSlotData, WeightProof from src.util.block_cache import BlockCache - from src.util.hash import std_hash -from src.util.ints import uint32, uint64, uint8, uint128 -from src.util.streamable import recurse_jsonify, dataclass_from_dict +from src.util.ints import uint8, uint32, uint64, uint128 +from src.util.streamable import dataclass_from_dict, recurse_jsonify log = logging.getLogger(__name__) diff --git a/src/harvester/harvester.py b/src/harvester/harvester.py index 807e00ec5db8..ed9944bbe305 100644 --- a/src/harvester/harvester.py +++ b/src/harvester/harvester.py @@ -1,21 +1,19 @@ -import logging import asyncio -import src.server.ws_connection as ws # lgtm [py/import-and-import-from] +import concurrent +import logging from concurrent.futures.thread import ThreadPoolExecutor from pathlib import Path -from typing import Dict, Optional, Tuple, List, Callable, Set -import concurrent +from typing import Callable, Dict, List, Optional, Set, Tuple from blspy import G1Element +import src.server.ws_connection as ws # lgtm [py/import-and-import-from] from src.consensus.constants import ConsensusConstants -from src.plotting.plot_tools import ( - load_plots, - PlotInfo, - remove_plot_directory as remove_plot_directory_pt, - add_plot_directory as add_plot_directory_pt, - get_plot_directories as get_plot_directories_pt, -) +from src.plotting.plot_tools import PlotInfo +from src.plotting.plot_tools import add_plot_directory as add_plot_directory_pt +from src.plotting.plot_tools import get_plot_directories as get_plot_directories_pt +from src.plotting.plot_tools import load_plots +from src.plotting.plot_tools import remove_plot_directory as remove_plot_directory_pt log = logging.getLogger(__name__) diff --git a/src/harvester/harvester_api.py b/src/harvester/harvester_api.py index 11bdf351bc10..c432930edc35 100644 --- a/src/harvester/harvester_api.py +++ b/src/harvester/harvester_api.py @@ -5,12 +5,9 @@ from blspy import AugSchemeMPL, G2Element -from src.consensus.pot_iterations import ( - calculate_sp_interval_iters, - calculate_iterations_quality, -) +from src.consensus.pot_iterations import calculate_iterations_quality, calculate_sp_interval_iters from src.harvester.harvester import Harvester -from src.plotting.plot_tools import PlotInfo +from src.plotting.plot_tools import PlotInfo, parse_plot_info from src.protocols import harvester_protocol from src.protocols.farmer_protocol import FarmingInfo from src.protocols.protocol_message_types import ProtocolMessageTypes @@ -19,9 +16,7 @@ from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 from src.util.api_decorators import api_request, peer_required -from src.util.ints import uint8, uint64, uint32 - -from src.plotting.plot_tools import parse_plot_info +from src.util.ints import uint8, uint32, uint64 from src.wallet.derive_keys import master_sk_to_local_sk diff --git a/src/introducer/introducer.py b/src/introducer/introducer.py index e9093f6a472d..dba5dc79b944 100644 --- a/src/introducer/introducer.py +++ b/src/introducer/introducer.py @@ -1,9 +1,10 @@ import asyncio import logging import time -from typing import Dict, Optional, Callable -from src.types.blockchain_format.sized_bytes import bytes32 +from typing import Callable, Dict, Optional + from src.server.server import ChiaServer +from src.types.blockchain_format.sized_bytes import bytes32 class Introducer: diff --git a/src/introducer/introducer_api.py b/src/introducer/introducer_api.py index 94d7299a5f59..722935d532c5 100644 --- a/src/introducer/introducer_api.py +++ b/src/introducer/introducer_api.py @@ -1,13 +1,13 @@ -from typing import Optional, Callable +from typing import Callable, Optional from src.introducer.introducer import Introducer +from src.protocols.introducer_protocol import RequestPeersIntroducer, RespondPeersIntroducer from src.protocols.protocol_message_types import ProtocolMessageTypes from src.server.outbound_message import Message, make_msg from src.server.ws_connection import WSChiaConnection from src.types.peer_info import TimestampedPeerInfo from src.util.api_decorators import api_request, peer_required from src.util.ints import uint64 -from src.protocols.introducer_protocol import RespondPeersIntroducer, RequestPeersIntroducer class IntroducerAPI: diff --git a/src/plotting/check_plots.py b/src/plotting/check_plots.py index 81381ed63c2f..0be67d0172ac 100644 --- a/src/plotting/check_plots.py +++ b/src/plotting/check_plots.py @@ -1,18 +1,16 @@ -from typing import List, Dict -from pathlib import Path import logging -from chiapos import Verifier from collections import Counter +from pathlib import Path +from typing import Dict, List + from blspy import G1Element -from src.util.keychain import Keychain +from chiapos import Verifier + +from src.plotting.plot_tools import find_duplicate_plot_IDs, get_plot_filenames, load_plots, parse_plot_info from src.util.config import load_config -from src.plotting.plot_tools import load_plots, get_plot_filenames, find_duplicate_plot_IDs from src.util.hash import std_hash -from src.wallet.derive_keys import master_sk_to_farmer_sk - -from src.plotting.plot_tools import parse_plot_info -from src.wallet.derive_keys import master_sk_to_local_sk - +from src.util.keychain import Keychain +from src.wallet.derive_keys import master_sk_to_farmer_sk, master_sk_to_local_sk log = logging.getLogger(__name__) diff --git a/src/plotting/create_plots.py b/src/plotting/create_plots.py index 2e3f0c3d830b..72f335090a6b 100644 --- a/src/plotting/create_plots.py +++ b/src/plotting/create_plots.py @@ -1,27 +1,20 @@ +import logging +from datetime import datetime from pathlib import Path from secrets import token_bytes -from typing import Optional, List, Tuple -import logging +from typing import List, Optional, Tuple + from blspy import AugSchemeMPL, G1Element, PrivateKey from chiapos import DiskPlotter -from datetime import datetime + +from src.plotting.plot_tools import add_plot_directory, stream_plot_info_ph, stream_plot_info_pk from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 from src.util.bech32m import decode_puzzle_hash -from src.util.keychain import Keychain from src.util.config import config_path_for_filename, load_config +from src.util.keychain import Keychain from src.util.path import mkdir -from src.plotting.plot_tools import ( - stream_plot_info_pk, - stream_plot_info_ph, - add_plot_directory, -) -from src.wallet.derive_keys import ( - master_sk_to_farmer_sk, - master_sk_to_pool_sk, - master_sk_to_local_sk, -) - +from src.wallet.derive_keys import master_sk_to_farmer_sk, master_sk_to_local_sk, master_sk_to_pool_sk log = logging.getLogger(__name__) diff --git a/src/plotting/plot_tools.py b/src/plotting/plot_tools.py index ebfece213cca..b1906fef68ea 100644 --- a/src/plotting/plot_tools.py +++ b/src/plotting/plot_tools.py @@ -1,19 +1,19 @@ -from typing import List, Dict, Optional, Tuple, Set, Union -from pathlib import Path -from blspy import PrivateKey, G1Element -from chiapos import DiskProver -from dataclasses import dataclass -import time import logging +import time import traceback +from dataclasses import dataclass +from pathlib import Path +from typing import Dict, List, Optional, Set, Tuple, Union -from src.consensus.pos_quality import _expected_plot_size, UI_ACTUAL_SPACE_CONSTANT_FACTOR +from blspy import G1Element, PrivateKey +from chiapos import DiskProver + +from src.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR, _expected_plot_size from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 from src.util.config import load_config, save_config from src.wallet.derive_keys import master_sk_to_local_sk - log = logging.getLogger(__name__) diff --git a/src/protocols/farmer_protocol.py b/src/protocols/farmer_protocol.py index 63bcb7becc8e..b38ddb8093d4 100644 --- a/src/protocols/farmer_protocol.py +++ b/src/protocols/farmer_protocol.py @@ -2,11 +2,11 @@ from typing import Optional from blspy import G2Element + +from src.types.blockchain_format.pool_target import PoolTarget from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.blockchain_format.pool_target import PoolTarget -from src.util.ints import uint32 -from src.util.ints import uint64, uint8 +from src.util.ints import uint8, uint32, uint64 from src.util.streamable import Streamable, streamable """ diff --git a/src/protocols/full_node_protocol.py b/src/protocols/full_node_protocol.py index 22f73438c5e4..b72abf4784e0 100644 --- a/src/protocols/full_node_protocol.py +++ b/src/protocols/full_node_protocol.py @@ -1,15 +1,15 @@ from dataclasses import dataclass from typing import List, Optional +from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.full_block import FullBlock +from src.types.peer_info import TimestampedPeerInfo from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock -from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.types.weight_proof import WeightProof from src.util.ints import uint8, uint32, uint64, uint128 -from src.types.peer_info import TimestampedPeerInfo from src.util.streamable import Streamable, streamable """ diff --git a/src/protocols/harvester_protocol.py b/src/protocols/harvester_protocol.py index a30e9cfbd51c..aff45a0060b9 100644 --- a/src/protocols/harvester_protocol.py +++ b/src/protocols/harvester_protocol.py @@ -5,7 +5,7 @@ from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint64, uint8 +from src.util.ints import uint8, uint64 from src.util.streamable import Streamable, streamable """ diff --git a/src/protocols/introducer_protocol.py b/src/protocols/introducer_protocol.py index 3bc3b4c2e6cb..d0924dde4293 100644 --- a/src/protocols/introducer_protocol.py +++ b/src/protocols/introducer_protocol.py @@ -2,7 +2,7 @@ from typing import List from src.types.peer_info import TimestampedPeerInfo -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable """ Protocol to introducer diff --git a/src/protocols/pool_protocol.py b/src/protocols/pool_protocol.py index 1f64e139d976..7ff33b10ddf5 100644 --- a/src/protocols/pool_protocol.py +++ b/src/protocols/pool_protocol.py @@ -1,10 +1,9 @@ from dataclasses import dataclass from typing import List, Optional - from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.util.ints import uint32, uint64 -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable """ Protocol between farmer and pool. diff --git a/src/protocols/shared_protocol.py b/src/protocols/shared_protocol.py index f5312607dc1e..fe8fcbe47e4b 100644 --- a/src/protocols/shared_protocol.py +++ b/src/protocols/shared_protocol.py @@ -1,8 +1,8 @@ from dataclasses import dataclass from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint16, uint8 -from src.util.streamable import streamable, Streamable +from src.util.ints import uint8, uint16 +from src.util.streamable import Streamable, streamable protocol_version = "0.0.32" diff --git a/src/protocols/timelord_protocol.py b/src/protocols/timelord_protocol.py index c4da3372c68d..bd020f92f8b8 100644 --- a/src/protocols/timelord_protocol.py +++ b/src/protocols/timelord_protocol.py @@ -1,17 +1,14 @@ from dataclasses import dataclass -from typing import Optional, List, Tuple +from typing import List, Optional, Tuple -from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.blockchain_format.foliage import Foliage -from src.types.blockchain_format.reward_chain_block import ( - RewardChainBlock, - RewardChainBlockUnfinished, -) +from src.types.blockchain_format.reward_chain_block import RewardChainBlock, RewardChainBlockUnfinished from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary from src.types.blockchain_format.vdf import VDFInfo, VDFProof +from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.util.ints import uint8, uint32, uint64, uint128 -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable """ Protocol between timelord and full node. diff --git a/src/protocols/wallet_protocol.py b/src/protocols/wallet_protocol.py index 68208bc62a8a..a17a0bfed8b7 100644 --- a/src/protocols/wallet_protocol.py +++ b/src/protocols/wallet_protocol.py @@ -1,12 +1,12 @@ from dataclasses import dataclass -from typing import List, Tuple, Optional +from typing import List, Optional, Tuple from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.program import Program -from src.types.spend_bundle import SpendBundle -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint32, uint128, uint8 +from src.types.header_block import HeaderBlock +from src.types.spend_bundle import SpendBundle +from src.util.ints import uint8, uint32, uint128 from src.util.streamable import Streamable, streamable """ diff --git a/src/rpc/farmer_rpc_api.py b/src/rpc/farmer_rpc_api.py index a879b1af13fd..53871e42daf2 100644 --- a/src/rpc/farmer_rpc_api.py +++ b/src/rpc/farmer_rpc_api.py @@ -2,7 +2,7 @@ from src.farmer.farmer import Farmer from src.util.byte_types import hexstr_to_bytes -from src.util.ws_message import create_payload_dict, WsRpcMessage +from src.util.ws_message import WsRpcMessage, create_payload_dict class FarmerRpcApi: diff --git a/src/rpc/farmer_rpc_client.py b/src/rpc/farmer_rpc_client.py index 20033cce1794..a3b33dd8dece 100644 --- a/src/rpc/farmer_rpc_client.py +++ b/src/rpc/farmer_rpc_client.py @@ -1,4 +1,5 @@ from typing import Dict, List, Optional + from src.rpc.rpc_client import RpcClient from src.types.blockchain_format.sized_bytes import bytes32 diff --git a/src/rpc/full_node_rpc_api.py b/src/rpc/full_node_rpc_api.py index 03e114e793a7..310ac9d3e251 100644 --- a/src/rpc/full_node_rpc_api.py +++ b/src/rpc/full_node_rpc_api.py @@ -1,17 +1,17 @@ +from typing import Any, Callable, Dict, List, Optional + from src.consensus.block_record import BlockRecord +from src.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR from src.full_node.full_node import FullNode -from typing import Callable, List, Optional, Dict, Any - +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_record import CoinRecord from src.types.full_block import FullBlock -from src.types.blockchain_format.sized_bytes import bytes32 from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.types.spend_bundle import SpendBundle from src.types.unfinished_header_block import UnfinishedHeaderBlock from src.util.byte_types import hexstr_to_bytes -from src.util.ints import uint64, uint32, uint128 -from src.util.ws_message import create_payload_dict, WsRpcMessage -from src.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR +from src.util.ints import uint32, uint64, uint128 +from src.util.ws_message import WsRpcMessage, create_payload_dict class FullNodeRpcApi: diff --git a/src/rpc/full_node_rpc_client.py b/src/rpc/full_node_rpc_client.py index 5ee562105992..8345eb96fb77 100644 --- a/src/rpc/full_node_rpc_client.py +++ b/src/rpc/full_node_rpc_client.py @@ -1,13 +1,14 @@ -from typing import Dict, Optional, List, Tuple -from src.types.full_block import FullBlock +from typing import Dict, List, Optional, Tuple + from src.consensus.block_record import BlockRecord +from src.rpc.rpc_client import RpcClient from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_record import CoinRecord +from src.types.full_block import FullBlock from src.types.spend_bundle import SpendBundle from src.types.unfinished_header_block import UnfinishedHeaderBlock from src.util.byte_types import hexstr_to_bytes from src.util.ints import uint32, uint64 -from src.types.coin_record import CoinRecord -from src.rpc.rpc_client import RpcClient class FullNodeRpcClient(RpcClient): diff --git a/src/rpc/harvester_rpc_api.py b/src/rpc/harvester_rpc_api.py index 8fae62225f5b..13e72c4afdbe 100644 --- a/src/rpc/harvester_rpc_api.py +++ b/src/rpc/harvester_rpc_api.py @@ -1,7 +1,7 @@ from typing import Callable, Dict, List from src.harvester.harvester import Harvester -from src.util.ws_message import create_payload_dict, WsRpcMessage +from src.util.ws_message import WsRpcMessage, create_payload_dict class HarvesterRpcApi: diff --git a/src/rpc/harvester_rpc_client.py b/src/rpc/harvester_rpc_client.py index 0d8eb10272a7..fc2e29d3a70a 100644 --- a/src/rpc/harvester_rpc_client.py +++ b/src/rpc/harvester_rpc_client.py @@ -1,4 +1,5 @@ -from typing import List, Dict +from typing import Dict, List + from src.rpc.rpc_client import RpcClient diff --git a/src/rpc/rpc_client.py b/src/rpc/rpc_client.py index 4d918b09f70e..f61613221a0b 100644 --- a/src/rpc/rpc_client.py +++ b/src/rpc/rpc_client.py @@ -1,14 +1,13 @@ +import asyncio from ssl import SSLContext +from typing import Dict, List, Optional import aiohttp -import asyncio - -from typing import Dict, Optional, List from src.server.server import ssl_context_for_client from src.server.ssl_context import private_ssl_ca_paths -from src.util.byte_types import hexstr_to_bytes from src.types.blockchain_format.sized_bytes import bytes32 +from src.util.byte_types import hexstr_to_bytes from src.util.ints import uint16 diff --git a/src/rpc/rpc_server.py b/src/rpc/rpc_server.py index 998c02d80e55..0513945de396 100644 --- a/src/rpc/rpc_server.py +++ b/src/rpc/rpc_server.py @@ -1,20 +1,19 @@ -from pathlib import Path -from typing import Callable, Dict, Any, List, Optional - -import aiohttp -import logging import asyncio import json +import logging import traceback +from pathlib import Path +from typing import Any, Callable, Dict, List, Optional + +import aiohttp from src.server.outbound_message import NodeType from src.server.server import ssl_context_for_server from src.types.peer_info import PeerInfo from src.util.byte_types import hexstr_to_bytes -from src.util.json_util import obj_to_response -from src.util.ws_message import create_payload, create_payload_dict, format_response, pong -from src.util.json_util import dict_to_json_str from src.util.ints import uint16 +from src.util.json_util import dict_to_json_str, obj_to_response +from src.util.ws_message import create_payload, create_payload_dict, format_response, pong log = logging.getLogger(__name__) diff --git a/src/rpc/wallet_rpc_api.py b/src/rpc/wallet_rpc_api.py index 6eb63116f67e..bbc9a3f263b3 100644 --- a/src/rpc/wallet_rpc_api.py +++ b/src/rpc/wallet_rpc_api.py @@ -2,35 +2,30 @@ import logging import time from pathlib import Path - -from typing import List, Optional, Tuple, Dict, Callable +from typing import Callable, Dict, List, Optional, Tuple from blspy import PrivateKey -from src.protocols.protocol_message_types import ProtocolMessageTypes -from src.util.byte_types import hexstr_to_bytes -from src.util.bech32m import encode_puzzle_hash, decode_puzzle_hash -from src.util.keychain import ( - generate_mnemonic, - bytes_to_mnemonic, -) -from src.util.path import path_from_root -from src.util.ws_message import create_payload_dict, WsRpcMessage - from src.cmds.init import check_keys +from src.protocols.protocol_message_types import ProtocolMessageTypes from src.server.outbound_message import NodeType, make_msg from src.simulator.simulator_protocol import FarmNewBlockProtocol -from src.util.ints import uint64, uint32 from src.types.blockchain_format.sized_bytes import bytes32 +from src.util.bech32m import decode_puzzle_hash, encode_puzzle_hash +from src.util.byte_types import hexstr_to_bytes +from src.util.ints import uint32, uint64 +from src.util.keychain import bytes_to_mnemonic, generate_mnemonic +from src.util.path import path_from_root +from src.util.ws_message import WsRpcMessage, create_payload_dict +from src.wallet.cc_wallet.cc_wallet import CCWallet +from src.wallet.rl_wallet.rl_wallet import RLWallet from src.wallet.trade_record import TradeRecord -from src.wallet.util.backup_utils import get_backup_info, download_backup, upload_backup +from src.wallet.transaction_record import TransactionRecord +from src.wallet.util.backup_utils import download_backup, get_backup_info, upload_backup from src.wallet.util.trade_utils import trade_record_to_dict from src.wallet.util.wallet_types import WalletType -from src.wallet.rl_wallet.rl_wallet import RLWallet -from src.wallet.cc_wallet.cc_wallet import CCWallet from src.wallet.wallet_info import WalletInfo from src.wallet.wallet_node import WalletNode -from src.wallet.transaction_record import TransactionRecord # Timeout for response from wallet/full node for sending a transaction TIMEOUT = 30 diff --git a/src/rpc/wallet_rpc_client.py b/src/rpc/wallet_rpc_client.py index 74dd4c7fd1f7..3e9068c80e8e 100644 --- a/src/rpc/wallet_rpc_client.py +++ b/src/rpc/wallet_rpc_client.py @@ -1,10 +1,11 @@ -from typing import Dict, List from pathlib import Path +from typing import Dict, List + from src.rpc.rpc_client import RpcClient -from src.wallet.transaction_record import TransactionRecord -from src.util.ints import uint64, uint32 from src.types.blockchain_format.sized_bytes import bytes32 from src.util.bech32m import decode_puzzle_hash +from src.util.ints import uint32, uint64 +from src.wallet.transaction_record import TransactionRecord class WalletRpcClient(RpcClient): diff --git a/src/server/address_manager.py b/src/server/address_manager.py index abe06559024c..e7137e50128f 100644 --- a/src/server/address_manager.py +++ b/src/server/address_manager.py @@ -1,14 +1,14 @@ -from src.util.hash import std_hash +import logging +import math +import time +from asyncio import Lock +from random import choice, randrange from secrets import randbits -from random import randrange, choice +from typing import Dict, List, Optional, Set, Tuple from src.types.peer_info import PeerInfo, TimestampedPeerInfo +from src.util.hash import std_hash from src.util.ints import uint16, uint64 -from typing import Dict, List, Optional, Tuple, Set -from asyncio import Lock -import logging -import time -import math TRIED_BUCKETS_PER_GROUP = 8 NEW_BUCKETS_PER_SOURCE_GROUP = 64 diff --git a/src/server/address_manager_store.py b/src/server/address_manager_store.py index 5df6c3619e2e..cc0109ec1b78 100644 --- a/src/server/address_manager_store.py +++ b/src/server/address_manager_store.py @@ -1,13 +1,15 @@ import logging +from typing import Dict, List, Tuple + import aiosqlite + from src.server.address_manager import ( - AddressManager, - ExtendedPeerInfo, - NEW_BUCKET_COUNT, BUCKET_SIZE, + NEW_BUCKET_COUNT, NEW_BUCKETS_PER_ADDRESS, + AddressManager, + ExtendedPeerInfo, ) -from typing import Dict, List, Tuple log = logging.getLogger(__name__) diff --git a/src/server/connection_utils.py b/src/server/connection_utils.py index 43fbc8f9f087..9f14a46dc519 100644 --- a/src/server/connection_utils.py +++ b/src/server/connection_utils.py @@ -1,6 +1,6 @@ import asyncio import random -from typing import List, Any, Tuple, Optional +from typing import Any, List, Optional, Tuple from src.server.ws_connection import WSChiaConnection diff --git a/src/server/introducer_peers.py b/src/server/introducer_peers.py index 0eb11571035b..ccc79d29b97c 100644 --- a/src/server/introducer_peers.py +++ b/src/server/introducer_peers.py @@ -1,9 +1,10 @@ -import time import random +import time +from typing import Dict, List, Optional + from src.types.blockchain_format.sized_bytes import bytes32 -from typing import List, Dict, Optional -from src.util.ints import uint64 from src.types.peer_info import PeerInfo +from src.util.ints import uint64 class IntroducerPeers: diff --git a/src/server/node_discovery.py b/src/server/node_discovery.py index 9b8bd1c46c45..02a37a58a499 100644 --- a/src/server/node_discovery.py +++ b/src/server/node_discovery.py @@ -1,28 +1,25 @@ import asyncio -import time import math +import time +import traceback from pathlib import Path +from random import Random +from secrets import randbits +from typing import Dict, Optional import aiosqlite -import traceback -from random import Random + import src.server.ws_connection as ws +from src.protocols import full_node_protocol, introducer_protocol from src.protocols.protocol_message_types import ProtocolMessageTypes - +from src.server.address_manager import AddressManager, ExtendedPeerInfo +from src.server.address_manager_store import AddressManagerStore +from src.server.outbound_message import NodeType, make_msg from src.server.server import ChiaServer from src.types.peer_info import PeerInfo, TimestampedPeerInfo -from src.util.path import path_from_root, mkdir -from src.server.outbound_message import NodeType, make_msg -from src.server.address_manager import ExtendedPeerInfo, AddressManager -from src.server.address_manager_store import AddressManagerStore -from src.protocols import ( - introducer_protocol, - full_node_protocol, -) -from secrets import randbits from src.util.hash import std_hash -from typing import Dict, Optional from src.util.ints import uint64 +from src.util.path import mkdir, path_from_root MAX_PEERS_RECEIVED_PER_REQUEST = 1000 MAX_TOTAL_PEERS_RECEIVED = 3000 diff --git a/src/server/outbound_message.py b/src/server/outbound_message.py index 29b0ba0bd805..b73434e89c48 100644 --- a/src/server/outbound_message.py +++ b/src/server/outbound_message.py @@ -1,9 +1,10 @@ from dataclasses import dataclass from enum import IntEnum from typing import Any, Optional -from src.util.ints import uint8, uint16 -from src.util.streamable import streamable, Streamable + from src.protocols.protocol_message_types import ProtocolMessageTypes +from src.util.ints import uint8, uint16 +from src.util.streamable import Streamable, streamable class NodeType(IntEnum): diff --git a/src/server/server.py b/src/server/server.py index 0f678caae084..f7c30cc7e5a2 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -2,28 +2,29 @@ import logging import ssl import time -from ipaddress import ip_address, IPv6Address +import traceback +from ipaddress import IPv6Address, ip_address from pathlib import Path from secrets import token_bytes -from typing import Any, List, Dict, Callable, Optional, Set, Tuple +from typing import Any, Callable, Dict, List, Optional, Set, Tuple + +from aiohttp import ClientSession, ClientTimeout, WSCloseCode, client_exceptions, web from aiohttp.web_app import Application from aiohttp.web_runner import TCPSite -from aiohttp import web, ClientTimeout, client_exceptions, ClientSession, WSCloseCode from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, serialization from src.protocols.protocol_message_types import ProtocolMessageTypes +from src.protocols.shared_protocol import protocol_version from src.server.introducer_peers import IntroducerPeers -from src.server.outbound_message import NodeType, Message +from src.server.outbound_message import Message, NodeType from src.server.ssl_context import private_ssl_paths, public_ssl_paths from src.server.ws_connection import WSChiaConnection -from src.types.peer_info import PeerInfo from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.errors import ProtocolError, Err +from src.types.peer_info import PeerInfo +from src.util.errors import Err, ProtocolError from src.util.ints import uint16 -from src.protocols.shared_protocol import protocol_version -import traceback def ssl_context_for_server( diff --git a/src/server/start_farmer.py b/src/server/start_farmer.py index ac334598808c..5912a6debb34 100644 --- a/src/server/start_farmer.py +++ b/src/server/start_farmer.py @@ -1,19 +1,17 @@ import pathlib - from typing import Dict from src.consensus.constants import ConsensusConstants from src.consensus.default_constants import DEFAULT_CONSTANTS from src.farmer.farmer import Farmer from src.farmer.farmer_api import FarmerAPI +from src.rpc.farmer_rpc_api import FarmerRpcApi from src.server.outbound_message import NodeType +from src.server.start_service import run_service from src.types.peer_info import PeerInfo -from src.util.keychain import Keychain from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH -from src.rpc.farmer_rpc_api import FarmerRpcApi - -from src.server.start_service import run_service +from src.util.keychain import Keychain # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/server/start_full_node.py b/src/server/start_full_node.py index 4e78e882b963..264864124500 100644 --- a/src/server/start_full_node.py +++ b/src/server/start_full_node.py @@ -1,6 +1,5 @@ import logging import pathlib - from multiprocessing import freeze_support from typing import Dict @@ -14,7 +13,6 @@ from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH - # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/server/start_harvester.py b/src/server/start_harvester.py index 63557f240223..d15801a92c2c 100644 --- a/src/server/start_harvester.py +++ b/src/server/start_harvester.py @@ -1,18 +1,16 @@ import pathlib - from typing import Dict from src.consensus.constants import ConsensusConstants from src.consensus.default_constants import DEFAULT_CONSTANTS from src.harvester.harvester import Harvester from src.harvester.harvester_api import HarvesterAPI +from src.rpc.harvester_rpc_api import HarvesterRpcApi from src.server.outbound_message import NodeType +from src.server.start_service import run_service from src.types.peer_info import PeerInfo from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH -from src.rpc.harvester_rpc_api import HarvesterRpcApi - -from src.server.start_service import run_service # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/server/start_introducer.py b/src/server/start_introducer.py index 789abbc9594b..8bc3c7ff6043 100644 --- a/src/server/start_introducer.py +++ b/src/server/start_introducer.py @@ -1,16 +1,14 @@ import pathlib - from typing import Dict from src.consensus.default_constants import DEFAULT_CONSTANTS from src.introducer.introducer import Introducer from src.introducer.introducer_api import IntroducerAPI from src.server.outbound_message import NodeType +from src.server.start_service import run_service from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH -from src.server.start_service import run_service - # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/server/start_service.py b/src/server/start_service.py index 1016f62f136f..fdf929be0379 100644 --- a/src/server/start_service.py +++ b/src/server/start_service.py @@ -2,11 +2,10 @@ import logging import logging.config import signal - from sys import platform -from typing import Any, List, Optional, Tuple, Callable +from typing import Any, Callable, List, Optional, Tuple -from src.server.ssl_context import private_ssl_ca_paths, chia_ssl_ca_paths +from src.server.ssl_context import chia_ssl_ca_paths, private_ssl_ca_paths from src.types.blockchain_format.sized_bytes import bytes32 try: @@ -14,6 +13,7 @@ except ImportError: uvloop = None +from src.rpc.rpc_server import start_rpc_server from src.server.outbound_message import NodeType from src.server.server import ChiaServer from src.server.upnp import upnp_remap_port @@ -21,7 +21,6 @@ from src.util.chia_logging import initialize_logging from src.util.config import load_config, load_config_cli from src.util.setproctitle import setproctitle -from src.rpc.rpc_server import start_rpc_server from .reconnect_task import start_reconnect_task diff --git a/src/server/start_timelord.py b/src/server/start_timelord.py index 480d0185bbea..dfd3515755e5 100644 --- a/src/server/start_timelord.py +++ b/src/server/start_timelord.py @@ -1,19 +1,17 @@ import logging import pathlib - from typing import Dict from src.consensus.constants import ConsensusConstants from src.consensus.default_constants import DEFAULT_CONSTANTS -from src.timelord.timelord import Timelord from src.server.outbound_message import NodeType +from src.server.start_service import run_service +from src.timelord.timelord import Timelord from src.timelord.timelord_api import TimelordAPI from src.types.peer_info import PeerInfo from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH -from src.server.start_service import run_service - # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/server/start_wallet.py b/src/server/start_wallet.py index a826bfa85c5d..afe96d653ff8 100644 --- a/src/server/start_wallet.py +++ b/src/server/start_wallet.py @@ -1,19 +1,18 @@ import pathlib - from multiprocessing import freeze_support from typing import Dict from src.consensus.constants import ConsensusConstants from src.consensus.default_constants import DEFAULT_CONSTANTS -from src.util.block_tools import test_constants -from src.wallet.wallet_node import WalletNode from src.rpc.wallet_rpc_api import WalletRpcApi from src.server.outbound_message import NodeType from src.server.start_service import run_service +from src.types.peer_info import PeerInfo +from src.util.block_tools import test_constants from src.util.config import load_config_cli from src.util.default_root import DEFAULT_ROOT_PATH from src.util.keychain import Keychain -from src.types.peer_info import PeerInfo +from src.wallet.wallet_node import WalletNode # See: https://bugs.python.org/issue29288 from src.wallet.wallet_node_api import WalletNodeAPI diff --git a/src/server/upnp.py b/src/server/upnp.py index 65ab37ddf1fe..a490b0aa6953 100644 --- a/src/server/upnp.py +++ b/src/server/upnp.py @@ -1,4 +1,5 @@ import logging + import miniupnpc log = logging.getLogger(__name__) diff --git a/src/server/ws_connection.py b/src/server/ws_connection.py index b76830e442f9..a96e88871863 100644 --- a/src/server/ws_connection.py +++ b/src/server/ws_connection.py @@ -1,20 +1,19 @@ +import asyncio import logging import time -import asyncio import traceback +from typing import Any, Callable, Dict, List, Optional -from typing import Any, Callable, Optional, List, Dict - -from aiohttp import WSMessage, WSMsgType, WSCloseCode +from aiohttp import WSCloseCode, WSMessage, WSMsgType from src.cmds.init import chia_full_version_str from src.protocols.protocol_message_types import ProtocolMessageTypes from src.protocols.shared_protocol import Handshake from src.server.outbound_message import Message, NodeType, make_msg -from src.types.peer_info import PeerInfo from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint16, uint8 +from src.types.peer_info import PeerInfo from src.util.errors import Err, ProtocolError +from src.util.ints import uint8, uint16 # Each message is prepended with LENGTH_BYTES bytes specifying the length from src.util.network import class_for_type diff --git a/src/simulator/full_node_simulator.py b/src/simulator/full_node_simulator.py index 556d3171de04..66c57ad17e94 100644 --- a/src/simulator/full_node_simulator.py +++ b/src/simulator/full_node_simulator.py @@ -6,7 +6,6 @@ from src.protocols.full_node_protocol import RespondBlock from src.simulator.simulator_protocol import FarmNewBlockProtocol, ReorgProtocol from src.types.full_block import FullBlock - from src.util.api_decorators import api_request from src.util.ints import uint8 diff --git a/src/simulator/simulator_constants.py b/src/simulator/simulator_constants.py index 5d8f370f0043..78a66e37b2c9 100644 --- a/src/simulator/simulator_constants.py +++ b/src/simulator/simulator_constants.py @@ -1,6 +1,6 @@ if __name__ == "__main__": - from src.util.default_root import DEFAULT_ROOT_PATH from src.util.block_tools import BlockTools, test_constants + from src.util.default_root import DEFAULT_ROOT_PATH # TODO: mariano: fix this with new consensus bt = BlockTools(root_path=DEFAULT_ROOT_PATH) diff --git a/src/simulator/start_simulator.py b/src/simulator/start_simulator.py index 98d9703f49c8..785cd4c6efd2 100644 --- a/src/simulator/start_simulator.py +++ b/src/simulator/start_simulator.py @@ -13,7 +13,6 @@ from .full_node_simulator import FullNodeSimulator - # See: https://bugs.python.org/issue29288 "".encode("idna") diff --git a/src/ssl/create_ssl.py b/src/ssl/create_ssl.py index d00e04a1855b..bac3b018b9b2 100644 --- a/src/ssl/create_ssl.py +++ b/src/ssl/create_ssl.py @@ -1,5 +1,6 @@ +import datetime from pathlib import Path -from typing import Tuple, Any +from typing import Any, Tuple import pkg_resources from cryptography import x509 @@ -8,7 +9,6 @@ from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.serialization import load_pem_private_key from cryptography.x509.oid import NameOID -import datetime def get_chia_ca_crt_key() -> Tuple[Any, Any]: diff --git a/src/timelord/iters_from_block.py b/src/timelord/iters_from_block.py index ac7d171bea1e..2bcffcdebc28 100644 --- a/src/timelord/iters_from_block.py +++ b/src/timelord/iters_from_block.py @@ -1,14 +1,7 @@ -from typing import Union, Tuple, Optional +from typing import Optional, Tuple, Union -from src.consensus.pot_iterations import ( - calculate_iterations_quality, - calculate_sp_iters, - calculate_ip_iters, -) -from src.types.blockchain_format.reward_chain_block import ( - RewardChainBlock, - RewardChainBlockUnfinished, -) +from src.consensus.pot_iterations import calculate_ip_iters, calculate_iterations_quality, calculate_sp_iters +from src.types.blockchain_format.reward_chain_block import RewardChainBlock, RewardChainBlockUnfinished from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint64 diff --git a/src/timelord/timelord.py b/src/timelord/timelord.py index 7f870afd8e24..144749662671 100644 --- a/src/timelord/timelord.py +++ b/src/timelord/timelord.py @@ -2,18 +2,15 @@ import dataclasses import io import logging +import random import time import traceback -import random -from typing import Dict, List, Optional, Tuple, Callable +from typing import Callable, Dict, List, Optional, Tuple from chiavdf import create_discriminant from src.consensus.constants import ConsensusConstants -from src.consensus.pot_iterations import ( - calculate_sp_iters, - is_overflow_block, -) +from src.consensus.pot_iterations import calculate_sp_iters, is_overflow_block from src.protocols import timelord_protocol from src.protocols.protocol_message_types import ProtocolMessageTypes from src.server.outbound_message import NodeType, make_msg @@ -22,7 +19,6 @@ from src.timelord.timelord_state import LastState from src.timelord.types import Chain, IterationType, StateType from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.blockchain_format.reward_chain_block import RewardChainBlock from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.slots import ( @@ -31,9 +27,10 @@ RewardChainSubSlot, SubSlotProofs, ) -from src.types.blockchain_format.vdf import VDFInfo, VDFProof -from src.util.ints import uint64, uint8, uint32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.blockchain_format.vdf import VDFInfo, VDFProof +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.util.ints import uint8, uint32, uint64 log = logging.getLogger(__name__) diff --git a/src/timelord/timelord_api.py b/src/timelord/timelord_api.py index 83afdfd37947..96a139dcdd40 100644 --- a/src/timelord/timelord_api.py +++ b/src/timelord/timelord_api.py @@ -1,11 +1,11 @@ -from typing import Callable, Optional import logging +from typing import Callable, Optional + from src.protocols import timelord_protocol -from src.timelord.timelord import Timelord, iters_from_block, Chain, IterationType +from src.timelord.timelord import Chain, IterationType, Timelord, iters_from_block from src.util.api_decorators import api_request from src.util.ints import uint64 - log = logging.getLogger(__name__) diff --git a/src/timelord/timelord_launcher.py b/src/timelord/timelord_launcher.py index 2fe6037cb8b1..781141e3f016 100644 --- a/src/timelord/timelord_launcher.py +++ b/src/timelord/timelord_launcher.py @@ -1,14 +1,15 @@ -import signal import asyncio import logging import pathlib +import signal import socket import time +from typing import List import pkg_resources + from src.util.chia_logging import initialize_logging from src.util.config import load_config -from typing import List from src.util.default_root import DEFAULT_ROOT_PATH from src.util.setproctitle import setproctitle diff --git a/src/timelord/timelord_state.py b/src/timelord/timelord_state.py index ecdf44d04318..016f133c6ea6 100644 --- a/src/timelord/timelord_state.py +++ b/src/timelord/timelord_state.py @@ -1,17 +1,16 @@ import logging -from typing import Optional, List, Tuple, Union +from typing import List, Optional, Tuple, Union from src.consensus.constants import ConsensusConstants from src.protocols import timelord_protocol from src.timelord.iters_from_block import iters_from_block -from src.timelord.types import StateType, Chain +from src.timelord.types import Chain, StateType from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.slots import ChallengeBlockInfo from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary -from src.util.ints import uint64, uint8, uint128, uint32 - +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.util.ints import uint8, uint32, uint64, uint128 log = logging.getLogger(__name__) diff --git a/src/types/announcement.py b/src/types/announcement.py index 7bce15271532..6ea5423b1178 100644 --- a/src/types/announcement.py +++ b/src/types/announcement.py @@ -1,5 +1,6 @@ -from src.types.blockchain_format.sized_bytes import bytes32 from dataclasses import dataclass + +from src.types.blockchain_format.sized_bytes import bytes32 from src.util.hash import std_hash diff --git a/src/types/blockchain_format/coin.py b/src/types/blockchain_format/coin.py index 79e7ef8fa1b5..7ec020065d3b 100644 --- a/src/types/blockchain_format/coin.py +++ b/src/types/blockchain_format/coin.py @@ -2,10 +2,10 @@ from typing import Any, List from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.clvm import int_to_bytes, int_from_bytes +from src.util.clvm import int_from_bytes, int_to_bytes from src.util.hash import std_hash from src.util.ints import uint64 -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/blockchain_format/foliage.py b/src/types/blockchain_format/foliage.py index 9d10f5f80814..23db850c9b21 100644 --- a/src/types/blockchain_format/foliage.py +++ b/src/types/blockchain_format/foliage.py @@ -1,12 +1,13 @@ from dataclasses import dataclass from typing import List, Optional + from blspy import G2Element +from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.pool_target import PoolTarget from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint64 from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.pool_target import PoolTarget -from src.types.blockchain_format.coin import Coin @dataclass(frozen=True) diff --git a/src/types/blockchain_format/pool_target.py b/src/types/blockchain_format/pool_target.py index a85eedaaeb5d..7ec9ee01732d 100644 --- a/src/types/blockchain_format/pool_target.py +++ b/src/types/blockchain_format/pool_target.py @@ -1,8 +1,8 @@ from dataclasses import dataclass -from src.util.streamable import Streamable, streamable from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint32 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/blockchain_format/program.py b/src/types/blockchain_format/program.py index e3c39317470d..af27d7b11199 100644 --- a/src/types/blockchain_format/program.py +++ b/src/types/blockchain_format/program.py @@ -1,18 +1,17 @@ import io from typing import List, Optional, Set, Tuple -from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.hash import std_hash - -from clvm import run_program as default_run_program, KEYWORD_FROM_ATOM, KEYWORD_TO_ATOM, SExp +from clvm import KEYWORD_FROM_ATOM, KEYWORD_TO_ATOM, SExp +from clvm import run_program as default_run_program from clvm.casts import int_from_bytes -from clvm.operators import OPERATOR_LOOKUP, OP_REWRITE -from clvm.serialize import sexp_from_stream, sexp_buffer_from_stream, sexp_to_stream from clvm.EvalError import EvalError - +from clvm.operators import OP_REWRITE, OPERATOR_LOOKUP +from clvm.serialize import sexp_buffer_from_stream, sexp_from_stream, sexp_to_stream +from clvm_rs import STRICT_MODE, deserialize_and_run_program from clvm_tools.curry import curry, uncurry -from clvm_rs import deserialize_and_run_program, STRICT_MODE +from src.types.blockchain_format.sized_bytes import bytes32 +from src.util.hash import std_hash def run_program( diff --git a/src/types/blockchain_format/proof_of_space.py b/src/types/blockchain_format/proof_of_space.py index 3f50b226abbb..3bbcb3ca3936 100644 --- a/src/types/blockchain_format/proof_of_space.py +++ b/src/types/blockchain_format/proof_of_space.py @@ -4,14 +4,13 @@ from bitstring import BitArray from blspy import G1Element - from chiapos import Verifier +from src.consensus.constants import ConsensusConstants from src.types.blockchain_format.sized_bytes import bytes32 +from src.util.hash import std_hash from src.util.ints import uint8 from src.util.streamable import Streamable, streamable -from src.util.hash import std_hash -from src.consensus.constants import ConsensusConstants log = logging.getLogger(__name__) diff --git a/src/types/blockchain_format/reward_chain_block.py b/src/types/blockchain_format/reward_chain_block.py index 628c645d2305..06dd137ea040 100644 --- a/src/types/blockchain_format/reward_chain_block.py +++ b/src/types/blockchain_format/reward_chain_block.py @@ -1,12 +1,13 @@ from dataclasses import dataclass -from blspy import G2Element from typing import Optional -from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint32, uint128, uint8 -from src.util.streamable import Streamable, streamable +from blspy import G2Element + from src.types.blockchain_format.proof_of_space import ProofOfSpace +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.vdf import VDFInfo +from src.util.ints import uint8, uint32, uint128 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/blockchain_format/slots.py b/src/types/blockchain_format/slots.py index 6349d9024a89..d21bd31a6e6b 100644 --- a/src/types/blockchain_format/slots.py +++ b/src/types/blockchain_format/slots.py @@ -1,12 +1,13 @@ -from typing import Optional from dataclasses import dataclass +from typing import Optional + from blspy import G2Element +from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.util.ints import uint8, uint64 from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.proof_of_space import ProofOfSpace -from src.types.blockchain_format.vdf import VDFInfo, VDFProof @dataclass(frozen=True) diff --git a/src/types/blockchain_format/sub_epoch_summary.py b/src/types/blockchain_format/sub_epoch_summary.py index df36dc366c6e..00749774a012 100644 --- a/src/types/blockchain_format/sub_epoch_summary.py +++ b/src/types/blockchain_format/sub_epoch_summary.py @@ -1,5 +1,5 @@ -from typing import Optional from dataclasses import dataclass +from typing import Optional from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint8, uint64 diff --git a/src/types/blockchain_format/vdf.py b/src/types/blockchain_format/vdf.py index 5ca8e0c77471..87e37af16dcd 100644 --- a/src/types/blockchain_format/vdf.py +++ b/src/types/blockchain_format/vdf.py @@ -1,16 +1,16 @@ import logging import traceback from dataclasses import dataclass -from typing import Optional, Tuple, Dict +from enum import IntEnum +from typing import Dict, Optional, Tuple + +from chiavdf import create_discriminant, verify_n_wesolowski -from chiavdf import create_discriminant +from src.consensus.constants import ConsensusConstants from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.sized_bytes import bytes32 -from chiavdf import verify_n_wesolowski from src.util.ints import uint8, uint64 from src.util.streamable import Streamable, streamable -from src.consensus.constants import ConsensusConstants -from enum import IntEnum log = logging.getLogger(__name__) diff --git a/src/types/coin_record.py b/src/types/coin_record.py index 91def51ffc2d..aae163851de0 100644 --- a/src/types/coin_record.py +++ b/src/types/coin_record.py @@ -2,8 +2,8 @@ from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.streamable import Streamable, streamable from src.util.ints import uint32, uint64 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/coin_solution.py b/src/types/coin_solution.py index 593a212d37ed..f9cfab47cb82 100644 --- a/src/types/coin_solution.py +++ b/src/types/coin_solution.py @@ -1,13 +1,13 @@ -from typing import List - from dataclasses import dataclass +from typing import List from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.program import Program -from .announcement import Announcement from src.util.chain_utils import additions_for_solution, announcements_for_solution from src.util.streamable import Streamable, streamable +from .announcement import Announcement + @dataclass(frozen=True) @streamable diff --git a/src/types/condition_var_pair.py b/src/types/condition_var_pair.py index 72f00810f487..9c07e43825e0 100644 --- a/src/types/condition_var_pair.py +++ b/src/types/condition_var_pair.py @@ -2,7 +2,7 @@ from typing import List from src.types.condition_opcodes import ConditionOpcode -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/end_of_slot_bundle.py b/src/types/end_of_slot_bundle.py index 1c7ef3b9fa26..a7cac1f98ec7 100644 --- a/src/types/end_of_slot_bundle.py +++ b/src/types/end_of_slot_bundle.py @@ -1,8 +1,12 @@ from dataclasses import dataclass from typing import Optional -from src.types.blockchain_format.slots import ChallengeChainSubSlot, InfusedChallengeChainSubSlot -from src.types.blockchain_format.slots import RewardChainSubSlot, SubSlotProofs +from src.types.blockchain_format.slots import ( + ChallengeChainSubSlot, + InfusedChallengeChainSubSlot, + RewardChainSubSlot, + SubSlotProofs, +) from src.util.streamable import Streamable, streamable diff --git a/src/types/full_block.py b/src/types/full_block.py index fcb4325041ba..fffe362fa354 100644 --- a/src/types/full_block.py +++ b/src/types/full_block.py @@ -1,24 +1,21 @@ from dataclasses import dataclass -from typing import Tuple, List, Optional, Set +from typing import List, Optional, Set, Tuple from chiabip158 import PyBIP158 -from src.types.header_block import HeaderBlock -from src.types.name_puzzle_condition import NPC -from src.types.blockchain_format.coin import Coin +from src.full_node.mempool_check_conditions import get_name_puzzle_conditions from src.types.announcement import Announcement +from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo +from src.types.blockchain_format.program import SerializedProgram +from src.types.blockchain_format.reward_chain_block import RewardChainBlock from src.types.blockchain_format.sized_bytes import bytes32 -from src.full_node.mempool_check_conditions import get_name_puzzle_conditions -from src.util.condition_tools import ( - created_outputs_for_conditions_dict, - created_announcements_for_conditions_dict, -) -from src.util.streamable import Streamable, streamable from src.types.blockchain_format.vdf import VDFProof -from src.types.blockchain_format.reward_chain_block import RewardChainBlock from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo -from src.types.blockchain_format.program import SerializedProgram +from src.types.header_block import HeaderBlock +from src.types.name_puzzle_condition import NPC +from src.util.condition_tools import created_announcements_for_conditions_dict, created_outputs_for_conditions_dict +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/header_block.py b/src/types/header_block.py index a96fa96269ba..7a4c362c8d2e 100644 --- a/src/types/header_block.py +++ b/src/types/header_block.py @@ -1,11 +1,11 @@ -from typing import Optional, List from dataclasses import dataclass +from typing import List, Optional +from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo +from src.types.blockchain_format.reward_chain_block import RewardChainBlock +from src.types.blockchain_format.vdf import VDFProof from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.vdf import VDFProof -from src.types.blockchain_format.reward_chain_block import RewardChainBlock -from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo @dataclass(frozen=True) diff --git a/src/types/mempool_item.py b/src/types/mempool_item.py index b007c1ad9086..be55ab11a8f8 100644 --- a/src/types/mempool_item.py +++ b/src/types/mempool_item.py @@ -3,8 +3,8 @@ from src.consensus.cost_calculator import CostResult from src.types.blockchain_format.coin import Coin -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.spend_bundle import SpendBundle from src.util.ints import uint64 from src.util.streamable import Streamable, streamable diff --git a/src/types/name_puzzle_condition.py b/src/types/name_puzzle_condition.py index f5b358aa9d23..f9a5e131ea2c 100644 --- a/src/types/name_puzzle_condition.py +++ b/src/types/name_puzzle_condition.py @@ -1,10 +1,10 @@ from dataclasses import dataclass from typing import Dict, List, Tuple -from src.types.condition_var_pair import ConditionVarPair from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_var_pair import ConditionVarPair from src.util.condition_tools import ConditionOpcode -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/peer_info.py b/src/types/peer_info.py index 4abfa305bc2a..780e194205ac 100644 --- a/src/types/peer_info.py +++ b/src/types/peer_info.py @@ -1,10 +1,9 @@ +import ipaddress from dataclasses import dataclass from src.util.ints import uint16, uint64 from src.util.streamable import Streamable, streamable -import ipaddress - @dataclass(frozen=True) @streamable diff --git a/src/types/spend_bundle.py b/src/types/spend_bundle.py index 248e083092e2..04468838178d 100644 --- a/src/types/spend_bundle.py +++ b/src/types/spend_bundle.py @@ -1,12 +1,14 @@ from dataclasses import dataclass from typing import List -from src.types.blockchain_format.coin import Coin +from blspy import AugSchemeMPL, G2Element + from src.types.announcement import Announcement +from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.sized_bytes import bytes32 from src.util.streamable import Streamable, streamable + from .coin_solution import CoinSolution -from blspy import G2Element, AugSchemeMPL @dataclass(frozen=True) diff --git a/src/types/unfinished_block.py b/src/types/unfinished_block.py index 2592a936b103..1c649ca1aaac 100644 --- a/src/types/unfinished_block.py +++ b/src/types/unfinished_block.py @@ -1,12 +1,12 @@ from dataclasses import dataclass from typing import List, Optional -from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.vdf import VDFProof -from src.types.blockchain_format.reward_chain_block import RewardChainBlockUnfinished from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock, TransactionsInfo from src.types.blockchain_format.program import SerializedProgram +from src.types.blockchain_format.reward_chain_block import RewardChainBlockUnfinished +from src.types.blockchain_format.vdf import VDFProof +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/types/unfinished_header_block.py b/src/types/unfinished_header_block.py index fcf1c6aed1c7..c97cafc90af8 100644 --- a/src/types/unfinished_header_block.py +++ b/src/types/unfinished_header_block.py @@ -1,11 +1,11 @@ -from typing import Optional, List from dataclasses import dataclass +from typing import List, Optional +from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock +from src.types.blockchain_format.reward_chain_block import RewardChainBlockUnfinished +from src.types.blockchain_format.vdf import VDFProof from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.util.streamable import Streamable, streamable -from src.types.blockchain_format.vdf import VDFProof -from src.types.blockchain_format.reward_chain_block import RewardChainBlockUnfinished -from src.types.blockchain_format.foliage import Foliage, FoliageTransactionBlock @dataclass(frozen=True) diff --git a/src/types/weight_proof.py b/src/types/weight_proof.py index 1f992abcfcd3..32a17e4125a0 100644 --- a/src/types/weight_proof.py +++ b/src/types/weight_proof.py @@ -1,14 +1,13 @@ from dataclasses import dataclass from typing import List, Optional - from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.reward_chain_block import RewardChainBlock from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.blockchain_format.vdf import VDFProof, VDFInfo +from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.header_block import HeaderBlock -from src.util.ints import uint8, uint64, uint32, uint128 +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.streamable import Streamable, streamable diff --git a/src/util/bech32m.py b/src/util/bech32m.py index affa8f0c1f99..5f9cbf97722c 100644 --- a/src/util/bech32m.py +++ b/src/util/bech32m.py @@ -22,9 +22,9 @@ # https://github.com/sipa/bips/blob/bip-bech32m/bip-bech32m.mediawiki """Reference implementation for Bech32m and segwit addresses.""" -from src.types.blockchain_format.sized_bytes import bytes32 +from typing import List, Optional, Tuple -from typing import Tuple, Optional, List +from src.types.blockchain_format.sized_bytes import bytes32 CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" diff --git a/src/util/block_cache.py b/src/util/block_cache.py index cc3f14c23f43..b59c2428e30d 100644 --- a/src/util/block_cache.py +++ b/src/util/block_cache.py @@ -3,10 +3,10 @@ from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary -from src.types.weight_proof import SubEpochSegments, SubEpochChallengeSegment +from src.types.header_block import HeaderBlock +from src.types.weight_proof import SubEpochChallengeSegment, SubEpochSegments from src.util.ints import uint32 diff --git a/src/util/block_tools.py b/src/util/block_tools.py index 71e0018433e3..cc45b8d1770b 100644 --- a/src/util/block_tools.py +++ b/src/util/block_tools.py @@ -9,70 +9,63 @@ from argparse import Namespace from dataclasses import replace from pathlib import Path -from typing import Dict, List, Tuple, Optional, Callable +from typing import Callable, Dict, List, Optional, Tuple -from blspy import G1Element, G2Element, AugSchemeMPL, PrivateKey +from blspy import AugSchemeMPL, G1Element, G2Element, PrivateKey -from src.consensus.blockchain_interface import BlockchainInterface -from src.consensus.deficit import calculate_deficit - -from src.cmds.init import create_default_chia_config, create_all_ssl +from src.cmds.init import create_all_ssl, create_default_chia_config from src.cmds.plots import create_plots +from src.consensus.block_creation import create_unfinished_block, unfinished_block_to_full_block +from src.consensus.block_record import BlockRecord +from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.coinbase import create_puzzlehash_for_pk from src.consensus.constants import ConsensusConstants +from src.consensus.default_constants import DEFAULT_CONSTANTS +from src.consensus.deficit import calculate_deficit +from src.consensus.full_block_to_block_record import block_to_block_record +from src.consensus.make_sub_epoch_summary import next_sub_epoch_summary from src.consensus.pot_iterations import ( calculate_ip_iters, calculate_iterations_quality, - calculate_sp_iters, calculate_sp_interval_iters, + calculate_sp_iters, is_overflow_block, ) -from src.consensus.full_block_to_block_record import block_to_block_record -from src.consensus.make_sub_epoch_summary import next_sub_epoch_summary -from src.full_node.signage_point import SignagePoint -from src.consensus.block_record import BlockRecord from src.consensus.vdf_info_computation import get_signage_point_vdf_info -from src.plotting.plot_tools import load_plots, PlotInfo +from src.full_node.signage_point import SignagePoint +from src.plotting.plot_tools import PlotInfo, load_plots, parse_plot_info from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.coin import Coin -from src.types.end_of_slot_bundle import EndOfSubSlotBundle -from src.types.full_block import FullBlock from src.types.blockchain_format.pool_target import PoolTarget from src.types.blockchain_format.proof_of_space import ProofOfSpace from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.slots import ( - InfusedChallengeChainSubSlot, ChallengeChainSubSlot, + InfusedChallengeChainSubSlot, RewardChainSubSlot, SubSlotProofs, ) -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary -from src.types.unfinished_block import UnfinishedBlock from src.types.blockchain_format.vdf import VDFInfo, VDFProof -from src.consensus.block_creation import ( - create_unfinished_block, - unfinished_block_to_full_block, -) +from src.types.end_of_slot_bundle import EndOfSubSlotBundle +from src.types.full_block import FullBlock +from src.types.spend_bundle import SpendBundle +from src.types.unfinished_block import UnfinishedBlock from src.util.bech32m import encode_puzzle_hash from src.util.block_cache import BlockCache from src.util.config import load_config, save_config from src.util.hash import std_hash -from src.util.ints import uint32, uint64, uint128, uint8 +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.keychain import Keychain, bytes_to_mnemonic from src.util.path import mkdir from src.util.vdf_prover import get_vdf_info_and_proof from src.util.wallet_tools import WalletTool from src.wallet.derive_keys import ( master_sk_to_farmer_sk, + master_sk_to_local_sk, master_sk_to_pool_sk, master_sk_to_wallet_sk, ) -from src.consensus.default_constants import DEFAULT_CONSTANTS - -from src.plotting.plot_tools import parse_plot_info -from src.wallet.derive_keys import master_sk_to_local_sk - test_constants = DEFAULT_CONSTANTS.replace( **{ diff --git a/src/util/chain_utils.py b/src/util/chain_utils.py index fffe9c876593..fd9f5e8ca6d7 100644 --- a/src/util/chain_utils.py +++ b/src/util/chain_utils.py @@ -1,13 +1,13 @@ from typing import List +from src.types.announcement import Announcement from src.types.blockchain_format.coin import Coin -from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.program import Program -from src.types.announcement import Announcement +from src.types.blockchain_format.sized_bytes import bytes32 from src.util.condition_tools import ( - created_outputs_for_conditions_dict, conditions_dict_for_solution, created_announcements_for_conditions_dict, + created_outputs_for_conditions_dict, ) diff --git a/src/util/chia_logging.py b/src/util/chia_logging.py index fe45faa3ecf6..7ff384af6000 100644 --- a/src/util/chia_logging.py +++ b/src/util/chia_logging.py @@ -1,12 +1,12 @@ import logging -import colorlog - from pathlib import Path from typing import Dict -from src.util.path import mkdir, path_from_root +import colorlog from concurrent_log_handler import ConcurrentRotatingFileHandler +from src.util.path import mkdir, path_from_root + def initialize_logging(service_name: str, logging_config: Dict, root_path: Path): log_path = path_from_root(root_path, logging_config.get("log_filename", "log/debug.log")) diff --git a/src/util/condition_tools.py b/src/util/condition_tools.py index 31e602a37672..7e6f1c20fe1b 100644 --- a/src/util/condition_tools.py +++ b/src/util/condition_tools.py @@ -1,16 +1,16 @@ -from typing import Optional, Tuple, List, Dict +from typing import Dict, List, Optional, Tuple from blspy import G1Element -from src.types.condition_var_pair import ConditionVarPair -from src.types.condition_opcodes import ConditionOpcode -from src.types.blockchain_format.coin import Coin from src.types.announcement import Announcement +from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_opcodes import ConditionOpcode +from src.types.condition_var_pair import ConditionVarPair from src.util.clvm import int_from_bytes +from src.util.errors import ConsensusError, Err from src.util.ints import uint64 -from src.util.errors import Err, ConsensusError def parse_sexp_to_condition( diff --git a/src/util/config.py b/src/util/config.py index ec1e279190f6..b69a4daf0f22 100644 --- a/src/util/config.py +++ b/src/util/config.py @@ -1,12 +1,13 @@ import argparse -import pkg_resources +import os +import shutil import sys +from pathlib import Path +from typing import Any, Callable, Dict, Optional, Union + +import pkg_resources import yaml -import shutil -import os -from pathlib import Path -from typing import Dict, Any, Callable, Optional, Union from src.util.path import mkdir diff --git a/src/util/create_alert_file.py b/src/util/create_alert_file.py index 36d136ab94c5..8a196f2c32ef 100644 --- a/src/util/create_alert_file.py +++ b/src/util/create_alert_file.py @@ -1,9 +1,11 @@ from pathlib import Path from typing import List + from blspy import AugSchemeMPL + from src.util.ints import uint32 from src.util.keychain import Keychain -from src.util.validate_alert import validate_alert_file, create_alert_file, create_not_ready_alert_file +from src.util.validate_alert import create_alert_file, create_not_ready_alert_file, validate_alert_file bitcoin_hash = None bram_message = None diff --git a/src/util/errors.py b/src/util/errors.py index e2fbdf73eacc..69010431f732 100644 --- a/src/util/errors.py +++ b/src/util/errors.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import List, Any +from typing import Any, List class Err(Enum): diff --git a/src/util/json_util.py b/src/util/json_util.py index cc90de690ea5..c93887451ceb 100644 --- a/src/util/json_util.py +++ b/src/util/json_util.py @@ -1,6 +1,7 @@ import dataclasses import json from typing import Any + from aiohttp import web from src.wallet.util.wallet_types import WalletType diff --git a/src/util/keychain.py b/src/util/keychain.py index 9254eeb62fb7..ea65c0296ea1 100644 --- a/src/util/keychain.py +++ b/src/util/keychain.py @@ -1,18 +1,16 @@ import unicodedata - +from hashlib import pbkdf2_hmac from secrets import token_bytes from sys import platform -from typing import List, Tuple, Optional -from hashlib import pbkdf2_hmac +from typing import List, Optional, Tuple import keyring as keyring_main import pkg_resources - from bitstring import BitArray from blspy import AugSchemeMPL, G1Element, PrivateKey from keyrings.cryptfile.cryptfile import CryptFileKeyring -from src.util.hash import std_hash +from src.util.hash import std_hash MAX_KEYS = 100 diff --git a/src/util/merkle_set.py b/src/util/merkle_set.py index fbc9c3e9764f..74df010b1229 100644 --- a/src/util/merkle_set.py +++ b/src/util/merkle_set.py @@ -1,6 +1,6 @@ from abc import ABCMeta, abstractmethod from hashlib import sha256 -from typing import Dict, List, Any, Tuple +from typing import Any, Dict, List, Tuple from src.types.blockchain_format.sized_bytes import bytes32 diff --git a/src/util/path.py b/src/util/path.py index cf7d11670f2b..3b1a133296f4 100644 --- a/src/util/path.py +++ b/src/util/path.py @@ -1,7 +1,6 @@ import os - -from typing import Union from pathlib import Path +from typing import Union def path_from_root(root: Path, path_str: Union[str, Path]) -> Path: diff --git a/src/util/prev_transaction_block.py b/src/util/prev_transaction_block.py index 73ce948c54b7..f67c9a296cd8 100644 --- a/src/util/prev_transaction_block.py +++ b/src/util/prev_transaction_block.py @@ -1,7 +1,7 @@ from typing import Tuple -from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.block_record import BlockRecord +from src.consensus.blockchain_interface import BlockchainInterface from src.util.ints import uint128 diff --git a/src/util/streamable.py b/src/util/streamable.py index 71192d9d6cc0..af20e6680883 100644 --- a/src/util/streamable.py +++ b/src/util/streamable.py @@ -1,27 +1,21 @@ # flake8: noqa from __future__ import annotations -import sys import dataclasses import io import pprint +import sys from enum import Enum -from typing import Any, BinaryIO, List, Type, get_type_hints, Dict, Tuple -from src.util.byte_types import hexstr_to_bytes -from src.types.blockchain_format.program import Program, SerializedProgram -from src.util.hash import std_hash +from typing import Any, BinaryIO, Dict, List, Tuple, Type, get_type_hints -from blspy import PrivateKey, G1Element, G2Element +from blspy import G1Element, G2Element, PrivateKey +from src.types.blockchain_format.program import Program, SerializedProgram from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint32, uint64, int64, uint128, int512 -from src.util.type_checking import ( - is_type_List, - is_type_Tuple, - is_type_SpecificOptional, - strictdataclass, -) - +from src.util.byte_types import hexstr_to_bytes +from src.util.hash import std_hash +from src.util.ints import int64, int512, uint32, uint64, uint128 +from src.util.type_checking import is_type_List, is_type_SpecificOptional, is_type_Tuple, strictdataclass if sys.version_info < (3, 8): diff --git a/src/util/type_checking.py b/src/util/type_checking.py index 722dc51584cf..e384c6d001a6 100644 --- a/src/util/type_checking.py +++ b/src/util/type_checking.py @@ -1,7 +1,6 @@ -import sys import dataclasses -from typing import Any, List, Type, Union, get_type_hints, Tuple, Optional - +import sys +from typing import Any, List, Optional, Tuple, Type, Union, get_type_hints if sys.version_info < (3, 8): diff --git a/src/util/validate_alert.py b/src/util/validate_alert.py index 54147529bf27..f8df66299a70 100644 --- a/src/util/validate_alert.py +++ b/src/util/validate_alert.py @@ -1,7 +1,7 @@ import json from pathlib import Path -from blspy import SignatureMPL, PublicKeyMPL, AugSchemeMPL +from blspy import AugSchemeMPL, PublicKeyMPL, SignatureMPL from src.util.byte_types import hexstr_to_bytes from src.util.hash import std_hash diff --git a/src/util/vdf_prover.py b/src/util/vdf_prover.py index 0b0f8cc3b0da..0e0d10c29c9d 100644 --- a/src/util/vdf_prover.py +++ b/src/util/vdf_prover.py @@ -5,8 +5,8 @@ from src.consensus.constants import ConsensusConstants from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.blockchain_format.vdf import VDFProof, VDFInfo -from src.util.ints import uint64, uint8 +from src.types.blockchain_format.vdf import VDFInfo, VDFProof +from src.util.ints import uint8, uint64 def get_vdf_info_and_proof( diff --git a/src/util/wallet_tools.py b/src/util/wallet_tools.py index da190efbe230..3417b878b12b 100644 --- a/src/util/wallet_tools.py +++ b/src/util/wallet_tools.py @@ -1,40 +1,35 @@ -from typing import List, Optional, Dict +from typing import Dict, List, Optional -from blspy import PrivateKey, AugSchemeMPL, G2Element +from blspy import AugSchemeMPL, G2Element, PrivateKey -from src.types.condition_var_pair import ConditionVarPair -from src.types.condition_opcodes import ConditionOpcode -from src.types.blockchain_format.program import Program from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.program import Program +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_solution import CoinSolution +from src.types.condition_opcodes import ConditionOpcode +from src.types.condition_var_pair import ConditionVarPair from src.types.spend_bundle import SpendBundle -from src.util.clvm import int_to_bytes, int_from_bytes -from src.util.condition_tools import ( - conditions_by_opcode, - pkm_pairs_for_conditions_dict, - conditions_for_solution, -) +from src.util.clvm import int_from_bytes, int_to_bytes +from src.util.condition_tools import conditions_by_opcode, conditions_for_solution, pkm_pairs_for_conditions_dict from src.util.ints import uint32, uint64 +from src.wallet.derive_keys import master_sk_to_wallet_sk from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ( + DEFAULT_HIDDEN_PUZZLE_HASH, + calculate_synthetic_secret_key, puzzle_for_pk, solution_for_conditions, - calculate_synthetic_secret_key, - DEFAULT_HIDDEN_PUZZLE_HASH, ) from src.wallet.puzzles.puzzle_utils import ( - make_create_announcement, + make_assert_aggsig_condition, make_assert_announcement, - make_assert_my_coin_id_condition, - make_create_coin_condition, - make_assert_height_now_exceeds_condition, make_assert_height_age_exceeds_condition, - make_assert_aggsig_condition, + make_assert_height_now_exceeds_condition, + make_assert_my_coin_id_condition, make_assert_seconds_now_exceeds_condition, + make_create_announcement, + make_create_coin_condition, make_reserve_fee_condition, ) -from src.wallet.derive_keys import master_sk_to_wallet_sk -from src.types.blockchain_format.sized_bytes import bytes32 - DEFAULT_SEED = b"seed" * 8 assert len(DEFAULT_SEED) == 32 diff --git a/src/util/ws_message.py b/src/util/ws_message.py index 82d1c336b2f5..3c65d8e4f801 100644 --- a/src/util/ws_message.py +++ b/src/util/ws_message.py @@ -1,5 +1,5 @@ from secrets import token_bytes -from typing import Dict, Any +from typing import Any, Dict from src.util.json_util import dict_to_json_str diff --git a/src/wallet/cc_wallet/cc_info.py b/src/wallet/cc_wallet/cc_info.py index ba64aef38754..1f7cb53cf159 100644 --- a/src/wallet/cc_wallet/cc_info.py +++ b/src/wallet/cc_wallet/cc_info.py @@ -3,7 +3,7 @@ from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/wallet/cc_wallet/cc_utils.py b/src/wallet/cc_wallet/cc_utils.py index c2e290b6e9db..145e3c79afb2 100644 --- a/src/wallet/cc_wallet/cc_utils.py +++ b/src/wallet/cc_wallet/cc_utils.py @@ -1,25 +1,23 @@ import dataclasses - from typing import List, Optional, Tuple -from blspy import G2Element, AugSchemeMPL +from blspy import AugSchemeMPL, G2Element from src.types.blockchain_format.coin import Coin -from src.types.condition_opcodes import ConditionOpcode from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_opcodes import ConditionOpcode from src.types.spend_bundle import CoinSolution, SpendBundle from src.util.condition_tools import conditions_dict_for_solution from src.util.ints import uint64 from src.wallet.puzzles.cc_loader import CC_MOD, LOCK_INNER_PUZZLE from src.wallet.puzzles.genesis_by_coin_id_with_0 import ( - lineage_proof_for_genesis, + genesis_coin_id_for_genesis_coin_checker, lineage_proof_for_coin, + lineage_proof_for_genesis, lineage_proof_for_zero, - genesis_coin_id_for_genesis_coin_checker, ) - NULL_SIGNATURE = G2Element() ANYONE_CAN_SPEND_PUZZLE = Program.to(1) # simply return the conditions diff --git a/src/wallet/cc_wallet/cc_wallet.py b/src/wallet/cc_wallet/cc_wallet.py index 565d83e92794..5a3b66a17c34 100644 --- a/src/wallet/cc_wallet/cc_wallet.py +++ b/src/wallet/cc_wallet/cc_wallet.py @@ -2,54 +2,51 @@ import logging import time +from dataclasses import replace from secrets import token_bytes +from typing import Any, Dict, List, Optional, Set -from typing import Dict, Optional, List, Any, Set -from blspy import G2Element, AugSchemeMPL +from blspy import AugSchemeMPL, G2Element -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.full_node.bundle_tools import best_solution_program from src.protocols.wallet_protocol import PuzzleSolutionResponse from src.types.blockchain_format.coin import Coin -from src.types.coin_solution import CoinSolution from src.types.blockchain_format.program import Program -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_solution import CoinSolution +from src.types.spend_bundle import SpendBundle from src.util.byte_types import hexstr_to_bytes -from src.util.condition_tools import ( - conditions_dict_for_solution, - pkm_pairs_for_conditions_dict, -) +from src.util.condition_tools import conditions_dict_for_solution, pkm_pairs_for_conditions_dict +from src.util.ints import uint8, uint32, uint64, uint128 from src.util.json_util import dict_to_json_str -from src.util.ints import uint8, uint64, uint32, uint128 from src.wallet.block_record import HeaderBlockRecord from src.wallet.cc_wallet.cc_info import CCInfo -from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ( - calculate_synthetic_secret_key, - DEFAULT_HIDDEN_PUZZLE_HASH, -) -from src.wallet.transaction_record import TransactionRecord -from src.wallet.util.transaction_type import TransactionType -from src.wallet.util.wallet_types import WalletType -from src.wallet.wallet import Wallet -from src.wallet.wallet_coin_record import WalletCoinRecord -from src.wallet.wallet_info import WalletInfo -from src.wallet.derivation_record import DerivationRecord from src.wallet.cc_wallet.cc_utils import ( + CC_MOD, SpendableCC, - cc_puzzle_hash_for_inner_puzzle_hash, cc_puzzle_for_inner_puzzle, - spend_bundle_for_spendable_ccs, + cc_puzzle_hash_for_inner_puzzle_hash, get_lineage_proof_from_coin_and_puz, + spend_bundle_for_spendable_ccs, uncurry_cc, - CC_MOD, ) +from src.wallet.derivation_record import DerivationRecord from src.wallet.puzzles.genesis_by_coin_id_with_0 import ( create_genesis_or_zero_coin_checker, - lineage_proof_for_genesis, genesis_coin_id_for_genesis_coin_checker, + lineage_proof_for_genesis, ) -from dataclasses import replace +from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ( + DEFAULT_HIDDEN_PUZZLE_HASH, + calculate_synthetic_secret_key, +) +from src.wallet.transaction_record import TransactionRecord +from src.wallet.util.transaction_type import TransactionType +from src.wallet.util.wallet_types import WalletType +from src.wallet.wallet import Wallet +from src.wallet.wallet_coin_record import WalletCoinRecord +from src.wallet.wallet_info import WalletInfo class CCWallet: diff --git a/src/wallet/cc_wallet/ccparent.py b/src/wallet/cc_wallet/ccparent.py index f09f5cc1d9ab..0c2bc8896fec 100644 --- a/src/wallet/cc_wallet/ccparent.py +++ b/src/wallet/cc_wallet/ccparent.py @@ -3,7 +3,7 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint64 -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/wallet/cc_wallet/debug_spend_bundle.py b/src/wallet/cc_wallet/debug_spend_bundle.py index ffaaa4c49735..a9566c70c4f5 100644 --- a/src/wallet/cc_wallet/debug_spend_bundle.py +++ b/src/wallet/cc_wallet/debug_spend_bundle.py @@ -1,19 +1,17 @@ from typing import List, Tuple +from blspy import AugSchemeMPL from clvm import KEYWORD_FROM_ATOM - from clvm_tools.binutils import disassemble as bu_disassemble -from blspy import AugSchemeMPL + from src.types.blockchain_format.coin import Coin -from src.types.condition_opcodes import ConditionOpcode from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_opcodes import ConditionOpcode from src.types.spend_bundle import SpendBundle -from src.util.condition_tools import conditions_dict_for_solution -from src.util.condition_tools import pkm_pairs_for_conditions_dict +from src.util.condition_tools import conditions_dict_for_solution, pkm_pairs_for_conditions_dict from src.util.hash import std_hash - CONDITIONS = dict((k, bytes(v)[0]) for k, v in ConditionOpcode.__members__.items()) # pylint: disable=E1101 KFA = {v: k for k, v in CONDITIONS.items()} diff --git a/src/wallet/derivation_record.py b/src/wallet/derivation_record.py index 114b3b506581..609505f6c585 100644 --- a/src/wallet/derivation_record.py +++ b/src/wallet/derivation_record.py @@ -1,9 +1,10 @@ from dataclasses import dataclass + from blspy import G1Element from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.streamable import Streamable, streamable from src.util.ints import uint32 +from src.util.streamable import Streamable, streamable from src.wallet.util.wallet_types import WalletType diff --git a/src/wallet/derive_keys.py b/src/wallet/derive_keys.py index a2fd29a41263..ccb8c8ae92ff 100644 --- a/src/wallet/derive_keys.py +++ b/src/wallet/derive_keys.py @@ -1,4 +1,5 @@ from typing import List + from blspy import AugSchemeMPL, PrivateKey from src.util.ints import uint32 diff --git a/src/wallet/key_val_store.py b/src/wallet/key_val_store.py index 2019114d0a38..6e244889179e 100644 --- a/src/wallet/key_val_store.py +++ b/src/wallet/key_val_store.py @@ -1,4 +1,5 @@ from typing import Any + import aiosqlite from src.util.byte_types import hexstr_to_bytes diff --git a/src/wallet/puzzles/genesis_by_coin_id_with_0.py b/src/wallet/puzzles/genesis_by_coin_id_with_0.py index 751b46ae6f93..cc7400f243d5 100644 --- a/src/wallet/puzzles/genesis_by_coin_id_with_0.py +++ b/src/wallet/puzzles/genesis_by_coin_id_with_0.py @@ -5,7 +5,6 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.wallet.puzzles.load_clvm import load_clvm - MOD = load_clvm("genesis-by-coin-id-with-0.clvm", package_or_requirement=__name__) diff --git a/src/wallet/puzzles/genesis_by_puzzle_hash_with_0.py b/src/wallet/puzzles/genesis_by_puzzle_hash_with_0.py index c4b32cb49441..e47a533246cd 100644 --- a/src/wallet/puzzles/genesis_by_puzzle_hash_with_0.py +++ b/src/wallet/puzzles/genesis_by_puzzle_hash_with_0.py @@ -5,7 +5,6 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.wallet.puzzles.load_clvm import load_clvm - MOD = load_clvm("genesis-by-puzzle-hash-with-0.clvm", package_or_requirement=__name__) diff --git a/src/wallet/puzzles/load_clvm.py b/src/wallet/puzzles/load_clvm.py index 32831b5ebb0b..01f8c9a4ebe3 100644 --- a/src/wallet/puzzles/load_clvm.py +++ b/src/wallet/puzzles/load_clvm.py @@ -1,7 +1,6 @@ import pathlib import pkg_resources - from clvm_tools.clvmc import compile_clvm from src.types.blockchain_format.program import Program, SerializedProgram diff --git a/src/wallet/puzzles/p2_conditions.py b/src/wallet/puzzles/p2_conditions.py index c971ee0bc4ee..3124f63077d8 100644 --- a/src/wallet/puzzles/p2_conditions.py +++ b/src/wallet/puzzles/p2_conditions.py @@ -14,7 +14,6 @@ from .load_clvm import load_clvm - MOD = load_clvm("p2_conditions.clvm") diff --git a/src/wallet/puzzles/p2_delegated_conditions.py b/src/wallet/puzzles/p2_delegated_conditions.py index 649f267c40b6..7eedfa857d6d 100644 --- a/src/wallet/puzzles/p2_delegated_conditions.py +++ b/src/wallet/puzzles/p2_delegated_conditions.py @@ -10,7 +10,6 @@ from .load_clvm import load_clvm - MOD = load_clvm("p2_delegated_conditions.clvm") diff --git a/src/wallet/puzzles/p2_delegated_puzzle.py b/src/wallet/puzzles/p2_delegated_puzzle.py index 5e6834e0c76d..fef2fb20699b 100644 --- a/src/wallet/puzzles/p2_delegated_puzzle.py +++ b/src/wallet/puzzles/p2_delegated_puzzle.py @@ -15,10 +15,8 @@ from src.types.blockchain_format.program import Program from . import p2_conditions - from .load_clvm import load_clvm - MOD = load_clvm("p2_delegated_puzzle.clvm") diff --git a/src/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py b/src/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py index de2986904d63..07b6f62500d3 100644 --- a/src/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +++ b/src/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py @@ -14,11 +14,9 @@ This roughly corresponds to bitcoin's taproot. """ import hashlib - from typing import Union from blspy import G1Element, PrivateKey - from clvm.casts import int_from_bytes from src.types.blockchain_format.program import Program @@ -27,7 +25,6 @@ from .load_clvm import load_clvm from .p2_conditions import puzzle_for_conditions - DEFAULT_HIDDEN_PUZZLE = Program.from_bytes(bytes.fromhex("ff0980")) DEFAULT_HIDDEN_PUZZLE_HASH = DEFAULT_HIDDEN_PUZZLE.get_tree_hash() # this puzzle `(x)` always fails diff --git a/src/wallet/puzzles/p2_m_of_n_delegate_direct.py b/src/wallet/puzzles/p2_m_of_n_delegate_direct.py index 91c75982f072..067390a50891 100644 --- a/src/wallet/puzzles/p2_m_of_n_delegate_direct.py +++ b/src/wallet/puzzles/p2_m_of_n_delegate_direct.py @@ -9,7 +9,6 @@ from .load_clvm import load_clvm - MOD = load_clvm("p2_m_of_n_delegate_direct.clvm") diff --git a/src/wallet/puzzles/p2_puzzle_hash.py b/src/wallet/puzzles/p2_puzzle_hash.py index 49e9527f459d..d953051cc451 100644 --- a/src/wallet/puzzles/p2_puzzle_hash.py +++ b/src/wallet/puzzles/p2_puzzle_hash.py @@ -10,7 +10,6 @@ from .load_clvm import load_clvm - MOD = load_clvm("p2_puzzle_hash.clvm") diff --git a/src/wallet/puzzles/prefarm/make_prefarm_ph.py b/src/wallet/puzzles/prefarm/make_prefarm_ph.py index b2ad37fdb5ac..a38cac36f14e 100644 --- a/src/wallet/puzzles/prefarm/make_prefarm_ph.py +++ b/src/wallet/puzzles/prefarm/make_prefarm_ph.py @@ -1,11 +1,11 @@ from clvm.casts import int_from_bytes from clvm_tools import binutils +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.types.blockchain_format.program import Program from src.types.condition_opcodes import ConditionOpcode from src.util.bech32m import decode_puzzle_hash, encode_puzzle_hash from src.util.condition_tools import parse_sexp_to_conditions -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward from src.util.ints import uint32 address1 = "txch15gx26ndmacfaqlq8m0yajeggzceu7cvmaz4df0hahkukes695rss6lej7h" # Gene wallet (m/12381/8444/2/42): diff --git a/src/wallet/puzzles/prefarm/spend_prefarm.py b/src/wallet/puzzles/prefarm/spend_prefarm.py index 358a91ccec5a..e5d34004e127 100644 --- a/src/wallet/puzzles/prefarm/spend_prefarm.py +++ b/src/wallet/puzzles/prefarm/spend_prefarm.py @@ -1,16 +1,16 @@ import asyncio + from blspy import G2Element from clvm_tools import binutils -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward +from src.rpc.full_node_rpc_client import FullNodeRpcClient from src.types.blockchain_format.program import Program from src.types.coin_solution import CoinSolution from src.types.spend_bundle import SpendBundle from src.util.bech32m import decode_puzzle_hash - -from src.util.default_root import DEFAULT_ROOT_PATH from src.util.config import load_config -from src.rpc.full_node_rpc_client import FullNodeRpcClient +from src.util.default_root import DEFAULT_ROOT_PATH from src.util.ints import uint32 diff --git a/src/wallet/puzzles/test_cc.py b/src/wallet/puzzles/test_cc.py index e2cd67b3f6e4..9fe301086b02 100644 --- a/src/wallet/puzzles/test_cc.py +++ b/src/wallet/puzzles/test_cc.py @@ -6,23 +6,22 @@ from blspy import G2Element from src.types.blockchain_format.coin import Coin -from src.types.condition_opcodes import ConditionOpcode from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_opcodes import ConditionOpcode from src.types.spend_bundle import CoinSolution, SpendBundle from src.util.ints import uint64 -from src.wallet.cc_wallet.debug_spend_bundle import debug_spend_bundle from src.wallet.cc_wallet.cc_utils import ( + CC_MOD, cc_puzzle_for_inner_puzzle, cc_puzzle_hash_for_inner_puzzle_hash, - spendable_cc_list_from_coin_solution, spend_bundle_for_spendable_ccs, - CC_MOD, + spendable_cc_list_from_coin_solution, ) +from src.wallet.cc_wallet.debug_spend_bundle import debug_spend_bundle from src.wallet.puzzles.genesis_by_coin_id_with_0 import create_genesis_or_zero_coin_checker from src.wallet.puzzles.genesis_by_puzzle_hash_with_0 import create_genesis_puzzle_or_zero_coin_checker - CONDITIONS = dict((k, bytes(v)[0]) for k, v in ConditionOpcode.__members__.items()) # pylint: disable=E1101 NULL_SIGNATURE = G2Element() diff --git a/src/wallet/rl_wallet/rl_wallet.py b/src/wallet/rl_wallet/rl_wallet.py index 422b7b89ab45..06d44d094550 100644 --- a/src/wallet/rl_wallet/rl_wallet.py +++ b/src/wallet/rl_wallet/rl_wallet.py @@ -1,25 +1,28 @@ # RLWallet is subclass of Wallet -from dataclasses import dataclass +import json import time +from dataclasses import dataclass from secrets import token_bytes -from typing import Optional, List, Tuple, Any +from typing import Any, List, Optional, Tuple + +from blspy import AugSchemeMPL, G1Element, PrivateKey -import json -from blspy import PrivateKey, AugSchemeMPL, G1Element from src.types.blockchain_format.coin import Coin -from src.types.coin_solution import CoinSolution from src.types.blockchain_format.program import Program -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_solution import CoinSolution +from src.types.spend_bundle import SpendBundle from src.util.byte_types import hexstr_to_bytes -from src.util.ints import uint8, uint64, uint32, uint128 -from src.util.streamable import streamable, Streamable +from src.util.ints import uint8, uint32, uint64, uint128 +from src.util.streamable import Streamable, streamable +from src.wallet.derivation_record import DerivationRecord +from src.wallet.derive_keys import master_sk_to_wallet_sk from src.wallet.rl_wallet.rl_wallet_puzzles import ( - rl_puzzle_for_pk, + make_clawback_solution, rl_make_aggregation_puzzle, rl_make_aggregation_solution, rl_make_solution_mode_2, - make_clawback_solution, + rl_puzzle_for_pk, solution_for_rl, ) from src.wallet.transaction_record import TransactionRecord @@ -28,8 +31,6 @@ from src.wallet.wallet import Wallet from src.wallet.wallet_coin_record import WalletCoinRecord from src.wallet.wallet_info import WalletInfo -from src.wallet.derivation_record import DerivationRecord -from src.wallet.derive_keys import master_sk_to_wallet_sk @dataclass(frozen=True) diff --git a/src/wallet/rl_wallet/rl_wallet_puzzles.py b/src/wallet/rl_wallet/rl_wallet_puzzles.py index 34037177d060..667d4106ebcb 100644 --- a/src/wallet/rl_wallet/rl_wallet_puzzles.py +++ b/src/wallet/rl_wallet/rl_wallet_puzzles.py @@ -3,9 +3,9 @@ from clvm_tools import binutils -from src.types.condition_opcodes import ConditionOpcode from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.condition_opcodes import ConditionOpcode from src.util.ints import uint64 from src.wallet.chialisp import sexp from src.wallet.puzzles.load_clvm import load_clvm diff --git a/src/wallet/settings/settings_objects.py b/src/wallet/settings/settings_objects.py index 99abacab38ca..db67a189815c 100644 --- a/src/wallet/settings/settings_objects.py +++ b/src/wallet/settings/settings_objects.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from src.util.streamable import streamable, Streamable +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/wallet/settings/user_settings.py b/src/wallet/settings/user_settings.py index 3077dc2a00c9..f347d6365fa2 100644 --- a/src/wallet/settings/user_settings.py +++ b/src/wallet/settings/user_settings.py @@ -1,8 +1,6 @@ from typing import Any, Dict from src.wallet.key_val_store import KeyValStore - - from src.wallet.settings.default_settings import default_settings from src.wallet.settings.settings_objects import BackupInitialized diff --git a/src/wallet/sign_coin_solutions.py b/src/wallet/sign_coin_solutions.py index 9cf53ca92a49..7ed47e2f8d06 100644 --- a/src/wallet/sign_coin_solutions.py +++ b/src/wallet/sign_coin_solutions.py @@ -1,11 +1,10 @@ from typing import Callable, List, Optional + from blspy import AugSchemeMPL, PrivateKey + from src.types.coin_solution import CoinSolution from src.types.spend_bundle import SpendBundle -from src.util.condition_tools import ( - conditions_dict_for_solution, - pkm_pairs_for_conditions_dict, -) +from src.util.condition_tools import conditions_dict_for_solution, pkm_pairs_for_conditions_dict async def sign_coin_solutions( diff --git a/src/wallet/trade_manager.py b/src/wallet/trade_manager.py index d3b91f1949ae..99fb7a22e4d4 100644 --- a/src/wallet/trade_manager.py +++ b/src/wallet/trade_manager.py @@ -1,9 +1,9 @@ +import logging import time import traceback from pathlib import Path from secrets import token_bytes -from typing import Dict, Optional, Tuple, List, Any -import logging +from typing import Any, Dict, List, Optional, Tuple from blspy import AugSchemeMPL @@ -15,6 +15,7 @@ from src.util.hash import std_hash from src.util.ints import uint32, uint64 from src.wallet.cc_wallet import cc_utils +from src.wallet.cc_wallet.cc_utils import CC_MOD, SpendableCC, spend_bundle_for_spendable_ccs, uncurry_cc from src.wallet.cc_wallet.cc_wallet import CCWallet from src.wallet.puzzles.genesis_by_coin_id_with_0 import genesis_coin_id_for_genesis_coin_checker from src.wallet.trade_record import TradeRecord @@ -23,19 +24,12 @@ from src.wallet.transaction_record import TransactionRecord from src.wallet.util.trade_utils import ( get_discrepancies_for_spend_bundle, - get_output_discrepancy_for_puzzle_and_solution, get_output_amount_for_puzzle_and_solution, -) -from src.wallet.cc_wallet.cc_utils import ( - SpendableCC, - uncurry_cc, - spend_bundle_for_spendable_ccs, - CC_MOD, + get_output_discrepancy_for_puzzle_and_solution, ) from src.wallet.util.transaction_type import TransactionType from src.wallet.util.wallet_types import WalletType from src.wallet.wallet import Wallet - from src.wallet.wallet_coin_record import WalletCoinRecord # from src.wallet.cc_wallet.debug_spend_bundle import debug_spend_bundle diff --git a/src/wallet/trade_record.py b/src/wallet/trade_record.py index 2040a865d490..4cc1e2ad9d57 100644 --- a/src/wallet/trade_record.py +++ b/src/wallet/trade_record.py @@ -1,11 +1,11 @@ from dataclasses import dataclass -from typing import Optional, List, Tuple +from typing import List, Optional, Tuple from src.types.blockchain_format.coin import Coin -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.spend_bundle import SpendBundle +from src.util.ints import uint8, uint32, uint64 from src.util.streamable import Streamable, streamable -from src.util.ints import uint32, uint64, uint8 @dataclass(frozen=True) diff --git a/src/wallet/trading/trade_store.py b/src/wallet/trading/trade_store.py index 5f7486409e0c..77fc43181b55 100644 --- a/src/wallet/trading/trade_store.py +++ b/src/wallet/trading/trade_store.py @@ -1,10 +1,12 @@ -from typing import Optional, List +from typing import List, Optional + import aiosqlite + from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint32, uint8 -from src.wallet.trade_record import TradeRecord from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.util.errors import Err +from src.util.ints import uint8, uint32 +from src.wallet.trade_record import TradeRecord from src.wallet.trading.trade_status import TradeStatus diff --git a/src/wallet/transaction_record.py b/src/wallet/transaction_record.py index 52544a3ed138..166a0ed2c1fc 100644 --- a/src/wallet/transaction_record.py +++ b/src/wallet/transaction_record.py @@ -1,12 +1,12 @@ from dataclasses import dataclass -from typing import Optional, List, Tuple +from typing import List, Optional, Tuple from src.types.blockchain_format.coin import Coin -from src.types.spend_bundle import SpendBundle from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.streamable import Streamable, streamable -from src.util.ints import uint32, uint64, uint8 from src.types.mempool_inclusion_status import MempoolInclusionStatus +from src.types.spend_bundle import SpendBundle +from src.util.ints import uint8, uint32, uint64 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/wallet/util/backup_utils.py b/src/wallet/util/backup_utils.py index fc88124fd54c..d6b807057190 100644 --- a/src/wallet/util/backup_utils.py +++ b/src/wallet/util/backup_utils.py @@ -3,7 +3,7 @@ from typing import Any import aiohttp -from blspy import PublicKeyMPL, SignatureMPL, AugSchemeMPL, PrivateKey +from blspy import AugSchemeMPL, PrivateKey, PublicKeyMPL, SignatureMPL from cryptography.fernet import Fernet from src.server.server import ssl_context_for_root diff --git a/src/wallet/util/trade_utils.py b/src/wallet/util/trade_utils.py index 663fd57c8539..51b81a6da37e 100644 --- a/src/wallet/util/trade_utils.py +++ b/src/wallet/util/trade_utils.py @@ -1,12 +1,12 @@ -from typing import Tuple, Optional, Dict +from typing import Dict, Optional, Tuple +from src.types.blockchain_format.program import Program +from src.types.condition_opcodes import ConditionOpcode from src.types.spend_bundle import SpendBundle +from src.util.condition_tools import conditions_dict_for_solution from src.wallet.cc_wallet import cc_utils from src.wallet.trade_record import TradeRecord from src.wallet.trading.trade_status import TradeStatus -from src.types.blockchain_format.program import Program -from src.util.condition_tools import conditions_dict_for_solution -from src.types.condition_opcodes import ConditionOpcode def trade_status_ui_string(status: TradeStatus): diff --git a/src/wallet/wallet.py b/src/wallet/wallet.py index 90b02ed6f00b..c115ad449c5d 100644 --- a/src/wallet/wallet.py +++ b/src/wallet/wallet.py @@ -1,30 +1,30 @@ import logging import time -from typing import Dict, List, Set, Any, Optional +from typing import Any, Dict, List, Optional, Set from blspy import G1Element -from src.types.blockchain_format.coin import Coin -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.full_node.bundle_tools import best_solution_program -from src.types.coin_solution import CoinSolution +from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.coin_solution import CoinSolution from src.types.spend_bundle import SpendBundle -from src.util.ints import uint8, uint64, uint32, uint128 +from src.util.ints import uint8, uint32, uint64, uint128 from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import ( - puzzle_for_pk, DEFAULT_HIDDEN_PUZZLE_HASH, - solution_for_conditions, calculate_synthetic_secret_key, + puzzle_for_pk, + solution_for_conditions, ) from src.wallet.puzzles.puzzle_utils import ( + make_assert_announcement, make_assert_my_coin_id_condition, make_assert_seconds_now_exceeds_condition, + make_create_announcement, make_create_coin_condition, make_reserve_fee_condition, - make_create_announcement, - make_assert_announcement, ) from src.wallet.secret_key_store import SecretKeyStore from src.wallet.sign_coin_solutions import sign_coin_solutions diff --git a/src/wallet/wallet_action.py b/src/wallet/wallet_action.py index 8039363109b7..826299516ac2 100644 --- a/src/wallet/wallet_action.py +++ b/src/wallet/wallet_action.py @@ -1,9 +1,9 @@ from dataclasses import dataclass from typing import Optional -from src.util.streamable import streamable, Streamable -from src.wallet.util.wallet_types import WalletType from src.util.ints import uint32 +from src.util.streamable import Streamable, streamable +from src.wallet.util.wallet_types import WalletType @dataclass(frozen=True) diff --git a/src/wallet/wallet_action_store.py b/src/wallet/wallet_action_store.py index 1dc26327a78b..7c6211416209 100644 --- a/src/wallet/wallet_action_store.py +++ b/src/wallet/wallet_action_store.py @@ -1,6 +1,7 @@ -from typing import Optional, List +from typing import List, Optional import aiosqlite + from src.util.ints import uint32 from src.wallet.util.wallet_types import WalletType from src.wallet.wallet_action import WalletAction diff --git a/src/wallet/wallet_block_store.py b/src/wallet/wallet_block_store.py index 96043b29184d..8516548b956e 100644 --- a/src/wallet/wallet_block_store.py +++ b/src/wallet/wallet_block_store.py @@ -1,12 +1,13 @@ -from typing import Dict, Optional, Tuple, List +from typing import Dict, List, Optional, Tuple + import aiosqlite from src.consensus.block_record import BlockRecord -from src.types.header_block import HeaderBlock +from src.types.blockchain_format.sized_bytes import bytes32 from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.header_block import HeaderBlock from src.util.ints import uint32, uint64 from src.wallet.block_record import HeaderBlockRecord -from src.types.blockchain_format.sized_bytes import bytes32 class WalletBlockStore: diff --git a/src/wallet/wallet_blockchain.py b/src/wallet/wallet_blockchain.py index 41759a435c2a..48d0e9ea9fd0 100644 --- a/src/wallet/wallet_blockchain.py +++ b/src/wallet/wallet_blockchain.py @@ -1,32 +1,30 @@ import asyncio import dataclasses import logging +import multiprocessing from concurrent.futures.process import ProcessPoolExecutor from enum import Enum -import multiprocessing -from typing import Dict, List, Optional, Tuple, Callable, Any, Set +from typing import Any, Callable, Dict, List, Optional, Set, Tuple +from src.consensus.block_header_validation import validate_finished_header_block, validate_unfinished_header_block +from src.consensus.block_record import BlockRecord from src.consensus.blockchain_interface import BlockchainInterface from src.consensus.constants import ConsensusConstants -from src.consensus.difficulty_adjustment import ( - get_next_sub_slot_iters_and_difficulty, -) +from src.consensus.difficulty_adjustment import get_next_sub_slot_iters_and_difficulty +from src.consensus.find_fork_point import find_fork_point_in_chain from src.consensus.full_block_to_block_record import block_to_block_record from src.consensus.multiprocess_validation import PreValidationResult, pre_validate_blocks_multiprocessing -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 -from src.consensus.block_record import BlockRecord from src.types.blockchain_format.sub_epoch_summary import SubEpochSummary +from src.types.header_block import HeaderBlock from src.types.unfinished_block import UnfinishedBlock from src.types.unfinished_header_block import UnfinishedHeaderBlock from src.util.errors import Err, ValidationError from src.util.ints import uint32, uint64 -from src.consensus.find_fork_point import find_fork_point_in_chain -from src.consensus.block_header_validation import validate_finished_header_block, validate_unfinished_header_block from src.util.streamable import recurse_jsonify from src.wallet.block_record import HeaderBlockRecord -from src.wallet.wallet_coin_store import WalletCoinStore from src.wallet.wallet_block_store import WalletBlockStore +from src.wallet.wallet_coin_store import WalletCoinStore log = logging.getLogger(__name__) diff --git a/src/wallet/wallet_coin_record.py b/src/wallet/wallet_coin_record.py index 729b5f53f1ac..6536896c46d0 100644 --- a/src/wallet/wallet_coin_record.py +++ b/src/wallet/wallet_coin_record.py @@ -2,8 +2,8 @@ from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.streamable import Streamable, streamable from src.util.ints import uint32 +from src.util.streamable import Streamable, streamable from src.wallet.util.wallet_types import WalletType diff --git a/src/wallet/wallet_coin_store.py b/src/wallet/wallet_coin_store.py index 813304cef259..ab41ae6d77bd 100644 --- a/src/wallet/wallet_coin_store.py +++ b/src/wallet/wallet_coin_store.py @@ -1,6 +1,8 @@ import asyncio -from typing import Dict, Optional, List, Set +from typing import Dict, List, Optional, Set + import aiosqlite + from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint32, uint64 diff --git a/src/wallet/wallet_info.py b/src/wallet/wallet_info.py index 15eebfefaeed..7f34c1ae19d8 100644 --- a/src/wallet/wallet_info.py +++ b/src/wallet/wallet_info.py @@ -1,7 +1,8 @@ from dataclasses import dataclass from typing import List -from src.util.streamable import streamable, Streamable -from src.util.ints import uint32, uint8 + +from src.util.ints import uint8, uint32 +from src.util.streamable import Streamable, streamable @dataclass(frozen=True) diff --git a/src/wallet/wallet_node.py b/src/wallet/wallet_node.py index e5f62406ef41..23cb50233ed4 100644 --- a/src/wallet/wallet_node.py +++ b/src/wallet/wallet_node.py @@ -1,45 +1,45 @@ import asyncio import json +import logging +import socket import time import traceback from asyncio import Task -from typing import Dict, Optional, Tuple, List, Callable, Union, Set from pathlib import Path -import socket -import logging +from typing import Callable, Dict, List, Optional, Set, Tuple, Union + from blspy import PrivateKey -from src.consensus.multiprocess_validation import PreValidationResult from src.consensus.block_record import BlockRecord +from src.consensus.constants import ConsensusConstants +from src.consensus.multiprocess_validation import PreValidationResult +from src.protocols import wallet_protocol from src.protocols.full_node_protocol import RequestProofOfWeight, RespondProofOfWeight from src.protocols.protocol_message_types import ProtocolMessageTypes from src.protocols.wallet_protocol import ( - RespondBlockHeader, - RequestAdditions, - RespondAdditions, - RespondRemovals, - RejectRemovalsRequest, RejectAdditionsRequest, + RejectRemovalsRequest, + RequestAdditions, RequestHeaderBlocks, + RespondAdditions, + RespondBlockHeader, RespondHeaderBlocks, + RespondRemovals, ) +from src.server.node_discovery import WalletPeers +from src.server.outbound_message import Message, NodeType, make_msg +from src.server.server import ChiaServer from src.server.ws_connection import WSChiaConnection -from src.types.blockchain_format.coin import hash_coin_list, Coin +from src.types.blockchain_format.coin import Coin, hash_coin_list +from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.header_block import HeaderBlock from src.types.peer_info import PeerInfo from src.util.byte_types import hexstr_to_bytes -from src.protocols import wallet_protocol -from src.consensus.constants import ConsensusConstants -from src.server.server import ChiaServer -from src.server.outbound_message import make_msg, NodeType, Message -from src.server.node_discovery import WalletPeers -from src.util.errors import ValidationError, Err +from src.util.errors import Err, ValidationError from src.util.ints import uint32, uint128 -from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.merkle_set import ( - confirm_included_already_hashed, - confirm_not_included_already_hashed, - MerkleSet, -) +from src.util.keychain import Keychain +from src.util.merkle_set import MerkleSet, confirm_included_already_hashed, confirm_not_included_already_hashed +from src.util.path import mkdir, path_from_root from src.wallet.block_record import HeaderBlockRecord from src.wallet.derivation_record import DerivationRecord from src.wallet.settings.settings_objects import BackupInitialized @@ -49,9 +49,6 @@ from src.wallet.wallet_action import WalletAction from src.wallet.wallet_blockchain import ReceiveBlockResult from src.wallet.wallet_state_manager import WalletStateManager -from src.types.header_block import HeaderBlock -from src.util.path import path_from_root, mkdir -from src.util.keychain import Keychain class WalletNode: diff --git a/src/wallet/wallet_node_api.py b/src/wallet/wallet_node_api.py index 978b1f3b3ac4..9454dc7bc4fd 100644 --- a/src/wallet/wallet_node_api.py +++ b/src/wallet/wallet_node_api.py @@ -1,4 +1,4 @@ -from src.protocols import wallet_protocol, full_node_protocol, introducer_protocol +from src.protocols import full_node_protocol, introducer_protocol, wallet_protocol from src.server.outbound_message import NodeType from src.server.ws_connection import WSChiaConnection from src.types.mempool_inclusion_status import MempoolInclusionStatus diff --git a/src/wallet/wallet_puzzle_store.py b/src/wallet/wallet_puzzle_store.py index 5a60bd40df75..cec83acf1bf2 100644 --- a/src/wallet/wallet_puzzle_store.py +++ b/src/wallet/wallet_puzzle_store.py @@ -1,12 +1,14 @@ import asyncio -from blspy import G1Element -from typing import Set, Tuple, Optional, List -import aiosqlite import logging +from typing import List, Optional, Set, Tuple + +import aiosqlite +from blspy import G1Element + from src.types.blockchain_format.sized_bytes import bytes32 from src.util.ints import uint32 -from src.wallet.util.wallet_types import WalletType from src.wallet.derivation_record import DerivationRecord +from src.wallet.util.wallet_types import WalletType log = logging.getLogger(__name__) diff --git a/src/wallet/wallet_state_manager.py b/src/wallet/wallet_state_manager.py index f5376dd31b5a..a57160674493 100644 --- a/src/wallet/wallet_state_manager.py +++ b/src/wallet/wallet_state_manager.py @@ -1,58 +1,57 @@ +import asyncio import base64 import json +import logging import time from collections import defaultdict from pathlib import Path - -from typing import Dict, Optional, List, Set, Tuple, Callable, Any -import logging -import asyncio +from typing import Any, Callable, Dict, List, Optional, Set, Tuple import aiosqlite +from blspy import AugSchemeMPL, G1Element, PrivateKey from chiabip158 import PyBIP158 -from blspy import PrivateKey, G1Element, AugSchemeMPL from cryptography.fernet import Fernet -from src.consensus.constants import ConsensusConstants +from src import __version__ from src.consensus.block_record import BlockRecord +from src.consensus.constants import ConsensusConstants +from src.consensus.find_fork_point import find_fork_point_in_chain from src.full_node.weight_proof import WeightProofHandler -from src.protocols.wallet_protocol import RespondPuzzleSolution, PuzzleSolutionResponse +from src.protocols.wallet_protocol import PuzzleSolutionResponse, RespondPuzzleSolution from src.types.blockchain_format.coin import Coin -from src.types.header_block import HeaderBlock +from src.types.blockchain_format.program import Program from src.types.blockchain_format.sized_bytes import bytes32 from src.types.full_block import FullBlock +from src.types.header_block import HeaderBlock +from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.util.byte_types import hexstr_to_bytes -from src.util.ints import uint32, uint64, uint128 +from src.util.errors import Err from src.util.hash import std_hash +from src.util.ints import uint32, uint64, uint128 from src.wallet.block_record import HeaderBlockRecord from src.wallet.cc_wallet.cc_wallet import CCWallet +from src.wallet.derivation_record import DerivationRecord +from src.wallet.derive_keys import master_sk_to_backup_sk, master_sk_to_wallet_sk from src.wallet.key_val_store import KeyValStore -from src.wallet.settings.user_settings import UserSettings from src.wallet.rl_wallet.rl_wallet import RLWallet +from src.wallet.settings.user_settings import UserSettings from src.wallet.trade_manager import TradeManager from src.wallet.transaction_record import TransactionRecord from src.wallet.util.backup_utils import open_backup_file from src.wallet.util.transaction_type import TransactionType +from src.wallet.util.wallet_types import WalletType +from src.wallet.wallet import Wallet from src.wallet.wallet_action import WalletAction from src.wallet.wallet_action_store import WalletActionStore +from src.wallet.wallet_block_store import WalletBlockStore from src.wallet.wallet_blockchain import WalletBlockchain from src.wallet.wallet_coin_record import WalletCoinRecord from src.wallet.wallet_coin_store import WalletCoinStore -from src.wallet.wallet_block_store import WalletBlockStore from src.wallet.wallet_info import WalletInfo, WalletInfoBackup from src.wallet.wallet_puzzle_store import WalletPuzzleStore from src.wallet.wallet_sync_store import WalletSyncStore from src.wallet.wallet_transaction_store import WalletTransactionStore from src.wallet.wallet_user_store import WalletUserStore -from src.types.mempool_inclusion_status import MempoolInclusionStatus -from src.util.errors import Err -from src.wallet.wallet import Wallet -from src.types.blockchain_format.program import Program -from src.wallet.derivation_record import DerivationRecord -from src.wallet.util.wallet_types import WalletType -from src.consensus.find_fork_point import find_fork_point_in_chain -from src.wallet.derive_keys import master_sk_to_wallet_sk, master_sk_to_backup_sk -from src import __version__ class WalletStateManager: diff --git a/src/wallet/wallet_sync_store.py b/src/wallet/wallet_sync_store.py index 6bae09310bb1..34e959822356 100644 --- a/src/wallet/wallet_sync_store.py +++ b/src/wallet/wallet_sync_store.py @@ -2,8 +2,8 @@ import logging from typing import Dict, List, Optional, Tuple -from src.types.header_block import HeaderBlock from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.header_block import HeaderBlock from src.util.ints import uint32 log = logging.getLogger(__name__) diff --git a/src/wallet/wallet_transaction_store.py b/src/wallet/wallet_transaction_store.py index c2853dea3cfb..87d46af995a4 100644 --- a/src/wallet/wallet_transaction_store.py +++ b/src/wallet/wallet_transaction_store.py @@ -1,10 +1,12 @@ -from typing import Dict, Optional, List, Set, Any +from typing import Any, Dict, List, Optional, Set + import aiosqlite + from src.types.blockchain_format.sized_bytes import bytes32 -from src.util.ints import uint32, uint8 -from src.wallet.transaction_record import TransactionRecord from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.util.errors import Err +from src.util.ints import uint8, uint32 +from src.wallet.transaction_record import TransactionRecord from src.wallet.util.transaction_type import TransactionType diff --git a/src/wallet/wallet_user_store.py b/src/wallet/wallet_user_store.py index 340fcc479d41..3127c05e6c76 100644 --- a/src/wallet/wallet_user_store.py +++ b/src/wallet/wallet_user_store.py @@ -1,6 +1,7 @@ -from typing import Optional, List +from typing import List, Optional import aiosqlite + from src.util.ints import uint32 from src.wallet.util.wallet_types import WalletType from src.wallet.wallet_info import WalletInfo diff --git a/tests/blockchain/test_blockchain.py b/tests/blockchain/test_blockchain.py index 04e1120ffdfa..913e381c24b4 100644 --- a/tests/blockchain/test_blockchain.py +++ b/tests/blockchain/test_blockchain.py @@ -1,9 +1,9 @@ # flake8: noqa: F811, F401 import asyncio +import logging import multiprocessing import time from dataclasses import replace -import logging from secrets import token_bytes import pytest @@ -12,23 +12,23 @@ from src.consensus.blockchain import ReceiveBlockResult from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.blockchain_format.slots import InfusedChallengeChainSubSlot +from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.types.end_of_slot_bundle import EndOfSubSlotBundle from src.types.full_block import FullBlock -from src.types.blockchain_format.slots import InfusedChallengeChainSubSlot from src.types.unfinished_block import UnfinishedBlock -from src.types.blockchain_format.vdf import VDFInfo, VDFProof from src.util.block_tools import get_vdf_info_and_proof from src.util.errors import Err from src.util.hash import std_hash -from src.util.ints import uint64, uint8 -from src.util.wallet_tools import WalletTool +from src.util.ints import uint8, uint64 from src.util.recursive_replace import recursive_replace -from tests.setup_nodes import test_constants, bt -from tests.core.fixtures import empty_blockchain # noqa: F401 -from tests.core.fixtures import default_1000_blocks # noqa: F401 +from src.util.wallet_tools import WalletTool from tests.core.fixtures import default_400_blocks # noqa: F401 +from tests.core.fixtures import default_1000_blocks # noqa: F401 from tests.core.fixtures import default_10000_blocks # noqa: F401 from tests.core.fixtures import default_10000_blocks_compact # noqa: F401 +from tests.core.fixtures import empty_blockchain # noqa: F401 +from tests.setup_nodes import bt, test_constants log = logging.getLogger(__name__) bad_element = ClassgroupElement.from_bytes(b"\x00") diff --git a/tests/clvm/coin_store.py b/tests/clvm/coin_store.py index 84ca94f9609c..daef08425af9 100644 --- a/tests/clvm/coin_store.py +++ b/tests/clvm/coin_store.py @@ -8,7 +8,7 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_record import CoinRecord from src.types.spend_bundle import SpendBundle -from src.util.condition_tools import created_announcements_for_conditions_dict, conditions_dict_for_solution +from src.util.condition_tools import conditions_dict_for_solution, created_announcements_for_conditions_dict from src.util.ints import uint32, uint64 diff --git a/tests/clvm/test_clvm_compilation.py b/tests/clvm/test_clvm_compilation.py index 7da33726111c..f7d37ccc9911 100644 --- a/tests/clvm/test_clvm_compilation.py +++ b/tests/clvm/test_clvm_compilation.py @@ -1,9 +1,9 @@ -from unittest import TestCase from pathlib import Path +from unittest import TestCase -from src.types.blockchain_format.program import SerializedProgram, Program from clvm_tools.clvmc import compile_clvm +from src.types.blockchain_format.program import Program, SerializedProgram wallet_program_files = set( [ diff --git a/tests/clvm/test_puzzles.py b/tests/clvm/test_puzzles.py index 34ac45f5ebf8..3e435cdec74f 100644 --- a/tests/clvm/test_puzzles.py +++ b/tests/clvm/test_puzzles.py @@ -13,14 +13,14 @@ p2_conditions, p2_delegated_conditions, p2_delegated_puzzle, - p2_puzzle_hash, - p2_m_of_n_delegate_direct, p2_delegated_puzzle_or_hidden_puzzle, + p2_m_of_n_delegate_direct, + p2_puzzle_hash, ) from tests.util.key_tool import KeyTool -from .coin_store import CoinStore, CoinTimestamp from ..core.make_block_generator import int_to_public_key +from .coin_store import CoinStore, CoinTimestamp T1 = CoinTimestamp(1, 10000000) T2 = CoinTimestamp(5, 10003000) diff --git a/tests/clvm/test_serialized_program.py b/tests/clvm/test_serialized_program.py index 4d5f07c507e6..4a17a9e0dd40 100644 --- a/tests/clvm/test_serialized_program.py +++ b/tests/clvm/test_serialized_program.py @@ -1,9 +1,8 @@ from unittest import TestCase -from src.types.blockchain_format.program import SerializedProgram, Program +from src.types.blockchain_format.program import Program, SerializedProgram from src.wallet.puzzles.load_clvm import load_clvm - SHA256TREE_MOD = load_clvm("sha256tree_module.clvm") diff --git a/tests/connection_utils.py b/tests/connection_utils.py index d20ccc0ec9e4..cb20fdfde990 100644 --- a/tests/connection_utils.py +++ b/tests/connection_utils.py @@ -3,7 +3,6 @@ from typing import Tuple import aiohttp - from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, serialization diff --git a/tests/core/consensus/test_pot_iterations.py b/tests/core/consensus/test_pot_iterations.py index b5a873abbc6b..58f751fb6f0a 100644 --- a/tests/core/consensus/test_pot_iterations.py +++ b/tests/core/consensus/test_pot_iterations.py @@ -1,14 +1,15 @@ +from pytest import raises + +from src.consensus.default_constants import DEFAULT_CONSTANTS from src.consensus.pos_quality import _expected_plot_size from src.consensus.pot_iterations import ( - is_overflow_block, - calculate_sp_iters, calculate_ip_iters, calculate_iterations_quality, + calculate_sp_iters, + is_overflow_block, ) from src.util.hash import std_hash from src.util.ints import uint8, uint64 -from src.consensus.default_constants import DEFAULT_CONSTANTS -from pytest import raises test_constants = DEFAULT_CONSTANTS.replace(**{"NUM_SPS_SUB_SLOT": 32, "SUB_SLOT_TIME_TARGET": 300}) diff --git a/tests/core/consensus/test_weight_proof.py b/tests/core/consensus/test_weight_proof.py index f4594b74f692..f1c3f757fb30 100644 --- a/tests/core/consensus/test_weight_proof.py +++ b/tests/core/consensus/test_weight_proof.py @@ -1,8 +1,7 @@ # flake8: noqa: F811, F401 import asyncio - import sys -from typing import Dict, Optional, List, Tuple +from typing import Dict, List, Optional, Tuple import aiosqlite import pytest @@ -26,19 +25,18 @@ from src.consensus.pot_iterations import calculate_iterations_quality - from src.full_node.weight_proof import ( # type: ignore WeightProofHandler, _map_sub_epoch_summaries, - _validate_summaries_weight, _validate_segment_slots, + _validate_summaries_weight, ) from src.types.full_block import FullBlock from src.types.header_block import HeaderBlock from src.util.ints import uint32, uint64 from tests.core.fixtures import ( - default_1000_blocks, default_400_blocks, + default_1000_blocks, default_10000_blocks, default_10000_blocks_compact, pre_genesis_empty_slots_1000_blocks, diff --git a/tests/core/daemon/test_daemon_alerts.py b/tests/core/daemon/test_daemon_alerts.py index cda72fbe1556..9959872e97a6 100644 --- a/tests/core/daemon/test_daemon_alerts.py +++ b/tests/core/daemon/test_daemon_alerts.py @@ -6,8 +6,8 @@ from src.util.hash import std_hash from src.util.validate_alert import create_alert_file, create_not_ready_alert_file from tests.setup_nodes import setup_daemon -from tests.util.alert_server import AlertServer from tests.time_out_assert import time_out_assert +from tests.util.alert_server import AlertServer master_int = 5399117110774477986698372024995405256382522670366369834617409486544348441851 master_sk: PrivateKey = PrivateKey.from_bytes(master_int.to_bytes(32, "big")) diff --git a/tests/core/fixtures.py b/tests/core/fixtures.py index b735ac397217..2a5a42f5c082 100644 --- a/tests/core/fixtures.py +++ b/tests/core/fixtures.py @@ -1,15 +1,17 @@ import pickle +from os import path +from pathlib import Path +from typing import List + import aiosqlite import pytest -from typing import List -from pathlib import Path -from src.full_node.block_store import BlockStore + from src.consensus.blockchain import Blockchain +from src.full_node.block_store import BlockStore from src.full_node.coin_store import CoinStore from src.types.full_block import FullBlock from src.util.path import mkdir -from tests.setup_nodes import test_constants, bt -from os import path +from tests.setup_nodes import bt, test_constants @pytest.fixture(scope="function") diff --git a/tests/core/full_node/test_address_manager.py b/tests/core/full_node/test_address_manager.py index 9224ab9e9b85..e84470d04eb2 100644 --- a/tests/core/full_node/test_address_manager.py +++ b/tests/core/full_node/test_address_manager.py @@ -1,12 +1,14 @@ import asyncio -import pytest -import time import math +import time +from pathlib import Path + import aiosqlite -from src.types.peer_info import PeerInfo, TimestampedPeerInfo -from src.server.address_manager import ExtendedPeerInfo, AddressManager +import pytest + +from src.server.address_manager import AddressManager, ExtendedPeerInfo from src.server.address_manager_store import AddressManagerStore -from pathlib import Path +from src.types.peer_info import PeerInfo, TimestampedPeerInfo @pytest.fixture(scope="module") diff --git a/tests/core/full_node/test_block_store.py b/tests/core/full_node/test_block_store.py index 47193527a85f..a5ebbb9ae4d5 100644 --- a/tests/core/full_node/test_block_store.py +++ b/tests/core/full_node/test_block_store.py @@ -1,14 +1,15 @@ import asyncio import random -from pathlib import Path import sqlite3 +from pathlib import Path import aiosqlite import pytest -from src.full_node.block_store import BlockStore + from src.consensus.blockchain import Blockchain +from src.full_node.block_store import BlockStore from src.full_node.coin_store import CoinStore -from tests.setup_nodes import test_constants, bt +from tests.setup_nodes import bt, test_constants @pytest.fixture(scope="module") diff --git a/tests/core/full_node/test_blockchain_transactions.py b/tests/core/full_node/test_blockchain_transactions.py index 272ae6077059..2a8b2ae58861 100644 --- a/tests/core/full_node/test_blockchain_transactions.py +++ b/tests/core/full_node/test_blockchain_transactions.py @@ -1,20 +1,20 @@ import asyncio +import logging import pytest -import logging from clvm.casts import int_to_bytes from src.consensus.blockchain import ReceiveBlockResult from src.protocols import full_node_protocol +from src.types.announcement import Announcement from src.types.condition_opcodes import ConditionOpcode from src.types.condition_var_pair import ConditionVarPair from src.types.spend_bundle import SpendBundle -from src.util.errors import Err, ConsensusError +from src.util.errors import ConsensusError, Err from src.util.ints import uint64 -from tests.core.full_node.test_full_node import connect_and_get_peer -from tests.setup_nodes import setup_two_nodes, test_constants, bt from src.util.wallet_tools import WalletTool -from src.types.announcement import Announcement +from tests.core.full_node.test_full_node import connect_and_get_peer +from tests.setup_nodes import bt, setup_two_nodes, test_constants BURN_PUZZLE_HASH = b"0" * 32 diff --git a/tests/core/full_node/test_coin_store.py b/tests/core/full_node/test_coin_store.py index aa79569ff41c..099489091101 100644 --- a/tests/core/full_node/test_coin_store.py +++ b/tests/core/full_node/test_coin_store.py @@ -1,21 +1,21 @@ import asyncio from pathlib import Path -from typing import Optional, List, Set, Tuple +from typing import List, Optional, Set, Tuple import aiosqlite import pytest -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.consensus.blockchain import Blockchain, ReceiveBlockResult -from src.consensus.coinbase import create_pool_coin, create_farmer_coin -from src.full_node.coin_store import CoinStore +from src.consensus.coinbase import create_farmer_coin, create_pool_coin from src.full_node.block_store import BlockStore +from src.full_node.coin_store import CoinStore from src.types.blockchain_format.coin import Coin from src.types.coin_record import CoinRecord from src.types.full_block import FullBlock from src.util.ints import uint64 -from tests.setup_nodes import test_constants, bt from src.util.wallet_tools import WalletTool +from tests.setup_nodes import bt, test_constants WALLET_A = WalletTool() diff --git a/tests/core/full_node/test_full_node.py b/tests/core/full_node/test_full_node.py index 63b45fe2b88c..df87cd0baa2d 100644 --- a/tests/core/full_node/test_full_node.py +++ b/tests/core/full_node/test_full_node.py @@ -1,44 +1,41 @@ # flake8: noqa: F811, F401 import asyncio import dataclasses - -import pytest +import logging import random import time -import logging -from typing import Dict from secrets import token_bytes +from typing import Dict + +import pytest from src.consensus.pot_iterations import is_overflow_block from src.full_node.full_node_api import FullNodeAPI -from src.protocols import full_node_protocol as fnp, timelord_protocol +from src.protocols import full_node_protocol as fnp +from src.protocols import timelord_protocol from src.protocols.protocol_message_types import ProtocolMessageTypes +from src.server.address_manager import AddressManager +from src.types.blockchain_format.classgroup import ClassgroupElement from src.types.blockchain_format.program import SerializedProgram +from src.types.blockchain_format.vdf import CompressibleVDFField +from src.types.condition_opcodes import ConditionOpcode +from src.types.condition_var_pair import ConditionVarPair from src.types.full_block import FullBlock -from src.types.peer_info import TimestampedPeerInfo, PeerInfo -from src.server.address_manager import AddressManager +from src.types.peer_info import PeerInfo, TimestampedPeerInfo from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock from src.util.block_tools import get_signage_point +from src.util.clvm import int_to_bytes from src.util.errors import Err from src.util.hash import std_hash -from src.util.ints import uint16, uint32, uint64, uint8 -from src.types.condition_var_pair import ConditionVarPair -from src.types.condition_opcodes import ConditionOpcode +from src.util.ints import uint8, uint16, uint32, uint64 +from src.util.vdf_prover import get_vdf_info_and_proof from src.util.wallet_tools import WalletTool from tests.connection_utils import add_dummy_connection, connect_and_get_peer from tests.core.full_node.test_coin_store import get_future_reward_coins -from tests.setup_nodes import test_constants, bt, self_hostname, setup_simulators_and_wallets -from src.util.clvm import int_to_bytes from tests.core.full_node.test_full_sync import node_height_at_least -from tests.time_out_assert import ( - time_out_assert, - time_out_assert_custom_interval, - time_out_messages, -) -from src.util.vdf_prover import get_vdf_info_and_proof -from src.types.blockchain_format.classgroup import ClassgroupElement -from src.types.blockchain_format.vdf import CompressibleVDFField +from tests.setup_nodes import bt, self_hostname, setup_simulators_and_wallets, test_constants +from tests.time_out_assert import time_out_assert, time_out_assert_custom_interval, time_out_messages log = logging.getLogger(__name__) diff --git a/tests/core/full_node/test_full_node_store.py b/tests/core/full_node/test_full_node_store.py index 476c623dfdce..5e8e832c4c32 100644 --- a/tests/core/full_node/test_full_node_store.py +++ b/tests/core/full_node/test_full_node_store.py @@ -2,6 +2,7 @@ import asyncio import logging from secrets import token_bytes + import pytest from pytest import raises @@ -14,13 +15,11 @@ from src.types.blockchain_format.sized_bytes import bytes32 from src.types.unfinished_block import UnfinishedBlock from src.util.block_cache import BlockCache -from src.util.hash import std_hash -from src.util.ints import uint32, uint8, uint128, uint64 -from tests.setup_nodes import test_constants, bt from src.util.block_tools import get_signage_point +from src.util.hash import std_hash +from src.util.ints import uint8, uint32, uint64, uint128 from tests.core.fixtures import empty_blockchain # noqa: F401 -from src.util.block_cache import BlockCache - +from tests.setup_nodes import bt, test_constants log = logging.getLogger(__name__) diff --git a/tests/core/full_node/test_full_sync.py b/tests/core/full_node/test_full_sync.py index 5751a2183880..9841021ce28e 100644 --- a/tests/core/full_node/test_full_sync.py +++ b/tests/core/full_node/test_full_sync.py @@ -6,19 +6,14 @@ import pytest +from src.protocols import full_node_protocol from src.types.full_block import FullBlock from src.types.peer_info import PeerInfo -from src.protocols import full_node_protocol from src.util.hash import std_hash from src.util.ints import uint16 -from tests.setup_nodes import setup_two_nodes, test_constants, bt, setup_n_nodes, self_hostname +from tests.core.fixtures import default_400_blocks, default_1000_blocks, default_10000_blocks, empty_blockchain +from tests.setup_nodes import bt, self_hostname, setup_n_nodes, setup_two_nodes, test_constants from tests.time_out_assert import time_out_assert -from tests.core.fixtures import ( - empty_blockchain, - default_400_blocks, - default_1000_blocks, - default_10000_blocks, -) def node_height_at_least(node, h): diff --git a/tests/core/full_node/test_initial_freeze.py b/tests/core/full_node/test_initial_freeze.py index 3f7682cfa13c..67dc419ee836 100644 --- a/tests/core/full_node/test_initial_freeze.py +++ b/tests/core/full_node/test_initial_freeze.py @@ -1,4 +1,5 @@ import asyncio + import pytest from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward @@ -13,7 +14,7 @@ from src.util.ints import uint16, uint32 from src.wallet.transaction_record import TransactionRecord from tests.core.full_node.test_full_node import add_dummy_connection -from tests.setup_nodes import setup_simulators_and_wallets, self_hostname, bt +from tests.setup_nodes import bt, self_hostname, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert diff --git a/tests/core/full_node/test_mempool.py b/tests/core/full_node/test_mempool.py index 1cbcaac8e638..c355f84384f5 100644 --- a/tests/core/full_node/test_mempool.py +++ b/tests/core/full_node/test_mempool.py @@ -5,14 +5,14 @@ import pytest from src.protocols import full_node_protocol +from src.types.announcement import Announcement from src.types.blockchain_format.coin import Coin from src.types.coin_solution import CoinSolution -from src.types.condition_var_pair import ConditionVarPair from src.types.condition_opcodes import ConditionOpcode +from src.types.condition_var_pair import ConditionVarPair from src.types.spend_bundle import SpendBundle -from src.types.announcement import Announcement -from src.util.condition_tools import conditions_for_solution from src.util.clvm import int_to_bytes +from src.util.condition_tools import conditions_for_solution from src.util.ints import uint64 from tests.core.full_node.test_full_node import connect_and_get_peer, node_height_at_least from tests.setup_nodes import bt, setup_simulators_and_wallets diff --git a/tests/core/full_node/test_node_load.py b/tests/core/full_node/test_node_load.py index 95c9dddcd9be..a2bc4f00dd66 100644 --- a/tests/core/full_node/test_node_load.py +++ b/tests/core/full_node/test_node_load.py @@ -7,7 +7,7 @@ from src.types.peer_info import PeerInfo from src.util.ints import uint16 from tests.core.full_node.test_full_node import connect_and_get_peer -from tests.setup_nodes import setup_two_nodes, test_constants, bt, self_hostname +from tests.setup_nodes import bt, self_hostname, setup_two_nodes, test_constants from tests.time_out_assert import time_out_assert diff --git a/tests/core/full_node/test_sync_store.py b/tests/core/full_node/test_sync_store.py index 4237f432cae2..6265ee62196d 100644 --- a/tests/core/full_node/test_sync_store.py +++ b/tests/core/full_node/test_sync_store.py @@ -1,6 +1,7 @@ import asyncio import pytest + from src.full_node.sync_store import SyncStore from src.util.hash import std_hash diff --git a/tests/core/full_node/test_transactions.py b/tests/core/full_node/test_transactions.py index d89a2266a06c..7770de4d2705 100644 --- a/tests/core/full_node/test_transactions.py +++ b/tests/core/full_node/test_transactions.py @@ -4,14 +4,14 @@ import pytest -from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.consensus.block_record import BlockRecord +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.full_node.full_node_api import FullNodeAPI from src.protocols import full_node_protocol from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.peer_info import PeerInfo from src.util.ints import uint16, uint32 -from tests.setup_nodes import setup_simulators_and_wallets, self_hostname +from tests.setup_nodes import self_hostname, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert diff --git a/tests/core/make_block_generator.py b/tests/core/make_block_generator.py index 6f1252472ca6..bc2cf726a88e 100644 --- a/tests/core/make_block_generator.py +++ b/tests/core/make_block_generator.py @@ -1,7 +1,7 @@ -import blspy - from typing import Dict +import blspy + from src.full_node.bundle_tools import best_solution_program from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.program import Program, SerializedProgram @@ -11,7 +11,6 @@ from src.util.ints import uint64 from src.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_pk, solution_for_conditions - GROUP_ORDER = 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001 diff --git a/tests/core/server/test_dos.py b/tests/core/server/test_dos.py index 3d129a119f44..f30f6b2a5e4e 100644 --- a/tests/core/server/test_dos.py +++ b/tests/core/server/test_dos.py @@ -1,10 +1,9 @@ # flake8: noqa: F811, F401 import asyncio - -import pytest import logging -from aiohttp import ClientTimeout, ClientSession, WSMessage, WSMsgType, WSCloseCode, ServerDisconnectedError +import pytest +from aiohttp import ClientSession, ClientTimeout, ServerDisconnectedError, WSCloseCode, WSMessage, WSMsgType from src.full_node.full_node_api import FullNodeAPI from src.server.server import ssl_context_for_client diff --git a/tests/core/ssl/test_ssl.py b/tests/core/ssl/test_ssl.py index cec498e82caa..8cd252e825ea 100644 --- a/tests/core/ssl/test_ssl.py +++ b/tests/core/ssl/test_ssl.py @@ -1,6 +1,8 @@ import asyncio + import aiohttp import pytest + from src.protocols.shared_protocol import protocol_version from src.server.outbound_message import NodeType from src.server.server import ChiaServer, ssl_context_for_client @@ -10,11 +12,11 @@ from src.util.block_tools import test_constants from src.util.ints import uint16 from tests.setup_nodes import ( - setup_simulators_and_wallets, + bt, self_hostname, setup_farmer_harvester, setup_introducer, - bt, + setup_simulators_and_wallets, setup_timelord, ) diff --git a/tests/core/test_cost_calculation.py b/tests/core/test_cost_calculation.py index b8a3d7315cfb..23e285812985 100644 --- a/tests/core/test_cost_calculation.py +++ b/tests/core/test_cost_calculation.py @@ -1,21 +1,17 @@ import asyncio -import time import logging import pathlib +import time import pytest +from clvm_tools import binutils -from src.consensus.cost_calculator import calculate_cost_of_program, CostResult +from src.consensus.cost_calculator import CostResult, calculate_cost_of_program from src.full_node.bundle_tools import best_solution_program -from src.full_node.mempool_check_conditions import ( - get_name_puzzle_conditions, - get_puzzle_and_solution_for_coin, -) +from src.full_node.mempool_check_conditions import get_name_puzzle_conditions, get_puzzle_and_solution_for_coin from src.types.blockchain_format.program import Program, SerializedProgram from src.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle - -from tests.setup_nodes import test_constants, bt -from clvm_tools import binutils +from tests.setup_nodes import bt, test_constants from .make_block_generator import make_block_generator diff --git a/tests/core/test_farmer_harvester_rpc.py b/tests/core/test_farmer_harvester_rpc.py index a7380082322e..56b5848ed3ac 100644 --- a/tests/core/test_farmer_harvester_rpc.py +++ b/tests/core/test_farmer_harvester_rpc.py @@ -1,21 +1,20 @@ -import pytest - from secrets import token_bytes + +import pytest from blspy import AugSchemeMPL from chiapos import DiskPlotter +from src.plotting.plot_tools import stream_plot_info_ph, stream_plot_info_pk from src.protocols import farmer_protocol +from src.rpc.farmer_rpc_api import FarmerRpcApi from src.rpc.farmer_rpc_client import FarmerRpcClient +from src.rpc.harvester_rpc_api import HarvesterRpcApi from src.rpc.harvester_rpc_client import HarvesterRpcClient from src.rpc.rpc_server import start_rpc_server -from src.util.hash import std_hash -from src.util.ints import uint16, uint64, uint8 -from src.plotting.plot_tools import stream_plot_info_pk, stream_plot_info_ph -from src.rpc.farmer_rpc_api import FarmerRpcApi -from src.rpc.harvester_rpc_api import HarvesterRpcApi - -from tests.setup_nodes import setup_farmer_harvester, test_constants, bt, self_hostname from src.util.block_tools import get_plot_dir +from src.util.hash import std_hash +from src.util.ints import uint8, uint16, uint64 +from tests.setup_nodes import bt, self_hostname, setup_farmer_harvester, test_constants from tests.time_out_assert import time_out_assert diff --git a/tests/core/test_full_node_rpc.py b/tests/core/test_full_node_rpc.py index ce92068dbcc2..a218b21cfe77 100644 --- a/tests/core/test_full_node_rpc.py +++ b/tests/core/test_full_node_rpc.py @@ -2,17 +2,17 @@ from blspy import AugSchemeMPL from src.consensus.pot_iterations import is_overflow_block -from src.rpc.full_node_rpc_api import FullNodeRpcApi -from src.rpc.rpc_server import start_rpc_server from src.protocols import full_node_protocol +from src.rpc.full_node_rpc_api import FullNodeRpcApi from src.rpc.full_node_rpc_client import FullNodeRpcClient +from src.rpc.rpc_server import start_rpc_server from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.spend_bundle import SpendBundle from src.types.unfinished_block import UnfinishedBlock from src.util.hash import std_hash from src.util.ints import uint16 from src.util.wallet_tools import WalletTool -from tests.setup_nodes import test_constants, bt, self_hostname, setup_simulators_and_wallets +from tests.setup_nodes import bt, self_hostname, setup_simulators_and_wallets, test_constants from tests.time_out_assert import time_out_assert diff --git a/tests/core/test_setproctitle.py b/tests/core/test_setproctitle.py index 8c306944954d..7b2371e54156 100644 --- a/tests/core/test_setproctitle.py +++ b/tests/core/test_setproctitle.py @@ -1,4 +1,5 @@ import unittest + from src.util.setproctitle import setproctitle diff --git a/tests/core/types/test_proof_of_space.py b/tests/core/types/test_proof_of_space.py index aac1db71986e..ad6d48e7334c 100644 --- a/tests/core/types/test_proof_of_space.py +++ b/tests/core/types/test_proof_of_space.py @@ -1,7 +1,7 @@ from secrets import token_bytes -from src.types.blockchain_format.proof_of_space import ProofOfSpace # pylint: disable=E0401 from src.consensus.default_constants import DEFAULT_CONSTANTS +from src.types.blockchain_format.proof_of_space import ProofOfSpace # pylint: disable=E0401 class TestProofOfSpace: diff --git a/tests/core/util/test_keychain.py b/tests/core/util/test_keychain.py index b58af29f354e..ac31e26d4707 100644 --- a/tests/core/util/test_keychain.py +++ b/tests/core/util/test_keychain.py @@ -1,14 +1,10 @@ -import unittest import json +import unittest from secrets import token_bytes -from blspy import PrivateKey, AugSchemeMPL -from src.util.keychain import ( - Keychain, - generate_mnemonic, - bytes_from_mnemonic, - bytes_to_mnemonic, - mnemonic_to_seed, -) + +from blspy import AugSchemeMPL, PrivateKey + +from src.util.keychain import Keychain, bytes_from_mnemonic, bytes_to_mnemonic, generate_mnemonic, mnemonic_to_seed class TesKeychain(unittest.TestCase): diff --git a/tests/core/util/test_significant_bits.py b/tests/core/util/test_significant_bits.py index 8d3de7c1665d..6794e509bb0e 100644 --- a/tests/core/util/test_significant_bits.py +++ b/tests/core/util/test_significant_bits.py @@ -1,8 +1,6 @@ import unittest -from src.util.significant_bits import ( - truncate_to_significant_bits, - count_significant_bits, -) + +from src.util.significant_bits import count_significant_bits, truncate_to_significant_bits class TestSignificantBits(unittest.TestCase): diff --git a/tests/core/util/test_streamable.py b/tests/core/util/test_streamable.py index 4ac37d63599c..d315018d959f 100644 --- a/tests/core/util/test_streamable.py +++ b/tests/core/util/test_streamable.py @@ -1,16 +1,17 @@ import unittest from dataclasses import dataclass from typing import List, Optional + from pytest import raises -from src.types.weight_proof import SubEpochChallengeSegment -from src.util.ints import uint32, uint8 +from src.protocols.wallet_protocol import RespondRemovals from src.types.blockchain_format.coin import Coin from src.types.blockchain_format.sized_bytes import bytes32 from src.types.full_block import FullBlock +from src.types.weight_proof import SubEpochChallengeSegment +from src.util.ints import uint8, uint32 from src.util.streamable import Streamable, streamable -from src.protocols.wallet_protocol import RespondRemovals -from tests.setup_nodes import test_constants, bt +from tests.setup_nodes import bt, test_constants class TestStreamable(unittest.TestCase): diff --git a/tests/core/util/test_type_checking.py b/tests/core/util/test_type_checking.py index 5cbbe1831892..4fe5332372b0 100644 --- a/tests/core/util/test_type_checking.py +++ b/tests/core/util/test_type_checking.py @@ -3,11 +3,7 @@ from typing import Dict, List, Optional, Tuple from src.util.ints import uint8 -from src.util.type_checking import ( - is_type_List, - is_type_SpecificOptional, - strictdataclass, -) +from src.util.type_checking import is_type_List, is_type_SpecificOptional, strictdataclass class TestIsTypeList(unittest.TestCase): diff --git a/tests/setup_nodes.py b/tests/setup_nodes.py index d1efcc0d1960..d25c55752d7f 100644 --- a/tests/setup_nodes.py +++ b/tests/setup_nodes.py @@ -1,36 +1,29 @@ import asyncio import signal - from secrets import token_bytes from typing import Dict, List, Optional + from src.consensus.constants import ConsensusConstants -from src.daemon.server import ( - create_server_for_daemon, - WebSocketServer, - daemon_launch_lock_path, - singleton, -) +from src.daemon.server import WebSocketServer, create_server_for_daemon, daemon_launch_lock_path, singleton from src.full_node.full_node_api import FullNodeAPI -from src.timelord.timelord_launcher import spawn_process, kill_processes -from src.util.block_tools import BlockTools, test_constants -from src.types.peer_info import PeerInfo -from src.util.config import save_config -from src.util.hash import std_hash -from src.util.keychain import Keychain, bytes_to_mnemonic -from src.simulator.start_simulator import service_kwargs_for_full_node_simulator from src.server.start_farmer import service_kwargs_for_farmer from src.server.start_full_node import service_kwargs_for_full_node from src.server.start_harvester import service_kwargs_for_harvester from src.server.start_introducer import service_kwargs_for_introducer +from src.server.start_service import Service from src.server.start_timelord import service_kwargs_for_timelord from src.server.start_wallet import service_kwargs_for_wallet -from src.server.start_service import Service -from src.util.ints import uint16, uint32 +from src.simulator.start_simulator import service_kwargs_for_full_node_simulator +from src.timelord.timelord_launcher import kill_processes, spawn_process +from src.types.peer_info import PeerInfo from src.util.bech32m import encode_puzzle_hash - +from src.util.block_tools import BlockTools, test_constants +from src.util.config import save_config +from src.util.hash import std_hash +from src.util.ints import uint16, uint32 +from src.util.keychain import Keychain, bytes_to_mnemonic from tests.time_out_assert import time_out_assert_custom_interval - bt = BlockTools(constants=test_constants) self_hostname = bt.config["self_hostname"] diff --git a/tests/simulation/test_simulation.py b/tests/simulation/test_simulation.py index f18c106bbebd..1b0c29dc2dc4 100644 --- a/tests/simulation/test_simulation.py +++ b/tests/simulation/test_simulation.py @@ -1,10 +1,11 @@ import pytest -from tests.core.full_node.test_full_sync import node_height_at_least -from tests.setup_nodes import setup_full_system, setup_full_node, test_constants, self_hostname -from src.util.ints import uint16 -from tests.time_out_assert import time_out_assert + from src.types.peer_info import PeerInfo from src.util.block_tools import BlockTools +from src.util.ints import uint16 +from tests.core.full_node.test_full_sync import node_height_at_least +from tests.setup_nodes import self_hostname, setup_full_node, setup_full_system, test_constants +from tests.time_out_assert import time_out_assert test_constants_modified = test_constants.replace( **{ diff --git a/tests/time_out_assert.py b/tests/time_out_assert.py index 32823785a0c1..2d5ee3364ad6 100644 --- a/tests/time_out_assert.py +++ b/tests/time_out_assert.py @@ -1,6 +1,6 @@ import asyncio -import time import logging +import time from typing import Callable from src.protocols.protocol_message_types import ProtocolMessageTypes diff --git a/tests/util/alert_server.py b/tests/util/alert_server.py index b2dcf74cf09c..53cf4d79bd49 100644 --- a/tests/util/alert_server.py +++ b/tests/util/alert_server.py @@ -1,10 +1,10 @@ import argparse -from typing import Any -from aiohttp import web import asyncio -from pathlib import Path import logging +from pathlib import Path +from typing import Any +from aiohttp import web log = logging.getLogger(__name__) diff --git a/tests/util/benchmark_cost.py b/tests/util/benchmark_cost.py index 520fe75c2221..1b8af73e1c56 100644 --- a/tests/util/benchmark_cost.py +++ b/tests/util/benchmark_cost.py @@ -1,16 +1,16 @@ import time from secrets import token_bytes -from blspy import PrivateKey, AugSchemeMPL +from blspy import AugSchemeMPL, PrivateKey from clvm_tools import binutils +from src.types.blockchain_format.program import Program from src.types.condition_opcodes import ConditionOpcode from src.types.condition_var_pair import ConditionVarPair -from src.types.blockchain_format.program import Program -from src.wallet.puzzles.p2_delegated_puzzle import puzzle_for_pk -from src.util.wallet_tools import WalletTool from src.util.ints import uint32 +from src.util.wallet_tools import WalletTool from src.wallet.derive_keys import master_sk_to_wallet_sk +from src.wallet.puzzles.p2_delegated_puzzle import puzzle_for_pk def float_to_str(f): diff --git a/tests/util/key_tool.py b/tests/util/key_tool.py index 21c550f6a027..d4deb35f3a42 100644 --- a/tests/util/key_tool.py +++ b/tests/util/key_tool.py @@ -2,14 +2,10 @@ from blspy import AugSchemeMPL, G2Element, PrivateKey -from src.util.condition_tools import ( - conditions_by_opcode, - pkm_pairs_for_conditions_dict, - conditions_for_solution, -) from src.types.blockchain_format.sized_bytes import bytes32 from src.types.coin_solution import CoinSolution -from tests.core.make_block_generator import int_to_public_key, GROUP_ORDER +from src.util.condition_tools import conditions_by_opcode, conditions_for_solution, pkm_pairs_for_conditions_dict +from tests.core.make_block_generator import GROUP_ORDER, int_to_public_key class KeyTool(dict): diff --git a/tests/wallet/cc_wallet/test_cc_wallet.py b/tests/wallet/cc_wallet/test_cc_wallet.py index 27d841b5c77e..a86bab94a573 100644 --- a/tests/wallet/cc_wallet/test_cc_wallet.py +++ b/tests/wallet/cc_wallet/test_cc_wallet.py @@ -3,19 +3,19 @@ import pytest +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.full_node.mempool_manager import MempoolManager from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.blockchain_format.coin import Coin -from src.types.peer_info import PeerInfo from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.peer_info import PeerInfo from src.util.ints import uint16, uint32, uint64 from src.wallet.cc_wallet.cc_utils import cc_puzzle_hash_for_inner_puzzle_hash +from src.wallet.cc_wallet.cc_wallet import CCWallet from src.wallet.puzzles.cc_loader import CC_MOD from src.wallet.transaction_record import TransactionRecord from src.wallet.wallet_coin_record import WalletCoinRecord from tests.setup_nodes import setup_simulators_and_wallets -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward -from src.wallet.cc_wallet.cc_wallet import CCWallet from tests.time_out_assert import time_out_assert diff --git a/tests/wallet/cc_wallet/test_trades.py b/tests/wallet/cc_wallet/test_trades.py index 1209dd1e393d..316dc033f775 100644 --- a/tests/wallet/cc_wallet/test_trades.py +++ b/tests/wallet/cc_wallet/test_trades.py @@ -8,10 +8,10 @@ from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.peer_info import PeerInfo from src.util.ints import uint16, uint64 +from src.wallet.cc_wallet.cc_wallet import CCWallet from src.wallet.trade_manager import TradeManager from src.wallet.trading.trade_status import TradeStatus from tests.setup_nodes import setup_simulators_and_wallets -from src.wallet.cc_wallet.cc_wallet import CCWallet @pytest.fixture(scope="module") diff --git a/tests/wallet/rl_wallet/test_rl_rpc.py b/tests/wallet/rl_wallet/test_rl_rpc.py index ed1cdda0b384..b6ceac9570e9 100644 --- a/tests/wallet/rl_wallet/test_rl_rpc.py +++ b/tests/wallet/rl_wallet/test_rl_rpc.py @@ -1,17 +1,18 @@ import asyncio + import pytest from src.rpc.wallet_rpc_api import WalletRpcApi from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.blockchain_format.coin import Coin +from src.types.blockchain_format.sized_bytes import bytes32 +from src.types.mempool_inclusion_status import MempoolInclusionStatus from src.types.peer_info import PeerInfo from src.util.bech32m import encode_puzzle_hash from src.util.ints import uint16 from src.wallet.util.wallet_types import WalletType -from tests.setup_nodes import setup_simulators_and_wallets, self_hostname +from tests.setup_nodes import self_hostname, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert -from src.types.blockchain_format.sized_bytes import bytes32 -from src.types.mempool_inclusion_status import MempoolInclusionStatus @pytest.fixture(scope="module") diff --git a/tests/wallet/rl_wallet/test_rl_wallet.py b/tests/wallet/rl_wallet/test_rl_wallet.py index 4175bd7ecb7d..01da032c4b47 100644 --- a/tests/wallet/rl_wallet/test_rl_wallet.py +++ b/tests/wallet/rl_wallet/test_rl_wallet.py @@ -6,7 +6,7 @@ from src.types.peer_info import PeerInfo from src.util.ints import uint16, uint64 from src.wallet.rl_wallet.rl_wallet import RLWallet -from tests.setup_nodes import setup_simulators_and_wallets, self_hostname +from tests.setup_nodes import self_hostname, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert diff --git a/tests/wallet/rpc/test_wallet_rpc.py b/tests/wallet/rpc/test_wallet_rpc.py index 01b6b726eff0..897c768d16df 100644 --- a/tests/wallet/rpc/test_wallet_rpc.py +++ b/tests/wallet/rpc/test_wallet_rpc.py @@ -1,19 +1,19 @@ import asyncio import logging +from pathlib import Path import pytest -from pathlib import Path -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward +from src.rpc.rpc_server import start_rpc_server +from src.rpc.wallet_rpc_api import WalletRpcApi +from src.rpc.wallet_rpc_client import WalletRpcClient from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.peer_info import PeerInfo +from src.util.bech32m import encode_puzzle_hash from src.util.ints import uint16, uint32 -from tests.setup_nodes import setup_simulators_and_wallets, bt +from tests.setup_nodes import bt, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert -from src.util.bech32m import encode_puzzle_hash -from src.rpc.wallet_rpc_client import WalletRpcClient -from src.rpc.wallet_rpc_api import WalletRpcApi -from src.rpc.rpc_server import start_rpc_server log = logging.getLogger(__name__) diff --git a/tests/wallet/test_chialisp.py b/tests/wallet/test_chialisp.py index 1227bf52be26..ad544ccc11ab 100644 --- a/tests/wallet/test_chialisp.py +++ b/tests/wallet/test_chialisp.py @@ -1,19 +1,19 @@ import pytest from src.wallet.chialisp import ( - sexp, - cons, - first, - rest, - nth, - args, apply, + args, + cons, eval, - quote, - make_if, - make_list, fail, + first, is_zero, + make_if, + make_list, + nth, + quote, + rest, + sexp, ) diff --git a/tests/wallet/test_puzzle_store.py b/tests/wallet/test_puzzle_store.py index 33efaeb316ba..e5096d6827ae 100644 --- a/tests/wallet/test_puzzle_store.py +++ b/tests/wallet/test_puzzle_store.py @@ -1,13 +1,15 @@ import asyncio -from secrets import token_bytes from pathlib import Path -import pytest +from secrets import token_bytes + import aiosqlite +import pytest from blspy import AugSchemeMPL + from src.util.ints import uint32 -from src.wallet.wallet_puzzle_store import WalletPuzzleStore from src.wallet.derivation_record import DerivationRecord from src.wallet.util.wallet_types import WalletType +from src.wallet.wallet_puzzle_store import WalletPuzzleStore @pytest.fixture(scope="module") diff --git a/tests/wallet/test_wallet.py b/tests/wallet/test_wallet.py index aa669692f907..928a8a003f55 100644 --- a/tests/wallet/test_wallet.py +++ b/tests/wallet/test_wallet.py @@ -2,8 +2,7 @@ import pytest - -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward from src.protocols.full_node_protocol import RespondBlock from src.server.server import ChiaServer from src.simulator.simulator_protocol import FarmNewBlockProtocol, ReorgProtocol @@ -11,7 +10,7 @@ from src.util.ints import uint16, uint32 from src.wallet.util.transaction_type import TransactionType from src.wallet.wallet_state_manager import WalletStateManager -from tests.setup_nodes import setup_simulators_and_wallets, self_hostname +from tests.setup_nodes import self_hostname, setup_simulators_and_wallets from tests.time_out_assert import time_out_assert, time_out_assert_not_none from tests.wallet.cc_wallet.test_cc_wallet import tx_in_pool diff --git a/tests/wallet/test_wallet_sync.py b/tests/wallet/test_wallet_sync.py index 32d565e3d349..d9e8b2e1f1c6 100644 --- a/tests/wallet/test_wallet_sync.py +++ b/tests/wallet/test_wallet_sync.py @@ -3,14 +3,14 @@ import pytest -from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward +from src.consensus.block_rewards import calculate_base_farmer_reward, calculate_pool_reward +from src.protocols import full_node_protocol from src.simulator.simulator_protocol import FarmNewBlockProtocol from src.types.peer_info import PeerInfo -from src.protocols import full_node_protocol from src.util.ints import uint16, uint32 from src.wallet.wallet_state_manager import WalletStateManager from tests.core.fixtures import default_400_blocks, default_1000_blocks -from tests.setup_nodes import setup_node_and_wallet, test_constants, bt, setup_simulators_and_wallets, self_hostname +from tests.setup_nodes import bt, self_hostname, setup_node_and_wallet, setup_simulators_and_wallets, test_constants from tests.time_out_assert import time_out_assert