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
* 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
* 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>
* 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.
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.
* 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.
* 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
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.
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
* 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
* 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
* 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.
* 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
* 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()
* 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.
* 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
* 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
* 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>
* 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>