Commit Graph

3337 Commits

Author SHA1 Message Date
Arvid Norberg
ed0f0eba67
fix flaky MAX_FUTURE_TIME test (#15499)
fix MAX_FUTURE_TIME tests
2023-06-13 09:56:25 -05:00
William Allen
fde6d6fe73
checkpoint: into main from release/1.8.2 @ c55be8e163 (#15476)
Source hash: c55be8e163
Remaining commits: 1
2023-06-09 17:33:19 -05:00
Matt Hauff
cf15c0fcb9
rename exclude_coin_* -> excluded_coin_* for consistency (#15460)
* exclude -> excluded

* Add a bit of test coverage

* fix bad change

* Add test coverage

* Add a little more test coverage
2023-06-09 16:35:53 -05:00
dustinface
5e0b8bb1ec
util: Drop chia.util.chunks and use chia.util.to_batches instead (#15418) 2023-06-09 16:35:31 -05:00
Kronus91
82c9ed953d
Clawback fixes (#15475)
Fix Clawback known issues
2023-06-09 12:15:40 -05:00
Amine Khaldi
37891cf01f
Merge commit 'c55be8e16364750ede9694ebdf58d5d143ecef97' into checkpoint/main_from_release_1.8.2_c55be8e16364750ede9694ebdf58d5d143ecef97 2023-06-09 17:15:14 +01:00
dustinface
e3beca2d0d
full_node: More set usage in subscription code (#15420) 2023-06-09 05:11:54 -05:00
Arvid Norberg
3ccaf37f77
use a more aggresive activation schedule on testnet10 (#15376) 2023-06-09 05:09:24 -05:00
William Allen
591e59a6cc
checkpoint: into main from release/1.8.2 @ f0071358bf (#15451)
Source hash: f0071358bf
Remaining commits: 2
2023-06-08 20:17:20 -05:00
Kyle Altendorf
9e8d6ebd71
rework LockQueue as PriorityMutex (#14920)
* explore a simplification of the blockchain priority lock queue

* add some tests

* correct task tracking

* use time.perf_counter for better resolution on windows

* just count an integer for request order retention

* stop using time in the (new) tests as well

* add tests and a couple no covers

* less existing test refactoring

* use a sync PriorityQueue

* switch to deques

* address bugs and simplify priority to deque mapping

* remove unused attribute ._priority_type

* make LockQueu.create() not async

* explain the active element check on wait cancellation

* drop LockQueue._process()

* import final from typing_extensions

* rename LockQueue to PriorityMutex

* remove test from mypy exclusions

* clean up straggling lock references

* ignore test failure case line coverage

* add a monkeypatch test ;[

* remove queued callback feature

* remove todos
2023-06-07 14:08:45 -05:00
dustinface
d23ea4df38
server: Fix versions for incoming connections (#15465) 2023-06-07 14:07:56 -05:00
Amine Khaldi
c8ee474583
Merge commit 'f0071358bf9a226af8adb2ad12105b3e3d015515' into checkpoint/main_from_release_1.8.2_f0071358bf9a226af8adb2ad12105b3e3d015515 2023-06-07 15:20:23 +01:00
Matt Hauff
0bd6a8ac3b
Move CAT_MOD from cat_loader -> cat_utils (#15459)
Move CAT_MOD from chia.wallet.puzzles.cat_loader -> chia.wallet.cat_wallet.cat_utils
2023-06-06 19:13:11 -05:00
Matt Hauff
35cc3debe9
Add a path in wallets_prefarm test fixture for generating an RPC client (#15426)
* add a path in wallets_prefarm for generating an RPC client

* Separate into new fixture

* Return wallet services as well
2023-06-06 12:40:17 -05:00
dustinface
b2cbea84d9
wallet: Hint puzzle_utils.py (#15422) 2023-06-06 12:39:15 -05:00
dustinface
ebc5f3c124
util: Improve list_to_batches (#15415)
* Make `list_to_batches` work with collections instead of lists only

* Move `to_batches` into `chia.util.misc`

* Only support `set` and `list`

* Drop `tests.generator.test_to_batches` exclusion

* Improve type restrictions and be more coverage friendly in tests
2023-06-06 12:00:07 -05:00
Earle Lowe
c55be8e163
Check all peers when subscribing/tracking to new DL singleton (#15427) 2023-06-05 11:26:56 -05:00
William Allen
349f87facf
checkpoint: into main from release/1.8.2 @ ef68bf76c1 (#15431)
Source hash: ef68bf76c1
Remaining commits: 0
2023-06-05 11:23:15 -05:00
Sebastjan Trepca
330c75022a
reduce the resend timeout to fix flakiness (#15435)
reduce the resend timeout
2023-06-05 10:54:03 -05:00
Kronus91
f0071358bf
Clawback Integration (#14348)
* Clawback integration draft

* Add unit test

* Clawback rework

* Fix unit test

* Fix coin type

* Add tx fee & bulk clawback

* Add manual claim

* Add get_clawback_coins API

* Fix unit test

* Fix unit test

* Resolve comments

* Fix unit test

* remove erroneous comment from p2_1_of_n.clvm

* Resolve comments

* use full puzzle instead of hash in augmented_condition.clvm

* Fix pre-commit

* Add set auto claim api

* Resolve comments

* Fix precommit

* Add get auto claim config api

* Fix pre-commit

* Fix mypy and unit tests

* Switch to reuse coin store solution

* Fix unit tests

* Fix pylint

* Resolve comments

* Fix rename

* Revert puzzle_decorator_type since circular import

* Resolve comments

* Add new coin_type & metadata to coin_records

* Remove unrelated changes

* Fix pre-commit

* Remove unrelated changes

* Fix pre-commit

* Add get_coin_records_between

* Fix field data type

* Resolve comments

* Fix unit test

* Remove unrelated changes

* Remove unrelated changes

* Improve unit tests

* Resolve comments

* Fix clvm hex

* Fix unit tests

* Fix API router

* Update rpc client

* Fix pre-commit

* Remove unrelated changes

* Fix set/get auto claim

* Force populate secret key for clawback

* optimizations

* added clawback puzzle hashes

* update drivers and add lifecycle tests

* Fix driver Program types

* avoid redundant uncurry in clawback

* simplify deserialize_coin_metadata()

* run clawback puzzles with a lower cost limit

* Update chia/wallet/wallet_state_manager.py

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

* Add tx records for Clawback

* Add clawback coin id

* Add type filter for get_transactions

* Modify clawback tx types

* Resolve comments

* Resolve comments

* Fix unit tests

* Resolve comments

* Improve unit test

* Use merkle tree class

* Resolve comments

* Resolve comments

* Fix curry tree hash

* Improve coverage

* Improve coverage

* Fix unit test

* Fix test

* Improve coverage

* Fix pre-commit

* Resolve comments

* Handle invalid clawback metadata

* Fix unit tests

* Improve coverage

* Handle empty byte issue

* Forward memo

* Fix unit test

* Resolve comments

* Rework Clawback TX management

* Add confirmed filter

* Resolve comments

* Fix unit test

* Fix pre-commit

* Improve coverage

* Fix unit test

* Handle missing auto_claim config

* Fix pre-commit

* Revert tx confirmed change

* Drop unused `deserialize_coin_metadata`

* Parse clawback metadata in `WalletCoinRecord.parsed_metadata`

* Use `WalletCoinRecord.parsed_metadata`

* Avoid querying low amount coins with the `amount_range` parameter

* Drop unused `to_puzhash`

* Drop `print("Ping")`

* Drop outdated assert

* Resolve comments

* Fix coverage

---------

Co-authored-by: geoffwalmsley <geoffwalmsley@gmail.com>
Co-authored-by: Sebastjan Trepca <trepca@gmail.com>
Co-authored-by: arvidn <arvid@libtorrent.org>
Co-authored-by: xdustinface <xdustinfacex@gmail.com>
2023-06-05 10:53:34 -05:00
Matt Hauff
5dd204a001
Fix .get_next_from_coin_spend on VerifiedCredential and test new puzhashes (#15423)
Fix .get_next_from_coin_spend on VCWallet and test new puzhashes
2023-06-02 17:54:04 -05:00
Arvid Norberg
ae0939af79
bump SOFT_FORK3_HEIGHT to align with the next release cycle (#15428) 2023-06-01 21:48:01 -05:00
Kronus91
ef68bf76c1
Add confirmed filter for get_transactions (#15374)
* Add confirmed filter

* resolve comment
2023-06-01 11:53:59 -05:00
Sebastjan Trepca
f4204de752
get_wallet_balances (#15367)
* added get_wallet_balances rpc api

* whitespace

* get_wallet_balances for GUI convenience

* test for specified ids

* wait for bundles to get into mempool
2023-05-31 11:28:40 -05:00
Amine Khaldi
fbe7daa32e
Convert blockchain_constants's consensus_mode param into a fixture and use it to skip some simulation related tests in HARD_FORK_2_0 mode (#15384)
* Convert blockchain_constants's consensus_mode param into a fixture and use it to run daemon_simulation one at a time.

* Simulation test seems to support only one running at a time too.
2023-05-26 11:31:14 -05:00
Arvid Norberg
6effab5dd2
remove unused test functions (#15375)
Mariano removed the test using these functions a long time ago
2023-05-25 14:05:08 -05:00
Amine Khaldi
36bc639ed9
Annotate test_farmer_harvester_rpc.py (#15377)
Annotate test_farmer_harvester_rpc.py.
2023-05-24 16:49:53 -05:00
dustinface
1141f1cdbd
wallet: Refactor WalletStateManager.get_keys (#15361)
* wallet: Refactor `WalletStateManager.get_keys`

* Test `WalletStateManager.get_private_key`
2023-05-24 16:49:36 -05:00
Adam Kelly
e2ed6a4833
Typecheck tests/tools/test_full_sync.py (#14947)
* Typecheck tests/tools/test_full_sync.py

* Merge remote-tracking branch 'origin/main' into ak.typecheck-test_full_sync

* typecheck test_full_sync.py

* Revert "typecheck test_full_sync.py"

This reverts commit e5c0d9d565.

* Revert "Merge remote-tracking branch 'origin/main' into ak.typecheck-test_full_sync"

This reverts commit e5d0e57000.

* typecheck tests.toos.test_full_sync

---------

Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-05-23 19:53:20 -05:00
Adam Kelly
41e17cdec9
Typecheck node_height.py (#14940)
* Typecheck node_height.py

* typecheck node_height

* return false if peak is none per code review

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-05-23 19:52:49 -05:00
Arvid Norberg
ae934ec0a9
update build_network_protocol_files.py (#15345)
* update build_network_protocol_files.py to generate the mypy-compatible files (which were fixed already, but the generator script was not). Specifically, tests/util/test_network_protocol_files.py was changed manually. This makes it possible to rerun the generation without breaking mypy

* run build_network_protocol_files.py in CI to ensure its generated files are up-to-date

* fixup mypy exclusions
2023-05-23 14:30:07 -05:00
Kyle Altendorf
5d14f0a208
add test coverage for starting a node with an existing db (#15338)
* add test coverage for starting a node with an existing db

* Update chia/simulator/setup_services.py
2023-05-23 14:27:10 -05:00
Adam Kelly
d1e10ea920
Remove test_setproctitle.py from mypy exclusions (#14939)
* Remove test_setproctitle.py from mypy exclusions

* typecheck test_setproctitle.py

---------

Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-05-23 14:25:08 -05:00
Arvid Norberg
ff226e8cb7
make sure tests that use BlockTools use a single source of consensus constants (#15364)
make sure tests that use BlockTools use a single source of consensus constants. This is in preparations for being able to run tests with different sets of constants, e.g. the hard-fork constants
2023-05-23 12:02:28 -05:00
Amine Khaldi
37d87c99c1
Annotate test_farmer_harvester.py (#15350) 2023-05-23 06:08:12 -05:00
dustinface
e9a260f3d9
wallet: Implement /get_coin_records RPC command (#15100)
Implement RPC command `get_coin_records`
2023-05-23 04:45:49 -05:00
Amine Khaldi
d892ed2c97
Fix Farmer imports in plot sync tests (#15346)
Fix Farmer imports in plot sync tests.
2023-05-22 17:37:34 -05:00
Kyle Altendorf
fab36d5b4e
hint and test dump keyring (#15355) 2023-05-22 14:54:46 -05:00
Arvid Norberg
f0433d2a47
Weight proof typing (#15316)
* add type hints to test_proof_of_space.py

* add type hints to weight_proof.py
2023-05-22 10:23:33 -05:00
dustinface
1777ecc2e8
server: Store Version objects instead of str in WSChiaConnection (#15330)
* server: Store `Version` objects instead of `str` in `WSChiaConnection`

* Test connection versions
2023-05-19 13:45:00 -05:00
Arvid Norberg
621c75e4ba
Fork infrastructure (#15299)
* remove softfork-logic for 1.7 softfork (which has already activated)

* add new constants for soft-fork3, hard-fork and the other plot-filter adjustments
2023-05-18 20:20:11 -05:00
dustinface
c5714b1720
wallet: Fix filter imports (#15325) 2023-05-18 13:19:57 -05:00
dustinface
9e9c75912f
full_node: Refactor get_puzzle_and_solution_for_coin (#15323) 2023-05-17 17:34:33 -05:00
Jack Nelson
f2cc1f2ea1
Have simulator not rely on chia_root as originally implemented. & fix simulator tests (#15157)
* fix parent path issue

* Update default_root.py

* remove fstring

* Update test-single.yml

* allow for multiple parallel runs
2023-05-17 12:55:12 -05:00
Kyle Altendorf
d6d8eaa984
use isort from the venv when running from pre-commit (#15310)
* use isort from the venv when running from pre-commit

* remove old isort pre-commit entries
2023-05-17 10:53:02 -05:00
Matt Hauff
d9aedb5494
Fix flaky VC test (#15289)
* Fix flaky VC test

* mypy

* fix coverage
2023-05-17 10:23:46 -05:00
Amine Khaldi
b4c161ec57
Merge commit '61ad4dae37b9fd9a1dcd61416d3d7eaae0cc2fe3' into checkpoint/main_from_release_1.8.1_61ad4dae37b9fd9a1dcd61416d3d7eaae0cc2fe3 2023-05-17 11:15:52 +01:00
Arvid Norberg
61ad4dae37
optimize compact proofs (#15304) 2023-05-16 16:45:22 -05:00
Matt Hauff
4603b9d768
Decorrelate forwards_compat and reuse_puzhash from trade test params (#15287)
Decorrelate forwards compat and reuse_puzhash from trade test params
2023-05-15 19:50:56 -05:00
Matt Hauff
598450f320
Pass VC fee parameter all the way through and check balances in tests (#15286)
Pass fee all the way through and check balances in tests
2023-05-15 19:49:31 -05:00
Kronus91
d5a56f756e
Add type filter for get_transactions (#15196)
* Add type filter for get_transactions

* Resolve comments

* Improve unit test

* Resolve comments

* Resolve comments
2023-05-15 10:19:06 -05:00
Earle Lowe
432d2ee308
Add some more daemon "rpc" tests (#15215)
* Add some more daemon "rpc" tests

* fixes due to some platform differences

* Add unlock_keyring tests and some experiments with monkeypatch

* rewrote simpler tests into single paramterized test

* add parameters to patch function

* Use monkeypatch.context for better isolation

* remove monkeypatch and test by deleting the keyring file

* remove now unused monkeypatch function

* changes from PR suggestions

* more readable parameterization per suggestions

* datacases

* description and id property

* swap description and route order

* *cases

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-05-12 17:48:41 -05:00
Kyle Altendorf
217429a126
add datacases() and named_datacases() (#15265)
* add `datacases()` and `named_datacases()`

* correct DataCasesProtocol

* add back the tests for testing the test utilities
2023-05-12 12:58:45 -05:00
Amine Khaldi
eb898dfe95
Identical spend aggregation (#13799)
* Exploring identical spend aggregation.

* Attempt to address review.

* Revert this.

* Explore spend-based processing instead of the bundle-based one.

* Attempt to address reviews.

* Update against chia_rs and add some improvements.

* Leverage the fact that we're in a function now to perform early exits.

* Explore propagating exceptions.

* Relax the exception handling.

* Add unit tests.

* Add some comments and perform some renames for more readability.

* Refactor tests and split them by scenario.

* Take Arvid's suggestion to simplify the check.

* Improve test readability.

* Make the set explicit instead of computing it with union().

* Run in MEMPOOL_MODE for cost and additions.

* Use int_from_bytes() instead of int.from_bytes().

* Add more unit tests for run_for_cost_and_additions (to cover coin amount 0 as well as a negative amount).

* Don't use as_python() for created coins.

* Account for the cost of create coin conditions and extract additions from the NPCResult.

* Rely on NPCResult for the maximum allowed cost.

* Stop looking for the relevant spend at the first occurrence (then process its created coins).

* Add a unit test for spending a coin in different ways then finding it spent in new peak.

This makes sure all mempool items that would spend that coin get removed.

* Parameterize the test for spending a coin in different ways then finding it spent in new peak, to account for both the optimized and the reorg code paths.

* Keep track of coin spends cost and additions in mempool items in case they won't make it into the block, so we don't rerun that again next time.

* Extend replace by fee tests with eligibility scenarios.

* Refactor find_duplicate_spends into get_deduplication_info and process_mempool_items into create_bundle_from_mempool_items.
Slightly refactor check_removals and create_bundle_from_mempool.

* Cast to uint64 in the return statement.

* Adapt to the recent addition of seq.

* Add unit tests for mempool items' bundle_coin_spends.

* Leverage the recently added make_test_conds when creating this npc_result.

* Pass in bundle_coin_spends and max_cost instead of InternalMempoolItem so that it remains internal.

* Add a test for the scenario where we pick a sub-optimal aggregation by deduplicating on solution A, seen in a relatively higher FPC item, then receiving better cost saving items on solution B after that one.

* Add some end-to-end tests for identical spend aggregation.

* Add a comment documenting why eligible_coin_spends map is ephemeral.
2023-05-12 10:55:53 -05:00
Earle Lowe
ee70a978de
Remove unused alert server test code and support files (#15249)
* Remove unused test code

* Remove remainder of defunct alert code
2023-05-12 00:12:30 -05:00
Matt Hauff
c1c4f99f6c
Introduce Verifiable Credentials Primitive (#15059)
* First crack at VC puzzles

* Add p2_puzzle_or_hidden_puzzle

* First crack at drivers

* Basic test infra

* compile clsp and test covenant layer

* lint

* Add test for match_covenant_layer

* Add tests for DID TP

* Add tests for DID backdoor

* Add tests for p2_puzzle_or_hidden_puzzle

* Change DID backdoor -> p2_puzzle_w_auth + did_puzzle_authorizer

* Add a VerifiedCredential class

* Make p2_puz_or_hidden_puz viral

* Add morpher solution to covenant layer

* Add capability to update the proofs of a VC

* update_proofs -> do_spend

* Finish lifecycle of VC

* Make backdoor puzzle, remove p2_puzzle_w_auth from stack

* Extract p2_puzzle_w_auth to its own files

* lint

* rework launch process so it works after revocation

* Add some extra tests for the final state after revocation

* Add cost logging

* slight opimizations

* python comments and ergonomic improvements

* Comments for chialisp

* Add VC wallet and store infra

* Add a negative test for updating proofs w/o DID

* First crack at CR CAT

* Turn two hashes into one

* Extract some shatrees out of puzzle hash creation

* Add a stager function

* Precalculate initial_singleton_inner_puzhash_hash

* Add another stager

* Refine stagers

* Add cost logging and assert provider is authorized

* Add sketched out CRCAT class

* black

* Test most of CRCAT drivers

* lint

* Remove an unnecessary param

* Don't commit to singleton ID in parent morpher

* Extract DID to ownership layer

* lint

* use intitial puzzle hash for covenant as proof to morpher

* Collapse hash of parent morhper

* Remove stagers

* Rename some params

* Use SELF_HASH construct

* remove dependency on shatree

* Minor optimization of curried hashes

* Balance tree

* hint -> remark

* Make a v2 ownership layer for cost-sake

* (WIP) Migrate to tp hash at ownership layer

* (WIP) Return tp_hash from tp

* use a stager again

* use constants for ints

* use more constants

* inline a function, get rid of constant

* Switch to tree metadata on ownership layer

* Impelement wallet launch vc

* Minor fixes and rename a bunch of stuff

* lint

* Fix tests

* First crack at proof checking

* Remove unused imports

* Merge tests to get better coverageg

* Fix is_vc methods

* pre-commit

* pre-commit again

* Implement VC spend

* make sql pre-commit check work with git worktrees

* CRCATWallet

* Comment reasoning in script file

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

* Add a concept of VCProofs

* Show proofs in vc_get_vc_list as well

* Implememnt CRCAT wallet

* Extend lineage store

* Make tests pass

* WalletIdentifier fix

* Add revocation RPC

* forgotten bytes32

* Return coin name with vc record

* First crack at adding VC authorizations to offers

* Add CROuterPuzzle

* Fix wallet_funcs.py

* VCWallet changes only

* Fix wallet db schema test

* Add RPC client methods and tests

* Allow a path for user to clear VC

* Mint VC command

* Get VCs command

* Forgotten hex compilation

* Automatically fetch DID when we have it

* Update Proofs command

* Add Proof Reveal command

* Get Proofs For Root command

* Revoke VC command

* Chialisp pre-commit cleanup

* Deprecate as_python()

* Add a limit to some sql queries

* Fix some bad imports

* Fix changed wallet sync function

* Check for tail condition amounts in CAT spending

* Add RPC docs

* only need one mojo for a singleton

* Fix comment

* remove create_puzhash from add_new_wallet

* Remove create_tandam_xch_tx

* fix wallet_state_manager hinting

* Rename RPCs

* Use streamable classes for RPC request parsing

* add back accidentally deleted method call

* Remove unnecessary copy() call

* Add negative test for using wrong DID to update proofs/revoke vc

* Add negative test for making sure invalid proofs can't be proven

* Add negative test for trying to piggyback on top an unrelated VC spend

* Make output_amount a uint64

* some chialisp bug fixes

* chialisp readability improvements

* Force same provider on provider update of DID

* typo in EML

* Add vc_wallet folders to package list

* mypy

* Increase test coverage a bit

* Add a bit more coverage

* rework wallet creation

* Delete is_addition_relevant

* Coveralls ignores

* remove brick reference

* coveralls-ignore --> pragma: no cover

* Couple more ignores

* typo corrections

---------

Co-authored-by: ytx1991 <t.yu@chia.net>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-05-11 19:09:05 -05:00
dustinface
c20c19387b
wallet: Fix coin state sorting (#15124) 2023-05-11 19:05:50 -05:00
dustinface
951158d7f5
wallet: Implement WalletPuzzleStore.delete_wallet (#15125) 2023-05-11 19:04:31 -05:00
dustinface
7c7740eb89
wallet: Implement WalletPoolStore.delete_wallet (#15126) 2023-05-11 19:04:15 -05:00
dustinface
0c4222f83e
wallet: Implement WalletCoinStore.delete_wallet (#15127) 2023-05-11 19:04:01 -05:00
Earle Lowe
360bf2d59a
Add basic test for get_farmed_amount wallet RPC (#15208)
* Add basic test for get_farmed_amount RPC

* remove unused line

* simplified test

* add a tx with a fee for get_farmed_amount test

* minor cleanup

* Apply suggestions from code review

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

* Some updates from PR comments

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-05-10 17:59:30 -05:00
dustinface
b90d91d46b
server: Don't pass the host to WSChiaConnection (#14152)
Use the one from the connection data like we do it with the port. The
result there is slightly different since its resolved so `localhost`
becomes an IP in `peer_info` but i anyway will open a PR soon to
transition from `str` to `IPAddress` in there.
2023-05-09 15:58:20 -05:00
dustinface
2983b99590
tests: Fix assert_tx_amounts in test_wallet_rpc.py (#15113)
* Fix `assert_tx_amounts`'s change condition

* Add a test case with `select_coin=True` without change
2023-05-09 15:57:07 -05:00
dustinface
5072f1825f
tests: Simplify block generation in test_did.py (#15122) 2023-05-09 15:56:35 -05:00
Arvid Norberg
5b0bf90a46
remove unused parts of test_rom.py (#15151)
* remove unused parts of test_rom.py

* remove unused code in test_compression.py
2023-05-09 15:56:20 -05:00
Jack Nelson
432e881439
Make Simulator CLI Tests Less Flaky (#15163)
* make less flaky by adding finally

* add different path for each test

in case path delete fails
2023-05-09 15:15:21 -05:00
Earle Lowe
434cbc42dd
Increase test_create_coin_duplicates to 1 second (#15229) 2023-05-09 14:50:43 -05:00
Amine Khaldi
78713b8289
Merge commit 'f100cd2cdf2630b270b88fc03e63f64af50005af' into checkpoint/main_from_release_1.8.1_f100cd2cdf2630b270b88fc03e63f64af50005af 2023-05-09 11:34:09 +01:00
Matt Hauff
77ea3cf663
Subscribe to the change children of CATs (#15176)
* Subscribe to the change children of CATs

* Address comments by @xdustinface

* capitalization

* type: ignore specific

* spin up only one wallet
2023-05-08 20:49:11 -05:00
Arvid Norberg
f100cd2cdf
Softfork2 testing (#15204)
* update tests to use the new softfork2 height

* activate both softforks immediately on testnet
2023-05-04 16:14:15 -05:00
Amine Khaldi
45c30c9a5e
Merge commit '1f8fc6410c795406aedb27e550c7376e027a7c02' into checkpoint/main_from_release_1.8.0_1f8fc6410c795406aedb27e550c7376e027a7c02 2023-05-04 19:34:11 +01:00
Amine Khaldi
ab999d6192
Optimize check_removals() by checking for mempool conflicts all at once (#15202)
* Make conflicting_items a list instead of a set as we're only iterating over it, we're not leveraging set ownership.

This simplifies using can_replace() and also prepares ground to simplify check_removals() next.

* Optimize check_removals by checking for mempool conflicts all at once.
2023-05-04 13:21:18 -05:00
Amine Khaldi
c9ce62c368
Annotate tests/util/blockchain.py (#15117)
Annotate tests/util/blockchain.py.
2023-05-04 13:19:27 -05:00
Matt Hauff
0346bddebe
Hint to CAT change (#15179)
* Hint to change

* Change cat test

* fix test_cat_spend test memo check

* Fix memos assertion again
2023-05-04 13:17:20 -05:00
dustinface
9a81cb36b6
protocols: Give rust wallet types an alias, don't use __all__ (#15186)
* protocols: Give rust wallet types an alias, don't use `__all__`

* Refactor `types_in_module` in `test_network_protocol_test.py`
2023-05-04 13:16:33 -05:00
dustinface
67910197eb
wallet: Improve WalletCoinStore.get_coin_records (#15099)
Improve `WalletCoinStore.get_coin_records`
2023-05-03 00:31:52 -05:00
dustinface
994aa24e44
wallet: Give Payment.memos a default value (#15172) 2023-05-03 00:30:53 -05:00
Kyle Altendorf
7cfa68139e
Add flexibility to log_exceptions() (#14992)
* Add flexibility to `log_exceptions()`

Allows configuration of the exception or exceptions to be caught, whether or not to show the traceback, the log level, and also adds the exception type to aid readability of errors like `KeyError` where the only text is the value of the key requested.

* add `log_exceptions(message=)`

* add tests for `chia.util.log_exceptions()`

* Update test_log_exceptions.py

* Update test_log_exceptions.py

* back to parametrize
2023-05-03 00:30:09 -05:00
Amine Khaldi
fc1e734b92
Merge commit '4e71529422039ff76d6b3af064f8d7653ccead5f' into checkpoint/main_from_release_1.8.0_4e71529422039ff76d6b3af064f8d7653ccead5f 2023-05-02 19:22:13 +01:00
dustinface
96cacc8a24
wallet: Revert "Add new coin_type & metadata to coin_records (#15013)" (#15154)
Revert "Add new coin_type & metadata to coin_records (#15013)"

This reverts commit a998ea48d8.
2023-05-01 09:56:48 -05:00
dustinface
1f8fc6410c
util: Async DNS lookups (#14999)
* Rename `get_host_addr` to `resolve`

* Async DNS lookups in `resolve`

* Drop not needed `str` conversions
2023-04-28 13:37:28 -05:00
dustinface
f902655efc
wallet: Implement WalletNFTStore.delete_wallet (#15128) 2023-04-27 09:55:53 -05:00
Amine Khaldi
de6fb526b5
Implement get_items_by_coin_ids() for the mempool (#15069)
Implement get_items_by_coin_ids() for the mempool.
2023-04-27 09:55:01 -05:00
dustinface
aa40fa7f21
wallet: Drop AmountWithPuzzlehHash, use Payment instead (#15019) 2023-04-27 09:52:27 -05:00
Kyle Altendorf
2ed75d47f3
more mypy platforms in ci (#12299)
* more mypy platforms in ci

* check not checks

* oh yeah, activate...

* add 3.11

* adjust job names

* actually use the right python version for install

* adjust for 3.7 hinting support

* exclude macos 3.7 and macos arm 3.8

* back to 3.8 for now

* major_dot_minor

* oops

* move ignore comments for 3.7

* and more
2023-04-27 09:51:18 -05:00
dustinface
4c7f7e7d23
wallet: Implement WalletCoinRecord.to_json_dict_parsed_metadata (#15108) 2023-04-25 11:21:10 -06:00
Kyle Altendorf
dd845b9a3c
improve ignore handling in __init__.py creation script (#15093)
improve ignore handling
2023-04-24 12:52:51 -06:00
Arvid Norberg
4e71529422
lower MAX_FUTURE_TIME to 2 minutes with the 1.8.0 soft-fork activation (#15035) 2023-04-24 12:52:38 -06:00
Kyle Altendorf
62d73db346
be more careful about deleting temporary plots (#15084) 2023-04-24 12:50:56 -06:00
dustinface
c2fac95aa1
tests: Fix flaky test_long_sync_untrusted_break (#15088) 2023-04-24 12:48:50 -06:00
Amine Khaldi
cf44101bc6
Use "item" instead of "spend" in mempool's items functions names (#15103)
Use "item" instead of "spend" in mempool's items functions names.

With this we're consistent with mempool's internal items map (_items) and _row_to_item as well as the return types.
2023-04-24 12:45:37 -06:00
Amine Khaldi
543199cc04
Annotate test_blockchain_transactions.py (#15061)
Annotate test_blockchain_transactions.py.
2023-04-24 12:45:03 -06:00
Kronus91
24019e35bb
Add DID CLI (#15065)
* Add DID CLI

* minor fixes

* build fix

* resolving comments

---------

Co-authored-by: Sebastjan Trepca <trepca@gmail.com>
2023-04-24 12:44:43 -06:00
Jack Nelson
872f939132
Add Chia Simulator tools directly Into Chia Blockchain (#15005)
* add simulator tool + tests into chia blockchain

add chia dev ...

* isort

* make sim chia root use normal chia root as a part of it

* fix starting path for tests

* cleanup start and stop + cli

* add extra env message

* fix cmds

* update test

* add existing_plots arg

* change to consume_errors

* fix tests

* cleanup cmds_util.py

* cleanup click

* clean up block_tools

dataclass + logic cleanup & tests

* isort block_tools.py
2023-04-19 19:48:21 -05:00
Arvid Norberg
536830b09b
Generator mod cleanup and simplification (#15055)
* remove unused run_generator_mempool() function

* move run_generator_unsafe() into the tests, which is the only place it's used

* remove (somewhat meaningless) setup_generator_args() and create_generator_args()

* remove unused GENERATOR_MOD in mempool_check_conditions.py

* remove redundant get_generator() function

* transition analyze-chain.py to use run_block_generator() and drop dependency on GENERATOR_MOD

* fixup type hints in test_rom.py

* fixup type hints in test_compression.py

* fixup type hints in test_generator_types.py
2023-04-18 16:30:10 -05:00
dustinface
04abd86555
wallet: Fix, simplify and test TransactionRecord.is_valid (#15048)
* Add `minimum_send_attempts`

* Fix `MempoolInclusionStatus` check

* Fix error access

* Fix error check

* Simplify

* Test `TransactionRecord.is_valid`
2023-04-18 11:28:50 -05:00
dustinface
5d514487e3
tests: Drop some unused code in test_puzzle_store.py (#15047) 2023-04-18 11:28:25 -05:00
Matt Hauff
e5b94d34a0
Chialisp file extensions (#14996)
* Rename chialisp file extensions

* Add pre-commit check for .clvm files

* Delete sha256tree files

* remove hash files in favor of central dictionary

* Add check for missing files like hex and hash entries

* Enhance clsp pre-commit check

* Actually check hash matches

* Update tools/manage_clvm.py

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

* Update tools/manage_clvm.py

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

* Fix Windows file writing

* Fix setup.py package_data fields

* Load hash dict at runtime

* Move away from exception pattern

* Bad equality check

* Minor fixes

* remove trailing whitespace fix

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-04-18 11:27:17 -05:00
dustinface
d9be2004c7
wallet: Some cleanup of WalletNode.fetch_puzzle_solution (#14896)
* wallet: Introduce `WalletNode.get_coin_spend_for_coin_state`

* Rename `fetch_puzzle_solution` and `get_coin_spend_for_coin_state`

* Free `fetch_coin_spend` and `fetch_coin_spend_for_coin_state`
2023-04-18 11:26:52 -05:00
Amine Khaldi
f278d9ccf8
Simplify create_bundle_from_mempool's handling of removals (#15056)
Simplify create_bundle_from_mempool's handling of removals.

They're already taken care of by aggregation.
2023-04-17 16:34:22 -05:00
Amine Khaldi
3410cf3deb
Introduce and use the ability to honor spends IDs in make_test_conds (#15060)
Introduce and use the ability to honor spends IDs in make_test_conds.
2023-04-17 15:43:50 -05:00
Arvid Norberg
9b8cdd36da
limit expiring transactions (#14993)
limit the mempool size used for transactions with short expiration times. This makes it so transactions that expire in the next 15 minutes may not take more than one block worth of cost in the mempool
2023-04-14 15:23:24 -06:00
dustinface
a7e7b9a290
server: Rework config peer resolving and connection handling (#14997)
merging as the snyk issue is confirmed a false positive
2023-04-14 15:22:24 -06:00
dustinface
4f7e2ff8c3
util: Cleanup Tuple[Optional[Err], ..] returns in condition_tools.py (#15009) 2023-04-14 15:20:36 -06:00
dustinface
3cd782be36
wallet: Some rework/cleanup of weight proof validation (#14572)
* Drop unused `List[SubEpochSummary]` return

* Drop unused `SubEpochSummary` return

* Raise in `WalletWeightProofHandler.validate_weight_proof`

* Move validation logs

* Set the new weight proof inside `fetch_and_update_weight_proof`

Which was `fetch_and_validate_the_weight_proof` before.

* Drop `WalletWeightProofHandler._weight_proof_tasks`, just await them

Doesn't seem to make a lot sense to have a list of tasks where we always 
just add a task, await it and remove it after. This happens in the long 
sync so to parent task will cancel the awaited task anyway.
2023-04-14 15:18:25 -06:00
Adam Kelly
4b594637c0
Rename singleton helper functions (#14983)
* Rename singleton helper functions

* Amend abbreviation in Singleton Puzzle creation functions
2023-04-12 11:34:08 -06:00
Almog De Paz
5b39e71842
Dl plugin service (#14883)
* generic downloader

* add s3 Downloader

* tests

* pre commit

* create uploader protocol, factor out upload code

* fix pre commit

* add s3 uploader

* add add helper for testing with real bucket

* typing

* lint

* logs

* start service separation

* working aiohttp s3 service

* lint

* multiple instances config

* break if failed to write

* better error handling

* update from conf before checking

* lint

* redundant config

* also update bucket

* improve exception handling

* remove old tests

* uae multiple uploaders

* Update chia/data_layer/data_layer.py

pr comments

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

* pr comments

* Apply typos fixes from code review

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

* Update chia/data_layer/s3_plugin_service.py

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

* scheme in conf

* use byte32 for store_ids list

* use dataclass instead of tuple for return value

* initial config handling for uploaders and downloaders

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Earle Lowe <30607889+emlowe@users.noreply.github.com>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-04-12 11:33:41 -06:00
dustinface
ed66308272
tests: Reuse puzzle_utils.make_create_coin_condition in test_puzzles (#15018) 2023-04-12 11:30:57 -06:00
Kronus91
a998ea48d8
Add new coin_type & metadata to coin_records (#15013)
* Add new coin_type & metadata to coin_records

* Remove unrelated changes

* Fix pre-commit

* Remove unrelated changes

* Fix pre-commit

* Add get_coin_records_between

* Fix field data type

* Resolve comments

* Fix unit test

* Remove unrelated changes

* Remove unrelated changes
2023-04-12 11:30:08 -06:00
dustinface
f0006b5353
server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
Justin England
0022ce797d
Small improvements to trusted peer check to include IPv6 addresses and add tests (#14626)
Refactor function `is_trusted_peer` to a standalone easily testable
function. Leverage the existing `is_localhost` function to extend
coverage to IPv6 local address for the trusted peer check

Added tests for the new standalone function
2023-04-11 14:36:37 -06:00
Arvid Norberg
00a3647643
optimize Mempool.add_to_pool() (#14988)
* optimize at-capacity check in mempool.add_to_pool() by only computing the total cost once and remove all items in a single call

* use sqlite logic

* add test for Mempool.add_to_pool() when it's full
2023-04-07 12:09:46 -05:00
dustinface
f3e165fc21
wallet: Enable and fix more mypy in wallet_node.py (#14913) 2023-04-07 05:16:12 -05:00
dustinface
a0659e923e
data_layer: Simplify wallet get and create code (#14878)
* Apply `final` decorator to `DataLayerWallet`

* Simplify `DataLayerWallet.create_new_dl_wallet`

* Simplify `DataLayerWallet.create`

* Improve `WalletStateManager.get_dl_wallet`

* More use of `WalletStateManager.get_dl_wallet`

* Only try `get_dl_wallet`
2023-04-05 12:56:39 -05:00
Arvid Norberg
624b24560a
Mempool insertion order (#14971)
* prepare mempool spends_by_feerate test for more test cases, move it to test_mempool.py (since it's testing the Mempool class)

* use insertion order as tie-breaker in mempool
2023-04-04 12:51:26 -05:00
Kyle Altendorf
b839dfa0c1
update black to 23.3.0 (#14537)
* unpin black

* Update setup.py

* Update .pre-commit-config.yaml

* black

* black

* 23.3.0

* cleanup
2023-04-04 12:50:58 -05:00
dustinface
cc6ff836cf
wallet: Introduce WalletIdentifier (#14964) 2023-04-04 00:08:10 -05:00
Matt Hauff
4710dd87d7
skip empty directories pre-commit (#14973) 2023-04-03 13:31:11 -05:00
dustinface
f90de71c9a
wallet: Raise in WalletNode.get_full_node_peer and move some of its calls (#14842)
wallet: Raise in `WalletNode.get_full_node_peer` + move some calls of it
2023-04-03 11:27:38 -05:00
dustinface
4dcbbda01e
wallet: Rename add block/state methods (#14460)
* `WalletBlockchain.receive_block` -> `WalletBlockchain.add_block`

* `receive_state_from_peer` -> `add_states_from_peer`

* `receive_and_validate` -> `validate_and_add`
2023-04-03 09:52:35 -05:00
dustinface
5e3bf65abb
wallet: Improve balance caching (#14631)
* wallet: Improve balance caching

* Fix missing entries in `get_balance` RPC and add a test for it

* Fix comment
2023-04-03 09:52:11 -05:00
dustinface
e8e8e0d709
wallet: Improve coin state retry wait logic and retry store test (#14911)
* wallet: Improve coin state retry wait logic and improve retry store test

* Avoid sleeping after uncatched exceptions

* Sleep only at the beginning since we have reduced timeout now in tests
2023-04-03 09:51:13 -05:00
Matt Hauff
bdd6eb8bfa
Make sql pre-commit check work when pre-commit hooks are in non-standard locations (#14955)
* make sql pre-commit check work with git worktrees

* Comment reasoning in script file

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

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-03-31 15:42:17 -05:00
Arvid Norberg
20bfba0fa6
assert_before_height, assert_before_seconds fields in MempoolItem (#14931)
fix issue where assert_before_height and assert_before_seconds fields in MempoolItem would not be populated
2023-03-30 12:06:22 -05:00
Amine Khaldi
1577f4aa33
Fix the mempool fee rate calculation (#14926)
* Fix the mempool fee per cost calculation.

It's currently performing integer division instead of float division, resulting in incorrect sorting of mempool items by fee rate. Items with x.y FPC get all treated as items of x.0 FPC.

* Add unit tests for mempool's spends_by_feerate.
2023-03-29 12:12:14 -05:00
Sebastjan Trepca
123d695c4e
slightly faster nft complex offer tests (#14847)
* slightly faster nft complex offer tests

* cached bundle, faster offer matching

* nft metadata test fix

* more optimizations

* use get_nft_count method in tests

* use counts in bulk minting, avoid sleep

* flake

* offer cache fix

* forward compat param, max int16

* only parse programs with pairs

* cache offer data on method call, not init

* black
2023-03-28 11:46:09 -05:00
Amine Khaldi
db6386ab3b
Add unit tests for replace by fee dynamics (#14815)
* Add unit tests for replace by fee dynamics.

* Separate scenarios into their own tests.

* Remove the TestReplaceByFee class.
2023-03-28 10:41:08 -05:00
dustinface
5e5395305d
wallet: Drop some parameters from WalletStateManager.add_new_wallet (#14919) 2023-03-27 18:07:19 -05:00
Amine Khaldi
faad1d7fd6
Improve core mempool test runs (#14914)
Improve mempool test runs.
2023-03-27 15:50:00 -05:00
dustinface
d83a6f8d14
consensus: Rename add block method/enum (#14459)
* `ReceiveBlockResult` -> `AddBlockResult`

* `Blockchain.receive_block` -> `Blockchain.add_block`
2023-03-27 12:57:37 -05:00
dustinface
9b608f40f9
wallet: Drop WalletCoinStore.get_multiple_coin_records (#14862) 2023-03-27 10:16:33 -05:00
Amine Khaldi
8afba0814d
Remove no longer needed cost_per_byte cases (#14850)
Remove no longer needed cost_per_byte cases.
2023-03-24 18:29:50 -05:00
Amine Khaldi
7acba82607
Merge commit 'f637881f80049f5648acd1936a2da936b5ca79a1' into checkpoint/main_from_release_1.7.1_f637881f80049f5648acd1936a2da936b5ca79a1 2023-03-24 14:36:57 +01:00
Kyle Altendorf
8cdaacf23c
increase wallet.nft_wallet test job timeout to 70 minutes (#14881)
from https://github.com/Chia-Network/chia-blockchain/actions/runs/4455716184/usage i see macos with nominal low 40s runtime and outliers into the low 50s, windows has a wider variance with highs in the low 50s and 8'ish hung runs that timed out at the 75 minute timeout, linux looks like 30'ish with a high of maybe 36.
2023-03-24 02:17:53 -05:00
Arvid Norberg
8dbfc4840a
enable soft-fork2 conditions (incl. ASSERT_BEFORE) (#14733)
* enable soft-fork2

* add blockchain (consensus) test for time-lock conditions (non-ephemeral spend)

* introduce new soft-fork rule to compare ASSERT_SECONDS_* conditions against the previous transaction block's timestamp (to be consistent with ASSERT_HEIGHT_* conditions)

* bump chia_rs. This updates the mempool rules to disallow relative height- and time conditions on ephemeral coin spends

* implement assert_before in mempool_check_time_locks. Extend ephemeral coin test in blockchain with assert_before conditions

* implement support for assert_before conditions in compute_assert_height()

* support assert-before in mempool

* add timelock rule

* address review comments
2023-03-23 11:30:10 -05:00
Adam Kelly
15d338976d
Add placeholders for DAO Wallet directories (#14858) 2023-03-22 04:47:32 -05:00
Arvid Norberg
8d7a462702
can_replace() tests (#14864)
* mempool min fee increase is a constant

* make can_replace() a free function rather than a member of mempool. It doesn't need to be a member, and a free function is easier to test

* simplify can_replace by passing in MempoolItem

* slightly simplify handling of conflicting mempool items in mempool_manager, to avoid double lookups

* simplify can_replace() by just passing removal_names instead of the whole dict

* add unit test for can_replace()
2023-03-21 18:41:16 -05:00
Matt Hauff
38180cb2b6
Add support to cat_spend RPC for running TAIL (#14730) 2023-03-21 13:33:07 -05:00
Arvid Norberg
f637881f80
1.7.1 fixes (#14860)
* Zstdwjb (#80)

* limit decompression output size

* added test

---------

Co-authored-by: William Blanke <wjb98672@gmail.com>

* check MAX_GENERATOR_REF_LIST_SIZE earlier (#68)

* make INFINITE_COST more reasonable (#69)

---------

Co-authored-by: William Allen <wallentx@users.noreply.github.com>
Co-authored-by: William Blanke <wjb98672@gmail.com>
2023-03-21 00:20:53 -05:00
Kyle Altendorf
f09d051552
fixup tests that do not close all event loops (#14851)
* remove event loop fixture from `test_dl_wallet`

* stop importing unused `Iterator`

* fixup more
2023-03-20 15:01:02 -05:00
dustinface
543f8c24eb
wallet: Return a dict in WalletCoinStore.get_coin_records (#14828) 2023-03-20 13:17:59 -05:00
Arvid Norberg
ea2da6ce6e
fix renaming of respond_block -> add_block (#14846) 2023-03-18 05:56:40 -05:00
dustinface
26c2ca29de
tests: Fix flaky RPC related tests in test_nft_bulk_mint.py (#14834)
* `assert spend_bundle is not None`, required after hinting in next commit

* Don't start duplicated RPC servers, use the already started ones

* Wait for wallet sync before minting
2023-03-17 19:34:46 -05:00
dustinface
f5afa47d85
wallet: Disconnect untrusted peers if we find a trusted synced one (#14640)
* Move `request_time` creation into `is_peer_synced`

* Pass in `height: uint32` instead of `header_block: HeaderBlock`

* Disconnect untrusted peers as soon as we have a synced trusted

* Add `test_long_sync_untrusted_break`

* Ignore already disconnected peers
2023-03-17 19:28:39 -05:00
Arvid Norberg
307b5726b3
Test cleanups (#14841)
* remove redundant test cases in test_blockchain.py test_ephemeral_timelock

* reorganize some test cases
2023-03-17 19:28:01 -05:00
Amine Khaldi
dca1a2423d
Merge commit '6d09a060379a0eb77d11abf52ba810c93bd4be5f' into checkpoint/main_from_release_1.7.1_6d09a060379a0eb77d11abf52ba810c93bd4be5f 2023-03-16 18:18:35 +01:00
Sebastjan Trepca
6d09a06037
better handling of offer status and failed txs (#14812)
* better handling of offer status and failed txs

* 5 retries before tx is marked failed

* increase test timeouts

* fixed test

* require only difference vs whole fee

* polish + fee coins kick in only if we're missing fee
2023-03-15 20:50:25 -05:00
dustinface
62ee1c8766
wallet: Don't just subscribe to all coin ids from the DB (#14813) 2023-03-15 17:52:56 -05:00
Sebastjan Trepca
a6f423522b
nft royalty edge cases (#14789)
* nft royalty edge cases

* making tests faster

* Update tests/wallet/nft_wallet/test_nft_1_offers.py

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

* flake

---------

Co-authored-by: Matt Hauff <quexington@gmail.com>
2023-03-14 20:27:15 -05:00
Arvid Norberg
99ef78029b
disable soft-fork 2 (for now) (#14786)
disable soft-fork 2 (for now) until we properly think-through and settle on how to handle ephemeral coins
2023-03-09 19:13:15 -06:00
Kronus91
95d05b72c4
Stop sending change to a new address (#14422)
* Stop sending change to a new address

* Fix bug

* Add config & unit tests

* Resolve comments

* Refine based on the requirements

* Change config to str

* Disable addr reuse for unit test since the hardcode offer doesn't compatible with it

* Cover offer trade

* Add unit test and RPC support

* Add reuse option for cli

* Enhance unit test

* Fix unit test
2023-03-09 18:32:21 -06:00
Amine Khaldi
7d770c1c1e
Add unit tests for create_bundle_from_mempool (#14700)
* Add unit tests for create_bundle_from_mempool().

* Factor out some shared code into a function.

* Add a variation for sending transactions in reverse order.

* Split some logic into functions.

* Refactor setting up the mempool with coins as well as big cost spend bundle handling.
2023-03-09 14:27:50 -06:00
Kyle Altendorf
c4c165eabd
avoid AttributeError when shutting down plotting (#3954)
* Remove valid # type: ignore

A user ran into an exception on this line that mypy should have caught.  Let's see what it says.

```python-traceback
2021-05-06T07:31:41.595 full_node full_node_server        : ERROR    Exception , exception Stack: Traceback (most recent call last):
  File "chia\server\server.py", line 356, in start_client
  File "aiohttp\client.py", line 763, in _ws_connect
  File "aiohttp\client.py", line 521, in _request
  File "aiohttp\connector.py", line 535, in connect
  File "aiohttp\connector.py", line 892, in _create_connection
  File "aiohttp\connector.py", line 1032, in _create_direct_connection
  File "aiohttp\connector.py", line 969, in _wrap_create_connection
  File "asyncio\base_events.py", line 949, in create_connection
  File "asyncio\selector_events.py", line 473, in sock_connect
concurrent.futures._base.CancelledError

2021-05-06T07:31:45.016 daemon asyncio                    : ERROR    Task exception was never retrieved
future: <Task finished coro=<kill_service() done, defined at chia\daemon\server.py:833> exception=AttributeError("'list' object has no attribute 'pid'")>
Traceback (most recent call last):
  File "chia\daemon\server.py", line 841, in kill_service
  File "chia\daemon\server.py", line 805, in kill_process
AttributeError: 'list' object has no attribute 'pid'
2021-05-06T07:32:09.965 full_node full_node_server        : ERROR    Exception:  <class 'concurrent.futures._base.CancelledError'>, closing connection None. Traceback (most recent call last):
  File "chia\server\server.py", line 531, in api_call
  File "asyncio\tasks.py", line 435, in wait_for
concurrent.futures._base.CancelledError

2021-05-06T07:33:20.573 full_node full_node_server        : ERROR    Exception , exception Stack: Traceback (most recent call last):
  File "chia\server\server.py", line 356, in start_client
  File "aiohttp\client.py", line 763, in _ws_connect
  File "aiohttp\client.py", line 521, in _request
  File "aiohttp\connector.py", line 535, in connect
  File "aiohttp\connector.py", line 892, in _create_connection
  File "aiohttp\connector.py", line 1032, in _create_direct_connection
  File "aiohttp\connector.py", line 969, in _wrap_create_connection
```

* fix plotter service killing

* just make it always be a list of processes for all services

* catch up tests

* Update chia/daemon/server.py
2023-03-09 04:22:38 -06:00
Arvid Norberg
b36a1f9eeb
Cleanup tests (#14776)
* clarify test with unknown condition opcode

* fix bug in mempool_manager test_ephemeral_timelock

* simplify test_blockchain test_ephemeral_timelock by factoring out the with_garbage parameter
2023-03-08 11:32:12 -06:00
Matt Hauff
adb3fe8082
Don't create a coin for 0 amount royalty payments (#14769)
* Don't create a coin for 0 amount royalty payments

* Tweak tests

* mypy
2023-03-08 10:59:29 -06:00
Arvid Norberg
4ed31c50d5
Bump chia rs 0.2.4 (#14758)
* fix bug in make_test_conds() test utility

* bump chia_rs to 0.2.4, which preserves assert_seconds_relative 0 in parsing conditions. This allows for the 1.8.0 soft-fork to make the existing time-lock conditions stricter, > instead of >=. This is to match the existing ASSERT_HEIGHT_RELATIVE, which already is >

* fixup separating ENABLE_ASSERT_BEFORE from MEMPOOL_MODE

* Use a low value for SOFT_FORK2_HEIGHT during tests and cover the case before soft-fork2

---------

Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
2023-03-07 15:29:54 -06:00
Kyle Altendorf
a42bf49050
catch up with mypy 1.1.1 (#14767) 2023-03-07 11:34:07 -06:00
Kyle Altendorf
e1d232883e
hint most chia.types (#14741)
* hint various chia.types

* hmm

* ints

* test todo
2023-03-06 16:34:22 -06:00
Earle Lowe
6e140f24fb
simplify and improve daemon connection handling (#14662)
* simplify daemon connection handling

* Add tests

* return list of service names during removal

* set remove raises KeyError

* Better test type hints

* Add types and code refactor

* fix test typos

* small type adjustments

* test code improvements

* Better error handling for bad json

* handle proper but unexpected JSON values

* Update chia/daemon/server.py

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

* test improvements

* check for empty thing equivalence

* Improved logging for ConnectionReset

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-03-06 12:49:38 -06:00
Kyle Altendorf
e5edbd9b3d
fix DataStore.get_tree_generation() detection of no generations (#14721)
* fix DataStore.get_tree_generation() detection of no generations

* revert unwanted change
2023-03-06 12:17:30 -06:00
Arvid Norberg
131c5ec5bf
parameterize Timelock and compute_assert_height tests (#14729)
* parameterize test_compute_assert_height

* parameterize tests in TestCheckTimelocks
2023-03-04 11:39:47 -06:00
Sebastjan Trepca
a38da21ebd
no duplicate offers, handle conflict offers correctly (#14722)
* no duplicate offers, handle conflict offers correctly

* don't sync every offer with a bad spend, only pending ones
2023-03-03 15:13:39 -06:00
Arvid Norberg
9e8dae67b2
Bump chia_rs to 0.2.3. and ASSERT_MY_BIRTH_* (#14720)
* bump chia_rs to version 0.2.3

* add new error codes for assert_my_birth_*

* add new condition codes for ASSERT_MY_BIRTH_*

* add logic for ASSERT_MY_BIRTH_* conditions
2023-03-03 15:12:37 -06:00
Arvid Norberg
c7301693e1
sqlite-backed mempool (#14657)
* implement Mempool using an in-memory sqlite database

* remove_from_pool with empty list is a no-op

* the order is not important in get_coin_records_by_puzzle_hash() or get_block_spends()

* use format string in log statement

* make MempoolItem not streamable, to improve performance of creating objects
2023-03-03 15:04:21 -06:00
Earle Lowe
74ab821051
no need for [] checks with ipv6 address 2023-03-02 13:30:47 -08:00
Earle Lowe
3e13236eef
Merge remote-tracking branch 'origin/main' into EL.trusted_peer_fix 2023-03-02 13:07:23 -08:00
Arvid Norberg
3f78f51211
fixup ephemeral coin test in test_mempool (#14719)
* user shorter names for constants in test_mempool.py

* fix typo in test_ephemeral_timelock in mempool test. The conditions should only be applied to the ephemeral coin, not the coin creating it
2023-03-02 05:16:35 -06:00
Arvid Norberg
8618ef0f52
Soft fork2 tests (#14712)
* use shorter names in test-ephemeral-coin test parameters

* use shorter names in TestConditions to make the test easier to read

* user shorter names in test_blockchain test_ephemeral_timelock, to make the test easier to read

* extend test_ephemeral_timelock to cover soft-fork 2

* extend test_conditions to cover soft-fork 2
2023-03-01 14:19:55 -06:00
Kyle Altendorf
3a5c1a5bd5
hint chia.harvester.harvester, harvester_api (#14690)
* hint chia.harvester.harvester

* hint chia.harvester.harvester_api
2023-02-28 11:42:58 -06:00
Kyle Altendorf
423689099e
add more wallet syncs to test_pool_rpc (#14703) 2023-02-28 11:40:57 -06:00
Adam Kelly
0a6856b498
Fix a DID Wallet issue where an old DID coin causes us to assert during wallet creation (#14668)
* wip

* Change test to reflect current DID Wallet operation

* Typecheck case where we do not know parent yet.
2023-02-27 16:48:10 -06:00
Arvid Norberg
5a5cb2e58e
simplify fee estimator by not leaking MempoolItem into its interface (#14685) 2023-02-27 16:34:11 -06:00
dustinface
6b680cf204
tests: Some refactoring of poll_directory and keyring sync tests (#14616)
* tests: Some refactoring of `poll_directory` and keyring sync tests

* Apply review suggestions

* Apply more review suggestions

* Add missing check for file existance
2023-02-27 15:29:13 -06:00
Arvid Norberg
e195d268fb
simplify the mempool filter to only pass in the spend_bundle name (#14665)
simplify the mempool filter to only pass in the spend_bundle name. That's the only thing we use
2023-02-27 12:57:32 -06:00
Arvid Norberg
60dacd9f36
remove some redundant fields from MempoolItem (#14652) 2023-02-27 12:56:06 -06:00
Kyle Altendorf
ff5ef6e073
remove leading newlines from indented code blocks (#14653)
* remove leading newlines from indented code blocks

* catch another one
2023-02-23 21:53:48 -06:00
Kronus91
9dcba09dda
Extend sign API to support hex string (#14448)
* Extend sign API to support hex string

* handle string input

* Resolve comments

* Fix pre-commit
2023-02-23 21:52:57 -06:00
Kyle Altendorf
96dad39392
remove unneeded parentheses (#14654) 2023-02-23 10:42:44 -06:00
dustinface
c098ee9166
full_node: Rename some receive/respond prefixes to add (#14458)
* full_node: Rename `FullNode.resond_block` to `FullNode.add_bock`

The naming `respond_block` is confusing here imo, we have a full node
API method called `respond_block` but here in the `FullNode` class this
method is there to try adding a block to the full nodes's chain so i
think `add_block` is the better choice?

Also change the `respond_block: full_node_protocol.RespondBlock`
parameter to `block: FullBlock` which lets us get rid of many
`full_node_protocol.RespondBlock` wrappings.

* `FullNode.receive_block_batch` -> `FullNode.add_block_batch`

* `receive_unfinished_block` -> `add_unfinished_block` + change parameter

* `FullNode.respond_transaction` -> `FullNode.add_transaction`

* `FullNode.respond_end_of_sub_slot` -> `FullNode.add_end_of_sub_slot`

* `FullNode.respond_compact_vdf` -> `FullNode.add_compact_vdf`

* `respond_compact_proof_of_time` -> `add_compact_proof_of_time`

* `respond_transaction_semaphore` -> `add_transaction_semaphore`
2023-02-23 10:28:29 -06:00
Amine Khaldi
b019fe5962
Introduce BlockRecordProtocol as a subset of BlockRecord that the mempool manager uses for peak (#14628)
* Introduce BlockRecordProtocol as a subset of BlockRecord that the mempool manager uses for peak.

* Create BenchBlockRecord and use it for benchmarks/mempool.py.

* PR #14611 didn't land yet (keep 3.7 support for now).

* We don't need this guidance anymore.
2023-02-23 01:04:47 -06:00
Kyle Altendorf
c678f00acb
cleanup adjacent string literals (#14650) 2023-02-22 17:16:07 -06:00
dustinface
c836093fd5
wallet: Fix sync mode indication (#14524)
* Make `WalletNode.set_sync_mode` an `asynccontextmanager`

* Only fetch the height if debug logs are enabled

* `yield` the start height of the sync context in `set_sync_mode`.
2023-02-22 13:41:36 -06:00
Arvid Norberg
ed8cee2b4b
Mempool private implementation (#14593)
* fix test asserts to not require the same object, just the same value

* make Mempool's implementation private and give it a public interface

* fixup test that used to count fee *levels* but now count transactions
2023-02-22 12:26:04 -06:00
Arvid Norberg
6e6325b1b5
make conditions_for_solution() support untrusted input (#14615)
* make conditions_for_solution able to parse untrusted CLVM structures

* demote as_atom_list() to be a test-only function in test_rom.py, which is the only place it's used now
2023-02-22 12:11:42 -06:00
Kyle Altendorf
93fe2f8692
exploring loop test adjustments (#14613)
* exploring loop test adjustments

* simplify the test

* drop unused variable hint
2023-02-22 12:11:06 -06:00
dustinface
18e88e8476
types: Use IPAddress instead of str in PeerInfo (#14167)
* Use `IPAddress` instead of `str` in `PeerInfo`

* Add comment about `get_host_addr`
2023-02-22 12:03:41 -06:00
dustinface
0e309d6c6b
tests: Merge some fixtures and drop other redundant ones (#14629)
* Drop redundant fixtures in `test_dl_wallet.py`

* Drop `two_wallet_nodes_five_freeze`

Maybe im just not getting it but the `five_freeze` doesn't sound right 
here to me and the fixture does the same as `two_wallet_nodes` so i 
guess we can just drop it?

* Drop `wallet_and_node` fixture

* Drop both `wallet_node` fixtures

The one in `conftest.py` and the one in `test_dl_wallet.py`.

* Drop both `wallet_node` fixtures

The one in `conftest.py` and the one in `test_dl_wallet.py`.

* Drop `wallet_node_sim_and_wallet` fixture

* Drop `wallet_node_simulator` fixture

* Drop `one_wallet_node` fixture
2023-02-21 18:37:33 -06:00
Arvid Norberg
23483b6b7b
make SpendBundle.additions() count complete cost (#14612)
make SpendBundle.additions() properly account for the cost of computing additions for all spends it contains
2023-02-21 18:37:12 -06:00
Adam Kelly
db19671827
Check Wallet DB integrity (#14401)
* Check Wallet DB integrity

* Update command line help

* Improve duplicate DerivationPath index error message

* Move tests to chia/tests

* lint

* py init file

* Print WalletType names

* Don't complain about wallets not having derivation entries that don't need them

* Validate addresses used in order

* Update tests with new error output

* Fix check_addresses_used_contiguous in the case when the last address of the previous wallet was unused
2023-02-21 18:35:15 -06:00
dustinface
1094ae21fd
tests: Setup 4 nodes in setup_four_nodes (#14630) 2023-02-21 12:26:29 -06:00
Arvid Norberg
1d4a3ecce8
Softfork2 infrastructure (#14625)
* add soft-fork2 (to be introduced in 1.8.0)

* update unknown-opcode test
2023-02-21 12:25:47 -06:00
Arvid Norberg
b48c91618f
require npc_result to be set in mempool items added to the mempool (#14624) 2023-02-21 12:25:22 -06:00
Earle Lowe
fe5d9c12e0
Fixup some ipv6 issues around [] 2023-02-20 11:31:55 -08:00
Earle Lowe
38b3f1568d
refactor is_trusted_peer 2023-02-20 08:23:39 -08:00
Kyle Altendorf
4e34ff7982
fixup test_agg_sig_unsafe() softfork fixture usage (#14597) 2023-02-16 19:54:16 -06:00
Sebastjan Trepca
6e632c2531
nft paging at sqlite level (#14561)
* nft paging at sqlite level

* use sqlite params
2023-02-16 03:40:50 -06:00
William Allen
03b007456a
catchup: into main from release/1.7.0 @ 124961a355 (#14575)
Source hash: 124961a355
Remaining commits: 0
2023-02-16 03:39:40 -06:00
Amine Khaldi
197533577b
Augment mempool's total_mempool_fees to int as it shouldn't be limited by type Mojos (#14587)
* Augment mempool's total_mempool_fees to int as it shouldn't be limited by type Mojos.

* Add an assert to make sure the total mempool fees are correct.
2023-02-15 23:06:06 -06:00
Sebastjan Trepca
7694ed0480
rpc endpoint to count nfts per wallet or all wallets (#14570) 2023-02-15 23:01:12 -06:00
Arvid Norberg
fc9da3732c
parameterize TestConditions (#14567) 2023-02-15 23:00:48 -06:00