Commit Graph
376 Commits
Author SHA1 Message Date
Arvid Norberg 7b0bea4043 various typing fixes (#15899)
* add blspy-stubs to improve mypy

* various typing fixes

* avoid cast

* use ValueError exception instead of assert when aborting picking a wallet key
2023-08-17 19:10:40 -05:00
Jack Nelson 0d36874caa Refactor Seeder & Crawler code + add tests (#15781)
* Cleanup seeder & mypy all files

holy crap mother of all tech debt this was horrid

* Make UDP Protocol class a dataclass & separate out functions.

* add TCP protocol class to DNS server

* Fix mypy types & other cleanup

also fix a couple bugs

* Add seeder and crawler tests

* change log levels

* re add db lock timeout

oops

* add edns & edns tests

* fix repeated shutdown on close signal

* fix binding to use both ipv6 and ipv4

whyyyyyyy

* add ipv6 and ipv4 tests + add ipv4 if windows
2023-08-11 05:25:19 -05:00
Arvid Norberg 8071dc6211 introduce SOFT_FORK4_HEIGHT and tie CHIP-13 to it (#15885)
* introduce SOFT_FORK4_HEIGHT and tie CHIP-13 to it

* fix test_plot_refreshing
2023-08-04 18:41:34 -05:00
Arvid Norberg f0cb47baef remove softfork2 logic (#15793) 2023-08-01 11:28:16 -05:00
Matt Hauff 217e81f478 Move some puzzles out of chia.wallet.puzzles (#15822) 2023-07-24 10:39:16 -05:00
7c6cf2cfe9 Chip13 (#15688)
* Chip13

* Lint.

* Black.

* Lint.

* Fix BlockTools.

* Trigger the soft fork.

* Parametrize bt.

* Syntax.

* Add softfork3 to empty_blockchain too.

* Skip test.

* Skip test.

* Try fix.

* Add persistent blocks.

* Lint.

* Run tests without block cache.

* Try to fix tests.

* Revert "Try to fix tests."

This reverts commit f10c7fc847.

* WIP plot filters.

* pytest.

* Lint.

* Skip cache tests.

* Try to lower the constraints.

* Try to increase timeout.

* Test blockchain.

* Store test.

* Revert to main

* Revert to main

* Revert to main

* Add tests with new interface

* Test.

* Fixtures.

* Fixtures.

* Lint.

* Add first test.

* Improve test.

* Isort.

* merge fix

* fix counter

* Bump test-cache version to soft_fork3.0 DBs

* Enable tests.

* Enable all.

* Syntax.

* Attempt higher timeouts.

* Try to skip big test.

* Revert tests larger timeouts.

* Try to get test to work with 4000.

* Skip 10000 blocks.

* Test.

* Update test_full_node_store.py

* Update test_blockchain.py

* Update test_blockchain.py

* Update tests/conftest.py

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

* Update tests/blockchain/test_blockchain.py

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

* Address some comments.

* Some more comments.

* Use new passes_plot_filter signature.

* Lint.

* Lint.

* Reduce benchmark timeout.

* Skip test.

* Address review comments.

* Delete leftovers.

* Review comments.

* await.

* Revert async call.

* Validate in body too.

* Fix test.

---------

Co-authored-by: almog <almogdepaz@gmail.com>
Co-authored-by: wallentx <william.allentx@gmail.com>
Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2023-07-20 21:25:23 -05:00
Amine KhaldiandArvid Norberg de05016ce0 New aggregate signature conditions (#15769)
* New aggregate signature conditions.

* compute domain strings on the fly (but cache them) (#2)

* Addendum to Arvid's idea.

* Fix a typo.

* more test coverage (#3)

* Fix a typo.

* Refactor final message creation logic into make_aggsig_final_message.

* Cover make_aggsig_final_message exception cases.

* Refactor processing spends' agg sig lists in pkm_pairs.

* Construct a Coin out of a Spend and use it in make_aggsig_final_message.

* Adopt Richard's dictionary trick to simplify make_aggsig_final_message.

* Leverage make_aggsig_final_message in WalletTool's sign_transaction.

---------

Co-authored-by: Arvid Norberg <arvid.norberg@gmail.com>
2023-07-20 15:29:10 -05:00
Arvid Norberg eda68c0cdd solution_generator (#15768)
* use solution_generator() from rust

* farm blocks with backrefs

* update BlockTools to generate block generators serialized with backrefs

* support deserializing programs with backrefs
2023-07-17 10:05:37 -05:00
Jack Nelson 5d1d328682 Cleanup & Fix Simulator Sub Epoch Logic (#15698)
* cleanup sub slot logic

* cleanup + fix code

* add more comments
2023-07-15 18:18:45 -05:00
William AllenandJack Nelson f96690bdc5 Renaming instances of 'decompresser' to 'decompressor' (#15751)
* Renaming instances of 'decompresser' to 'decompressor'

* Making 'parallel_decompressors_count' singular

* Using chiapos version that has matching spelling

* Putting the clsp file back where I found it

* fix ver

---------

Co-authored-by: Jack Nelson <j.nelson@chia.net>
2023-07-13 09:59:51 -05:00
Arvid NorbergandFlorin Chirica 7b67fe0a4a compressed plot support (#15702)
* Compression branch.

* disable GPU farming in tests

---------

Co-authored-by: Florin Chirica <fchirica96@gmail.com>
2023-07-12 16:49:15 -05:00
Arvid NorbergandAmine Khaldi cecda28e84 Plot filter hard fork (#15336)
* update passed_plot_filter() to take the filter size rather than consensus constants. This allows the filter size to change by block height. make verify_and_get_quality_string() take either the height or filter size

* Add some filter_prefix_bits tests on test blocks.

* Add some filter_prefix_bits tests on simulated farmer and harvester.

* Cache filter prefix bits by challenge chain signage point hash and use that for the the lookups. This allows us to perform plot filter validation.

* Add more cases to verify_and_get_quality_string() unit tests.

* Add some tests for Farmer's respond_signatures.

* Apply Kevin's suggestion to simplify the check for passing plot filter.

* Apply Kevin's suggestions to simplify some test checks and fix a couple typos.

* Apply Kevin's suggestion to send peak height instead of filter prefix bits as part of NewSignagePoint.

* Remove no longer needed filter prefix bit related logic and make height non optional in verify_and_get_quality_string().

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2023-07-12 10:26:23 -05:00
Arvid Norberg ca1147584d Hard fork 2.0 (#15581)
* add HARD_FORK_2_0 consensus_mode to run tests under hard-fork consensus rules

* hook up soft-fork and hard-fork changes in CLVM

* fix AGG_SIG_* garbage tests for the 2.0 hard-fork

* add test for unknown conditions with cost, which is a hard-fork feature

* add mempool tests for unknown conditions with cost

* add tests for the SOFTFORK condition

* fix benchmark to take LIMIT_ANNOUNCES into account
2023-07-07 13:58:43 -05:00
Jack Nelson d30922d6b6 Fix fork height constant for simulator / block tools (#15629)
* add fork height  const

* Update block_tools.py

* fix tests
2023-07-06 13:24:56 -05:00
Rigidity e3e825813c Update simulator SSL keys to PKCS#8 (#15630) 2023-06-27 01:05:54 -05:00
Kyle Altendorf 7ba5272a97 call fix_ssl() after create_all_ssl() in block tools (#15517) 2023-06-21 12:54:39 -05:00
dustinfaceandKyle Altendorf 49140b2b3c server: Introduce ApiProtocol (#15466)
* server: Introduce `ApiProtocol`

* genericize (#5)

* `ApiProtocol.api_ready` -> `ApiProtocol.ready()`

* Add `ApiProtocol.log` and give APIs separate loggers

* Fix `CrawlerAPI`

* Drop some unrelated removals

* Fix some of the generic hinting

* Revert some changes in `timelord_api.py`

* Fix `CawlerAPI` readiness

* Fix hinting

* Get some `CrawlerAPI` coverage

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-06-13 20:12:25 -05:00
dustinface d6a2a9aa5d seeder: Drop CrawlerAPI.__getattr__ (#15489)
* Test sending unknown messages to the crawler

* Drop `CrawlerAPI.__getattr__`

* Use a real crawler service for the test
2023-06-13 15:25:39 -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
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
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 5473c94a6b Annotate chia/simulator/block_tools.py (#15349) 2023-05-23 10:09:45 -05:00
dustinface 994aa24e44 wallet: Give Payment.memos a default value (#15172) 2023-05-03 00:30:53 -05:00
dustinface aa40fa7f21 wallet: Drop AmountWithPuzzlehHash, use Payment instead (#15019) 2023-04-27 09:52:27 -05: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 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
Kyle Altendorf a609a815ec remove unused Service(server_listen_ports=) parameter 2023-03-28 13:55:44 -04: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
Kyle Altendorf d84917f5df hint chia.plotting.create_plots (#14692)
* hint chia.plotting.create_plots

* correct the import

* fixup

* imports

* get final from typing_extensions
2023-03-08 12:57:50 -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
dustinface fe321ea488 daemon: Fix server shutdown / wait for it (#14674)
* Create the shutdown event inside `WebSocketServer.__init__`

* Rename `WebSocketServer.start` to `run` and make it a contextmanager
2023-02-28 11:43:24 -06:00
Kyle Altendorf 12ddc928c2 gc.collect() before unlinking the db in some tests (more) (#14702)
https://github.com/Chia-Network/chia-blockchain/pull/14491
https://github.com/python/cpython/issues/97641
2023-02-28 11:40:17 -06:00
Kyle Altendorf 381d1317de hint chia.cmds.init, chia.cmds.init_funcs (#14682)
* hint chia.cmds.init, chia.cmds.init_funcs

* optional for now at least

* we will update mypy.ini later
2023-02-28 03:04:08 -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
Kyle Altendorf f2a6d8decf drop trailing commas in unpacking assignment (#14655) 2023-02-23 10:43:14 -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
Kyle Altendorf c678f00acb cleanup adjacent string literals (#14650) 2023-02-22 17:16:07 -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
Kyle Altendorf 41ca9622a3 close the keychain proxy in more failure and cancellation cases (#14415) 2023-02-22 02:51:26 -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 885df8c458 simplify compute_additions and remove unnecessary functions (#14543) 2023-02-15 22:52:16 -06:00
Arvid Norberg 07450b7dda use run_block_generator() to run block generators (#14544)
use the new run_block_generator() function from chia_rs
2023-02-13 11:00:21 -06:00
Kyle Altendorf 6e70868888 move wallet_is_synced/wallets_are_synced to FullNodeSimulator methods (#14403)
* move wallet_is_synced/wallets_are_synced to FullNodeSimulator methods

* black

* gotta catch 'em all
2023-02-10 15:13:23 -06:00
Kyle Altendorf f346de94ba refactor test_pool_rpc (#14196)
* preliminary test_pool_rpc refactor

* remove todo

* handle some todos

* one more

* wait for wallets to sync in the fixtures

* drop an extra wallet

* drop unused function
2023-02-08 19:43:43 -06:00
Kyle Altendorf 872924d65e fix crossed parameters for setup_simulators_and_wallets_inner() calling setup_full_node() (#14480) 2023-02-07 18:25:11 -06:00
dustinface 5d55cd6a22 simulator: Replace localhost -> 127.0.0.1 in farmer/harvester config (#14165)
We create new configs in `setup_farmer` and `setup_harvester` and they 
contain `localhost` defaults. Replace it here also like we do it in 
`BlockTools` to consistently use `127.0.0.1` instead of `localhost` in 
tests.
2023-02-05 22:16:18 -06:00
Kyle Altendorf 649e5ac4b0 gc.collect() before unlinking the db in some tests (#14491)
https://github.com/python/cpython/issues/97641
2023-02-04 15:05:26 -06:00
Arvid Norberg cbbc8b43b8 make the tests use the real COST_PER_BYTE constant (#14470) 2023-02-04 14:14:52 -06:00