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
chia/simulator/block_tools.py
CHANGED
|
@@ -20,20 +20,31 @@ import anyio
|
|
|
20
20
|
from chia_puzzles_py.programs import CHIALISP_DESERIALISATION, ROM_BOOTSTRAP_GENERATOR
|
|
21
21
|
from chia_rs import (
|
|
22
22
|
AugSchemeMPL,
|
|
23
|
+
BlockRecord,
|
|
24
|
+
ChallengeChainSubSlot,
|
|
23
25
|
ConsensusConstants,
|
|
26
|
+
EndOfSubSlotBundle,
|
|
27
|
+
FullBlock,
|
|
24
28
|
G1Element,
|
|
25
29
|
G2Element,
|
|
30
|
+
InfusedChallengeChainSubSlot,
|
|
31
|
+
PlotSize,
|
|
26
32
|
PoolTarget,
|
|
27
33
|
PrivateKey,
|
|
34
|
+
ProofOfSpace,
|
|
35
|
+
RewardChainSubSlot,
|
|
36
|
+
SpendBundle,
|
|
37
|
+
SubEpochSummary,
|
|
38
|
+
SubSlotProofs,
|
|
39
|
+
UnfinishedBlock,
|
|
28
40
|
solution_generator,
|
|
29
41
|
)
|
|
30
42
|
from chia_rs.sized_bytes import bytes32
|
|
31
43
|
from chia_rs.sized_ints import uint8, uint16, uint32, uint64, uint128
|
|
32
44
|
|
|
33
45
|
from chia.consensus.block_creation import create_unfinished_block, unfinished_block_to_full_block
|
|
34
|
-
from chia.consensus.block_record import
|
|
46
|
+
from chia.consensus.block_record import BlockRecordProtocol
|
|
35
47
|
from chia.consensus.blockchain_interface import BlockRecordsProtocol
|
|
36
|
-
from chia.consensus.coinbase import create_puzzlehash_for_pk
|
|
37
48
|
from chia.consensus.condition_costs import ConditionCost
|
|
38
49
|
from chia.consensus.constants import replace_str_to_bytes
|
|
39
50
|
from chia.consensus.default_constants import DEFAULT_CONSTANTS
|
|
@@ -46,11 +57,12 @@ from chia.consensus.pot_iterations import (
|
|
|
46
57
|
calculate_sp_interval_iters,
|
|
47
58
|
calculate_sp_iters,
|
|
48
59
|
is_overflow_block,
|
|
60
|
+
validate_pospace_and_get_required_iters,
|
|
49
61
|
)
|
|
62
|
+
from chia.consensus.signage_point import SignagePoint
|
|
50
63
|
from chia.consensus.vdf_info_computation import get_signage_point_vdf_info
|
|
51
64
|
from chia.daemon.keychain_proxy import KeychainProxy, connect_to_keychain_and_validate, wrap_local_keychain
|
|
52
65
|
from chia.full_node.bundle_tools import simple_solution_generator, simple_solution_generator_backrefs
|
|
53
|
-
from chia.full_node.signage_point import SignagePoint
|
|
54
66
|
from chia.plotting.create_plots import PlotKeys, create_plots
|
|
55
67
|
from chia.plotting.manager import PlotManager
|
|
56
68
|
from chia.plotting.util import (
|
|
@@ -70,35 +82,24 @@ from chia.simulator.ssl_certs import (
|
|
|
70
82
|
get_next_nodes_certs_and_keys,
|
|
71
83
|
get_next_private_ca_cert_and_key,
|
|
72
84
|
)
|
|
85
|
+
from chia.simulator.vdf_prover import get_vdf_info_and_proof
|
|
73
86
|
from chia.simulator.wallet_tools import WalletTool
|
|
74
87
|
from chia.ssl.create_ssl import create_all_ssl
|
|
88
|
+
from chia.ssl.ssl_check import fix_ssl
|
|
75
89
|
from chia.types.blockchain_format.classgroup import ClassgroupElement
|
|
76
90
|
from chia.types.blockchain_format.coin import Coin
|
|
77
|
-
from chia.types.blockchain_format.program import DEFAULT_FLAGS, INFINITE_COST, Program
|
|
91
|
+
from chia.types.blockchain_format.program import DEFAULT_FLAGS, INFINITE_COST, Program, _run, run_with_cost
|
|
78
92
|
from chia.types.blockchain_format.proof_of_space import (
|
|
79
|
-
ProofOfSpace,
|
|
80
93
|
calculate_pos_challenge,
|
|
81
94
|
calculate_prefix_bits,
|
|
82
95
|
generate_plot_public_key,
|
|
83
96
|
generate_taproot_sk,
|
|
84
97
|
passes_plot_filter,
|
|
85
|
-
verify_and_get_quality_string,
|
|
86
98
|
)
|
|
87
99
|
from chia.types.blockchain_format.serialized_program import SerializedProgram
|
|
88
|
-
from chia.types.blockchain_format.slots import (
|
|
89
|
-
ChallengeChainSubSlot,
|
|
90
|
-
InfusedChallengeChainSubSlot,
|
|
91
|
-
RewardChainSubSlot,
|
|
92
|
-
SubSlotProofs,
|
|
93
|
-
)
|
|
94
|
-
from chia.types.blockchain_format.sub_epoch_summary import SubEpochSummary
|
|
95
100
|
from chia.types.blockchain_format.vdf import VDFInfo, VDFProof
|
|
96
101
|
from chia.types.condition_opcodes import ConditionOpcode
|
|
97
|
-
from chia.types.
|
|
98
|
-
from chia.types.full_block import FullBlock
|
|
99
|
-
from chia.types.generator_types import BlockGenerator
|
|
100
|
-
from chia.types.spend_bundle import SpendBundle
|
|
101
|
-
from chia.types.unfinished_block import UnfinishedBlock
|
|
102
|
+
from chia.types.generator_types import NewBlockGenerator
|
|
102
103
|
from chia.util.bech32m import encode_puzzle_hash
|
|
103
104
|
from chia.util.block_cache import BlockCache
|
|
104
105
|
from chia.util.config import (
|
|
@@ -112,22 +113,23 @@ from chia.util.config import (
|
|
|
112
113
|
from chia.util.default_root import DEFAULT_ROOT_PATH
|
|
113
114
|
from chia.util.hash import std_hash
|
|
114
115
|
from chia.util.keychain import Keychain, bytes_to_mnemonic
|
|
115
|
-
from chia.util.ssl_check import fix_ssl
|
|
116
116
|
from chia.util.timing import adjusted_timeout, backoff_times
|
|
117
|
-
from chia.util.vdf_prover import get_vdf_info_and_proof
|
|
118
117
|
from chia.wallet.derive_keys import (
|
|
119
118
|
master_sk_to_farmer_sk,
|
|
120
119
|
master_sk_to_local_sk,
|
|
121
120
|
master_sk_to_pool_sk,
|
|
122
121
|
master_sk_to_wallet_sk,
|
|
123
122
|
)
|
|
123
|
+
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_hash_for_pk
|
|
124
124
|
|
|
125
125
|
DESERIALIZE_MOD = Program.from_bytes(CHIALISP_DESERIALISATION)
|
|
126
126
|
|
|
127
127
|
GENERATOR_MOD: SerializedProgram = SerializedProgram.from_bytes(ROM_BOOTSTRAP_GENERATOR)
|
|
128
128
|
|
|
129
129
|
test_constants = DEFAULT_CONSTANTS.replace(
|
|
130
|
-
|
|
130
|
+
MIN_PLOT_SIZE_V1=uint8(18),
|
|
131
|
+
# TODO: todo_v2_plots decide on v2 test plot k-size
|
|
132
|
+
MIN_PLOT_SIZE_V2=uint8(18),
|
|
131
133
|
MIN_BLOCKS_PER_CHALLENGE_BLOCK=uint8(12),
|
|
132
134
|
DIFFICULTY_STARTING=uint64(2**10),
|
|
133
135
|
DISCRIMINANT_SIZE_BITS=uint16(16),
|
|
@@ -135,7 +137,7 @@ test_constants = DEFAULT_CONSTANTS.replace(
|
|
|
135
137
|
WEIGHT_PROOF_THRESHOLD=uint8(2),
|
|
136
138
|
WEIGHT_PROOF_RECENT_BLOCKS=uint32(380),
|
|
137
139
|
DIFFICULTY_CONSTANT_FACTOR=uint128(33554432),
|
|
138
|
-
NUM_SPS_SUB_SLOT=
|
|
140
|
+
NUM_SPS_SUB_SLOT=uint8(16), # Must be a power of 2
|
|
139
141
|
MAX_SUB_SLOT_BLOCKS=uint32(50),
|
|
140
142
|
EPOCH_BLOCKS=uint32(340),
|
|
141
143
|
# the block cache must contain at least 3 epochs in order for
|
|
@@ -144,7 +146,7 @@ test_constants = DEFAULT_CONSTANTS.replace(
|
|
|
144
146
|
BLOCKS_CACHE_SIZE=uint32(340 * 3), # Coordinate with the above values
|
|
145
147
|
SUB_SLOT_TIME_TARGET=uint16(600), # The target number of seconds per slot, mainnet 600
|
|
146
148
|
SUB_SLOT_ITERS_STARTING=uint64(2**10), # Must be a multiple of 64
|
|
147
|
-
|
|
149
|
+
NUMBER_ZERO_BITS_PLOT_FILTER_V1=uint8(1), # H(plot signature of the challenge) must start with these many zeroes
|
|
148
150
|
# Allows creating blockchains with timestamps up to 10 days in the future, for testing
|
|
149
151
|
MAX_FUTURE_TIME2=uint32(3600 * 24 * 10),
|
|
150
152
|
MEMPOOL_BLOCK_BUFFER=uint8(6),
|
|
@@ -155,7 +157,7 @@ def compute_additions_unchecked(sb: SpendBundle) -> list[Coin]:
|
|
|
155
157
|
ret: list[Coin] = []
|
|
156
158
|
for cs in sb.coin_spends:
|
|
157
159
|
parent_id = cs.coin.name()
|
|
158
|
-
_, r = cs.puzzle_reveal
|
|
160
|
+
_, r = run_with_cost(cs.puzzle_reveal, INFINITE_COST, cs.solution)
|
|
159
161
|
for cond in Program.to(r).as_iter():
|
|
160
162
|
atoms = cond.as_iter()
|
|
161
163
|
op = next(atoms).atom
|
|
@@ -167,6 +169,48 @@ def compute_additions_unchecked(sb: SpendBundle) -> list[Coin]:
|
|
|
167
169
|
return ret
|
|
168
170
|
|
|
169
171
|
|
|
172
|
+
def compute_block_cost(
|
|
173
|
+
generator: SerializedProgram, constants: ConsensusConstants, height: uint32, prev_tx_height: uint32
|
|
174
|
+
) -> uint64:
|
|
175
|
+
# this function cannot *validate* the block or any of the transactions. We
|
|
176
|
+
# deliberately create invalid blocks as parts of the tests, and we still
|
|
177
|
+
# need to be able to compute the cost of it
|
|
178
|
+
|
|
179
|
+
condition_cost = 0
|
|
180
|
+
clvm_cost = 0
|
|
181
|
+
|
|
182
|
+
if height >= constants.HARD_FORK_HEIGHT:
|
|
183
|
+
blocks: list[bytes] = []
|
|
184
|
+
cost, result = _run(generator, INFINITE_COST, DEFAULT_FLAGS, [DESERIALIZE_MOD, blocks])
|
|
185
|
+
clvm_cost += cost
|
|
186
|
+
|
|
187
|
+
for spend in result.first().as_iter():
|
|
188
|
+
# each spend is a list of:
|
|
189
|
+
# (parent-coin-id puzzle amount solution)
|
|
190
|
+
puzzle = spend.at("rf")
|
|
191
|
+
solution = spend.at("rrrf")
|
|
192
|
+
|
|
193
|
+
cost, result = _run(puzzle, INFINITE_COST, DEFAULT_FLAGS, solution)
|
|
194
|
+
clvm_cost += cost
|
|
195
|
+
condition_cost += conditions_cost(
|
|
196
|
+
result, charge_for_conditions=prev_tx_height >= constants.HARD_FORK2_HEIGHT
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
else:
|
|
200
|
+
block_program_args = SerializedProgram.to([[]])
|
|
201
|
+
clvm_cost, result = _run(GENERATOR_MOD, INFINITE_COST, DEFAULT_FLAGS, [generator, block_program_args])
|
|
202
|
+
|
|
203
|
+
for res in result.first().as_iter():
|
|
204
|
+
# each condition item is:
|
|
205
|
+
# (parent-coin-id puzzle-hash amount conditions)
|
|
206
|
+
conditions = res.at("rrrf")
|
|
207
|
+
condition_cost += conditions_cost(conditions, charge_for_conditions=False)
|
|
208
|
+
|
|
209
|
+
size_cost = len(bytes(generator)) * constants.COST_PER_BYTE
|
|
210
|
+
|
|
211
|
+
return uint64(clvm_cost + size_cost + condition_cost)
|
|
212
|
+
|
|
213
|
+
|
|
170
214
|
def make_spend_bundle(coins: list[Coin], wallet: WalletTool, rng: Random) -> tuple[SpendBundle, list[Coin]]:
|
|
171
215
|
"""
|
|
172
216
|
makes a new spend bundle (block generator) spending some of the coins in the
|
|
@@ -181,9 +225,6 @@ def make_spend_bundle(coins: list[Coin], wallet: WalletTool, rng: Random) -> tup
|
|
|
181
225
|
bundle = wallet.generate_signed_transaction(uint64(c.amount // 2), receiver, c)
|
|
182
226
|
new_coins.extend(bundle.additions())
|
|
183
227
|
spend_bundles.append(bundle)
|
|
184
|
-
coins.remove(c)
|
|
185
|
-
|
|
186
|
-
coins.extend(new_coins)
|
|
187
228
|
|
|
188
229
|
return SpendBundle.aggregate(spend_bundles), new_coins
|
|
189
230
|
|
|
@@ -304,6 +345,83 @@ class BlockTools:
|
|
|
304
345
|
match_str=str(self.plot_dir.relative_to(DEFAULT_ROOT_PATH.parent)) if not automated_testing else None,
|
|
305
346
|
)
|
|
306
347
|
|
|
348
|
+
def setup_new_gen(
|
|
349
|
+
self,
|
|
350
|
+
tx_block_heights: list[uint32],
|
|
351
|
+
curr: BlockRecordProtocol,
|
|
352
|
+
wallet: Optional[WalletTool],
|
|
353
|
+
rng: Optional[random.Random],
|
|
354
|
+
available_coins: list[Coin],
|
|
355
|
+
*,
|
|
356
|
+
prev_tx_height: uint32,
|
|
357
|
+
dummy_block_references: bool,
|
|
358
|
+
include_transactions: bool,
|
|
359
|
+
transaction_data: Optional[SpendBundle],
|
|
360
|
+
block_refs: list[uint32],
|
|
361
|
+
) -> Optional[NewBlockGenerator]:
|
|
362
|
+
# we don't know if the new block will be a transaction
|
|
363
|
+
# block or not, so even though we prepare a block
|
|
364
|
+
# generator, we can't update our state (like,
|
|
365
|
+
# available_coins) until it's confirmed the block
|
|
366
|
+
# generator made it into the block.
|
|
367
|
+
dummy_refs: list[uint32]
|
|
368
|
+
if dummy_block_references and len(tx_block_heights) > 4:
|
|
369
|
+
dummy_refs = [
|
|
370
|
+
tx_block_heights[1],
|
|
371
|
+
tx_block_heights[len(tx_block_heights) // 2],
|
|
372
|
+
tx_block_heights[-2],
|
|
373
|
+
]
|
|
374
|
+
else:
|
|
375
|
+
dummy_refs = []
|
|
376
|
+
|
|
377
|
+
if transaction_data is not None:
|
|
378
|
+
# this means the caller passed in transaction_data
|
|
379
|
+
# to be included in the block.
|
|
380
|
+
additions = compute_additions_unchecked(transaction_data)
|
|
381
|
+
removals = transaction_data.removals()
|
|
382
|
+
if curr.height >= self.constants.HARD_FORK_HEIGHT:
|
|
383
|
+
program = simple_solution_generator_backrefs(transaction_data).program
|
|
384
|
+
else:
|
|
385
|
+
program = simple_solution_generator(transaction_data).program
|
|
386
|
+
block_refs = []
|
|
387
|
+
cost = compute_block_cost(program, self.constants, uint32(curr.height + 1), prev_tx_height)
|
|
388
|
+
return NewBlockGenerator(
|
|
389
|
+
program,
|
|
390
|
+
[],
|
|
391
|
+
block_refs,
|
|
392
|
+
transaction_data.aggregated_signature,
|
|
393
|
+
additions,
|
|
394
|
+
removals,
|
|
395
|
+
cost,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
if include_transactions:
|
|
399
|
+
# if the caller did not pass in specific
|
|
400
|
+
# transactions, this parameter means we just want
|
|
401
|
+
# some transactions
|
|
402
|
+
assert wallet is not None
|
|
403
|
+
assert rng is not None
|
|
404
|
+
bundle, additions = make_spend_bundle(available_coins, wallet, rng)
|
|
405
|
+
removals = bundle.removals()
|
|
406
|
+
program = simple_solution_generator(bundle).program
|
|
407
|
+
cost = compute_block_cost(program, self.constants, uint32(curr.height + 1), prev_tx_height)
|
|
408
|
+
return NewBlockGenerator(
|
|
409
|
+
program,
|
|
410
|
+
[],
|
|
411
|
+
block_refs + dummy_refs,
|
|
412
|
+
bundle.aggregated_signature,
|
|
413
|
+
additions,
|
|
414
|
+
removals,
|
|
415
|
+
cost,
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
if dummy_block_references:
|
|
419
|
+
program = SerializedProgram.from_bytes(solution_generator([]))
|
|
420
|
+
cost = compute_block_cost(program, self.constants, uint32(curr.height + 1), prev_tx_height)
|
|
421
|
+
return NewBlockGenerator(program, [], block_refs + dummy_refs, G2Element(), [], [], cost)
|
|
422
|
+
|
|
423
|
+
return None
|
|
424
|
+
|
|
307
425
|
async def setup_keys(self, fingerprint: Optional[int] = None, reward_ph: Optional[bytes32] = None) -> None:
|
|
308
426
|
keychain_proxy: Optional[KeychainProxy]
|
|
309
427
|
try:
|
|
@@ -336,10 +454,10 @@ class BlockTools:
|
|
|
336
454
|
self.pool_pk = master_sk_to_pool_sk(self.pool_master_sk).get_g1()
|
|
337
455
|
|
|
338
456
|
if reward_ph is None:
|
|
339
|
-
self.farmer_ph: bytes32 =
|
|
457
|
+
self.farmer_ph: bytes32 = puzzle_hash_for_pk(
|
|
340
458
|
master_sk_to_wallet_sk(self.farmer_master_sk, uint32(0)).get_g1()
|
|
341
459
|
)
|
|
342
|
-
self.pool_ph: bytes32 =
|
|
460
|
+
self.pool_ph: bytes32 = puzzle_hash_for_pk(
|
|
343
461
|
master_sk_to_wallet_sk(self.pool_master_sk, uint32(0)).get_g1()
|
|
344
462
|
)
|
|
345
463
|
else:
|
|
@@ -595,6 +713,8 @@ class BlockTools:
|
|
|
595
713
|
skip_overflow: bool = False,
|
|
596
714
|
min_signage_point: int = -1,
|
|
597
715
|
) -> list[FullBlock]:
|
|
716
|
+
# make a copy to not have different invocations affect each other
|
|
717
|
+
block_refs = block_refs[:]
|
|
598
718
|
assert num_blocks > 0
|
|
599
719
|
if block_list_input is not None:
|
|
600
720
|
block_list = block_list_input.copy()
|
|
@@ -610,11 +730,14 @@ class BlockTools:
|
|
|
610
730
|
tx_block_heights.append(b.height)
|
|
611
731
|
|
|
612
732
|
constants = self.constants
|
|
613
|
-
|
|
733
|
+
|
|
614
734
|
if time_per_block is None:
|
|
615
735
|
time_per_block = float(constants.SUB_SLOT_TIME_TARGET) / float(constants.SLOT_BLOCKS_TARGET)
|
|
616
736
|
|
|
617
737
|
available_coins: list[Coin] = []
|
|
738
|
+
# award coins aren't available to spend until the transaction block
|
|
739
|
+
# after the one they were created by, so we "stage" them here to move
|
|
740
|
+
# them into available_coins at the next transaction block
|
|
618
741
|
pending_rewards: list[Coin] = []
|
|
619
742
|
wallet: Optional[WalletTool] = None
|
|
620
743
|
rng: Optional[Random] = None
|
|
@@ -676,7 +799,7 @@ class BlockTools:
|
|
|
676
799
|
curr = blocks[curr.prev_hash]
|
|
677
800
|
assert curr.timestamp is not None
|
|
678
801
|
last_timestamp = float(curr.timestamp)
|
|
679
|
-
|
|
802
|
+
prev_tx_height = curr.height
|
|
680
803
|
|
|
681
804
|
curr = latest_block
|
|
682
805
|
blocks_added_this_sub_slot = 1
|
|
@@ -709,7 +832,7 @@ class BlockTools:
|
|
|
709
832
|
num_empty_slots_added += 1
|
|
710
833
|
else:
|
|
711
834
|
# Loop over every signage point (Except for the last ones, which are used for overflows)
|
|
712
|
-
for signage_point_index in range(
|
|
835
|
+
for signage_point_index in range(constants.NUM_SPS_SUB_SLOT - constants.NUM_SP_INTERVALS_EXTRA):
|
|
713
836
|
curr = latest_block
|
|
714
837
|
while curr.total_iters > sub_slot_start_total_iters + calculate_sp_iters(
|
|
715
838
|
constants, sub_slot_iters, uint8(signage_point_index)
|
|
@@ -753,6 +876,7 @@ class BlockTools:
|
|
|
753
876
|
difficulty,
|
|
754
877
|
sub_slot_iters,
|
|
755
878
|
curr.height,
|
|
879
|
+
tx_block_heights[-1] if len(tx_block_heights) > 0 else uint32(0),
|
|
756
880
|
force_plot_id=force_plot_id,
|
|
757
881
|
)
|
|
758
882
|
|
|
@@ -766,20 +890,6 @@ class BlockTools:
|
|
|
766
890
|
continue
|
|
767
891
|
|
|
768
892
|
assert latest_block.header_hash in blocks
|
|
769
|
-
additions = None
|
|
770
|
-
removals = None
|
|
771
|
-
if transaction_data_included:
|
|
772
|
-
transaction_data = None
|
|
773
|
-
block_refs = []
|
|
774
|
-
if transaction_data is not None:
|
|
775
|
-
additions = compute_additions_unchecked(transaction_data)
|
|
776
|
-
removals = transaction_data.removals()
|
|
777
|
-
elif include_transactions:
|
|
778
|
-
assert wallet is not None
|
|
779
|
-
assert rng is not None
|
|
780
|
-
transaction_data, additions = make_spend_bundle(available_coins, wallet, rng)
|
|
781
|
-
removals = transaction_data.removals()
|
|
782
|
-
transaction_data_included = False
|
|
783
893
|
|
|
784
894
|
assert last_timestamp is not None
|
|
785
895
|
if proof_of_space.pool_contract_puzzle_hash is not None:
|
|
@@ -794,32 +904,19 @@ class BlockTools:
|
|
|
794
904
|
else:
|
|
795
905
|
pool_target = PoolTarget(self.pool_ph, uint32(0))
|
|
796
906
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
907
|
+
new_gen = self.setup_new_gen(
|
|
908
|
+
tx_block_heights,
|
|
909
|
+
curr,
|
|
910
|
+
wallet,
|
|
911
|
+
rng,
|
|
912
|
+
available_coins,
|
|
913
|
+
prev_tx_height=prev_tx_height,
|
|
914
|
+
dummy_block_references=dummy_block_references,
|
|
915
|
+
transaction_data=transaction_data,
|
|
916
|
+
include_transactions=include_transactions,
|
|
917
|
+
block_refs=block_refs,
|
|
918
|
+
)
|
|
804
919
|
|
|
805
|
-
aggregate_signature = transaction_data.aggregated_signature
|
|
806
|
-
else:
|
|
807
|
-
block_generator = None
|
|
808
|
-
aggregate_signature = G2Element()
|
|
809
|
-
|
|
810
|
-
if dummy_block_references:
|
|
811
|
-
if block_generator is None:
|
|
812
|
-
program = SerializedProgram.from_bytes(solution_generator([]))
|
|
813
|
-
block_generator = BlockGenerator(program, [])
|
|
814
|
-
|
|
815
|
-
if len(tx_block_heights) > 4:
|
|
816
|
-
block_refs.extend(
|
|
817
|
-
[
|
|
818
|
-
tx_block_heights[1],
|
|
819
|
-
tx_block_heights[len(tx_block_heights) // 2],
|
|
820
|
-
tx_block_heights[-2],
|
|
821
|
-
]
|
|
822
|
-
)
|
|
823
920
|
(
|
|
824
921
|
full_block,
|
|
825
922
|
block_record,
|
|
@@ -835,12 +932,8 @@ class BlockTools:
|
|
|
835
932
|
farmer_reward_puzzle_hash,
|
|
836
933
|
pool_target,
|
|
837
934
|
last_timestamp,
|
|
838
|
-
start_height,
|
|
839
935
|
time_per_block,
|
|
840
|
-
|
|
841
|
-
aggregate_signature,
|
|
842
|
-
additions,
|
|
843
|
-
removals,
|
|
936
|
+
new_gen,
|
|
844
937
|
height_to_hash,
|
|
845
938
|
difficulty,
|
|
846
939
|
required_iters,
|
|
@@ -853,10 +946,11 @@ class BlockTools:
|
|
|
853
946
|
seed,
|
|
854
947
|
normalized_to_identity_cc_ip=normalized_to_identity_cc_ip,
|
|
855
948
|
current_time=current_time,
|
|
856
|
-
|
|
949
|
+
overflow_cc_challenge=None,
|
|
950
|
+
overflow_rc_challenge=None,
|
|
857
951
|
)
|
|
858
952
|
if block_record.is_transaction_block:
|
|
859
|
-
|
|
953
|
+
transaction_data = None
|
|
860
954
|
block_refs = []
|
|
861
955
|
keep_going_until_tx_block = False
|
|
862
956
|
assert full_block.foliage_transaction_block is not None
|
|
@@ -864,34 +958,38 @@ class BlockTools:
|
|
|
864
958
|
continue
|
|
865
959
|
# print(f"{full_block.height:4}: difficulty {difficulty} "
|
|
866
960
|
# f"time: {new_timestamp - last_timestamp:0.2f} "
|
|
867
|
-
# f"additions: {len(additions) if block_record.is_transaction_block else 0:2} "
|
|
868
|
-
# f"removals: {len(removals) if block_record.is_transaction_block else 0:2} "
|
|
961
|
+
# f"additions: {len(new_gen.additions) if block_record.is_transaction_block else 0:2} "
|
|
962
|
+
# f"removals: {len(new_gen.removals) if block_record.is_transaction_block else 0:2} "
|
|
869
963
|
# f"refs: {len(full_block.transactions_generator_ref_list):3} "
|
|
870
964
|
# f"tx: {block_record.is_transaction_block}")
|
|
871
965
|
last_timestamp = new_timestamp
|
|
872
966
|
block_list.append(full_block)
|
|
873
967
|
|
|
874
968
|
if include_transactions:
|
|
969
|
+
prev_tx_height = full_block.height
|
|
875
970
|
for coin in full_block.get_included_reward_coins():
|
|
876
971
|
if coin.puzzle_hash == self.farmer_ph:
|
|
877
972
|
pending_rewards.append(coin)
|
|
878
973
|
if full_block.is_transaction_block():
|
|
879
974
|
available_coins.extend(pending_rewards)
|
|
880
975
|
pending_rewards = []
|
|
976
|
+
if new_gen is not None:
|
|
977
|
+
for rem in new_gen.removals:
|
|
978
|
+
available_coins.remove(rem)
|
|
979
|
+
available_coins.extend(new_gen.additions)
|
|
881
980
|
|
|
882
981
|
if full_block.transactions_generator is not None:
|
|
883
982
|
tx_block_heights.append(full_block.height)
|
|
884
983
|
|
|
885
984
|
blocks_added_this_sub_slot += 1
|
|
886
|
-
|
|
887
985
|
blocks[full_block.header_hash] = block_record
|
|
888
|
-
self.log.info(
|
|
889
|
-
|
|
890
|
-
|
|
986
|
+
self.log.info(f"Created block {block_record.height} ov=False, iters {block_record.total_iters}")
|
|
987
|
+
num_blocks -= 1
|
|
988
|
+
|
|
891
989
|
height_to_hash[uint32(full_block.height)] = full_block.header_hash
|
|
892
990
|
latest_block = blocks[full_block.header_hash]
|
|
893
991
|
finished_sub_slots_at_ip = []
|
|
894
|
-
|
|
992
|
+
|
|
895
993
|
if num_blocks <= 0 and not keep_going_until_tx_block:
|
|
896
994
|
self._block_cache_header = block_list[-1].header_hash
|
|
897
995
|
self._block_cache_height_to_hash = height_to_hash
|
|
@@ -1032,19 +1130,6 @@ class BlockTools:
|
|
|
1032
1130
|
latest_block_eos = latest_block
|
|
1033
1131
|
overflow_cc_challenge = finished_sub_slots_at_ip[-1].challenge_chain.get_hash()
|
|
1034
1132
|
overflow_rc_challenge = finished_sub_slots_at_ip[-1].reward_chain.get_hash()
|
|
1035
|
-
additions = None
|
|
1036
|
-
removals = None
|
|
1037
|
-
if transaction_data_included:
|
|
1038
|
-
transaction_data = None
|
|
1039
|
-
if transaction_data is not None:
|
|
1040
|
-
additions = compute_additions_unchecked(transaction_data)
|
|
1041
|
-
removals = transaction_data.removals()
|
|
1042
|
-
elif include_transactions:
|
|
1043
|
-
assert wallet is not None
|
|
1044
|
-
assert rng is not None
|
|
1045
|
-
transaction_data, additions = make_spend_bundle(available_coins, wallet, rng)
|
|
1046
|
-
removals = transaction_data.removals()
|
|
1047
|
-
transaction_data_included = False
|
|
1048
1133
|
sub_slots_finished += 1
|
|
1049
1134
|
self.log.info(
|
|
1050
1135
|
f"Sub slot finished. blocks included: {blocks_added_this_sub_slot} blocks_per_slot: "
|
|
@@ -1095,6 +1180,7 @@ class BlockTools:
|
|
|
1095
1180
|
difficulty,
|
|
1096
1181
|
sub_slot_iters,
|
|
1097
1182
|
curr.height,
|
|
1183
|
+
tx_block_heights[-1] if len(tx_block_heights) > 0 else uint32(0),
|
|
1098
1184
|
force_plot_id=force_plot_id,
|
|
1099
1185
|
)
|
|
1100
1186
|
for required_iters, proof_of_space in sorted(qualified_proofs, key=lambda t: t[0]):
|
|
@@ -1112,30 +1198,19 @@ class BlockTools:
|
|
|
1112
1198
|
pool_target = PoolTarget(pool_reward_puzzle_hash, uint32(0))
|
|
1113
1199
|
else:
|
|
1114
1200
|
pool_target = PoolTarget(self.pool_ph, uint32(0))
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
program = SerializedProgram.from_bytes(solution_generator([]))
|
|
1129
|
-
block_generator = BlockGenerator(program, [])
|
|
1130
|
-
|
|
1131
|
-
if len(tx_block_heights) > 4:
|
|
1132
|
-
block_refs.extend(
|
|
1133
|
-
[
|
|
1134
|
-
tx_block_heights[1],
|
|
1135
|
-
tx_block_heights[len(tx_block_heights) // 2],
|
|
1136
|
-
tx_block_heights[-2],
|
|
1137
|
-
]
|
|
1138
|
-
)
|
|
1201
|
+
|
|
1202
|
+
new_gen = self.setup_new_gen(
|
|
1203
|
+
tx_block_heights,
|
|
1204
|
+
curr,
|
|
1205
|
+
wallet,
|
|
1206
|
+
rng,
|
|
1207
|
+
available_coins,
|
|
1208
|
+
prev_tx_height=prev_tx_height,
|
|
1209
|
+
dummy_block_references=dummy_block_references,
|
|
1210
|
+
transaction_data=transaction_data,
|
|
1211
|
+
include_transactions=include_transactions,
|
|
1212
|
+
block_refs=block_refs,
|
|
1213
|
+
)
|
|
1139
1214
|
|
|
1140
1215
|
(
|
|
1141
1216
|
full_block,
|
|
@@ -1152,12 +1227,8 @@ class BlockTools:
|
|
|
1152
1227
|
farmer_reward_puzzle_hash,
|
|
1153
1228
|
pool_target,
|
|
1154
1229
|
last_timestamp,
|
|
1155
|
-
start_height,
|
|
1156
1230
|
time_per_block,
|
|
1157
|
-
|
|
1158
|
-
aggregate_signature,
|
|
1159
|
-
additions,
|
|
1160
|
-
removals,
|
|
1231
|
+
new_gen,
|
|
1161
1232
|
height_to_hash,
|
|
1162
1233
|
difficulty,
|
|
1163
1234
|
required_iters,
|
|
@@ -1168,15 +1239,13 @@ class BlockTools:
|
|
|
1168
1239
|
signage_point,
|
|
1169
1240
|
latest_block,
|
|
1170
1241
|
seed,
|
|
1171
|
-
overflow_cc_challenge=overflow_cc_challenge,
|
|
1172
|
-
overflow_rc_challenge=overflow_rc_challenge,
|
|
1173
1242
|
normalized_to_identity_cc_ip=normalized_to_identity_cc_ip,
|
|
1174
1243
|
current_time=current_time,
|
|
1175
|
-
|
|
1244
|
+
overflow_cc_challenge=overflow_cc_challenge,
|
|
1245
|
+
overflow_rc_challenge=overflow_rc_challenge,
|
|
1176
1246
|
)
|
|
1177
|
-
|
|
1178
1247
|
if block_record.is_transaction_block:
|
|
1179
|
-
|
|
1248
|
+
transaction_data = None
|
|
1180
1249
|
block_refs = []
|
|
1181
1250
|
keep_going_until_tx_block = False
|
|
1182
1251
|
assert full_block.foliage_transaction_block is not None
|
|
@@ -1184,30 +1253,34 @@ class BlockTools:
|
|
|
1184
1253
|
continue
|
|
1185
1254
|
# print(f"{full_block.height:4}: difficulty {difficulty} "
|
|
1186
1255
|
# f"time: {new_timestamp - last_timestamp:0.2f} "
|
|
1187
|
-
# f"additions: {len(additions) if block_record.is_transaction_block else 0:2} "
|
|
1188
|
-
# f"removals: {len(removals) if block_record.is_transaction_block else 0:2} "
|
|
1256
|
+
# f"additions: {len(new_gen.additions) if block_record.is_transaction_block else 0:2} "
|
|
1257
|
+
# f"removals: {len(new_gen.removals) if block_record.is_transaction_block else 0:2} "
|
|
1189
1258
|
# f"refs: {len(full_block.transactions_generator_ref_list):3} "
|
|
1190
1259
|
# f"tx: {block_record.is_transaction_block}")
|
|
1191
1260
|
last_timestamp = new_timestamp
|
|
1192
|
-
|
|
1193
1261
|
block_list.append(full_block)
|
|
1194
1262
|
|
|
1195
1263
|
if include_transactions:
|
|
1264
|
+
prev_tx_height = full_block.height
|
|
1196
1265
|
for coin in full_block.get_included_reward_coins():
|
|
1197
1266
|
if coin.puzzle_hash == self.farmer_ph:
|
|
1198
1267
|
pending_rewards.append(coin)
|
|
1199
1268
|
if full_block.is_transaction_block():
|
|
1200
1269
|
available_coins.extend(pending_rewards)
|
|
1201
1270
|
pending_rewards = []
|
|
1271
|
+
if new_gen is not None:
|
|
1272
|
+
for rem in new_gen.removals:
|
|
1273
|
+
available_coins.remove(rem)
|
|
1274
|
+
available_coins.extend(new_gen.additions)
|
|
1202
1275
|
|
|
1203
1276
|
if full_block.transactions_generator is not None:
|
|
1204
1277
|
tx_block_heights.append(full_block.height)
|
|
1205
1278
|
|
|
1206
1279
|
blocks_added_this_sub_slot += 1
|
|
1280
|
+
blocks[full_block.header_hash] = block_record
|
|
1207
1281
|
self.log.info(f"Created block {block_record.height} ov=True, iters {block_record.total_iters}")
|
|
1208
1282
|
num_blocks -= 1
|
|
1209
1283
|
|
|
1210
|
-
blocks[full_block.header_hash] = block_record
|
|
1211
1284
|
height_to_hash[uint32(full_block.height)] = full_block.header_hash
|
|
1212
1285
|
latest_block = blocks[full_block.header_hash]
|
|
1213
1286
|
finished_sub_slots_at_ip = []
|
|
@@ -1248,7 +1321,7 @@ class BlockTools:
|
|
|
1248
1321
|
# Keep trying until we get a good proof of space that also passes sp filter
|
|
1249
1322
|
while True:
|
|
1250
1323
|
cc_challenge, rc_challenge = get_challenges(constants, {}, finished_sub_slots, None)
|
|
1251
|
-
for signage_point_index in range(
|
|
1324
|
+
for signage_point_index in range(constants.NUM_SPS_SUB_SLOT):
|
|
1252
1325
|
signage_point: SignagePoint = get_signage_point(
|
|
1253
1326
|
constants,
|
|
1254
1327
|
BlockCache({}),
|
|
@@ -1274,6 +1347,7 @@ class BlockTools:
|
|
|
1274
1347
|
constants.DIFFICULTY_STARTING,
|
|
1275
1348
|
constants.SUB_SLOT_ITERS_STARTING,
|
|
1276
1349
|
uint32(0),
|
|
1350
|
+
uint32(0),
|
|
1277
1351
|
)
|
|
1278
1352
|
|
|
1279
1353
|
# Try each of the proofs of space
|
|
@@ -1313,7 +1387,6 @@ class BlockTools:
|
|
|
1313
1387
|
BlockCache({}),
|
|
1314
1388
|
seed=seed,
|
|
1315
1389
|
finished_sub_slots_input=finished_sub_slots,
|
|
1316
|
-
compute_cost=compute_cost_test,
|
|
1317
1390
|
compute_fees=compute_fee_test,
|
|
1318
1391
|
)
|
|
1319
1392
|
assert unfinished_block is not None
|
|
@@ -1423,6 +1496,7 @@ class BlockTools:
|
|
|
1423
1496
|
difficulty: uint64,
|
|
1424
1497
|
sub_slot_iters: uint64,
|
|
1425
1498
|
height: uint32,
|
|
1499
|
+
prev_transaction_b_height: uint32,
|
|
1426
1500
|
force_plot_id: Optional[bytes32] = None,
|
|
1427
1501
|
) -> list[tuple[uint64, ProofOfSpace]]:
|
|
1428
1502
|
found_proofs: list[tuple[uint64, ProofOfSpace]] = []
|
|
@@ -1432,18 +1506,22 @@ class BlockTools:
|
|
|
1432
1506
|
plot_id: bytes32 = plot_info.prover.get_id()
|
|
1433
1507
|
if force_plot_id is not None and plot_id != force_plot_id:
|
|
1434
1508
|
continue
|
|
1435
|
-
|
|
1509
|
+
# TODO: todo_v2_plots support v2 plots in the plot manager
|
|
1510
|
+
prefix_bits = calculate_prefix_bits(constants, height, PlotSize.make_v1(plot_info.prover.get_size()))
|
|
1436
1511
|
if passes_plot_filter(prefix_bits, plot_id, challenge_hash, signage_point):
|
|
1437
1512
|
new_challenge: bytes32 = calculate_pos_challenge(plot_id, challenge_hash, signage_point)
|
|
1438
1513
|
qualities = plot_info.prover.get_qualities_for_challenge(new_challenge)
|
|
1439
1514
|
|
|
1440
1515
|
for proof_index, quality_str in enumerate(qualities):
|
|
1441
1516
|
required_iters = calculate_iterations_quality(
|
|
1442
|
-
constants
|
|
1517
|
+
constants,
|
|
1443
1518
|
quality_str,
|
|
1444
|
-
|
|
1519
|
+
# TODO: todo_v2_plots support v2 plots in the plot manager
|
|
1520
|
+
PlotSize.make_v1(plot_info.prover.get_size()),
|
|
1445
1521
|
difficulty,
|
|
1446
1522
|
signage_point,
|
|
1523
|
+
sub_slot_iters,
|
|
1524
|
+
prev_transaction_b_height,
|
|
1447
1525
|
)
|
|
1448
1526
|
if required_iters < calculate_sp_interval_iters(constants, sub_slot_iters):
|
|
1449
1527
|
proof_xs: bytes = plot_info.prover.get_full_proof(new_challenge, proof_index)
|
|
@@ -1694,21 +1772,25 @@ def load_block_list(
|
|
|
1694
1772
|
assert full_block.reward_chain_block.challenge_chain_sp_vdf is not None
|
|
1695
1773
|
challenge = full_block.reward_chain_block.challenge_chain_sp_vdf.challenge
|
|
1696
1774
|
sp_hash = full_block.reward_chain_block.challenge_chain_sp_vdf.output.get_hash()
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
)
|
|
1700
|
-
|
|
1701
|
-
required_iters
|
|
1702
|
-
constants
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
uint64(difficulty),
|
|
1775
|
+
|
|
1776
|
+
cache = BlockCache(blocks)
|
|
1777
|
+
prev_transaction_b_height = uint32(0) # TODO: todo_v2_plots
|
|
1778
|
+
|
|
1779
|
+
required_iters = validate_pospace_and_get_required_iters(
|
|
1780
|
+
constants,
|
|
1781
|
+
full_block.reward_chain_block.proof_of_space,
|
|
1782
|
+
challenge,
|
|
1706
1783
|
sp_hash,
|
|
1784
|
+
full_block.height,
|
|
1785
|
+
uint64(difficulty),
|
|
1786
|
+
sub_slot_iters,
|
|
1787
|
+
prev_transaction_b_height,
|
|
1707
1788
|
)
|
|
1789
|
+
assert required_iters is not None
|
|
1708
1790
|
|
|
1709
1791
|
blocks[full_block.header_hash] = block_to_block_record(
|
|
1710
1792
|
constants,
|
|
1711
|
-
|
|
1793
|
+
cache,
|
|
1712
1794
|
required_iters,
|
|
1713
1795
|
full_block,
|
|
1714
1796
|
sub_slot_iters,
|
|
@@ -1785,12 +1867,8 @@ def get_full_block_and_block_record(
|
|
|
1785
1867
|
farmer_reward_puzzle_hash: bytes32,
|
|
1786
1868
|
pool_target: PoolTarget,
|
|
1787
1869
|
last_timestamp: float,
|
|
1788
|
-
start_height: uint32,
|
|
1789
1870
|
time_per_block: float,
|
|
1790
|
-
|
|
1791
|
-
aggregate_signature: G2Element,
|
|
1792
|
-
additions: Optional[list[Coin]],
|
|
1793
|
-
removals: Optional[list[Coin]],
|
|
1871
|
+
new_gen: Optional[NewBlockGenerator],
|
|
1794
1872
|
height_to_hash: dict[uint32, bytes32],
|
|
1795
1873
|
difficulty: uint64,
|
|
1796
1874
|
required_iters: uint64,
|
|
@@ -1802,7 +1880,6 @@ def get_full_block_and_block_record(
|
|
|
1802
1880
|
prev_block: BlockRecord,
|
|
1803
1881
|
seed: bytes = b"",
|
|
1804
1882
|
*,
|
|
1805
|
-
block_refs: list[uint32] = [],
|
|
1806
1883
|
overflow_cc_challenge: Optional[bytes32] = None,
|
|
1807
1884
|
overflow_rc_challenge: Optional[bytes32] = None,
|
|
1808
1885
|
normalized_to_identity_cc_ip: bool = False,
|
|
@@ -1837,13 +1914,9 @@ def get_full_block_and_block_record(
|
|
|
1837
1914
|
uint64(timestamp),
|
|
1838
1915
|
BlockCache(blocks),
|
|
1839
1916
|
seed,
|
|
1840
|
-
|
|
1841
|
-
aggregate_signature,
|
|
1842
|
-
additions,
|
|
1843
|
-
removals,
|
|
1917
|
+
new_gen,
|
|
1844
1918
|
prev_block,
|
|
1845
1919
|
finished_sub_slots,
|
|
1846
|
-
compute_cost=compute_cost_test,
|
|
1847
1920
|
compute_fees=compute_fee_test,
|
|
1848
1921
|
)
|
|
1849
1922
|
|
|
@@ -1898,10 +1971,19 @@ def compute_cost_table() -> list[int]:
|
|
|
1898
1971
|
CONDITION_COSTS = compute_cost_table()
|
|
1899
1972
|
|
|
1900
1973
|
|
|
1901
|
-
def conditions_cost(conds: Program) -> uint64:
|
|
1974
|
+
def conditions_cost(conds: Program, *, charge_for_conditions: bool) -> uint64:
|
|
1975
|
+
free_conditions = 100
|
|
1976
|
+
|
|
1902
1977
|
condition_cost = 0
|
|
1903
1978
|
for cond in conds.as_iter():
|
|
1904
1979
|
condition = cond.first().as_atom()
|
|
1980
|
+
|
|
1981
|
+
# this is new in hard fork 2
|
|
1982
|
+
if free_conditions > 0:
|
|
1983
|
+
free_conditions -= 1
|
|
1984
|
+
elif charge_for_conditions:
|
|
1985
|
+
condition_cost += ConditionCost.GENERIC_CONDITION_COST.value
|
|
1986
|
+
|
|
1905
1987
|
if condition == ConditionOpcode.CREATE_COIN:
|
|
1906
1988
|
condition_cost += ConditionCost.CREATE_COIN.value
|
|
1907
1989
|
# after the 2.0 hard fork, two byte conditions (with no leading 0)
|
|
@@ -1940,44 +2022,6 @@ def compute_fee_test(additions: Sequence[Coin], removals: Sequence[Coin]) -> uin
|
|
|
1940
2022
|
return uint64(ret)
|
|
1941
2023
|
|
|
1942
2024
|
|
|
1943
|
-
def compute_cost_test(generator: BlockGenerator, constants: ConsensusConstants, height: uint32) -> uint64:
|
|
1944
|
-
# this function cannot *validate* the block or any of the transactions. We
|
|
1945
|
-
# deliberately create invalid blocks as parts of the tests, and we still
|
|
1946
|
-
# need to be able to compute the cost of it
|
|
1947
|
-
|
|
1948
|
-
condition_cost = 0
|
|
1949
|
-
clvm_cost = 0
|
|
1950
|
-
|
|
1951
|
-
if height >= constants.HARD_FORK_HEIGHT:
|
|
1952
|
-
blocks = generator.generator_refs
|
|
1953
|
-
cost, result = generator.program._run(INFINITE_COST, DEFAULT_FLAGS, [DESERIALIZE_MOD, blocks])
|
|
1954
|
-
clvm_cost += cost
|
|
1955
|
-
|
|
1956
|
-
for spend in result.first().as_iter():
|
|
1957
|
-
# each spend is a list of:
|
|
1958
|
-
# (parent-coin-id puzzle amount solution)
|
|
1959
|
-
puzzle = spend.at("rf")
|
|
1960
|
-
solution = spend.at("rrrf")
|
|
1961
|
-
|
|
1962
|
-
cost, result = puzzle._run(INFINITE_COST, DEFAULT_FLAGS, solution)
|
|
1963
|
-
clvm_cost += cost
|
|
1964
|
-
condition_cost += conditions_cost(result)
|
|
1965
|
-
|
|
1966
|
-
else:
|
|
1967
|
-
block_program_args = SerializedProgram.to([generator.generator_refs])
|
|
1968
|
-
clvm_cost, result = GENERATOR_MOD._run(INFINITE_COST, DEFAULT_FLAGS, [generator.program, block_program_args])
|
|
1969
|
-
|
|
1970
|
-
for res in result.first().as_iter():
|
|
1971
|
-
# each condition item is:
|
|
1972
|
-
# (parent-coin-id puzzle-hash amount conditions)
|
|
1973
|
-
conditions = res.at("rrrf")
|
|
1974
|
-
condition_cost += conditions_cost(conditions)
|
|
1975
|
-
|
|
1976
|
-
size_cost = len(bytes(generator.program)) * constants.COST_PER_BYTE
|
|
1977
|
-
|
|
1978
|
-
return uint64(clvm_cost + size_cost + condition_cost)
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
2025
|
@dataclass
|
|
1982
2026
|
class BlockToolsNewPlotResult:
|
|
1983
2027
|
plot_id: bytes32
|