Commit Graph

80 Commits

Author SHA1 Message Date
Rigidity
41047bddc8
Async connection close handlers (#17017) 2023-12-11 08:27:25 -06:00
Kyle Altendorf
06e680d421
farmer just manage (#16754) 2023-11-21 17:13:08 -06:00
Kyle Altendorf
fbdb27bef1
managers for services (#16670) 2023-11-16 19:21:12 -06:00
Arvid Norberg
95e5b97557
Use bls from chia rs (#16715)
* replace blspy imports with chia_rs imports for BLS types

* remove blspy-stubs, since we're dropping the blspy dependency. chia_rs has type stubs already
2023-11-07 09:06:52 -08:00
Izumi Hoshino
c9f414611a
Distinguish insufficient_partials from invalid_partials (#16667) 2023-10-30 10:12:06 -07:00
Kyle Altendorf
aaf081f69d
explicit protocol checks against RpcServiceProtocol (#16710) 2023-10-27 12:03:15 -07: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
Izumi Hoshino
5c76f50117
Farmer now returns missing signage points (#15765)
* Farmer now returns missing signage points

* Added test

* Fixed lint error

* Ignored strange pylint behavior

* Fixed lint error

---------

Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-07-18 21:04:03 -05:00
Izumi Hoshino
e772e4ff69
Improved pool stats handling (#15764)
* Improved pool stats handling

* Minor update

* Made `increment_pool_stats` free function

* Updated `increment_pool_stats` function args

* Fixed isort issue

* WIP: Adding test cases

* Fixed lint error

* Fixed lint error 2

* Fixed lint error 3

* Added test case
2023-07-17 15:39:00 -05:00
Izumi Hoshino
15fa5f3764
Added quality lookup time info to FarmingInfo (#15775) 2023-07-14 14:23:34 -05:00
Arvid Norberg
cecda28e84
Plot filter hard fork (#15336)
* update passed_plot_filter() to take the filter size rather than consensus constants. This allows the filter size to change by block height. make verify_and_get_quality_string() take either the height or filter size

* Add some filter_prefix_bits tests on test blocks.

* Add some filter_prefix_bits tests on simulated farmer and harvester.

* Cache filter prefix bits by challenge chain signage point hash and use that for the the lookups. This allows us to perform plot filter validation.

* Add more cases to verify_and_get_quality_string() unit tests.

* Add some tests for Farmer's respond_signatures.

* Apply Kevin's suggestion to simplify the check for passing plot filter.

* Apply Kevin's suggestions to simplify some test checks and fix a couple typos.

* Apply Kevin's suggestion to send peak height instead of filter prefix bits as part of NewSignagePoint.

* Remove no longer needed filter prefix bit related logic and make height non optional in verify_and_get_quality_string().

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2023-07-12 10:26:23 -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
Amine Khaldi
cf4fffdbea
Annotate farmer/farmer_api.py (#15347)
Annotate farmer/farmer_api.py.
2023-05-23 05:34:53 -05:00
wjblanke
f2785201bd
Changed: output plotid when we find an invalid proof of space (#15257)
* output plotid when we find an invalid proof of space

* fix
2023-05-11 19:06:17 -05:00
dustinface
f0006b5353
server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
Kyle Altendorf
c5d7339bd5
hint chia.farmer.farmer (#14687)
* hint chia.farmer.farmer

* we will update mypy.ini later
2023-02-28 03:05:08 -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
Adam Kelly
9f0220771f
Limit rate of log messages when farmer is disconnected from pool (#14344)
* Limit rate of spammy log messages when farmer is disconnected from pool

* Remove typo

* Use reliably increasing clock

* Make test faster, more reliable
2023-01-23 16:43:42 -06:00
Earle Lowe
062dde7e24
Check for valid timeout and log error (#14304)
* Handle edge case for missing pool state

* add proper check

* Switch to error from warning
2023-01-12 01:09:03 -06:00
dustinface
a40f04012b
server: Replace WSChiaConnection.__getattr__ with call_api (#14052) 2022-12-13 00:35:42 -06:00
Arvid Norberg
27cbd08229
Factor out member functions of ProofOfSpace to be free functions (#13930) 2022-11-17 13:46:22 -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
Mariano Sorgente
e314040d8d
No network type (#12783)
* No network type

* Use selected network

* remove NETWORK_TYPE

* Don't warn on invalid key, and remove from config

* Remove bytes32

* Put back the warning log
2022-08-05 13:53:02 -05:00
dustinface
4611d0aa43
util: Move all keychain related errors into chia.util.error (#12756)
Also derive them from `KeychainException` and name them consistently.
2022-08-05 02:05:58 -05:00
dustinface
2a36f950d4
farmer: Handle KeychainProxyConnectionFailure in Farmer.setup_keys (#12135) 2022-06-28 11:52:48 -05:00
dustinface
0d5251c3a7
farmer|gui: Enable paginated plot loading and improved state reporting (#11367)
* farmer: Adjust notifications from the farmer to the UI

- Only send the data for the harvester which actually sent an update
- Notify for each loaded batch during initial loading

* Enable improved farmer/harvester GUI
2022-05-03 15:33:38 -07:00
dustinface
d00d045d9c
farmer|rpc|tests: Implement paginated harvester plot endpoints (#11365)
* farmer|rpc|tests: Implement paginated harvester plot endpoints

* Simplify filtering

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

* Let the API handle the exceptions

* Simplify the other filtering too

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

* Simplify count assertions

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

* Refactor `is_filter_match` to `plot_matches_filter`

And just convert to `Plot` in tests.

* Move `chia.util.misc.KeyValue` to `chia.rpc.farmer_rpc_api.FilterItem`

* Rename `peer_id` to `node_id` to be match `get_harvesters_{summary}`

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-05-03 09:17:05 -07:00
dustinface
b693aeb407
farmer|rpc: Introduce get_harvesters_summary RPC endpoint (#11245) 2022-04-28 19:36:21 -07: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
Earle Lowe
cb98258a8e
Check observer addresses (#11259) 2022-04-21 16:59:11 -07:00
dustinface
ee3bf4f866
farmer: Enable isort (#11128) 2022-04-20 11:37:46 -07:00
dustinface
f27cba07b0
farmer: Introduce UPDATE_POOL_INFO_FAILURE_RETRY_INTERVAL (#11076)
Retry to load the pool info with a 2 minutes interval if it failed.
2022-04-20 11:13:07 -07:00
dustinface
ded9f68583
chia|tests|github: Implement, integrate and test plot sync protocol (#9695)
* protocols|server: Define new harvester plot refreshing protocol messages

* protocols: Bump `protocol_version` to `0.0.34`

* tests: Introduce `setup_farmer_multi_harvester`

Allows to run a test setup with 1 farmer and mutiple harvesters.

* plotting: Add an initial plot loading indication to `PlotManager`

* plotting|tests: Don't add removed duplicates to `total_result.removed`

`PlotRefreshResult.removed` should only contain plots that were loaded
properly before they were removed. It shouldn't contain e.g. removed
duplicates or invalid plots since those are synced in an extra sync step
and not as diff but as whole list every time.

* harvester: Reset `PlotManager` on shutdown

* plot_sync: Implement plot sync protocol

* farmer|harvester: Integrate and enable plot sync

* tests: Implement tests for the plot sync protocol

* farmer|tests: Drop obsolete harvester caching code

* setup: Add `chia.plot_sync` to packages

* plot_sync: Type hints in `DeltaType`

* plot_sync: Drop parameters in `super()` calls

* plot_sync: Introduce `send_response` helper in `Receiver._process`

* plot_sync: Add some parentheses

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

* plot_sync: Additional hint for a `Receiver.process_path_list` parameter

* plot_sync: Force named parameters in `Receiver.process_path_list`

* test: Fix fixtures after rebase

* tests: Fix sorting after rebase

* tests: Return type hint for `plot_sync_setup`

* tests: Rename `WSChiaConnection` and move it in the outer scope

* tests|plot_sync: More type hints

* tests: Rework some delta tests

* tests: Drop a `range` and iterate over the list directly

* tests: Use the proper flags to overwrite

* test: More missing duplicates tests

* tests: Drop `ExpectedResult.reset`

* tests: Reduce some asserts

* tests: Add messages to some `assert False` statements

* tests: Introduce `ErrorSimulation` enum in `test_sync_simulated.py`

* tests: Use `secrects` instead of `Crypto.Random`

* Fixes after rebase

* Import from `typing_extensions` to support python 3.7

* Drop task name to support python 3.7

* Introduce `Sender.syncing`, `Sender.connected` and a log about the task

* Add `tests/plot_sync/config.py`

* Align the multi harvester fixture with what we do in other places

* Update the workflows

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-04-07 17:10:44 -07:00
Jeff
d35c414c09
Set keychain_proxy to None in await_closed() to support reinitialization (#11075)
* Set keychain_proxy to None in await_closed() to support reinitialization.

* Added `shutting_down` param to _await_closed() to control whether the keychain_proxy is closed.
2022-04-06 20:14:49 -07:00
Jack Nelson
9b7d7d2555
Remove websockets dependency & do some refactoring (#10611)
* remove old ws
2022-04-05 10:19:09 -07:00
Kyle Altendorf
e0a1fc4eaf
Switch to integrated lock_and_load_config() context manager (#10698)
* minor lock scope reduction

* use the lock in tests

* Use the passed root_path in configure CLI command

* switch to lock_and_load_config()

* oops

* cleanup

* make _load_config_maybe_locked() private

* black

* Remove future improvement opportunity TODO comment
2022-03-28 12:52:51 -07:00
Kyle Altendorf
48cd97cf47
minor followup to config locking (#10696)
* minor lock scope reduction

* use the lock in tests
2022-03-17 09:03:58 -07:00
Kyle Altendorf
dbeff36ae0
Add configuration locking (#10680)
* Add configuration locking

Extracted from https://github.com/Chia-Network/chia-blockchain/pull/10631

* note that fasteners will likely be replaced by filelock

* Fix test_multiple_writers on macOS

* create_all_ssl() doesn't need to be inside the config access lock

* add warnings about not using async within get_config_lock() get lock contexts

* no need to pre-touch the lock file

* .yaml.lock instead of just .lock

* test_multiple_writers() is sync

* Revert "add warnings about not using async within get_config_lock() get lock contexts"

This reverts commit 681af3835b.

* reduce lock context size in chia_init()

* use an exit stack in load_config()

* avoid config existence precheck

* only lock around the read in load_config()

* do not raise e, just raise

* tidy new imports

* fix queue empty check in test_config.py

* remove commented out code in test_config.py

* remove unused import

Co-authored-by: Jeff Cruikshank <jeff@chia.net>
2022-03-12 06:52:47 -08:00
dustinface
695d9f7ef0
farmer: Cleanup request retry and some logs (#10484)
* farmer: Bump next update times regardless of the request results

* farmer: Drop additional "success/failure" log logic

We already print the PUT response in `_pool_put_farmer` the other parts 
just lead to confusion if the pool didn't implement the PUT correct.

* farmer: Print error responses from the pool with `WARNING` log level
2022-03-01 13:11:21 -05:00
dustinface
55c4eb3d28
farmer: Send a PUT /farmer if the signature verification failed (#10364)
Due to the bug which was fixed in #9922 some pools obviously still have 
incorrect authentication public keys from their farmers. This PR is to 
make sure that the farmers update their authentication public key on the 
pool if they get an `INVALID_SIGNATURE` response error from a `GET 
/farmer`.
2022-02-24 08:46:28 -05:00
dustinface
2ba0b9f41d
farmer: Log POST/PUT requests data with DEBUG log level (#10405) 2022-02-23 22:29:50 -05:00
Mariano Sorgente
e1e779ee3c
Add auth key back (#10374)
* Add auth key back

* PK not SK
2022-02-22 12:34:53 -08:00
dustinface
b229211ea5
farmer: Move some member instantiations into Farmer.__init__ (#10179) 2022-02-11 12:34:34 -08:00
dustinface
ed70c2663a
farmer: Wait until xch_target_address is in the config in setup_keys (#10185)
* farmer: Wait until `xch_target_address` is in the config in `setup_keys`

* farmer: Reload config in `setup_keys` before `xch_target_address` checks
2022-02-11 12:33:53 -08:00
Mariano Sorgente
34edf6e35e
pool_wallet: Deterministic derivation of auth key, and only count poo… (#9922)
* pool_wallet: Deterministic derivation of auth key, and only count poolWallets for indeces

* cli: Use the same limit for cli creation

* farmer: no more auth keys in config

* farmer: handle case of no authentication sk

* farmer: remove async, and fix test

* lint

* test: Add a test for many pool wallets, and user store

* test: Wait for wallet to be synced in test

* wallet: fix startup (no dns servers) and change to server checking of plotnfts

* cli: change to server checking

* tests: fix user store test

* Improve caching

* PR comments

* Remove useless class

* Try to fix test again
2022-01-30 12:31:55 -05:00
Earle Lowe
142b0c5c5b
Safer check for pool_list in config (#9810)
* Safer check for pool_list in config

* safer pool_list check
2022-01-19 11:35:24 -08:00