Commit Graph
97 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
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 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 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 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 ed74439d73 check network errors and their .__cause__ for expected error types (#18849) 2024-11-14 08:15:56 -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 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
wjblankeandGitHub 74536ba781 CHIA-1568: fix object has no attribute code errors (#18665)
* fix object has no attribute code errors

* fix
2024-10-04 09:00:29 -07:00
Arvid NorbergandGitHub 23288e78b9 only print warnings about protocol mismatches for farmer and harvester (#17801)
only print warnings about protocol mismatches for farmer and harvester. In the future, maybe this should also include trusted wallets
2024-03-29 16:06:05 -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 6b42878ca2 update to aiohttp 3.9.2 (#17726)
* update to aiohttp 3.9.2

* 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 11:58:16 -07:00
Earle LoweandGitHub 48e4039e58 Update black to 24.1.1 and update source as needed (#17499)
* Update source to black 24 spec

* update black to 24.1.1

* update pylint to ignore multiple-statements

* update test file

* black updates

* format updates

* Update test_network_protocol_files.py

* Update test_network_protocol_files.py
2024-03-13 11:08:19 -07:00
RigidityandGitHub 41047bddc8 Async connection close handlers (#17017) 2023-12-11 08:27:25 -06:00
88e2761a5c merge listen into advertised_port as None (#15024)
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2023-10-03 20:24:04 -05:00
Arvid NorbergandGitHub 540747fae1 ban peers for 10 minutes when violating consensus rules (#16323) 2023-09-14 14:08:18 -05:00
Kyle AltendorfandGitHub cd9d6eff33 add SizedBytes.random()/.secret(), replace token_bytes() usage (#16276) 2023-09-14 14:08:01 -05:00
dustinfaceandGitHub 350534bf4f server: Drop unused send messages (#16215)
* Drop unused `WSChiaConnection.send_messages`

* Drop unused `WSChiaConnection.send_to_others`
2023-09-05 08:46:51 -05:00
Arvid NorbergandGitHub ec9d0096f4 demote log level for TIMESTAMP_TOO_FAR_IN_FUTURE errors (#16101) 2023-08-29 13:46:57 -05:00
dustinfaceandGitHub ede354c58f protocols: Introduce error protocol message (#15493)
* protocols: Introduce `error` protocol message

* Add `Optional` extra data `Error.data`

* Test `Err` entries
2023-07-13 13:46:20 -05:00
dustinfaceandGitHub d1d3522629 server: Store Handshake.software_version in connections as str (#15725) 2023-07-10 11:53:43 -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 bb5b3ccf6f server: Drop unused WSChiaConnection.active (#15464) 2023-06-09 05:12:54 -05:00
dustinfaceandGitHub d23ea4df38 server: Fix versions for incoming connections (#15465) 2023-06-07 14:07:56 -05:00
dustinfaceandGitHub 1777ecc2e8 server: Store Version objects instead of str in WSChiaConnection (#15330)
* server: Store `Version` objects instead of `str` in `WSChiaConnection`

* Test connection versions
2023-05-19 13:45:00 -05:00
dustinfaceandGitHub b90d91d46b server: Don't pass the host to WSChiaConnection (#14152)
Use the one from the connection data like we do it with the port. The
result there is slightly different since its resolved so `localhost`
becomes an IP in `peer_info` but i anyway will open a PR soon to
transition from `str` to `IPAddress` in there.
2023-05-09 15:58:20 -05:00
dustinfaceandGitHub f0006b5353 server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
Kyle AltendorfandGitHub 2b96a33c26 correct rate limiting of rate limit log message (#14659) 2023-02-27 12:56:34 -06:00
Kyle AltendorfandGitHub ff5ef6e073 remove leading newlines from indented code blocks (#14653)
* remove leading newlines from indented code blocks

* catch another one
2023-02-23 21:53:48 -06:00
Kyle AltendorfandGitHub 9e27220d27 avoid excessive logging filter registration (#14638) 2023-02-22 17:16:26 -06:00
Kyle AltendorfandGitHub c678f00acb cleanup adjacent string literals (#14650) 2023-02-22 17:16:07 -06:00
Kyle AltendorfandGitHub c71fcc0da0 handle ._get_extra_info() call on a closing connection (#14618)
* handle ._get_extra_info() call on a closing connection

* or just return none

* don't check if the transport is closing

* or have to catch an exception
2023-02-21 01:15:32 -06:00
Adam KellyandGitHub 91655a9c0b Rate limit 'Rate limiting' message (#14435) 2023-02-08 21:25:35 -06:00
dustinfaceandGitHub 3bd6069f04 server: Exclude some attributes from WSChiaConnection.__repr__ (#14466) 2023-02-04 14:14:27 -06:00
Almog De PazandGitHub 3f97435159 dont announce none response capability to peers (#14386)
* dont announce none response capability to peers

* comment out none response handling

* skip test instead of comment out
2023-01-25 13:53:38 -06:00
Amine Khaldi 7defb1ebfc Merge commit '618f93b4c42b176659cc74c02a4dd711adc62052' into checkpoint/main_from_release_1.6.2_618f93b4c42b176659cc74c02a4dd711adc62052 2022-12-14 19:24:34 +01:00
dustinfaceandGitHub a40f04012b server: Replace WSChiaConnection.__getattr__ with call_api (#14052) 2022-12-13 00:35:42 -06:00
Kyle AltendorfandGitHub 618f93b4c4 handle incoming unknown capabilities (#14093)
* handle incoming unknown capabilities

* move it around

* chia.server.capabilities

* Update tests/util/test_network_protocol_files.py
2022-12-09 18:37:18 -06:00
dustinfaceandGitHub 8a3ee3f4c0 server: Move api call processing into WSChiaConnection (#14008) 2022-12-09 03:47:46 -06:00