mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-11 18:58:59 +03:00
Speed up tests
This commit is contained in:
parent
a7cd787477
commit
04edeb5255
@ -12,6 +12,7 @@ version_data = copy_metadata(get_distribution("chia-blockchain"))[0]
|
||||
|
||||
SUBCOMMANDS = [
|
||||
"init",
|
||||
"plots",
|
||||
"keys",
|
||||
"show",
|
||||
"start",
|
||||
@ -26,8 +27,7 @@ other = ["aiter.active_aiter", "aiter.aiter_forker", "aiter.aiter_to_iter", "ait
|
||||
"aiter.iter_to_aiter", "aiter.join_aiters", "aiter.map_aiter", "aiter.map_filter_aiter", "aiter.preload_aiter",
|
||||
"aiter.push_aiter", "aiter.sharable_aiter", "aiter.stoppable_aiter"]
|
||||
|
||||
entry_points = ["src.cmds.check_plots",
|
||||
"src.cmds.create_plots",
|
||||
entry_points = ["src.cmds.chia",
|
||||
"src.server.start_wallet",
|
||||
"src.server.start_full_node",
|
||||
"src.server.start_harvester",
|
||||
@ -83,7 +83,7 @@ wallet = Analysis([f"{root}/src/server/start_wallet.py"],
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
|
||||
plotter = Analysis([f"{root}/src/cmds/create_plots.py"],
|
||||
plotter = Analysis([f"{root}/src/cmds/chia.py"],
|
||||
pathex=[f"{root}/venv/lib/python3.7/site-packages/aiter/", f"{root}"],
|
||||
binaries = [],
|
||||
datas=[version_data],
|
||||
@ -122,7 +122,7 @@ harvester = Analysis([f"{root}/src/server/start_harvester.py"],
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
|
||||
check_plots = Analysis([f"{root}/src/cmds/check_plots.py"],
|
||||
check_plots = Analysis([f"{root}/src/cmds/chia.py"],
|
||||
pathex=[f"{root}/venv/lib/python3.7/site-packages/aiter/", f"{root}"],
|
||||
binaries = [],
|
||||
datas=[version_data],
|
||||
|
@ -16,6 +16,7 @@ version_data = copy_metadata(get_distribution("chia-blockchain"))[0]
|
||||
SUBCOMMANDS = [
|
||||
"init",
|
||||
"keys",
|
||||
"plots",
|
||||
"show",
|
||||
"start",
|
||||
"stop",
|
||||
@ -30,8 +31,7 @@ other = ["aiter.active_aiter", "aiter.aiter_forker", "aiter.aiter_to_iter", "ait
|
||||
"aiter.push_aiter", "aiter.sharable_aiter", "aiter.stoppable_aiter", "win32timezone", "win32cred", "pywintypes", "win32ctypes.pywin32"]
|
||||
|
||||
entry_points = ["aiohttp", "aiohttp",
|
||||
"src.cmds.check_plots",
|
||||
"src.cmds.create_plots",
|
||||
"src.cmds.chia",
|
||||
"src.server.start_wallet",
|
||||
"src.server.start_full_node",
|
||||
"src.server.start_harvester",
|
||||
@ -86,7 +86,7 @@ wallet = Analysis([f"../src/server/start_wallet.py"],
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
|
||||
plotter = Analysis([f"../src/cmds/create_plots.py"],
|
||||
plotter = Analysis([f"../src/cmds/chia.py"],
|
||||
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f".."],
|
||||
binaries = [],
|
||||
datas=[version_data],
|
||||
@ -125,7 +125,7 @@ harvester = Analysis([f"../src/server/start_harvester.py"],
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
|
||||
check_plots = Analysis([f"../src/cmds/check_plots.py"],
|
||||
check_plots = Analysis([f"../src/cmds/chia.py"],
|
||||
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
|
||||
binaries = [],
|
||||
datas=[version_data],
|
||||
|
@ -1,9 +1,12 @@
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import pathlib
|
||||
from src.plotting.plot_tools import add_plot_directory
|
||||
from src.plotting.create_plots import create_plots
|
||||
from src.plotting.check_plots import check_plots
|
||||
from src.util.logging import initialize_logging
|
||||
from argparse import ArgumentParser
|
||||
from src.util.default_root import DEFAULT_ROOT_PATH
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -108,3 +111,22 @@ def handler(args, parser):
|
||||
elif command == "add":
|
||||
str_path = args.final_dir
|
||||
add_plot_directory(str_path, root_path)
|
||||
|
||||
|
||||
def main():
|
||||
# TODO: remove: this is a hack to get pypacker to be able to call the script
|
||||
parser: ArgumentParser = ArgumentParser(description="Chia plots")
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"--root-path",
|
||||
help="Config file root (defaults to %s)." % DEFAULT_ROOT_PATH,
|
||||
type=pathlib.Path,
|
||||
default=DEFAULT_ROOT_PATH,
|
||||
)
|
||||
make_parser(parser)
|
||||
args = parser.parse_args()
|
||||
handler(args, parser)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -7,9 +7,13 @@ from datetime import datetime
|
||||
from src.types.proof_of_space import ProofOfSpace
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.keychain import Keychain
|
||||
from src.util.config import config_path_for_filename, load_config, save_config
|
||||
from src.util.config import config_path_for_filename, load_config
|
||||
from src.util.path import mkdir
|
||||
from src.plotting.plot_tools import get_plot_filenames, stream_plot_info
|
||||
from src.plotting.plot_tools import (
|
||||
get_plot_filenames,
|
||||
stream_plot_info,
|
||||
add_plot_directory,
|
||||
)
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -78,6 +82,8 @@ def create_plots(args, root_path, use_datetime=True):
|
||||
mkdir(args.tmp2_dir)
|
||||
mkdir(args.final_dir)
|
||||
finished_filenames = []
|
||||
config = load_config(root_path, config_filename)
|
||||
plot_filenames = get_plot_filenames(config["harvester"])
|
||||
for i in range(args.index, args.index + num):
|
||||
# Generate a sk based on the seed, plot size (k), and index
|
||||
sk: PrivateKey = PrivateKey.from_seed(
|
||||
@ -101,14 +107,13 @@ def create_plots(args, root_path, use_datetime=True):
|
||||
filename = f"plot-k{args.size}-{plot_seed}.plot"
|
||||
full_path: Path = args.final_dir / filename
|
||||
|
||||
config = load_config(root_path, config_filename)
|
||||
plot_filenames = get_plot_filenames(config["harvester"])
|
||||
if args.final_dir.resolve() not in plot_filenames:
|
||||
# Adds the directory to the plot directories if it is not present
|
||||
config["harvester"]["plot_directories"].append(
|
||||
if (
|
||||
str(args.final_dir.resolve())
|
||||
)
|
||||
save_config(root_path, config_filename, config)
|
||||
not in config["harvester"]["plot_directories"]
|
||||
):
|
||||
# Adds the directory to the plot directories if it is not present
|
||||
config = add_plot_directory(str(args.final_dir.resolve()), root_path)
|
||||
|
||||
if not full_path.exists():
|
||||
# Creates the plot. This will take a long time for larger plots.
|
||||
|
@ -72,6 +72,7 @@ def add_plot_directory(str_path, root_path):
|
||||
if str(Path(str_path).resolve()) not in config["harvester"]["plot_directories"]:
|
||||
config["harvester"]["plot_directories"].append(str(Path(str_path).resolve()))
|
||||
save_config(root_path, "config.yaml", config)
|
||||
return config
|
||||
|
||||
|
||||
def load_plots(
|
||||
|
@ -17,13 +17,14 @@ from src.util.api_decorators import api_request
|
||||
from src.util.ints import uint64
|
||||
from tests.block_tools import BlockTools
|
||||
|
||||
bt = BlockTools()
|
||||
OutboundMessageGenerator = AsyncGenerator[OutboundMessage, None]
|
||||
|
||||
|
||||
class FullNodeSimulator(FullNode):
|
||||
def __init__(self, config, root_path, name, override_constants):
|
||||
super().__init__(config, root_path, name, override_constants)
|
||||
self.bt = BlockTools()
|
||||
def __init__(self, config, root_path, consensus_constants, name):
|
||||
super().__init__(config, root_path, consensus_constants, name)
|
||||
self.bt = bt
|
||||
|
||||
def _set_server(self, server: ChiaServer):
|
||||
super()._set_server(server)
|
||||
|
@ -11,8 +11,6 @@ from src.types.full_block import FullBlock
|
||||
from src.types.header import Header, HeaderData
|
||||
from src.types.proof_of_space import ProofOfSpace
|
||||
from src.util.ints import uint8, uint64, uint32
|
||||
from src.consensus.constants import ConsensusConstants
|
||||
from tests.block_tools import BlockTools
|
||||
from src.util.errors import Err
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.types.pool_target import PoolTarget
|
||||
@ -22,10 +20,9 @@ from src.full_node.coin_store import CoinStore
|
||||
from src.consensus.find_fork_point import find_fork_point_in_chain
|
||||
from tests.make_test_constants import make_test_constants_with_genesis
|
||||
|
||||
from tests.setup_nodes import bt
|
||||
|
||||
test_constants: Dict[str, Any] = consensus_constants.copy()
|
||||
test_constants.update(
|
||||
|
||||
test_constants, bt = make_test_constants_with_genesis(
|
||||
{
|
||||
"DIFFICULTY_STARTING": 1,
|
||||
"DISCRIMINANT_SIZE_BITS": 8,
|
||||
|
@ -12,5 +12,7 @@ def make_test_constants_with_genesis(test_constants_overrides: Dict):
|
||||
|
||||
new_genesis_block = bt.create_genesis_block(test_constants, bytes([0] * 32), b"0")
|
||||
|
||||
final_test_constants = test_constants.replace(GENESIS_BLOCK=bytes(new_genesis_block))
|
||||
return final_test_constants
|
||||
final_test_constants = test_constants.replace(
|
||||
GENESIS_BLOCK=bytes(new_genesis_block)
|
||||
)
|
||||
return final_test_constants, bt
|
||||
|
@ -1,5 +1,5 @@
|
||||
[pytest]
|
||||
; logging options
|
||||
log_cli = 1
|
||||
log_level = WARNING
|
||||
log_level = INFO
|
||||
log_format = %(asctime)s %(name)s: %(levelname)s %(message)s
|
||||
|
@ -11,7 +11,6 @@ from src.simulator.full_node_simulator import FullNodeSimulator
|
||||
from src.timelord_launcher import spawn_process, kill_processes
|
||||
from src.util.keychain import Keychain
|
||||
from src.wallet.wallet_node import WalletNode
|
||||
from tests.block_tools import BlockTools
|
||||
from src.util.config import load_config
|
||||
from src.harvester import Harvester
|
||||
from src.farmer import Farmer
|
||||
@ -24,25 +23,26 @@ from tests.make_test_constants import make_test_constants_with_genesis
|
||||
from tests.time_out_assert import time_out_assert
|
||||
|
||||
|
||||
bt = BlockTools()
|
||||
test_constants, bt = make_test_constants_with_genesis(
|
||||
{
|
||||
"DIFFICULTY_STARTING": 1,
|
||||
"DISCRIMINANT_SIZE_BITS": 8,
|
||||
"BLOCK_TIME_TARGET": 10,
|
||||
"DIFFICULTY_EPOCH": 12, # The number of blocks per epoch
|
||||
"DIFFICULTY_DELAY": 3, # EPOCH / WARP_FACTOR
|
||||
"PROPAGATION_THRESHOLD": 10,
|
||||
"PROPAGATION_DELAY_THRESHOLD": 20,
|
||||
"TX_PER_SEC": 1,
|
||||
"MEMPOOL_BLOCK_BUFFER": 10,
|
||||
"MIN_ITERS_STARTING": 50 * 1,
|
||||
"NUMBER_ZERO_BITS_CHALLENGE_SIG": 1,
|
||||
"CLVM_COST_RATIO_CONSTANT": 108,
|
||||
}
|
||||
)
|
||||
|
||||
global_config = load_config(bt.root_path, "config.yaml")
|
||||
self_hostname = global_config["self_hostname"]
|
||||
|
||||
test_constants = make_test_constants_with_genesis({
|
||||
"DIFFICULTY_STARTING": 1,
|
||||
"DISCRIMINANT_SIZE_BITS": 8,
|
||||
"BLOCK_TIME_TARGET": 10,
|
||||
"DIFFICULTY_EPOCH": 12, # The number of blocks per epoch
|
||||
"DIFFICULTY_DELAY": 3, # EPOCH / WARP_FACTOR
|
||||
"PROPAGATION_THRESHOLD": 10,
|
||||
"PROPAGATION_DELAY_THRESHOLD": 20,
|
||||
"TX_PER_SEC": 1,
|
||||
"MEMPOOL_BLOCK_BUFFER": 10,
|
||||
"MIN_ITERS_STARTING": 50 * 1,
|
||||
"CLVM_COST_RATIO_CONSTANT": 108,
|
||||
})
|
||||
|
||||
|
||||
def constants_for_dic(dic):
|
||||
return test_constants.replace(**dic)
|
||||
|
@ -8,8 +8,7 @@ from tests.make_test_constants import make_test_constants_with_genesis
|
||||
from tests.time_out_assert import time_out_assert, time_out_assert_custom_interval
|
||||
|
||||
|
||||
|
||||
test_constants = make_test_constants_with_genesis(
|
||||
test_constants, bt = make_test_constants_with_genesis(
|
||||
{
|
||||
"DIFFICULTY_STARTING": 500,
|
||||
"MIN_ITERS_STARTING": 500,
|
||||
|
Loading…
Reference in New Issue
Block a user