Commit Graph

183 Commits

Author SHA1 Message Date
Kyle Altendorf
1ec2fc1526
Fix new complaints from mypy 0.920 (#9586) 2021-12-15 17:52:25 -08:00
xchdata.io
41ff79a86c
Properly assign keyring observer to instance field (#9556) 2021-12-13 22:41:51 -08:00
Jeff
30a0ff02bc
Restore peer_db_path and wallet_peers_path config keys/values for downgrading from a newer install. (#9557) 2021-12-13 22:01:14 -08:00
Kyle Altendorf
8bbbc7f9d8
Fix odd string format (#9508)
I would like to just have a list of strings instead of splitting, but let's at least have it be a clean string for now.
2021-12-13 08:39:36 -08:00
Kyle Altendorf
44b4d69ad7
Fix some hints (#9484)
* Fix some hints

* remove unused import

* correct AmountWithPuzzlehash.amount to be uint64
2021-12-10 15:00:43 -08:00
Kyle Altendorf
5eeec865e9
stub and use SizedBytes.fromhex() until upstream is released (#9458)
* stub SizedBytes.fromhex() until upstream is released

https://github.com/python/typeshed/pull/6201

* black

* more

* more

* more

* more

* more

* import TYPE_CHECKING via from

* more

* more

* catch up
2021-12-10 14:59:49 -08:00
Kyle Altendorf
c5902841de
Just use bytes32() some more (#9472)
* Just use bytes32() some more

* black

* more
2021-12-07 07:55:48 -08:00
Kyle Altendorf
406253f782
Adjust compress_root() to return bytes32 (#9470) 2021-12-07 07:55:04 -08:00
Kyle Altendorf
b998193c7e
create and use SizedBytes.from_hexstr() (bytes32) (#9467)
* create and use SizedBytes.from_hexstr() (bytes32)

* another

* more

* more
2021-12-07 07:54:26 -08:00
Arvid Norberg
70d31a8c68
V2 database framework (#9442)
* fix block_store benchmark linting issues

* basic support for database versioning

* update benchmark to run v1 and v2
2021-12-03 13:52:10 -08: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
Florin Chirica
ae8bdbc3c7
Windows blueboxing. (#8394)
* Windows bluebox.
2021-12-01 11:32:49 -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
dustinface
a95dfba70b
plotting|util|tests: Introduce chia.util.generator_tools.list_to_batches (#9304)
* plotting|util: Introduce `chia.util.generator_tools.list_to_batches`

* tests: Test `list_to_batches` in  `test_list_to_batches.py`

* util|tests: Return an empty iterator for empty input lists

* tests: Test list sizes from 1-10 in `test_valid`
2021-11-24 11:27:31 -08:00
Arvid Norberg
aacdc03188
Sql index changes (#9349)
* make the is_peak index smaller

* condition database updates on a configuration option

* drop unused coin_spent index

* drop redundant index on primary key

Co-authored-by: neurosis69 <83925572+neurosis69@users.noreply.github.com>
2021-11-23 13:23:07 -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
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
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
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
Jeff Cruikshank
911d26d3a8
Enable keyring passphrase support by default. Can be disabled by setting the CHIA_PASSPHRASE_SUPPORT env variable to false. (#8864) 2021-10-22 09:03:27 -07:00
Mariano Sorgente
8f3ea9c81b
Update old comment on streamables (#8872)
* Update old comment on streamables

* Apply suggestions from code review

Co-authored-by: Arvid Norberg <arvid.norberg@gmail.com>

Co-authored-by: Arvid Norberg <arvid.norberg@gmail.com>
2021-10-19 10:37:31 -07:00
Arvid Norberg
732fb51fe0
add alternative to pkm_pairs_for_conditions_dict() which is a bit more straigh-forward and returns the public keys and messages in the forms we need them to validate them. This is a step towards simplifying the conditions data structures (#8128) 2021-10-19 06:26:53 -07:00
Arvid Norberg
1f893907b9
make db_sync setting default to FULL. Extend the configuration to cover all of OFF, NORMAL and OFF (#8836) 2021-10-16 09:02:18 -07:00
Jeff Cruikshank
3864f750b4
Backend changes to support passphrase hints and additional GUI passphrase support (#8779)
* Expose GUI option to save passphrase (where available)
Prevent GUI from showing the option to remove migrated keys

* Backend support for getting/setting the passphrase hint. The hint data is stored in keyring.yaml in the clear.

* CLI support for showing/setting/removing the passphrase hint

* Tests for setting/retrieving passphrase hints

* Squelch LGTM false positive

* Fixed issue when running without passphrase support enabled

* CLI updates based on feedback

* Initialize passphrase_hint earlier.

* Minor restructuring to address linter complaint.
2021-10-13 10:36:10 -07: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
Jeff Cruikshank
b1fda8f9a8
Fixes cherry-picked from fix_keyring_tests. (#8766)
* Fixes cherry-picked from fix_keyring_tests.

* Logging for the failing test_using_legacy_cryptfilekeyring test

* See if reordering the tests makes a difference.

* Revert "See if reordering the tests makes a difference."

This reverts commit b53807880b.

* Log changes to the _configure_legacy_backend patch

* Fixed patching

* Checking if something isn't cleaned up properly

* Revert "Checking if something isn't cleaned up properly"

This reverts commit ce995ba773.

* Revert "Fixed patching"

This reverts commit 66a70a16ff.

* Revert "Log changes to the _configure_legacy_backend patch"

This reverts commit 26791a40b7.

* Revert "Logging for the failing test_using_legacy_cryptfilekeyring test"

This reverts commit 4fd4873565.

* Move test_keyring_wrapper.py into a standalone test

* Small refactorings/changes per feedback
2021-10-08 11:02:46 -07:00
Arvid Norberg
61a513869d
make synchronous mode in sqlite database connections configurable (#8753)
* make synchronous mode in sqlite database connections configurabel. Default to enabling synchronous mode, leaving the door open for a more sophisticated heuristic in the future

* Update chia/util/db_synchronous.py

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

* Update chia/util/initial-config.yaml

Co-authored-by: Nino Uzelac <uzelac.nino@gmail.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
Co-authored-by: Nino Uzelac <uzelac.nino@gmail.com>
2021-10-08 06:13:06 -07:00
Jeff Cruikshank
26d23b9279
Keyring windows (#8465)
* Fix to allow migration of keys on macOS

* Fixed file_keyring synchronization test failures on macOS.
Fixed sporadic test failures on macOS when fsevents are delivered for the keyring after deletion.
TempKeyring-based tests now patch supports_os_passphrase_storage() to return False.

* Fixed LGTM issues

* Re-added the cleaning up temp keychain statement. This is being removed in a separate PR.

* Windows keyring passphrase support

* Test tweaks for Windows (mostly to support my slow VM)

* Linter fixes

* Restored prompt_for_passphrase() function which was accidentally removed during a rebase.

* Added CHIA_PASSPHRASE_SUPPORT env variable to allow more testing
2021-10-05 09:59:53 -07:00
Earle Lowe
7fdd0b2fd7
Improved mempool validation and test (#8652) 2021-09-30 16:07:22 -07:00
Jeff Cruikshank
1254d4decd
In rare cases where os.replace fails, retry using shutil.move. (#8589)
* In rare cases where os.replace() fails, retry using shutil.move. Seen on some Windows installs.

* Catch the PermissionError specifically
2021-09-24 13:24:03 -07:00
Jeff Cruikshank
a70082f29a
macOS keyring.yaml support (#8292)
* Added 'service' as a Keychain ctor param. Removed 'testing'

* Detect existing keys in the Mac Keychain

* Fix to allow migration of keys on macOS

* Added dump_keyring.py tool to show decrypted contents of keyring.yaml

* Prompt to save passphrase to macOS keychain

* Master passphrase retrieval/removal from the macOS Keychain.
Fixed typos.

* Warn if errSecInteractionNotAllowed is detected when accessing the macOS Keychain

* Fixed file_keyring synchronization test failures on macOS.
Fixed sporadic test failures on macOS when fsevents are delivered for the keyring after deletion.
TempKeyring-based tests now patch supports_os_passphrase_storage() to return False.

* TempKeyring mocks-out legacy_keyring setup to allow tests to succeed on macOS (which could find existing keys in the Keychain)

* Fixed pylint error

* Use with_name instead of with_stem (which is new to Python 3.9)

* Fixed keychain tests that started prompting for the keyring passphrase.

* Fixed LGTM issues

* Re-added the cleaning up temp keychain statement. This is being removed in a separate PR.

* Linter fixes

* Fixed keyring assignment on macOS when passphrase support is disabled.

* Include 'can_save_passphrase' flag in keyring_status response

* More linter fixes

* Fixed determination of the user_passphrase_is_set flag. This was returning true for a newly created keyring without any keys (or passphrase set)

* Removed the tidy_passphrase function per feedback

* Added some comments based on feedback

* Update chia/cmds/passphrase_funcs.py

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

Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
2021-09-24 10:32:57 -07:00
Oliver
b72f2c50af
Fix edge case with negative input (#8529) 2021-09-22 10:45:26 -07: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
Arvid Norberg
31dab2ae5f
Rust only conditions (#8467)
* no need to check announcements in python, it's all done in rust

* remove python condition parsing, use rust unconditionally

* no need to assert_my_amount, it's done in rust

* assert my puzzlehash is done in rust, no need to check it in python

* parent id is checked in rust, no need to do it in python

* my coin ID is checked in rust, no need to do it in python

* reorder condition checks to have to ones we won't see at the end

* no need for the RUST_CONDITION_CHECKER constant anymore

* update pool tests to use get_name_puzzle_condition
2021-09-18 10:25:19 -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
dustinface
4f98891877
typo: passphase -> passphrase, Passphase -> Passphrase (#8473) 2021-09-17 10:52:50 -07:00
Earle Lowe
6d37d5477c
configurable max message size (#8500) 2021-09-17 10:51:37 -07:00
Tobias "Knight" S
f21d14d02d
Fix shown permissions (#8450) 2021-09-13 13:20:52 -07:00
Jeff Cruikshank
fd7bba6ae5
Ensure that config.yaml and keyring.yaml aren't partially written-to (#8379)
* Ensure that the initial config isn't partially written-to

* Fixed linter error

* Use os.replace instead of shutil.move

* Tests for reading/writing config.yaml

* Linter fixes
2021-09-13 13:20:19 -07:00
Chris Marslender
d172efa3a3
Allow host to be configurable for timelord launcher (#8434)
* Let the timelord laucher connect to a configurable hostname

* Use 'host' to be more consistent with the other config sections

* Add timelord launcher host to initial config
2021-09-10 17:00:10 -07:00
matt-o-how
0096f755a1
DID Update Merge (#8129)
* fixed the bugs related to DID puzzles

* change test so that wallets recover into other wallets

* fix parent_info fetching when recovering

* fix did_test

* delete did tests related to singleton behaviours as that is tested elsewhere

* linting fixes

* update hash commit for did_innerpuz.clvm

* update DID wallet RPC calls

* more lint fixes

* delete further references to deprecated did_spend function

* fix bug in wallet state manager related to falsely detecting pool create

* added did_rpc test

* make sure amounts are uint64

* lint fixes

* Fix deadlock in DID wallet creation, and introduce create_new_did_wallet API call

* rename solution_to_pool_state

* Remove tests dir from packages

* added potential fix

* Allow getting unconfirmed balance from wallet_state_manager when under lock

* Remove a deadlock from create_new_did_wallet

* Update DID wallet test to use async check for farmed chia in wallet setup

* Fix unsigned arithmetic error

* Make DID wallet tests compatible with WalletStateManager lock checking

* check if removal belongs to the wallet

* unconfirmed

* did test cleanup

* fix temppuzhash to be an innerpuz

* clean up DID Wallet, add test for previously broken case

* added state_change call when coin added
added did_info for transaction sent

* update delete wallet parameters

* add comments to DID innerpuz

* fix duplicating bug with tx store

* re-enable did tests

* fix cc wallet bare raise

* remove unused assignation

* fix bare spend in did_wallet

* fix small bug

* messages are a cons box where the first value denotes type of message

* cc_wallet uses new parameter for get_confired_balance

* updates to the puzzle based upon suggestion by Richard

* update git submodule chia-blockchain-gui to did_branch

* updated gui to did_branch 76f9e6cea9f58a30984580b594631f3ae2679752

* updated gui to 041ac79be4

Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
Co-authored-by: Yostra <straya@chia.net>
Co-authored-by: William Blanke <wjb98672@gmail.com>
2021-09-07 12:48:41 -07:00
Arvid Norberg
6d60bfd58d
add debug option to log all SQL commands (#8324) 2021-09-03 14:13:45 -07:00
dustinface
2db9944687
plotting|util: Adjust plot refresh parameter (#8275) 2021-09-02 08:23:52 -07:00
dustinface
17dea1b708
plotting|util|tests: Fix and test re-trying of plots which failed to load (#8279)
* Revert "plotting: Fix failed_to_open_filenames re-try interval"

This reverts 8a8abc41a8 which is part of 
#7848. Seems like i confused myself there.

* plotting|util: Introduce `retry_invalid_seconds` in plot refresh params

* plotting: Cleanup `failed_to_open_filenames`

* tests: Test re-try of plots which failed to load
2021-09-01 09:21:29 -07:00
Jeff Cruikshank
5587375c03
RPC updates to support keyring migration and passphrase requirements (#8059)
* Added migrate_keyring daemon RPC support.
Passphrase requirements (min length, empty allowed) are now communicated to callers of the keyring_status RPC.
Refactored the keyring migration code to support interactive and non-interactive modes.

* Minor fixes for error handling during migration

* Cleaned up checking passphrase requirements

* Added a comment explaining why a failure is returned early in migrate_keyring if the keyring is already migrated

* Support for notifying the GUI and daemon when keyring status changes occur, including migration
2021-08-31 10:24:45 -07:00
Michael Graczyk
461fe82587
Fix type of FileKeyring.keyring_path (#8258)
This type is always non-None as it is assigned in __init__ from a call that returns non-None Path
2021-08-31 10:21:34 -07:00
Arvid Norberg
463b971613
break problematic dependency where the streamable infrastructure depends on Program, G1Element, G2Element and PrivateKey. (#8237) 2021-08-31 08:02:40 -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
Arvid Norberg
98b001682f
enable the rust condition checker unconditionally in testnet (#8122) 2021-08-24 10:53:46 -07:00
Almog De Paz
c4c14939a5
Sync faster (#7665)
* better concurrency for sync_from_fork_point

* dedup code in wallet

* revert

* lint

* lint

* logs

* lint

* lint

* error handling, async bug fix

* lint

* break fetch if bath failed coroutine

* remove outdated comment

* consolidate duplicate code

* consolidate duplicate code

* notify wallet after each batch

* typo

* add try/catch/finally

* typing, check stale peer

* comment on worker shutdown
2021-08-18 18:26:38 -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
dustinface
53149f2e57
chia|tests: Introduce PlotManager + some plot loading improvements and fixes (#7848)
* harvester|plotting|tests: Introduce `PlotManager` class

This moves all plots related and plot-directory related stuff from the
harvester into the class `PlotManager`, adjusts all related code
accordingly and adds some extra wrappers there.

* harvester|plotting|tests: Return how many new plots were loaded

* plotting: Fix `failed_to_open_filenames` re-try interval

With `< 1200` it just tries it on the next refresh.

* plotting: Fix and improve duplicates handling

* harvester|plotting: Thread locks for `PlotManager.plots`

* chia|tests: Load plots in batches

* chia|tests: Move plot refreshing into a separate thread

* plotting: Properly handle removed plots

And fix tests accordingly. It seems like this fix https://github.com/Chia-Network/chia-blockchain/pull/3350 wasn't really a fix, rather adjusting to allow for a bug?

* plotting|harvester|tests: Introduce `PlotRefreshResult`

* tests: Expand `test_farmer_harvester_rpc.py`

* chia|tests: Move some stuff from `plot_tools.py` into new file `util.py`

* refactor: Rename `plot_tools.py` to `manager.py`

* chia|tests: Use pure dataclass for `PlotsRefreshParameter`

With `uint16` as type saving to config doesn't work, this is a
preparation for the next commit.

* harvester: Adjust deprecation message, use `info` instead of `warning`

* plotting: Fix typo

* refactor: Rename `filename` to `file_path`

Fits better and does avoid shadowing with filename from outer scope.

* chia|tests: Move some methods from `plotting.manager` to `plotting.util`

* plotting: Make `refresh_callback` mandatory
2021-08-09 10:25:15 -07:00
dustinface
b1ade3ad81
refactor: Introduce write_uint32 and parse_uint32 in streamable.py (#7932)
* refactor: Introduce `parse_uint32` in `streamable.py`

* refactor: Introduce `write_uint32` in `streamable.py`

* tests: Add `test_uint32` in `test_streamable.py`

Adds tests for `write_uint32` and `parse_uint32`
2021-08-09 10:23:44 -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
Arvid Norberg
7927a45945
remove initial transaction freeze feature (#7922) 2021-08-03 10:21:37 -07:00
Arvid Norberg
485fab80b7
don't save unknown conditions (#7548)
* don't save unknown conditions

* remove UNKNOWN enum from ConditionOpcode enum
2021-08-02 14:40:32 -07:00
dustinface
b2fdeb2291
pre-commit: Add initial config and run it for all files (#7053)
* pre-commit: Add initial `.pre-commit-config.yaml`

* pre-commit: Apply hook `end-of-file-fixer`

* pre-commit: Apply hook `trailing-whitespace`

* pre-commit: Apply hook `debug-statements`

* contrib: Add `pre-commit` section
2021-08-02 10:48:22 -07:00
Rostislav Skudnov
89b96fb40d
Add pairing cache for faster aggregate signature verification (#7484)
* Add pairing cache to speed up aggregate signature verification

* Reduce excessive logging in test_performance.py

* Fix issues in cached_bls found in code review

Co-authored-by: Rostislav <rostislav@users.noreply.github.com>
2021-07-27 19:45:58 -07:00
wjblanke
d3599da0a0
reverting 7645 (#7708) 2021-07-22 09:00:36 -07:00
Earle Lowe
2d1b19d871
Option to revert back to sequential read (#7644)
* Option to revert back to sequential read

* reverse logic for disable

* Add parallel_read to initial-config
2021-07-21 10:37:07 -07:00
dustinface
5b690066c1
cmds|util|tests: Drop 0x prefix from JSON conversions (#7645)
Not sure if that has been done for a specific reason but i feel like its 
better to not have them in general. Let me know if there are any 
objections, im happy to close this PR if its for a reason i missed.
2021-07-20 13:01:58 -07:00
Richard Kiss
6cf29102f9
Rename coin solution to coin spend (#6841)
* Rename `CoinSolution` as `CoinSpend` everywhere.

* Run `black` everywhere.
2021-07-12 16:31:27 -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
Arvid Norberg
0368544c84
validate more aspects of conditions earlier (#6654)
* validate more aspects of conditions earlier, in the process clvm execution is offloaded to

* more tests

* use as_int() in SExp rather than int_from_bytes()

* put condition parser tests in its own test class

* capitalize module-scope variable

* abbreviate enum names in parse_condition_args

* use a more realistic cost per byte in test_rom

* merge parse_coin_id and parse_hash, since they are identical
2021-06-23 09:49:23 -07:00
Earle Lowe
150b6cc9b0
remove non-ascii space (#6842) 2021-06-18 05:22:01 -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
Gian Luca Decurtins
0ffbe1339c
Log syslog (#6490)
* Keep mnemnic as secret as possible

* Add logging support for remote syslog

* Fix lint (W293 and E251)

* syslog Formatter in one line

* Set log_syslog to False in case not specified
2021-06-14 19:11:35 -07:00
Arvid Norberg
ca3c8ce407
validate integers in StructStream constructors (#4298)
* validate integers in StructStream constructors

* don't step back sub slots beyond zero

* fix off-by-one in blocks-to-remove

* handle find_fork_point_in_chain() returning -1 in wallet

* fix handling of not finding a shared ancestor in wallet reorg

* terminate clean_block_record() when we reach height 0

* harden int/uint validation in constructor. add comment about int512
2021-06-08 10:45:56 -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
Nikolaj Kuntner
0b3124821f
bytes formatting simplify (#6021)
* init

* Add dash in README

* add more test cases

* whitespace around ==

* explicit return

* add another large test case
2021-05-26 11:11:44 -07:00
Arvid Norberg
203232e429
add profiler to wallet process (#6019) 2021-05-26 11:01:17 -07:00
Ruslan Skorb
9e21716965
Add format_bytes(bytes:) function to convert bytes to human readable string. (#5449) 2021-05-24 22:14:29 -07:00
elliottback
6f06f047a5
Add an explicit error message (#4758)
* Add an explicit error message when mnemonic words are not in the dictionary; should help users self-service issues like #3425 faster.

* fix lint

* fix lint x2
2021-05-21 18:14:49 -07:00
Florin Chirica
bb662f27dc Address review comments. 2021-05-14 14:05:12 -06:00
Florin Chirica
413d29083f Initial commit. 2021-05-14 14:05:12 -06:00
Rostislav Skudnov
b2800c94fa
Optimize Streamable parsing by avoiding extra post-init checks (#4714)
* Optimize Streamable parsing by avoiding extra post-init checks

A performance test indicates that this optimization makes parsing block
records from database up to 40% faster (0.66 vs 1.09 seconds for 10000
records).

* Add type annotations, remove unnecessary .keys() call in Streamable

Co-authored-by: Rostislav <rostislav@users.noreply.github.com>
2021-05-13 10:33:59 -07:00
Almog De Paz
3277058372
optional no_tx_filter (#4560)
* add no_tx option to get_header_blocks_in_range

* add type

* get_header_block_by_height no_tx_filter

* double negetive

* add param name

* param name

* change filter to false

* test header hash

* lint
2021-05-13 10:29:53 -07: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
5034fcc85d
Add more types (#3441) 2021-05-12 15:32:21 -07:00
Arvid Norberg
12751ce811
add simple profiler, enabled by enable_profiler config (#4054)
Analyze profilers with chia/utils/profiler.py
2021-05-12 10:46:38 -07:00
Mariano Sorgente
5d3d4bbefc
No negative amounts (#4294)
Mempool no negative amounts
Don't disconnect for COIN_AMOUNT_NEGATIVE
2021-05-10 01:28:15 +09:00
justinengland
ec0a4cec4b fixing dupes 2021-05-05 18:19:45 -06:00
justinengland
0f2af011d5 adding testnet0 back 2021-05-05 18:19:45 -06:00
justinengland
bff9e4a248 adding configure options. removing old testnets 2021-05-05 18:19:45 -06:00
Mariano Sorgente
d044cbb763
2 harvesting features (#3331)
* 3 harvesting features:
- Debug level shows the time for every quality lookup
- Warning level if takes longer than 5 seconds
- Allow configuration of plot loading interval (default 2 minutes)

* Comment out super logging
2021-05-01 10:16:19 -07:00
Richard Kiss
a7f996b4dc
Tests skipping mempool (#3065)
* Avoid importing `test_constants` as it takes a long time.

* Some new tests that circumvents mempool.

* Fix lint problems.
2021-04-30 10:23:45 -07:00
Richard Kiss
b084813b12
Improve streamable (#3031)
* Avoid importing `test_constants` as it takes a long time.

* Factor out `parse_*` functions.

* First crack at refactoring `Streamable.parse`.

* Don't add `_parse_functions` attribute to `Streamable`.

This no longer requires an extra `_parse_functions` attribute on a
`Streamable`, as it may be confusing serializers or other functions
that use `__annotations__`.

* Fix lint problems with `black`.

* Fix `parse_tuple`.

* Defer some parsing failures to parse time rather than class-creation time.

* Tidy up & remove some obsolete stuff.

* Decorate `RequestBlocks` as `streamable`.

* Fix wrong uses of Streamable class

Revert an earlier commit and error out on class creation in case a
Streamable subclass is instantiated incorrectly, e.g. containing a
non-serializable member.

Fix cases where Streamable parent class was forgotten.

* Fix wrong types when creating DerivationRecord and WalletCoinRecord

* additional unit tests for streamable parsers

* add type annotations (#3222)

Co-authored-by: Rostislav <rostislav@users.noreply.github.com>
Co-authored-by: arvidn <arvid@libtorrent.org>
2021-04-30 10:22:11 -07:00
Yostra
44728ff98d
increase ratio (#3155) 2021-04-30 10:14:56 -07:00
matt-o-how
637177519a
Add announcements for standard tx (#3023)
* changed bahviour of wallet and wallet tools for standard solutions

* black formatting wallet_tools

* added a test for hypothetical stolen zero_output coin

* swap to sha256 from sha256tree for message

* fix wallet_tools version, address lint issues

* correctly int_from_bytes

* fix uninstantiated key in dict

* Comment out broken test

* Fix types (used SerializedProgram)

Co-authored-by: Mariano <sorgente711@gmail.com>
2021-04-30 03:13:00 +09:00
Antonio Borrero Granell
ad205d9cd6
Fix typo (#3069) 2021-04-29 13:30:07 -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
621c13c249
Improve safety of coin store (#2984)
* Improve safety of coin store

* Add test for exception

* Fix issue with fork_point_with_peak
2021-04-28 15:27:56 -04:00
Mariano Sorgente
8aed3645be
1,2,3 mojo attack prevention (#3017) 2021-04-28 10:52:22 -07:00
wjblanke
ec48e968a9
increase wp timeout from 3 minutes (2 megabit) to 6 minutes (1 megabit) (#3022) 2021-04-28 10:51:18 -07:00
Yostra
4ef3777119
Avoid multiple requests (#2860)
* avoid dupe requests

* move to store, clean tasks

* linting

* limit

* 10peers,5sec
2021-04-28 02:58:45 -04:00
Arvid Norberg
8717ca4b02
Leave programs in SpendBundle serialized (#2380) 2021-04-27 10:52:21 -07:00
Yostra
a929ec889e
Use lru cache (#2433)
* use lru cache

* use new func

* cache block after write is done

* dont iterate as orederd dict
2021-04-26 23:21:58 -07:00
Yostra
4c98dd2b71
decorator (#2221) 2021-04-26 23:21:04 -07:00