Commit Graph

47 Commits

Author SHA1 Message Date
Kyle Altendorf
07004049aa
add RPC API generic parameter to Service (#16973) 2023-12-05 13:30:56 -06:00
Kyle Altendorf
65dfbbb6aa
add Service type variables for each combination (#16970) 2023-11-30 13:38:38 -06:00
Kyle Altendorf
9d5cbf3f24
crawler just manage (#16758) 2023-11-21 17:14:29 -06:00
Kyle Altendorf
fbdb27bef1
managers for services (#16670) 2023-11-16 19:21:12 -06:00
Kyle Altendorf
aaf081f69d
explicit protocol checks against RpcServiceProtocol (#16710) 2023-10-27 12:03:15 -07:00
Chris Marslender
066140cb36
Swap some info logs in seeder to warning (#16703) 2023-10-26 19:59:04 -05:00
Kyle Altendorf
90c1441af0
apply pyupgrade --py38-plus --keep-runtime-typing (#14646) 2023-10-24 12:01:23 -05:00
Kyle Altendorf
e9ac7ea610
apply uint*() more (#16287) 2023-09-13 10:48:06 -05:00
Kyle Altendorf
353f12d5a3
commonize signal setup (#13568)
* commonize signal setup

* add signal setup for async handlers

* future

* Update misc.py

* catch up

* logging

* missed one

* context manager and waiting for signal handlers to complete

* correct logging

* fixup

* fixup
2023-09-06 13:01:11 -05:00
Kyle Altendorf
538edfd6b8
Do not enable seeder signal handlers in tests (#16079) 2023-08-23 23:04:56 -05:00
Jack Nelson
33dd20e6be
Fix Core Test Flake (#16055)
* upgrade and fix find avail listen port

cleanup names and logic

* Update chia/seeder/dns_server.py

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>

* rewrite db test

---------

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2023-08-16 18:39:42 -05:00
Jack Nelson
0d36874caa
Refactor Seeder & Crawler code + add tests (#15781)
* Cleanup seeder & mypy all files

holy crap mother of all tech debt this was horrid

* Make UDP Protocol class a dataclass & separate out functions.

* add TCP protocol class to DNS server

* Fix mypy types & other cleanup

also fix a couple bugs

* Add seeder and crawler tests

* change log levels

* re add db lock timeout

oops

* add edns & edns tests

* fix repeated shutdown on close signal

* fix binding to use both ipv6 and ipv4

whyyyyyyy

* add ipv6 and ipv4 tests + add ipv4 if windows
2023-08-11 05:25:19 -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
d6a2a9aa5d
seeder: Drop CrawlerAPI.__getattr__ (#15489)
* Test sending unknown messages to the crawler

* Drop `CrawlerAPI.__getattr__`

* Use a real crawler service for the test
2023-06-13 15:25:39 -05:00
dustinface
e7f8aa0827
seeder: Hint crawler_api.py (#15498) 2023-06-13 11:25:15 -05:00
dustinface
1f8fc6410c
util: Async DNS lookups (#14999)
* Rename `get_host_addr` to `resolve`

* Async DNS lookups in `resolve`

* Drop not needed `str` conversions
2023-04-28 13:37:28 -05:00
Justin England
9f0a2ece07
remove unused Service(server_listen_ports=) parameter (#14928)
<!-- 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:

remove dead code so the remaining code is more comprehensible

<!-- 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:19 -06:00
François Deppierraz
b594f8915b
seeder: case-insensitive DNS label matching to support bit 0x20 use (#14933)
Some DNS resolvers (notably 8.8.8.8) have implemented the use of bit 0x20 in
DNS labels to make cache poisoning attacks more difficult.

See https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 for
more details.

Without this patch, resolution though Google public DNS fails:

$ dig dns-introducer.chia.net @8.8.8.8 +short | wc -l
       0

Whereas it works as expected on a seeder which already deployed this patch:

$ dig chia.ctrlaltdel.ch @8.8.8.8 +short | wc -l
      32
2023-04-03 13:33:32 -05:00
Kyle Altendorf
a609a815ec
remove unused Service(server_listen_ports=) parameter 2023-03-28 13:55:44 -04:00
Chris Marslender
db6bf72af3
Listen on ::0 so we can respond to both ipv4 and ipv6 (#14731)
* Listen on ::0 so we can respond to both ipv4 and ipv6

* Move the initial sleep to the end of the first attempt to load reliable peers, so that if we already have a database, it doesn't take 60 seconds to start responding
2023-03-03 19:59:54 -06:00
Earle Lowe
2d721ec8bb
Quick fix to some hostname problems (#14725) 2023-03-03 15:05:02 -06: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
Adam Kelly
58c669164c
Typecheck _set_state_changed_callback (#14464) 2023-02-01 15:31:46 -06:00
dustinface
42f6a883ae
isort: Remove the remaining exceptions and sort the related files (#14124) 2022-12-13 17:10:55 -06:00
dustinface
a40f04012b
server: Replace WSChiaConnection.__getattr__ with call_api (#14052) 2022-12-13 00:35:42 -06:00
dustinface
50d148eadd
Cleanup WSChiaConnection imports/usage (#13868) 2022-11-08 10:10:59 -06:00
Kyle Altendorf
bae4e0c5ce
refactor @api_request decorator and family to use a single decorator (#13565)
* 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

* hack the ~planet~ `@api_request` decorator

* R not T

* more future

* implementation detail renames
2022-10-20 16:10:23 -04: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
Kyle Altendorf
1dbf575a3e
RpcApiProtocol and RpcServiceProtocol (#11522)
* provide a skeleton hint protocol for rpc apis

* more

* more self.custom_get_connections = None

* fix RpcApiProtocol.service hinting

* catch up with RpcApiProtocol._state_changed()

* FullNode.server is now non-optional.  'ish

* drop another todo

* custom_get_connections -> get_connections

* just make get_connections() a mandatory method with a helper provided

* lots

* try again

* ._start_with_fingerprint()

* fill out the Service generic parameter in start scripts

* ... instead of pass

* add docstrings to the protocols

* remove no longer needed hasattr/not None checks

* remove outdated comment

* refactor Harvester._is_shutdown to ._shut_down
2022-09-21 22:49:01 -05:00
dustinface
70fe981fb3
cmds: Implement chia beta (#12389)
* cmds: Implement `chia beta` for the beta test program

* Unhide and document all `beta` subcommands

* Refactor all subcommands

* Introduce `chia beta configure`

* Introduce `chia beta status`

* Test all `chia beta` commands

* Use a separate file logger for beta logs

* Write the plotting call args to the log file

* Sort potential submissions

* Some refactoring around log file log handler creation

* JSON dump the plotting args
2022-09-12 16:57:31 -05:00
Mariano Sorgente
87a3e93cc4
Ms.mypy enable (#13320)
* Remove mempool.additions

* Don't re run the program, and remove program from mempool item

* Removals only stores item ids, and stores a list

* Move pending cache down to prevent cache dos

* Separate validation from adding to pool, and remove mypy exceptions

* Fix bug with replacing

* Add to mypy

* Revert cbgui

* precommit fail

* Properly update the seen dict

* lint error

* Fix mempool bug

* Enable mypy for a bunch of files

* Update after merge with main

* 99/260 remaining

* Address comments

* Enable more mypy

* Merge conflict mypy file

* More fixes

* pytest.ini and cb-gui

* One more flake8 fix

* Flake8 and tests

* More test fixes

* isort

* Make LGTM happy

* Update chia/full_node/block_store.py

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

* Update chia/full_node/full_node_store.py

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

* Update chia/wallet/util/peer_request_cache.py

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

* Apply all suggestions from PR comments

* Revert cb-gui

* 100 back to 1000, minor tweaks

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-09-08 12:57:15 -05:00
Kyle Altendorf
81b8dc45b5
service_name="full_node" (#12358) 2022-07-13 15:02:08 -05:00
Chris Marslender
a58369cb3b
Add change_data to _state_changed since the later calls expect it (#12355)
* Add change_data to _state_changed since the later calls expect it

* Add default change_data of `None` to the rpc_service state_changed method (everywhere else has this default)

* Change data is optional
2022-07-13 15:01:16 -05:00
Kyle Altendorf
f2061d86d6
rework service creation to be hint checkable (#12153)
* rework service creation to be hint checkable

* fixup config vs. service_config

* more fixup

* service start cleanup

* Update nft_metadata_updater_default.clvm.hex

* reorder advertised_port= parameter

* undo unrelated tweaks

* Optional[RpcInfo]

* undo unrelated whitespace change
2022-07-13 11:43:48 -05:00
Kyle Altendorf
1205418f22
Simplify service start configuration loading (#12204)
* Simplify service start configuration loading

* oops

* more oops

* rename `config` to `service_config` as appropriate

* rename `full_config` to `config`
2022-07-07 19:57:08 -05:00
Kyle Altendorf
52df955a1a
Make start_crawler.py consistent with start_*.py (#12196) 2022-07-02 01:08:13 -05:00
Kyle Altendorf
90516263aa
remove chia.util.path.mkdir() (#10842)
* remove chia.util.path.mkdir()

* remove submodule change

* less tmpdir, more tmp_path
2022-06-08 10:24:40 -05:00
Chris Marslender
7b838239a9
Additional metrics (#11271)
* Remove _set_state_changed_callback from harvester_api.py as its never actually called

In rpc/rpc_server.py:318, what is actually called is rpc_server.rpc_api.service._set_state_changed_callback, so the version of this in harvester.py is what is actually used

* Remove duplicate initial value for state_changed_callback in init

* _state_changed -> state_changed so it can be called from harvester_api as well

* Add farming info state_changed event from harvester

* Add time to farming_info event

* Add [pre_]validation_time to block event

* Remove unused set_state_changed_callback on full_node_api. This is actually called on full_node_rpc_api.service

* Remove unused set_state_changed_callback on crawler_api. This is actually called on crawler_rpc_api.service (crawler)

* Remove unused set_state_changed_callback on farmer_api. This is actually called on farmer_rpc_api.service (farmer), not the api itself

* Add state changed event for submitting a partial

* Lint fixes
2022-04-22 10:53:03 -07:00
dustinface
a48fd43100
streamable: Simplify and force correct usage (#10509)
* streamable: Merge `strictdataclass` into `Streamable` class

* tests: Test not supported streamable types

* streamable: Reorder decorators

* streamable: Simplify streamable decorator and force correct usage/syntax

* streamable: Just move some stuff around in the file

* streamable: Improve syntax error messages

* mypy: Drop `type_checking.py` and `test_type_checking.py` from exclusion

* streamable: Use cached fields instead of `__annotations__`

This is now possible after merging `__post_init__` into `Streamable`

* Introduce `DefinitionError` as `StreamableError`

* `/t` -> `    `
2022-04-08 18:29:32 -07:00
Kyle Altendorf
a691d3c4b2
asyncio.get_event_loop() is deprecated in 3.10, stop using it (mostly) (#10418)
* asyncio.get_event_loop() is deprecated in 3.10, stop using it

https://docs.python.org/3.10/library/asyncio-eventloop.html#asyncio.get_event_loop
> Deprecated since version 3.10: Deprecation warning is emitted if there is no running event loop. In future Python releases, this function will be an alias of get_running_loop().

* black
2022-03-28 13:20:50 -07:00
Chris Marslender
be2d8267aa
Don't load initial data older than 5 days (#10481)
* When loading initial data, don't include IPs older than 5 days in the best timestamp dict

* Don't load version data for hosts older than 5 days
2022-02-28 15:21:31 -08:00
Chris Marslender
5e4c1a1f62
Timelord RPC + Misc Metrics Updates/Fixes (#10255)
* Add mempool_max_total_cost to RPC

* Add signage_point event

* Fix incorrect crawler RPC port lookup

* Set up initial timelord RPC server + finished_pot_challenge event

* Add new compact proof event

* Add skipping/new_peak to track when fastest or not

* Check for None on change_data

* Add skipping_peak + new_peak to changes for metrics

* Convert chain to value

* Rename iters

* Timelord RPC to 8557 - 8556 is used in simulation tests

* Make tests work with RPC server on timelord

* Change event name to finished_pot

* Use broadcast_farmer object

* Move state changed for `finished_pot` after proofs_finished.append

* Fix type on ips var + add vdf_info and vdf_proof

* fix event name on the state_changed function
2022-02-18 07:43:52 -08:00
Chris Marslender
eb3ed142e0
Crawler RPC (#10141)
* Add crawler RPC server

* Generate private keypair for crawler

* Bring over cleanup changes from the last closed PR

* Update the crawler RPC information to be its own subsection within seeder

* Add sleep before crawling to let the daemon connection get set up

* Wait for the actual callback to not be None, instead of just a random sleep interval

* Rework crawler/dns seeder to use the daemon + normal chia start process rather than the old system intended for the standalone repo

* Update configure testnet to work with seeder config

* Add back the crawler/seeder options from the standalone version

* Remove the check for none/sleep. Not needed when this is started by the daemon

* Add real data to the get_peer_counts endpoint

* Lint

* Fix calls to configure from init

* Turns out we still might sometimes move too quick before daemon/state changed callback is ready

* Add peer counts in the state_changed callback method

* Add a setting for peer_connect_timeout in the seeder: section so we can control it just for crawler

* start_seeder

* Pass config/root_path to the DNSServer so it can also use the configured crawler DB Path

* change in () instead of if/or

* Remove unnecessary return
2022-02-14 11:48:35 -08:00
Chris Marslender
fc0b1dd7a4
Crawler retry db on lock (#9562)
* Remove initial writes to DB, since there is nothing new to write at this point

Both of these methods are called later after each crawler iteration. The lines being deleted write all the same data back to the DB right after the initial data was loaded FROM the DB in the "create" method call, which is a waste of time, especially for mainnet where there are hundreds of thousands of records to write back

* Add additional logs around DB writes

* Add a retry around writing to the DB in case something else has a lock on the DB

Metrics processes read from this DB periodically and sometimes things time out just right and we get a lock exception. Without this retry, we'd hit the other exception handler which doesn't allow the loop to continue
2021-12-14 18:01:45 -08:00
Earle Lowe
7d801144ea
Add TLS version to collected crawler stats (#9534) 2021-12-13 08:40:22 -08:00
Chris Marslender
772e607681
always update best timestamp even if we weren't able to connect to keep track of gossiped peers properly (#9538) 2021-12-10 09:16:17 -08:00
Gregory
025c45f0b5
Chia Seeder (#8991)
* initial hack

* crawler

* add pytz

* Checkpoint.

* Catch some bugs.

* Localhost dig working.

* Checkpoint: return only high quality nodes.

* Statistics.

* Try improving finding reliable nodes.

* Bug.

* Move db to memory.

* Timestamp in the last 5 days.

* Increase crawl parameters, 180+ connections per sec.

* Bug.

* Optimize for DNS traffic.

* Prepare for hosting.

* Minimum height.

* Typo.

* Try catch everything.

* dnslib.

* Add db, format code.

* nits.

* No connections for the dns server.

* Rename src -> chia

* Fix some issues with v1.1

* Crawler task pool.

* Optimize closing connections.

* Split crawler and dns server.

* Install instructions.

* Catch startup bug.

* Try a big timeout for lock aquire.

* lint.

* Lint.

* Initial commit extended stats.

* Simplify code.

* Config.

* Correct stats.

* Be more restrictive in crawling.

* Attempt to fix stats bug.

* Add other peers port to config.

* Update README for the config.

* Simplify crawl task.

* Fix bug on restarts.

* Prevent log spamming.

* More spam prevention.

* Fix bug.

* Ipv6 (#1)

* Enable ipv6.

* Fix bug.

* Use numeric codes for QTYPE.

* ANY working.

* More spam prevention.

* Try to improve IPv6 selection.

* Log IPv6 available.

* Try to crawl more aggresive for v6.

* rename dns.py to crawler_dns.py so it doesn't conflict with imported package names

* Remove pytz package off dependencies

* Tidy-up ws_connection.py

* Fix spelling

* Reinstate chia-blockchain readme, with additional lines pertaining to the DNS introducer & crawler

* More detailed info in the README wrt Chia Seeder

* Nit

* More memetic naming of Chia Seeder

* Nit

* Add entry points

* Add entry in packages

* Patch some methods on the upstream server

* Update peer record fields

* Standard library imports first

* Crawler API check

* Reconcile crawl store

* Account for crawler_db_path in config

* Await crawl store load DB and load reliable peers

* Updates to crawler

* Rename to dns_server

* Crawler-specific overrides for the chia server

* Edit comment

* Undo changes to ChiaServer in view of crawler-specific overrides introduced in previous commit

* Nit

* Update service groups

* Expand name maps, mostly

* Fix the init config

* Remove unused import

* total_records unused at this stage

* Remove ios_reliable in peer_reliability table

* Remove row[20] entry

* Split overly long line

* Fix

* Type hint for ns_records

* Reconcile mismatch btw type int and uint64

* Type annotations in crawler

* Check whether crawl store is set

* Remove upnp_list

* Lint

* Chia Seeder CLI

* Lint

* Two white spaces

* 3rd party package import

* Cleaner way to handle overrides for ChiaServer method

* Address linter warnings

* Rename

* Nits

* Fix

* Change port #

* Most chia_seeder commands up and running

* Rename

* Progress of sorts

* Fix

* Improve legibility

* Fix naming

* Fix setup.py

* Lint

* None -> ''

* Remove whitespace

* Rename

* Log ipv6 better. (#9227)

* Log ipv6 better.

* Lint.

* -

* Undo GUI changes

* Another attempt

* GUI changes

Co-authored-by: Yostra <straya@chia.net>
Co-authored-by: Florin Chirica <fchirica96@gmail.com>
Co-authored-by: Chris Marslender <chrismarslender@gmail.com>
2021-11-27 18:30:25 -08:00