Commit Graph

275 Commits

Author SHA1 Message Date
Kyle Altendorf
d4ccfa1a9b
Merge commit 'ce533879e25a536b6414307c4e6d850c1da06d4f' into atari-merge_main_ce533879e25a536b6414307c4e6d850c1da06d4f 2022-03-14 19:03:45 -04:00
Kyle Altendorf
b81518e4a7
Provide default for when rpc_server_max_request_body_size is not specified 2022-03-14 14:45:42 -04:00
Kyle Altendorf
e79768ede6
Merge commit '98971de9d525e1de323ecb09f0777cca6286f932' into atari-merge_main_98971de9d525e1de323ecb09f0777cca6286f932 2022-03-10 21:26:45 -05:00
Kyle Altendorf
c065420042
black 2022-03-06 09:32:23 -05:00
Kyle Altendorf
4d5858a2af
Add configurable request size limit for data layer service 2022-03-06 08:53:06 -05:00
Kyle Altendorf
af163a1c5b
Merge commit '87aeadc34310eb86aa0bd56f4eb00f84cc9563b2' into atari-merge_main_87aeadc34310eb86aa0bd56f4eb00f84cc9563b2 2022-03-01 17:59:11 -05:00
Kyle Altendorf
95c5213fbb
Merge commit 'ca84fa9f8d332687534399fc824d6017effaed2e' into atari-merge_main_ca84fa9f8d332687534399fc824d6017effaed2e 2022-03-01 15:27:25 -05:00
Mariano Sorgente
e8475fb194
GC connections in wallet (#10450) 2022-02-26 18:31:10 -05:00
Mariano Sorgente
c844016019
Improve trusted sync performance (#10377)
* Improve trusted sync performance

* Fix broken CLI

* Decrease timestamp cache size

* Add all valid states at the right time
2022-02-22 18:37:51 -08:00
Arvid Norberg
29bd136238
name processes we spawn in tests with a test_ prefix, to make it easier and find and kill them in case they're left running (#10318) 2022-02-19 12:39:17 -08:00
Kyle Altendorf
9a3194599d
do not enable signals on services in tests (#10290) 2022-02-18 07:49:19 -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
Mariano Sorgente
52e439ccbe
Ms.sync cancel (#10244)
* Start fixing other issues

* Fork point, sync cancelling, random peer

* Reduce logging

* Improve performance and have a fallback peer for fetching

* Disconnect not synced peers

* Make sure try catch doesn't fail

* Fix lint

* Update chia/wallet/wallet_node.py

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

* Pylint has a bug so ignore pylint for this line

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-02-17 13:35:41 -08:00
Kyle Altendorf
767974cb93
reinstate pre-existing signal configuration on windows for services (#10263) 2022-02-16 15:26:03 -08:00
Kyle Altendorf
220e845d51
shutdown the weight proof process pool (#10163)
* shutdown the weight proof process pool

* use a context manager for the weight proof process pool executor

* record of the debug code

* mostly cleaned up

* suppress sync task cancellation propagation when awaited while closing

* breakup multi-second WeightProofHandler.validate_weight_proof with async sleeps

* move awaiting of sync task until after existing cancellation

* properly handle shutdown file with a new instance each time and a context manager

* cleanup
2022-02-15 12:22:23 -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
Kyle Altendorf
5b7f46fca7
simplify new peak timeout (#10053)
* simplify new peak timeout

* correct to asyncio.TimeoutError
2022-02-02 17:13:06 -08:00
Yostra
ca84fa9f8d
Sync improvements (#9974)
* stash

* change log level

* stash changes

* cat tests

* add node id chia show

* make max sibscribe items configurable

* lint

* add logs for limits

* paralelize incluzion valdiation, don't diconnet from remote peers until local peer in synced

* wallet rate limit

* test log lvl, trusted, black

* only validation under semaphore

* flake mypy trade test

* reduce flakyness

* merge fix

* rename

* linting

* validate parallel, apply serial

* reduce falkyness

* lint

* Fix CAT tests

* black

* flaky test, total amount

* fix cat test

* skip existing state

* skip existing

* try other caches

* flake8

Co-authored-by: Matt Hauff <quexington@gmail.com>
Co-authored-by: William Blanke <wjb98672@gmail.com>
2022-01-28 19:16:47 -08:00
almog
7379a2f0ac
fix get roots test
lint
2022-01-21 14:35:41 +02:00
almog
a866fa62ec
use bt in dl rpc tests 2022-01-20 21:18:35 +02:00
almog
2914bcdd97
lint 2022-01-20 19:47:13 +02:00
almog
57cc29ea73
init wallet rpc in data service test 2022-01-20 18:11:17 +02:00
almog
f2fe296ace
init wallet rpc in data service 2022-01-20 15:15:59 +02:00
almog
cebcb6a4ca
use wallet rpc inside data_layer 2022-01-20 15:08:36 +02:00
Kyle Altendorf
4453f32363
Merge commit '2acf03e850fb883dc6ca5a554f5f827097157ac1' (latest main) into atari-merge_main_2acf03e850fb883dc6ca5a554f5f827097157ac1 2022-01-19 10:37:04 -05:00
Matt Hauff
6e899f5992
Merge commit '89f15f591cc3cc3e8ae40e95ffc802f7f2561ece' into atari-merge_main_89f15f591cc3cc3e8ae40e95ffc802f7f2561ece 2022-01-14 20:11:22 -07:00
Kyle Altendorf
2a79868a61
Merge commit '0ba838b7a8ea2b5410d438ac70295df699a30dae' (main) into atari-merge_main_0ba838b7a8ea2b5410d438ac70295df699a30dae 2022-01-14 19:21:13 -05:00
Chris Marslender
516f5639db
Add testnet10 config (#9805)
* Add testnet10 config

* Add testnet10 to missed files

Co-authored-by: Jack Nelson <jack@jacknelson.xyz>
2022-01-13 13:13:05 -08:00
Yostra
89f15f591c
Merge standalone wallet into main (#9793)
* wallet changes from pac

* cat changes

* pool tests

* pooling tests passing

* offers

* lint

* mempool_mode

* black

* linting

* workflow files

* flake8

* more cleanup

* renamed

* remove obsolete test, don't cast announcement

* memos are not only bytes32

* trade renames

* fix rpcs, block_record

* wallet rpc, recompile settlement clvm

* key derivation

* clvm tests

* lgtm issues and wallet peers

* stash

* rename

* mypy linting

* flake8

* bad initializer

* flaky tests

* Make CAT wallets only create on verified hints (#9651)

* fix clvm tests

* return to log lvl warn

* check puzzle unhardened

* public key, not bytes. api caching change

* precommit changes

* remove unused import

* mypy ci file, tests

* ensure balance before creating a tx

* Remove CAT logic from full node test (#9741)

* Add confirmations and sleeps for wallet (#9742)

* use pool executor

* rever merge mistakes/cleanup

* Fix trade test flakiness (#9751)

* remove precommit

* older version of black

* lint only in super linter

* Make announcements in RPC be objects instead of bytes (#9752)

* Make announcements in RPC be objects instead of bytes

* Lint

* misc hint'ish cleanup (#9753)

* misc hint'ish cleanup

* unremove some ci bits

* Use main cached_bls.py

* Fix bad merge in main_pac (#9774)

* Fix bad merge at 71da0487b9

* Remove unused ignores

* more unused ignores

* Fix bad merge at 3b143e7050

* One more byte32.from_hexstr

* Remove obsolete test

* remove commented out

* remove duplicate payment object

* remove long sync

* remove unused test, noise

* memos type

* bytes32

* make it clear it's a single state at a time

* copy over asset ids from pacr

* file endl linter

* Update chia/server/ws_connection.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: Matt Hauff <quexington@gmail.com>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2022-01-13 12:08:32 -08:00
Earle Lowe
34d44c1324
Limit server to TLS 1.2 and set cipher list (#9195)
* Limit server to TLS 1.3 (also ran isort)

* Set minimum to TLS1.2 and add warning
2022-01-10 21:02:23 -08:00
dustinface
b76b75f317
farmer|server|tests: Fix for farmer service crash if the keychain is empty (#9515)
* farmer: Run a start background task to wait if there are no keys yet

* farmer: Run the handshake in a background task if there are no keys yet

* tests: Yield the service in farmer/harvester setups

* tests: Introduce `start_service` in farmer/harvester setups

* server: Make `ChiaServer` and `Service` restartable

* tests: Test the delayed start/handshake in `test_farmer_harvester.py`

* tests: Move `test_farmer_harvester.py` to `tests/core/farmer_harvester`

Attempt to avoid issues due to the global block tools / shared keychain 
between tests

* farmer: Return `bool` in `Farmer.setup_keys`

* tests: Add `__init__.py` to `tests/farmer_harvester`
2021-12-14 18:03:59 -08:00
Kyle Altendorf
bd0ecc1646
Merge branch 'main' into atari-merge_main_a3c79c939da2f65ec1fc5a6c9423ffae1e63cccd 2021-12-14 11:14:10 -05:00
Earle Lowe
7d801144ea
Add TLS version to collected crawler stats (#9534) 2021-12-13 08:40:22 -08:00
Kyle Altendorf
759b173e7d
stricter hints 2021-12-09 12:13:48 -05:00
Kyle Altendorf
d17ce9efab
Merge branch 'main' into atari 2021-12-07 21:39:10 -05:00
Kyle Altendorf
8291f0221a
Make the sized bytes types hint compatible (#9369)
* Rework sized bytes for type hinting compatibility

* add a bunch of type: ignores

* this will be handled elsewhere

* noqa E501 instead of changing code

* normalize comment plurality

* @classmethod

* Revert "@classmethod"

This reverts commit 95db80e339.

* add ignore in benchmarks

* just E501 again...

* add some new type: ignores
2021-12-02 09:43:39 -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
Kyle Altendorf
b1abc3df26
Merge branch 'main' into atari 2021-11-27 19:43:42 -05:00
dustinface
b89d958108
server: Drop reply_to_request and use send_message instead (#9327)
It's doing the same thing.
2021-11-24 11:28:24 -08:00
Kyle Altendorf
1073f9d5dd
mypy: warn_unused_ignores = true (and remove some) (#9085)
* mypy: warn_unused_ignores = true (and remove some)

* catch up

* type checking tweaks

* precommit uses mypy --no-warn-unused-ignores

* revert a bit

* precommit explanatory comment

* Update .pre-commit-config.yaml

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-11-23 12:44:53 -08:00
Kyle Altendorf
04969f1a71
Merge branch 'main' into atari 2021-11-22 22:04:41 -05:00
Chris Ross
2c4aaa1ec9
Resolve v6 addresses (#8861)
* Address deficiency discussed in #8552, add ability to resolve to IPv6
addresses for hostnames.

* If there is no prefer_ipv6 in the config, set it True (per @hoffmang9)
and write it back to config.yaml

* Pass prefer_ipv6 flag to get_host_addr, which required a little digging
for it in a few places that call get_host_addr.

* Update a couple things for consistency

* Move the load_config into Wallet's __init__ so it doesn't get called so
many times as it would in has_full_node.

* Pass None into get_host_addr if there's no preference in config, so we have only that one place where the coded default lives.  also fix an oversight where we were building a PeerInfo from a PeerInfo in some cases.

* Change the default here to match the default coded into util/network.py.  It seems that github testers can't handle trying to use IPv6 and this may be easier for average users (sadly)

* A test to see if manually creating the server on :: (IP6_ANY) lets tests connect to localhost with IPv6 on

* Revert back to IPv4 default and remove the override inserted into
TCPSite for testing.

* Don't test for ip6-localhost, as it's not on all systems.

* Bah.  Forced formatting of commented code...

* Add a type annotation for the addrset variable

* If we don't quote the socket enums, pylint gets upset because it has issues figuring out where/how they're defined.  So, quote them here.

Co-authored-by: Chris Ross <cross+chia@distal.com>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2021-11-22 14:34:03 -08:00
Kyle Altendorf
a6e58c9855
Merge branch 'main' into atari 2021-11-22 14:24:00 -05:00
dustinface
f8e8edc567
server: Refine return value of WSChiaConnection.send_message (#9305) 2021-11-19 11:13:50 -08:00
Jeff
c4e14f5c78
Peer db new serialization (#9079)
* Serialize/deserialize peer data alongside existing sqlite implementation (to be removed)

* Simplified AddressManagerStore. No longer uses sqlite and is no longer async.

* Removed aiosqlite usage from AddressManagerStore.
Added PeerStoreResolver class to determine the appropriate location for "peers.dat"
Updated initial-config.yaml to include "peers_file_path" default, replacing "peer_db_path" (similar change for "wallet_peers_path")

* Minor comment changes/additions

* Added migration from sqlite peer db.
Made AddressManagerStore's serialization async as it was right at the edge of blocking for too long.

* Minor tweaks to checking for migration

* Removed AddressManagerSQLiteStore class scaffolding

* makePeerDataSerialization now returns bytes instead of a PeerDataSerialization object

* Async file I/O for write_file_async using aiofiles
Added more tests

* Separate out the synchronous part of move_file

* Renamed write_file to files since we're opening up the capabilities a bit

* Update references to write_file

* Renamed test_write_file to test_files

* Tests covering move_file and move_file_async

* Minor refinements to behavior and tests

* Use aiofiles for reading peers.dat

* Added missing mypy typing info for aiofiles. Also added types-PyYAML to dev_dependencies so that `mypy chia tests` doesn't require running with --install-types

* Add types-aiofiles to the linting workflow

* Directory perms can now be passed into write_file_async.
Added an explicit f.flush() followed by os.fsync() after writing the temp file contents.
2021-11-19 11:12:58 -08:00
Kyle Altendorf
f2c5ed3b4a
lint 2021-11-19 09:37:11 -05:00
Kyle Altendorf
5bd8b3dbaa
Merge branch 'main' into atari 2021-11-11 08:57:35 -05:00
Florin Chirica
13a49c7a2e
Fix wallet gossip. (#8709)
* Increase wallet sleep.

* Fix wallet gossip.

* Type checking.

* Add callable.

* Address comment.

* Remove Callable.
2021-11-10 10:39:56 -08:00
almog
4f8e407279
try init wallet_manager with datalayer service, cli broken 2021-11-08 17:57:31 +02:00
Mariano Sorgente
8a028c3594
Ms.mempool locking (#9050)
* Prority locking to consensus

* Remove pstats

* Linting

* Do some stuff outside of lock

* Fix startup

* Add log timings

* Try some different locking

* Add limit

* catch excp

* CLVM inside lock

* Try using a semaphore instead

* use events for lock queue

* test

* Add logging for message types

* type

* remove seed

* check new peak waiters

* correct FullNodeAPI self.full_node.new_peak._waiters typo

* correct logging string typos

* only warn about new_peak Waiters if there is at least 1

* remove no-longer-accepted parameter to FullNode.peak_post_processing()

* only warn about respond_transaction Waiters if there is at least 1

* lint

* Change some constants

* Small fix and logging changes

* Put message types outside

* Change some log levels so we can test with info

* More logging

* Increase rate limits but decrease paralelism

* tweaks

* Log dropped tx

* Fix pool rpc test

* Test fixes

* Mempool optimization

* Remove from seen if fails

* Increase queue sizes

* Message types info

* More test and logging

* Small changes to networking just in case

* Decrease logging

* Decrease logging even further

* Decrease logging even further even further

* Decrease logging 3

* Transaction queue

* Don't cancel tasks or close connection

* Cancel tasks on disconnect (for shutdown purposed)

* Fix typo

* Catch cancelled

* Do multiple at a time

* More accurate farmer response time

* More efficiently create tasks

* Increase queue size and priority by fee

* Revert priority

* Don't re-request too many times for dropped TX

* Handle cancelled error so we don't go into a bad state

* Catch cancelled in syncing tasks

* Reduce new_peak_sem to improve performance

* Less bytes conversion

* Missing file, and 2 workers for CLVM

* Validate BLS in a new thread

* tests

* Change semaphore constants

* correct a cancellation triggered exception and assertion

* Fix send_transaction, dont use BaseException, fix tests

* Fix more tests

* only log transaction handler cancellation in debug

* typing in log

* move unfinished validation to diff proc

* it is asyncio.CancelledError

* Add a test for bad signature

* Fix more tests, reduce logging, lint

* One more lint

* blockchain tests, pass bytes directly, single call

* Try to fix rl_wallet failures

* Fix mempool test

* catch everything

* Don't test RL wallet

* Fix more tests and return error code

* Improve error handling in multiprocess

* Add pre-validation time

* Add pre-validation time in logs, and revert pytest.ini changes

* Add log correctly

* Ms.bls cache experiment (#9115)

* Logging for cache

* Less logging

* Return to original plan

* Clean up

* Remove coment

* Remove log

* formalize LockQueue shutdown

* Comments

* Fix blockchain test

* Improve cache

* Remove logs

* Fix sign_coin_spends

* Fix pool wallet

Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Yostra <straya@chia.net>
2021-11-04 09:29:05 -07:00
Mariano Sorgente
55406d729b
Rate limits for new protocol (#8977) 2021-10-27 08:35:41 -07:00
Kyle Altendorf
fe83bebf7f
Merge branch 'main' into altendky-data_layer_exploration 2021-10-12 21:11:23 -04:00
Jeff Cruikshank
ab7d07ad30
Renamed chia.util.ssl to avoid conflicting with aiohttp's ssl import. (#8805)
Removed hacky sys.path reordering in dump_keyring.py
2021-10-12 13:59:29 -07:00
Chris Ross
0a2294841d
Before calling gethostbyname(); check if host is an address (#8765)
* Before calling gethostbyname(), check to see if we already have an address.
That prevents an unnecessary call, and also allows for specifying IPv6
addresses which otherwise cause exceptions here.

* Also recognize addresses when passed to timelord spawn_process, so that
IPv6 addresses can be used.

* Missed importing PeerInfo

* Adjust style to match requirements and existing code

* Cast PeerInfo port to uint16
2021-10-07 16:56:34 -07:00
Kyle Altendorf
0cdcb14749
preliminary data layer cli 2021-09-28 20:57:12 -04:00
Kyle Altendorf
97d94d9569 Merge branch 'main' into altendky-data_layer_exploration 2021-09-22 17:39:48 -04:00
Arvid Norberg
600a5f90a0
CoinStore benchmark and performance improvements (#8514)
* add coin_store benchmark

* optimize _set_spent in CoinStore

* simplify _add_coin_record, since we won't use it to replace an entry anymore

* use executemany in add_coin_record and set_spent

* disable sqlite sync
2021-09-21 10:43:43 -07:00
Kyle Altendorf
c969e63188 Merge branch 'main' into altendky-data_layer_exploration 2021-09-20 21:49:46 -04:00
Adam Kelly
e9bf0ec12b
Reply type decorator (#8276)
* Check types of messages returned from other peers

* Check message type data structures at startup, check that no peeer messages that expect replies are broadcast, and dynamically check return types of messages that do expect replies.

* Type hint protocol message type check functions

* lint

* typo

* add replay_type decorator

* add api reply decorations

* typo

* Don't check non full-node broadcast messages

* Distinguish internal vs peer protocol error
Added Changelog
Moved static check to import time
Moved protocol timeouts to chia/protocols/protocol_timing.py
Comment typos
Rename create_request -> send_request
Comment that INVALID_PROTOCOL_MESSAGE is bannable, not temporary

* Call static check at module import time

* Rename message_response_ok

* Improve protocol checking for outgoing message validation

* Type-o

* reset submodule

Co-authored-by: almog <almogdepaz@gmail.com>
2021-09-20 11:31:15 -07:00
Yostra
5766a8d367
Fullnode related changes from wallet protocol and unharded derivation (#8522)
* fullnode related changes from wallet protocol and unharded derivation

* limit total subscriptions per peer

* reset counter on disconnect

* dict not a set

* check membership

* remove unused tests, lint
2021-09-18 10:27:34 -07:00
Chris Marslender
4d3823bb70
Add a config option for peer_connect_timeout (#8516)
* Add a config option for peer_connect_timeout

* Add configure option for peer connect timeout

* Fix linter complaints
2021-09-17 18:35:06 -07:00
Chris Marslender
c7255a78a9
Move software_version to after the error checking in ws_connection (#8518) 2021-09-17 13:57:30 -07:00
Chris Marslender
9359adbbe2
Add version to ws_connection for crawler (#8512) 2021-09-17 10:59:32 -07:00
Arvid Norberg
b748bb1356
Disable sqlite sync (#8319)
* change sqlite pragma synchronous=FULL to pragma synchronous=NORMAL to improve disk I/O performance. In the case of catastrophic (hardware, power or kernel) failure, our database can be rebuilt

* removed redundant database pragmas in wallet
2021-09-17 10:47:34 -07:00
Kyle Altendorf
e708a3685c black and flake8 2021-09-17 08:31:28 -04:00
Kyle Altendorf
0df73425e6 Preliminary exploration of a data layer skeleton 2021-09-15 21:31:41 -04:00
Arvid Norberg
e4b9db08cd
execute the sqlite pragmas only once, at the lever where the database is opened. Also, say FULL instead of 2, to make it clearer what the pragma is doing (#5993) 2021-09-15 10:57:13 -07:00
dustinface
4130551b23
cmds|server|util: Fix, refactor and improve SSL permission checks (#8211)
* server|util: Refactor `verify_ssl_certs_and_keys`

Let it take two lists instead of one with an tuple holding optional
paths.

* util: Introduce `get_ssl_perm_warning`

* util: Drop some redundant brackets

* util: Introduce `get_all_ssl_file_paths`

* util: Print warnings for CLI only

* cmds|util: Call `check_ssl` for all CLI commands
2021-08-25 15:32:17 -07:00
wjblanke
a2de2d8f30
up request block rate limit for faster sync (#8204) 2021-08-25 10:25:40 -07:00
Earle Lowe
da5df49f39
New call for logging peer_host (#8108) 2021-08-18 13:02:30 -07:00
Florin Chirica
2ce7c5950c
Use ip.chia.net (#8039)
* Use ip.chia.net

* oops...
2021-08-16 14:12:43 -07:00
Florin Chirica
639d5ee1f6
Enable querying AAAA records for DNS Introducer. (#8008)
* Initial commit DNS ipv6.

* Fix pyblack.

* nit.
2021-08-16 11:35:37 -07:00
Jeff Cruikshank
39fbe2aa17
Create SSL keys/certs with proper permissions, also verify/fix existing installs (#7972)
* Create directories with 755 permissions, SSL certs with 644, and keys with 600.

* Check SSL file permissions during chia_init(). Exits if permissions are incorrect.

* Overwrite certs/keys instead of failing to write

* Skip SSL file permission checks on Windows (requires checking ACLs)

* Check SSL file permissions when creating an ssl_context

* Skip check_ssl on Windows.
Handle some SSLInvalidPermissions exceptions.

* Added a few comments

* Added chia init --fix-ssl-permissions option to attempt to fix SSL file permission issues.
Update imported cert permissions when using chia init -c.
Code cleanup/restructuring.

* Return a tuple instead of a list

* LGTM and other minor fixes

* Fixed SSL test breakage when calling ssl_context_for_client. The ca_crt param was being passed in as both the cert and private key, triggering the permission check failure.

* Don't exit if SSL file permissions issues are found

* Tweak the exception types that are raised from traverse_dict
2021-08-15 15:53:54 -07:00
Jeff Cruikshank
325d7f8245
Keyring passphrase protection (#7249)
* Moved keyring handling into a KeyringWrapper class

* Update click to 8.0.x for prompt_required support

* Renamed KeyringWrapper to _KeyringWrapper

* Expose password management options on Linux

* CLI support for setting/removing a password

* Global option for specifying the master password

* Cache the password instead of setting on the context

* Password bootstrapping during chia init

* Tidying up _KeyringWraper's interface

* Initial pass migrating the legacy keyring contents

* Encryption/decryption of keyring.yaml contents

* FileKeyring backend encrypts with ChaCha20Poly1305

* Tightened up keyring migration and initialization

* Fixed issues identified by linters

* Remove root_path from Keychain

* Prevent double-migration if setting master passwd

* KeyringWrapper tests are mostly complete

* FileKeyring will now honor the service param

* Tests for get/set/delete password

* Formatting/commenting updates

* Writer lock support with tests - WIP

* keyring.yaml is now watched for modifications

* Reader/Writer lock for get/delete password

* Fixed linter issues

* Reader lock tests

* Formatting update

* Hook up CHIA_ROOT support for KeychainWrapper

* Quick fix to address test failures

* Fixed failures when existing legacy keyring exists

* Fixed test failures caused by reusing the same temp dir

* keyring.yaml now lives in ~/.chia_keys by default. Can be overridden with CHIA_KEYS_ROOT or --keys-root-path

* Fixed migration failure when setting a password (not using the default)

* KeyringWrapper now uses supports_keyring_password to determine if a FileKeyring should be used. Patched tests to work regardless of whether supports_keyring_password return False

* The daemon now takes a --have-gui option that will prevent calling check_keys() during startup. If the keyring is locked, we want the GUI to prompt for the password.

* Added is_keyring_locked RPC call

* Added 'unlock_keyring' RPC command

* Added KeychainProxy and KeychainServer to handle RPC messages related to keyring operations. WalletNode no longer directly accesses the Keychain class.

* Turn on macOS support for testing keyring passwords

* Fixed get_key_for_fingerprint to use the ocal keychain if the platform doesn't need to remotely access the daemon's keychain.

Fixed key reconstruction when sent over RPC.

* Farmer now accesses the keychain over RPC

* Fixes for linter issues and some restructuring to support tests that use setup_nodes.py

* Couple of fixes to unblock the GUI from launching when a keyring password is set

* Added a keychain RPC call for add_private_key()

* Added remaining keychain proxy RPC calls for delete_key_by_fingerprint and delete_all_keys

* Check for None when inspecting request arguments

* Run check_keys after unlocking the keyring when the daemon is launched via GUI

* Added check_keys RPC method.
Fixed deserialization of key entropy in get_all_private_keys. This was preventing the GUI from being able to show key details.

* Added get_first_private_key to keychain_server/proxy.
create_plots now uses the keychain proxy when launched from the daemon.

* Added a comment about KeychainProxy in chia plots check

* Workaround import conflict  when importing from 'tests.*' due to fasteners name conflict

* Simulator now uses KeychainProxy if launched by the daemon.
KeychainServer/Proxy now takes keychain user/testing params for testing scenarios.

* Added "set_keyring_passphrase" RPC message

* Reworking KeychainProxy usage to handle local keychain tests and RPC keychain tests.

* Replace my prior usage of asyncio.run() with asyncio.get_event_loop().run_until_complete()

* Silencing file_keyring logging for the moment.

* Updated tests to use test keychains and appropriate BlockTools construction

BlockTools should now be created with create_block_tools(_async) to handle async scenarios.

Updated block_tools to be async compatible

Updated fasteners to fix installation of top-level 'tests' in site-packages

* Added 'remove_keyring_passphrase' RPC message to the daemon

Minor tweak to TempKeyring to default to some test params

* Fixed linter issues

* Remove flake8 ignore statement now that the fasteners module has been updated

* Some initial renaming changes: password -> passphrase

* Fixed wallet RPC issue where get_key_for_fingerprint wasn't awaited-upon.

Fixed legacy keyring initialization (for migration scenarios)

* Fixed improperly merged file

* Fixed linter issues.
More renaming.

* Updated spots that were still using an incorrect keychain call

* Renamed use_password_cache, obtain_current_password

* Renamed supports_keyring_password

* Renamed has_master_password

* Renamed has_cached_password, get_cached_master_password

* Linter fixes

* Renamed master_password_is_valid

* Renamed set_cached_master_password

* Renamed set_master_password

* Renamed remove_master_password

* Renamed has_cached_master_password

* Renaming in file_keyring and keyring_wrapper

Updated default keyring payload used for tests

* Renamed get_password
Other renaming updates

* Renamed set_password
Other renaming updates

* Renamed remaining password occurrences (where appropriate)

* password -> passphrase

* Added tests for setting an emoji and Japanese master passphrase

* Attempt to notify the daemon when a keyring passphrase is set/updated/removed

* Missed one password -> passphrase replacement.

* Fixed some file synchronization issues found when running tests on macOS

* Adjusted timeout values for test_writer_lock_reacquisition_failure for macOS.

* Removed logging statements previously added for debugging

* Prompt for keyring passphrase up-front when launching a service.

Changed --have-gui flag to --wait-for-unlock

* Updated set_keyring_passphrase RPC message to fix optional current_passphrase param when the keyring is using the default passphrase.

* Minor test cleanup to deduplicate some code.

* Fixed regression when setting a new master passphrase

* Minor refactoring and docs/commenting updates

* Renaming password -> passphrase went too far. Keyring backends use password terminology for compatibility with third party backends.

* Disabling macOS support (previously added for testing only)

* Disabling passphrase support in preparation for sending out the PR

* Fixed improper merge (vscode didn't save changes during rebase)

* Update chia/cmds/init_funcs.py

Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>

* skip_check_keys -> should_check_keys

* Shuffling some imports around to break cycles reported by LGTM

* Handle unlocking the daemon if it's already launched and waiting for unlock.

* Replaced uses_keychain_proxy decorator in farmer.py. Fixed async usage of get_reward_targets.

Linter/reformatting fixes

* Replaced uses_keychain_proxy decorator with a clearer method.

* Cleanup the temp keyring dir using shutil.rmtree()

* Restored self._root_path (had been changed to self.root_path)

* Minor cleanup

* ensure_keychain_proxy() now throws if connect_to_keychain_and_validate() fails

* Plot key resolution now yields a PlotKeys object which can be passed into create_plots.

De-indented test_invalid_icc_sub_slot_vdf to keep git blame tidy.

* Added 'keyring_status' daemon RPC message to support the GUI

* Minor changes relating to PR feedback

* Addressed more PR feedback (mostly type annotations)

* Commented-out macOS file keyring usage. This can be re-enabled for testing purposes.

* Addressed test failures that require multiple keyrings in the same process. Each TempKeyring will now set a custom KeyringWrapper instance.

* Fixed logic for communicating user_passphrase_is_set in the keyring_status RPC response.

* Updated type annotations and method signature for set_passphrase to expect a string instead of bytes.

* Fixed Wallet RPC tests

* Fixed full_node_store tests. BlockTools should be created using the create_block_tools(_async) function(s)

* Fixed test failures in test_pool_rpc

* Fixed test_daemon. After BlockTools.setup_plots is run, the config file needs to be re-read to refresh stale plot_directories.

* Suppressing LGTM false positives regarding passphrase leakage in CLI error output. Seems that LGTM sees MIN_PASSPHRASE_LEN as sensitive data.

* Second attempt at suppressing LGTM false positives

* Third attempt at addressing LGTM false positives

* Removed test_keyring_wrapper param from Keychain ctor. Test setup now sets the keyring_wrapper property directly.

* Reformatting

* More targeted update of the test config to refresh just the "plot_directories" value

* More LGTM suppressions

Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
Co-authored-by: wjblanke <wjb98672@gmail.com>
2021-08-04 12:46:55 -07:00
Earle Lowe
18708e2bb8
More friendly error reporting for peername errors (#7716) 2021-07-22 09:05:31 -07:00
dustinface
1b196e6bd8
chia|tests: Add node_type parameter to get_connections RPC (#7492)
* rpc|server: Add Optional `node_type` paramter to `get_connections`

* farmer: Query `HARVESTER` connections only

* tests: Basic test for `node_type` parameter
2021-07-15 07:42:06 -07:00
dustinface
de1a6c6463
farmer|harvester|server: Fix harvester cache updates, bump message size, increase timeout (#7244)
* farmer: Increase timeout for `HarvesterAPI.request_plots` requests

Set it to `UPDATE_HARVESTER_CACHE_INTERVAL`.

* farmer|harvester: Add some debug logs around `get_harvester` stuff

* server: Bump size limit for `respond_plots` from 10MB/msg to 100MB/msg

Those messages can become pretty big now for large farms.

* farmer: Keep also track of failed cache update attempts

Prior to this commit the farmer called the `request_plots` every second 
for each harvester as long as they failed to respond properly. Since the 
rate limit was 10/minute this lead to hitting the rate limit if the 
harvester didn't responds for 10 tries in a row for whatever reason.

This commit changes the behaviour to always keep track of request 
attempts even if they end up in a timeout to really only re-try every 
60s no matter what.

* farmer: Introduce and use `HarvesterCacheEntry`
2021-07-09 09:32:05 -07:00
Earle Lowe
46395374ae
Improves error handling for unknown protocol types (#7073)
* Improves error handling for unknown protocol types

* Add test for invalid protocol
2021-07-01 21:20:21 -07:00
Adam Kelly
89f7a4b3d6
Pools mainnet (#7047)
* added clarifying comments

* WIP test

* added WIP test

* Refine genesis challenge. Remove unnecessary pool_puzzle function

* Sign spend. Remove create_member_spend. Rename state transition function to create_travel_spend

* Rename create_member_spend to create_travel_spend

* Add singleton id logging

* Enhance logging for debugging

* renaming

* rephrase inside the puzzle

* fixed signing and added some support functions

* Fix issue with announcement

* Progress spending the singleton

* Fix arguments to pool_state_to_inner_puzzle call

* Fix arguments to pool_state_to_inner_puzzle

* Improve error message when wallet is not running

* Remove misleading message about missing wallet process, when problem is the farmer by making poolnft command error out earlier

* Fix parent coin info bug

* Multiple state transitions in one block

* Lint

* Remove assert

* Fix incorrect p2_singleton_ph calculation (thanks nil00)

* Update waiting room puzzle to accept genesis_challenge

* Update calls to create_waiting

* Go to waiting state from committed state

* Augment debug_spend_bundle

* fix 2 bugs in wallet

* Fix lint

* fix bad_agg_sig bug

* Tests and lint

* remove breakpoint

* fix clvm tests for new hexs and hashs

* Fixed a bug in the coin store that was probably from merging. (#6577)

* Fixed a bug in the coin store that was probably from merging.

* The exception doesn't need to be there

* CI Lint fix

* Added lifecycle tests for pooling drivers (#6610)

* Ms.poolabsorb (#6615)

* Support for absorbing rewards in pools (untested)

* Style improvements

* More work on absorb

* Revert default root and remove log

* Revert small plots

* Use real sub slot iters

* Update types

* debug1

* Fix bugs

* fix output of agg sig log messages

* Make fewer calls to pw_status in test

* remove old comment

* logging and state management

* logging

* small bug fix & rename for accuracy

* format

* Fix types for uncurry function

* lint

* Update test to use exceptions

* Change assumptions about self-pooling in lifecycle test

* Install types for mypy

* Revert "Install types for mypy"

This reverts commit a82dcb712a.

* install types for mypy

* install types for mypy

* More keys

* Remove flags requiring interactive prompts

* Change initial spend to waiting room if self-pooling

* lint

* lint

* linting

* Refactor test

* Use correct value in log message

* update p2_singleton_or_delated_puzhash

* initial version of pool wallet with p2_singleton_or_delay

* run black formatting

* fix rebase wonkiness

* fix announcement code in p2_singleton_or_delayed

* removed redundant defaulting
standardised hexstr handling

* lint fixes

* Fixed pool lifecycle tests to current standards, but discovered tests are not validating signatures

* Signatures validate on this test now although the test still does not check it.

* Lint fix

* Fixed plotnft show and linting errors

* fixed failing farmer/harvester rpc test

* lint fix

* Commenting out some outdated tests

* Updated test coverage

* lint fix

* Some minor P2singleton improvements (#6325)

* Improve some debugging tools.

* Tidy pool clvm.

* Use `SINGLETON_STRUCT`. Remove unused `and` macro.

* Use better name `SINGLETON_MOD_HASH`.

* Finish lifecycle test suite.

* Fixing for merge with chia-blockchain/pools_delayed_puzzle (#72)

Co-authored-by: Matt Hauff <quexington@gmail.com>

* Default delay time was being set incorrectly

* Extracted get_delayed_puz_info_from_launcher_spend to driver code

* Ms.taproot plot2 (#6692)

* Start work on adding taproot to new plots

* Fix issue in block_tools

* new test-cache

* Lint

* DID fixexs

* Fix other tests

* Python black

* Fix full node store test

* Ensure block index <= 128 bits.

* fix test_pool_config test

* fix comments in pool_config and in chialisp files

* self_pool -> pool -> self_pool

* Implement leaving pools

* Fix conflicts with main via mini-rebase

* Fixup rebase mistakes

* Bring in Mariano's node discovery chagnes from pools.dev

* Fix adapters - Thanks Richard

* build tests

* Add pools tests

* Disable DID tests

* farmer|protocol: Some renaming related to the pool protocol

* farmer: Use `None` instead of `{}` and add local `pool_state`

* protocol|farmer: Introduce and use `PoolErrorCode`

* rename: `pool_payout_instructions` -> `payout_instructions`

* refactor: `AuthenticationKeyInfo` -> `authentication_key`

* refactor: Move `launcher_id` up

* rename: Some variable name changes

* rename: `points_balance` -> `points`

* format: Squash aggregation into one line

* farmer: Make `update_pool_state` public

* farmer: Print traceback if `update_pool_state` fails

* farmer: Periodically call `GET /pool_info`, add `_pool_get_pool_info`

* farmer: Add `authentication_token_timeout` to `pool_state`

Fetch it from `GET /pool_info`

* protocol|farmer: Implement support for `GET|POST|PUT /farmer`

* farmer: Make use of `GET|POST /farmer`

- To make the farmer known by the pool
- To update local balance/difficulty from the pool periodically

* farmer|protocol: Adjust `POST /partial` to match the latest spec

* farmer: Hash messages before signing

* pools: Drop unused code

* farmer: Fix aggregation of partial signatures

* farmer: support self pooling, don't pool if url==""

* wallet: return uint64 for delay time, instead of bytes

* pool: add error code for delay time too short

* farmer: cleaner logging when no connection to pool

* farmer: add harvester node id to pool protocol

* Rename method (test fix) and lint fix

* Change errors to warnings (pool communication)

* Remove pool callbacks on a reorg

* farmer: Continue earlier when no pool URL is provided

* farmer: Print method in log

* farmer: Handle exceptions for all pool endpoint calls

* farmer|protocol: Keep track of failed requests to the pool

* farmer: Fix typo which caused issue with pooling

* wallet: simplify solution_to_extra_data

* tests: Comment out DID tests which are not working yet

* Remove DID Wallet test workflows

* Return launcher_id when creating Pool Wallet

* Name p2_singleton_puzzle_hash correctly

* Improve 'test_singleton_lifecycle_fast.py'.

* Make test more robust in the face of asynchronous adversity

* Add commandline cmds for joining and leaving pools

* Fix poolnft leave params

* Remove redundant assignment brought in from main

* Remove unneeded code

* Style and parsimony

* pool_puzzles: Check was wrong, and bad naming

* format: Fix linting

* format: Remove log and rename variable

* pool-wallet: Fix self pooling with multiple pool wallets. Don't remove interested puzzle_hash

* gui: Use pools branch

* format: fix lint

* Remove ununsed code, improve initial_pool_state_from_dict

* farmer: Instantly update the config, when config file changes

* format: Speed up loading of the authentication key

* logging: less annoying logging

* Test pool NFT creation directly to pool

* Test switching pools without self-farming in between

* lint

* pooling: Use integer for protocol version (#6797)

* pooling: Use integer for protocol version

* pooling: Fix import

* Update GUI commit

* Ms.login2 (#6804)

* pooling: Login WIP

* pooling: add RPC for get_link

* dont use timeout

* pooling: rename to get_login_link

* format: remove logging

* Fix SES test

* Required cli argument

Co-authored-by: almog <almogdepaz@gmail.com>

* farmer|protocols: Rename `current_difficulty` for `POST /partial` (#6807)

* Fix to farm summary

* Use target_puzzlehash param name in RPC call

* Pool test coverage (#6782)

* Improvement in test coverage and typing

* Added an extra absorb to the pool lifecycle test (only works when merged with https://github.com/Chia-Network/chia-blockchain/pull/6733)

* Added new drivers for the p2_singleton puzzles

* Added new tests and test coverage for singletons

* organize pools testing directory

* black formatting

* black formatting in venv

* lint fix

* Update CI tests

* Fixing tests post rebase

* lint fix

* Minor readability fix

Co-authored-by: matt <matt@chia.net>

* farmer: Drop `target_puzzle_hash` from `GET /farmer` and `GET /login` (#6816)

* Allow creation of PlotNFTs in self-farming state

* gui: Fix install with more RAM (#6821)

* Allow implicit payout_address in self-pool state, improve error messages and param ergonomics

* print units in non-standard wallets correctly

* Fix farmer import

* Make syncing message in CLI more intuitive like the GUI

* Fix linting and show header hash instead of height

* gui: Update to 725071236eff8c81d5b267dc8eb69d7e03f3df8c

* Revert "Merge"

This reverts commit 23a1e688c5, reversing
changes made to a850246c6f.

* Revert "Revert "Merge""

This reverts commit 680331859f.

* Treat tx_record as Dict. Refactor tx submission

* Also add passed-in coin spends when processing new blocks in reconsider_peak

* Test utilities had moved

* Fix import of moved block_tools

* Potentially fix yaml

* Previously didn't take the right part of this change

* Add -y flag, improve commandline plotnft handling

* Fix typo

* Add -y flag to plotnft create

* pool_wallet: Restore from DB properly

* wallet: ignore bad pool configs

* Reduce memory

* pool_wallet: Add claim command

* pool_wallet: Set transaction records to confirmed

* wallet: Fix bug in transaction cache

* Formatting and remove log

* pool_wallet: CLI balance and improvements to plotnft_funcs.py

* pool_wallet: Simplify, and fix issue with double submission

* pool_wallet: Fix tests

* pool_wallet: Don't allow switching before relative lock height

* update gui

* change to 3000 mem

* Correct sense of -y flag for self-pooling

* cli: Display payout instructions for pool

* pool_wallet: Don't create massive transactions

* cli: Improvements to plotnft

* pool_wallet: Get correct pool state

* pool_wallet: Use last transaction block to prevent condition failure

* Add block height for current state

* Add outstanding unconfirmed transactions to pw_status

* Refine command line plotnft show pending transactions

* Fix tests by using the correct output from pw_status

* Try to fix windows build

* Print expected leave height

* label pool urls

* pool_wallet: Don't include pool 1.75 rewards in total

* wallet: Add RPC and CLI for deleting unconfirmed transactions for a wallet

* pool_wallet: If farming to a pool, show 0 balance in wallet

* pool_wallet: Show error message if invalid state, in CLI

* pool_wallet: Don't allow switching if there are pending unconfirmed transactions

* tests: Clean up pool test logging

* tests: Fix lint

* Changed the pool innerpuzzes (#6802)

* overload solutions for pool_innerpuz parameters

* Fix tests for reduced size puzzles

* deleted messy deprecated test

* Fix lint.

* fix bug where spend types were the wrong way around

* merge with richard's lint fix

* fix wallet bug
remove unnecessary signature
add defun-inline for clarity

* Swap to defun for absorb case
Use cons box for member innerpuz solution

* fix if statement for cons box p1

* remove unnecessary solution arg

* quick innerpuz fix to make tests pass

* Switch to key-value pairs
Undo cons box solution in pool_member inner puzzle

* fix singleton lifecycle test

* added some comments to calrify the meaning on "ps"

* lint fix

* reduce label size, search for label when reconstructing from solution

* no need to keep looping if `p` found

* lint fix

* Removed unecessary defun-inline and changed hyphens to underscores

* Changed created_coin_value_or_0 to an inline function

* Changed morph_condition to an inline function

* Added a comment for odd_cons_m113

* Rename output_odd and odd_output_found

* Add inline functions to document the lineage proof values

* Stager two rewrite

* Added an ASSER_MY_AMOUNT to p2_singleton_or_delayed

* Extract truth functionality to singleton_truths.clib

* Fix tree hashes

* Changed truths to a struct rather than a list.

* fix test_singletons
update did_innerpuz

* recompile did_innerpuz

* fix a log error

* Renamed variable and factored out code per @richardkiss

* lint fix

* switch launcher extra_data to key_value pairs

* fix parsing of new format of extra_data in launcher solution

* fix broken test for new launcher solution format

* remove bare raise

Co-authored-by: Richard Kiss <him@richardkiss.com>
Co-authored-by: Matt Hauff <quexington@gmail.com>

* Also add passed-in coin spends when processing new blocks in reconsider_peak (#6898)

Co-authored-by: Adam Kelly <aqk>

* Moved debug_spend_bundle and added it to the SpendBundle object (#6840)

* Moved debug_spend_bundle and added it to the SpendBundle object

* Remove problematic typing

* Add testnet config

* wallet: Memory would get corrupted if there was an error (#6902)

* wallet: Memory would get corrupted if there was an error

* wallet: Use block_record

* wallet: Add records in a full fork too

* wallet: remove unnecessary arguments in CC and DID

* add to cache, revert if transaction fails

Co-authored-by: Yostra <straya@chia.net>

* Improve comment

* pool_wallet: Fix driver bug

* wallet: Fix memory corruption

* gui: Update to latest

* Increase memory size

* tests: Add test for absorbing from pool

* small fix in solution_to_extra_data

* Fixed incorrect function name

* pooling: Fix EOS handling in full node

* [pools.testnet9]add post /partial and /farmer header (#6957)

* Update farmer.py

add post header

* Update farmer_api.py

add post header

* Update chia/farmer/farmer.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* Update chia/farmer/farmer_api.py

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com>
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

* Fix lint and cleanup farmer.py

* farmer: Fix linting issues (#7010)

* Handle the case of incorrectly formatted PoolState data returned from inner singleton

* wallet: Resubmit transaction if not successful, rename to new_transaction_block_callback (#7008)

* Fix lint in pool_puzzles

* pooling: Fix owner private key lookup, and remove unnecessary argument

* pooling: Clear target state on `delete_unconfirmed_transactions`

* Lint

* Fix non-deterministic test

* Slight cleanup clvm driver code (#7028)

* Return None when a deserialized CLVM structure does not fit the expected format of var-value pair for singleton data

* lint

Co-authored-by: Adam Kelly <aqk>

* Revert "Add testnet config"

This reverts commit 9812442724.

Co-authored-by: matt <matt@chia.net>
Co-authored-by: Adam Kelly <aqk@aqk.im>
Co-authored-by: Mariano Sorgente <sorgente711@gmail.com>
Co-authored-by: Matt Hauff <quexington@gmail.com>
Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com>
Co-authored-by: Adam <aqk@Adams-MacBook-Pro.local>
Co-authored-by: Adam Kelly <aqk>
Co-authored-by: Richard Kiss <him@richardkiss.com>
Co-authored-by: xdustinface <xdustinfacex@gmail.com>
Co-authored-by: almog <almogdepaz@gmail.com>
Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: arvidn <arvid@libtorrent.org>
Co-authored-by: willi123yao <willi123yao@gmail.com>
Co-authored-by: arty <art.yerkes@gmail.com>
Co-authored-by: William Blanke <wjb98672@gmail.com>
Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com>
Co-authored-by: Chris Marslender <chrismarslender@gmail.com>
Co-authored-by: Yostra <straya@chia.net>
Co-authored-by: DouCrazy <43004977+lpf763827726@users.noreply.github.com>
2021-06-29 14:21:25 -07:00
Almog De Paz
e5eff54149
wallet short batch sync (#6112)
* short batch sync

* switch log for fixing ci

* switch log level back

* increase test time

* new line

* test fix

* change sem to lock

* change sem to lock

* refactor

* move weight check under lock

* short sync tests

* lint

* remove duplicate code

* remove duplicate code

* add await

* fix
2021-06-29 11:25:54 -07:00
Yostra
ab4f44175b
service singleton (#6735) 2021-06-24 11:10:46 -07:00
Arvid Norberg
375ec8f69d
fix mypy warning (#6910) 2021-06-22 11:46:23 -07:00
Arvid Norberg
42fde9a8d4
move chia.util.block_tools and chia.util.wallet_tools into tests (#6799)
* move chia.util.block_tools and chia.util.wallet_tools into tests

* only depend on block_tools when we actually run the wallet in test mode
2021-06-16 11:12:26 -07:00
Nikolaj Kuntner
07f64d2190
Less log getter setup calls (#6123)
* init

* remove whitespace

* docs

* rem double colon

* more type annotation

* retrigger timed out test

Co-authored-by: wjblanke
2021-06-14 09:13:41 -07:00
wjblanke
d2cc4fdf0d
Fix broken UPnP in upnp.py (#6690)
* Contributed by phoyd: 39ef696 introduced deleteportmapping to cleanup previous mappings. deleteportmapping might throw an error from a upnp server reply when the port mapping to delete does not exist (see rfc6970, section-5.8 NoSuchEntryInArray). This prevents the subsequent addportmapping() and hence opening upnp does not work anymore (For example, issue #6250)

* added f

* lint
2021-06-11 16:10:58 -07:00
Florin Chirica
d13840ff3b
Catch exception in dns resolver. (#6613) 2021-06-10 08:55:21 -07:00
Arvid Norberg
9239ee5c9e
ClientSession lifetime simplification (#6114)
* properly initialize field of FullNodePeers in node_discovery

* clean up handling of closing the ClientSession() when we fail
2021-06-08 10:49:13 -07:00
Florin Chirica
06a23d7769
Add full node ports for testnet dns. (#6369)
* Add full node ports for testnet dns.

* Lint.
2021-06-08 09:45:53 -07:00
Florin Chirica
59d415fd71
Rename testnet peer dbs. (#6353)
* Rename testnet peer dbs.

* Add selected_network to all constructors.
2021-06-02 15:19:58 -07:00
Arvid Norberg
7800dbb58c
Cleanup shutdown (#6011)
* ignore signals in subprocesses

The sub-processes started by ProcessPoolExecutor will also receive SIGINT when the main process receives it. This results in the signal handler running in every subprocess and fail to create the task to close all connections. They print this error to stdout

* cleanup UPnP shutdown

make an explicit call to UPnP shutdown() (which joins the thread). Improve logging a bit

* wait for initialize_weight_proof task when shutting down
2021-05-26 12:18:12 -07:00
Arvid Norberg
ee35d85ad8
store tasks used to initiate peer connections (#5557)
to ensure they are kept alive and to be able to wait for them if we hit the upper limit on number of pending outgoing connections
2021-05-26 11:06:55 -07:00
Arvid Norberg
78f73b3d55
demote DNS failure log to a warning (#5771) 2021-05-24 11:53:31 -07:00
Florin Chirica
bf3ffa6eeb
Initial commit. (#5627) 2021-05-20 15:03:59 -07:00
Florin Chirica
4ad8d9dcef
Speedup connections 2. (#5421)
* Decrease sleeps.

* Wait 30 minutes before retrying address.

* Address comments.

* Address comments.

* Sleep in node discovery if we don't need connections.

* Rename sleeps.

* Lint.

* Refactor sleeps.

* Don't query introducers at startup.
2021-05-20 10:38:35 -07:00
Mariano Sorgente
5ce56bce6d
Don't use a global (#5553)
* Don't use a global

* Only construct once
2021-05-19 17:41:53 -07:00
Mariano Sorgente
1c808b6c29
Ms.spikes4 (Fix duplicate signage points) (#4844)
* Fix duplicate signage point spikes

* Block record not hash

* Fix bugs in signage point cache

* Fix test, and log in debug level

* Change transaction logging to info

* More logging improvements
2021-05-16 11:33:47 -07:00
Florin Chirica
7012ca9e07
Speedup outbound connections. (#5124)
* Initial commit.

* Fix typo.

* Retry each node once every 30 mins.

* Flake8.

* mypy.

* Bound number of concurrent outbound connections.

* Blank line.
2021-05-15 23:07:39 -07:00
Will Bendick
39ef69643b
release upnp ports on shutdown (#4024)
* release upnp ports on shutdown

* lint

* explicitly removes port mapping first to handle possible unclean shutdowns

* catches exception

* moves upnp setup to thread

* lint

* moves upnp logic to a message queue on a worker thread

* lint
2021-05-14 14:11:19 -07:00
Florin Chirica
bb662f27dc Address review comments. 2021-05-14 14:05:12 -06:00
Florin Chirica
3cbb5dc4d5 Fix bug. 2021-05-14 14:05:12 -06:00
Florin Chirica
ca09382fe5 linter. 2021-05-14 14:05:12 -06:00
Florin Chirica
413d29083f Initial commit. 2021-05-14 14:05:12 -06:00
Peter Tripp
178f63a3a3
exempt_peer_networks: allow exceeding target_peer_count. (#3234)
* exempt_peer_networks: allow exceeding target_peer_count.

* Flake8.

* Cleanup incorrect types.

* More typing.

* Added configuration examples for exempt_peer_networks.

* Be generous in the IP network definitions we allow as input.

* Correctly define 192.168.1.0/24 without host bits.

* Trivial change to re-trigger tests.

Co-authored-by: wjblanke <wjb98672@gmail.com>
2021-05-12 17:44:26 -07:00
An Long
eb7b6dd243
Makes linter happy (#2483) 2021-05-12 17:31:28 -07:00
Yostra
60fd84191d
don't read from cli (#4625) 2021-05-12 10:38:35 -07:00
Nikolaj Kuntner
cbc9141689
add all none's (#4503)
Co-authored-by: Nikolaj Kuntner <>
2021-05-10 22:05:45 -07:00
Arvid Norberg
b759958d13
fix indentation issue in message send retry logic. factor out retry coroutine (#3629) 2021-05-04 22:28:58 +09:00
Arvid Norberg
912dc84663
don't increment counters for outgoing messages blocked by the rate limit. (#3518)
This was causing a problem where outbound messages, blocked by the rate limiter,
would still increment the counters as-if they had been sent. This, in turn,
could cause other message types to get blocked becuase the rate limiter thought
we had sent a lot of the other (blocked) message type.
2021-05-03 11:18:29 -07:00
Mariano Sorgente
5ce1bfc34c
Don't retry respond_peers message (#3508) 2021-05-03 18:58:17 +09:00
Mariano Sorgente
75d75de190
SES could corrupt DB. Also don't cancel a task which could lead to corrupt memory. (#3237) 2021-04-30 16:11:05 -04:00
Yostra
5f9f63155d
Add lock, keep cache consistent (#3051)
* execute task decorator

* use blockchain lock

* indentation

* lint

* execute_task
2021-04-29 16:13:00 +09:00
Mariano Sorgente
cb054ef72b
Hopefully reduce chances of nonce collision (#2161)
* Hopefully reduce chances of nonce collision

* No collisions
2021-04-28 13:34:32 -04:00
Yostra
b3cc6bfe93 retry 2021-04-23 00:53:08 -07:00
Arvid Norberg
572110b7df
delay 5 seconds after connecting the introducer to give it a chance to add any peers we got from it (#2299) 2021-04-21 12:17:08 -07:00
Arvid Norberg
8c24306f88
exponentially back-off contacting the introducer (#2250)
* exponentially back-off contacting the introducer (until reaching 5 minute delay)

* bump introducer connection timeout from 10 to 30 seconds
2021-04-21 03:48:44 -07:00
Arvid Norberg
f074f517e6
ping the introducer at least once on startup (#2214) 2021-04-20 15:20:09 -07:00
Arvid Norberg
dc7071f459
attempt to save time hashing PeerInfo objects in introducer (#1990)
* attempt to save time hashing PeerInfo objects in introducer, by moving attributes from hash tables into the peer object itself, where it belongs

* only remove peers after a few failures in a row, not immediately. Ensure we don't check peers too frequently.
2021-04-17 09:25:40 -07:00
Florin Chirica
ae911f53c4
Wallet sleep before finding connections. (#1968) 2021-04-16 13:31:36 -07:00
Yostra
a142f10cfd
Init as None (#1814)
* init as None

* lint

* fix import from asyncio

Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
2021-04-11 20:35:51 -07:00
Yostra
06e871c5d5 cancel safely 2021-04-11 18:42:13 -07:00
Mariano Sorgente
876692631a
Fix issue with error handling in timelord. Show infusion rate for all… (#1716)
* Fix issue with error handling in timelord. Show infusion rate for all timelords (even slow ones), and fix logging for rate limiting

* Fix another issue

* Further improvements in crashes, and better counting

* Don't error if we cannot infuse

* flake8

* more flake8

* Improvements for not the fastest timelord

* Don't double count

* Don't double count (again)
2021-04-06 19:48:46 -07:00
Yostra
43c02e513a use wal and full sync mode 2021-04-06 18:22:01 -07:00
Yostra
a69abb1717 don't start with api requests before ready 2021-04-06 17:50:25 -04:00
Mariano
691534f3fe Removes warnings by renaming some protocol messages. Also improves error handling for timelord. 2021-04-04 23:54:11 -07:00
Richard Kiss
f2b577dda1 git mv src chia 2021-04-04 21:41:39 -07:00