Commit Graph
425 Commits
Author SHA1 Message Date
Earle LoweandGitHub 3461286e8d Eliminate rate limits and bans for exempt peer networks (#20345)
* Eliminate rate limits and bans for exempt peer networks

* Add some tests for banning when closing connections

* make sure to pass in parameter to constructor
2025-12-15 09:46:40 -08: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 fcdb8e4925 Manual fixes for upcoming Ruff pyupgrade push (#20213)
* Manual fixes

* Revert back to variable in type expression

* Fix streamable to handle UnionType
2025-11-03 09:16:42 -07:00
Amine Khaldi bae4615a57 Make sure the fee and cost specified in a NewTransaction match the ones from validating its spend bundle. 2025-10-29 11:47:25 +01:00
e8f5a17888 python 3.13 support (#19123)
* python 3.13 support

* some more

* 3.13 for dep checks

* more 3.13  *confused*

* fixup

* fixup

* update expected signature in 3.13

* fixup _attach/_detach hinting and testing

* ban freethreading

* Fix trailing comma in list

* replace legacy kw_only_dataclass decorator

* Adjust check for python version

* Remove debugging output

* Use reruns for 3.13+Windows flakes only

* re-lock poetry

---------

Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Matt Hauff <quexington@gmail.com>
2025-10-23 15:41:26 -05:00
Earle LoweandGitHub e57358aea6 CHIA-2102 - Set minimum to TLSv1.3 (#19079)
* Set minimum to TLSv1.3

* Update daemon specific option

* Remove deprecation warning
2025-10-22 11:47:41 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Matt
32b60dbf14 build(deps): bump ruff from 0.12.11 to 0.14.0 (#20137)
* build(deps): bump ruff from 0.12.11 to 0.14.0

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.12.11 to 0.14.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.12.11...0.14.0)

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

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

* Add some ignores and fix some errors

---------

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>
2025-10-15 15:16:15 -07:00
Almog De PazandGitHub 6bd9360f5e Farmer solver networking (#20019)
* farmer connects to solver

* default solver peer

* configure solver peer

* solver trusted peers

* minor fixes

* connect to solver cli

* fix and rename fixture

* pr fixes

* load new service config if missing

* fix failling test

* fix test
2025-09-29 09:39:10 -07:00
Arvid NorbergandGitHub 73cb54789b [CHIA-3712] simplify add_transaction() (#20063)
* simpliy add_transaction() and replace literals with the CONSENSUS_ERROR_BAN_SECONDS constant

* fix tests and review comments

* review comments
2025-09-16 10:15:37 -07:00
Arvid NorbergandGitHub c1d15dfda3 Simplify rate limit numbers (#19991)
* remove unused default_settings in rate limits

* simplify rate_limit_numbers by flattening the structure. just map message type -> rate limits

* review comments
2025-09-11 08:54:17 -07:00
Arvid NorbergandGitHub 29c25fb188 Rate limits cleanup (#19990)
* use monotonic clock in rate limiter

* rename minute -> slot in rate limiter, as the length is a parameter

* mock timer in rate limit test to make them deterministic

* remove unnecessary pytest class

* improve comment in rate_limit_numbers

* fix minor typos in rate_limits.py

* replace test_too_many_messages() with a parametrized test for (almost) all rate-limit cases

* review comments: give better names to test parameters

* review comments

* review comments

* review comments

* review comments
2025-09-02 12:13:04 -07:00
52cd1086a7 [CHIA-3593] New solver service (#19938)
* add solver service

* lint

* wire service evrywhear

* 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

* harvester and farmer v2 support

* solver service, api, rpc

* clenup, add config to tests

* pre-commit

* remove mocks from test

* aync solver, fixtures, tests

* naming

* remove redundant farmer message

* solver fixtures and tests

* change quality_string to quality_chain

* fix service tests, cleanup

* name change, fix comments

* lint

* rename to partial proof

* network protocol test, use ThreadPoolExecutor

* naming and types

* check filter for both plot versions

* update network protocol tests

* more pr comments addressed

* fix rename

* fix network formatting error

* change to Assertion errors

* add todo

* remove strength from SolverInfo

* more pr comments, fix test to catch assertion

* revert strength

* test and comments

* rename to partial proof

---------

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2025-08-22 15:26:09 -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
Arvid NorbergandGitHub 37d0a3c724 update testnet overrides in wallet (#19796) 2025-07-09 20:49:10 -05:00
Arvid NorbergandGitHub 9ab42fb4d2 update constant testnet overrides for timelord (#19783) 2025-07-07 09:14:25 -07:00
Arvid NorbergandGitHub 9d8c170b1a Fix plot size override (#19771)
* fix testnet11 plot size override as the constant has changed name

* correct overrides when starting the harvester as well

* update
2025-06-27 11:29:07 -07:00
Kyle AltendorfandGitHub 6e7fcf38d7 drop universal mypy ignore missing imports (#19750)
* drop universal mypy ignore missing imports

* delete nor comment out

* ignore our use of the private `_overlapped`

* type...

* on same line. go me
2025-06-25 09:46:40 -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
Kyle AltendorfandGitHub f054d339a1 unignore some ruff s rules (#19703) 2025-06-12 11:12:54 -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
Richard KissandGitHub e4ccb8024f Fix chia.util <= chia.server dependency (#19629)
Move `get_unresolved_peer_infos` and `set_peer_info` from
`chia.util.config` to `chia.server.resolve_peer_info.py` so that
`chia.util` no longer depends upon `chia.server`.
2025-05-23 09:06:11 -05:00
Richard KissandGitHub 20a0d934cb Move ssl_check.py to chia/ssl (#19596) 2025-05-12 08:53:18 -04:00
matt-o-howandGitHub 8f0e8e4b0b Improve the serialisation of AddressManager (#19467)
<!-- 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?) -->

### Purpose:
This PR is an optimisation for the way that AddressManager and
ExtendedPeerInfo are serialized, which happens periodically in a task
called from node_discovery.py

As well as the format of the serialization, the serialization algorithm
itself has had a multitude of speedups, including removing redundant
loops, minimising allocations, and so on.

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

### Current Behavior:

Previously we were serialising ExtendedPeerInfo as a string and
AddressManager as an `@streamable` `.to_bytes()`.
Copying all the data to this class was taking a deal of time.

The serialising function also had a lot of complicated pieces of
redundant code, looping over data multiple times when 1 pass might do.

### New Behavior:

This PR instead serialises AddressManager directly using a bytearray,
and refactors the code to reduce the complexity and number of loops.

More comments have been added in this area of the codebase as well.

### Testing Notes:

This PR includes a new benchmark file for the AddressManager's
serialisation.
Here are my personal results comparing this PR with `main`:

On main: `Average serialize time:   1.544302 seconds`
Sum of my optimisations: `Average serialize time:   0.468669 seconds`

Feel free to run `benchmarks/address_manager_store.py` to see for
yourself.

I have also added in a migration test in
`chia/_tests/core/full_node/test_address_manager.py` which creates an
old serialisation, loads it using the current loading code, then
serialises it using the new serialization, and then loads that.
It is also checked at each step along the way to ensure that the
serialisation has remained good.
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
2025-05-06 11:23:30 -05: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
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Earle Lowe
31a8715919 build(deps): bump ruff from 0.9.6 to 0.11.4 (#19482)
* build(deps): bump ruff from 0.9.6 to 0.11.4

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

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

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

* ruff fixes

* ruff fixes

* ruff fixes

* Address review suggestions

---------

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>
2025-04-14 16:09:07 -05:00
Arvid NorbergandGitHub 07b50763ca remove unused function on AddressManager (#19471) 2025-04-07 13:17:14 -07:00
07ccc77676 Add ContextManager to FullNodePeers (#19427)
* convert AddressManager to dataclass

* type annotations for default factory code

* convert FullNodePeers and FullNodeDiscovery into dataclasses

* make WalletPeers also a dataclass

* typing fixes

* fix type parameters for generic type "Queue"

* context manage FullNodePeers

* Update chia/full_node/full_node.py

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

* remove init=false

* add coverage for node_discovery

* refactor full_node_peers entering context

* clear() uses same code as init() for matrices

* Update chia/server/address_manager.py

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

* Add functools import to address_manager.py

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2025-04-04 11:34:59 -05:00
Florin ChiricaandGitHub 3a1f70a9b4 Add fallback for introducer. (#19333)
* Add fallback for introducer.

* Lint.

* Lint.

* Lint.

* Fix test.

* Add test.

* Lint.:
2025-03-07 08:10:27 -08:00
Kyle AltendorfandGitHub d50b6e0883 use chia_rs directly for sized bytes (#19326) 2025-02-28 09:35:25 -08: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
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
RigidityandGitHub 8f484e6bc9 Name wallet protocol subscription messages consistently (#19132)
* Name wallet protocol subscription messages consistently

* fix changelog

* fix name in full_node_api

* missed a spot
2025-01-14 10:12:09 -07: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
Arvid NorbergandGitHub c4e714eeab [CHIA-1829] don't drop outgoing response messages (#18990)
never rate limit outgoing response messages (RespondBlock, RespondBlocks, RejectBlock, RejectBlocks). Instead, disconnect any peer sending unsolicited response blocks
2024-12-11 09:09:09 -07:00
Kyle AltendorfandGitHub e7d12c7cb1 add root_path parameter to initialize_service_logging() (#18961) 2024-12-03 14:32:34 -07:00
Kyle AltendorfandGitHub d1596d4386 enable flake8-tidy-imports (#18913) 2024-11-21 14:57:15 -07:00
Arvid NorbergandGitHub e17e65707d improve logging of rate limits (#18907)
* improve logging of rate limits

* fix rate limiting of logs
2024-11-21 14:56:59 -07:00
Kyle AltendorfandGitHub 29da4a3b57 put None at the end in Unions - incoming RUF036 (#18905) 2024-11-21 14:56:39 -07:00
Kyle AltendorfandGitHub dd028574bb enable ruff flake8 async (#18899) 2024-11-20 09:00:14 -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
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
Kyle AltendorfandGitHub f5235c2b5e add /get_log_level, /reset_log_level, and /set_log_level to all rpcs (#18843)
* add `/get_log_level` and `/set_log_level` to all rpcs

* tidy

* for py <3.11

* fixup

* add tests

* a few no covers

* add `RpcClient.reset_log_level()`

* tidy

* fixup
2024-11-14 15:57:18 -07:00
Kyle AltendorfandGitHub ed74439d73 check network errors and their .__cause__ for expected error types (#18849) 2024-11-14 08:15:56 -07:00
thesemaphoreslimandGitHub 075adb251e Logging changes for feeler connections (#18784)
* Check if connections are classified as feelers and log connection successes/failures to debug level only. Continue logging warnings/errors as before, just specify if they are associated with feeler connections.

* Reformatted for CI

* Flake8 formatting

* Simplified logging into one-liners where possible.
2024-11-13 09:08:08 -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