Commit Graph

207 Commits

Author SHA1 Message Date
Arvid Norberg
afae2ad5fe
make recurse_jsonify() work directly on types (#11537)
* make recurse_jsonify() work directly on types, circumventing the dataclasses.asdict() step. This enables simpler integration of non dataclasses into the Streamable and JSON protocols

* add benchmark for Streamable.to_json_dict()
2022-05-18 09:15:03 -07:00
Mariano Sorgente
31ed32628f
Optimize code to not perform useless subgroup checks (#11546)
* Optimize code to not perform useless subgroup checks

* Revert less important optimizations
2022-05-18 09:09:56 -07:00
Mariano Sorgente
56e6e68eb3
Uses the new from_bytes_unchecked method in blspy, to improve perfo… (#11463)
* Uses the new `from_bytes_unchecked` method in blspy, to improve performance

* Update test

* Fix merge conflict

* Use from_bytes_unchecked in post_init and from_json

* More uniform code
2022-05-16 09:49:50 -07:00
Kyle Altendorf
7c91f470f4
simplify SizedBytes and StructStream (#11429)
* simplify SizedBytes and StructStream

* lint

* super()  !!!

* do not pass parameter up to super().__init__()

* Update chia/util/struct_stream.py

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

* parse fixed-width int data from class name

* add int512 and uint128 .from_bytes(), test .parse() failures

* test serialization against struct.pack()

* use typing_extensions for final

* override ignore

* stop using struct for StructStream

oh the irony

* fixup .to_bytes() to accept parameters again for where we use that

* bring back signed parameter

* format

* adjust tests for new exception

* eliminate custom coding for uint128 and int512

* tidy

* remove unused StructStream.PACK attribute

* add direct tests for parse_metadata_from_name()

* stricter hinting

* remove no-longer-needed typeshed work-around

* apply strict type checking to all touched files

* remove StructStream override of .to_bytes()

* tidy

* types touchup

* add unused parameter comments

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
Co-authored-by: wjblanke <wjb98672@gmail.com>
2022-05-14 02:05:27 -07:00
Adam Kelly
298ea9ea20
Resend transactions (#11167)
* Resend transactions

* Don't recheck transactions more frequently than timeout

* Add wallet resend parameter to config, move timeout code out of tx store, but close to call site

* Add a test for wallet transaction resend

* Add test for wallet retry

* isort new files for precommit and update workflows

* Use correct fixture name

* LGTM - remove unused import

Co-authored-by: Earle Lowe <e.lowe@chia.net>
2022-05-14 02:03:10 -07:00
Kyle Altendorf
6788c0a5ef
Use context manager for locking clvm files (#11467) 2022-05-10 04:41:57 -07:00
dustinface
541b99e311
harvester: Introduce recursive_plot_scan (#11468)
* harvester: Introduce `recursive_plot_scan`

* Change log and merge boths lookups

* Drop redundant assignments
2022-05-09 16:43:53 -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
Arvid Norberg
340e26e154
simplify merkle set (#11416)
* _make_middle doesn't need to be a member function

* add some unit tests
2022-05-03 07:49:29 -07:00
dustinface
984c442b5e
util: Implement Paginator class as interface to access a list by pages (#11247)
* util: Implement `Paginator` class as interface to access a list by pages

* Be less restrictive about page sizes and refactor tests

* Make the pages based of 0 instead of 1 and some more test refactoring

* More tests

* Adjust workflows after rebase

* Introduce `Paginator.create`

* `<=` instead of `- 1`
2022-04-29 18:35:47 -07:00
Arvid Norberg
d3f2ae367d
remove unused functions on MerkleSet (#11362) 2022-04-29 08:17:37 -07:00
dustinface
b693aeb407
farmer|rpc: Introduce get_harvesters_summary RPC endpoint (#11245) 2022-04-28 19:36:21 -07:00
Mariano Sorgente
7630d220f5
Optimize BLS verification when public key is repeated (#11318)
* Optimize BLS verification when public key is repeated

* Fix accidental commit

* Lint

* Fix isort

* Address comments
2022-04-27 11:38:48 -07:00
dustinface
c0f3d4d231
daemon|util: Don't remove from list while iterating (#11208)
* daemon: Iterate over a copy of `websockets`

Currently when it fails to send the response to one websocket it skips 
the next websocket in list becaue we remove from the list while 
iterating.

* util: Iterate over a copy of `peers_with_peak`

Currently when a peer is closed it skips the check for the next peer in 
the list becaue we remove from the list while iterating.
2022-04-22 10:55:57 -07:00
Kyle Altendorf
1088801e73
Remove code related to no-longer-used websockets library (#11123)
* Remove logging tweak for no-longer-used websockets library

Follow up after https://github.com/Chia-Network/chia-blockchain/pull/10611.

* Update pylintrc

* Update test_daemon.py
2022-04-20 11:18:42 -07:00
dustinface
79cbadf987
streamable: Enable isort + more mypy (#10539)
* isort: Fix `streamable.py` and `test_streamable.py`

* mypy: Drop `streamable.py` and `test_streamable.py` form exclusion

And fix all the mypy issues.

* Fix `pylint`

* Introduce `ParseFunctionType` and `StreamFunctionType`

* Use `object` instead of `Type[Any]` for `is_type_*` functions

* Some `Any` -> `object`

* Use `typing.overload` for `recurse_jsonify`

* Move some comments

* Drop `Union`, use `Literal` properly

* Explicitly ignore the return of `f_type.parse`

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

* Merge two `recurse_jsonify` overloads

* Typing for the base definition of `recurse_jsonify`

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-04-20 11:09:41 -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
Arvid Norberg
21fb6f260e
transition to using chia_rs module (#11094) 2022-04-08 09:37:10 -07:00
Arvid Norberg
fe77c69018
run_generator2 rust call and compact conditions data structure (#8862)
* use run_generator2 rust call and compact spend bundle conditions data structure pervasively.

* address review comments
2022-04-04 11:53:13 -07:00
dustinface
62de4a883c
streamable|pools: Fix Optional parsing in dataclass_from_dict (#10573)
* Test more `Optional` parsing in `dataclass_from_dict`

* Fix optional parsing in `dataclass_from_dict`

* Fix pool wallet / tests
2022-04-04 11:50:59 -07:00
Mariano Sorgente
890c7d3754
Fix remaining linting issues (#10962)
* FIx remaining linting issues

* Revert type:ignore

* Revert token_bytes change
2022-04-02 13:22:55 -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
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
Adam Kelly
efcf0cf0ad
await the db commit in the async version of set_db_version (#10906) 2022-03-28 12:48:14 -07:00
Arvid Norberg
1bcf409ee1
single thread executor (#10919)
* add inline executor and an option to run single-threaded

* add option to run test_full_sync in single-thread mode, to include block validation in profiles. Also attempt to speed it up by disabling db_sync
2022-03-28 12:47:46 -07:00
Arvid Norberg
a100dda37e
new DBWrapper supporting concurrent readers (#10166)
* new DBWrapper supporting concurrent readers

* adress review comments

* fixup default database version, when file doesn't exist

* remove unused argument
2022-03-28 11:58:00 -07:00
Arvid Norberg
ba6eb6af3d
when creating a new blockchain database implicitly, make it v2 (#10498)
* when creating a new blockchain database implicitly, make it v2

* fix config deadlock
2022-03-17 09:09:26 -07:00
arty
4bd8498e5a
Enable clvm_tools_rs by default (#10554)
* Enable clvm_tools_rs by default

* Re-add clvm_tools dep for now as it provides python idioms for interacting with clvm data

* Take lint formatting

* Adam: Try making this non-parallel

* Try fix for threading issue in tests

* Test whether turning off parallel runs causes things to work (temp)

* Test use of temp files in clvm_tools_rs as a candidate solution for atomic replacement of hex output

* Use proper git+https url scheme (oops)

* Update to candidate 0.1.6 so we can test

* Revert version bump to re-test

* Test whether we can re-enable parallelism

* Attempt to mitigate concurrent test running: return own conception of the compiled output.  This will work if the failing path is downstream of recompilation

* fix path to hex file

* Probe for source of 0-length data

* Further exploration: more assertions, hopefully to trigger in the test on ci

* Do an even more paranoid check to verify that we observe a file whose filesystem reported size is much smaller than expected

* Try a heavier handed approach, using heavyweight lockfiles on the filesystem

* Import a simple lockfile implementation and use it to enforce mutual exclusion.  Simplify it and remove the unwanted os traffic

* Take lint, precommit advice, bump to clvm_tools_rs 0.1.6 now that it's released

* Fix lint

* While i was working on this, -n auto was on the command line so i think this didn't actually do anything, but reverting my change just in case

* Lint

* label the hashes re: pr

* Add a lock.py for spot exclusivity using the filesystem (re: adam in the pr) and a convenience wrapper that hides the details

* Formatting warning

* Ensure type info is present and do the obvious return of the inner function's result

* Use double quotes (lint)

* Properly balance blank lines

* Lint: alphabetize imports

* One line is required here (lint)

* Remove unnecessary assignment
2022-03-17 09:08:36 -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
Jeff
75ed1307e5
Fix exception when chia keys migrate is run without needing migration (#10655)
* Fix exception when `chia keys migrate` is run without needing migration

* Linter fixes
2022-03-11 16:23:24 -08:00
Johannes Tysiak
e8ff5a32a7
fix initial-config typo - log_maxbytesrotation (#10598) 2022-03-10 11:10:28 -08:00
Juraj Oršulić
05f9667018
Allow CAT autodiscovery, refactor CAT default naming (#10308)
* Allow CAT autodiscovery

* Add wallet autodiscovery test

* Use dict get for automatically_add_unknown_cats with default false

* Refactor name generation for new CATs into one place

* Remove hardcoded default cat wallet name from wallet rpc test

* initial-config.yaml comment nit
2022-03-04 08:27:15 -08:00
Kyle Altendorf
c6978f07b1
correct multiprocessing start method logging, add python_default (#10547)
* correct multiprocessing start method logging, add python_default

* todo -> regular comment
2022-03-04 07:46:54 -08:00
Kyle Altendorf
50857caf8c
make multiprocessing start method configurable (#10528)
* make multiprocessing start method configurable

* forkserver

* corrections

* fixup

* optional

* more optional

* stop attempting anchors in the yaml

* rework config handling

* comment
2022-03-03 10:27:36 -08:00
dustinface
fdb993cb10
streamable: Cache stream functions (#10419)
Apply the same pattern as we have for deserialization to serialization.

This avoids all those recursive runtime lookups for "how to stream this
object" which brings a nice speedup:

```
compare: benchmark
mode         | µs/iteration old | µs/iteration new | diff %
to_bytes     | 447.57           | 193.56           | -56.75

compare: full_block
mode         | µs/iteration old | µs/iteration new | diff %
to_bytes     | 110.32           | 61.09            | -44.62
```
2022-02-25 08:07:24 -08:00
Arvid Norberg
874cc23c71
add db validate function to check consistency of blockchain database (#10398) 2022-02-25 08:00:16 -08:00
Kyle Altendorf
89740234e7
spawn (not fork) for multiprocessing (#10322)
* spawn (not fork) for multiprocessing

* just append _worker to existing process names

* return properly in getproctitle()

* black

* ignore for unhinted getproctitle()

* Add comments about the setting of the multiprocessing start method
2022-02-24 20:08:06 -08:00
dustinface
8eb2a29834
streamable: Enable flake8 and pylint (#10355) 2022-02-22 12:42:05 -08:00
Arvid Norberg
58019afd5b
chunk coin_store request into smaller sql queries (#10359)
* chunk coin_store request into smaller sql queries, to not exceed the limit of 999 on old versions of sqlite

* extend tests for chunks
2022-02-21 20:07:05 -08:00
Patrick Maslana
e35174c268
Fixed two typos in the initial-config.yaml (#10357)
* Fixed two typos in the initial-config.yaml

* Changed the letter case for a word.
2022-02-21 09:19:47 -08:00
Kyle Altendorf
e3fb3ce96e
Move black from SuperLinter to upload workflow, use 21.12b0 in pre-commit (#10103)
* black==21.12b0 in pre-commit

Match `setup.py`.

* move black from super linter to upload workflow

* black (updated)

* configure so black . works

* --check --diff for black
2022-02-20 21:33:09 -08:00
dustinface
3608d25c80
type_checking: Drop some redundant None checks (#10334) 2022-02-20 21:30:57 -08:00
Amine Khaldi
b544e75cd7
Align the wallet node's weight proof timeout with the full node's value. (#10341)
* Align the wallet node's weight proof timeout with the full node's value.

* Give the wallet config its own weight_proof_timeout value.

* Apply Kyle's cleaner version.

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

* Apply Kyle's anchors suggestion.

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-02-20 21:28:43 -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
Kyle Altendorf
47a0a9101c
apply isort (#10280) 2022-02-17 19:46:51 -08:00
Kyle Altendorf
f6e479cc07
Improve StructStream hints to support decimal and other parameters like int itself (#9949)
* Improve StructStream hints to support decimal and other parameters like int itself

* get SupportsIndex from typing_extensions
2022-02-17 07:35:13 -08:00
Arvid Norberg
34159d3529
optimize get_block_generator() (#10104)
* optimize get_block_generator()

* add a v1 compatible get_generator() to speed up get_block_generator() with v1 databases. Add test. Add error log in case generator_from_block() fails.

* speed up test_full_block_utils
2022-02-17 07:32:29 -08:00
Kyle Altendorf
cc63c7017b
Remove deprecated initial_num_public_keys_new_wallet from initial-config.yaml (#10221)
231ef6faf2/CHANGELOG.md
> Fixed issues where the wallet code would not generate enough addresses when looking for coins, which can result in missed coins due to the address not being checked. Deprecated the config setting initial_num_public_keys_new_wallet. The config setting initial_num_public_keys is now used in all cases.
2022-02-14 12:53:47 -08:00
Kyle Altendorf
884ebd902b
remove chia.util.clvm pass-through file (#10130)
* remove chia.util.clvm pass-through file

* in tests too
2022-02-14 12:52:14 -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