Commit Graph
1149 Commits
Author SHA1 Message Date
almog f75eb12ff8 Merge branch 'main' into api_none_response
# Conflicts:
#	chia/full_node/full_node.py
#	chia/server/ws_connection.py
2021-09-19 12:10:29 +03:00
YostraandGitHub 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 NorbergandGitHub 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
Arvid NorbergandGitHub f5dca63048 improve CoinStore test (#8495)
* improve CoinStore test by using pytest parameters (instead of for loops) and use a context manager for the DB connection

* use temporary filename for sqlite db
2021-09-17 14:09:02 -07:00
Jeff CruikshankandGitHub fb086bcdc1 Switched from using asyncio.to_thread to threading.Thread as to_thread is only available in Python 3.9 (#8481) 2021-09-17 10:54:53 -07:00
Arvid NorbergandGitHub 55baeb532a remove CoinStore's dependency on FullBlock. Just pass in the parts of the block necessary to add the block. Even though this is a net increase in lines of code (for now), it improves encapsulation of the CoinStore class and enables simpler tests of it (#8496) 2021-09-17 10:40:44 -07:00
dustinfaceandGitHub ada12b3f42 tests: Fix rmtree call in create_pool_plot (#8463) 2021-09-13 13:20:36 -07:00
Jeff CruikshankandGitHub 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
Jeff CruikshankandGitHub 1ac7e58140 Added validate_keyring_passphrase RPC. Includes a test in test_daemon. (#8325)
Some minor refactoring to support writing tidier RPC tests.
2021-09-13 13:19:52 -07:00
Arvid NorbergandGitHub 0b92c89e7d Conditions parser (#8393)
* tests for invalid list terminators in conditions

* bump clvm_rs version
2021-09-08 14:46:25 -07:00
dustinfaceandGitHub 64a8249d75 plotting|tests: Fix two PlotsRefreshParameter instantiations (#8367)
* tests: Set `batch_size` to `2` in `setup_plots`

The idea here was to test something smaller than the plots we load.

Fix after 17dea1b708.

* plotting: Set `batch_sleep_milliseconds` to `0` in `check_plots`

The idea here was to have less sleep time since we don't need to give 
other threads the chance to jump in. It was `1` before but `0` makes 
more sense imo.

Fix after 17dea1b708.
2021-09-07 14:02:19 -07:00
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 041ac79be4af360d856a6527a4b8f4a074415a9a

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
dustinfaceandGitHub 17cb41ae16 plotting|tests: Cache plot data in PlotManager (#8009) 2021-09-02 08:22:48 -07:00
dustinfaceandGitHub 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
Arvid NorbergandGitHub 3f67425d06 simplify the block_tools test facility. We don't need to parse out the full conditions, just know what the total cost of the generator is (#8236) 2021-08-31 08:01:35 -07:00
Arvid NorbergandGitHub 70fb97c986 make TestCostCalculation deterministic and check against a specific cost (#8274) 2021-08-31 08:01:03 -07:00
almog 40a6db45ca test backward comp 2021-08-25 15:20:09 +03:00
Kyle AltendorfandGitHub a72995495e Correct * to ** kwargs unpacking in time_out_assert() (#8160) 2021-08-24 10:56:42 -07:00
YostraandGitHub f918669f32 Fix single coin generator (#8185)
* fix single coin generator

* add sha256tree file

* add test for single

* pass it as array

* remove breakpoint
2021-08-24 10:50:40 -07:00
almog 7a37603ac0 backward compatibility 2021-08-19 16:44:33 +03:00
almog 372ac8a3f1 Merge branch 'main' into api_none_response 2021-08-19 16:42:20 +03:00
Arvid NorbergandGitHub cd2f9d9d00 remove commented-out debug breakpoint()s (#8114) 2021-08-18 10:13:03 -07:00
almog a388a976f8 Merge branch 'main' into api_none_response 2021-08-18 15:45:48 +03:00
Arvid NorbergandGitHub d81198384f fix mempool TX cache cost (#8054)
* fix issue where the cost of the mempool TX cache (for spend bundles that can't be included in a block yet) would not be reset when the cache was emptied

* factor out the Pending TX cache from mempool, to allow unit testing
2021-08-17 23:09:15 -07:00
Chris MarslenderandGitHub 00af150e00 Increase timeout (#8111)
* Increase timeout

* increase timeout to 30
2021-08-17 19:54:50 -07:00
Arvid NorbergandGitHub 5ee182932e Rust conditions (#7167)
* use rust implementation of condition checker

* enable rust condition checker at specific block height

* bump switch-over height
2021-08-17 14:57:41 -07:00
Matt HauffandGitHub 90313d9205 Added an RPC for coin records by multiple coin names (#7920) 2021-08-17 10:52:51 -07:00
almog 07c11a8847 add ability to send and receive None response 2021-08-16 17:59:55 +03:00
Jeff CruikshankandGitHub 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
7b2aab99c8 Add test of pairing cache for BLS signature verification (#8028)
Co-authored-by: Rostislav <rostislav@users.noreply.github.com>
2021-08-12 12:00:22 -07:00
Arvid NorbergandGitHub 750a2759a3 test agg sig conditions (#7962)
* agg sig conditions always take two args

* extend test a bit, add comment

* unit test agg sig parser where args list is not null terminated

* fix formatting
2021-08-10 15:26:29 -07:00
dustinfaceandGitHub 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
dustinfaceandGitHub 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
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
Chris MarslenderandGitHub 6a7034ffaa Swap password to just be "foo" (#7946) 2021-08-04 09:58:53 -07:00
Chris MarslenderandGitHub deac3ad3cc Create keychain for use in CI jobs (#7933)
* Create keychain for use in CI jobs

* Add local keychain in the template for workflow generation
2021-08-03 13:52:12 -07:00
Arvid NorbergandGitHub 7927a45945 remove initial transaction freeze feature (#7922) 2021-08-03 10:21:37 -07:00
Arvid NorbergandGitHub d380957460 remove trailing whitespace in generated workflow files (#7921) 2021-08-02 17:14:25 -07:00
Arvid NorbergandGitHub 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
dustinfaceandGitHub 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
dustinfaceandGitHub 74f88690b4 refactor: Rename folder tests/core/types to tests/core/custom_types (#7852)
* refactor: Rename folder `tests/core/types` to `tests/core/custom_types`

Seems like the name `types` in the folder conflicts there with some python
standard stuff because i just can't get the debugger in PyCharm to work
without this renaming. Instantly getting the following error:

```
ImportError: cannot import name 'MappingProxyType' from 'types'
(/home/me/chia/chia-blockchain/tests/core/types/__init__.py)
Traceback (most recent call last):
  File
"/snap/pycharm-professional/248/plugins/python/helpers/pydev/pydevd.py",
line 8, in <module>
    from contextlib import contextmanager
  File "/usr/lib/python3.8/contextlib.py", line 7, in <module>
    from types import MethodType
ImportError: cannot import name 'MethodType' from 'types'
(/home/me/chia/chia-blockchain/tests/core/types/__init__.py)
```

If someone has an idea how else to fix this please tell me!

* github: Run `build-workflows.py`

With DID tests dropped!
2021-08-02 10:41:34 -07:00
Adam KellyandGitHub f05988fc6d Disable DID wallet tests while DID wallet is under construction. (#7862) 2021-08-02 10:40:59 -07:00
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
Almog De PazandGitHub 85fd9f7d89 add block height assertions after block farming (#7526)
add tx confirmed assertions
use time_out_assert only when needed
2021-07-27 14:21:19 -07:00
Arvid NorbergandGitHub c6bf1910d0 extend initial freeze test (#7580) 2021-07-27 10:30:48 -07:00
dustinfaceandGitHub efd8facf54 farmer|tests: Always bump last_update in update_cached_harvesters (#7792)
* farmer: Always bump `last_update` in `update_cached_harvesters`

* tests: Wait a bit for the harvester in `test_farmer_harvester_rpc.py`
2021-07-26 10:14:42 -07:00
wjblankeandGitHub d3599da0a0 reverting 7645 (#7708) 2021-07-22 09:00:36 -07:00
30cb11a051 Partial reversion of CoinSpend rename for API compatibility (#7636)
* Partial reversion of the coin spend rename

* Make `SpendBundle` json-serialize the classic way by default.

Co-authored-by: Richard Kiss <him@richardkiss.com>
2021-07-21 10:24:47 -07:00
dustinfaceandGitHub 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
51a7adf966 add mempool tests (#7519)
* add mempool tests

* Update tests/core/full_node/test_mempool.py

Co-authored-by: Richard Kiss <him@richardkiss.com>

* Update tests/core/full_node/test_mempool.py

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

* Update tests/core/full_node/test_mempool.py

Co-authored-by: Richard Kiss <him@richardkiss.com>

* Update tests/core/full_node/test_mempool.py

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

Co-authored-by: Richard Kiss <him@richardkiss.com>
Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
2021-07-16 11:43:13 -07:00