Commit Graph

3036 Commits

Author SHA1 Message Date
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
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
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
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
Amine Khaldi
ac0349f8dc
Simplify request_mempool_transactions() and get_items_not_in_filter() (#14404)
* Only deal with the relevant subset of the MempoolItem (which is SpendBundle here).

* get_items_not_in_filter() doesn't need to be async.

* Use len(items) instead of counter for the limit check.

* Update tests to reflect the improvements.
2023-02-15 22:47:07 -06:00