Commit Graph
148 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 de520177c7 pass in unresolved name for use as servername in ws_connect (#20349)
* pass in unresolved name for use as servername in ws_connect

* apply some bugbot comments

* avoid setting server hostname when it's actually the ip address

* different strategy for when to not use server_hostname
2026-06-03 14:05:08 -05:00
Amine Khaldi 60324086f9 Merge commit '7080538f7d944b9a3e4cd12bcd9b6bb61f46018b' into checkpoint/main_from_release_2.7.1_7080538f7d944b9a3e4cd12bcd9b6bb61f46018b 2026-05-21 17:58:24 +01:00
Zachary BrownandGitHub 08bfaa76e4 [CHIA-4209] Handle stale peers during connection garbage collection (#20865)
Handle stale peers during connection garbage collection
2026-05-18 11:30:06 -05:00
7080538f7d 2.7.1 Checkpoint Merge (#20887)
* Checkpoint Merge

Co-authored-by: Almog De Paz <almogdepaz@gmail.com>
Co-authored-by: Zachary Brown <z.brown@chia.net>

* Add a timeout during node shutdown

* Revert "Add a timeout during node shutdown"

This reverts commit ab57da71fb.

* Replace test_add_transaction_seen_before_validation with simpler version

The previous version of this test was the sole cause of a CI hang on the
2.7.1-checkpoint branch (confirmed by bisection). It used the heavyweight
wallet_nodes fixture, a real peer connection, and a backgrounded task driving
add_transaction, all of which left orphaned async work during fixture teardown
under pytest-xdist on CI runners.

The replacement keeps the same regression coverage for SEC-111 (tx must be
marked in-flight before pre_validate_spendbundle) but does so with:
- the lightweight one_node_one_block fixture
- pytest.MonkeyPatch.context() instead of manual attribute swap
- two asyncio.Events to deterministically gate validation
- asyncio.wait_for on both the gate and the final task to fail fast

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Almog De Paz <almogdepaz@gmail.com>
Co-authored-by: Zachary Brown <z.brown@chia.net>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-15 18:53:31 -05:00
Zachary BrownandGitHub f393929129 Add outbound handshake timeout in start_client (#20766)
* Handle outbound handshake timeout explicitly.

Wrap outbound handshakes in a 120s timeout for non-local/non-exempt peers and treat timeout failures as clean connection closures with a dedicated regression test.

* Make outbound handshake timeout configurable via config.

Read `outbound_handshake_timeout` from node config (default 120s),
consistent with the existing `peer_connect_timeout` pattern.
Add regression test that verifies the config override is applied.
2026-04-09 17:52:17 -05:00
Chris MarslenderandGitHub 0046a3a4e4 [CHIA-3995] Update inbound timelord connection handling (#20720)
* Update so localhost peers always bypass the config limits for inbound peers. Move timelords to accept only if in exempt peer networks or on localhost

* Fix pre-commit issues

* For now scope the is_localhost check to just timelord service

* Abstract the logic for should accept inbound to its own directly testable function
2026-03-26 08:58:30 -05:00
Amine KhaldiandGitHub d3005e17a7 CHIA-3821 Full nodes should only accept peer connections post hard fork 2 from nodes that signal support for it (#20452)
Full nodes should only accept peer connections post hard fork 2 from nodes that signal support for it.
2026-03-03 10:00:23 -06:00
Amine KhaldiandGitHub 0a2536f806 CHIA-3906 Improve accept_inbound_connections (#20557)
Improve accept_inbound_connections.
2026-02-27 15:01:08 -06:00
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
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
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
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
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
Kyle AltendorfandGitHub f054d339a1 unignore some ruff s rules (#19703) 2025-06-12 11:12:54 -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 20a0d934cb Move ssl_check.py to chia/ssl (#19596) 2025-05-12 08:53:18 -04: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
Kyle AltendorfandGitHub d50b6e0883 use chia_rs directly for sized bytes (#19326) 2025-02-28 09:35:25 -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
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
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
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
pengbanbanandGitHub 3d916bd25d chore: fix some comments (#18485)
Signed-off-by: pengbanban <pengbanban@aliyun.com>
2024-09-13 10:52:32 -05:00
Chris MarslenderandGitHub dafd8b41d9 Add optional trusted CIDR list (#18094)
* trusted_cidr list

* Tests for trusted cidrs

* only check IPs

* Fixing lint
2024-05-29 13:45:59 -05: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
Arvid NorbergandGitHub bdfffca5ab improve handling of UnfinishedBlocks (#17247)
* update full_node_store to support multiple UnfinishedBlocks with the same reward hash

* extend full node store to support recording outstanding requests for v2 unfinished blocks

* add test for full_node_store

* simplify creation of UnfinishedBlock in test_full_node.py

* extend UnfinishedBlock protocol to support distinguishing between unfinished blocks with the same partial hash but different foliage

* add test for NewUnfinishedBlock and NewUnfinishedBlock2

* when asking the full_node_store for an unfinished block, only by its partial hash; return the highest ranking (lowest foliage tx block hash)
2024-01-26 13:20:03 -08:00
Amine Khaldi 3a2be22c44 Merge commit 'a4cab829edd4f16dd89b29c7234ed39c23c5dcaa' into checkpoint/main_from_release_2.1.4_a4cab829edd4f16dd89b29c7234ed39c23c5dcaa 2023-12-22 23:29:59 +01:00
wjblankeandGitHub a4cab829ed Performance tweaks (#17155)
* changed default peers from 80 to 40. switched auto db_sync default to NORMAL instead of FULL

* fixed default

* add defaults to config query
2023-12-22 16:28:31 -06:00
RigidityandGitHub 41047bddc8 Async connection close handlers (#17017) 2023-12-11 08:27:25 -06:00
Earle LoweandGitHub 206b5c5185 Fix problems with wallet node discovery (#16782)
* Fix problems with wallet node discovery

* Adjust tests to work more consistently

* Attempt to debug rate limit test

* Limit rate test to one consensus mode
2023-11-08 08:40:21 -08:00
Kyle AltendorfandGitHub 90c1441af0 apply pyupgrade --py38-plus --keep-runtime-typing (#14646) 2023-10-24 12:01:23 -05: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
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
Felix BruckerandGitHub c5ca0978f6 Add support for multi node farmers (#15444)
* Extract `respond_signatures` logic

* Add `call_api_of_specific` method to `ChiaServer`

* Fix typehint for test fixture `farmer_one_harvester`

* Make test helper `add_dummy_connection` work with any node type

* Add `reply_types` to `request_signatures` of harvester

* Fix duplicate SP processing with multiple nodes

* Handle state in `request_signed_values`

* Add set typehint

* Add comment re `_process_respond_signatures()` usage

* Fix imports

* Fix wording to not confuse with SignedValues message
2023-07-28 14:48:32 -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 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
Kyle AltendorfandGitHub 0832f211b7 cleanup connection removal from ChiaServer.all_connections (#15026) 2023-04-14 15:19:17 -06:00
dustinfaceandGitHub f0006b5353 server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
Justin EnglandandGitHub 1360383db9 more passing arguments by name in ChiaServer (#14937)
<!-- 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:



<!-- 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) -->
2023-04-11 14:55:37 -06:00
Justin EnglandandGitHub 4976017853 change self peer connection error to info, remove traceback (#14884)
<!-- 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:

Self connection errors don't need to be `ERROR` level in the log nor do
they need to have tracebacks. This will mostly happen when a node is
unaware of one or more of its own public IPs being used by the network.
Could be IPv4 vs. IPv6, or multiple IPs, or just being behind a NAT.

<!-- Does this PR introduce a breaking change? -->
### Current Behavior:

```python-traceback
2023-03-22T14:00:46.076 full_node full_node_server        : ERROR    Exception Trying to connect to a peer (PeerInfo(_ip=IPv4Address('<REDACTED>'), _port=58445)) with the same peer_id: <REDACTED>, exception Stack: Traceback (most recent call last):
  File "/home/ubuntu/chia-blockchain/chia/server/server.py", line 525, in start_client
    raise RuntimeError(f"Trying to connect to a peer ({target_node}) with the same peer_id: {peer_id}")
RuntimeError: Trying to connect to a peer (PeerInfo(_ip=IPv4Address('<REDACTED>'), _port=58445)) with the same peer_id: <REDACTED>
```

### New Behavior:

`INFO` level logging without a traceback

<!-- 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) -->
2023-04-11 14:51:46 -06:00
Justin EnglandandGitHub 0022ce797d Small improvements to trusted peer check to include IPv6 addresses and add tests (#14626)
Refactor function `is_trusted_peer` to a standalone easily testable
function. Leverage the existing `is_localhost` function to extend
coverage to IPv6 local address for the trusted peer check

Added tests for the new standalone function
2023-04-11 14:36:37 -06:00