Commit Graph
41 Commits
Author SHA1 Message Date
Matt HauffandGitHub 40db4635a8 [LABS-245] Enable PEP604 Ruff rules (#20269)
* Enable PEP604 Ruff rules

* Fix harcoded signature in test

* Hack CLVMStreamable test with note to fast follow
2025-11-18 12:34:00 -08:00
Arvid NorbergandGitHub 224fb82383 require block generators to use canonical CLVM serialization after 3.0-hard fork (#19714) 2025-06-26 10:18:37 -07:00
6050235bdb [CHIA-3043] Add (hopefully) non-controversial ruff rules (#19684)
* Add (hopefully) non-controversial ruff rules

* mypy-exclusions.txt

* PIE

* Fix pre-commit?

* PYI

* RSE

* S + ignores

* Whitespace fix

* Re-add build-init-files.py

* Add comment about security ignores

* Update mypy-exclusions.txt

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

* Fix the executable status of build-init-files.py

* Set executable bit for tools/run_block.py and readd shebang

* Fix new errors

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2025-06-11 08:36:08 -07:00
Amine KhaldiandGitHub 6c2c13a2d0 CHIA-1626 Move some modules to the utils virtual project (#18692)
Move some modules to the utils virtual project.
2024-10-18 10:40:49 -07:00
Kyle AltendorfandGitHub 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 NorbergandGitHub 65ef0f4ec4 fix error codes and add more test coverage for message conditions (#17819) 2024-04-05 06:45:09 -07:00
Arvid NorbergandGitHub c67b8bbe5e message conditions (#17772)
* bump chia_rs to 0.6.1

* introduce soft-fork 3, to enable message conditions

* add wallet tests
2024-03-27 16:08:29 -07:00
Almog De PazandGitHub d966f3f9e6 Add bad peak cache (#16027)
* add and check bad peak hash

* move check

* refactor, add tests, change cache to Dict

* pr fixes

* fix bad f-string

* refactor chip-0013 errors

* limit cache size, add size to constants

* test cache invalidation fix invalidation bug

* fix off by one

* move cache size to config

* remove bt conf override

* use get_peers_with_peak

* fix expected exception in test_soft_fork4_activation
2023-08-30 13:27:22 -05:00
Arvid NorbergandGitHub ec9d0096f4 demote log level for TIMESTAMP_TOO_FAR_IN_FUTURE errors (#16101) 2023-08-29 13:46:57 -05:00
Jack NelsonandGitHub 9713c3f5f4 Fix Cli error when exiting on some builds of python. (#15762)
* change from exit to sys.exit and remove catch

* change error to ClickException and move error messages

* cleanup wallet func
2023-07-14 17:39:30 -05:00
dustinfaceandGitHub ede354c58f protocols: Introduce error protocol message (#15493)
* protocols: Introduce `error` protocol message

* Add `Optional` extra data `Error.data`

* Test `Err` entries
2023-07-13 13:46:20 -05:00
Jack NelsonandGitHub 3eb23f60da Cleanup CLI RPC connection error handling (#15704)
* remove none from async generator and add a custom error type

* remove client check from data funcs

* remove client check from farm funcs

* remove client check from peer, show and netspace funcs

* remove none check from sim funcs

* change the wallet code in cmds util to use the new error type

* update plotnft_funcs with new error

* remove none checks from coin and wallet funcs

* cleanup logic a tad
2023-07-10 15:41:51 -05:00
Arvid NorbergandGitHub 3d94d3a7ff 2.0 updates (#15580)
* add names for new error codes (from chia_rs)

* add constant for SOFTFORK condition opcode

* add chialisp constant for SOFTFORK condition
2023-06-22 07:08:34 -05:00
Arvid NorbergandGitHub 8dbfc4840a enable soft-fork2 conditions (incl. ASSERT_BEFORE) (#14733)
* 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
2023-03-23 11:30:10 -05:00
Arvid NorbergandGitHub 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 NorbergandGitHub 9166b83993 fix typo introduced in bumping of chia-rs dependency (#14581) 2023-02-15 23:01:55 -06:00
Arvid NorbergandGitHub 1b6201852a bump chia_rs to 0.2.2 (#14533)
* bump chia_rs to latest version

* add new error codes for ASSERT_BEFORE_* condition failures, ASSERT_CONCURRENT_SPEND failing, ASSERT_CONCURRENT_PUZZLE_FAILED and for impossible constraints

* add new condition opcodes for ASSERT_BEFORE_*, ASSERT_CONCURRENT_SPEND and ASSERT_CONCURRENT_PUZZLE

* fixup Spend and SpendBundleCondition types

* fixup tests that otherwise fail with MINTING_COIN

* fix test that otherwise would fail with RESERVE_FEE_CONDITION_FAILED

* remove use of NO_NEG_DIV flag. It's now implied

* remove duplicate test parameters
2023-02-10 15:14:56 -06:00
Kyle AltendorfandGitHub a063d0c224 remove args passed to super() calls (#14407) 2023-01-27 17:19:12 -06:00
Adam KellyandGitHub 5ba71957d8 Display complete exception info in log file (#14319)
* Display complete exception info in logfile

* Update mempool tests

* Update mempool tests
2023-01-19 15:31:26 -06:00
dustinfaceandGitHub 2e2c297a80 util: Remove legacy keyring support (#13398) 2022-11-18 10:33:18 -06:00
Kyle AltendorfandGitHub 3b084a165b configure isort to add the future annotations import (#13327)
* configure isort to add the future annotations import

* apply the new isort setting

* remove type ignores for new mypy (#13539)

https://pypi.org/project/mypy/0.981/

* another
2022-09-30 03:40:22 -05:00
dustinfaceandGitHub 70fe981fb3 cmds: Implement chia beta (#12389)
* cmds: Implement `chia beta` for the beta test program

* Unhide and document all `beta` subcommands

* Refactor all subcommands

* Introduce `chia beta configure`

* Introduce `chia beta status`

* Test all `chia beta` commands

* Use a separate file logger for beta logs

* Write the plotting call args to the log file

* Sort potential submissions

* Some refactoring around log file log handler creation

* JSON dump the plotting args
2022-09-12 16:57:31 -05:00
dustinfaceandGitHub fed2ba630e util: Implement key label support for FileKeyring and KeyringWrapper (#12843)
* util: Implement key label support for `FileKeyring` and `KeyringWrapper`

* Restrict trailing/leading whitespaces in the label

* Bump `MAX_LABEL_LENGTH` to 65

* Additional label tests

* Drop duplicated `KeychainFingerprintNotFound` definition
2022-08-25 19:12:47 -05:00
dustinfaceandGitHub 62642b3b15 util: Introduce get_key/get_keys in Keychain + KeychainServer (#12830) 2022-08-24 01:18:34 -05:00
dustinfaceandGitHub 9d5d76d611 util: Introduce KeyData and _get_pk_and_entropy -> _get_key_data (#12752)
* util: Introduce `KeyData` and `_get_pk_and_entropy` -> `_get_key_data`

* Fix typos

* `include_secrets=False` in `delete_key_by_fingerprint`

* Use a variable for the mnemonic string in `KeyDataSecrets.__post_init__`
2022-08-22 11:24:31 -05:00
8441b90e16 cleanup keychain proxy (#12993)
* listener fixes

* cleanup timeout logic

* fix error handling

* clear up code

* Update keychain_proxy.py

* clean up more keychain stuff

* Apply suggestions from code review

they make sense

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

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-08-17 17:51:54 -05:00
dustinfaceandGitHub da69ae6ad1 util: Raise in Keychain.add_private_key if the key already exists (#12747) 2022-08-10 03:13:21 -05:00
dustinfaceandGitHub 4611d0aa43 util: Move all keychain related errors into chia.util.error (#12756)
Also derive them from `KeychainException` and name them consistently.
2022-08-05 02:05:58 -05:00
Mariano SorgenteandGitHub f0a6189f2d Move BLS validation to other processes during sync (#9746)
* Try putting BLS in multiprocess

* Fix test

* Fix test again

* Fix test again ^ 2

* Don't use cache unless necessary, cleanup of unused code.

* WIP fixing tests

* Blockchain tests passing

* Remaining tests and lint

* More test fixes

* Fix full_node_rpc test

* Fix remaining tests

* Correct boolean

* Don't validate sig if CLVM fails. Also testing signature validation properly

* Simplify block prevalidation API and improve tests

* Fix logic error and remaining tests

* Update comments and change to AssertionError

* Try to improve CI performance

* Fix mempool test, try to fix test_blockchain performance

* Set default argument to fix test

* Fix DB conversion test

* Use cache for validating signatures (#9859)

* Use cache for validating signatures

* comments: fix typo

* Don't rerun the super slow part of the test (#9887)
2022-01-20 14:50:41 -08:00
Earle LoweandGitHub 7fdd0b2fd7 Improved mempool validation and test (#8652) 2021-09-30 16:07:22 -07:00
e9bf0ec12b Reply type decorator (#8276)
* Check types of messages returned from other peers

* Check message type data structures at startup, check that no peeer messages that expect replies are broadcast, and dynamically check return types of messages that do expect replies.

* Type hint protocol message type check functions

* lint

* typo

* add replay_type decorator

* add api reply decorations

* typo

* Don't check non full-node broadcast messages

* Distinguish internal vs peer protocol error
Added Changelog
Moved static check to import time
Moved protocol timeouts to chia/protocols/protocol_timing.py
Comment typos
Rename create_request -> send_request
Comment that INVALID_PROTOCOL_MESSAGE is bannable, not temporary

* Call static check at module import time

* Rename message_response_ok

* Improve protocol checking for outgoing message validation

* Type-o

* reset submodule

Co-authored-by: almog <almogdepaz@gmail.com>
2021-09-20 11:31:15 -07:00
Arvid NorbergandGitHub 7927a45945 remove initial transaction freeze feature (#7922) 2021-08-03 10:21:37 -07:00
Mariano SorgenteandGitHub 5d3d4bbefc No negative amounts (#4294)
Mempool no negative amounts
Don't disconnect for COIN_AMOUNT_NEGATIVE
2021-05-10 01:28:15 +09:00
Mariano SorgenteandGitHub 8aed3645be 1,2,3 mojo attack prevention (#3017) 2021-04-28 10:52:22 -07:00
e55988479b More tests (#2295)
Co-authored-by: Mariano <sorgente711@gmail.com>
2021-04-21 11:17:21 -07:00
Mariano SorgenteandGitHub e62be6c422 Ms.block body tests (#2203)
* Start block body tests

* More tests

* More tests

* Improvements and security fixes to block body validation

* Revert bad test changes

* Fix check for ref list size
2021-04-20 12:18:16 -07:00
a6874bd2fe Block compression and decompression (#1959)
* squash

* rebase cleanup

* cost

* Combine adam's and straya's PRs

* Fix cost test

* Fix another test

* Improve safety in reorgs

* Improve wallet in reorgs

* Improve wallet in reorgs

* Bug in reorg handling

* Bug in reorg handling, and fix test

* Band aid

* Comment out to pass test

* Comment out test

* rebase clean

* USe a list of reference generators

* create

* Integrate Block Compression

* Fix generator argument creation

* improve test

* update block tools

* Separate CompressorArg and GeneratorArg, improve type hints

* First crack at `list_to_tree`.

* Integrate generator arguments as tree

* End to end test for generators

* Fix linting issues, hook up things, and add a test

* tidy GeneratorArg test

* Get compression and decompression working in full node

* Fix fetching block generator from DB in multiprocess

* Fix edge case in reorgs, test many combinations of reorgs

* reduce max number of generators refs allowed in a block

* Apply Straya's fix for calculating the end index for generator args

* typos

* Run test_block_compression for a transaction large enough to force multiple input coins in the transaction

* Update generator compression tests for treearg change and decompressor offset args fix

* Fix merge conflict

* Fix test

* Fix full node tests

* Don't make full blocks

* fix lint

Co-authored-by: Yostra <straya@chia.net>
Co-authored-by: Adam Kelly <aqk@aqk.im>
Co-authored-by: Richard Kiss <him@richardkiss.com>
2021-04-16 23:13:22 -07:00
matt-o-howandGitHub 332d9392f9 Add test for relative seconds, and rename conditions (#1902)
* Add test for relative seconds

* rebased on top of main

* Renamed AGG_SIG to AGG_SIG_UNSAFE
Renamed height and time conditions
Changed some demo p2 puzzles to use AGG_SIG_ME

* fix merge on cost_calculator

* update hex and sha256tree of p2_delegated_conditions

* fix condition name in rl clvm

* updated the innerpuz sha256tree after careful inspection
2021-04-15 13:00:14 -07:00
Adam KellyandYostra e7627c567f Change generator ref error message name 2021-04-14 20:02:10 -07:00
Adam KellyandYostra 73d5577bec Validate Generator Reference field during block validation. Validate size in bytes of generator against MAX_GENERATOR_SIZE. Lower max generator list entries. 2021-04-14 20:02:10 -07:00
Richard KissandGene Hoffman f2b577dda1 git mv src chia 2021-04-04 21:41:39 -07:00