Commit Graph
33 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
Arvid NorbergandGitHub ece6de2af5 [CHIA-3795] change v1 plot phase-out (#20216)
* change v1 plot phase-out to not affect required iters, and to be quantized to epoch blocks

* disable hard-fork 2 tests until we have a new test cache

* fix rate limits test

* address review comments
2025-11-06 09:36:29 -07: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
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
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
Kyle AltendorfandGitHub b872728304 add another case to test_get_rate_limits_to_use() (#20004) 2025-09-09 09:05:26 -07:00
Amine KhaldiandGitHub cd792f5468 CHIA-3708 Annotate test_rate_limits.py (#20005)
Annotate test_rate_limits.py.
2025-09-03 13:49:53 -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
Richard KissandGitHub 4e6038ba3b Simplify dependencies wrt chia.server (#19895)
Remove some dependencies in `chia.server`.
2025-08-06 12:03:47 -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
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
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
Arvid NorbergandGitHub 45bac2e62d mypy annotation for test_dos.py (#19036)
* remove unused function, get_block_path()

* add type annotation to test_dos.py
2025-02-25 11:32:06 -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 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
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 dd028574bb enable ruff flake8 async (#18899) 2024-11-20 09:00:14 -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
Matt HauffandGitHub 2808ee2446 [CHIA-1681] Replace black with Ruff (#18813)
* Replace black with Ruff

* Change build_network_protocol_files.py
2024-11-04 15:22:18 -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
Matt HauffandGitHub 0e703e48e0 (Mostly) Replace flake8 with Ruff (#18801)
* Get flake8 config partially ready

* Mostly remove flake8 config

* Delete arithmetic whitespace ignore

* Delete unused program strings from tests

* Remove unnecessary noqas

* A couple more flake8 warnings
2024-11-01 09:55:16 -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
RigidityandGitHub 23e88632d5 New subscription and wallet sync protocol (#17340)
* New wallet sync protocol

* New updates to protocol and initial tests

* Bump new message ids

* Bump protocol version

* Update existing messages

* Implementation of TransactionAddedUpdate

* Improve unit tests

* Update protocol and tests to use previous height

* Testing tweaks

* Remove transaction subscriptions

* Update protocol tests

* Fix request_coin_state test

* Improve test suite, add min_amount, fix bugs

* Update protocol message serialization tests

* Resolve conflicting file

* Remove old hint store code

* Remove transaction added protocol type

* Make height optional for genesis challenge

* Test subscribe after initial state and dedupe ids in that case

* Forcing an empty commit.

* Fix new protocol tests

* Improve performance of clearing subscriptions

* Add more amounts to coin store test

* Lower max items for coin store test

* Fix test coverage, set lower max response items

* Remove add_puzzle_subscriptions and remove_puzzle_subscriptions from protocol

* Update protocol message list test

* Fix valid reply len

* Fix performance issue in query and add error codes

* Add missing message to regression tes

* Add rate limits

* Add test for hint store get_coin_ids_multi

* Increase max puzzle hash batch size and make it a constant

* Use actual params on to_bytes

* Fix test

* Actually check output of no puzzle hash coin state test
2024-03-29 12:56:20 -07:00
f200fcf16b Separate protocol versions (#17791)
* use separate protocol versions for the different services

* Validate protocol version on handshake

* simplify checking protocol version for incoming connections

---------

Co-authored-by: Harold Brenes <h.brenes@chia.net>
2024-03-29 07:40:06 -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
Kyle AltendorfandGitHub 172e28f728 correct testing of bans (#17753)
* correct testing of bans

* fixup

* again

* again (again)

* 🍌 ooh-ooh-aah-aah 🐒

* add back a test that banned host can not connect
2024-03-25 08:44:40 -07:00
Kyle AltendorfandGitHub a89222a428 move tests (#17209)
* prep

* verify source and installed tests match

* move

* remove move script
2024-03-14 10:19:20 -07:00