Commit Graph

113 Commits

Author SHA1 Message Date
Amine Khaldi
3a2be22c44
Merge commit 'a4cab829edd4f16dd89b29c7234ed39c23c5dcaa' into checkpoint/main_from_release_2.1.4_a4cab829edd4f16dd89b29c7234ed39c23c5dcaa 2023-12-22 23:29:59 +01:00
wjblanke
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
Rigidity
41047bddc8
Async connection close handlers (#17017) 2023-12-11 08:27:25 -06:00
Earle Lowe
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 Altendorf
90c1441af0
apply pyupgrade --py38-plus --keep-runtime-typing (#14646) 2023-10-24 12:01:23 -05:00
Kyle Altendorf
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
dustinface
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 Brucker
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
dustinface
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
dustinface
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 Altendorf
0832f211b7
cleanup connection removal from ChiaServer.all_connections (#15026) 2023-04-14 15:19:17 -06:00
dustinface
f0006b5353
server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
Justin England
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 England
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 England
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
Kyle Altendorf
ec6b13192b
just return 2023-04-03 08:26:00 -04:00
Kyle Altendorf
cabb0ceec5
move it 2023-03-29 22:11:52 -04:00
Kyle Altendorf
de7d68468b
just ChiaServer.start() since it sometimes doesn't really start serving 2023-03-29 21:21:15 -04:00
Kyle Altendorf
89b8cfae9c
not private... 2023-03-29 21:18:51 -04:00
Kyle Altendorf
e2c4417f77
more passing arguments by name in ChiaServer 2023-03-29 21:16:22 -04:00
Kyle Altendorf
3b29c2ff7f
add explicit listen option for Service() and ChiaServer.start_server() 2023-03-28 21:22:05 -04:00
Kyle Altendorf
83c0b0cb0f
change self peer connection error to info, remove traceback 2023-03-22 13:22:11 -04:00
Earle Lowe
3e13236eef
Merge remote-tracking branch 'origin/main' into EL.trusted_peer_fix 2023-03-02 13:07:23 -08:00
Kyle Altendorf
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
dustinface
18e88e8476
types: Use IPAddress instead of str in PeerInfo (#14167)
* Use `IPAddress` instead of `str` in `PeerInfo`

* Add comment about `get_host_addr`
2023-02-22 12:03:41 -06:00
Earle Lowe
38b3f1568d
refactor is_trusted_peer 2023-02-20 08:23:39 -08:00
Kyle Altendorf
83900d7147
use .get("testing", False) to avoid errors when missing (#14267)
https://github.com/Chia-Network/chia-blockchain/issues/14239
2023-01-03 20:50:58 -06:00
Kyle Altendorf
d53f249e5c
only send_to_all(), drop send_to_all_except() (#14229)
* only send_to_all(), drop send_to_all_except()

* catch up tools/ as well

* add default
2023-01-02 21:39:11 -06:00
Almog De Paz
b5f44027dd
don't throw unnecessary exception on peer connect (#14108)
don't throw unnecessary exception
2022-12-13 01:29:05 -06:00
dustinface
8a3ee3f4c0
server: Move api call processing into WSChiaConnection (#14008) 2022-12-09 03:47:46 -06:00
dustinface
5cc83b8af6
server: Some adjustments related to WSChiaConnection.close_event (#14039)
- Make it non-optional
- Make it private
- Only set it at the end of `WSChiaConnection.close`
2022-12-07 20:48:04 -06:00
Almog De Paz
4d068f284a
dont wait for timeout on None response (#13967)
* dont wait for timeout on None response

* handle return msg by type

* remove empty line

* isort

* improve reply check

* use map to check reply, add has_capability helper

* fix has_capability

* unused import
2022-12-07 20:47:21 -06:00
xdustinface
c356fe0465
Fix ChiaServer.is_duplicate_or_self_connection 2022-12-05 07:41:56 +01:00
dustinface
898543b874
server: Enable and fix mypy for all chia.server files (#13990)
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-11-28 18:00:45 -06:00
dustinface
23ac4f7c80
server: Drop unused WSChiaConnection.is_feeler (#14011) 2022-11-28 13:57:01 -06:00
dustinface
9b1989b014
Enable and fix mypy in server.py (#13579)
* server: Enable and fix `mypy` in `server.py`

* Add a comment about the `Message` hint

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

* Tweak assert message

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

* Make `name` non-optional

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

* Properly reject incoming connections to crawlers

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

* Hint `StreamResponse` and return the existing `WebSocketResonse`

* Raise if `remote` is `None`

* Restore old behaviour: succeed, don't fail for self connection

* Raise `HTTPInternalServerError` if `remote` is `None`

* Cast config values to `int`

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-11-18 10:43:14 -06:00
dustinface
2ff987573d
Simplify ChiaServer.close_all_connections (#13916) 2022-11-16 13:57:30 -06:00
dustinface
5c861db42f
Make WSChiaConnection a dataclass (#13906)
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-11-16 13:38:28 -06:00
dustinface
643b29e636
Drop broken message types logging (#13914)
Seems like the idea was to log an overview of message types for the 
currently active api calls whenever we have multiples of 100 running. 
This currently isn't working at all because `len(message_types) % 100 == 
0` will only trigger if there are 100 different message types in the 
counter (we don't even have that much different messages). A fix would 
be to check `message_types.total() % 100 == 0`. But then, if we hover 
around 100 active messages this will repeatedly trigger logs since we 
decrement for each processed message, im not sure this all makes much 
sense and we anyway log all received message types with `DEBUG` logs so 
i decided to just drop this. If someone thinks we should keep it with 
the fix or has ideas to make this a more reasonable log instead of 
dropping it, let me know :)
2022-11-16 10:44:48 -06:00
dustinface
8e2e51a8c8
Add optional outbound parameter to get_connections (#13879) 2022-11-15 17:40:16 -06:00
Earle Lowe
f30f0b3512
Call close callback for already closed connections (#13727)
* always call close callback

* Some further explorations

* some more explorations

* Add delay while connections are closed in test

* Add a delay to make sure connections drain

* Update chia/server/server.py

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

* Update tests/connection_utils.py

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

* use log_exceptions context manager

* set close flag correctly

* Added callback type and other changes

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-11-15 16:23:06 -06:00
Kyle Altendorf
5cf8a291f7
adjust approach to optionality around ApiMetadata (#13888) 2022-11-10 19:58:12 -06:00
dustinface
24961dd02c
server: Drop some unused code (#13867)
* Drop unused `Delivery` enum

* Drop unused `get_outgoing_connections`

* Drop `connection_utils.py`
2022-11-08 18:04:56 -06:00
dustinface
cf77f58bf2
server: Make ChiaServer a dataclass (#13574)
* server: Make `ChiaServer` a `dataclass`

* Use existing logger

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

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-11-03 11:28:23 -05:00
dustinface
7a5d9579ef
server: More use of ChiaServer.get_connections (#13573)
* Drop `get_full_node_connections` -> use `get_connections`

* Drop `connection_by_type`

I think the housekeeping required to have it isn't worth it since we
don't handle huge numbers of connections and `get_connections` should be
less enough overhead. Im open for complains though.
2022-10-05 11:21:38 -05:00
dustinface
31f31296a7
server: Use WebServer in ChiaServer (#13545)
* server: Use `WebServer`

* Fix `yaml.representer.RepresenterError: ('cannot represent an object', 49405)`
2022-10-03 14:43:04 -05:00
dustinface
35acbabf80
server: Use get_extra_info to get the ssl_object (#13578) 2022-09-30 17:50:46 -05:00
Kyle Altendorf
2fc65e1178
more explicit and complete handling of api decorator data (#13542)
* more explicit and complete handling of api decorator data

* fix

* .message_class

* actually, those are different types...

* tweak

* simplify

* learn that functools.wraps copies random attributes
2022-09-30 17:47:56 -05:00
dustinface
c3ebc62246
server: Drop some ChiaServer attributes (#13513)
* Drop unused `ChiaServer.tasks`

* Drop unused `ChiaServer._tasks`
2022-09-30 17:41:51 -05:00
Kyle Altendorf
3b084a165b
configure isort to add the future annotations import (#13327)
* configure isort to add the future annotations import

* apply the new isort setting

* remove type ignores for new mypy (#13539)

https://pypi.org/project/mypy/0.981/

* another
2022-09-30 03:40:22 -05:00