chia-blockchain 2.5.1rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chia/__init__.py +10 -0
- chia/__main__.py +5 -0
- chia/_tests/README.md +53 -0
- chia/_tests/__init__.py +0 -0
- chia/_tests/blockchain/__init__.py +0 -0
- chia/_tests/blockchain/blockchain_test_utils.py +195 -0
- chia/_tests/blockchain/config.py +4 -0
- chia/_tests/blockchain/test_augmented_chain.py +145 -0
- chia/_tests/blockchain/test_blockchain.py +4202 -0
- chia/_tests/blockchain/test_blockchain_transactions.py +1031 -0
- chia/_tests/blockchain/test_build_chains.py +59 -0
- chia/_tests/blockchain/test_get_block_generator.py +72 -0
- chia/_tests/blockchain/test_lookup_fork_chain.py +194 -0
- chia/_tests/build-init-files.py +92 -0
- chia/_tests/build-job-matrix.py +204 -0
- chia/_tests/check_pytest_monitor_output.py +34 -0
- chia/_tests/check_sql_statements.py +72 -0
- chia/_tests/chia-start-sim +42 -0
- chia/_tests/clvm/__init__.py +0 -0
- chia/_tests/clvm/benchmark_costs.py +23 -0
- chia/_tests/clvm/coin_store.py +149 -0
- chia/_tests/clvm/test_chialisp_deserialization.py +101 -0
- chia/_tests/clvm/test_clvm_step.py +37 -0
- chia/_tests/clvm/test_condition_codes.py +13 -0
- chia/_tests/clvm/test_curry_and_treehash.py +55 -0
- chia/_tests/clvm/test_message_conditions.py +184 -0
- chia/_tests/clvm/test_program.py +150 -0
- chia/_tests/clvm/test_puzzle_compression.py +143 -0
- chia/_tests/clvm/test_puzzle_drivers.py +45 -0
- chia/_tests/clvm/test_puzzles.py +242 -0
- chia/_tests/clvm/test_singletons.py +540 -0
- chia/_tests/clvm/test_spend_sim.py +181 -0
- chia/_tests/cmds/__init__.py +0 -0
- chia/_tests/cmds/cmd_test_utils.py +469 -0
- chia/_tests/cmds/config.py +3 -0
- chia/_tests/cmds/conftest.py +23 -0
- chia/_tests/cmds/test_click_types.py +200 -0
- chia/_tests/cmds/test_cmd_framework.py +620 -0
- chia/_tests/cmds/test_cmds_util.py +97 -0
- chia/_tests/cmds/test_daemon.py +92 -0
- chia/_tests/cmds/test_dev_gh.py +131 -0
- chia/_tests/cmds/test_farm_cmd.py +66 -0
- chia/_tests/cmds/test_show.py +116 -0
- chia/_tests/cmds/test_sim.py +207 -0
- chia/_tests/cmds/test_timelock_args.py +75 -0
- chia/_tests/cmds/test_tx_config_args.py +154 -0
- chia/_tests/cmds/testing_classes.py +59 -0
- chia/_tests/cmds/wallet/__init__.py +0 -0
- chia/_tests/cmds/wallet/test_consts.py +47 -0
- chia/_tests/cmds/wallet/test_dao.py +565 -0
- chia/_tests/cmds/wallet/test_did.py +403 -0
- chia/_tests/cmds/wallet/test_nft.py +471 -0
- chia/_tests/cmds/wallet/test_notifications.py +124 -0
- chia/_tests/cmds/wallet/test_offer.toffer +1 -0
- chia/_tests/cmds/wallet/test_tx_decorators.py +27 -0
- chia/_tests/cmds/wallet/test_vcs.py +400 -0
- chia/_tests/cmds/wallet/test_wallet.py +1125 -0
- chia/_tests/cmds/wallet/test_wallet_check.py +109 -0
- chia/_tests/conftest.py +1419 -0
- chia/_tests/connection_utils.py +125 -0
- chia/_tests/core/__init__.py +0 -0
- chia/_tests/core/cmds/__init__.py +0 -0
- chia/_tests/core/cmds/test_beta.py +382 -0
- chia/_tests/core/cmds/test_keys.py +1734 -0
- chia/_tests/core/cmds/test_wallet.py +126 -0
- chia/_tests/core/config.py +3 -0
- chia/_tests/core/consensus/__init__.py +0 -0
- chia/_tests/core/consensus/test_block_creation.py +54 -0
- chia/_tests/core/consensus/test_pot_iterations.py +117 -0
- chia/_tests/core/custom_types/__init__.py +0 -0
- chia/_tests/core/custom_types/test_coin.py +107 -0
- chia/_tests/core/custom_types/test_proof_of_space.py +144 -0
- chia/_tests/core/custom_types/test_spend_bundle.py +70 -0
- chia/_tests/core/daemon/__init__.py +0 -0
- chia/_tests/core/daemon/config.py +4 -0
- chia/_tests/core/daemon/test_daemon.py +2128 -0
- chia/_tests/core/daemon/test_daemon_register.py +109 -0
- chia/_tests/core/daemon/test_keychain_proxy.py +101 -0
- chia/_tests/core/data_layer/__init__.py +0 -0
- chia/_tests/core/data_layer/config.py +5 -0
- chia/_tests/core/data_layer/conftest.py +106 -0
- chia/_tests/core/data_layer/test_data_cli.py +56 -0
- chia/_tests/core/data_layer/test_data_layer.py +83 -0
- chia/_tests/core/data_layer/test_data_layer_util.py +218 -0
- chia/_tests/core/data_layer/test_data_rpc.py +3847 -0
- chia/_tests/core/data_layer/test_data_store.py +2424 -0
- chia/_tests/core/data_layer/test_data_store_schema.py +381 -0
- chia/_tests/core/data_layer/test_plugin.py +91 -0
- chia/_tests/core/data_layer/util.py +233 -0
- chia/_tests/core/farmer/__init__.py +0 -0
- chia/_tests/core/farmer/config.py +3 -0
- chia/_tests/core/farmer/test_farmer_api.py +103 -0
- chia/_tests/core/full_node/__init__.py +0 -0
- chia/_tests/core/full_node/config.py +4 -0
- chia/_tests/core/full_node/dos/__init__.py +0 -0
- chia/_tests/core/full_node/dos/config.py +3 -0
- chia/_tests/core/full_node/full_sync/__init__.py +0 -0
- chia/_tests/core/full_node/full_sync/config.py +4 -0
- chia/_tests/core/full_node/full_sync/test_full_sync.py +443 -0
- chia/_tests/core/full_node/ram_db.py +27 -0
- chia/_tests/core/full_node/stores/__init__.py +0 -0
- chia/_tests/core/full_node/stores/config.py +4 -0
- chia/_tests/core/full_node/stores/test_block_store.py +590 -0
- chia/_tests/core/full_node/stores/test_coin_store.py +897 -0
- chia/_tests/core/full_node/stores/test_full_node_store.py +1219 -0
- chia/_tests/core/full_node/stores/test_hint_store.py +229 -0
- chia/_tests/core/full_node/stores/test_sync_store.py +135 -0
- chia/_tests/core/full_node/test_address_manager.py +588 -0
- chia/_tests/core/full_node/test_block_height_map.py +556 -0
- chia/_tests/core/full_node/test_conditions.py +556 -0
- chia/_tests/core/full_node/test_full_node.py +2700 -0
- chia/_tests/core/full_node/test_generator_tools.py +82 -0
- chia/_tests/core/full_node/test_hint_management.py +104 -0
- chia/_tests/core/full_node/test_node_load.py +34 -0
- chia/_tests/core/full_node/test_performance.py +179 -0
- chia/_tests/core/full_node/test_subscriptions.py +492 -0
- chia/_tests/core/full_node/test_transactions.py +203 -0
- chia/_tests/core/full_node/test_tx_processing_queue.py +155 -0
- chia/_tests/core/large_block.py +2388 -0
- chia/_tests/core/make_block_generator.py +70 -0
- chia/_tests/core/mempool/__init__.py +0 -0
- chia/_tests/core/mempool/config.py +4 -0
- chia/_tests/core/mempool/test_mempool.py +3255 -0
- chia/_tests/core/mempool/test_mempool_fee_estimator.py +104 -0
- chia/_tests/core/mempool/test_mempool_fee_protocol.py +55 -0
- chia/_tests/core/mempool/test_mempool_item_queries.py +190 -0
- chia/_tests/core/mempool/test_mempool_manager.py +2084 -0
- chia/_tests/core/mempool/test_mempool_performance.py +64 -0
- chia/_tests/core/mempool/test_singleton_fast_forward.py +567 -0
- chia/_tests/core/node_height.py +28 -0
- chia/_tests/core/server/__init__.py +0 -0
- chia/_tests/core/server/config.py +3 -0
- chia/_tests/core/server/flood.py +84 -0
- chia/_tests/core/server/serve.py +135 -0
- chia/_tests/core/server/test_api_protocol.py +21 -0
- chia/_tests/core/server/test_capabilities.py +66 -0
- chia/_tests/core/server/test_dos.py +319 -0
- chia/_tests/core/server/test_event_loop.py +109 -0
- chia/_tests/core/server/test_loop.py +294 -0
- chia/_tests/core/server/test_node_discovery.py +73 -0
- chia/_tests/core/server/test_rate_limits.py +482 -0
- chia/_tests/core/server/test_server.py +226 -0
- chia/_tests/core/server/test_upnp.py +8 -0
- chia/_tests/core/services/__init__.py +0 -0
- chia/_tests/core/services/config.py +3 -0
- chia/_tests/core/services/test_services.py +188 -0
- chia/_tests/core/ssl/__init__.py +0 -0
- chia/_tests/core/ssl/config.py +3 -0
- chia/_tests/core/ssl/test_ssl.py +202 -0
- chia/_tests/core/test_coins.py +33 -0
- chia/_tests/core/test_cost_calculation.py +313 -0
- chia/_tests/core/test_crawler.py +175 -0
- chia/_tests/core/test_crawler_rpc.py +53 -0
- chia/_tests/core/test_daemon_rpc.py +24 -0
- chia/_tests/core/test_db_conversion.py +130 -0
- chia/_tests/core/test_db_validation.py +162 -0
- chia/_tests/core/test_farmer_harvester_rpc.py +505 -0
- chia/_tests/core/test_filter.py +35 -0
- chia/_tests/core/test_full_node_rpc.py +768 -0
- chia/_tests/core/test_merkle_set.py +343 -0
- chia/_tests/core/test_program.py +47 -0
- chia/_tests/core/test_rpc_util.py +86 -0
- chia/_tests/core/test_seeder.py +420 -0
- chia/_tests/core/test_setproctitle.py +13 -0
- chia/_tests/core/util/__init__.py +0 -0
- chia/_tests/core/util/config.py +4 -0
- chia/_tests/core/util/test_block_cache.py +44 -0
- chia/_tests/core/util/test_cached_bls.py +57 -0
- chia/_tests/core/util/test_config.py +337 -0
- chia/_tests/core/util/test_file_keyring_synchronization.py +105 -0
- chia/_tests/core/util/test_files.py +391 -0
- chia/_tests/core/util/test_jsonify.py +146 -0
- chia/_tests/core/util/test_keychain.py +522 -0
- chia/_tests/core/util/test_keyring_wrapper.py +491 -0
- chia/_tests/core/util/test_lockfile.py +380 -0
- chia/_tests/core/util/test_log_exceptions.py +187 -0
- chia/_tests/core/util/test_lru_cache.py +56 -0
- chia/_tests/core/util/test_significant_bits.py +40 -0
- chia/_tests/core/util/test_streamable.py +883 -0
- chia/_tests/db/__init__.py +0 -0
- chia/_tests/db/test_db_wrapper.py +566 -0
- chia/_tests/environments/__init__.py +0 -0
- chia/_tests/environments/common.py +35 -0
- chia/_tests/environments/full_node.py +47 -0
- chia/_tests/environments/wallet.py +429 -0
- chia/_tests/ether.py +19 -0
- chia/_tests/farmer_harvester/__init__.py +0 -0
- chia/_tests/farmer_harvester/config.py +3 -0
- chia/_tests/farmer_harvester/test_farmer.py +1264 -0
- chia/_tests/farmer_harvester/test_farmer_harvester.py +292 -0
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +131 -0
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +528 -0
- chia/_tests/farmer_harvester/test_third_party_harvesters_data.json +29 -0
- chia/_tests/fee_estimation/__init__.py +0 -0
- chia/_tests/fee_estimation/config.py +3 -0
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +262 -0
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +287 -0
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +144 -0
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +146 -0
- chia/_tests/generator/__init__.py +0 -0
- chia/_tests/generator/puzzles/__init__.py +0 -0
- chia/_tests/generator/puzzles/test_generator_deserialize.clsp +3 -0
- chia/_tests/generator/puzzles/test_generator_deserialize.clsp.hex +1 -0
- chia/_tests/generator/puzzles/test_multiple_generator_input_arguments.clsp +19 -0
- chia/_tests/generator/puzzles/test_multiple_generator_input_arguments.clsp.hex +1 -0
- chia/_tests/generator/test_compression.py +201 -0
- chia/_tests/generator/test_generator_types.py +44 -0
- chia/_tests/generator/test_rom.py +180 -0
- chia/_tests/plot_sync/__init__.py +0 -0
- chia/_tests/plot_sync/config.py +3 -0
- chia/_tests/plot_sync/test_delta.py +101 -0
- chia/_tests/plot_sync/test_plot_sync.py +618 -0
- chia/_tests/plot_sync/test_receiver.py +451 -0
- chia/_tests/plot_sync/test_sender.py +116 -0
- chia/_tests/plot_sync/test_sync_simulated.py +451 -0
- chia/_tests/plot_sync/util.py +68 -0
- chia/_tests/plotting/__init__.py +0 -0
- chia/_tests/plotting/config.py +3 -0
- chia/_tests/plotting/test_plot_manager.py +781 -0
- chia/_tests/plotting/util.py +12 -0
- chia/_tests/pools/__init__.py +0 -0
- chia/_tests/pools/config.py +5 -0
- chia/_tests/pools/test_pool_cli_parsing.py +128 -0
- chia/_tests/pools/test_pool_cmdline.py +1001 -0
- chia/_tests/pools/test_pool_config.py +42 -0
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +397 -0
- chia/_tests/pools/test_pool_rpc.py +1123 -0
- chia/_tests/pools/test_pool_wallet.py +205 -0
- chia/_tests/pools/test_wallet_pool_store.py +161 -0
- chia/_tests/process_junit.py +348 -0
- chia/_tests/rpc/__init__.py +0 -0
- chia/_tests/rpc/test_rpc_client.py +138 -0
- chia/_tests/rpc/test_rpc_server.py +183 -0
- chia/_tests/simulation/__init__.py +0 -0
- chia/_tests/simulation/config.py +6 -0
- chia/_tests/simulation/test_simulation.py +501 -0
- chia/_tests/simulation/test_simulator.py +232 -0
- chia/_tests/simulation/test_start_simulator.py +107 -0
- chia/_tests/testconfig.py +13 -0
- chia/_tests/timelord/__init__.py +0 -0
- chia/_tests/timelord/config.py +3 -0
- chia/_tests/timelord/test_new_peak.py +437 -0
- chia/_tests/timelord/test_timelord.py +11 -0
- chia/_tests/tools/1315537.json +170 -0
- chia/_tests/tools/1315544.json +160 -0
- chia/_tests/tools/1315630.json +150 -0
- chia/_tests/tools/300000.json +105 -0
- chia/_tests/tools/442734.json +140 -0
- chia/_tests/tools/466212.json +130 -0
- chia/_tests/tools/__init__.py +0 -0
- chia/_tests/tools/config.py +5 -0
- chia/_tests/tools/test-blockchain-db.sqlite +0 -0
- chia/_tests/tools/test_full_sync.py +30 -0
- chia/_tests/tools/test_legacy_keyring.py +82 -0
- chia/_tests/tools/test_run_block.py +128 -0
- chia/_tests/tools/test_virtual_project.py +591 -0
- chia/_tests/util/__init__.py +0 -0
- chia/_tests/util/benchmark_cost.py +170 -0
- chia/_tests/util/benchmarks.py +153 -0
- chia/_tests/util/bip39_test_vectors.json +148 -0
- chia/_tests/util/blockchain.py +134 -0
- chia/_tests/util/blockchain_mock.py +132 -0
- chia/_tests/util/build_network_protocol_files.py +302 -0
- chia/_tests/util/clvm_generator.bin +0 -0
- chia/_tests/util/config.py +3 -0
- chia/_tests/util/constants.py +20 -0
- chia/_tests/util/db_connection.py +37 -0
- chia/_tests/util/full_sync.py +253 -0
- chia/_tests/util/gen_ssl_certs.py +114 -0
- chia/_tests/util/generator_tools_testing.py +45 -0
- chia/_tests/util/get_name_puzzle_conditions.py +52 -0
- chia/_tests/util/key_tool.py +36 -0
- chia/_tests/util/misc.py +675 -0
- chia/_tests/util/network_protocol_data.py +1072 -0
- chia/_tests/util/protocol_messages_bytes-v1.0 +0 -0
- chia/_tests/util/protocol_messages_json.py +2701 -0
- chia/_tests/util/rpc.py +26 -0
- chia/_tests/util/run_block.py +163 -0
- chia/_tests/util/setup_nodes.py +481 -0
- chia/_tests/util/spend_sim.py +492 -0
- chia/_tests/util/split_managers.py +102 -0
- chia/_tests/util/temp_file.py +14 -0
- chia/_tests/util/test_action_scope.py +144 -0
- chia/_tests/util/test_async_pool.py +366 -0
- chia/_tests/util/test_build_job_matrix.py +42 -0
- chia/_tests/util/test_build_network_protocol_files.py +7 -0
- chia/_tests/util/test_chia_version.py +50 -0
- chia/_tests/util/test_collection.py +11 -0
- chia/_tests/util/test_condition_tools.py +229 -0
- chia/_tests/util/test_config.py +426 -0
- chia/_tests/util/test_dump_keyring.py +60 -0
- chia/_tests/util/test_errors.py +10 -0
- chia/_tests/util/test_full_block_utils.py +279 -0
- chia/_tests/util/test_installed.py +20 -0
- chia/_tests/util/test_limited_semaphore.py +53 -0
- chia/_tests/util/test_logging_filter.py +42 -0
- chia/_tests/util/test_misc.py +445 -0
- chia/_tests/util/test_network.py +73 -0
- chia/_tests/util/test_network_protocol_files.py +578 -0
- chia/_tests/util/test_network_protocol_json.py +267 -0
- chia/_tests/util/test_network_protocol_test.py +256 -0
- chia/_tests/util/test_paginator.py +71 -0
- chia/_tests/util/test_pprint.py +17 -0
- chia/_tests/util/test_priority_mutex.py +488 -0
- chia/_tests/util/test_recursive_replace.py +116 -0
- chia/_tests/util/test_replace_str_to_bytes.py +137 -0
- chia/_tests/util/test_service_groups.py +15 -0
- chia/_tests/util/test_ssl_check.py +31 -0
- chia/_tests/util/test_testnet_overrides.py +19 -0
- chia/_tests/util/test_tests_misc.py +38 -0
- chia/_tests/util/test_timing.py +37 -0
- chia/_tests/util/test_trusted_peer.py +51 -0
- chia/_tests/util/time_out_assert.py +191 -0
- chia/_tests/wallet/__init__.py +0 -0
- chia/_tests/wallet/cat_wallet/__init__.py +0 -0
- chia/_tests/wallet/cat_wallet/config.py +4 -0
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +468 -0
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +69 -0
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +1826 -0
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +291 -0
- chia/_tests/wallet/cat_wallet/test_trades.py +2600 -0
- chia/_tests/wallet/clawback/__init__.py +0 -0
- chia/_tests/wallet/clawback/config.py +3 -0
- chia/_tests/wallet/clawback/test_clawback_decorator.py +78 -0
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +292 -0
- chia/_tests/wallet/clawback/test_clawback_metadata.py +50 -0
- chia/_tests/wallet/config.py +4 -0
- chia/_tests/wallet/conftest.py +278 -0
- chia/_tests/wallet/dao_wallet/__init__.py +0 -0
- chia/_tests/wallet/dao_wallet/config.py +3 -0
- chia/_tests/wallet/dao_wallet/test_dao_clvm.py +1330 -0
- chia/_tests/wallet/dao_wallet/test_dao_wallets.py +3488 -0
- chia/_tests/wallet/db_wallet/__init__.py +0 -0
- chia/_tests/wallet/db_wallet/config.py +3 -0
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +141 -0
- chia/_tests/wallet/db_wallet/test_dl_offers.py +491 -0
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +823 -0
- chia/_tests/wallet/did_wallet/__init__.py +0 -0
- chia/_tests/wallet/did_wallet/config.py +4 -0
- chia/_tests/wallet/did_wallet/test_did.py +2284 -0
- chia/_tests/wallet/nft_wallet/__init__.py +0 -0
- chia/_tests/wallet/nft_wallet/config.py +4 -0
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +1493 -0
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +1024 -0
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +375 -0
- chia/_tests/wallet/nft_wallet/test_nft_offers.py +1209 -0
- chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +172 -0
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +2584 -0
- chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +70 -0
- chia/_tests/wallet/rpc/__init__.py +0 -0
- chia/_tests/wallet/rpc/config.py +4 -0
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +285 -0
- chia/_tests/wallet/rpc/test_wallet_rpc.py +3153 -0
- chia/_tests/wallet/simple_sync/__init__.py +0 -0
- chia/_tests/wallet/simple_sync/config.py +3 -0
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +718 -0
- chia/_tests/wallet/sync/__init__.py +0 -0
- chia/_tests/wallet/sync/config.py +4 -0
- chia/_tests/wallet/sync/test_wallet_sync.py +1692 -0
- chia/_tests/wallet/test_address_type.py +189 -0
- chia/_tests/wallet/test_bech32m.py +45 -0
- chia/_tests/wallet/test_clvm_streamable.py +244 -0
- chia/_tests/wallet/test_coin_management.py +354 -0
- chia/_tests/wallet/test_coin_selection.py +588 -0
- chia/_tests/wallet/test_conditions.py +400 -0
- chia/_tests/wallet/test_debug_spend_bundle.py +218 -0
- chia/_tests/wallet/test_new_wallet_protocol.py +1174 -0
- chia/_tests/wallet/test_nft_store.py +192 -0
- chia/_tests/wallet/test_notifications.py +196 -0
- chia/_tests/wallet/test_offer_parsing_performance.py +48 -0
- chia/_tests/wallet/test_puzzle_store.py +132 -0
- chia/_tests/wallet/test_sign_coin_spends.py +159 -0
- chia/_tests/wallet/test_signer_protocol.py +947 -0
- chia/_tests/wallet/test_singleton.py +122 -0
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +772 -0
- chia/_tests/wallet/test_singleton_store.py +152 -0
- chia/_tests/wallet/test_taproot.py +19 -0
- chia/_tests/wallet/test_transaction_store.py +945 -0
- chia/_tests/wallet/test_util.py +185 -0
- chia/_tests/wallet/test_wallet.py +2139 -0
- chia/_tests/wallet/test_wallet_action_scope.py +85 -0
- chia/_tests/wallet/test_wallet_blockchain.py +111 -0
- chia/_tests/wallet/test_wallet_coin_store.py +1002 -0
- chia/_tests/wallet/test_wallet_interested_store.py +43 -0
- chia/_tests/wallet/test_wallet_key_val_store.py +40 -0
- chia/_tests/wallet/test_wallet_node.py +780 -0
- chia/_tests/wallet/test_wallet_retry.py +95 -0
- chia/_tests/wallet/test_wallet_state_manager.py +259 -0
- chia/_tests/wallet/test_wallet_test_framework.py +275 -0
- chia/_tests/wallet/test_wallet_trade_store.py +218 -0
- chia/_tests/wallet/test_wallet_user_store.py +34 -0
- chia/_tests/wallet/test_wallet_utils.py +156 -0
- chia/_tests/wallet/vc_wallet/__init__.py +0 -0
- chia/_tests/wallet/vc_wallet/config.py +3 -0
- chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +70 -0
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +883 -0
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +830 -0
- chia/_tests/wallet/wallet_block_tools.py +327 -0
- chia/_tests/weight_proof/__init__.py +0 -0
- chia/_tests/weight_proof/config.py +3 -0
- chia/_tests/weight_proof/test_weight_proof.py +528 -0
- chia/apis.py +19 -0
- chia/clvm/__init__.py +0 -0
- chia/cmds/__init__.py +0 -0
- chia/cmds/beta.py +184 -0
- chia/cmds/beta_funcs.py +137 -0
- chia/cmds/check_wallet_db.py +420 -0
- chia/cmds/chia.py +151 -0
- chia/cmds/cmd_classes.py +323 -0
- chia/cmds/cmd_helpers.py +242 -0
- chia/cmds/cmds_util.py +488 -0
- chia/cmds/coin_funcs.py +275 -0
- chia/cmds/coins.py +182 -0
- chia/cmds/completion.py +49 -0
- chia/cmds/configure.py +332 -0
- chia/cmds/dao.py +1064 -0
- chia/cmds/dao_funcs.py +598 -0
- chia/cmds/data.py +708 -0
- chia/cmds/data_funcs.py +385 -0
- chia/cmds/db.py +87 -0
- chia/cmds/db_backup_func.py +77 -0
- chia/cmds/db_upgrade_func.py +452 -0
- chia/cmds/db_validate_func.py +184 -0
- chia/cmds/dev.py +18 -0
- chia/cmds/farm.py +100 -0
- chia/cmds/farm_funcs.py +200 -0
- chia/cmds/gh.py +275 -0
- chia/cmds/init.py +63 -0
- chia/cmds/init_funcs.py +367 -0
- chia/cmds/installers.py +131 -0
- chia/cmds/keys.py +527 -0
- chia/cmds/keys_funcs.py +863 -0
- chia/cmds/netspace.py +50 -0
- chia/cmds/netspace_funcs.py +54 -0
- chia/cmds/options.py +32 -0
- chia/cmds/param_types.py +238 -0
- chia/cmds/passphrase.py +131 -0
- chia/cmds/passphrase_funcs.py +292 -0
- chia/cmds/peer.py +51 -0
- chia/cmds/peer_funcs.py +129 -0
- chia/cmds/plotnft.py +260 -0
- chia/cmds/plotnft_funcs.py +405 -0
- chia/cmds/plots.py +230 -0
- chia/cmds/plotters.py +18 -0
- chia/cmds/rpc.py +208 -0
- chia/cmds/show.py +72 -0
- chia/cmds/show_funcs.py +215 -0
- chia/cmds/signer.py +296 -0
- chia/cmds/sim.py +225 -0
- chia/cmds/sim_funcs.py +509 -0
- chia/cmds/start.py +24 -0
- chia/cmds/start_funcs.py +109 -0
- chia/cmds/stop.py +62 -0
- chia/cmds/units.py +9 -0
- chia/cmds/wallet.py +1901 -0
- chia/cmds/wallet_funcs.py +1874 -0
- chia/consensus/__init__.py +0 -0
- chia/consensus/block_body_validation.py +562 -0
- chia/consensus/block_creation.py +546 -0
- chia/consensus/block_header_validation.py +1059 -0
- chia/consensus/block_record.py +31 -0
- chia/consensus/block_rewards.py +53 -0
- chia/consensus/blockchain.py +1087 -0
- chia/consensus/blockchain_interface.py +56 -0
- chia/consensus/coinbase.py +30 -0
- chia/consensus/condition_costs.py +9 -0
- chia/consensus/constants.py +49 -0
- chia/consensus/cost_calculator.py +15 -0
- chia/consensus/default_constants.py +89 -0
- chia/consensus/deficit.py +55 -0
- chia/consensus/difficulty_adjustment.py +412 -0
- chia/consensus/find_fork_point.py +111 -0
- chia/consensus/full_block_to_block_record.py +167 -0
- chia/consensus/get_block_challenge.py +106 -0
- chia/consensus/get_block_generator.py +27 -0
- chia/consensus/make_sub_epoch_summary.py +210 -0
- chia/consensus/multiprocess_validation.py +268 -0
- chia/consensus/pos_quality.py +19 -0
- chia/consensus/pot_iterations.py +67 -0
- chia/consensus/puzzles/__init__.py +0 -0
- chia/consensus/puzzles/chialisp_deserialisation.clsp +69 -0
- chia/consensus/puzzles/chialisp_deserialisation.clsp.hex +1 -0
- chia/consensus/puzzles/rom_bootstrap_generator.clsp +37 -0
- chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex +1 -0
- chia/consensus/vdf_info_computation.py +156 -0
- chia/daemon/__init__.py +0 -0
- chia/daemon/client.py +252 -0
- chia/daemon/keychain_proxy.py +502 -0
- chia/daemon/keychain_server.py +365 -0
- chia/daemon/server.py +1606 -0
- chia/daemon/windows_signal.py +56 -0
- chia/data_layer/__init__.py +0 -0
- chia/data_layer/data_layer.py +1291 -0
- chia/data_layer/data_layer_api.py +33 -0
- chia/data_layer/data_layer_errors.py +50 -0
- chia/data_layer/data_layer_server.py +170 -0
- chia/data_layer/data_layer_util.py +985 -0
- chia/data_layer/data_layer_wallet.py +1311 -0
- chia/data_layer/data_store.py +2267 -0
- chia/data_layer/dl_wallet_store.py +407 -0
- chia/data_layer/download_data.py +389 -0
- chia/data_layer/puzzles/__init__.py +0 -0
- chia/data_layer/puzzles/graftroot_dl_offers.clsp +100 -0
- chia/data_layer/puzzles/graftroot_dl_offers.clsp.hex +1 -0
- chia/data_layer/s3_plugin_config.yml +33 -0
- chia/data_layer/s3_plugin_service.py +468 -0
- chia/data_layer/util/__init__.py +0 -0
- chia/data_layer/util/benchmark.py +107 -0
- chia/data_layer/util/plugin.py +40 -0
- chia/farmer/__init__.py +0 -0
- chia/farmer/farmer.py +923 -0
- chia/farmer/farmer_api.py +820 -0
- chia/full_node/__init__.py +0 -0
- chia/full_node/bitcoin_fee_estimator.py +85 -0
- chia/full_node/block_height_map.py +271 -0
- chia/full_node/block_store.py +576 -0
- chia/full_node/bundle_tools.py +19 -0
- chia/full_node/coin_store.py +647 -0
- chia/full_node/fee_estimate.py +54 -0
- chia/full_node/fee_estimate_store.py +24 -0
- chia/full_node/fee_estimation.py +92 -0
- chia/full_node/fee_estimator.py +90 -0
- chia/full_node/fee_estimator_constants.py +38 -0
- chia/full_node/fee_estimator_interface.py +42 -0
- chia/full_node/fee_history.py +25 -0
- chia/full_node/fee_tracker.py +564 -0
- chia/full_node/full_node.py +3327 -0
- chia/full_node/full_node_api.py +2025 -0
- chia/full_node/full_node_store.py +1033 -0
- chia/full_node/hint_management.py +56 -0
- chia/full_node/hint_store.py +93 -0
- chia/full_node/mempool.py +589 -0
- chia/full_node/mempool_check_conditions.py +146 -0
- chia/full_node/mempool_manager.py +853 -0
- chia/full_node/pending_tx_cache.py +112 -0
- chia/full_node/puzzles/__init__.py +0 -0
- chia/full_node/puzzles/block_program_zero.clsp +14 -0
- chia/full_node/puzzles/block_program_zero.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp +5 -0
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp +7 -0
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_puzzle.clsp +6 -0
- chia/full_node/puzzles/decompress_puzzle.clsp.hex +1 -0
- chia/full_node/signage_point.py +16 -0
- chia/full_node/subscriptions.py +247 -0
- chia/full_node/sync_store.py +146 -0
- chia/full_node/tx_processing_queue.py +78 -0
- chia/full_node/util/__init__.py +0 -0
- chia/full_node/weight_proof.py +1720 -0
- chia/harvester/__init__.py +0 -0
- chia/harvester/harvester.py +272 -0
- chia/harvester/harvester_api.py +380 -0
- chia/introducer/__init__.py +0 -0
- chia/introducer/introducer.py +122 -0
- chia/introducer/introducer_api.py +70 -0
- chia/legacy/__init__.py +0 -0
- chia/legacy/keyring.py +155 -0
- chia/plot_sync/__init__.py +0 -0
- chia/plot_sync/delta.py +61 -0
- chia/plot_sync/exceptions.py +56 -0
- chia/plot_sync/receiver.py +386 -0
- chia/plot_sync/sender.py +340 -0
- chia/plot_sync/util.py +43 -0
- chia/plotters/__init__.py +0 -0
- chia/plotters/bladebit.py +388 -0
- chia/plotters/chiapos.py +63 -0
- chia/plotters/madmax.py +224 -0
- chia/plotters/plotters.py +577 -0
- chia/plotters/plotters_util.py +133 -0
- chia/plotting/__init__.py +0 -0
- chia/plotting/cache.py +213 -0
- chia/plotting/check_plots.py +283 -0
- chia/plotting/create_plots.py +278 -0
- chia/plotting/manager.py +436 -0
- chia/plotting/util.py +336 -0
- chia/pools/__init__.py +0 -0
- chia/pools/pool_config.py +110 -0
- chia/pools/pool_puzzles.py +459 -0
- chia/pools/pool_wallet.py +933 -0
- chia/pools/pool_wallet_info.py +118 -0
- chia/pools/puzzles/__init__.py +0 -0
- chia/pools/puzzles/pool_member_innerpuz.clsp +70 -0
- chia/pools/puzzles/pool_member_innerpuz.clsp.hex +1 -0
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp +69 -0
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex +1 -0
- chia/protocols/__init__.py +0 -0
- chia/protocols/farmer_protocol.py +102 -0
- chia/protocols/full_node_protocol.py +219 -0
- chia/protocols/harvester_protocol.py +216 -0
- chia/protocols/introducer_protocol.py +25 -0
- chia/protocols/pool_protocol.py +177 -0
- chia/protocols/protocol_message_types.py +139 -0
- chia/protocols/protocol_state_machine.py +87 -0
- chia/protocols/protocol_timing.py +8 -0
- chia/protocols/shared_protocol.py +86 -0
- chia/protocols/timelord_protocol.py +93 -0
- chia/protocols/wallet_protocol.py +401 -0
- chia/py.typed +0 -0
- chia/rpc/__init__.py +0 -0
- chia/rpc/crawler_rpc_api.py +80 -0
- chia/rpc/data_layer_rpc_api.py +644 -0
- chia/rpc/data_layer_rpc_client.py +188 -0
- chia/rpc/data_layer_rpc_util.py +58 -0
- chia/rpc/farmer_rpc_api.py +365 -0
- chia/rpc/farmer_rpc_client.py +86 -0
- chia/rpc/full_node_rpc_api.py +959 -0
- chia/rpc/full_node_rpc_client.py +292 -0
- chia/rpc/harvester_rpc_api.py +141 -0
- chia/rpc/harvester_rpc_client.py +54 -0
- chia/rpc/rpc_client.py +164 -0
- chia/rpc/rpc_server.py +521 -0
- chia/rpc/timelord_rpc_api.py +32 -0
- chia/rpc/util.py +93 -0
- chia/rpc/wallet_request_types.py +904 -0
- chia/rpc/wallet_rpc_api.py +4943 -0
- chia/rpc/wallet_rpc_client.py +1814 -0
- chia/seeder/__init__.py +0 -0
- chia/seeder/crawl_store.py +425 -0
- chia/seeder/crawler.py +410 -0
- chia/seeder/crawler_api.py +135 -0
- chia/seeder/dns_server.py +593 -0
- chia/seeder/peer_record.py +146 -0
- chia/seeder/start_crawler.py +92 -0
- chia/server/__init__.py +0 -0
- chia/server/address_manager.py +658 -0
- chia/server/address_manager_store.py +237 -0
- chia/server/api_protocol.py +116 -0
- chia/server/capabilities.py +24 -0
- chia/server/chia_policy.py +346 -0
- chia/server/introducer_peers.py +76 -0
- chia/server/node_discovery.py +714 -0
- chia/server/outbound_message.py +33 -0
- chia/server/rate_limit_numbers.py +214 -0
- chia/server/rate_limits.py +153 -0
- chia/server/server.py +741 -0
- chia/server/signal_handlers.py +120 -0
- chia/server/ssl_context.py +32 -0
- chia/server/start_data_layer.py +151 -0
- chia/server/start_farmer.py +98 -0
- chia/server/start_full_node.py +112 -0
- chia/server/start_harvester.py +93 -0
- chia/server/start_introducer.py +81 -0
- chia/server/start_service.py +316 -0
- chia/server/start_timelord.py +89 -0
- chia/server/start_wallet.py +113 -0
- chia/server/upnp.py +118 -0
- chia/server/ws_connection.py +766 -0
- chia/simulator/__init__.py +0 -0
- chia/simulator/add_blocks_in_batches.py +54 -0
- chia/simulator/block_tools.py +2054 -0
- chia/simulator/full_node_simulator.py +794 -0
- chia/simulator/keyring.py +128 -0
- chia/simulator/setup_services.py +506 -0
- chia/simulator/simulator_constants.py +13 -0
- chia/simulator/simulator_full_node_rpc_api.py +99 -0
- chia/simulator/simulator_full_node_rpc_client.py +60 -0
- chia/simulator/simulator_protocol.py +29 -0
- chia/simulator/simulator_test_tools.py +164 -0
- chia/simulator/socket.py +24 -0
- chia/simulator/ssl_certs.py +114 -0
- chia/simulator/ssl_certs_1.py +697 -0
- chia/simulator/ssl_certs_10.py +697 -0
- chia/simulator/ssl_certs_2.py +697 -0
- chia/simulator/ssl_certs_3.py +697 -0
- chia/simulator/ssl_certs_4.py +697 -0
- chia/simulator/ssl_certs_5.py +697 -0
- chia/simulator/ssl_certs_6.py +697 -0
- chia/simulator/ssl_certs_7.py +697 -0
- chia/simulator/ssl_certs_8.py +697 -0
- chia/simulator/ssl_certs_9.py +697 -0
- chia/simulator/start_simulator.py +143 -0
- chia/simulator/wallet_tools.py +246 -0
- chia/ssl/__init__.py +0 -0
- chia/ssl/chia_ca.crt +19 -0
- chia/ssl/chia_ca.key +28 -0
- chia/ssl/create_ssl.py +249 -0
- chia/ssl/dst_root_ca.pem +20 -0
- chia/timelord/__init__.py +0 -0
- chia/timelord/iters_from_block.py +50 -0
- chia/timelord/timelord.py +1226 -0
- chia/timelord/timelord_api.py +138 -0
- chia/timelord/timelord_launcher.py +190 -0
- chia/timelord/timelord_state.py +244 -0
- chia/timelord/types.py +22 -0
- chia/types/__init__.py +0 -0
- chia/types/aliases.py +35 -0
- chia/types/block_protocol.py +20 -0
- chia/types/blockchain_format/__init__.py +0 -0
- chia/types/blockchain_format/classgroup.py +5 -0
- chia/types/blockchain_format/coin.py +28 -0
- chia/types/blockchain_format/foliage.py +8 -0
- chia/types/blockchain_format/pool_target.py +5 -0
- chia/types/blockchain_format/program.py +269 -0
- chia/types/blockchain_format/proof_of_space.py +135 -0
- chia/types/blockchain_format/reward_chain_block.py +6 -0
- chia/types/blockchain_format/serialized_program.py +5 -0
- chia/types/blockchain_format/sized_bytes.py +11 -0
- chia/types/blockchain_format/slots.py +9 -0
- chia/types/blockchain_format/sub_epoch_summary.py +5 -0
- chia/types/blockchain_format/tree_hash.py +72 -0
- chia/types/blockchain_format/vdf.py +86 -0
- chia/types/clvm_cost.py +13 -0
- chia/types/coin_record.py +43 -0
- chia/types/coin_spend.py +115 -0
- chia/types/condition_opcodes.py +73 -0
- chia/types/condition_with_args.py +16 -0
- chia/types/eligible_coin_spends.py +365 -0
- chia/types/end_of_slot_bundle.py +5 -0
- chia/types/fee_rate.py +38 -0
- chia/types/full_block.py +5 -0
- chia/types/generator_types.py +13 -0
- chia/types/header_block.py +5 -0
- chia/types/internal_mempool_item.py +18 -0
- chia/types/mempool_inclusion_status.py +9 -0
- chia/types/mempool_item.py +85 -0
- chia/types/mempool_submission_status.py +30 -0
- chia/types/mojos.py +7 -0
- chia/types/peer_info.py +64 -0
- chia/types/signing_mode.py +29 -0
- chia/types/spend_bundle.py +30 -0
- chia/types/spend_bundle_conditions.py +7 -0
- chia/types/transaction_queue_entry.py +55 -0
- chia/types/unfinished_block.py +5 -0
- chia/types/unfinished_header_block.py +37 -0
- chia/types/validation_state.py +14 -0
- chia/types/weight_proof.py +49 -0
- chia/util/__init__.py +0 -0
- chia/util/action_scope.py +168 -0
- chia/util/async_pool.py +226 -0
- chia/util/augmented_chain.py +134 -0
- chia/util/batches.py +42 -0
- chia/util/bech32m.py +126 -0
- chia/util/beta_metrics.py +119 -0
- chia/util/block_cache.py +56 -0
- chia/util/byte_types.py +12 -0
- chia/util/check_fork_next_block.py +33 -0
- chia/util/chia_logging.py +144 -0
- chia/util/chia_version.py +33 -0
- chia/util/collection.py +17 -0
- chia/util/condition_tools.py +201 -0
- chia/util/config.py +367 -0
- chia/util/cpu.py +22 -0
- chia/util/db_synchronous.py +23 -0
- chia/util/db_version.py +32 -0
- chia/util/db_wrapper.py +430 -0
- chia/util/default_root.py +27 -0
- chia/util/dump_keyring.py +93 -0
- chia/util/english.txt +2048 -0
- chia/util/errors.py +353 -0
- chia/util/file_keyring.py +469 -0
- chia/util/files.py +97 -0
- chia/util/full_block_utils.py +345 -0
- chia/util/generator_tools.py +72 -0
- chia/util/hash.py +31 -0
- chia/util/initial-config.yaml +694 -0
- chia/util/inline_executor.py +26 -0
- chia/util/ints.py +19 -0
- chia/util/ip_address.py +39 -0
- chia/util/json_util.py +37 -0
- chia/util/keychain.py +676 -0
- chia/util/keyring_wrapper.py +327 -0
- chia/util/limited_semaphore.py +41 -0
- chia/util/lock.py +49 -0
- chia/util/log_exceptions.py +32 -0
- chia/util/logging.py +36 -0
- chia/util/lru_cache.py +31 -0
- chia/util/math.py +20 -0
- chia/util/network.py +182 -0
- chia/util/paginator.py +48 -0
- chia/util/path.py +31 -0
- chia/util/permissions.py +20 -0
- chia/util/prev_transaction_block.py +21 -0
- chia/util/priority_mutex.py +95 -0
- chia/util/profiler.py +197 -0
- chia/util/recursive_replace.py +24 -0
- chia/util/safe_cancel_task.py +16 -0
- chia/util/service_groups.py +47 -0
- chia/util/setproctitle.py +22 -0
- chia/util/significant_bits.py +32 -0
- chia/util/ssl_check.py +213 -0
- chia/util/streamable.py +642 -0
- chia/util/task_referencer.py +59 -0
- chia/util/task_timing.py +382 -0
- chia/util/timing.py +67 -0
- chia/util/vdf_prover.py +30 -0
- chia/util/virtual_project_analysis.py +540 -0
- chia/util/ws_message.py +66 -0
- chia/wallet/__init__.py +0 -0
- chia/wallet/cat_wallet/__init__.py +0 -0
- chia/wallet/cat_wallet/cat_constants.py +75 -0
- chia/wallet/cat_wallet/cat_info.py +47 -0
- chia/wallet/cat_wallet/cat_outer_puzzle.py +120 -0
- chia/wallet/cat_wallet/cat_utils.py +164 -0
- chia/wallet/cat_wallet/cat_wallet.py +855 -0
- chia/wallet/cat_wallet/dao_cat_info.py +28 -0
- chia/wallet/cat_wallet/dao_cat_wallet.py +669 -0
- chia/wallet/cat_wallet/lineage_store.py +74 -0
- chia/wallet/cat_wallet/puzzles/__init__.py +0 -0
- chia/wallet/cat_wallet/puzzles/cat_truths.clib +31 -0
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp +397 -0
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp +25 -0
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp +15 -0
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp +26 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp +42 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp +24 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex +1 -0
- chia/wallet/coin_selection.py +188 -0
- chia/wallet/conditions.py +1512 -0
- chia/wallet/dao_wallet/__init__.py +0 -0
- chia/wallet/dao_wallet/dao_info.py +61 -0
- chia/wallet/dao_wallet/dao_utils.py +811 -0
- chia/wallet/dao_wallet/dao_wallet.py +2119 -0
- chia/wallet/db_wallet/__init__.py +0 -0
- chia/wallet/db_wallet/db_wallet_puzzles.py +111 -0
- chia/wallet/derivation_record.py +30 -0
- chia/wallet/derive_keys.py +146 -0
- chia/wallet/did_wallet/__init__.py +0 -0
- chia/wallet/did_wallet/did_info.py +39 -0
- chia/wallet/did_wallet/did_wallet.py +1494 -0
- chia/wallet/did_wallet/did_wallet_puzzles.py +221 -0
- chia/wallet/did_wallet/puzzles/__init__.py +0 -0
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp +135 -0
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex +1 -0
- chia/wallet/driver_protocol.py +26 -0
- chia/wallet/key_val_store.py +55 -0
- chia/wallet/lineage_proof.py +58 -0
- chia/wallet/nft_wallet/__init__.py +0 -0
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +92 -0
- chia/wallet/nft_wallet/nft_info.py +120 -0
- chia/wallet/nft_wallet/nft_puzzles.py +305 -0
- chia/wallet/nft_wallet/nft_wallet.py +1687 -0
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +101 -0
- chia/wallet/nft_wallet/puzzles/__init__.py +0 -0
- chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp +6 -0
- chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp +6 -0
- chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp +30 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp +28 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp +100 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp +78 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp +74 -0
- chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp.hex +1 -0
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +101 -0
- chia/wallet/nft_wallet/transfer_program_puzzle.py +82 -0
- chia/wallet/nft_wallet/uncurry_nft.py +217 -0
- chia/wallet/notification_manager.py +117 -0
- chia/wallet/notification_store.py +178 -0
- chia/wallet/outer_puzzles.py +84 -0
- chia/wallet/payment.py +33 -0
- chia/wallet/puzzle_drivers.py +118 -0
- chia/wallet/puzzles/__init__.py +0 -0
- chia/wallet/puzzles/augmented_condition.clsp +13 -0
- chia/wallet/puzzles/augmented_condition.clsp.hex +1 -0
- chia/wallet/puzzles/clawback/__init__.py +0 -0
- chia/wallet/puzzles/clawback/drivers.py +188 -0
- chia/wallet/puzzles/clawback/metadata.py +38 -0
- chia/wallet/puzzles/clawback/puzzle_decorator.py +67 -0
- chia/wallet/puzzles/condition_codes.clib +77 -0
- chia/wallet/puzzles/curry-and-treehash.clib +102 -0
- chia/wallet/puzzles/curry.clib +135 -0
- chia/wallet/puzzles/curry_by_index.clib +16 -0
- chia/wallet/puzzles/dao_cat_eve.clsp +17 -0
- chia/wallet/puzzles/dao_cat_eve.clsp.hex +1 -0
- chia/wallet/puzzles/dao_cat_launcher.clsp +36 -0
- chia/wallet/puzzles/dao_cat_launcher.clsp.hex +1 -0
- chia/wallet/puzzles/dao_finished_state.clsp +35 -0
- chia/wallet/puzzles/dao_finished_state.clsp.hex +1 -0
- chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_lockup.clsp +288 -0
- chia/wallet/puzzles/dao_lockup.clsp.hex +1 -0
- chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal.clsp +377 -0
- chia/wallet/puzzles/dao_proposal.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp +78 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp +87 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp +240 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex +1 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_treasury.clsp +115 -0
- chia/wallet/puzzles/dao_treasury.clsp.hex +1 -0
- chia/wallet/puzzles/dao_update_proposal.clsp +44 -0
- chia/wallet/puzzles/dao_update_proposal.clsp.hex +1 -0
- chia/wallet/puzzles/deployed_puzzle_hashes.json +67 -0
- chia/wallet/puzzles/json.clib +25 -0
- chia/wallet/puzzles/load_clvm.py +161 -0
- chia/wallet/puzzles/merkle_utils.clib +18 -0
- chia/wallet/puzzles/notification.clsp +7 -0
- chia/wallet/puzzles/notification.clsp.hex +1 -0
- chia/wallet/puzzles/p2_1_of_n.clsp +22 -0
- chia/wallet/puzzles/p2_1_of_n.clsp.hex +1 -0
- chia/wallet/puzzles/p2_conditions.clsp +3 -0
- chia/wallet/puzzles/p2_conditions.clsp.hex +1 -0
- chia/wallet/puzzles/p2_conditions.py +26 -0
- chia/wallet/puzzles/p2_delegated_conditions.clsp +18 -0
- chia/wallet/puzzles/p2_delegated_conditions.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_conditions.py +21 -0
- chia/wallet/puzzles/p2_delegated_puzzle.clsp +19 -0
- chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_puzzle.py +34 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp +91 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +160 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp +108 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex +1 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +21 -0
- chia/wallet/puzzles/p2_parent.clsp +19 -0
- chia/wallet/puzzles/p2_parent.clsp.hex +1 -0
- chia/wallet/puzzles/p2_puzzle_hash.clsp +18 -0
- chia/wallet/puzzles/p2_puzzle_hash.clsp.hex +1 -0
- chia/wallet/puzzles/p2_puzzle_hash.py +27 -0
- chia/wallet/puzzles/p2_singleton.clsp +30 -0
- chia/wallet/puzzles/p2_singleton.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_aggregator.clsp +81 -0
- chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp +50 -0
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp +47 -0
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/puzzle_utils.py +34 -0
- chia/wallet/puzzles/settlement_payments.clsp +49 -0
- chia/wallet/puzzles/settlement_payments.clsp.hex +1 -0
- chia/wallet/puzzles/sha256tree.clib +11 -0
- chia/wallet/puzzles/singleton_launcher.clsp +16 -0
- chia/wallet/puzzles/singleton_launcher.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer.clsp +177 -0
- chia/wallet/puzzles/singleton_top_layer.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer.py +296 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp +107 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +345 -0
- chia/wallet/puzzles/singleton_truths.clib +21 -0
- chia/wallet/puzzles/tails.py +348 -0
- chia/wallet/puzzles/utility_macros.clib +48 -0
- chia/wallet/signer_protocol.py +125 -0
- chia/wallet/singleton.py +106 -0
- chia/wallet/singleton_record.py +30 -0
- chia/wallet/trade_manager.py +1102 -0
- chia/wallet/trade_record.py +67 -0
- chia/wallet/trading/__init__.py +0 -0
- chia/wallet/trading/offer.py +702 -0
- chia/wallet/trading/trade_status.py +13 -0
- chia/wallet/trading/trade_store.py +526 -0
- chia/wallet/transaction_record.py +158 -0
- chia/wallet/transaction_sorting.py +14 -0
- chia/wallet/uncurried_puzzle.py +17 -0
- chia/wallet/util/__init__.py +0 -0
- chia/wallet/util/address_type.py +55 -0
- chia/wallet/util/blind_signer_tl.py +164 -0
- chia/wallet/util/clvm_streamable.py +203 -0
- chia/wallet/util/compute_hints.py +66 -0
- chia/wallet/util/compute_memos.py +43 -0
- chia/wallet/util/curry_and_treehash.py +91 -0
- chia/wallet/util/debug_spend_bundle.py +232 -0
- chia/wallet/util/merkle_tree.py +100 -0
- chia/wallet/util/merkle_utils.py +102 -0
- chia/wallet/util/new_peak_queue.py +82 -0
- chia/wallet/util/notifications.py +12 -0
- chia/wallet/util/peer_request_cache.py +174 -0
- chia/wallet/util/pprint.py +39 -0
- chia/wallet/util/puzzle_compression.py +95 -0
- chia/wallet/util/puzzle_decorator.py +100 -0
- chia/wallet/util/puzzle_decorator_type.py +7 -0
- chia/wallet/util/query_filter.py +59 -0
- chia/wallet/util/transaction_type.py +23 -0
- chia/wallet/util/tx_config.py +158 -0
- chia/wallet/util/wallet_sync_utils.py +351 -0
- chia/wallet/util/wallet_types.py +72 -0
- chia/wallet/vc_wallet/__init__.py +0 -0
- chia/wallet/vc_wallet/cr_cat_drivers.py +664 -0
- chia/wallet/vc_wallet/cr_cat_wallet.py +877 -0
- chia/wallet/vc_wallet/cr_outer_puzzle.py +102 -0
- chia/wallet/vc_wallet/cr_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp +3 -0
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex +1 -0
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp +304 -0
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex +1 -0
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp +45 -0
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_drivers.py +838 -0
- chia/wallet/vc_wallet/vc_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp +30 -0
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp +75 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp +32 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp +80 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp +163 -0
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp +16 -0
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp +74 -0
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp +23 -0
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp +64 -0
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_store.py +263 -0
- chia/wallet/vc_wallet/vc_wallet.py +638 -0
- chia/wallet/wallet.py +698 -0
- chia/wallet/wallet_action_scope.py +96 -0
- chia/wallet/wallet_blockchain.py +244 -0
- chia/wallet/wallet_coin_record.py +72 -0
- chia/wallet/wallet_coin_store.py +351 -0
- chia/wallet/wallet_info.py +35 -0
- chia/wallet/wallet_interested_store.py +188 -0
- chia/wallet/wallet_nft_store.py +279 -0
- chia/wallet/wallet_node.py +1765 -0
- chia/wallet/wallet_node_api.py +207 -0
- chia/wallet/wallet_pool_store.py +119 -0
- chia/wallet/wallet_protocol.py +90 -0
- chia/wallet/wallet_puzzle_store.py +396 -0
- chia/wallet/wallet_retry_store.py +70 -0
- chia/wallet/wallet_singleton_store.py +259 -0
- chia/wallet/wallet_spend_bundle.py +25 -0
- chia/wallet/wallet_state_manager.py +2819 -0
- chia/wallet/wallet_transaction_store.py +496 -0
- chia/wallet/wallet_user_store.py +110 -0
- chia/wallet/wallet_weight_proof_handler.py +126 -0
- chia_blockchain-2.5.1rc1.dist-info/LICENSE +201 -0
- chia_blockchain-2.5.1rc1.dist-info/METADATA +156 -0
- chia_blockchain-2.5.1rc1.dist-info/RECORD +1042 -0
- chia_blockchain-2.5.1rc1.dist-info/WHEEL +4 -0
- chia_blockchain-2.5.1rc1.dist-info/entry_points.txt +17 -0
- mozilla-ca/cacert.pem +3611 -0
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
import time
|
|
6
|
+
from collections.abc import Awaitable, Collection
|
|
7
|
+
from concurrent.futures import Executor, ThreadPoolExecutor
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Callable, Optional, TypeVar
|
|
10
|
+
|
|
11
|
+
from chia_rs import ELIGIBLE_FOR_DEDUP, ELIGIBLE_FOR_FF, BLSCache, supports_fast_forward, validate_clvm_and_signature
|
|
12
|
+
from chiabip158 import PyBIP158
|
|
13
|
+
|
|
14
|
+
from chia.consensus.block_record import BlockRecordProtocol
|
|
15
|
+
from chia.consensus.constants import ConsensusConstants
|
|
16
|
+
from chia.consensus.cost_calculator import NPCResult
|
|
17
|
+
from chia.full_node.bitcoin_fee_estimator import create_bitcoin_fee_estimator
|
|
18
|
+
from chia.full_node.fee_estimation import FeeBlockInfo, MempoolInfo, MempoolItemInfo
|
|
19
|
+
from chia.full_node.fee_estimator_interface import FeeEstimatorInterface
|
|
20
|
+
from chia.full_node.mempool import MEMPOOL_ITEM_FEE_LIMIT, Mempool, MempoolRemoveInfo, MempoolRemoveReason
|
|
21
|
+
from chia.full_node.mempool_check_conditions import mempool_check_time_locks
|
|
22
|
+
from chia.full_node.pending_tx_cache import ConflictTxCache, PendingTxCache
|
|
23
|
+
from chia.types.blockchain_format.coin import Coin
|
|
24
|
+
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
25
|
+
from chia.types.clvm_cost import CLVMCost
|
|
26
|
+
from chia.types.coin_record import CoinRecord
|
|
27
|
+
from chia.types.eligible_coin_spends import EligibilityAndAdditions, UnspentLineageInfo
|
|
28
|
+
from chia.types.fee_rate import FeeRate
|
|
29
|
+
from chia.types.mempool_inclusion_status import MempoolInclusionStatus
|
|
30
|
+
from chia.types.mempool_item import BundleCoinSpend, MempoolItem
|
|
31
|
+
from chia.types.spend_bundle import SpendBundle
|
|
32
|
+
from chia.types.spend_bundle_conditions import SpendBundleConditions
|
|
33
|
+
from chia.util.db_wrapper import SQLITE_INT_MAX
|
|
34
|
+
from chia.util.errors import Err, ValidationError
|
|
35
|
+
from chia.util.inline_executor import InlineExecutor
|
|
36
|
+
from chia.util.ints import uint32, uint64
|
|
37
|
+
|
|
38
|
+
log = logging.getLogger(__name__)
|
|
39
|
+
|
|
40
|
+
# mempool items replacing existing ones must increase the total fee at least by
|
|
41
|
+
# this amount. 0.00001 XCH
|
|
42
|
+
MEMPOOL_MIN_FEE_INCREASE = uint64(10000000)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class TimelockConditions:
|
|
47
|
+
assert_height: uint32 = uint32(0)
|
|
48
|
+
assert_seconds: uint64 = uint64(0)
|
|
49
|
+
assert_before_height: Optional[uint32] = None
|
|
50
|
+
assert_before_seconds: Optional[uint64] = None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def compute_assert_height(
|
|
54
|
+
removal_coin_records: dict[bytes32, CoinRecord],
|
|
55
|
+
conds: SpendBundleConditions,
|
|
56
|
+
) -> TimelockConditions:
|
|
57
|
+
"""
|
|
58
|
+
Computes the most restrictive height- and seconds assertion in the spend bundle.
|
|
59
|
+
Relative heights and times are resolved using the confirmed heights and
|
|
60
|
+
timestamps from the coin records.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
ret = TimelockConditions()
|
|
64
|
+
ret.assert_height = uint32(conds.height_absolute)
|
|
65
|
+
ret.assert_seconds = uint64(conds.seconds_absolute)
|
|
66
|
+
ret.assert_before_height = (
|
|
67
|
+
uint32(conds.before_height_absolute) if conds.before_height_absolute is not None else None
|
|
68
|
+
)
|
|
69
|
+
ret.assert_before_seconds = (
|
|
70
|
+
uint64(conds.before_seconds_absolute) if conds.before_seconds_absolute is not None else None
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
for spend in conds.spends:
|
|
74
|
+
if spend.height_relative is not None:
|
|
75
|
+
h = uint32(removal_coin_records[bytes32(spend.coin_id)].confirmed_block_index + spend.height_relative)
|
|
76
|
+
ret.assert_height = max(ret.assert_height, h)
|
|
77
|
+
|
|
78
|
+
if spend.seconds_relative is not None:
|
|
79
|
+
s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.seconds_relative)
|
|
80
|
+
ret.assert_seconds = max(ret.assert_seconds, s)
|
|
81
|
+
|
|
82
|
+
if spend.before_height_relative is not None:
|
|
83
|
+
h = uint32(
|
|
84
|
+
removal_coin_records[bytes32(spend.coin_id)].confirmed_block_index + spend.before_height_relative
|
|
85
|
+
)
|
|
86
|
+
if ret.assert_before_height is not None:
|
|
87
|
+
ret.assert_before_height = min(ret.assert_before_height, h)
|
|
88
|
+
else:
|
|
89
|
+
ret.assert_before_height = h
|
|
90
|
+
|
|
91
|
+
if spend.before_seconds_relative is not None:
|
|
92
|
+
s = uint64(removal_coin_records[bytes32(spend.coin_id)].timestamp + spend.before_seconds_relative)
|
|
93
|
+
if ret.assert_before_seconds is not None:
|
|
94
|
+
ret.assert_before_seconds = min(ret.assert_before_seconds, s)
|
|
95
|
+
else:
|
|
96
|
+
ret.assert_before_seconds = s
|
|
97
|
+
|
|
98
|
+
return ret
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@dataclass
|
|
102
|
+
class SpendBundleAddInfo:
|
|
103
|
+
cost: Optional[uint64]
|
|
104
|
+
status: MempoolInclusionStatus
|
|
105
|
+
removals: list[MempoolRemoveInfo]
|
|
106
|
+
error: Optional[Err]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class NewPeakInfo:
|
|
111
|
+
items: list[NewPeakItem]
|
|
112
|
+
removals: list[MempoolRemoveInfo]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class NewPeakItem:
|
|
117
|
+
transaction_id: bytes32
|
|
118
|
+
spend_bundle: SpendBundle
|
|
119
|
+
conds: SpendBundleConditions
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# For block overhead cost calculation
|
|
123
|
+
QUOTE_BYTES = 2
|
|
124
|
+
QUOTE_EXECUTION_COST = 20
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class MempoolManager:
|
|
128
|
+
pool: Executor
|
|
129
|
+
constants: ConsensusConstants
|
|
130
|
+
seen_bundle_hashes: dict[bytes32, bytes32]
|
|
131
|
+
get_coin_records: Callable[[Collection[bytes32]], Awaitable[list[CoinRecord]]]
|
|
132
|
+
nonzero_fee_minimum_fpc: int
|
|
133
|
+
mempool_max_total_cost: int
|
|
134
|
+
# a cache of MempoolItems that conflict with existing items in the pool
|
|
135
|
+
_conflict_cache: ConflictTxCache
|
|
136
|
+
# cache of MempoolItems with height conditions making them not valid yet
|
|
137
|
+
_pending_cache: PendingTxCache
|
|
138
|
+
seen_cache_size: int
|
|
139
|
+
peak: Optional[BlockRecordProtocol]
|
|
140
|
+
mempool: Mempool
|
|
141
|
+
_worker_queue_size: int
|
|
142
|
+
max_block_clvm_cost: uint64
|
|
143
|
+
max_tx_clvm_cost: uint64
|
|
144
|
+
|
|
145
|
+
def __init__(
|
|
146
|
+
self,
|
|
147
|
+
get_coin_records: Callable[[Collection[bytes32]], Awaitable[list[CoinRecord]]],
|
|
148
|
+
consensus_constants: ConsensusConstants,
|
|
149
|
+
*,
|
|
150
|
+
single_threaded: bool = False,
|
|
151
|
+
max_tx_clvm_cost: Optional[uint64] = None,
|
|
152
|
+
):
|
|
153
|
+
self.constants: ConsensusConstants = consensus_constants
|
|
154
|
+
|
|
155
|
+
# Keep track of seen spend_bundles
|
|
156
|
+
self.seen_bundle_hashes: dict[bytes32, bytes32] = {}
|
|
157
|
+
|
|
158
|
+
self.get_coin_records = get_coin_records
|
|
159
|
+
|
|
160
|
+
# The fee per cost must be above this amount to consider the fee "nonzero", and thus able to kick out other
|
|
161
|
+
# transactions. This prevents spam. This is equivalent to 0.055 XCH per block, or about 0.00005 XCH for two
|
|
162
|
+
# spends.
|
|
163
|
+
self.nonzero_fee_minimum_fpc = 5
|
|
164
|
+
|
|
165
|
+
# We need to deduct the block overhead, which consists of the wrapping
|
|
166
|
+
# quote opcode's bytes cost as well as its execution cost.
|
|
167
|
+
BLOCK_OVERHEAD = QUOTE_BYTES * self.constants.COST_PER_BYTE + QUOTE_EXECUTION_COST
|
|
168
|
+
|
|
169
|
+
self.max_block_clvm_cost = uint64(self.constants.MAX_BLOCK_COST_CLVM - BLOCK_OVERHEAD)
|
|
170
|
+
self.max_tx_clvm_cost = (
|
|
171
|
+
max_tx_clvm_cost if max_tx_clvm_cost is not None else uint64(self.constants.MAX_BLOCK_COST_CLVM // 2)
|
|
172
|
+
)
|
|
173
|
+
self.mempool_max_total_cost = int(self.constants.MAX_BLOCK_COST_CLVM * self.constants.MEMPOOL_BLOCK_BUFFER)
|
|
174
|
+
|
|
175
|
+
# Transactions that were unable to enter mempool, used for retry. (they were invalid)
|
|
176
|
+
self._conflict_cache = ConflictTxCache(self.constants.MAX_BLOCK_COST_CLVM * 1, 1000)
|
|
177
|
+
self._pending_cache = PendingTxCache(self.constants.MAX_BLOCK_COST_CLVM * 1, 1000)
|
|
178
|
+
self.seen_cache_size = 10000
|
|
179
|
+
self._worker_queue_size = 0
|
|
180
|
+
if single_threaded:
|
|
181
|
+
self.pool = InlineExecutor()
|
|
182
|
+
else:
|
|
183
|
+
self.pool = ThreadPoolExecutor(max_workers=2)
|
|
184
|
+
|
|
185
|
+
# The mempool will correspond to a certain peak
|
|
186
|
+
self.peak: Optional[BlockRecordProtocol] = None
|
|
187
|
+
self.fee_estimator: FeeEstimatorInterface = create_bitcoin_fee_estimator(self.max_block_clvm_cost)
|
|
188
|
+
mempool_info = MempoolInfo(
|
|
189
|
+
CLVMCost(uint64(self.mempool_max_total_cost)),
|
|
190
|
+
FeeRate(uint64(self.nonzero_fee_minimum_fpc)),
|
|
191
|
+
CLVMCost(uint64(self.max_block_clvm_cost)),
|
|
192
|
+
)
|
|
193
|
+
self.mempool: Mempool = Mempool(mempool_info, self.fee_estimator)
|
|
194
|
+
|
|
195
|
+
def shut_down(self) -> None:
|
|
196
|
+
self.pool.shutdown(wait=True)
|
|
197
|
+
|
|
198
|
+
async def create_bundle_from_mempool(
|
|
199
|
+
self,
|
|
200
|
+
last_tb_header_hash: bytes32,
|
|
201
|
+
get_unspent_lineage_info_for_puzzle_hash: Callable[[bytes32], Awaitable[Optional[UnspentLineageInfo]]],
|
|
202
|
+
item_inclusion_filter: Optional[Callable[[bytes32], bool]] = None,
|
|
203
|
+
) -> Optional[tuple[SpendBundle, list[Coin]]]:
|
|
204
|
+
"""
|
|
205
|
+
Returns aggregated spendbundle that can be used for creating new block,
|
|
206
|
+
additions and removals in that spend_bundle
|
|
207
|
+
"""
|
|
208
|
+
|
|
209
|
+
if self.peak is None or self.peak.header_hash != last_tb_header_hash:
|
|
210
|
+
return None
|
|
211
|
+
if item_inclusion_filter is None:
|
|
212
|
+
|
|
213
|
+
def always(bundle_name: bytes32) -> bool:
|
|
214
|
+
return True
|
|
215
|
+
|
|
216
|
+
item_inclusion_filter = always
|
|
217
|
+
return await self.mempool.create_bundle_from_mempool_items(
|
|
218
|
+
item_inclusion_filter, get_unspent_lineage_info_for_puzzle_hash, self.constants, self.peak.height
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
def get_filter(self) -> bytes:
|
|
222
|
+
all_transactions: set[bytes32] = set()
|
|
223
|
+
byte_array_list = []
|
|
224
|
+
for key in self.mempool.all_item_ids():
|
|
225
|
+
if key not in all_transactions:
|
|
226
|
+
all_transactions.add(key)
|
|
227
|
+
byte_array_list.append(bytearray(key))
|
|
228
|
+
|
|
229
|
+
tx_filter: PyBIP158 = PyBIP158(byte_array_list)
|
|
230
|
+
return bytes(tx_filter.GetEncoded())
|
|
231
|
+
|
|
232
|
+
def is_fee_enough(self, fees: uint64, cost: uint64) -> bool:
|
|
233
|
+
"""
|
|
234
|
+
Determines whether any of the pools can accept a transaction with a given fees
|
|
235
|
+
and cost.
|
|
236
|
+
"""
|
|
237
|
+
if cost == 0:
|
|
238
|
+
return False
|
|
239
|
+
fees_per_cost = fees / cost
|
|
240
|
+
if not self.mempool.at_full_capacity(cost):
|
|
241
|
+
return True
|
|
242
|
+
if fees_per_cost < self.nonzero_fee_minimum_fpc:
|
|
243
|
+
return False
|
|
244
|
+
min_fee_rate = self.mempool.get_min_fee_rate(cost)
|
|
245
|
+
return min_fee_rate is not None and fees_per_cost > min_fee_rate
|
|
246
|
+
|
|
247
|
+
def add_and_maybe_pop_seen(self, spend_name: bytes32) -> None:
|
|
248
|
+
self.seen_bundle_hashes[spend_name] = spend_name
|
|
249
|
+
while len(self.seen_bundle_hashes) > self.seen_cache_size:
|
|
250
|
+
first_in = next(iter(self.seen_bundle_hashes.keys()))
|
|
251
|
+
self.seen_bundle_hashes.pop(first_in)
|
|
252
|
+
|
|
253
|
+
def seen(self, bundle_hash: bytes32) -> bool:
|
|
254
|
+
"""Return true if we saw this spendbundle recently"""
|
|
255
|
+
return bundle_hash in self.seen_bundle_hashes
|
|
256
|
+
|
|
257
|
+
def remove_seen(self, bundle_hash: bytes32) -> None:
|
|
258
|
+
if bundle_hash in self.seen_bundle_hashes:
|
|
259
|
+
self.seen_bundle_hashes.pop(bundle_hash)
|
|
260
|
+
|
|
261
|
+
async def pre_validate_spendbundle(
|
|
262
|
+
self, spend_bundle: SpendBundle, spend_bundle_id: Optional[bytes32] = None, bls_cache: Optional[BLSCache] = None
|
|
263
|
+
) -> SpendBundleConditions:
|
|
264
|
+
"""
|
|
265
|
+
Errors are included within the cached_result.
|
|
266
|
+
This runs in another process so we don't block the main thread
|
|
267
|
+
"""
|
|
268
|
+
|
|
269
|
+
if spend_bundle.coin_spends == []:
|
|
270
|
+
raise ValidationError(Err.INVALID_SPEND_BUNDLE, "Empty SpendBundle")
|
|
271
|
+
|
|
272
|
+
assert self.peak is not None
|
|
273
|
+
|
|
274
|
+
self._worker_queue_size += 1
|
|
275
|
+
try:
|
|
276
|
+
sbc, new_cache_entries, duration = await asyncio.get_running_loop().run_in_executor(
|
|
277
|
+
self.pool,
|
|
278
|
+
validate_clvm_and_signature,
|
|
279
|
+
spend_bundle,
|
|
280
|
+
self.max_tx_clvm_cost,
|
|
281
|
+
self.constants,
|
|
282
|
+
self.peak.height,
|
|
283
|
+
)
|
|
284
|
+
# validate_clvm_and_signature raises a TypeError with an error code
|
|
285
|
+
except Exception as e:
|
|
286
|
+
# Convert that to a ValidationError
|
|
287
|
+
if len(e.args) > 0:
|
|
288
|
+
error = Err(e.args[0])
|
|
289
|
+
raise ValidationError(error)
|
|
290
|
+
else:
|
|
291
|
+
raise ValidationError(Err.UNKNOWN) # pragma: no cover
|
|
292
|
+
finally:
|
|
293
|
+
self._worker_queue_size -= 1
|
|
294
|
+
|
|
295
|
+
if bls_cache is not None:
|
|
296
|
+
bls_cache.update(new_cache_entries)
|
|
297
|
+
|
|
298
|
+
ret = NPCResult(None, sbc)
|
|
299
|
+
|
|
300
|
+
if spend_bundle_id is None:
|
|
301
|
+
spend_bundle_id = spend_bundle.name()
|
|
302
|
+
|
|
303
|
+
log.log(
|
|
304
|
+
logging.DEBUG if duration < 2 else logging.WARNING,
|
|
305
|
+
f"pre_validate_spendbundle took {duration:0.4f} seconds "
|
|
306
|
+
f"for {spend_bundle_id} (queue-size: {self._worker_queue_size})",
|
|
307
|
+
)
|
|
308
|
+
if ret.error is not None:
|
|
309
|
+
raise ValidationError(Err(ret.error), "pre_validate_spendbundle failed")
|
|
310
|
+
assert ret.conds is not None
|
|
311
|
+
return ret.conds
|
|
312
|
+
|
|
313
|
+
async def add_spend_bundle(
|
|
314
|
+
self,
|
|
315
|
+
new_spend: SpendBundle,
|
|
316
|
+
conds: SpendBundleConditions,
|
|
317
|
+
spend_name: bytes32,
|
|
318
|
+
first_added_height: uint32,
|
|
319
|
+
get_coin_records: Optional[Callable[[Collection[bytes32]], Awaitable[list[CoinRecord]]]] = None,
|
|
320
|
+
) -> SpendBundleAddInfo:
|
|
321
|
+
"""
|
|
322
|
+
Validates and adds to mempool a new_spend with the given NPCResult, and spend_name, and the current mempool.
|
|
323
|
+
The mempool should be locked during this call (blockchain lock). If there are mempool conflicts, the conflicting
|
|
324
|
+
spends might be removed (if the new spend is a superset of the previous). Otherwise, the new spend might be
|
|
325
|
+
added to the potential pool.
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
new_spend: spend bundle to validate and add
|
|
329
|
+
conds: result of running the clvm transaction in a fake block
|
|
330
|
+
spend_name: hash of the spend bundle data, passed in as an optimization
|
|
331
|
+
|
|
332
|
+
Returns:
|
|
333
|
+
Optional[uint64]: cost of the entire transaction, None iff status is FAILED
|
|
334
|
+
MempoolInclusionStatus: SUCCESS (should add to pool), FAILED (cannot add), and PENDING (can add later)
|
|
335
|
+
list[MempoolRemoveInfo]: conflicting mempool items which were removed, if no Err
|
|
336
|
+
Optional[Err]: Err is set iff status is FAILED
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
# Skip if already added
|
|
340
|
+
existing_item = self.mempool.get_item_by_id(spend_name)
|
|
341
|
+
if existing_item is not None:
|
|
342
|
+
return SpendBundleAddInfo(existing_item.cost, MempoolInclusionStatus.SUCCESS, [], None)
|
|
343
|
+
|
|
344
|
+
if get_coin_records is None:
|
|
345
|
+
get_coin_records = self.get_coin_records
|
|
346
|
+
err, item, remove_items = await self.validate_spend_bundle(
|
|
347
|
+
new_spend,
|
|
348
|
+
conds,
|
|
349
|
+
spend_name,
|
|
350
|
+
first_added_height,
|
|
351
|
+
get_coin_records,
|
|
352
|
+
)
|
|
353
|
+
if err is None:
|
|
354
|
+
# No error, immediately add to mempool, after removing conflicting TXs.
|
|
355
|
+
assert item is not None
|
|
356
|
+
conflict = self.mempool.remove_from_pool(remove_items, MempoolRemoveReason.CONFLICT)
|
|
357
|
+
info = self.mempool.add_to_pool(item)
|
|
358
|
+
if info.error is not None:
|
|
359
|
+
return SpendBundleAddInfo(item.cost, MempoolInclusionStatus.FAILED, [], info.error)
|
|
360
|
+
return SpendBundleAddInfo(item.cost, MempoolInclusionStatus.SUCCESS, [*info.removals, conflict], None)
|
|
361
|
+
elif err is Err.MEMPOOL_CONFLICT and item is not None:
|
|
362
|
+
# The transaction has a conflict with another item in the
|
|
363
|
+
# mempool, put it aside and re-try it later
|
|
364
|
+
self._conflict_cache.add(item)
|
|
365
|
+
return SpendBundleAddInfo(item.cost, MempoolInclusionStatus.PENDING, [], err)
|
|
366
|
+
elif item is not None:
|
|
367
|
+
# The transasction has a height assertion and is not yet valid.
|
|
368
|
+
# remember it to try it again later
|
|
369
|
+
self._pending_cache.add(item)
|
|
370
|
+
return SpendBundleAddInfo(item.cost, MempoolInclusionStatus.PENDING, [], err)
|
|
371
|
+
else:
|
|
372
|
+
# Cannot add to the mempool or pending pool.
|
|
373
|
+
return SpendBundleAddInfo(None, MempoolInclusionStatus.FAILED, [], err)
|
|
374
|
+
|
|
375
|
+
async def validate_spend_bundle(
|
|
376
|
+
self,
|
|
377
|
+
new_spend: SpendBundle,
|
|
378
|
+
conds: SpendBundleConditions,
|
|
379
|
+
spend_name: bytes32,
|
|
380
|
+
first_added_height: uint32,
|
|
381
|
+
get_coin_records: Callable[[Collection[bytes32]], Awaitable[list[CoinRecord]]],
|
|
382
|
+
) -> tuple[Optional[Err], Optional[MempoolItem], list[bytes32]]:
|
|
383
|
+
"""
|
|
384
|
+
Validates new_spend with the given NPCResult, and spend_name, and the current mempool. The mempool should
|
|
385
|
+
be locked during this call (blockchain lock).
|
|
386
|
+
|
|
387
|
+
Args:
|
|
388
|
+
new_spend: spend bundle to validate
|
|
389
|
+
conds: result of running the clvm transaction in a fake block
|
|
390
|
+
spend_name: hash of the spend bundle data, passed in as an optimization
|
|
391
|
+
first_added_height: The block height that `new_spend` first entered this node's mempool.
|
|
392
|
+
Used to estimate how long a spend has taken to be included on the chain.
|
|
393
|
+
This value could differ node to node. Not preserved across full_node restarts.
|
|
394
|
+
|
|
395
|
+
Returns:
|
|
396
|
+
Optional[Err]: Err is set if we cannot add to the mempool, None if we will immediately add to mempool
|
|
397
|
+
Optional[MempoolItem]: the item to add (to mempool or pending pool)
|
|
398
|
+
list[bytes32]: conflicting mempool items to remove, if no Err
|
|
399
|
+
"""
|
|
400
|
+
start_time = time.time()
|
|
401
|
+
if self.peak is None:
|
|
402
|
+
return Err.MEMPOOL_NOT_INITIALIZED, None, []
|
|
403
|
+
|
|
404
|
+
cost = conds.cost
|
|
405
|
+
|
|
406
|
+
removal_names: set[bytes32] = set()
|
|
407
|
+
additions_dict: dict[bytes32, Coin] = {}
|
|
408
|
+
addition_amount: int = 0
|
|
409
|
+
# Map of coin ID to eligibility information
|
|
410
|
+
eligibility_and_additions: dict[bytes32, EligibilityAndAdditions] = {}
|
|
411
|
+
non_eligible_coin_ids: list[bytes32] = []
|
|
412
|
+
for spend in conds.spends:
|
|
413
|
+
coin_id = bytes32(spend.coin_id)
|
|
414
|
+
removal_names.add(coin_id)
|
|
415
|
+
spend_additions = []
|
|
416
|
+
for puzzle_hash, amount, _ in spend.create_coin:
|
|
417
|
+
child_coin = Coin(coin_id, puzzle_hash, uint64(amount))
|
|
418
|
+
spend_additions.append(child_coin)
|
|
419
|
+
additions_dict[child_coin.name()] = child_coin
|
|
420
|
+
addition_amount += child_coin.amount
|
|
421
|
+
is_eligible_for_dedup = bool(spend.flags & ELIGIBLE_FOR_DEDUP)
|
|
422
|
+
is_eligible_for_ff = bool(spend.flags & ELIGIBLE_FOR_FF)
|
|
423
|
+
eligibility_and_additions[coin_id] = EligibilityAndAdditions(
|
|
424
|
+
is_eligible_for_dedup=is_eligible_for_dedup,
|
|
425
|
+
spend_additions=spend_additions,
|
|
426
|
+
is_eligible_for_ff=is_eligible_for_ff,
|
|
427
|
+
)
|
|
428
|
+
removal_names_from_coin_spends: set[bytes32] = set()
|
|
429
|
+
fast_forward_coin_ids: set[bytes32] = set()
|
|
430
|
+
bundle_coin_spends: dict[bytes32, BundleCoinSpend] = {}
|
|
431
|
+
for coin_spend in new_spend.coin_spends:
|
|
432
|
+
coin_id = coin_spend.coin.name()
|
|
433
|
+
removal_names_from_coin_spends.add(coin_id)
|
|
434
|
+
eligibility_info = eligibility_and_additions.get(
|
|
435
|
+
coin_id,
|
|
436
|
+
EligibilityAndAdditions(is_eligible_for_dedup=False, spend_additions=[], is_eligible_for_ff=False),
|
|
437
|
+
)
|
|
438
|
+
mark_as_fast_forward = eligibility_info.is_eligible_for_ff and supports_fast_forward(coin_spend)
|
|
439
|
+
# We are now able to check eligibility of both dedup and fast forward
|
|
440
|
+
if not (eligibility_info.is_eligible_for_dedup or mark_as_fast_forward):
|
|
441
|
+
non_eligible_coin_ids.append(coin_id)
|
|
442
|
+
if mark_as_fast_forward:
|
|
443
|
+
fast_forward_coin_ids.add(coin_id)
|
|
444
|
+
bundle_coin_spends[coin_id] = BundleCoinSpend(
|
|
445
|
+
coin_spend=coin_spend,
|
|
446
|
+
eligible_for_dedup=eligibility_info.is_eligible_for_dedup,
|
|
447
|
+
eligible_for_fast_forward=mark_as_fast_forward,
|
|
448
|
+
additions=eligibility_info.spend_additions,
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
if removal_names != removal_names_from_coin_spends:
|
|
452
|
+
# If you reach here it's probably because your program reveal doesn't match the coin's puzzle hash
|
|
453
|
+
return Err.INVALID_SPEND_BUNDLE, None, []
|
|
454
|
+
|
|
455
|
+
removal_record_dict: dict[bytes32, CoinRecord] = {}
|
|
456
|
+
removal_amount: int = 0
|
|
457
|
+
removal_records = await get_coin_records(removal_names)
|
|
458
|
+
for record in removal_records:
|
|
459
|
+
removal_record_dict[record.coin.name()] = record
|
|
460
|
+
|
|
461
|
+
for name in removal_names:
|
|
462
|
+
if name not in removal_record_dict and name not in additions_dict:
|
|
463
|
+
return Err.UNKNOWN_UNSPENT, None, []
|
|
464
|
+
if name in additions_dict:
|
|
465
|
+
removal_coin = additions_dict[name]
|
|
466
|
+
# The timestamp and block-height of this coin being spent needs
|
|
467
|
+
# to be consistent with what we use to check time-lock
|
|
468
|
+
# conditions (below). All spends (including ephemeral coins) are
|
|
469
|
+
# spent simultaneously. Ephemeral coins with an
|
|
470
|
+
# ASSERT_SECONDS_RELATIVE 0 condition are still OK to spend in
|
|
471
|
+
# the same block.
|
|
472
|
+
assert self.peak.timestamp is not None
|
|
473
|
+
removal_record = CoinRecord(
|
|
474
|
+
removal_coin,
|
|
475
|
+
uint32(self.peak.height + 1),
|
|
476
|
+
uint32(0),
|
|
477
|
+
False,
|
|
478
|
+
self.peak.timestamp,
|
|
479
|
+
)
|
|
480
|
+
removal_record_dict[name] = removal_record
|
|
481
|
+
else:
|
|
482
|
+
removal_record = removal_record_dict[name]
|
|
483
|
+
removal_amount += removal_record.coin.amount
|
|
484
|
+
|
|
485
|
+
fees = uint64(removal_amount - addition_amount)
|
|
486
|
+
|
|
487
|
+
if cost == 0:
|
|
488
|
+
return Err.UNKNOWN, None, []
|
|
489
|
+
|
|
490
|
+
if cost > self.max_tx_clvm_cost:
|
|
491
|
+
return Err.BLOCK_COST_EXCEEDS_MAX, None, []
|
|
492
|
+
|
|
493
|
+
# this is not very likely to happen, but it's here to ensure SQLite
|
|
494
|
+
# never runs out of precision in its computation of fees.
|
|
495
|
+
# sqlite's integers are signed int64, so the max value they can
|
|
496
|
+
# represent is 2^63-1
|
|
497
|
+
if fees > MEMPOOL_ITEM_FEE_LIMIT or SQLITE_INT_MAX - self.mempool.total_mempool_fees() <= fees:
|
|
498
|
+
return Err.INVALID_BLOCK_FEE_AMOUNT, None, []
|
|
499
|
+
|
|
500
|
+
fees_per_cost: float = fees / cost
|
|
501
|
+
# If pool is at capacity check the fee, if not then accept even without the fee
|
|
502
|
+
if self.mempool.at_full_capacity(cost):
|
|
503
|
+
if fees_per_cost < self.nonzero_fee_minimum_fpc:
|
|
504
|
+
return Err.INVALID_FEE_TOO_CLOSE_TO_ZERO, None, []
|
|
505
|
+
min_fee_rate = self.mempool.get_min_fee_rate(cost)
|
|
506
|
+
if min_fee_rate is None:
|
|
507
|
+
return Err.INVALID_COST_RESULT, None, []
|
|
508
|
+
if fees_per_cost <= min_fee_rate:
|
|
509
|
+
return Err.INVALID_FEE_LOW_FEE, None, []
|
|
510
|
+
|
|
511
|
+
# Check removals against UnspentDB + DiffStore + Mempool + SpendBundle
|
|
512
|
+
# Use this information later when constructing a block
|
|
513
|
+
fail_reason, conflicts = self.check_removals(non_eligible_coin_ids, removal_record_dict, fast_forward_coin_ids)
|
|
514
|
+
|
|
515
|
+
# If we have a mempool conflict, continue, since we still want to keep around the TX in the pending pool.
|
|
516
|
+
if fail_reason is not None and fail_reason is not Err.MEMPOOL_CONFLICT:
|
|
517
|
+
return fail_reason, None, []
|
|
518
|
+
|
|
519
|
+
# Verify conditions, create hash_key list for aggsig check
|
|
520
|
+
for spend in conds.spends:
|
|
521
|
+
coin_record: CoinRecord = removal_record_dict[bytes32(spend.coin_id)]
|
|
522
|
+
# Check that the revealed removal puzzles actually match the puzzle hash
|
|
523
|
+
if spend.puzzle_hash != coin_record.coin.puzzle_hash:
|
|
524
|
+
log.warning("Mempool rejecting transaction because of wrong puzzle_hash")
|
|
525
|
+
log.warning(f"{spend.puzzle_hash.hex()} != {coin_record.coin.puzzle_hash.hex()}")
|
|
526
|
+
return Err.WRONG_PUZZLE_HASH, None, []
|
|
527
|
+
|
|
528
|
+
# the height and time we pass in here represent the previous transaction
|
|
529
|
+
# block's height and timestamp. In the mempool, the most recent peak
|
|
530
|
+
# block we've received will be the previous transaction block, from the
|
|
531
|
+
# point-of-view of the next block to be farmed. Therefore we pass in the
|
|
532
|
+
# current peak's height and timestamp
|
|
533
|
+
assert self.peak.timestamp is not None
|
|
534
|
+
tl_error: Optional[Err] = mempool_check_time_locks(
|
|
535
|
+
removal_record_dict,
|
|
536
|
+
conds,
|
|
537
|
+
self.peak.height,
|
|
538
|
+
self.peak.timestamp,
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
timelocks: TimelockConditions = compute_assert_height(removal_record_dict, conds)
|
|
542
|
+
|
|
543
|
+
if timelocks.assert_before_height is not None and timelocks.assert_before_height <= timelocks.assert_height:
|
|
544
|
+
# returning None as the "potential" means it failed. We won't store it
|
|
545
|
+
# in the pending cache
|
|
546
|
+
return Err.IMPOSSIBLE_HEIGHT_ABSOLUTE_CONSTRAINTS, None, [] # MempoolInclusionStatus.FAILED
|
|
547
|
+
if timelocks.assert_before_seconds is not None and timelocks.assert_before_seconds <= timelocks.assert_seconds:
|
|
548
|
+
return Err.IMPOSSIBLE_SECONDS_ABSOLUTE_CONSTRAINTS, None, [] # MempoolInclusionStatus.FAILED
|
|
549
|
+
|
|
550
|
+
potential = MempoolItem(
|
|
551
|
+
new_spend,
|
|
552
|
+
uint64(fees),
|
|
553
|
+
conds,
|
|
554
|
+
spend_name,
|
|
555
|
+
first_added_height,
|
|
556
|
+
timelocks.assert_height,
|
|
557
|
+
timelocks.assert_before_height,
|
|
558
|
+
timelocks.assert_before_seconds,
|
|
559
|
+
bundle_coin_spends,
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
if tl_error:
|
|
563
|
+
if tl_error is Err.ASSERT_HEIGHT_ABSOLUTE_FAILED or tl_error is Err.ASSERT_HEIGHT_RELATIVE_FAILED:
|
|
564
|
+
return tl_error, potential, [] # MempoolInclusionStatus.PENDING
|
|
565
|
+
else:
|
|
566
|
+
return tl_error, None, [] # MempoolInclusionStatus.FAILED
|
|
567
|
+
|
|
568
|
+
if fail_reason is Err.MEMPOOL_CONFLICT:
|
|
569
|
+
log.debug(f"Replace attempted. number of MempoolItems: {len(conflicts)}")
|
|
570
|
+
if not can_replace(conflicts, removal_names, potential):
|
|
571
|
+
return Err.MEMPOOL_CONFLICT, potential, []
|
|
572
|
+
|
|
573
|
+
duration = time.time() - start_time
|
|
574
|
+
|
|
575
|
+
log.log(
|
|
576
|
+
logging.DEBUG if duration < 2 else logging.WARNING,
|
|
577
|
+
f"add_spendbundle {spend_name} took {duration:0.2f} seconds. "
|
|
578
|
+
f"Cost: {cost} ({round(100.0 * cost / self.constants.MAX_BLOCK_COST_CLVM, 3)}% of max block cost)",
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
return None, potential, [item.name for item in conflicts]
|
|
582
|
+
|
|
583
|
+
def check_removals(
|
|
584
|
+
self,
|
|
585
|
+
non_eligible_coin_ids: list[bytes32],
|
|
586
|
+
removals: dict[bytes32, CoinRecord],
|
|
587
|
+
fast_forward_coin_ids: set[bytes32],
|
|
588
|
+
) -> tuple[Optional[Err], list[MempoolItem]]:
|
|
589
|
+
"""
|
|
590
|
+
This function checks for double spends, unknown spends and conflicting transactions in mempool.
|
|
591
|
+
Returns Error (if any), the set of existing MempoolItems with conflicting spends (if any).
|
|
592
|
+
Note that additions are not checked for duplicates, because having duplicate additions requires also
|
|
593
|
+
having duplicate removals.
|
|
594
|
+
"""
|
|
595
|
+
assert self.peak is not None
|
|
596
|
+
# 1. Checks if it's been spent already
|
|
597
|
+
for record in removals.values():
|
|
598
|
+
if record.spent:
|
|
599
|
+
# Only consider it a double spend if this is not a fast forward
|
|
600
|
+
if record.name not in fast_forward_coin_ids:
|
|
601
|
+
return Err.DOUBLE_SPEND, []
|
|
602
|
+
# 2. Checks if there's a mempool conflict
|
|
603
|
+
# Only consider conflicts if the coin is not eligible for deduplication
|
|
604
|
+
conflicts = self.mempool.get_items_by_coin_ids(non_eligible_coin_ids)
|
|
605
|
+
if len(conflicts) > 0:
|
|
606
|
+
return Err.MEMPOOL_CONFLICT, conflicts
|
|
607
|
+
# 5. If coins can be spent return list of unspents as we see them in local storage
|
|
608
|
+
return None, []
|
|
609
|
+
|
|
610
|
+
def get_spendbundle(self, bundle_hash: bytes32) -> Optional[SpendBundle]:
|
|
611
|
+
"""Returns a full SpendBundle if it's inside one the mempools"""
|
|
612
|
+
item: Optional[MempoolItem] = self.mempool.get_item_by_id(bundle_hash)
|
|
613
|
+
if item is not None:
|
|
614
|
+
return item.spend_bundle
|
|
615
|
+
return None
|
|
616
|
+
|
|
617
|
+
def get_mempool_item(self, bundle_hash: bytes32, include_pending: bool = False) -> Optional[MempoolItem]:
|
|
618
|
+
"""
|
|
619
|
+
Returns the MempoolItem in the mempool that matches the provided spend bundle hash (id)
|
|
620
|
+
or None if not found.
|
|
621
|
+
|
|
622
|
+
If include_pending is specified, also check the PENDING cache.
|
|
623
|
+
"""
|
|
624
|
+
item = self.mempool.get_item_by_id(bundle_hash)
|
|
625
|
+
if not item and include_pending:
|
|
626
|
+
# no async lock needed since we're not mutating the pending_cache
|
|
627
|
+
item = self._pending_cache.get(bundle_hash)
|
|
628
|
+
if not item and include_pending:
|
|
629
|
+
item = self._conflict_cache.get(bundle_hash)
|
|
630
|
+
|
|
631
|
+
return item
|
|
632
|
+
|
|
633
|
+
async def new_peak(
|
|
634
|
+
self, new_peak: Optional[BlockRecordProtocol], spent_coins: Optional[list[bytes32]]
|
|
635
|
+
) -> NewPeakInfo:
|
|
636
|
+
"""
|
|
637
|
+
Called when a new peak is available, we try to recreate a mempool for the new tip.
|
|
638
|
+
new_peak should always be the most recent *transaction* block of the chain. Since
|
|
639
|
+
the mempool cannot traverse the chain to find the most recent transaction block,
|
|
640
|
+
we wouldn't be able to detect, and correctly update the mempool, if we saw a
|
|
641
|
+
non-transaction block on a fork. self.peak must always be set to a transaction
|
|
642
|
+
block.
|
|
643
|
+
"""
|
|
644
|
+
if new_peak is None:
|
|
645
|
+
return NewPeakInfo([], [])
|
|
646
|
+
# we're only interested in transaction blocks
|
|
647
|
+
if new_peak.is_transaction_block is False:
|
|
648
|
+
return NewPeakInfo([], [])
|
|
649
|
+
if self.peak == new_peak:
|
|
650
|
+
return NewPeakInfo([], [])
|
|
651
|
+
assert new_peak.timestamp is not None
|
|
652
|
+
self.fee_estimator.new_block_height(new_peak.height)
|
|
653
|
+
included_items: list[MempoolItemInfo] = []
|
|
654
|
+
|
|
655
|
+
expired = self.mempool.new_tx_block(new_peak.height, new_peak.timestamp)
|
|
656
|
+
mempool_item_removals: list[MempoolRemoveInfo] = [expired]
|
|
657
|
+
|
|
658
|
+
use_optimization: bool = self.peak is not None and new_peak.prev_transaction_block_hash == self.peak.header_hash
|
|
659
|
+
self.peak = new_peak
|
|
660
|
+
|
|
661
|
+
if use_optimization and spent_coins is not None:
|
|
662
|
+
# We don't reinitialize a mempool, just kick removed items
|
|
663
|
+
# transactions in the mempool may be spending multiple coins,
|
|
664
|
+
# when looking up transactions by all coin IDs, we're likely to
|
|
665
|
+
# find the same transaction multiple times. We put them in a set
|
|
666
|
+
# to deduplicate
|
|
667
|
+
spendbundle_ids_to_remove: set[bytes32] = set()
|
|
668
|
+
for spend in spent_coins:
|
|
669
|
+
items = self.mempool.get_items_by_coin_id(spend)
|
|
670
|
+
for item in items:
|
|
671
|
+
included_items.append(MempoolItemInfo(item.cost, item.fee, item.height_added_to_mempool))
|
|
672
|
+
self.remove_seen(item.name)
|
|
673
|
+
spendbundle_ids_to_remove.add(item.name)
|
|
674
|
+
mempool_item_removals.append(
|
|
675
|
+
self.mempool.remove_from_pool(list(spendbundle_ids_to_remove), MempoolRemoveReason.BLOCK_INCLUSION)
|
|
676
|
+
)
|
|
677
|
+
else:
|
|
678
|
+
log.warning(
|
|
679
|
+
"updating the mempool using the slow-path. "
|
|
680
|
+
f"peak: {self.peak.header_hash.hex()} "
|
|
681
|
+
f"new-peak-prev: {new_peak.prev_transaction_block_hash} "
|
|
682
|
+
f"coins: {'not set' if spent_coins is None else 'set'}"
|
|
683
|
+
)
|
|
684
|
+
old_pool = self.mempool
|
|
685
|
+
self.mempool = Mempool(old_pool.mempool_info, old_pool.fee_estimator)
|
|
686
|
+
self.seen_bundle_hashes = {}
|
|
687
|
+
|
|
688
|
+
# in order to make this a bit quicker, we look-up all the spends in
|
|
689
|
+
# a single query, rather than one at a time.
|
|
690
|
+
coin_records: dict[bytes32, CoinRecord] = {}
|
|
691
|
+
|
|
692
|
+
removals: set[bytes32] = set()
|
|
693
|
+
for item in old_pool.all_items():
|
|
694
|
+
for s in item.spend_bundle.coin_spends:
|
|
695
|
+
removals.add(s.coin.name())
|
|
696
|
+
|
|
697
|
+
for record in await self.get_coin_records(removals):
|
|
698
|
+
name = record.coin.name()
|
|
699
|
+
coin_records[name] = record
|
|
700
|
+
|
|
701
|
+
async def local_get_coin_records(names: Collection[bytes32]) -> list[CoinRecord]:
|
|
702
|
+
ret: list[CoinRecord] = []
|
|
703
|
+
for name in names:
|
|
704
|
+
r = coin_records.get(name)
|
|
705
|
+
if r is not None:
|
|
706
|
+
ret.append(r)
|
|
707
|
+
return ret
|
|
708
|
+
|
|
709
|
+
for item in old_pool.all_items():
|
|
710
|
+
info = await self.add_spend_bundle(
|
|
711
|
+
item.spend_bundle,
|
|
712
|
+
item.conds,
|
|
713
|
+
item.spend_bundle_name,
|
|
714
|
+
item.height_added_to_mempool,
|
|
715
|
+
local_get_coin_records,
|
|
716
|
+
)
|
|
717
|
+
# Only add to `seen` if inclusion worked, so it can be resubmitted in case of a reorg
|
|
718
|
+
if info.status == MempoolInclusionStatus.SUCCESS:
|
|
719
|
+
self.add_and_maybe_pop_seen(item.spend_bundle_name)
|
|
720
|
+
# If the spend bundle was confirmed or conflicting (can no longer be in mempool), it won't be
|
|
721
|
+
# successfully added to the new mempool.
|
|
722
|
+
if info.status == MempoolInclusionStatus.FAILED and info.error == Err.DOUBLE_SPEND:
|
|
723
|
+
# Item was in mempool, but after the new block it's a double spend.
|
|
724
|
+
# Item is most likely included in the block.
|
|
725
|
+
included_items.append(MempoolItemInfo(item.cost, item.fee, item.height_added_to_mempool))
|
|
726
|
+
|
|
727
|
+
potential_txs = self._pending_cache.drain(new_peak.height)
|
|
728
|
+
potential_txs.update(self._conflict_cache.drain())
|
|
729
|
+
txs_added = []
|
|
730
|
+
for item in potential_txs.values():
|
|
731
|
+
info = await self.add_spend_bundle(
|
|
732
|
+
item.spend_bundle,
|
|
733
|
+
item.conds,
|
|
734
|
+
item.spend_bundle_name,
|
|
735
|
+
item.height_added_to_mempool,
|
|
736
|
+
self.get_coin_records,
|
|
737
|
+
)
|
|
738
|
+
if info.status == MempoolInclusionStatus.SUCCESS:
|
|
739
|
+
txs_added.append(NewPeakItem(item.spend_bundle_name, item.spend_bundle, item.conds))
|
|
740
|
+
mempool_item_removals.extend(info.removals)
|
|
741
|
+
log.info(
|
|
742
|
+
f"Size of mempool: {self.mempool.size()} spends, "
|
|
743
|
+
f"cost: {self.mempool.total_mempool_cost()} "
|
|
744
|
+
f"minimum fee rate (in FPC) to get in for 5M cost tx: {self.mempool.get_min_fee_rate(5000000)}"
|
|
745
|
+
)
|
|
746
|
+
self.mempool.fee_estimator.new_block(FeeBlockInfo(new_peak.height, included_items))
|
|
747
|
+
return NewPeakInfo(txs_added, mempool_item_removals)
|
|
748
|
+
|
|
749
|
+
def get_items_not_in_filter(self, mempool_filter: PyBIP158, limit: int = 100) -> list[SpendBundle]:
|
|
750
|
+
items: list[SpendBundle] = []
|
|
751
|
+
|
|
752
|
+
assert limit > 0
|
|
753
|
+
|
|
754
|
+
# Send 100 with the highest fee per cost
|
|
755
|
+
for item in self.mempool.items_by_feerate():
|
|
756
|
+
if len(items) >= limit:
|
|
757
|
+
return items
|
|
758
|
+
if mempool_filter.Match(bytearray(item.spend_bundle_name)):
|
|
759
|
+
continue
|
|
760
|
+
items.append(item.spend_bundle)
|
|
761
|
+
|
|
762
|
+
return items
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
T = TypeVar("T", uint32, uint64)
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
def optional_min(a: Optional[T], b: Optional[T]) -> Optional[T]:
|
|
769
|
+
return min((v for v in [a, b] if v is not None), default=None)
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
def optional_max(a: Optional[T], b: Optional[T]) -> Optional[T]:
|
|
773
|
+
return max((v for v in [a, b] if v is not None), default=None)
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
def can_replace(
|
|
777
|
+
conflicting_items: list[MempoolItem],
|
|
778
|
+
removal_names: set[bytes32],
|
|
779
|
+
new_item: MempoolItem,
|
|
780
|
+
) -> bool:
|
|
781
|
+
"""
|
|
782
|
+
This function implements the mempool replacement rules. Given a Mempool item
|
|
783
|
+
we're attempting to insert into the mempool (new_item) and the set of existing
|
|
784
|
+
mempool items that conflict with it, this function answers the question whether
|
|
785
|
+
the existing items can be replaced by the new one. The removals parameter are
|
|
786
|
+
the coin IDs the new mempool item is spending.
|
|
787
|
+
"""
|
|
788
|
+
|
|
789
|
+
conflicting_fees = 0
|
|
790
|
+
conflicting_cost = 0
|
|
791
|
+
assert_height: Optional[uint32] = None
|
|
792
|
+
assert_before_height: Optional[uint32] = None
|
|
793
|
+
assert_before_seconds: Optional[uint64] = None
|
|
794
|
+
for item in conflicting_items:
|
|
795
|
+
conflicting_fees += item.fee
|
|
796
|
+
conflicting_cost += item.cost
|
|
797
|
+
|
|
798
|
+
# All coins spent in all conflicting items must also be spent in the new item. (superset rule). This is
|
|
799
|
+
# important because otherwise there exists an attack. A user spends coin A. An attacker replaces the
|
|
800
|
+
# bundle with AB with a higher fee. An attacker then replaces the bundle with just B with a higher
|
|
801
|
+
# fee than AB therefore kicking out A altogether. The better way to solve this would be to keep a cache
|
|
802
|
+
# of booted transactions like A, and retry them after they get removed from mempool due to a conflict.
|
|
803
|
+
for coin in item.removals:
|
|
804
|
+
if coin.name() not in removal_names:
|
|
805
|
+
log.debug(f"Rejecting conflicting tx as it does not spend conflicting coin {coin.name()}")
|
|
806
|
+
return False
|
|
807
|
+
|
|
808
|
+
assert_height = optional_max(assert_height, item.assert_height)
|
|
809
|
+
assert_before_height = optional_min(assert_before_height, item.assert_before_height)
|
|
810
|
+
assert_before_seconds = optional_min(assert_before_seconds, item.assert_before_seconds)
|
|
811
|
+
|
|
812
|
+
# New item must have higher fee per cost
|
|
813
|
+
conflicting_fees_per_cost = conflicting_fees / conflicting_cost
|
|
814
|
+
if new_item.fee_per_cost <= conflicting_fees_per_cost:
|
|
815
|
+
log.debug(
|
|
816
|
+
f"Rejecting conflicting tx due to not increasing fees per cost "
|
|
817
|
+
f"({new_item.fee_per_cost} <= {conflicting_fees_per_cost})"
|
|
818
|
+
)
|
|
819
|
+
return False
|
|
820
|
+
|
|
821
|
+
# New item must increase the total fee at least by a certain amount
|
|
822
|
+
fee_increase = new_item.fee - conflicting_fees
|
|
823
|
+
if fee_increase < MEMPOOL_MIN_FEE_INCREASE:
|
|
824
|
+
log.debug(f"Rejecting conflicting tx due to low fee increase ({fee_increase})")
|
|
825
|
+
return False
|
|
826
|
+
|
|
827
|
+
# New item may not have a different effective height/time lock (time-lock rule)
|
|
828
|
+
if new_item.assert_height != assert_height:
|
|
829
|
+
log.debug(
|
|
830
|
+
"Rejecting conflicting tx due to changing ASSERT_HEIGHT constraints %s -> %s",
|
|
831
|
+
assert_height,
|
|
832
|
+
new_item.assert_height,
|
|
833
|
+
)
|
|
834
|
+
return False
|
|
835
|
+
|
|
836
|
+
if new_item.assert_before_height != assert_before_height:
|
|
837
|
+
log.debug(
|
|
838
|
+
"Rejecting conflicting tx due to changing ASSERT_BEFORE_HEIGHT constraints %s -> %s",
|
|
839
|
+
assert_before_height,
|
|
840
|
+
new_item.assert_before_height,
|
|
841
|
+
)
|
|
842
|
+
return False
|
|
843
|
+
|
|
844
|
+
if new_item.assert_before_seconds != assert_before_seconds:
|
|
845
|
+
log.debug(
|
|
846
|
+
"Rejecting conflicting tx due to changing ASSERT_BEFORE_SECONDS constraints %s -> %s",
|
|
847
|
+
assert_before_seconds,
|
|
848
|
+
new_item.assert_before_seconds,
|
|
849
|
+
)
|
|
850
|
+
return False
|
|
851
|
+
|
|
852
|
+
log.info(f"Replacing conflicting tx in mempool. New tx fee: {new_item.fee}, old tx fees: {conflicting_fees}")
|
|
853
|
+
return True
|