* 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
* 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>
* remove unused default_settings in rate limits
* simplify rate_limit_numbers by flattening the structure. just map message type -> rate limits
* review comments
* 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
<!-- 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) -->
Move `get_unresolved_peer_infos` and `set_peer_info` from
`chia.util.config` to `chia.server.resolve_peer_info.py` so that
`chia.util` no longer depends upon `chia.server`.
<!-- 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:
This PR is an optimisation for the way that AddressManager and
ExtendedPeerInfo are serialized, which happens periodically in a task
called from node_discovery.py
As well as the format of the serialization, the serialization algorithm
itself has had a multitude of speedups, including removing redundant
loops, minimising allocations, and so on.
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
Previously we were serialising ExtendedPeerInfo as a string and
AddressManager as an `@streamable` `.to_bytes()`.
Copying all the data to this class was taking a deal of time.
The serialising function also had a lot of complicated pieces of
redundant code, looping over data multiple times when 1 pass might do.
### New Behavior:
This PR instead serialises AddressManager directly using a bytearray,
and refactors the code to reduce the complexity and number of loops.
More comments have been added in this area of the codebase as well.
### Testing Notes:
This PR includes a new benchmark file for the AddressManager's
serialisation.
Here are my personal results comparing this PR with `main`:
On main: `Average serialize time: 1.544302 seconds`
Sum of my optimisations: `Average serialize time: 0.468669 seconds`
Feel free to run `benchmarks/address_manager_store.py` to see for
yourself.
I have also added in a migration test in
`chia/_tests/core/full_node/test_address_manager.py` which creates an
old serialisation, loads it using the current loading code, then
serialises it using the new serialization, and then loads that.
It is also checked at each step along the way to ensure that the
serialisation has remained good.
<!-- 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
* add `/get_log_level` and `/set_log_level` to all rpcs
* tidy
* for py <3.11
* fixup
* add tests
* a few no covers
* add `RpcClient.reset_log_level()`
* tidy
* fixup
* 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.