Commit Graph
376 Commits
Author SHA1 Message Date
Matt Hauff 8f0cd0eab8 [CHIA-1673] Comment out a manual ._finish_sync() call (#18783)
* Delete a manual `._finish_sync()` call

* Add comment
2024-10-30 09:25:52 -07:00
Arvid Norberg 2df931bf87 [CHIA-1566] pipeline block validation in sync_from_fork_point() (#18703)
* make pre_validate_multi_processing() return futures, rather than the awaited and joined results from the thread jobs. This is crucial to allow the validaion jobs to run concurrently with the database interaction in the main thread

* Split up the add_block_batch() function into 3 parts, preparing them to be pipelined in long-sync

* pass AugmentedBlockchain into pre_validate_multiprocessing() and prevalidate_blocks(), to support the augmented blockchain to outlive a single batch

* pipeline pre-validation in sync_from_forkpoint()

* optimize the common case of _reconsider_peak(), to avoid one database lookup

* address review comments

* rename filter_blocks() -> skip_blocks(). It's is only relevant at the start of the sync, add comment and assert
2024-10-25 08:38:23 -07:00
Arvid Norberg 8c72d22edf move add_blocks_in_batches() out of tests (#18750)
move add_blocks_in_batches() out of tests, since the node simulator depends on it
2024-10-23 08:50:08 -05:00
Almog De Paz a80d779fe6 refactor full_node add_block (#18584)
* refactor

* minor fixes

* fix_tests

* add finish sync to add_blocks_in_batches

* add_blocks_in_batches updates wallets

* test fixes

* fix condition in add_block

* add known block to cache

* restore comment

* remove init file from log dir

* fix failed reorg test

* revert known block info change

* assert height in cat test

* wait for wallet height in nft test

* assert sync all height for all wallets

* test_cat_creation assert height

* rename vars

* assert height in process states
2024-10-22 12:14:18 -07:00
Kyle Altendorf 3b6f547d45 bytes zeros (#18475)
* `ZERO_32`

* `bytes(\d+)\(\[0\] \* \1\)`

* `bytes(\d+)\(b"\\(x00|0)" \* \1\)`

* `bytes(\d+)\(b"0" \* \1\)`

* Revert "`bytes(\d+)\(b"0" \* \1\)`"

This reverts commit 2d629dcb0a.
2024-10-22 12:07:07 -07:00
Kyle Altendorf 9c8557a1f8 Remove Python 3.8 support and update source to 3.9 standards (#18687)
* manual python 3.8 removals

* poetry

* pyupgrade

* black

* isort

* manually tidy imports

* work around shadowed type

* catch up build network protocol files for pyupgrade changes

* placate pylint

* re-enable 20.04

* placate flake8
2024-10-16 14:21:15 -07:00
Arvid Norberg e7241ebfe0 simplify passing around difficulty, sub slot iterators and prev_ses_block (#18660)
* combine current sub slot iterations, current difficulty and previous ses block into ChainState, to make it easier to pass around and update

* address review comments

* address review comments. rename ChainState -> ValidationState. add more comments
2024-10-07 11:09:15 -07:00
Arvid NorbergandAmine Khaldi 1e8c999c09 multiprocess_validation refactor (#18541)
* slightly simplify call to pre_validate_blocks_multiprocessing. batch size is always 4, check_filter is always True. Remove the member function wrapper around it in Blockchain, to prepare for being able to pass wrapped blockchains into it

* address review comments

* Apply suggestions from code review (addendum).

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2024-09-23 09:48:11 -07:00
Almog De Paz b6faed828f clean add block and prevalidation (#18569)
* add_block ssi not optional

* pass ses block to prevalidaiton

* fix tests

* covrage

* move parma
2024-09-11 09:41:32 -07:00
Arvid Norberg d1844b6b15 CHIA-1101: update BlockGenerator type (#18508)
change the type of ref_list to List[bytes] instead of List[SerializedProgram]. Also, avoid passing the block generator twice to the worker process for validation
2024-08-23 01:08:27 +08:00
Arvid Norberg 700a67344b BlockchainInterface as a protocol (#18486)
* turn BlockchainInterface into a proper Protocol, to allow mypy to check it

* split out a subset of BlockchainInterface into BlockRecordsInterface

* separate BlockCache into the (simple) production use case and the (complex) test use case of mocking a blockchain object
2024-08-23 01:02:43 +08:00
Matt Hauff 126a8a2d83 [CHIA-1115] Optimize create_coins_with_amounts a bit (#18470)
* Optimize `create_coins_with_amounts` a bit

* Just generate new for each conflicting amount
2024-08-15 09:07:49 -07:00
Kyle Altendorf 7d88089e8f more bytes32.from_hexstr() (#18446) 2024-08-14 15:05:41 -07:00
Matt HauffandAmine Khaldi 723636b471 [CHIA-1092] Port test_cat_wallet.py to WalletTestFramework (#18439)
* temp

* Port `test_cat_creation`

* Port `test_cat_creation_unique_lineage_store`

* Delete `...reuse_address` test

* Port `test_get_wallet_for_asset_id`

* Port `test_cat_doesnt_see_eve`

* Port `test_cat_max_amount_send`

* Port `test_cat_hint`

* Port `test_cat_change_detection`

* Name test amount and fees in test_cat_creation.

* Use set_remainder for first test

* Match the ValueError we're expecting in test_cat_max_amount_send.

* Comment.

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2024-08-14 09:25:01 -07:00
Matt Hauff 8bc332f95e [CHIA-1037] Add TXConfig to action scopes (#18406)
* Add TXConfig to action scopes

* Fix DID test

* Fix CR-CAT method

* Fix NFT offer test
2024-08-07 11:27:13 -07:00
Arvid Norberg ba9420b553 remove block_height_list from BlockGenerator (#18302)
* remove block_height_list from BlockGenerator. This field is only used when farming blocks, and we don't use it in production right now. We only use it in the tests, BlockTools. It has been updated with a cleaner and more direct way of setting the block reference list in new blocks

* test
2024-08-01 16:41:39 -07:00
Almog De PazandEarle Lowe 1c1e030e1e refactor new_peak_timelord (#16881)
* refactor new_peak_timelord

* fix test

* improve test assertions

* lint

* return after skipping peak

* improve comments

* limit condition to a diff of one block

* remove log

* refactor test

* better conditions
consider overflows as well

* pre commit

* test with overflow

* add test for EOS case

* lint

* comment

* prefer lower iterations peaks

* test full node receiving same weight lower iterations

* lint

* fix reorg test, lint

* fix block tools bug

* use signage point param in test

* use signage point param for overflows as well

* remove unused case

* fix block_tools condition

* lint

* lint

* Add check for peak not none in test

---------

Co-authored-by: Earle Lowe <e.lowe@chia.net>
2024-07-29 11:23:39 -07:00
Chris Marslender b14d912d3c Crawler Loop Fix + Test Improvements (#18329)
* Change a bunch of info logs back to warning in crawler, since crawlers are typically run in warning mode, to avoid the info log connection spam

* Ensure that the crawler loop ONLY doesn't start when in tests

* Rename the crawler service to crawler_service_no_loop, so defaults can also be tested WITH a loop

* Test crawler loop modes

* Add message when we received state chaged callback

* Add log to indicate crawling has started and how many peers we're crawling
2024-07-17 12:17:42 -07:00
Matt Hauff 055588914e [CHIA-714] Add usage of action scope throughout wallet codebase (#18128)
* Add the concept of 'action scopes'

* Add `WalletActionScope`

* Fix CATWallet pending_change calculation

* Add action_scope: WalletActionScope to all tx endpoints

* Add usage of action scope throughout wallet codebase

* Add the concept of 'action scopes'

* pylint and test coverage

* add try/finally

* add try/except

* Undo giving a variable a name

* Fix CRCAT test

* Fix trade tests

* Fix cat test

* Fix miscellaneous test

* Fix miscellaneous test

* Fix miscellaneous test

* pylint

* Add auto claim test coverage

* Take advantage of extra_spends

* Fix tests

* test fixes

* pylint
2024-07-17 12:17:16 -07:00
Matt Hauff 4ffb6dfa6f [CHIA-713] Add action_scope: WalletActionScope to all tx endpoints (#18127)
* Add the concept of 'action scopes'

* Add `WalletActionScope`

* Fix CATWallet pending_change calculation

* Add action_scope: WalletActionScope to all tx endpoints

* Add the concept of 'action scopes'

* pylint and test coverage

* add try/finally

* add try/except

* Undo giving a variable a name

* Fix CRCAT test

* Fix trade tests

* Fix cat test

* Fix miscellaneous test

* Fix miscellaneous test

* Fix miscellaneous test

* Add auto claim test coverage
2024-07-16 11:06:01 -07:00
Arvid Norberg b4290a2f2f [CHIA-786] remove the original block compression (#18209)
remove the original form block compression, now that the hard fork has activated and we serialize CLVM in a more efficient way
2024-07-09 12:16:51 -07:00
Arvid Norberg 260c7a363a [CHIA-786] simplify hard-fork consensus rules (#18208)
the hard fork has activated. From now on we can simplify some of the updated consensus rules to apply unconditionally to block height
2024-07-05 09:52:03 -07:00
Kyle Altendorf 3061cd83d7 remove some pylint ignores (#18140) 2024-06-18 14:24:30 -05:00
Matt Hauff 3637bd33c6 Delete chia.util.misc (#18170)
* Move VersionedBlob to chia.util.streamable

* Move format_bytes to chia.cmds.cmds_util

* Move format_minutes to chia.cmds.cmds_util

* Move prompt_yes_no to chia.cmds.cmds_util

* Move get_list_or_len to from chia.plot_sync.receiver

* Move validate_directory_writable to chia.cmds.cmds_util

* Move *termination_signals to test_services

* Move UInt*Range to chia.util.streamable

* Create chia.util.batches

* Create chia.server.signal_handlers

* Create chia._tests.util.split_managers

* Move ValuedEvent to chia.types.transaction_queue_entry

* Move available_logical_cores to chia.util.cpu

* Move caller_file_and_line to chia._tests.util.misc

* Move satisfies_hint to chia._tests.wallet.test_singleton_lifecycle_fast
2024-06-18 08:27:17 -05:00
Arvid Norberg a745cb0344 CHIA-603: drop support for testnet10 (#18075)
* clean up some code kept around just to support testnet10

* remove configs and overrides for unsupported testnets
2024-06-09 00:25:09 +01:00
Rigidity a9e8e4b91a CHIA-623: Split capabilities for each service (#18096)
* Move capabilities underneath Capability

* Split default capabilities for each service

* Make get_capabilities take in node_type

* Remove optionality

* Refactor get_capability_overrides
2024-06-04 17:01:59 +01:00
Arvid Norberg 605e3b8982 [CHIA-615] make BLSCache a proper class (#18053)
* make BlsCache a proper class, rather than a global dict with helper functions

* make the BLS cache a member of the FullNode, rather than a global variable

* add test for BAD_AGGREGATE_SIGNATURE when using the BLS cache
2024-05-31 13:57:20 -05:00
Matt Hauff aefe7fdf28 Observer Mode (#17792)
* Observer Mode

* Address comments by @altendky

* Change RPC default and fix test coverage

* Add test coverage for rpc marshaller

* Fix @marshal util to return proper transactions
2024-05-07 13:39:25 -07:00
Arvid NorbergandRigidity 8eb41c59d7 bump chia_rs to 0.7.0 (#17909)
* bump chia_rs to 0.7.0 and transition using sized ints and sized bytes from chia_rs

* transition StructStream to use the version from chia_rs

* Initial port of ConsensusConstants to Rust

* Revert max cost calculation to use int for now

* Remove SizedBytes, since it was moved to chia_rs

* Remove test_struct_stream, since it was moved to chia_rs

* use [0] * 100 instead of bytes(100)

* restore wallet_rpc_api, and make type hints match JsonDict (Any)

* fixup ConsensusConstants; restore return value of calculate_prefix_bits()

* fixup ConsensusConstants; construct int for intermedate cost values

* fixup ConsensusConstants; construct int for intermedate cost values

* fixup: transition StructStream to use the version from chia_rs

* revert changing type annotations for json dict

---------

Co-authored-by: Rigidity <me@rigidnetwork.com>
2024-04-26 08:06:25 -07:00
Amine Khaldi 960274899e Move SimulatorFullNodeService type alias to start_simulator (#17875)
Move SimulatorFullNodeService type alias to start_simulator.
2024-04-18 14:26:36 -07:00
Amine Khaldi b1dd363256 Properly construct uint64 objects for Coin amounts (#17745)
Properly construct uint64 objects for Coin amounts.
2024-03-25 12:00:04 -07:00
Matt HauffandAmine Khaldi 835c1f8924 Port tests/wallet/test_wallet.py to WalletTestFramework (#17687)
* Port test_wallet_coinbase

* Port test_wallet_make_transaction

* Port test_wallet_reuse_address

* Port test_wallet_clawback_claim_auto

* Port test_wallet_clawback_clawback

* Port test_wallet_clawback_sent_self

* Port test_wallet_clawback_claim_manual

* Port test_wallet_clawback_reorg

* Rebase fixes and flakiness improvements

* Port test_get_clawback_coins

* Port test_clawback_resync

* Port test_wallet_coinbase_reorg

* Port test_wallet_make_transaction_hop

* Port test_wallet_make_transaction_with_fee

* Port test_wallet_make_transaction_with_memo

* Port test_wallet_create_hit_max_send_amount

* Port test_wallet_prevent_fee_theft

* Port test_wallet_tx_reorg

* Port test_address_sliding_window

* Port test_sign_message

* Port test_wallet_transaction_options

* Remove unneeded check_balances call.

* Introduce tx_amount and use it across test_wallet_clawback_claim_auto.

* Reapply b79ecd2 (got lost in the recent merge).

* Minor improvements to test_wallet_clawback_clawback:

* Introduce tx_amount and test_fees and use them to clarify test conditions.
* Remove no longer needed json.dumps(resp) call.
* Remove unneeded dict() call on a {} constructed dictionary.

* Remove accidental change (addendum to bebc87f).

* More tx_amount and test_fees.

* Remove no longer needed json import.

* Remove unneeded dict() calls on {} constructed dictionaries.

* Introduce tx_amount2 in test_clawback_resync and clarify state transitions.

* Clarify state transitions in test_wallet_make_transaction_hop.

* Simplify transaction_has_failed.

* Just some consistency.

* Remove unneeded check_balances calls.

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
2024-03-20 09:08:00 -07:00
Kyle Altendorf 774f5c0493 flake8 ignore E226 (#17700) 2024-03-13 16:40:26 -07:00
Earle Lowe 48e4039e58 Update black to 24.1.1 and update source as needed (#17499)
* Update source to black 24 spec

* update black to 24.1.1

* update pylint to ignore multiple-statements

* update test file

* black updates

* format updates

* Update test_network_protocol_files.py

* Update test_network_protocol_files.py
2024-03-13 11:08:19 -07:00
58cf78de04 Wallet Block Tools (#17580)
* Remove consensus logic in part from wallet tests

* Fix simulation test

* Test coverage

* test coverage

* Improve handling of block_list_input in WalletBlockTools's get_consecutive_blocks.

* Update tests/wallet/conftest.py

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

* Address comments by @arvidn

---------

Co-authored-by: Amine Khaldi <amine.khaldi@reactos.org>
Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2024-03-12 13:50:21 -07:00
Matt Hauff 536a96241d Various test flakiness fixes (#17650) 2024-03-05 10:53:48 -08:00
Arvid Norberg fe89b5b782 undo some unnecessary int type casts (#17521)
* undo redundant type-casts from slots, SubEpochSummary and SubEpochData

* undo redundant type-casts from proof-of-space, reward chain and foliage types

* undo redundant type-casts from VDFInfo, VDFProof and ClassgroupElement

* remove unnecessary type annotation
2024-02-08 15:29:33 -08:00
Matt Hauff c6f1a57c56 Unify transaction pushing (#17458)
* Don't autopush transactions by default anywhere

* Remove ignore_max_send_amount

* Use TXConfig instead of pending_transactions for coin exclusion in spend_clawback_coins

* Unify transaction pushing into a single method

* Address offline comments by @emlowe

* Rework max send amount to be based on coin quantity rather than amount

* Inadvertent changes

* Test fixes

* Inadvertent change

* Bad import?

* Inadvertent changes?

* readd missing test
2024-02-05 10:34:47 -08:00
Amine Khaldi 1977c2d7c1 Augment conditions_dict_for_solution and conditions_for_solution to accept both types of programs (#17451)
Augment conditions_dict_for_solution and conditions_for_solution to accept both programs and serialized programs.

This allows us to use serialized programs without the need to convert them into programs.
2024-01-31 17:27:49 -08:00
StartToaster c4eea85b72 Remove Announcement class in favor of Condition subclasses (#17377)
Recreation of PR #16384

checkpoint: into main from long_lived/vault @
f96aaee604
Remaining commits: 16
2024-01-29 10:49:12 -08:00
0ae3b2823f Support for third-party, farmer-rewarded, Harvesters (#16717)
* Begin add to support for third-party fee-based harvesters

Signed-off-by: Harold Brenes <h.brenes@chia.net>

* Return FoliageBlockData back to Farmer from FullNode

* Send FoliageBlockData all the way to the harvester, if requested

* Preparing tests for 3rd party  harvester support

* Continue writing tests for 3rd party harvester

* Some cleanup. Drafting

* Test full message chain of third-party Harvester reward overwrite.

Added test that validates messages between Farmer, Harvester and FullNode
to ensure that the correct data is used when an overwritten farmer reward
address is given by a third-party Harvester service.

* Changing Harvester signature request flow
to include original data, if requested.

This makes it so that NewSignagePoint unconditionally
always includes the source of the SP hashes.

* Fix incorrect field name

* Harvester can ask for original signing data without
 overwriting the reward address also.

* Update test_farmer_handles_farmer_reward_address_override to reflect changes.

- Correct farmer API get the correct data source for the signage point signature request.
- Trivial fixes

* Removing some obsolete stuff

* Trivial

* Fix tests in updated harvester protocol

- Fix including source data when
include_source_signature_data is set.

- Set source data fields optional.

- Update test so that a timelord is started and we get proper signage points
instead of aritficial ones. This helps us
make sure we test for all the source data
cases needed from the full node.

* Refactor harvester source signing data test

- Remove older harvester signing data test
 (had missing coverage for data)

- Add harvester fee convention logging

- Begin fee convention logging test

- Refactor fixtures for harvester enhancement protocol tests

Start harvester

* Complete test for harvester fee convention

* Update SignatureRequestSourceData message

- SignatureRequestSourceData is now serialized as enum + bytes.

- Update usage locations for SignatureRequestSourceData.

- Update tests to reflect this

* Missing test from last commit

* Revert to explicit None checks, instead of relying on truthiness

Revert scratch work

* Linting

* adjust for anyio

* Moe linting

* mypy fixes

* Documentation comments

* Move third-party harvester protocol tests

Moved to own directory in order to enable `install_timelord = True`

* mypy fixes

* checkout_blocks_and_plots = True

* Update some log messages, syntax and docs

* Bump timeout in tests

* Update protocol message types for
harvester and farmer for test_missing_messages`

* Regenerate protocol message data for protocol tests

* Remove timelord requirement for tests.

Inject pre-generated signage points and blocks instead.

* Linting

* More linting

* More linting

* Merge from main and lint again

* Remove customized test plots requirements

* Rebase fix

* Coverage update

- Update valid fee quality test to be unit, instead of pseudo-integration.
- New test for invalid fee quality.
- More explicit messaging for invalid fee qualities.
- Explicitly comment out uncovered case in test.
- Update types for mypy.

* Lint

* Lint

* Lint, better logs

* add protocol file tests

* coverage

* Update formatting in fee quality logging

* Rebase fix

* Regenerate protocol_message_bytes-v1.0

---------

Signed-off-by: Harold Brenes <h.brenes@chia.net>
Co-authored-by: Harold Brenes <h.brenes@chia.net>
Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Harold Brenes <152330941+haorldbchi@users.noreply.github.com>
Co-authored-by: arvidn <arvid@libtorrent.org>
2024-01-26 15:07:30 -08:00
Amine Khaldi a6827c2e92 Singleton fast forward (#16919)
Initial iteration of singleton fast forward.
2024-01-26 13:20:42 -08:00
Arvid Norberg bdfffca5ab improve handling of UnfinishedBlocks (#17247)
* update full_node_store to support multiple UnfinishedBlocks with the same reward hash

* extend full node store to support recording outstanding requests for v2 unfinished blocks

* add test for full_node_store

* simplify creation of UnfinishedBlock in test_full_node.py

* extend UnfinishedBlock protocol to support distinguishing between unfinished blocks with the same partial hash but different foliage

* add test for NewUnfinishedBlock and NewUnfinishedBlock2

* when asking the full_node_store for an unfinished block, only by its partial hash; return the highest ranking (lowest foliage tx block hash)
2024-01-26 13:20:03 -08:00
Matt 9a44ca926d Merge commit 'f96aaee604072b83c9aae7bcb03a1e3856f4b4cc' into HEAD 2024-01-22 09:59:43 -08:00
Arvid Norberg c6d5f7fa1e use rust types for slots, SubEpochSummary and SubEpochData (#17298)
* use rust types for slots, SubEpochSummary and SubEpochData

* use rust type for EndOfSubSlotBundle

* use rust types for SubEpochChallengeSegment, SubEpochSegments and SubSlotData
2024-01-16 11:04:49 -06:00
Arvid Norberg 51808b4ef7 Rust proof-of-space, reward chain and foliage types (#17218)
* use rust type for ProofOfSpace

* use rust types for Foliage

* use rust types for reward chain blocks
2024-01-10 15:42:31 -06:00
Arvid Norberg 92499b64a2 use rust types for VDFInfo, VDFProof and ClassgroupElement (#17102)
* use rust types for VDFInfo, VDFProof and ClassgroupElement. Since these types aren't dataclasses, the dataclass.replace() is changed to method replace()

* add test for recursive_replace()

* add comment in recursive_replace() hack
2024-01-04 10:54:21 -08:00
Amine Khaldi f14383805e Merge commit '788db8bdffdebc612fbb97973fc0312a76fe3955' into checkpoint/main_from_release_2.1.3_788db8bdffdebc612fbb97973fc0312a76fe3955 2023-12-18 18:55:16 +01:00
Arvid Norberg 788db8bdff Fix compressed blocks (#17071) 2023-12-18 10:48:21 -06:00
Arvid Norberg bd18018a00 adapt conditions_dict_for_solution() to how it's used (#17034) 2023-12-13 09:25:20 -06:00