* 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
* more mypy platforms in ci
* check not checks
* oh yeah, activate...
* add 3.11
* adjust job names
* actually use the right python version for install
* adjust for 3.7 hinting support
* exclude macos 3.7 and macos arm 3.8
* back to 3.8 for now
* major_dot_minor
* oops
* move ignore comments for 3.7
* and more
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.
* add_missing_files
* lint
* dont error on fail to write
* use resource
* remove prints
* use dl folder and file names
* rearrange loop
* remove redundant str conversion
* dont break on failed upload
* Add plugin_id and healthz endpoints to s3 plugin service
* Add `chia data plugins check` cli
* plugin_id -> plugin_info
* updates based on reviews
* Use gather to run the lookups
* Update chia/data_layer/data_layer.py
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* Fix typo
* short_help -> help
---------
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* 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
* Added some sanity checks to upload and download
* Add server files path to config
* small fix
* send filenames and not paths now
* minor tweaks
* Update chia/data_layer/s3_plugin_service.py
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* use bytes32.fromhex and other fixes
* set host to "localhost"
---------
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* Partially revert 6d09a06
* Include fee amount when selecting XCH coins for offers
* Rename `get_coin_amount` -> `amount_to_select`
* Adjust comment
* No need to create a list first
* Addition logging for datalayer wrt plugins
* some plugin modifications to config and endpoints
* Add entry point and some minor config checking
* Improved config file reading for store_ids
* Changed to upload_bucket and download_url
* Apply suggestions from code review
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* Code review suggestions
* uploaders and downloaders are now URLs and this was missed earlier
* Update pyinstaller.spec to include plugin binary
* updates based on code review
* Update chia/data_layer/s3_plugin_service.py
Co-authored-by: Almog De Paz <almogdepaz@gmail.com>
* minor updates
* Add boto3 to setup for s3 plugin
* Add None check
---------
Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Almog De Paz <almogdepaz@gmail.com>
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
* Drop unused `List[SubEpochSummary]` return
* Drop unused `SubEpochSummary` return
* Raise in `WalletWeightProofHandler.validate_weight_proof`
* Move validation logs
* Set the new weight proof inside `fetch_and_update_weight_proof`
Which was `fetch_and_validate_the_weight_proof` before.
* Drop `WalletWeightProofHandler._weight_proof_tasks`, just await them
Doesn't seem to make a lot sense to have a list of tasks where we always
just add a task, await it and remove it after. This happens in the long
sync so to parent task will cancel the awaited task anyway.
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
remove dead code so the remaining code is more comprehensible
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
Self connection errors don't need to be `ERROR` level in the log nor do
they need to have tracebacks. This will mostly happen when a node is
unaware of one or more of its own public IPs being used by the network.
Could be IPv4 vs. IPv6, or multiple IPs, or just being behind a NAT.
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
```python-traceback
2023-03-22T14:00:46.076 full_node full_node_server : ERROR Exception Trying to connect to a peer (PeerInfo(_ip=IPv4Address('<REDACTED>'), _port=58445)) with the same peer_id: <REDACTED>, exception Stack: Traceback (most recent call last):
File "/home/ubuntu/chia-blockchain/chia/server/server.py", line 525, in start_client
raise RuntimeError(f"Trying to connect to a peer ({target_node}) with the same peer_id: {peer_id}")
RuntimeError: Trying to connect to a peer (PeerInfo(_ip=IPv4Address('<REDACTED>'), _port=58445)) with the same peer_id: <REDACTED>
```
### New Behavior:
`INFO` level logging without a traceback
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
As is this would not close the daemon if a BaseException were raised.
For example `KeyboardInterrupt` or `asyncio.CancelledError` (on 3.8+).
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
Please weigh in on whether this should be applied to the release or
retargeted to main.
The `finally:` clause will already result in `None` being put into the
queue. I expect that the other `None` pushed before the `return` is
unnecessarily doubling this up. I don't know if the double `None` has
any negative effect.
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
Make it so `python -m chia` works. This makes it easier to subprocess
such as `subprocess.run([sys.executable, "-m", "chia"], check=True)`
when we need to.
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
self.new_subslot_end is not currently used. clean up to make code
cleaner
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
Same behavior
### New Behavior:
Same behavior
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
No change in behavior. Code is the same.
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
Refactor function `is_trusted_peer` to a standalone easily testable
function. Leverage the existing `is_localhost` function to extend
coverage to IPv6 local address for the trusted peer check
Added tests for the new standalone function
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
Code cleanup
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
It's unnecessary to have the same create_tandem_xch_tx method in
different wallets.
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
Each wallet its own create_tandem_xch_tx
### New Behavior:
Share the create_tandem_xch_tx in the standard wallet, unless the wallet
needs to override, like CAT wallet.
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
<!-- Merging Requirements:
- Please give your PR a title that is release-note friendly
- In order to be merged, you must add the most appropriate category
Label (Added, Changed, Fixed) to your PR
-->
<!-- Explain why this is an improvement (Does this add missing
functionality, improve performance, or reduce complexity?) -->
### Purpose:
<!-- Does this PR introduce a breaking change? -->
### Current Behavior:
### New Behavior:
<!-- As we aim for complete code coverage, please include details
regarding unit, and regression tests -->
### Testing Notes:
<!-- Attach any visual examples, or supporting evidence (attach any
.gif/video/console output below) -->
* 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
* Move some logs to `DEBUG` for disconnected peers
* Introduce `_add_coin_states` to log and cleanup cache in one place only
* Bail out early for disconnected peers in some places
* Consider renaming from #14460
* Apply `final` decorator to `DataLayerWallet`
* Simplify `DataLayerWallet.create_new_dl_wallet`
* Simplify `DataLayerWallet.create`
* Improve `WalletStateManager.get_dl_wallet`
* More use of `WalletStateManager.get_dl_wallet`
* Only try `get_dl_wallet`
* 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
This is causing trouble around creating transactions and then submitting them as the creation triggers the wallet to consider itself unsynced when creating a new address for change while building a transaction. This creates a race between syncing and the calling code submitting the generated transaction.
Some DNS resolvers (notably 8.8.8.8) have implemented the use of bit 0x20 in
DNS labels to make cache poisoning attacks more difficult.
See https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 for
more details.
Without this patch, resolution though Google public DNS fails:
$ dig dns-introducer.chia.net @8.8.8.8 +short | wc -l
0
Whereas it works as expected on a seeder which already deployed this patch:
$ dig chia.ctrlaltdel.ch @8.8.8.8 +short | wc -l
32
* wallet: Improve coin state retry wait logic and improve retry store test
* Avoid sleeping after uncatched exceptions
* Sleep only at the beginning since we have reduced timeout now in tests
* 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.
* slightly faster nft complex offer tests
* cached bundle, faster offer matching
* nft metadata test fix
* more optimizations
* use get_nft_count method in tests
* use counts in bulk minting, avoid sleep
* flake
* offer cache fix
* forward compat param, max int16
* only parse programs with pairs
* cache offer data on method call, not init
* black
* Rename `new_coin_state` -> `add_coin_states` in `WalletStateManager
* Avoid redundant coin id calculations
* Don't `max`, just use `derivation_index` since its max by the condition
* Just get the children in the begining since we anyway always fetch them
* Don't pre-hint `existing`
* Adjust some logging
* Simplify coinbase/tx_type logic
* Confirm transactions immediately, don't create a list first
* Move transaction confirmation logic
* Combine `TransactionRecord` creation cases since they are equal
* Drop `timestamp`
* Drop redundant parentheses
* Just assign to `change`
* Rename `coin_record_1` -> `coin_record`
* `break` after transaction was confirmed
* Harden `coinbase` condition
* 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()