* 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
* 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>
* 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.
* 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
* 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
* 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
<!-- 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) -->
* 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
* 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.
* 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>
* 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)
* 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
* 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
* 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>
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.
<!-- 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) -->
<!-- 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) -->
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