Commit Graph

243 Commits

Author SHA1 Message Date
Arvid Norberg
95e5b97557
Use bls from chia rs (#16715)
* replace blspy imports with chia_rs imports for BLS types

* remove blspy-stubs, since we're dropping the blspy dependency. chia_rs has type stubs already
2023-11-07 09:06:52 -08:00
Kyle Altendorf
aaf081f69d
explicit protocol checks against RpcServiceProtocol (#16710) 2023-10-27 12:03:15 -07:00
Kyle Altendorf
90c1441af0
apply pyupgrade --py38-plus --keep-runtime-typing (#14646) 2023-10-24 12:01:23 -05:00
Matt Hauff
ff59bc3e1f
Add cache to wallet node preventing resend of processing TX (#16640) 2023-10-18 17:13:50 -05:00
Geoff Walmsley
75af6a98d8
Dao wallet (#16500)
Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
Co-authored-by: Matthew Howard <m.o.howard97@gmail.com>
Co-authored-by: matt-o-how <48453825+matt-o-how@users.noreply.github.com>
Co-authored-by: Karlkim Suwanmongkol <karlkim@gmail.com>
Co-authored-by: Sebastjan Trepca <trepca@gmail.com>
Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-10-11 14:19:12 -05:00
Earle Lowe
4ba74c96ae
Use network overrides for default port for WalletPeers (#16525) 2023-10-06 13:18:48 -05:00
Kyle Altendorf
51d3bf018e
Revert "Dao wallet" (#16465) 2023-10-01 11:57:09 -05:00
matt-o-how
810df50bf6
Dao wallet (#15559)
Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com>
Co-authored-by: Geoff Walmsley <geoffwalmsley@gmail.com>
Co-authored-by: Geoff Walmsley <5695735+geoffwalmsley@users.noreply.github.com>
Co-authored-by: Karlkim Suwanmongkol <karlkim@gmail.com>
Co-authored-by: Sebastjan Trepca <trepca@gmail.com>
Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-09-30 14:24:35 -05:00
Matt Hauff
efff83e7be
Add timelock information to Trades and Transactions (#15915) 2023-09-12 11:28:01 -05:00
dustinface
e9b5937dce
wallet: Drop is_peer_synced / More cache usage (#16261) 2023-09-11 17:52:43 -05:00
dustinface
cd1d22d29b
wallet: Fix and improve untrusted race caching (#16239) 2023-09-06 13:00:25 -05:00
dustinface
4ee7fe27be
wallet: Refactor new_peak in WalletStateManager and PoolWallet (#16262) 2023-09-06 12:59:55 -05:00
dustinface
2e18f904dd
wallet: Fix comment in WalletNode.validate_received_state_from_peer (#16037) 2023-08-24 12:38:05 -05:00
Amine Khaldi
54290f812a
Merge commit '17659b80396c3e87fa60415a6ff3fcc2983c0b52' into checkpoint/main_from_release_2.0.0_17659b80396c3e87fa60415a6ff3fcc2983c0b52 2023-08-15 12:09:03 +01:00
Kronus91
17659b8039
Fix clawback sender resync issue (#15853)
* Fix clawback sender resync issue

* enhance unit test

* Fix CI

* Add comment

* Fix unit test & revert changes

* Remove prints

* Resolve comments

* Resolve comments

* Remove check
2023-08-09 10:09:41 -05:00
Matt Hauff
289260c374
Credential Restricted CATs (#15411)
* Allow create_tandem_xch_tx to take a set of announcements

* Create potential announcement in correct arm of create_tandem_xch_tx

* Make does_coin_belong_to_wallet more robust

* Add match_hinted_coin to wallet protocol

* Add CROuterPuzzle

* Add conditions with fee announce.clsp

* Add CRCATWallet

* Add CLI support for CR-CATs

* Fix bug in CATOuterPuzzle

* Add SOFTFORK_HEIGHTS as an exportable variable from conftest

* Allow specifying num of blocks to farm to wallets_prefarm_services

* Add potential subclasses to cat wallet creation

* Integrate CR-CATs into offers

* Address comments by @geoffwalmsley

* Add CRCAT info to get_wallets

* Changes due to (#15846)
2023-08-03 19:36:21 -05:00
dustinface
7b2f481d31
wallet: Deduplicate coin states from peers (#15598) 2023-06-23 12:59:26 -05:00
Matt Hauff
9b465a08c6
Only subscribe to inner wallet puzzle hashes (#14356)
* Only subscribe to inner wallet puzzle hashes

* Add a store for unacknowledge CAT coin states

* Add additions and removals to dummy TX

* whoops

* Add interested coin IDs when saving trade

* black

* One test was not hinting, make it use push_transaction RPC instead

* restructure and comment a block

* Change asset ID to blob and add index

* Add get all puzzle hashes by wallet id

* Separate unacknowledged state getter and deletion

* Remove peer_id from CAT states table

* lint

* fix forwards compat tests

* isort

* Subscribe to the change children of CATs

* Hint to change

* undo unintentional changes

* Change cat test

* fix test_cat_spend test memo check

* provide save_trade parameter

* Address comments by @xdustinface

* Fix memos assertion again

* hint in test cat creation

* Missing save_trade call

* time out assert

* Hint in RPC test

* Fix wallet resync function

* Fix DB bug, add test coverage

* pass offer to save_trade

* add reorg rollback to unacknowledged states

* Add some unit tests
2023-06-13 12:51:16 -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
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
Adam Kelly
7f591890af
Give a type to tuple representing peak (height and block hash) of peer (#14853)
* Give a type to  tuple representing peak (height and block hash) of peer

* Update chia/wallet/wallet_node.py

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

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
2023-05-23 19:53:32 -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
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
43a4939dbc
wallet: Move WalletPeers init to the end of _start_with_fingerprint (#15150) 2023-05-11 19:04:52 -05:00
Amine Khaldi
9ba94a6cbc
Merge commit 'b0cc1bebdb1990b0dafb369fef699d5ba6a34c77' into checkpoint/main_from_release_1.8.0_b0cc1bebdb1990b0dafb369fef699d5ba6a34c77 2023-05-07 10:57:20 +01:00
dustinface
5b93bd320c
wallet: Cleanup wallet_protocol imports (#15185) 2023-05-03 16:37:32 -05:00
Kyle Altendorf
cf6a529265
use type name in Pulled from queue: log messages (#15003) 2023-05-03 00:29:52 -05:00
dustinface
b0cc1bebdb
wallet: Lock WalletStateManager.lock while populating balances initially (#15149)
Lock `WalletStateManager.lock` while populating balances initially
2023-04-28 14:55:15 -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
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
dustinface
f0006b5353
server: peer_host + peer_port -> peer_info in WSChiaConnection (#14151) 2023-04-12 11:14:38 -06:00
dustinface
f3e165fc21
wallet: Enable and fix more mypy in wallet_node.py (#14913) 2023-04-07 05:16:12 -05:00
dustinface
bd571de422
wallet: Handle some peer closed cases better (#14642)
* Move some logs to `DEBUG` for disconnected peers

* Introduce `_add_coin_states` to log and cleanup cache in one place only

* Bail out early for disconnected peers in some places

* Consider renaming from #14460
2023-04-06 14:48:19 -05:00
dustinface
c63b0020fc
wallet: Drop leaking weight proof validation cache (#14574)
* Make `wp_valid_cache` a LRU cache

* Drop `wp_valid_cache`
2023-04-05 12:55:37 -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
dustinface
8ca8de8046
wallet: Some tweaks and rename of WalletStateManager.new_coin_state (#14863)
* Rename `new_coin_state` -> `add_coin_states` in `WalletStateManager

* Avoid redundant coin id calculations

* Don't `max`, just use `derivation_index` since its max by the condition

* Just get the children in the begining since we anyway always fetch them

* Don't pre-hint `existing`

* Adjust some logging
2023-03-27 13:29:50 -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
3772365198
wallet: Rename WalletNode.untrusted_caches -> WalletNode.peer_caches (#14886) 2023-03-27 10:17:48 -05:00
dustinface
df6991551a
wallet: Drop some unused members of WalletNode (#14876) 2023-03-24 13:29:17 -05:00
dustinface
c889ba02cd
wallet: Cleanup get_timestamp_for_height + Drop height_to_time (#14885) 2023-03-24 03:38:43 -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
dustinface
62ee1c8766
wallet: Don't just subscribe to all coin ids from the DB (#14813) 2023-03-15 17:52:56 -05: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
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
dustinface
66d53f415d
wallet: Access trusted_peers with a default (#14643) 2023-02-22 17:16:57 -06:00
Kyle Altendorf
c678f00acb
cleanup adjacent string literals (#14650) 2023-02-22 17:16:07 -06:00