chia-blockchain 2.5.4rc1__py3-none-any.whl → 2.5.5__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/_tests/blockchain/blockchain_test_utils.py +2 -3
- chia/_tests/blockchain/test_augmented_chain.py +2 -3
- chia/_tests/blockchain/test_blockchain.py +261 -44
- chia/_tests/blockchain/test_blockchain_transactions.py +4 -3
- chia/_tests/blockchain/test_build_chains.py +197 -1
- chia/_tests/blockchain/test_get_block_generator.py +1 -1
- chia/_tests/blockchain/test_lookup_fork_chain.py +1 -1
- chia/_tests/clvm/benchmark_costs.py +1 -1
- chia/_tests/clvm/coin_store.py +3 -4
- chia/_tests/clvm/test_message_conditions.py +2 -2
- chia/_tests/clvm/test_puzzle_compression.py +2 -3
- chia/_tests/clvm/test_puzzles.py +1 -2
- chia/_tests/clvm/test_singletons.py +2 -3
- chia/_tests/clvm/test_spend_sim.py +7 -7
- chia/_tests/cmds/cmd_test_utils.py +30 -25
- chia/_tests/cmds/test_dev_gh.py +1 -1
- chia/_tests/cmds/test_farm_cmd.py +1 -1
- chia/_tests/cmds/test_show.py +1 -2
- chia/_tests/cmds/wallet/test_did.py +101 -56
- chia/_tests/cmds/wallet/test_nft.py +109 -84
- chia/_tests/cmds/wallet/test_notifications.py +1 -1
- chia/_tests/cmds/wallet/test_offer.toffer +1 -1
- chia/_tests/cmds/wallet/test_vcs.py +8 -8
- chia/_tests/cmds/wallet/test_wallet.py +100 -46
- chia/_tests/conftest.py +31 -20
- chia/_tests/connection_utils.py +1 -1
- chia/_tests/core/consensus/stores/__init__.py +0 -0
- chia/_tests/core/consensus/stores/test_coin_store_protocol.py +40 -0
- chia/_tests/core/consensus/test_block_creation.py +2 -31
- chia/_tests/core/consensus/test_pot_iterations.py +38 -3
- chia/_tests/core/custom_types/test_proof_of_space.py +154 -26
- chia/_tests/core/custom_types/test_spend_bundle.py +2 -3
- chia/_tests/core/daemon/test_daemon.py +80 -0
- chia/_tests/core/data_layer/test_data_layer.py +1 -1
- chia/_tests/core/data_layer/test_data_layer_util.py +1 -1
- chia/_tests/core/data_layer/test_data_rpc.py +14 -10
- chia/_tests/core/data_layer/test_data_store.py +5 -5
- chia/_tests/core/farmer/test_farmer_api.py +2 -2
- chia/_tests/core/full_node/full_sync/test_full_sync.py +446 -406
- chia/_tests/core/full_node/ram_db.py +3 -1
- chia/_tests/core/full_node/stores/test_block_store.py +28 -16
- chia/_tests/core/full_node/stores/test_coin_store.py +277 -185
- chia/_tests/core/full_node/stores/test_full_node_store.py +11 -4
- chia/_tests/core/full_node/stores/test_hint_store.py +2 -2
- chia/_tests/core/full_node/test_address_manager.py +200 -27
- chia/_tests/core/full_node/test_block_height_map.py +2 -2
- chia/_tests/core/full_node/test_conditions.py +7 -6
- chia/_tests/core/full_node/test_full_node.py +456 -40
- chia/_tests/core/full_node/test_generator_tools.py +32 -2
- chia/_tests/core/full_node/test_hint_management.py +1 -1
- chia/_tests/core/full_node/test_node_load.py +20 -21
- chia/_tests/core/full_node/test_performance.py +3 -4
- chia/_tests/core/full_node/test_prev_tx_block.py +43 -0
- chia/_tests/core/full_node/test_subscriptions.py +1 -2
- chia/_tests/core/full_node/test_transactions.py +9 -5
- chia/_tests/core/full_node/test_tx_processing_queue.py +1 -2
- chia/_tests/core/large_block.py +1 -2
- chia/_tests/core/make_block_generator.py +3 -4
- chia/_tests/core/mempool/test_mempool.py +36 -86
- chia/_tests/core/mempool/test_mempool_fee_estimator.py +1 -1
- chia/_tests/core/mempool/test_mempool_item_queries.py +1 -3
- chia/_tests/core/mempool/test_mempool_manager.py +529 -69
- chia/_tests/core/mempool/test_mempool_performance.py +3 -2
- chia/_tests/core/mempool/test_singleton_fast_forward.py +61 -132
- chia/_tests/core/server/flood.py +1 -1
- chia/_tests/core/server/test_dos.py +1 -1
- chia/_tests/core/server/test_node_discovery.py +41 -27
- chia/_tests/core/server/test_rate_limits.py +1 -1
- chia/_tests/core/server/test_server.py +1 -1
- chia/_tests/core/services/test_services.py +5 -5
- chia/_tests/core/ssl/test_ssl.py +1 -1
- chia/_tests/core/test_cost_calculation.py +6 -6
- chia/_tests/core/test_crawler.py +2 -2
- chia/_tests/core/test_crawler_rpc.py +1 -1
- chia/_tests/core/test_db_conversion.py +3 -1
- chia/_tests/core/test_db_validation.py +5 -3
- chia/_tests/core/test_farmer_harvester_rpc.py +15 -15
- chia/_tests/core/test_filter.py +4 -1
- chia/_tests/core/test_full_node_rpc.py +99 -82
- chia/_tests/core/test_program.py +2 -2
- chia/_tests/core/util/test_block_cache.py +1 -1
- chia/_tests/core/util/test_keychain.py +2 -2
- chia/_tests/core/util/test_lockfile.py +1 -1
- chia/_tests/core/util/test_log_exceptions.py +5 -5
- chia/_tests/core/util/test_streamable.py +81 -22
- chia/_tests/db/test_db_wrapper.py +1 -3
- chia/_tests/environments/wallet.py +5 -5
- chia/_tests/farmer_harvester/test_farmer.py +9 -7
- chia/_tests/farmer_harvester/test_farmer_harvester.py +11 -4
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +6 -5
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +15 -9
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +1 -2
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +7 -5
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +1 -1
- chia/_tests/generator/test_compression.py +1 -2
- chia/_tests/generator/test_rom.py +8 -4
- chia/_tests/plot_sync/test_plot_sync.py +3 -3
- chia/_tests/plot_sync/test_receiver.py +3 -3
- chia/_tests/plot_sync/test_sender.py +1 -1
- chia/_tests/plot_sync/test_sync_simulated.py +3 -3
- chia/_tests/plot_sync/util.py +2 -2
- chia/_tests/pools/test_pool_cmdline.py +48 -21
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +2 -3
- chia/_tests/pools/test_pool_rpc.py +237 -105
- chia/_tests/pools/test_pool_wallet.py +11 -2
- chia/_tests/pools/test_wallet_pool_store.py +5 -4
- chia/_tests/rpc/test_rpc_client.py +1 -1
- chia/_tests/simulation/test_simulation.py +13 -8
- chia/_tests/simulation/test_simulator.py +2 -2
- chia/_tests/timelord/test_new_peak.py +191 -47
- chia/_tests/timelord/test_timelord.py +1 -1
- chia/_tests/tools/test_full_sync.py +0 -2
- chia/_tests/tools/test_run_block.py +3 -1
- chia/_tests/util/benchmark_cost.py +3 -3
- chia/_tests/util/benchmarks.py +2 -2
- chia/_tests/util/blockchain.py +11 -5
- chia/_tests/util/blockchain_mock.py +1 -4
- chia/_tests/util/coin_store.py +29 -0
- chia/_tests/util/constants.py +2 -18
- chia/_tests/util/full_sync.py +3 -3
- chia/_tests/util/generator_tools_testing.py +2 -3
- chia/_tests/util/key_tool.py +2 -3
- chia/_tests/util/misc.py +33 -31
- chia/_tests/util/network_protocol_data.py +19 -17
- chia/_tests/util/protocol_messages_bytes-v1.0 +0 -0
- chia/_tests/util/protocol_messages_json.py +3 -1
- chia/_tests/util/run_block.py +2 -2
- chia/_tests/util/setup_nodes.py +7 -7
- chia/_tests/util/spend_sim.py +47 -55
- chia/_tests/util/test_condition_tools.py +5 -4
- chia/_tests/util/test_config.py +2 -2
- chia/_tests/util/test_dump_keyring.py +1 -1
- chia/_tests/util/test_full_block_utils.py +12 -14
- chia/_tests/util/test_misc.py +2 -2
- chia/_tests/util/test_paginator.py +4 -4
- chia/_tests/util/test_priority_mutex.py +2 -2
- chia/_tests/util/test_replace_str_to_bytes.py +15 -5
- chia/_tests/util/test_ssl_check.py +1 -1
- chia/_tests/util/test_testnet_overrides.py +13 -3
- chia/_tests/util/time_out_assert.py +4 -2
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +1 -1
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +1 -2
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +352 -432
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +3 -6
- chia/_tests/wallet/cat_wallet/test_trades.py +53 -77
- chia/_tests/wallet/clawback/test_clawback_decorator.py +3 -1
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +3 -3
- chia/_tests/wallet/clawback/test_clawback_metadata.py +4 -2
- chia/_tests/wallet/conftest.py +11 -12
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +11 -4
- chia/_tests/wallet/db_wallet/test_dl_offers.py +433 -130
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +3 -3
- chia/_tests/wallet/did_wallet/test_did.py +2132 -2000
- chia/_tests/wallet/nft_wallet/config.py +1 -1
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +1610 -742
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +486 -907
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +4 -4
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +517 -294
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +133 -62
- chia/_tests/wallet/rpc/test_wallet_rpc.py +495 -265
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +10 -6
- chia/_tests/wallet/sync/test_wallet_sync.py +89 -60
- chia/_tests/wallet/test_clvm_casts.py +88 -0
- chia/_tests/wallet/test_coin_management.py +1 -1
- chia/_tests/wallet/test_coin_selection.py +1 -1
- chia/_tests/wallet/test_conditions.py +1 -1
- chia/_tests/wallet/test_new_wallet_protocol.py +13 -11
- chia/_tests/wallet/test_notifications.py +5 -3
- chia/_tests/wallet/test_sign_coin_spends.py +6 -6
- chia/_tests/wallet/test_signer_protocol.py +13 -12
- chia/_tests/wallet/test_singleton.py +1 -1
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +5 -7
- chia/_tests/wallet/test_util.py +2 -2
- chia/_tests/wallet/test_wallet.py +108 -29
- chia/_tests/wallet/test_wallet_action_scope.py +9 -2
- chia/_tests/wallet/test_wallet_blockchain.py +2 -3
- chia/_tests/wallet/test_wallet_key_val_store.py +1 -2
- chia/_tests/wallet/test_wallet_node.py +2 -4
- chia/_tests/wallet/test_wallet_retry.py +4 -2
- chia/_tests/wallet/test_wallet_state_manager.py +191 -5
- chia/_tests/wallet/test_wallet_test_framework.py +1 -1
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +8 -8
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +29 -12
- chia/_tests/wallet/wallet_block_tools.py +6 -6
- chia/_tests/weight_proof/test_weight_proof.py +10 -48
- chia/apis.py +1 -1
- chia/cmds/beta.py +1 -1
- chia/cmds/chia.py +9 -9
- chia/cmds/cmd_classes.py +12 -11
- chia/cmds/cmd_helpers.py +1 -1
- chia/cmds/cmds_util.py +12 -9
- chia/cmds/coin_funcs.py +2 -2
- chia/cmds/configure.py +2 -2
- chia/cmds/data.py +0 -2
- chia/cmds/data_funcs.py +1 -1
- chia/cmds/db_validate_func.py +1 -2
- chia/cmds/dev/__init__.py +0 -0
- chia/cmds/dev/data.py +273 -0
- chia/cmds/{gh.py → dev/gh.py} +5 -5
- chia/cmds/dev/main.py +22 -0
- chia/cmds/dev/mempool.py +78 -0
- chia/cmds/dev/mempool_funcs.py +63 -0
- chia/cmds/farm_funcs.py +5 -4
- chia/cmds/init_funcs.py +11 -11
- chia/cmds/keys.py +2 -2
- chia/cmds/keys_funcs.py +4 -4
- chia/cmds/netspace_funcs.py +1 -1
- chia/cmds/peer_funcs.py +2 -2
- chia/cmds/plotnft_funcs.py +72 -26
- chia/cmds/rpc.py +1 -1
- chia/cmds/show_funcs.py +5 -5
- chia/cmds/signer.py +8 -7
- chia/cmds/sim_funcs.py +8 -9
- chia/cmds/wallet.py +2 -2
- chia/cmds/wallet_funcs.py +165 -131
- chia/{util → consensus}/augmented_chain.py +1 -2
- chia/consensus/block_body_validation.py +54 -40
- chia/consensus/block_creation.py +42 -76
- chia/consensus/block_header_validation.py +32 -26
- chia/consensus/block_record.py +0 -3
- chia/consensus/blockchain.py +23 -32
- chia/consensus/blockchain_interface.py +1 -5
- chia/consensus/check_time_locks.py +57 -0
- chia/consensus/coin_store_protocol.py +151 -0
- chia/consensus/coinbase.py +0 -6
- chia/consensus/condition_costs.py +4 -0
- chia/{util → consensus}/condition_tools.py +4 -5
- chia/consensus/cost_calculator.py +1 -1
- chia/consensus/default_constants.py +32 -9
- chia/consensus/deficit.py +1 -3
- chia/consensus/difficulty_adjustment.py +1 -2
- chia/consensus/find_fork_point.py +1 -3
- chia/consensus/full_block_to_block_record.py +1 -6
- chia/{util → consensus}/generator_tools.py +1 -3
- chia/consensus/get_block_challenge.py +30 -7
- chia/consensus/make_sub_epoch_summary.py +1 -5
- chia/consensus/multiprocess_validation.py +21 -20
- chia/consensus/pot_iterations.py +74 -13
- chia/{util → consensus}/prev_transaction_block.py +1 -1
- chia/consensus/vdf_info_computation.py +1 -3
- chia/daemon/keychain_proxy.py +5 -5
- chia/daemon/server.py +22 -5
- chia/data_layer/data_layer.py +92 -51
- chia/{rpc → data_layer}/data_layer_rpc_api.py +1 -1
- chia/{rpc → data_layer}/data_layer_rpc_util.py +3 -6
- chia/data_layer/data_layer_util.py +4 -6
- chia/data_layer/data_layer_wallet.py +42 -69
- chia/data_layer/dl_wallet_store.py +12 -6
- chia/data_layer/download_data.py +3 -3
- chia/data_layer/s3_plugin_service.py +0 -1
- chia/farmer/farmer.py +3 -4
- chia/farmer/farmer_api.py +11 -7
- chia/{rpc → farmer}/farmer_rpc_client.py +1 -1
- chia/full_node/block_height_map.py +7 -6
- chia/full_node/block_store.py +5 -7
- chia/full_node/bundle_tools.py +1 -2
- chia/full_node/coin_store.py +153 -124
- chia/{types → full_node}/eligible_coin_spends.py +39 -70
- chia/full_node/fee_estimator.py +1 -1
- chia/full_node/fee_estimator_interface.py +0 -8
- chia/full_node/fee_tracker.py +25 -25
- chia/full_node/full_node.py +70 -53
- chia/full_node/full_node_api.py +57 -40
- chia/{rpc → full_node}/full_node_rpc_api.py +87 -8
- chia/{rpc → full_node}/full_node_rpc_client.py +7 -6
- chia/full_node/full_node_store.py +23 -8
- chia/full_node/mempool.py +206 -53
- chia/full_node/mempool_check_conditions.py +20 -63
- chia/full_node/mempool_manager.py +53 -47
- chia/full_node/subscriptions.py +1 -3
- chia/full_node/tx_processing_queue.py +50 -3
- chia/full_node/weight_proof.py +46 -37
- chia/harvester/harvester.py +1 -1
- chia/harvester/harvester_api.py +22 -7
- chia/introducer/introducer.py +1 -1
- chia/introducer/introducer_api.py +1 -1
- chia/plot_sync/exceptions.py +1 -1
- chia/plot_sync/receiver.py +1 -1
- chia/plot_sync/sender.py +2 -2
- chia/pools/pool_puzzles.py +13 -18
- chia/pools/pool_wallet.py +23 -46
- chia/protocols/farmer_protocol.py +11 -3
- chia/protocols/full_node_protocol.py +1 -4
- chia/protocols/harvester_protocol.py +3 -3
- chia/protocols/pool_protocol.py +1 -2
- chia/protocols/shared_protocol.py +3 -3
- chia/protocols/timelord_protocol.py +1 -3
- chia/protocols/wallet_protocol.py +3 -3
- chia/rpc/rpc_client.py +7 -8
- chia/rpc/rpc_server.py +3 -3
- chia/rpc/util.py +3 -1
- chia/seeder/crawler.py +1 -1
- chia/seeder/crawler_api.py +1 -1
- chia/seeder/dns_server.py +2 -0
- chia/seeder/start_crawler.py +3 -3
- chia/server/address_manager.py +286 -38
- chia/server/address_manager_store.py +0 -215
- chia/{types → server}/aliases.py +7 -7
- chia/server/api_protocol.py +1 -1
- chia/server/chia_policy.py +1 -1
- chia/server/node_discovery.py +76 -113
- chia/server/rate_limits.py +1 -1
- chia/server/resolve_peer_info.py +43 -0
- chia/server/server.py +5 -5
- chia/server/start_data_layer.py +4 -4
- chia/server/start_farmer.py +5 -4
- chia/server/start_full_node.py +5 -4
- chia/server/start_harvester.py +7 -5
- chia/server/start_introducer.py +2 -2
- chia/server/start_service.py +1 -1
- chia/server/start_timelord.py +7 -5
- chia/server/start_wallet.py +7 -5
- chia/server/ws_connection.py +1 -1
- chia/simulator/add_blocks_in_batches.py +2 -2
- chia/simulator/block_tools.py +245 -201
- chia/simulator/full_node_simulator.py +38 -10
- chia/simulator/setup_services.py +12 -12
- chia/simulator/simulator_full_node_rpc_api.py +2 -2
- chia/simulator/simulator_full_node_rpc_client.py +2 -2
- chia/simulator/simulator_test_tools.py +2 -2
- chia/simulator/start_simulator.py +1 -1
- chia/simulator/wallet_tools.py +10 -18
- chia/ssl/create_ssl.py +1 -1
- chia/timelord/iters_from_block.py +14 -14
- chia/timelord/timelord.py +15 -11
- chia/timelord/timelord_api.py +14 -2
- chia/timelord/timelord_state.py +20 -14
- chia/types/blockchain_format/program.py +53 -10
- chia/types/blockchain_format/proof_of_space.py +73 -19
- chia/types/coin_spend.py +3 -56
- chia/types/generator_types.py +28 -0
- chia/types/internal_mempool_item.py +1 -2
- chia/types/mempool_item.py +12 -7
- chia/types/unfinished_header_block.py +1 -2
- chia/types/validation_state.py +1 -2
- chia/types/weight_proof.py +1 -3
- chia/util/action_scope.py +3 -3
- chia/util/block_cache.py +1 -2
- chia/util/byte_types.py +1 -1
- chia/util/casts.py +21 -0
- chia/util/config.py +0 -37
- chia/util/db_wrapper.py +8 -1
- chia/util/errors.py +3 -2
- chia/util/initial-config.yaml +21 -5
- chia/util/keychain.py +6 -7
- chia/util/keyring_wrapper.py +5 -5
- chia/util/limited_semaphore.py +1 -1
- chia/util/priority_mutex.py +1 -1
- chia/util/streamable.py +63 -5
- chia/util/task_timing.py +1 -1
- chia/util/virtual_project_analysis.py +1 -1
- chia/wallet/cat_wallet/cat_info.py +7 -3
- chia/wallet/cat_wallet/cat_outer_puzzle.py +9 -5
- chia/wallet/cat_wallet/cat_utils.py +1 -1
- chia/wallet/cat_wallet/cat_wallet.py +44 -36
- chia/wallet/cat_wallet/lineage_store.py +7 -0
- chia/wallet/cat_wallet/r_cat_wallet.py +274 -0
- chia/wallet/conditions.py +5 -10
- chia/wallet/db_wallet/db_wallet_puzzles.py +4 -4
- chia/wallet/derivation_record.py +33 -0
- chia/wallet/derive_keys.py +3 -3
- chia/wallet/did_wallet/did_info.py +12 -3
- chia/wallet/did_wallet/did_wallet.py +132 -101
- chia/wallet/did_wallet/did_wallet_puzzles.py +9 -9
- chia/wallet/driver_protocol.py +3 -1
- chia/{types/spend_bundle.py → wallet/estimate_fees.py} +2 -7
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +5 -3
- chia/wallet/nft_wallet/nft_puzzle_utils.py +1 -1
- chia/wallet/nft_wallet/nft_wallet.py +69 -112
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +5 -3
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +6 -4
- chia/wallet/nft_wallet/transfer_program_puzzle.py +4 -2
- chia/wallet/nft_wallet/uncurry_nft.py +4 -6
- chia/wallet/notification_manager.py +2 -3
- chia/wallet/outer_puzzles.py +7 -2
- chia/wallet/puzzle_drivers.py +1 -1
- chia/wallet/puzzles/clawback/drivers.py +5 -4
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +1 -1
- chia/wallet/puzzles/singleton_top_layer.py +2 -1
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +2 -1
- chia/wallet/puzzles/tails.py +1 -3
- chia/wallet/signer_protocol.py +5 -6
- chia/wallet/singleton.py +5 -4
- chia/wallet/singleton_record.py +1 -1
- chia/wallet/trade_manager.py +18 -20
- chia/wallet/trade_record.py +3 -6
- chia/wallet/trading/offer.py +12 -13
- chia/wallet/uncurried_puzzle.py +2 -2
- chia/wallet/util/compute_additions.py +58 -0
- chia/wallet/util/compute_hints.py +3 -3
- chia/wallet/util/compute_memos.py +4 -4
- chia/wallet/util/curry_and_treehash.py +2 -1
- chia/wallet/util/debug_spend_bundle.py +1 -1
- chia/wallet/util/merkle_tree.py +1 -1
- chia/wallet/util/peer_request_cache.py +1 -2
- chia/wallet/util/tx_config.py +3 -8
- chia/wallet/util/wallet_sync_utils.py +10 -5
- chia/wallet/util/wallet_types.py +1 -0
- chia/wallet/vc_wallet/cr_cat_drivers.py +17 -18
- chia/wallet/vc_wallet/cr_cat_wallet.py +30 -28
- chia/wallet/vc_wallet/cr_outer_puzzle.py +5 -3
- chia/wallet/vc_wallet/vc_drivers.py +50 -8
- chia/wallet/vc_wallet/vc_store.py +3 -5
- chia/wallet/vc_wallet/vc_wallet.py +15 -22
- chia/wallet/wallet.py +36 -46
- chia/wallet/wallet_action_scope.py +73 -4
- chia/wallet/wallet_blockchain.py +1 -3
- chia/wallet/wallet_interested_store.py +1 -1
- chia/wallet/wallet_nft_store.py +3 -3
- chia/wallet/wallet_node.py +17 -16
- chia/wallet/wallet_node_api.py +4 -5
- chia/wallet/wallet_pool_store.py +1 -1
- chia/wallet/wallet_protocol.py +2 -0
- chia/wallet/wallet_puzzle_store.py +1 -1
- chia/{rpc → wallet}/wallet_request_types.py +670 -81
- chia/{rpc → wallet}/wallet_rpc_api.py +735 -766
- chia/{rpc → wallet}/wallet_rpc_client.py +268 -420
- chia/wallet/wallet_singleton_store.py +8 -7
- chia/wallet/wallet_spend_bundle.py +4 -3
- chia/wallet/wallet_state_manager.py +320 -191
- chia/wallet/wallet_weight_proof_handler.py +1 -2
- chia/wallet/wsm_apis.py +98 -0
- {chia_blockchain-2.5.4rc1.dist-info → chia_blockchain-2.5.5.dist-info}/METADATA +7 -7
- {chia_blockchain-2.5.4rc1.dist-info → chia_blockchain-2.5.5.dist-info}/RECORD +443 -436
- mozilla-ca/cacert.pem +3 -165
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +0 -145
- chia/cmds/dev.py +0 -18
- chia/types/blockchain_format/slots.py +0 -9
- chia/types/blockchain_format/sub_epoch_summary.py +0 -5
- chia/types/end_of_slot_bundle.py +0 -5
- chia/types/full_block.py +0 -5
- chia/types/header_block.py +0 -5
- chia/types/spend_bundle_conditions.py +0 -7
- chia/types/transaction_queue_entry.py +0 -56
- chia/types/unfinished_block.py +0 -5
- /chia/cmds/{installers.py → dev/installers.py} +0 -0
- /chia/cmds/{sim.py → dev/sim.py} +0 -0
- /chia/{util → cmds}/dump_keyring.py +0 -0
- /chia/{full_node → consensus}/signage_point.py +0 -0
- /chia/{rpc → data_layer}/data_layer_rpc_client.py +0 -0
- /chia/{rpc → farmer}/farmer_rpc_api.py +0 -0
- /chia/{util → full_node}/full_block_utils.py +0 -0
- /chia/{rpc → harvester}/harvester_rpc_api.py +0 -0
- /chia/{rpc → harvester}/harvester_rpc_client.py +0 -0
- /chia/{full_node → protocols}/fee_estimate.py +0 -0
- /chia/{server → protocols}/outbound_message.py +0 -0
- /chia/{rpc → seeder}/crawler_rpc_api.py +0 -0
- /chia/{util → simulator}/vdf_prover.py +0 -0
- /chia/{util → ssl}/ssl_check.py +0 -0
- /chia/{rpc → timelord}/timelord_rpc_api.py +0 -0
- {chia_blockchain-2.5.4rc1.dist-info → chia_blockchain-2.5.5.dist-info}/LICENSE +0 -0
- {chia_blockchain-2.5.4rc1.dist-info → chia_blockchain-2.5.5.dist-info}/WHEEL +0 -0
- {chia_blockchain-2.5.4rc1.dist-info → chia_blockchain-2.5.5.dist-info}/entry_points.txt +0 -0
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
4
|
+
import time
|
|
3
5
|
from datetime import datetime, timezone
|
|
4
6
|
from typing import TYPE_CHECKING, Any, ClassVar, Optional, cast
|
|
5
7
|
|
|
8
|
+
from chia_rs import (
|
|
9
|
+
MEMPOOL_MODE,
|
|
10
|
+
BlockRecord,
|
|
11
|
+
CoinSpend,
|
|
12
|
+
FullBlock,
|
|
13
|
+
PlotSize,
|
|
14
|
+
SpendBundle,
|
|
15
|
+
SpendBundleConditions,
|
|
16
|
+
run_block_generator2,
|
|
17
|
+
)
|
|
6
18
|
from chia_rs.sized_bytes import bytes32
|
|
7
19
|
from chia_rs.sized_ints import uint32, uint64, uint128
|
|
8
20
|
|
|
9
|
-
from chia.consensus.block_record import BlockRecord
|
|
10
21
|
from chia.consensus.blockchain import Blockchain, BlockchainMutexPriority
|
|
11
22
|
from chia.consensus.get_block_generator import get_block_generator
|
|
12
23
|
from chia.consensus.pos_quality import UI_ACTUAL_SPACE_CONSTANT_FACTOR
|
|
@@ -17,16 +28,12 @@ from chia.full_node.mempool_check_conditions import (
|
|
|
17
28
|
get_spends_for_block,
|
|
18
29
|
get_spends_for_block_with_conditions,
|
|
19
30
|
)
|
|
31
|
+
from chia.protocols.outbound_message import NodeType
|
|
20
32
|
from chia.rpc.rpc_server import Endpoint, EndpointResult
|
|
21
|
-
from chia.server.outbound_message import NodeType
|
|
22
33
|
from chia.types.blockchain_format.proof_of_space import calculate_prefix_bits
|
|
23
34
|
from chia.types.coin_record import CoinRecord
|
|
24
|
-
from chia.types.
|
|
25
|
-
from chia.types.full_block import FullBlock
|
|
26
|
-
from chia.types.generator_types import BlockGenerator
|
|
35
|
+
from chia.types.generator_types import BlockGenerator, NewBlockGenerator
|
|
27
36
|
from chia.types.mempool_inclusion_status import MempoolInclusionStatus
|
|
28
|
-
from chia.types.spend_bundle import SpendBundle
|
|
29
|
-
from chia.types.spend_bundle_conditions import SpendBundleConditions
|
|
30
37
|
from chia.types.unfinished_header_block import UnfinishedHeaderBlock
|
|
31
38
|
from chia.util.byte_types import hexstr_to_bytes
|
|
32
39
|
from chia.util.log_exceptions import log_exceptions
|
|
@@ -124,6 +131,7 @@ class FullNodeRpcApi:
|
|
|
124
131
|
"/get_all_mempool_items": self.get_all_mempool_items,
|
|
125
132
|
"/get_mempool_item_by_tx_id": self.get_mempool_item_by_tx_id,
|
|
126
133
|
"/get_mempool_items_by_coin_name": self.get_mempool_items_by_coin_name,
|
|
134
|
+
"/create_block_generator": self.create_block_generator,
|
|
127
135
|
# Fee estimation
|
|
128
136
|
"/get_fee_estimate": self.get_fee_estimate,
|
|
129
137
|
}
|
|
@@ -592,7 +600,9 @@ class FullNodeRpcApi:
|
|
|
592
600
|
raise ValueError(f"Older block {older_block_hex} not found")
|
|
593
601
|
delta_weight = newer_block.weight - older_block.weight
|
|
594
602
|
|
|
595
|
-
|
|
603
|
+
# TODO: todo_v2_plots Update this calculation to take v2 plots into
|
|
604
|
+
# account
|
|
605
|
+
plot_filter_size = calculate_prefix_bits(self.service.constants, newer_block.height, PlotSize.make_v1(32))
|
|
596
606
|
delta_iters = newer_block.total_iters - older_block.total_iters
|
|
597
607
|
weight_div_iters = delta_weight / delta_iters
|
|
598
608
|
additional_difficulty_constant = self.service.constants.DIFFICULTY_CONSTANT_FACTOR
|
|
@@ -836,6 +846,75 @@ class FullNodeRpcApi:
|
|
|
836
846
|
|
|
837
847
|
return {"mempool_items": [item.to_json_dict() for item in items]}
|
|
838
848
|
|
|
849
|
+
async def create_block_generator(self, _: dict[str, Any]) -> EndpointResult:
|
|
850
|
+
gen = NewBlockGenerator()
|
|
851
|
+
|
|
852
|
+
# Grab best transactions from Mempool for given tip target
|
|
853
|
+
async with self.service.blockchain.priority_mutex.acquire(priority=BlockchainMutexPriority.low):
|
|
854
|
+
peak: Optional[BlockRecord] = self.service.blockchain.get_peak()
|
|
855
|
+
|
|
856
|
+
if peak is None:
|
|
857
|
+
return {
|
|
858
|
+
"generator": gen.program,
|
|
859
|
+
"refs": gen.block_refs,
|
|
860
|
+
"additions": gen.additions,
|
|
861
|
+
"removals": gen.removals,
|
|
862
|
+
"sig": gen.signature,
|
|
863
|
+
"cost": gen.cost,
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
# Finds the last transaction block before this one
|
|
867
|
+
curr_l_tb: BlockRecord = peak
|
|
868
|
+
while not curr_l_tb.is_transaction_block:
|
|
869
|
+
curr_l_tb = self.service.blockchain.block_record(curr_l_tb.prev_hash)
|
|
870
|
+
|
|
871
|
+
self.service.log.info("Beginning simulated block construction from mempool")
|
|
872
|
+
start_time = time.monotonic()
|
|
873
|
+
|
|
874
|
+
try:
|
|
875
|
+
maybe_gen = self.service.mempool_manager.create_block_generator2(curr_l_tb.header_hash, 2.0)
|
|
876
|
+
if maybe_gen is None:
|
|
877
|
+
self.service.log.error(f"failed to create block generator, peak: {peak}")
|
|
878
|
+
else:
|
|
879
|
+
gen = maybe_gen
|
|
880
|
+
except Exception:
|
|
881
|
+
self.service.log.exception(f"Error creating block generator, peak: {peak}")
|
|
882
|
+
self.service.log.info(f"Simulated block constructed in {time.monotonic() - start_time:0.2f} seconds")
|
|
883
|
+
|
|
884
|
+
if maybe_gen is not None:
|
|
885
|
+
# this also validates the signature
|
|
886
|
+
err, conds = await asyncio.get_running_loop().run_in_executor(
|
|
887
|
+
self.service.blockchain.pool,
|
|
888
|
+
run_block_generator2,
|
|
889
|
+
bytes(gen.program),
|
|
890
|
+
gen.generator_refs,
|
|
891
|
+
self.service.constants.MAX_BLOCK_COST_CLVM,
|
|
892
|
+
MEMPOOL_MODE,
|
|
893
|
+
gen.signature,
|
|
894
|
+
None,
|
|
895
|
+
self.service.constants,
|
|
896
|
+
)
|
|
897
|
+
if err is not None:
|
|
898
|
+
self.service.log.error(f"failed to validate block: {err}")
|
|
899
|
+
else:
|
|
900
|
+
assert conds is not None
|
|
901
|
+
if conds.cost != gen.cost:
|
|
902
|
+
self.service.log.error(
|
|
903
|
+
f"invalid cost of generated block: {conds.cost} expected {gen.cost}"
|
|
904
|
+
f" exe-cost: {conds.execution_cost}"
|
|
905
|
+
f" cond-cost: {conds.condition_cost}"
|
|
906
|
+
)
|
|
907
|
+
# TODO: maybe validate additions and removals too
|
|
908
|
+
|
|
909
|
+
return {
|
|
910
|
+
"generator": gen.program,
|
|
911
|
+
"refs": gen.block_refs,
|
|
912
|
+
"additions": gen.additions,
|
|
913
|
+
"removals": gen.removals,
|
|
914
|
+
"sig": gen.signature,
|
|
915
|
+
"cost": gen.cost,
|
|
916
|
+
}
|
|
917
|
+
|
|
839
918
|
def _get_spendbundle_type_cost(self, name: str) -> uint64:
|
|
840
919
|
"""
|
|
841
920
|
This is a stopgap until we modify the wallet RPCs to get exact costs for created SpendBundles
|
|
@@ -2,17 +2,14 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Optional, cast
|
|
4
4
|
|
|
5
|
+
from chia_rs import BlockRecord, CoinSpend, EndOfSubSlotBundle, FullBlock, SpendBundle
|
|
5
6
|
from chia_rs.sized_bytes import bytes32
|
|
6
7
|
from chia_rs.sized_ints import uint32
|
|
7
8
|
|
|
8
|
-
from chia.consensus.
|
|
9
|
-
from chia.full_node.signage_point import SignagePoint
|
|
9
|
+
from chia.consensus.signage_point import SignagePoint
|
|
10
10
|
from chia.rpc.rpc_client import RpcClient
|
|
11
11
|
from chia.types.coin_record import CoinRecord
|
|
12
|
-
from chia.types.coin_spend import
|
|
13
|
-
from chia.types.end_of_slot_bundle import EndOfSubSlotBundle
|
|
14
|
-
from chia.types.full_block import FullBlock
|
|
15
|
-
from chia.types.spend_bundle import SpendBundle
|
|
12
|
+
from chia.types.coin_spend import CoinSpendWithConditions
|
|
16
13
|
from chia.types.unfinished_header_block import UnfinishedHeaderBlock
|
|
17
14
|
|
|
18
15
|
|
|
@@ -261,6 +258,10 @@ class FullNodeRpcClient(RpcClient):
|
|
|
261
258
|
response = await self.fetch("get_mempool_items_by_coin_name", {"coin_name": coin_name.hex()})
|
|
262
259
|
return response
|
|
263
260
|
|
|
261
|
+
async def create_block_generator(self) -> Optional[dict[str, Any]]:
|
|
262
|
+
response = await self.fetch("create_block_generator", {})
|
|
263
|
+
return response
|
|
264
|
+
|
|
264
265
|
async def get_recent_signage_point_or_eos(
|
|
265
266
|
self, sp_hash: Optional[bytes32], challenge_hash: Optional[bytes32]
|
|
266
267
|
) -> Optional[Any]:
|
|
@@ -6,24 +6,20 @@ import logging
|
|
|
6
6
|
import time
|
|
7
7
|
from typing import Optional
|
|
8
8
|
|
|
9
|
-
from chia_rs import ConsensusConstants
|
|
9
|
+
from chia_rs import BlockRecord, ConsensusConstants, EndOfSubSlotBundle, FullBlock, UnfinishedBlock
|
|
10
10
|
from chia_rs.sized_bytes import bytes32
|
|
11
11
|
from chia_rs.sized_ints import uint8, uint32, uint64, uint128
|
|
12
12
|
|
|
13
|
-
from chia.consensus.block_record import BlockRecord
|
|
14
13
|
from chia.consensus.blockchain_interface import BlockRecordsProtocol
|
|
15
14
|
from chia.consensus.difficulty_adjustment import can_finish_sub_and_full_epoch
|
|
16
15
|
from chia.consensus.make_sub_epoch_summary import make_sub_epoch_summary
|
|
17
16
|
from chia.consensus.multiprocess_validation import PreValidationResult
|
|
18
17
|
from chia.consensus.pot_iterations import calculate_sp_interval_iters
|
|
19
|
-
from chia.
|
|
18
|
+
from chia.consensus.signage_point import SignagePoint
|
|
20
19
|
from chia.protocols import timelord_protocol
|
|
21
|
-
from chia.
|
|
20
|
+
from chia.protocols.outbound_message import Message
|
|
22
21
|
from chia.types.blockchain_format.classgroup import ClassgroupElement
|
|
23
22
|
from chia.types.blockchain_format.vdf import VDFInfo, validate_vdf
|
|
24
|
-
from chia.types.end_of_slot_bundle import EndOfSubSlotBundle
|
|
25
|
-
from chia.types.full_block import FullBlock
|
|
26
|
-
from chia.types.unfinished_block import UnfinishedBlock
|
|
27
23
|
from chia.util.lru_cache import LRUCache
|
|
28
24
|
from chia.util.streamable import Streamable, streamable
|
|
29
25
|
|
|
@@ -833,6 +829,25 @@ class FullNodeStore:
|
|
|
833
829
|
return sp
|
|
834
830
|
return None
|
|
835
831
|
|
|
832
|
+
def get_signage_point_by_index_and_cc_output(
|
|
833
|
+
self, cc_signage_point: bytes32, challenge: bytes32, index: uint8
|
|
834
|
+
) -> Optional[SignagePoint]:
|
|
835
|
+
assert len(self.finished_sub_slots) >= 1
|
|
836
|
+
if cc_signage_point == self.constants.GENESIS_CHALLENGE:
|
|
837
|
+
return SignagePoint(None, None, None, None)
|
|
838
|
+
for sub_slot, sps, _ in self.finished_sub_slots:
|
|
839
|
+
if sub_slot is not None and sub_slot.challenge_chain.get_hash() == challenge:
|
|
840
|
+
if index == 0:
|
|
841
|
+
# first SP in the sub slot
|
|
842
|
+
return SignagePoint(None, None, None, None)
|
|
843
|
+
sp: Optional[SignagePoint] = sps[index]
|
|
844
|
+
if sp is None:
|
|
845
|
+
return None
|
|
846
|
+
assert sp.cc_vdf is not None
|
|
847
|
+
if sp.cc_vdf.output.get_hash() == cc_signage_point:
|
|
848
|
+
return sp
|
|
849
|
+
return None
|
|
850
|
+
|
|
836
851
|
def get_signage_point_by_index(
|
|
837
852
|
self, challenge_hash: bytes32, index: uint8, last_rc_infusion: bytes32
|
|
838
853
|
) -> Optional[SignagePoint]:
|
|
@@ -867,7 +882,7 @@ class FullNodeStore:
|
|
|
867
882
|
|
|
868
883
|
if cc_hash == challenge_hash:
|
|
869
884
|
found_rc_hash = False
|
|
870
|
-
for i in range(
|
|
885
|
+
for i in range(index):
|
|
871
886
|
sp: Optional[SignagePoint] = sps[i]
|
|
872
887
|
if sp is not None and sp.rc_vdf is not None and sp.rc_vdf.challenge == last_rc_infusion:
|
|
873
888
|
found_rc_hash = True
|
chia/full_node/mempool.py
CHANGED
|
@@ -2,28 +2,43 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import sqlite3
|
|
5
|
-
from collections.abc import
|
|
5
|
+
from collections.abc import Iterator
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from datetime import datetime
|
|
8
8
|
from enum import Enum
|
|
9
9
|
from time import monotonic
|
|
10
|
-
from typing import
|
|
11
|
-
|
|
12
|
-
from chia_rs import
|
|
10
|
+
from typing import Optional
|
|
11
|
+
|
|
12
|
+
from chia_rs import (
|
|
13
|
+
DONT_VALIDATE_SIGNATURE,
|
|
14
|
+
MEMPOOL_MODE,
|
|
15
|
+
AugSchemeMPL,
|
|
16
|
+
BlockBuilder,
|
|
17
|
+
Coin,
|
|
18
|
+
CoinSpend,
|
|
19
|
+
ConsensusConstants,
|
|
20
|
+
G2Element,
|
|
21
|
+
SpendBundle,
|
|
22
|
+
get_flags_for_height_and_constants,
|
|
23
|
+
run_block_generator2,
|
|
24
|
+
solution_generator_backrefs,
|
|
25
|
+
)
|
|
13
26
|
from chia_rs.sized_bytes import bytes32
|
|
14
27
|
from chia_rs.sized_ints import uint32, uint64
|
|
15
28
|
|
|
16
29
|
from chia.consensus.default_constants import DEFAULT_CONSTANTS
|
|
30
|
+
from chia.full_node.eligible_coin_spends import (
|
|
31
|
+
IdenticalSpendDedup,
|
|
32
|
+
SingletonFastForward,
|
|
33
|
+
SkipDedup,
|
|
34
|
+
)
|
|
17
35
|
from chia.full_node.fee_estimation import FeeMempoolInfo, MempoolInfo, MempoolItemInfo
|
|
18
36
|
from chia.full_node.fee_estimator_interface import FeeEstimatorInterface
|
|
19
37
|
from chia.types.blockchain_format.serialized_program import SerializedProgram
|
|
20
38
|
from chia.types.clvm_cost import CLVMCost
|
|
21
|
-
from chia.types.
|
|
22
|
-
from chia.types.eligible_coin_spends import EligibleCoinSpends, SkipDedup, UnspentLineageInfo
|
|
23
|
-
from chia.types.generator_types import BlockGenerator
|
|
39
|
+
from chia.types.generator_types import NewBlockGenerator
|
|
24
40
|
from chia.types.internal_mempool_item import InternalMempoolItem
|
|
25
41
|
from chia.types.mempool_item import MempoolItem
|
|
26
|
-
from chia.types.spend_bundle import SpendBundle
|
|
27
42
|
from chia.util.batches import to_batches
|
|
28
43
|
from chia.util.db_wrapper import SQLITE_MAX_VARIABLE_NUMBER
|
|
29
44
|
from chia.util.errors import Err
|
|
@@ -35,9 +50,9 @@ log = logging.getLogger(__name__)
|
|
|
35
50
|
# block we're trying to create.
|
|
36
51
|
MAX_SKIPPED_ITEMS = 10
|
|
37
52
|
|
|
38
|
-
# Threshold after which we stop including mempool items with
|
|
39
|
-
# during the creation of a block
|
|
40
|
-
# time on potentially expensive items.
|
|
53
|
+
# Threshold after which we stop including mempool items with fast-forward or
|
|
54
|
+
# dedup spends during the creation of a block generator. We do that to avoid
|
|
55
|
+
# spending too much time on potentially expensive items.
|
|
41
56
|
PRIORITY_TX_THRESHOLD = 3
|
|
42
57
|
|
|
43
58
|
# Typical cost of a standard XCH spend. It's used as a heuristic to help
|
|
@@ -459,8 +474,8 @@ class Mempool:
|
|
|
459
474
|
for coin_id, bcs in item.bundle_coin_spends.items():
|
|
460
475
|
# any FF spend should be indexed by its latest singleton coin
|
|
461
476
|
# ID, this way we'll find it when the singleton is spent
|
|
462
|
-
if bcs.
|
|
463
|
-
all_coin_spends.append((bcs.
|
|
477
|
+
if bcs.latest_singleton_lineage is not None:
|
|
478
|
+
all_coin_spends.append((bcs.latest_singleton_lineage.coin_id, item_name))
|
|
464
479
|
else:
|
|
465
480
|
all_coin_spends.append((coin_id, item_name))
|
|
466
481
|
conn.executemany("INSERT OR IGNORE INTO spends VALUES(?, ?)", all_coin_spends)
|
|
@@ -487,21 +502,18 @@ class Mempool:
|
|
|
487
502
|
|
|
488
503
|
return self._total_cost + cost > self.mempool_info.max_size_in_cost
|
|
489
504
|
|
|
490
|
-
|
|
505
|
+
def create_block_generator(
|
|
491
506
|
self,
|
|
492
|
-
get_unspent_lineage_info_for_puzzle_hash: Callable[[bytes32], Awaitable[Optional[UnspentLineageInfo]]],
|
|
493
507
|
constants: ConsensusConstants,
|
|
494
508
|
height: uint32,
|
|
495
|
-
|
|
496
|
-
) -> Optional[
|
|
509
|
+
timeout: float,
|
|
510
|
+
) -> Optional[NewBlockGenerator]:
|
|
497
511
|
"""
|
|
498
512
|
height is needed in case we fast-forward a transaction and we need to
|
|
499
513
|
re-run its puzzle.
|
|
500
514
|
"""
|
|
501
515
|
|
|
502
|
-
mempool_bundle =
|
|
503
|
-
get_unspent_lineage_info_for_puzzle_hash, constants, height, item_inclusion_filter
|
|
504
|
-
)
|
|
516
|
+
mempool_bundle = self.create_bundle_from_mempool_items(constants, height, timeout)
|
|
505
517
|
if mempool_bundle is None:
|
|
506
518
|
return None
|
|
507
519
|
|
|
@@ -519,35 +531,61 @@ class Mempool:
|
|
|
519
531
|
duration = monotonic() - start_time
|
|
520
532
|
log.log(
|
|
521
533
|
logging.INFO if duration < 1 else logging.WARNING,
|
|
522
|
-
f"serializing block generator took {duration:0.2f} seconds"
|
|
534
|
+
f"serializing block generator took {duration:0.2f} seconds "
|
|
535
|
+
f"spends: {len(removals)} additions: {len(additions)}",
|
|
523
536
|
)
|
|
524
|
-
|
|
525
|
-
|
|
537
|
+
|
|
538
|
+
flags = get_flags_for_height_and_constants(height, constants) | MEMPOOL_MODE | DONT_VALIDATE_SIGNATURE
|
|
539
|
+
|
|
540
|
+
err, conds = run_block_generator2(
|
|
541
|
+
block_program,
|
|
542
|
+
[],
|
|
543
|
+
constants.MAX_BLOCK_COST_CLVM,
|
|
544
|
+
flags,
|
|
545
|
+
spend_bundle.aggregated_signature,
|
|
546
|
+
None,
|
|
547
|
+
constants,
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
# this should not happen. This is essentially an assertion failure
|
|
551
|
+
if err is not None: # pragma: no cover
|
|
552
|
+
log.error(
|
|
553
|
+
f"Failed to compute block cost during farming: {err} "
|
|
554
|
+
f"height: {height} "
|
|
555
|
+
f"generator: {bytes(block_program).hex()}"
|
|
556
|
+
)
|
|
557
|
+
return None
|
|
558
|
+
|
|
559
|
+
assert conds is not None
|
|
560
|
+
assert conds.cost > 0
|
|
561
|
+
|
|
562
|
+
return NewBlockGenerator(
|
|
563
|
+
SerializedProgram.from_bytes(block_program),
|
|
564
|
+
[],
|
|
565
|
+
[],
|
|
526
566
|
spend_bundle.aggregated_signature,
|
|
527
567
|
additions,
|
|
528
568
|
removals,
|
|
569
|
+
uint64(conds.cost),
|
|
529
570
|
)
|
|
530
571
|
|
|
531
|
-
|
|
532
|
-
self,
|
|
533
|
-
get_unspent_lineage_info_for_puzzle_hash: Callable[[bytes32], Awaitable[Optional[UnspentLineageInfo]]],
|
|
534
|
-
constants: ConsensusConstants,
|
|
535
|
-
height: uint32,
|
|
536
|
-
item_inclusion_filter: Optional[Callable[[bytes32], bool]] = None,
|
|
572
|
+
def create_bundle_from_mempool_items(
|
|
573
|
+
self, constants: ConsensusConstants, height: uint32, timeout: float = 1.0
|
|
537
574
|
) -> Optional[tuple[SpendBundle, list[Coin]]]:
|
|
538
575
|
cost_sum = 0 # Checks that total cost does not exceed block maximum
|
|
539
576
|
fee_sum = 0 # Checks that total fees don't exceed 64 bits
|
|
540
577
|
processed_spend_bundles = 0
|
|
541
578
|
additions: list[Coin] = []
|
|
542
|
-
# This contains
|
|
543
|
-
#
|
|
544
|
-
#
|
|
545
|
-
#
|
|
546
|
-
#
|
|
547
|
-
|
|
548
|
-
#
|
|
549
|
-
#
|
|
550
|
-
|
|
579
|
+
# This contains a map of coin ID to a coin spend solution and its
|
|
580
|
+
# isolated cost. We reconstruct it for every bundle we create from
|
|
581
|
+
# mempool items because we deduplicate on the first coin spend solution
|
|
582
|
+
# that comes with the highest fee rate item, and that can change across
|
|
583
|
+
# calls.
|
|
584
|
+
dedup_coin_spends = IdenticalSpendDedup()
|
|
585
|
+
# This contains a map of fast forward eligible singleton puzzle hash to
|
|
586
|
+
# the most recent unspent singleton data, to allow chaining fast forward
|
|
587
|
+
# singleton spends.
|
|
588
|
+
singleton_ff = SingletonFastForward()
|
|
551
589
|
coin_spends: list[CoinSpend] = []
|
|
552
590
|
sigs: list[G2Element] = []
|
|
553
591
|
log.info(f"Starting to make block, max cost: {self.mempool_info.max_block_clvm_cost}")
|
|
@@ -560,11 +598,9 @@ class Mempool:
|
|
|
560
598
|
item = self._items[name]
|
|
561
599
|
|
|
562
600
|
current_time = monotonic()
|
|
563
|
-
if current_time - bundle_creation_start
|
|
601
|
+
if current_time - bundle_creation_start >= timeout:
|
|
564
602
|
log.info(f"exiting early, already spent {current_time - bundle_creation_start:0.2f} s")
|
|
565
603
|
break
|
|
566
|
-
if item_inclusion_filter is not None and not item_inclusion_filter(name):
|
|
567
|
-
continue
|
|
568
604
|
try:
|
|
569
605
|
assert item.conds is not None
|
|
570
606
|
cost = item.conds.cost
|
|
@@ -575,12 +611,9 @@ class Mempool:
|
|
|
575
611
|
# might fit, but we also want to avoid spending too much
|
|
576
612
|
# time on potentially expensive ones, hence this shortcut.
|
|
577
613
|
if any(
|
|
578
|
-
|
|
579
|
-
lambda spend_data: (spend_data.eligible_for_dedup or spend_data.eligible_for_fast_forward),
|
|
580
|
-
item.bundle_coin_spends.values(),
|
|
581
|
-
)
|
|
614
|
+
sd.eligible_for_dedup or sd.eligible_for_fast_forward for sd in item.bundle_coin_spends.values()
|
|
582
615
|
):
|
|
583
|
-
log.info("Skipping transaction with dedup or FF spends {item.name}")
|
|
616
|
+
log.info(f"Skipping transaction with dedup or FF spends {item.spend_bundle.name()}")
|
|
584
617
|
continue
|
|
585
618
|
|
|
586
619
|
unique_coin_spends = []
|
|
@@ -590,13 +623,10 @@ class Mempool:
|
|
|
590
623
|
unique_additions.extend(spend_data.additions)
|
|
591
624
|
cost_saving = 0
|
|
592
625
|
else:
|
|
593
|
-
bundle_coin_spends =
|
|
594
|
-
mempool_item=item,
|
|
595
|
-
get_unspent_lineage_info_for_puzzle_hash=get_unspent_lineage_info_for_puzzle_hash,
|
|
596
|
-
height=height,
|
|
597
|
-
constants=constants,
|
|
626
|
+
bundle_coin_spends = singleton_ff.process_fast_forward_spends(
|
|
627
|
+
mempool_item=item, height=height, constants=constants
|
|
598
628
|
)
|
|
599
|
-
unique_coin_spends, cost_saving, unique_additions =
|
|
629
|
+
unique_coin_spends, cost_saving, unique_additions = dedup_coin_spends.get_deduplication_info(
|
|
600
630
|
bundle_coin_spends=bundle_coin_spends, max_cost=cost
|
|
601
631
|
)
|
|
602
632
|
item_cost = cost - cost_saving
|
|
@@ -640,7 +670,7 @@ class Mempool:
|
|
|
640
670
|
log.info(f"Exception while checking a mempool item for deduplication: {e}")
|
|
641
671
|
skipped_items += 1
|
|
642
672
|
continue
|
|
643
|
-
if
|
|
673
|
+
if coin_spends == []:
|
|
644
674
|
return None
|
|
645
675
|
log.info(
|
|
646
676
|
f"Cumulative cost of block (real cost should be less) {cost_sum}. Proportion "
|
|
@@ -655,3 +685,126 @@ class Mempool:
|
|
|
655
685
|
f"create_bundle_from_mempool_items took {duration:0.4f} seconds",
|
|
656
686
|
)
|
|
657
687
|
return agg, additions
|
|
688
|
+
|
|
689
|
+
def create_block_generator2(
|
|
690
|
+
self, constants: ConsensusConstants, height: uint32, timeout: float
|
|
691
|
+
) -> Optional[NewBlockGenerator]:
|
|
692
|
+
fee_sum = 0 # Checks that total fees don't exceed 64 bits
|
|
693
|
+
additions: list[Coin] = []
|
|
694
|
+
removals: list[Coin] = []
|
|
695
|
+
|
|
696
|
+
dedup_coin_spends = IdenticalSpendDedup()
|
|
697
|
+
singleton_ff = SingletonFastForward()
|
|
698
|
+
log.info(f"Starting to make block, max cost: {self.mempool_info.max_block_clvm_cost}")
|
|
699
|
+
generator_creation_start = monotonic()
|
|
700
|
+
cursor = self._db_conn.execute("SELECT name, fee FROM tx ORDER BY fee_per_cost DESC, seq ASC")
|
|
701
|
+
builder = BlockBuilder()
|
|
702
|
+
skipped_items = 0
|
|
703
|
+
# the total (estimated) cost of the transactions added so far
|
|
704
|
+
block_cost = 0
|
|
705
|
+
added_spends = 0
|
|
706
|
+
|
|
707
|
+
batch_transactions: list[SpendBundle] = []
|
|
708
|
+
batch_additions: list[Coin] = []
|
|
709
|
+
batch_spends = 0
|
|
710
|
+
# this cost only includes conditions and execution cost, not byte-cost
|
|
711
|
+
batch_cost = 0
|
|
712
|
+
|
|
713
|
+
for row in cursor:
|
|
714
|
+
current_time = monotonic()
|
|
715
|
+
if current_time - generator_creation_start >= timeout:
|
|
716
|
+
log.info(f"exiting early, already spent {current_time - generator_creation_start:0.2f} s")
|
|
717
|
+
break
|
|
718
|
+
|
|
719
|
+
name = bytes32(row[0])
|
|
720
|
+
fee = int(row[1])
|
|
721
|
+
item = self._items[name]
|
|
722
|
+
try:
|
|
723
|
+
assert item.conds is not None
|
|
724
|
+
cost = item.conds.condition_cost + item.conds.execution_cost
|
|
725
|
+
bundle_coin_spends = singleton_ff.process_fast_forward_spends(
|
|
726
|
+
mempool_item=item, height=height, constants=constants
|
|
727
|
+
)
|
|
728
|
+
unique_coin_spends, cost_saving, unique_additions = dedup_coin_spends.get_deduplication_info(
|
|
729
|
+
bundle_coin_spends=bundle_coin_spends, max_cost=cost
|
|
730
|
+
)
|
|
731
|
+
new_fee_sum = fee_sum + fee
|
|
732
|
+
if new_fee_sum > DEFAULT_CONSTANTS.MAX_COIN_AMOUNT:
|
|
733
|
+
# Such a fee is very unlikely to happen but we're defensively
|
|
734
|
+
# accounting for it
|
|
735
|
+
break # pragma: no cover
|
|
736
|
+
|
|
737
|
+
# if adding item would make us exceed the block cost, commit the
|
|
738
|
+
# batch we've built up first, to see if more space may be freed
|
|
739
|
+
# up by the compression
|
|
740
|
+
if block_cost + item.conds.cost - cost_saving > constants.MAX_BLOCK_COST_CLVM:
|
|
741
|
+
added, done = builder.add_spend_bundles(batch_transactions, uint64(batch_cost), constants)
|
|
742
|
+
|
|
743
|
+
block_cost = builder.cost()
|
|
744
|
+
if added:
|
|
745
|
+
added_spends += batch_spends
|
|
746
|
+
additions.extend(batch_additions)
|
|
747
|
+
removals.extend([cs.coin for sb in batch_transactions for cs in sb.coin_spends])
|
|
748
|
+
log.info(
|
|
749
|
+
f"adding TX batch, additions: {len(batch_additions)} removals: {batch_spends} "
|
|
750
|
+
f"cost: {batch_cost} total cost: {block_cost}"
|
|
751
|
+
)
|
|
752
|
+
else:
|
|
753
|
+
skipped_items += 1
|
|
754
|
+
|
|
755
|
+
batch_cost = 0
|
|
756
|
+
batch_transactions = []
|
|
757
|
+
batch_additions = []
|
|
758
|
+
batch_spends = 0
|
|
759
|
+
if done:
|
|
760
|
+
break
|
|
761
|
+
|
|
762
|
+
batch_cost += cost - cost_saving
|
|
763
|
+
batch_transactions.append(SpendBundle(unique_coin_spends, item.spend_bundle.aggregated_signature))
|
|
764
|
+
batch_spends += len(unique_coin_spends)
|
|
765
|
+
batch_additions.extend(unique_additions)
|
|
766
|
+
fee_sum = new_fee_sum
|
|
767
|
+
block_cost += item.conds.cost - cost_saving
|
|
768
|
+
except SkipDedup as e:
|
|
769
|
+
log.info(f"{e}")
|
|
770
|
+
continue
|
|
771
|
+
except Exception as e:
|
|
772
|
+
log.info(f"Exception while checking a mempool item for deduplication: {e}")
|
|
773
|
+
skipped_items += 1
|
|
774
|
+
continue
|
|
775
|
+
|
|
776
|
+
if len(batch_transactions) > 0:
|
|
777
|
+
added, _ = builder.add_spend_bundles(batch_transactions, uint64(batch_cost), constants)
|
|
778
|
+
|
|
779
|
+
if added:
|
|
780
|
+
added_spends += batch_spends
|
|
781
|
+
additions.extend(batch_additions)
|
|
782
|
+
removals.extend([cs.coin for sb in batch_transactions for cs in sb.coin_spends])
|
|
783
|
+
block_cost = builder.cost()
|
|
784
|
+
log.info(
|
|
785
|
+
f"adding TX batch, additions: {len(batch_additions)} removals: {batch_spends} "
|
|
786
|
+
f"cost: {batch_cost} total cost: {block_cost}"
|
|
787
|
+
)
|
|
788
|
+
|
|
789
|
+
if removals == []:
|
|
790
|
+
return None
|
|
791
|
+
|
|
792
|
+
generator_creation_end = monotonic()
|
|
793
|
+
duration = generator_creation_end - generator_creation_start
|
|
794
|
+
block_program, signature, cost = builder.finalize(constants)
|
|
795
|
+
log.log(
|
|
796
|
+
logging.INFO if duration < 2 else logging.WARNING,
|
|
797
|
+
f"create_block_generator2() took {duration:0.4f} seconds. "
|
|
798
|
+
f"block cost: {cost} spends: {added_spends} additions: {len(additions)}",
|
|
799
|
+
)
|
|
800
|
+
assert block_cost == cost
|
|
801
|
+
|
|
802
|
+
return NewBlockGenerator(
|
|
803
|
+
SerializedProgram.from_bytes(block_program),
|
|
804
|
+
[],
|
|
805
|
+
[],
|
|
806
|
+
signature,
|
|
807
|
+
additions,
|
|
808
|
+
removals,
|
|
809
|
+
uint64(block_cost),
|
|
810
|
+
)
|