From 658d3562a99d55e4f2b58356e11d8d3f11ad86a1 Mon Sep 17 00:00:00 2001 From: William Blanke Date: Wed, 16 Oct 2024 18:12:37 -0700 Subject: [PATCH] fix bluebox --- chia/timelord/timelord.py | 20 ++++++++++++-- chia/util/vdf_prover.py | 1 + poetry.lock | 58 +++++++++++++++++++-------------------- pyproject.toml | 2 +- 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/chia/timelord/timelord.py b/chia/timelord/timelord.py index 462f4783ca8b..4fd5a6c126cc 100644 --- a/chia/timelord/timelord.py +++ b/chia/timelord/timelord.py @@ -7,12 +7,13 @@ import logging import os import random +import tempfile import time import traceback from collections.abc import AsyncIterator from concurrent.futures import ThreadPoolExecutor from pathlib import Path -from typing import TYPE_CHECKING, Any, ClassVar, Optional, cast +from typing import IO, TYPE_CHECKING, Any, ClassVar, Optional, cast from chiavdf import create_discriminant, prove @@ -53,7 +54,7 @@ class BlueboxProcessData(Streamable): iters: uint64 -def prove_bluebox_slow(payload: bytes) -> bytes: +def prove_bluebox_slow(payload: bytes, executor_shutdown_tempfile_name: str) -> bytes: bluebox_process_data = BlueboxProcessData.from_bytes(payload) initial_el = b"\x08" + (b"\x00" * 99) return cast( @@ -63,10 +64,15 @@ def prove_bluebox_slow(payload: bytes) -> bytes: initial_el, bluebox_process_data.size_bits, bluebox_process_data.iters, + executor_shutdown_tempfile_name, ), ) +def _create_shutdown_file() -> IO[bytes]: + return tempfile.NamedTemporaryFile(prefix="chia_timelord_executor_shutdown_trigger") + + class Timelord: if TYPE_CHECKING: from chia.rpc.rpc_server import RpcServiceProtocol @@ -138,6 +144,7 @@ def __init__(self, root_path: Path, config: dict[str, Any], constants: Consensus self.pending_bluebox_info: list[tuple[float, timelord_protocol.RequestCompactProofOfTime]] = [] self.last_active_time = time.time() self.max_allowed_inactivity_time = 60 + self._executor_shutdown_tempfile: Optional[IO[bytes]] = None self.bluebox_pool: Optional[ThreadPoolExecutor] = None @contextlib.asynccontextmanager @@ -156,6 +163,7 @@ async def manage(self) -> AsyncIterator[None]: if os.name == "nt" or slow_bluebox: # `vdf_client` doesn't build on windows, use `prove()` from chiavdf. workers = self.config.get("slow_bluebox_process_count", 1) + self._executor_shutdown_tempfile = _create_shutdown_file() self.bluebox_pool = ThreadPoolExecutor( max_workers=workers, ) @@ -169,6 +177,8 @@ async def manage(self) -> AsyncIterator[None]: yield finally: self._shut_down = True + if self._executor_shutdown_tempfile is not None: + self._executor_shutdown_tempfile.close() for task in self.process_communication_tasks: task.cancel() if self.main_loop is not None: @@ -1168,6 +1178,7 @@ async def _manage_discriminant_queue_sanitizer_slow(self, pool: ThreadPoolExecut pool, prove_bluebox_slow, bytes(bluebox_process_data), + "" if self._executor_shutdown_tempfile is None else self._executor_shutdown_tempfile.name, ) t2 = time.time() delta = t2 - t1 @@ -1175,6 +1186,11 @@ async def _manage_discriminant_queue_sanitizer_slow(self, pool: ThreadPoolExecut ips = picked_info.new_proof_of_time.number_of_iterations / delta else: ips = 0 + + if len(proof) == 0: + log.info(f"Empty VDF proof returned: {picked_info.height}. Time: {delta}s. IPS: {ips}.") + return + log.info(f"Finished compact proof: {picked_info.height}. Time: {delta}s. IPS: {ips}.") output = proof[:100] proof_part = proof[100:200] diff --git a/chia/util/vdf_prover.py b/chia/util/vdf_prover.py index 3086733115ce..2ac23cf675af 100644 --- a/chia/util/vdf_prover.py +++ b/chia/util/vdf_prover.py @@ -22,6 +22,7 @@ def get_vdf_info_and_proof( vdf_input.data, constants.DISCRIMINANT_SIZE_BITS, number_iters, + "", ) output = ClassgroupElement.create(result[:form_size]) diff --git a/poetry.lock b/poetry.lock index a9c98fc50c84..9eece0490bb0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "aiofiles" @@ -930,37 +930,37 @@ files = [ [[package]] name = "chiavdf" -version = "1.1.6" +version = "1.1.8" description = "Chia vdf verification (wraps C++)" optional = false python-versions = ">=3.8" files = [ - {file = "chiavdf-1.1.6-cp310-cp310-macosx_13_0_arm64.whl", hash = "sha256:0e7c7a0032d14ef11ed12bb6144437d4057d1c2ce435e1da7165659422e8e486"}, - {file = "chiavdf-1.1.6-cp310-cp310-macosx_13_0_x86_64.whl", hash = "sha256:728fe9fa328e134f9b08c46d4e535e6d24e55a0fbbf98c1008a32d63b22e1a3b"}, - {file = "chiavdf-1.1.6-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:34b682795f5c1348cf6b95fb60acf69649a7bd9fac8b890c9cecff8654798f36"}, - {file = "chiavdf-1.1.6-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:89eb391a43ee804bf410a76748d5a725fdb18989e17e9dffec4de5f57413c0f4"}, - {file = "chiavdf-1.1.6-cp310-cp310-win_amd64.whl", hash = "sha256:ca57ceb1e0410bcde5d7b6fdcfa1d9a5b05fb0c6e6d78d6a6cc6df6518eb6e09"}, - {file = "chiavdf-1.1.6-cp311-cp311-macosx_13_0_arm64.whl", hash = "sha256:a1b109417191071590f36268bd8f7c633b708f023dfe52372756ee3ef9f2466a"}, - {file = "chiavdf-1.1.6-cp311-cp311-macosx_13_0_x86_64.whl", hash = "sha256:c7766e94c84fae64b95e4af16c63a9a44a3e9ba382f896ff268048e40be8f9f6"}, - {file = "chiavdf-1.1.6-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:8ac0719cd64b22895121fdbc5a3497ce96ef7e5ba88b0d57c4a6146114a80c11"}, - {file = "chiavdf-1.1.6-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:b3b3fd2631b3e3b795b14d1d6143bad6aa73ca6f8cd67824da551a9a8ba95435"}, - {file = "chiavdf-1.1.6-cp311-cp311-win_amd64.whl", hash = "sha256:c517489d01b7fe775f7230aebea57cfdd2257300b5855c27fb39b5818f912138"}, - {file = "chiavdf-1.1.6-cp312-cp312-macosx_13_0_arm64.whl", hash = "sha256:3f0c662d45aa99a1121ac4b79588f328bdd88fe9739d06785a5a18454bb16388"}, - {file = "chiavdf-1.1.6-cp312-cp312-macosx_13_0_x86_64.whl", hash = "sha256:523125900b3909aeaeca11e4fe3406316f1f7b00f5323f60035bdece7c27d247"}, - {file = "chiavdf-1.1.6-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:481457538da7f71e46f7823e1f092a4768cf379e06d2b29e0e2fa167045b5ce6"}, - {file = "chiavdf-1.1.6-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:0a4ec91e53729c966f6fb43c63e3355dc585dd9c00d020176d214f86afa0af87"}, - {file = "chiavdf-1.1.6-cp312-cp312-win_amd64.whl", hash = "sha256:2db5542a7e11af42a03c63709e1e71ac119b25f694cae640e450369deee32003"}, - {file = "chiavdf-1.1.6-cp38-cp38-macosx_13_0_arm64.whl", hash = "sha256:d30c6ef55d8bbccda0fc96fdca295acb47673fb729287e58691c5da2248ce264"}, - {file = "chiavdf-1.1.6-cp38-cp38-macosx_13_0_x86_64.whl", hash = "sha256:978311d09e07bbd0c807fd8dee8d243a01b8f9b6bebe909b5a33a75a6e6fd244"}, - {file = "chiavdf-1.1.6-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:de4d4e5123724b23259bb3fbc9d89e8e225e129e518b3325446b994624bfd880"}, - {file = "chiavdf-1.1.6-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:9f32049e97b407bc5e7e2536c91589026272a4c608fb0f22dd4e8e982fa740c8"}, - {file = "chiavdf-1.1.6-cp38-cp38-win_amd64.whl", hash = "sha256:88a752a9f3b4cc7cfec517af0b74eee15581474d6f27c4f21cd468ba1a29878d"}, - {file = "chiavdf-1.1.6-cp39-cp39-macosx_13_0_arm64.whl", hash = "sha256:9b7f6cd025cc71128f0a467d07eb1ea0b76a074892a50ae76c2094fc8deb93d4"}, - {file = "chiavdf-1.1.6-cp39-cp39-macosx_13_0_x86_64.whl", hash = "sha256:cbdd824114d28e4c0c17ba1e14492b04f440b7cf6697ad582d541b9f7e01e79b"}, - {file = "chiavdf-1.1.6-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:183f8380170ac749d2b479172394118d2536b0a4d02ef56c0e630d22d545e7a3"}, - {file = "chiavdf-1.1.6-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:612518b22da3339d2a1f42711d53d4f0353c21aad1683ad8b86c5ef0e2e49871"}, - {file = "chiavdf-1.1.6-cp39-cp39-win_amd64.whl", hash = "sha256:5cc41e58f751ed156f475905d8d4415e6f8285ce3ee64127496325ea62af20c2"}, - {file = "chiavdf-1.1.6.tar.gz", hash = "sha256:bf32ad4f114db49c9839ff18b7fc704582e162923780751420838830cd92bac6"}, + {file = "chiavdf-1.1.8-cp310-cp310-macosx_13_0_arm64.whl", hash = "sha256:9cff805d701dacb5c0a715e64b6cc83b547c7d0b4b30ad2387d72949714c7084"}, + {file = "chiavdf-1.1.8-cp310-cp310-macosx_13_0_x86_64.whl", hash = "sha256:5661249abe84b89c3f6897e56230e13aaf4ff52497289daca391d48fe5a40fa3"}, + {file = "chiavdf-1.1.8-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:5b89e98bd0417675dfb447deafe02ff3dcd9c756bb3d6e5627a4cae5698fcdc1"}, + {file = "chiavdf-1.1.8-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:d470e8a4ace49fcdb44bc90bd1b137dcbcbdc983154105725f760306295b1089"}, + {file = "chiavdf-1.1.8-cp310-cp310-win_amd64.whl", hash = "sha256:bb04bc702bab305f5b9c4e4769ae4e9f2c424733c88ff3e455f806d663698a6c"}, + {file = "chiavdf-1.1.8-cp311-cp311-macosx_13_0_arm64.whl", hash = "sha256:d12cd8c6e1bd30711aafa9a08cef2841c819821ae833a1bb56ccce16852f2992"}, + {file = "chiavdf-1.1.8-cp311-cp311-macosx_13_0_x86_64.whl", hash = "sha256:c109871a72c4110ae7257f68e1d71b9b64bd4bd296a0d10aa9370883aefaa79e"}, + {file = "chiavdf-1.1.8-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:dc37331ca8facfd994522fe47a4e17f96d3a0eead13d5ccb4564c06362bed3ef"}, + {file = "chiavdf-1.1.8-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:76c616dd2d1fc7d3edc81eeefb304b63e74b3d19187e422351af2ca88cf719ad"}, + {file = "chiavdf-1.1.8-cp311-cp311-win_amd64.whl", hash = "sha256:da4b65abd16fb49aeca7fb49fd5f3eb7b307419af80ac675e59eff0d9343a6a2"}, + {file = "chiavdf-1.1.8-cp312-cp312-macosx_13_0_arm64.whl", hash = "sha256:b589e0cd6b4746bcb698ca4247565c1a918fef9a6186d4db8adc17f9470e683a"}, + {file = "chiavdf-1.1.8-cp312-cp312-macosx_13_0_x86_64.whl", hash = "sha256:7027eea1f45a5ededfbcc472e2592e4730de60e8191b6c8661acc8a8bfeba9ed"}, + {file = "chiavdf-1.1.8-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:553251b254fdf5e174a494383102e9c4f894cfeabe46d0197107f3674c182a6a"}, + {file = "chiavdf-1.1.8-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:af6a1b6f491d76f305badf8cef6c3bfe70853198b2ce29f1a643e81f64615d75"}, + {file = "chiavdf-1.1.8-cp312-cp312-win_amd64.whl", hash = "sha256:362b7633e46001857733706431002cfefe0bcc402f2cf0c913d1a6e6fb691aca"}, + {file = "chiavdf-1.1.8-cp38-cp38-macosx_13_0_arm64.whl", hash = "sha256:c258c0ee6298494bf03ccfb7b992191e2cf210c247eace66ca6792d6cf73ead8"}, + {file = "chiavdf-1.1.8-cp38-cp38-macosx_13_0_x86_64.whl", hash = "sha256:366ea2ad88ba96eadc62b4aa7be1a6925f832ad2da3b366e52757f0a66b78424"}, + {file = "chiavdf-1.1.8-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:4efae12d61bd8efaa5f6c062c3373bd5617236f4e8347732228b4281284f61c9"}, + {file = "chiavdf-1.1.8-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:585ed4e00deb2f5e16aff10b37e08fd23117423cac0bd12eb9e35e787aaea744"}, + {file = "chiavdf-1.1.8-cp38-cp38-win_amd64.whl", hash = "sha256:13258a8828c4169d800dd13946e7ec7748954fb557d5bac7bad84642e900d144"}, + {file = "chiavdf-1.1.8-cp39-cp39-macosx_13_0_arm64.whl", hash = "sha256:a7c2631edc1836c579b88e600cdd930ae9d2cc0bb02c368a0818d1bc9e571d59"}, + {file = "chiavdf-1.1.8-cp39-cp39-macosx_13_0_x86_64.whl", hash = "sha256:65bf866200d899b5843bd0a5fe0d63acb6f33075d151fa0d82c202c012b5482d"}, + {file = "chiavdf-1.1.8-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:b7d405428c429666bead8e27e563a95f0d3020a10c7ee2f3641ef61da3463405"}, + {file = "chiavdf-1.1.8-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:76ca77f7cbca2f53d0d8f42531df7dfce1aa01235e5e278b102693d5e2dda39e"}, + {file = "chiavdf-1.1.8-cp39-cp39-win_amd64.whl", hash = "sha256:af76c53e6819dfb9d00388111e074fbc8ce0fa408d4dd9cafcd444adb7962cdf"}, + {file = "chiavdf-1.1.8.tar.gz", hash = "sha256:e4c6904953d44b6097cbdce1621821c5eba1c47ad120c6ffbbc24c5815eff33f"}, ] [[package]] @@ -3438,4 +3438,4 @@ upnp = ["miniupnpc"] [metadata] lock-version = "2.0" python-versions = ">=3.9, <3.13" -content-hash = "f5fa932e4e2facb84efb24d244d477db40be0eb4307378f3bea7355c5ccbb2e0" +content-hash = "db54f56de18ee245440aea61e7a96bdbc73190327b1dbd69f7569ff57abd0cc0" diff --git a/pyproject.toml b/pyproject.toml index f8e80ab793f4..da1dec873351 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ boto3 = "1.34.143" # AWS S3 for Data Layer S3 plugin chiabip158 = "1.5.1" # bip158-style wallet filters chiapos = "2.0.4" # proof of space chia_rs = "0.15.0" -chiavdf = "1.1.6" # timelord and vdf verification +chiavdf = "1.1.8" # timelord and vdf verification click = "8.1.7" # For the CLI clvm = "0.9.10" clvm_tools = "0.4.9" # Currying Program.to other conveniences