Commit Graph
53 Commits
Author SHA1 Message Date
Matt HauffandGitHub 40db4635a8 [LABS-245] Enable PEP604 Ruff rules (#20269)
* Enable PEP604 Ruff rules

* Fix harcoded signature in test

* Hack CLVMStreamable test with note to fast follow
2025-11-18 12:34:00 -08:00
Arvid NorbergandGitHub 5664516dda Bump chia rs 0.34.0 (#20226)
bump chia_rs to 0.34.0
2025-11-10 17:02:10 -07:00
arvidn 39764bb7c5 use log.exception() instead of log.error() and log.warning() when logging exceptions 2025-10-28 14:18:41 +01:00
Arvid NorbergandGitHub 4d2d27192e [CHIA-3659] ignore unreasonably small v2 plots (#19984)
just like we ignore unreasonably small v1 plots, ignore unreasonably small v2 plots
2025-08-26 11:21:37 -07:00
Arvid NorbergandGitHub 18fd65d13b pass along plot format version from ProverProtocol into ProofOfSpace (#19930)
pass along plot format version from ProverProtocol into ProofOfSpace objects
2025-08-14 12:31:07 -07:00
Almog De PazandGitHub 19a8329cbe Plotmanager v2 (#19832)
* prover protocol and v2Prover

* format name

* format

* refactor filename

* tests/raise unimplemented

* add get_filename_str to mock

* rename methods

* rename

* refactor

* improve coverage

* test from bytes
2025-07-30 11:05:52 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Earle LoweEarle LoweKyle Altendorf
d7e2358a32 build(deps): bump ruff from 0.8.5 to 0.9.6 (#19260)
* build(deps): bump ruff from 0.8.5 to 0.9.6

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.5 to 0.9.6.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/0.8.5...0.9.6)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update source to ruff 0.9.6

* Apply suggestions from code review

Co-authored-by: Kyle Altendorf <sda@fstab.net>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Earle Lowe <30607889+emlowe@users.noreply.github.com>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2025-02-27 09:53:34 -08:00
Arvid NorbergandGitHub 95c82997a3 name threads in ThreadPoolExecutor (#19250) 2025-02-11 06:27:01 -07:00
Matt HauffandGitHub 604fc1feb0 [CHIA-1732] Add Ruff specific linting rules (#18845)
* Add Ruff specific linting rules

* Further tighten ignore list

* Address comments by @altendky

* One more comment @altendky
2024-11-14 15:58:12 -07:00
Matt HauffandGitHub 73e4a5bbea [CHIA-1680] Finish replacing flake8 with Ruff (#18802)
* Apply ruff unsafe fixes

* Manually fix tuples with `as`

* Remove all references to flake8
2024-11-04 08:59:57 -07:00
Kyle AltendorfandGitHub 9c8557a1f8 Remove Python 3.8 support and update source to 3.9 standards (#18687)
* manual python 3.8 removals

* poetry

* pyupgrade

* black

* isort

* manually tidy imports

* work around shadowed type

* catch up build network protocol files for pyupgrade changes

* placate pylint

* re-enable 20.04

* placate flake8
2024-10-16 14:21:15 -07:00
Matt HauffandGitHub 3637bd33c6 Delete chia.util.misc (#18170)
* Move VersionedBlob to chia.util.streamable

* Move format_bytes to chia.cmds.cmds_util

* Move format_minutes to chia.cmds.cmds_util

* Move prompt_yes_no to chia.cmds.cmds_util

* Move get_list_or_len to from chia.plot_sync.receiver

* Move validate_directory_writable to chia.cmds.cmds_util

* Move *termination_signals to test_services

* Move UInt*Range to chia.util.streamable

* Create chia.util.batches

* Create chia.server.signal_handlers

* Create chia._tests.util.split_managers

* Move ValuedEvent to chia.types.transaction_queue_entry

* Move available_logical_cores to chia.util.cpu

* Move caller_file_and_line to chia._tests.util.misc

* Move satisfies_hint to chia._tests.wallet.test_singleton_lifecycle_fast
2024-06-18 08:27:17 -05:00
Arvid NorbergandGitHub 95e5b97557 Use bls from chia rs (#16715)
* replace blspy imports with chia_rs imports for BLS types

* remove blspy-stubs, since we're dropping the blspy dependency. chia_rs has type stubs already
2023-11-07 09:06:52 -08:00
0deb8e6dc6 Timeout for retrieving a decompressor. (#16047)
* Timeout for retrieving a decompressor.

* Pre-commit fix

* Use new chiapos

* Use chiapos 2.0.1

---------

Co-authored-by: wallentx <william.allentx@gmail.com>
2023-08-16 18:40:29 -05:00
Florin ChiricaandGitHub cbf971e7f5 Don't farm compressed plots if context count is 0 (#16004)
* Don't farm compressed plots if context count is 0

* Move checks outside cache.
2023-08-11 13:40:49 -05:00
Izumi HoshinoandGitHub 85d14f561a Added compression level and harvesting mode to harvester protocol/mes… (#15776)
* Added compression level and harvesting mode to harvester protocol/messages

* Added test

* Fixed lint error
2023-07-18 16:24:56 -05:00
f96690bdc5 Renaming instances of 'decompresser' to 'decompressor' (#15751)
* Renaming instances of 'decompresser' to 'decompressor'

* Making 'parallel_decompressors_count' singular

* Using chiapos version that has matching spelling

* Putting the clsp file back where I found it

* fix ver

---------

Co-authored-by: Jack Nelson <j.nelson@chia.net>
2023-07-13 09:59:51 -05:00
7b67fe0a4a compressed plot support (#15702)
* Compression branch.

* disable GPU farming in tests

---------

Co-authored-by: Florin Chirica <fchirica96@gmail.com>
2023-07-12 16:49:15 -05:00
dustinfaceandGitHub ebc5f3c124 util: Improve list_to_batches (#15415)
* Make `list_to_batches` work with collections instead of lists only

* Move `to_batches` into `chia.util.misc`

* Only support `set` and `list`

* Drop `tests.generator.test_to_batches` exclusion

* Improve type restrictions and be more coverage friendly in tests
2023-06-06 12:00:07 -05:00
Kyle AltendorfandGitHub 3a5c1a5bd5 hint chia.harvester.harvester, harvester_api (#14690)
* hint chia.harvester.harvester

* hint chia.harvester.harvester_api
2023-02-28 11:42:58 -06:00
Kyle AltendorfandGitHub 3b084a165b configure isort to add the future annotations import (#13327)
* configure isort to add the future annotations import

* apply the new isort setting

* remove type ignores for new mypy (#13539)

https://pypi.org/project/mypy/0.981/

* another
2022-09-30 03:40:22 -05:00
dustinfaceandGitHub ec059e9a4f harvester: Some log updates (#13508)
* Log the number of cache entries and the time it took to parse them

* Log `started` and `done` as `INFO` and `batch_processed` as `DEBUG`

* Log the plot found message with `DEBUG` level

* Some additional debug logs in `new_signage_point_harvester`
2022-09-29 14:53:06 -05:00
Kyle AltendorfandGitHub 4bcbcdbbe4 remove type ignores for new mypy (#13539)
https://pypi.org/project/mypy/0.981/
2022-09-26 16:54:19 -05:00
Kyle AltendorfandGitHub a9f7cce06b Skip plot_sync_callback if delta is None, hint Harvester.server (#11620)
* hint Harvester.server as Optional[ChiaServer]

* use a Protocol instead of Callable

* oh right, Optional
2022-05-24 13:21:14 -07:00
dustinfaceandGitHub d73fa27ea7 harvester: Sort plot_paths before splitting it into batches (#11508)
After changing `plot_paths` to be a set in #11204 the plots are loaded 
out of order. Sorting the list before splitting it to batches recovers 
the load order. 

Fixes #11499
2022-05-24 13:20:27 -07:00
dustinfaceandGitHub 7d11d54f89 plotting: Enable isort (#11135) 2022-04-21 17:00:00 -07:00
dustinfaceandGitHub 553e46ab6d harvester: Use a set instead of a list to speed up availability checks (#11204) 2022-04-20 11:43:31 -07:00
dustinfaceandGitHub 1e7703fe6a plotting|tests|setup: Improve PlotManager cache (#9903)
* plotting|tests: Extend the lifetime of plot data cache entries

* plotting|tests: Add `prover` and `farmer_public_key` to the cache

* plotting: Missing type hints in `Cache` and `CacheEntry`

* setup: Bump `chiapos` to 1.0.10

* plotting: Move cache classes into `chia.plotting.cache`

* plotting: Introduce `CacheEntry.from_disk_prover`

* Make `Cache` a dataclass

* `staticmethod` -> `classmethod`

* Store cache data as `bytes` in `DiskCache`
2022-04-20 11:08:35 -07:00
9ff3fc993f Ms.plot load perf2 (#10978)
* 2.7 seconds -> 0.45 seconds

* Merge

* Work on create_plots refactor

* Try to fix tests

* Try to fix tests

* Use new functions

* Fix block_tools by adding dir

* Extra argument

* Try to fix cyclic import

* isort

* Drop warning

* Some cleanups around `exclude_final_dir` and directory adding

* Cleanup `min_mainnet_k_size` checks

* Drop unrelated changes

* Fixes after rebase

* Fix cyclic import

* Update tests/block_tools.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* Update tests/block_tools.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: xdustinface <xdustinfacex@gmail.com>
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2022-04-11 09:16:01 -07:00
dustinfaceandGitHub a48fd43100 streamable: Simplify and force correct usage (#10509)
* streamable: Merge `strictdataclass` into `Streamable` class

* tests: Test not supported streamable types

* streamable: Reorder decorators

* streamable: Simplify streamable decorator and force correct usage/syntax

* streamable: Just move some stuff around in the file

* streamable: Improve syntax error messages

* mypy: Drop `type_checking.py` and `test_type_checking.py` from exclusion

* streamable: Use cached fields instead of `__annotations__`

This is now possible after merging `__post_init__` into `Streamable`

* Introduce `DefinitionError` as `StreamableError`

* `/t` -> `    `
2022-04-08 18:29:32 -07:00
ded9f68583 chia|tests|github: Implement, integrate and test plot sync protocol (#9695)
* protocols|server: Define new harvester plot refreshing protocol messages

* protocols: Bump `protocol_version` to `0.0.34`

* tests: Introduce `setup_farmer_multi_harvester`

Allows to run a test setup with 1 farmer and mutiple harvesters.

* plotting: Add an initial plot loading indication to `PlotManager`

* plotting|tests: Don't add removed duplicates to `total_result.removed`

`PlotRefreshResult.removed` should only contain plots that were loaded
properly before they were removed. It shouldn't contain e.g. removed
duplicates or invalid plots since those are synced in an extra sync step
and not as diff but as whole list every time.

* harvester: Reset `PlotManager` on shutdown

* plot_sync: Implement plot sync protocol

* farmer|harvester: Integrate and enable plot sync

* tests: Implement tests for the plot sync protocol

* farmer|tests: Drop obsolete harvester caching code

* setup: Add `chia.plot_sync` to packages

* plot_sync: Type hints in `DeltaType`

* plot_sync: Drop parameters in `super()` calls

* plot_sync: Introduce `send_response` helper in `Receiver._process`

* plot_sync: Add some parentheses

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* plot_sync: Additional hint for a `Receiver.process_path_list` parameter

* plot_sync: Force named parameters in `Receiver.process_path_list`

* test: Fix fixtures after rebase

* tests: Fix sorting after rebase

* tests: Return type hint for `plot_sync_setup`

* tests: Rename `WSChiaConnection` and move it in the outer scope

* tests|plot_sync: More type hints

* tests: Rework some delta tests

* tests: Drop a `range` and iterate over the list directly

* tests: Use the proper flags to overwrite

* test: More missing duplicates tests

* tests: Drop `ExpectedResult.reset`

* tests: Reduce some asserts

* tests: Add messages to some `assert False` statements

* tests: Introduce `ErrorSimulation` enum in `test_sync_simulated.py`

* tests: Use `secrects` instead of `Crypto.Random`

* Fixes after rebase

* Import from `typing_extensions` to support python 3.7

* Drop task name to support python 3.7

* Introduce `Sender.syncing`, `Sender.connected` and a log about the task

* Add `tests/plot_sync/config.py`

* Align the multi harvester fixture with what we do in other places

* Update the workflows

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-04-07 17:10:44 -07:00
dustinfaceandGitHub 0bf370c642 plotting: Only lock while actually accessing PlotManager.plots (#10675) 2022-03-11 16:23:01 -08:00
dustinfaceandGitHub eb0e3a2cc8 plotting: Add missing locks in PlotManager (#9708) 2022-02-01 10:02:43 -08:00
dustinfaceandGitHub eecc7cd1cd plotting: Move show_memo out of PlotManager (#9932)
This flag is only used by the `chia plots check` command.
2022-01-25 07:37:39 -08:00
dustinfaceandGitHub 2c4f4d78b3 plotting: Drop plot_removed and just check if the path is still there (#9879)
This saves a `Path.exists()` call for all plots for each refresh 
interval.
2022-01-20 07:48:01 -08:00
dustinfaceandGitHub 2ab146bf2d plotting|tests|github: Fix and test re-loading/removal of plots where we missed the keys (#9578)
* tests: Allow to use custom keys in `BlockTools.new_plot`

* tests: Create three plots with `G1Element()` as farmer/pool key

But not add them as default plots. Just to have plots in the test cache with different keys from
within and outside the keychain for plot loading tests.

create

* test|github: Bump `test-cache` version to `0.28.0`

* plotting: Drop plots from `no_key_filenames` after the keys appeared

* plotting: Drop plots from `no_key_filenames` if the plot was removed

* tests: Test loading of plots where we miss the keys

* plotting: Use `x.copy()` instead of `list(x)`

* plotting: Add a comment about the missing keys plot removal

* tests: Fix after #9595
2021-12-17 14:36:29 -08:00
dustinfaceandGitHub aabc54bb53 plotting|tests: Fix try/except in PlotManager._refresh_task (#9588)
* plotting: Fix try/except in `PlotManager._refresh_task`

* tests: Move the start refreshing call into `PlotRefreshTester` ctor

It being in `run()` before where it was called every test iteration lead
to not detecting an issue with the try/except introduced in #9409. See
ee1dd1912f4678d7b960b670473bd4b3ffbd890b for the fix.
2021-12-16 15:14:34 -08:00
dustinfaceandGitHub a68ffecea1 plotting|tests: Fix and test removal of invalid plots (#9587)
* plotting: Drop from `failed_to_open_filenames` if the plot was removed

* tests: Test removal from `failed_to_open_filenames`
2021-12-16 15:14:12 -08:00
dustinfaceandGitHub ad7b549cbd plotting|tests: Catch exceptions in the plot manager thread (#9409)
Without this the plot manager thread silently dies on exceptions and
refreshing just stops. This change leads to refreshing reset and a error
log on exceptions.
2021-12-07 09:57:24 -08:00
dustinfaceandGitHub 59b8be5f72 chia|tests: Pass the loaded/removed plots with PlotRefreshResult (#9306)
* chia|tests: Pass the loaded/removed plots with `PlotRefreshResult`

Instead of just the counts.

* plotting: Default to `False` for `expected_result_matched`

* tests: Validate the loaded/removed plots match the expectations
2021-12-06 07:53:26 -08:00
dustinfaceandGitHub a95dfba70b plotting|util|tests: Introduce chia.util.generator_tools.list_to_batches (#9304)
* plotting|util: Introduce `chia.util.generator_tools.list_to_batches`

* tests: Test `list_to_batches` in  `test_list_to_batches.py`

* util|tests: Return an empty iterator for empty input lists

* tests: Test list sizes from 1-10 in `test_valid`
2021-11-24 11:27:31 -08:00
dustinfaceandGitHub d9143063ff plotting: Reduce Path.exists calls (#8999)
* plotting: Move plot removals out of `PlotManager.refresh_batch`

Moving this checks up in the trace so that it only runs once for each
refresh cycle reduces `plot_removed` calls per cycle from `batch_count *
plot_count` to `plot_count` only. This checks can be quite expensive
depending on how/where the plots are stored so this should noticeably
improve refresh times in slow setups and large farms even for the
initial refresh cycle. I don't see any downside here considered that
even if a plot gets removed during a refresh cycle (after the checks
run) it will catch it in the next cycle.

**Note**: This has become an issue now (e.g. in #8972) because prior to
way, that it only really processed in batches for the very first run
after a restart. For each repeated refresh cycle it just walked through
all files in one `refresh_batch` call. Now after #8385 fixed this
behavior the checks are called `batch_count * plot_count` for all
refresh cycles, even for each repeated cycle where it was `plot_count`
before.

* plotting: Move `file_path.exists` call down 

There is no point in testing it before here, it only leads to redundant 
calls for repeated refresh cycles. The important point here is just that 
it runs after 

```
if file_path in self.plots:
    return self.plots[file_path]
```

so it could still be moved around differently if there are other 
suggestions, tell me. I even think it might be possible to just drop it 
with no bad impact but lets just move it for now.
2021-10-29 09:29:46 -07:00
dustinfaceandGitHub 7c1a72848c plotting|harvester|tests: Improve batch processing (#8385)
* plotting|harvester|tests: Improve batch processing

Let it only process `batch_size` files per `refresh_batch` call.

* plotting: Improve thread shutdown
2021-10-20 18:06:01 -07:00
Earle LoweandGitHub 8cabdc66bf Remove flaky mtime check for plots (#8590)
* Change logic for mtime mismatch to log but ignore

* Remove entirely flaky mtime check
2021-10-15 10:34:32 -07:00
dustinfaceandGitHub 71f2c68831 plotting: Fix log output for duplicated plots (#8812) 2021-10-15 09:39:50 -07:00
dustinfaceandGitHub 5fae0aae41 plotting|harvester|tests: Drop some parts of PlotRefreshResult (#8760)
* plotting|harvester|tests: Drop `loaded_size` from `PlotRefreshResult`

* rename: Drop `_plots` and `_files` suffixes in `PlotRefreshResult`

* plotting: Drop `PlotRefreshResult.__add__`

I introduced it but i don't really like it because its not a "real" add
any only works in one direction because of `remaining`.
2021-10-13 14:20:32 -07:00
dustinfaceandGitHub 653a11476c plotting|tests: Test duplicates in test_farmer_harvester_rpc.py (#8769)
* plotting: Introduce `PlotManager.get_duplicates`

* tests: Test duplicates in `test_farmer_harvester_rpc.py`
2021-10-12 09:07:18 -07:00
dustinfaceandGitHub ab9ae7e990 plotting: Some refactoring of PlotManager.refresh_batch.process_file (#8380)
* plotting: Refactor file exists check in `process_file`

* plotting: Refactor processing of the `ThreadPoolExecutor.map()` result

I might miss something but imo the use of `reduce` here just reduces
readability and has no value.

* plotting: Let `process_file` return `Optional[PlotInfo]`
2021-09-08 15:23:01 -07:00
dustinfaceandGitHub ba293f65c8 plotting: Drop some redundant code (#8308)
* plotting: Drop some redundant `None` checks

* plotting: Drop redundant `stat_info`
2021-09-07 18:18:17 -07:00
dustinfaceandGitHub fe6837218c plotting: Don't reload all plot paths for each batch, do it once upfront (#8368) 2021-09-07 16:29:09 -07:00