81 Commits
Author SHA1 Message Date
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Matt
67cdfcda41 build(deps): bump ruff from 0.15.21 to 0.16.0 (#21238)
* build(deps): bump ruff from 0.15.21 to 0.16.0

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.15.21 to 0.16.0.
- [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.15.21...0.16.0)

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

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

* affect changes

* Restrict formtting to chia/tools/benchmarks

* Fix generated protocol files

* more noqa

* network protocol files

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt <quexington@gmail.com>
2026-08-06 09:34:35 -07:00
Earle LoweandGitHub c32a4a7493 Add Python 3.14 support (#20195)
* First pass add 3.14

* Update bitarray

* Update markupsafe

* Update zstd

* Update tach to version with 3.14 support

* Changes for 3.14 related things

* Refactor shutdown handling in sync method

* Ignore unclosed database ResourceWarning

Added a new warning to ignore for unclosed database resources.

* Update pytest.ini to ignore additional warnings

* ignore resourcewarnings about tempdir cleanup

* Minor cleanup for tests running under python 3.14

* Reduce consensus tests for test_ban_for_mismatched_tx_cost_fee

* make sure to close RPC client at end of test

* different idea for TempFile

* oh, no cleanup function

* small fixes for tests detected by 3.14

* update pytest.ini

* ignore sqlite errors during closing in __del__

* add code to ignore deprecatewarnings for loop policy

* Pass in ClientSession to wschiaconnection for proper cleanup

* Some more resource cleanup

* Trying to find unclosed sessions

* One more time needing a close

* wait for harvesters to connect to the farmer

* properly teardown vdf_server using context manager

* Testing cleanup for simulator tests

* Add in a sleep to allow sockets time to cleanup

* Revert "Testing cleanup for simulator tests"

This reverts commit c5a4ef0cc3.

* Revert "properly teardown vdf_server using context manager"

This reverts commit 18b456a7b6.

* Revert "Revert "Testing cleanup for simulator tests""

This reverts commit 8c8efc2e03.

* vdf_server cleanup

* attempt 47 of timelord cleanup

* Some other cleanup fixes in tests

* yet another attempt at timelord shutdown

* Some more adjustments for 3.14

* ignore unclosed socket resource warnings

* some more adjustments and cleanup

* remove commented code

* correct poetry.lock file

* Address some review comments

* fix merge indentation

* fix install script print

* update requests

* fix problems with timelord tests on 3.14

* Make sure to close dummy session on any exception

* Use different cleanup pattern to help with flakes on Windows

* better shutdown handling

* hopefully better awaiting for cleanup

* yet more better timelord cleanup

* some test adjustments

* more time for cleanup
2026-05-13 09:32:01 -05:00
Patrick MaslanaandGitHub 0ac9ef7a52 Validate QR bit in DNS seeder to only process queries (#20553) 2026-02-23 23:53:51 -06:00
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
Richard KissandGitHub ec35492946 Api stubs (#19979)
* harvester_api_protocol

* move to apis

* Remove `chia.apis` => `chia.harvester` dependency.

* Remove circular dependencies between `chia.apis` and service modules.

* SolverAPIStub, and add solver to tach.toml.

* Make the stubs (lack of) implementations more consistent.

* Use `stub_metadata_for_type` instead of `class_for_type`.

The only thing ever used from `ApiProtocol` in `WSConnection`
was the metadata field, so let's pass along only that.

* NewSignagePointHarvester2

* remove some stuff
2025-11-12 09:06:12 -07:00
Matt HauffandGitHub a803dc0fa6 [CHIA-3633] August 2025 pass of Ruff linting rules (#19929)
* Enable Ruff `PLR1704` (`redefined-argument-from-local`)

* Enable Ruff `PLR5501` (`collapsible-else-if`)

* Enable Ruff `PLW2901` (`redefined-loop-name`)

* bad change

* Enable Ruff `RUF043` (`pytest-raises-ambiguous-pattern`)

* Enable Ruff `RUF046` (`unnecessary-cast-to-int`)

* Enable Ruff `RUF052` (`used-dummy-variable`)

* Remove unused ignore `UP006`

* One mis-signaled regex

* Comments by @altendky

* bad change, my bad
2025-08-11 14:39:12 -07:00
Richard KissandGitHub 4e6038ba3b Simplify dependencies wrt chia.server (#19895)
Remove some dependencies in `chia.server`.
2025-08-06 12:03:47 -07:00
Kyle AltendorfandGitHub 7a26610e8f less pre-inting for ints (#19853) 2025-07-23 13:18:04 -07:00
Kyle AltendorfandGitHub 32ca9c0804 by service not layer (#19715)
* by service not layer

* monkey patch fixup
2025-06-16 14:31:51 -07:00
6050235bdb [CHIA-3043] Add (hopefully) non-controversial ruff rules (#19684)
* Add (hopefully) non-controversial ruff rules

* mypy-exclusions.txt

* PIE

* Fix pre-commit?

* PYI

* RSE

* S + ignores

* Whitespace fix

* Re-add build-init-files.py

* Add comment about security ignores

* Update mypy-exclusions.txt

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

* Fix the executable status of build-init-files.py

* Set executable bit for tools/run_block.py and readd shebang

* Fix new errors

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2025-06-11 08:36:08 -07:00
Richard KissandGitHub a803d18c3b The chia.protocols module no longer depends upon chia.server. (#19636)
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->

The modules `chia.protocols` and `chia.server` form a dependency loop.
This change at least removes the direct dependency of `chia.protocols`
on `chia.server`.

### Purpose:

<!-- Does this PR introduce a breaking change? -->

### Current Behavior:

### New Behavior:

<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->

### Testing Notes:

<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
2025-05-29 09:24:29 -07:00
Kyle AltendorfandGitHub a90f04ff48 move chia.types.aliases to chia.server.aliases (#19535)
* move `chia.types.aliases` to `chia.server.aliases`

* touchup
2025-04-25 13:15:04 -05:00
Kyle AltendorfandGitHub e446d6b726 use chia_rs directly for sized ints (#19303)
* use chia_rs directly for sized ints

* Update data_layer_rpc_api.py
2025-02-24 14:33:09 -08:00
Kyle AltendorfandGitHub 30c4ef2689 use chia_rs directly for consensus constants (#19301) 2025-02-21 10:03:17 -08:00
Kyle AltendorfandGitHub 1ffa73e99e task referencer (#18914)
* put otherwise unheld tasks into the pit

* and the rest too

* cull less often

* task referencer

* private

* report unexpectedly unreferenced tasks

* also warn for automated catching in tests

* reporting task

* undo some

* fixup for 3.9

* ban asyncio.create_task

* oof

* simplify including using `Task.add_done_callback()` for culling
2025-01-02 10:13:51 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Earle Lowe
030392a68b build(deps): bump dnspython from 2.6.1 to 2.7.0 (#19017)
* build(deps): bump dnspython from 2.6.1 to 2.7.0

Bumps [dnspython](https://github.com/rthalley/dnspython) from 2.6.1 to 2.7.0.
- [Release notes](https://github.com/rthalley/dnspython/releases)
- [Changelog](https://github.com/rthalley/dnspython/blob/main/doc/whatsnew.rst)
- [Commits](https://github.com/rthalley/dnspython/compare/v2.6.1...v2.7.0)

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

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

* update seeder for mypy

---------

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>
2024-12-17 10:27:07 -07:00
Kyle AltendorfandGitHub e7d12c7cb1 add root_path parameter to initialize_service_logging() (#18961) 2024-12-03 14:32:34 -07:00
Kyle AltendorfandGitHub dd028574bb enable ruff flake8 async (#18899) 2024-11-20 09:00:14 -07:00
8d44c61913 Add support for a static list of peers to always have available in the dns_server (#18890)
* Add support for a static list of peers to always have available in the dns_server

* Add some tests

* Test the hostname to ip resolution for static dns server responses

* Sort imports

* Fix types/lint

* Fix test_db_processing flake

* remove unnecessary continue

* Ensure the parts that used to loop every 2 seconds when the DB is being populated for the first time still loop every 2s

* Update chia/seeder/dns_server.py

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>

* Remove redundant check for crawl store

---------

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2024-11-20 09:00:02 -07:00
Kyle AltendorfandGitHub 748c8cec8e # TODO: stop dropping tasks on the floor (#18866)
* # TODO: stop dropping tasks on the floor

* Update chia/_tests/core/data_layer/test_data_rpc.py

* no really, stop
2024-11-18 12:32:52 -07:00
Chris MarslenderandGitHub 817427c19f If 0 peers to crawl, sleep before trying to crawl again (#18882)
* If 0 peers to crawl, sleep before trying to crawl again

* Invert the logic to only have one place that we sleep
2024-11-18 12:15:36 -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
6c90a76b56 Tighten up ruff ignore list (#18837)
* Tighten up ruff ignore list

* Okay that fix was indeed unsafe

* enable type-name-incorrect-variance

* enable literal-membership

* enable non-augmented-assignment

* enable useless-return

* enable global-variable-not-assigned

* -

* fixup

* Clean up roff.toml from annotations

* use ignore instead of explicit re-export

* use more descriptive names

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2024-11-12 12:19:31 -07:00
ff3cf282c2 explicitly collect api methods instead of later using getattr (#18800)
* explicitly collect api methods instead of later using getattr

* api as a class itself

* tidy

* fixup

* tidier

* and...

* fixup

* oops

* mm

* hum

* fixup

* monkey patching helper

* ...

* tidy

* back to instances

* fix

* self-patch

* duplicate original request attributes

* Update chia/_tests/wallet/sync/test_wallet_sync.py

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>

* test that `@metadata.request()` fails on repeated request type

* ...

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2024-11-08 08:58:15 -07:00
4910323dbc Replace class_for_type function with a dict (#18773)
* Pass down `class_for_type` dict instead of global function.

* Simplify

* Update chia/apis.py

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

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2024-11-01 09:54:10 -07:00
Kyle AltendorfandGitHub 79ba87c32d explicitly check ApiProtocol classes (#18785) 2024-10-30 09:28:05 -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
Chris MarslenderandGitHub b14d912d3c Crawler Loop Fix + Test Improvements (#18329)
* Change a bunch of info logs back to warning in crawler, since crawlers are typically run in warning mode, to avoid the info log connection spam

* Ensure that the crawler loop ONLY doesn't start when in tests

* Rename the crawler service to crawler_service_no_loop, so defaults can also be tested WITH a loop

* Test crawler loop modes

* Add message when we received state chaged callback

* Add log to indicate crawling has started and how many peers we're crawling
2024-07-17 12:17:42 -07:00
Chris MarslenderandGitHub 8b01fdcfa8 Add prune old peers functionality for crawler (#18310)
* Add prune old peers functionality for crawler to keep the database size and write times under control

* Add test

* Make starting the crawler loop optional for tests. Test the pruning of old peers

* Fix lint issues
2024-07-16 08:19:09 -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
8eb41c59d7 bump chia_rs to 0.7.0 (#17909)
* bump chia_rs to 0.7.0 and transition using sized ints and sized bytes from chia_rs

* transition StructStream to use the version from chia_rs

* Initial port of ConsensusConstants to Rust

* Revert max cost calculation to use int for now

* Remove SizedBytes, since it was moved to chia_rs

* Remove test_struct_stream, since it was moved to chia_rs

* use [0] * 100 instead of bytes(100)

* restore wallet_rpc_api, and make type hints match JsonDict (Any)

* fixup ConsensusConstants; restore return value of calculate_prefix_bits()

* fixup ConsensusConstants; construct int for intermedate cost values

* fixup ConsensusConstants; construct int for intermedate cost values

* fixup: transition StructStream to use the version from chia_rs

* revert changing type annotations for json dict

---------

Co-authored-by: Rigidity <me@rigidnetwork.com>
2024-04-26 08:06:25 -07:00
Felix BruckerandGitHub d09b61b72d Pass full version in Handshake (#15679)
* Pass full version in Handshake

* Move chia version conversion into crawler

* Rename to overloaded `chia_short_version` and always return str

* Ensure we extract major.minor.patch from invalid pep440 if available
2024-03-27 10:40:47 -07:00
Earle LoweandGitHub 4e90ca2a12 turned concatenation of strings to f-strings (from eukub) (#17676)
turned concatenation of strings to f-strings
2024-03-15 09:17:40 -07:00
wjblankeandGitHub a5972b9b8b new_unfinished_block2 support in seeder (#17684)
new_unfinished_block2
2024-03-13 22:57:24 -05:00
Kyle AltendorfandGitHub 07004049aa add RPC API generic parameter to Service (#16973) 2023-12-05 13:30:56 -06:00
Kyle AltendorfandGitHub 65dfbbb6aa add Service type variables for each combination (#16970) 2023-11-30 13:38:38 -06:00
Kyle AltendorfandGitHub 9d5cbf3f24 crawler just manage (#16758) 2023-11-21 17:14:29 -06:00
Kyle AltendorfandGitHub fbdb27bef1 managers for services (#16670) 2023-11-16 19:21:12 -06:00
Kyle AltendorfandGitHub aaf081f69d explicit protocol checks against RpcServiceProtocol (#16710) 2023-10-27 12:03:15 -07:00
Chris MarslenderandGitHub 066140cb36 Swap some info logs in seeder to warning (#16703) 2023-10-26 19:59:04 -05:00
Kyle AltendorfandGitHub 90c1441af0 apply pyupgrade --py38-plus --keep-runtime-typing (#14646) 2023-10-24 12:01:23 -05:00
Kyle AltendorfandGitHub e9ac7ea610 apply uint*() more (#16287) 2023-09-13 10:48:06 -05:00
Kyle AltendorfandGitHub 353f12d5a3 commonize signal setup (#13568)
* commonize signal setup

* add signal setup for async handlers

* future

* Update misc.py

* catch up

* logging

* missed one

* context manager and waiting for signal handlers to complete

* correct logging

* fixup

* fixup
2023-09-06 13:01:11 -05:00
Kyle AltendorfandGitHub 538edfd6b8 Do not enable seeder signal handlers in tests (#16079) 2023-08-23 23:04:56 -05:00
33dd20e6be Fix Core Test Flake (#16055)
* upgrade and fix find avail listen port

cleanup names and logic

* Update chia/seeder/dns_server.py

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>

* rewrite db test

---------

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2023-08-16 18:39:42 -05:00
Jack NelsonandGitHub 0d36874caa Refactor Seeder & Crawler code + add tests (#15781)
* Cleanup seeder & mypy all files

holy crap mother of all tech debt this was horrid

* Make UDP Protocol class a dataclass & separate out functions.

* add TCP protocol class to DNS server

* Fix mypy types & other cleanup

also fix a couple bugs

* Add seeder and crawler tests

* change log levels

* re add db lock timeout

oops

* add edns & edns tests

* fix repeated shutdown on close signal

* fix binding to use both ipv6 and ipv4

whyyyyyyy

* add ipv6 and ipv4 tests + add ipv4 if windows
2023-08-11 05:25:19 -05:00
49140b2b3c server: Introduce ApiProtocol (#15466)
* server: Introduce `ApiProtocol`

* genericize (#5)

* `ApiProtocol.api_ready` -> `ApiProtocol.ready()`

* Add `ApiProtocol.log` and give APIs separate loggers

* Fix `CrawlerAPI`

* Drop some unrelated removals

* Fix some of the generic hinting

* Revert some changes in `timelord_api.py`

* Fix `CawlerAPI` readiness

* Fix hinting

* Get some `CrawlerAPI` coverage

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-06-13 20:12:25 -05:00
dustinfaceandGitHub d6a2a9aa5d seeder: Drop CrawlerAPI.__getattr__ (#15489)
* Test sending unknown messages to the crawler

* Drop `CrawlerAPI.__getattr__`

* Use a real crawler service for the test
2023-06-13 15:25:39 -05:00
dustinfaceandGitHub e7f8aa0827 seeder: Hint crawler_api.py (#15498) 2023-06-13 11:25:15 -05:00
dustinfaceandGitHub 1f8fc6410c util: Async DNS lookups (#14999)
* Rename `get_host_addr` to `resolve`

* Async DNS lookups in `resolve`

* Drop not needed `str` conversions
2023-04-28 13:37:28 -05:00