chia-blockchain 2.5.0rc1__py3-none-any.whl → 2.5.1__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/README.md +1 -1
- chia/_tests/blockchain/blockchain_test_utils.py +24 -26
- chia/_tests/blockchain/test_augmented_chain.py +6 -8
- chia/_tests/blockchain/test_blockchain.py +409 -307
- chia/_tests/blockchain/test_blockchain_transactions.py +56 -75
- chia/_tests/blockchain/test_build_chains.py +11 -13
- chia/_tests/blockchain/test_get_block_generator.py +8 -8
- chia/_tests/blockchain/test_lookup_fork_chain.py +3 -4
- chia/_tests/build-init-files.py +3 -4
- chia/_tests/build-job-matrix.py +9 -9
- chia/_tests/check_sql_statements.py +2 -3
- chia/_tests/clvm/benchmark_costs.py +1 -1
- chia/_tests/clvm/coin_store.py +7 -5
- chia/_tests/clvm/test_chialisp_deserialization.py +8 -8
- chia/_tests/clvm/test_condition_codes.py +2 -2
- chia/_tests/clvm/test_curry_and_treehash.py +2 -4
- chia/_tests/clvm/test_message_conditions.py +184 -0
- chia/_tests/clvm/test_puzzle_compression.py +1 -2
- chia/_tests/clvm/test_puzzle_drivers.py +3 -3
- chia/_tests/clvm/test_puzzles.py +13 -18
- chia/_tests/clvm/test_singletons.py +17 -17
- chia/_tests/clvm/test_spend_sim.py +7 -7
- chia/_tests/cmds/cmd_test_utils.py +42 -45
- chia/_tests/cmds/conftest.py +2 -2
- chia/_tests/cmds/test_click_types.py +21 -16
- chia/_tests/cmds/test_cmd_framework.py +255 -35
- chia/_tests/cmds/test_cmds_util.py +2 -2
- chia/_tests/cmds/test_daemon.py +3 -3
- chia/_tests/cmds/test_dev_gh.py +131 -0
- chia/_tests/cmds/test_farm_cmd.py +1 -2
- chia/_tests/cmds/test_show.py +6 -6
- chia/_tests/cmds/test_tx_config_args.py +2 -1
- chia/_tests/cmds/wallet/test_dao.py +23 -23
- chia/_tests/cmds/wallet/test_did.py +29 -29
- chia/_tests/cmds/wallet/test_nft.py +24 -23
- chia/_tests/cmds/wallet/test_notifications.py +8 -8
- chia/_tests/cmds/wallet/test_tx_decorators.py +3 -3
- chia/_tests/cmds/wallet/test_vcs.py +97 -73
- chia/_tests/cmds/wallet/test_wallet.py +74 -75
- chia/_tests/cmds/wallet/test_wallet_check.py +5 -7
- chia/_tests/conftest.py +153 -38
- chia/_tests/connection_utils.py +7 -6
- chia/_tests/core/cmds/test_beta.py +3 -3
- chia/_tests/core/cmds/test_keys.py +6 -6
- chia/_tests/core/cmds/test_wallet.py +3 -3
- chia/_tests/core/consensus/test_block_creation.py +3 -5
- chia/_tests/core/custom_types/test_coin.py +1 -3
- chia/_tests/core/custom_types/test_spend_bundle.py +3 -4
- chia/_tests/core/daemon/test_daemon.py +58 -58
- chia/_tests/core/daemon/test_keychain_proxy.py +2 -1
- chia/_tests/core/data_layer/conftest.py +4 -3
- chia/_tests/core/data_layer/test_data_cli.py +1 -2
- chia/_tests/core/data_layer/test_data_layer.py +5 -5
- chia/_tests/core/data_layer/test_data_layer_util.py +8 -9
- chia/_tests/core/data_layer/test_data_rpc.py +75 -93
- chia/_tests/core/data_layer/test_data_store.py +38 -37
- chia/_tests/core/data_layer/test_data_store_schema.py +11 -11
- chia/_tests/core/data_layer/util.py +11 -10
- chia/_tests/core/farmer/test_farmer_api.py +6 -4
- chia/_tests/core/full_node/full_sync/test_full_sync.py +5 -10
- chia/_tests/core/full_node/ram_db.py +2 -2
- chia/_tests/core/full_node/stores/test_block_store.py +113 -11
- chia/_tests/core/full_node/stores/test_coin_store.py +37 -28
- chia/_tests/core/full_node/stores/test_full_node_store.py +34 -30
- chia/_tests/core/full_node/stores/test_hint_store.py +3 -4
- chia/_tests/core/full_node/test_address_manager.py +2 -2
- chia/_tests/core/full_node/test_block_height_map.py +1 -1
- chia/_tests/core/full_node/test_conditions.py +10 -12
- chia/_tests/core/full_node/test_full_node.py +2077 -1822
- chia/_tests/core/full_node/test_generator_tools.py +4 -4
- chia/_tests/core/full_node/test_hint_management.py +2 -2
- chia/_tests/core/full_node/test_performance.py +2 -5
- chia/_tests/core/full_node/test_subscriptions.py +4 -4
- chia/_tests/core/full_node/test_tx_processing_queue.py +5 -4
- chia/_tests/core/make_block_generator.py +5 -7
- chia/_tests/core/mempool/test_mempool.py +205 -208
- chia/_tests/core/mempool/test_mempool_fee_protocol.py +5 -5
- chia/_tests/core/mempool/test_mempool_item_queries.py +2 -4
- chia/_tests/core/mempool/test_mempool_manager.py +109 -80
- chia/_tests/core/mempool/test_mempool_performance.py +3 -4
- chia/_tests/core/mempool/test_singleton_fast_forward.py +12 -12
- chia/_tests/core/server/flood.py +6 -4
- chia/_tests/core/server/serve.py +10 -7
- chia/_tests/core/server/test_api_protocol.py +21 -0
- chia/_tests/core/server/test_capabilities.py +3 -5
- chia/_tests/core/server/test_dos.py +15 -16
- chia/_tests/core/server/test_loop.py +14 -10
- chia/_tests/core/server/test_node_discovery.py +1 -2
- chia/_tests/core/server/test_rate_limits.py +156 -44
- chia/_tests/core/server/test_server.py +8 -7
- chia/_tests/core/services/test_services.py +59 -37
- chia/_tests/core/ssl/test_ssl.py +5 -3
- chia/_tests/core/test_cost_calculation.py +5 -6
- chia/_tests/core/test_crawler.py +2 -2
- chia/_tests/core/test_db_conversion.py +5 -4
- chia/_tests/core/test_db_validation.py +6 -5
- chia/_tests/core/test_farmer_harvester_rpc.py +8 -7
- chia/_tests/core/test_filter.py +3 -5
- chia/_tests/core/test_full_node_rpc.py +64 -90
- chia/_tests/core/test_merkle_set.py +10 -10
- chia/_tests/core/test_program.py +2 -4
- chia/_tests/core/test_rpc_util.py +1 -2
- chia/_tests/core/test_seeder.py +124 -12
- chia/_tests/core/util/test_block_cache.py +5 -5
- chia/_tests/core/util/test_cached_bls.py +3 -3
- chia/_tests/core/util/test_config.py +13 -13
- chia/_tests/core/util/test_files.py +2 -2
- chia/_tests/core/util/test_jsonify.py +9 -9
- chia/_tests/core/util/test_keychain.py +13 -5
- chia/_tests/core/util/test_keyring_wrapper.py +6 -5
- chia/_tests/core/util/test_log_exceptions.py +3 -3
- chia/_tests/core/util/test_streamable.py +38 -38
- chia/_tests/db/test_db_wrapper.py +13 -12
- chia/_tests/environments/common.py +2 -2
- chia/_tests/environments/full_node.py +2 -2
- chia/_tests/environments/wallet.py +109 -48
- chia/_tests/farmer_harvester/test_farmer.py +35 -35
- chia/_tests/farmer_harvester/test_farmer_harvester.py +17 -17
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +6 -5
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +73 -46
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +8 -8
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +47 -47
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +6 -7
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +11 -11
- chia/_tests/generator/test_compression.py +13 -30
- chia/_tests/generator/test_generator_types.py +3 -3
- chia/_tests/generator/test_rom.py +7 -9
- chia/_tests/plot_sync/test_delta.py +2 -3
- chia/_tests/plot_sync/test_plot_sync.py +25 -24
- chia/_tests/plot_sync/test_receiver.py +9 -9
- chia/_tests/plot_sync/test_sender.py +1 -1
- chia/_tests/plot_sync/test_sync_simulated.py +27 -26
- chia/_tests/plot_sync/util.py +2 -1
- chia/_tests/plotting/test_plot_manager.py +54 -11
- chia/_tests/plotting/util.py +2 -3
- chia/_tests/pools/test_pool_cli_parsing.py +128 -0
- chia/_tests/pools/test_pool_cmdline.py +993 -15
- chia/_tests/pools/test_pool_config.py +3 -5
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +10 -11
- chia/_tests/pools/test_pool_rpc.py +203 -90
- chia/_tests/pools/test_pool_wallet.py +12 -8
- chia/_tests/pools/test_wallet_pool_store.py +3 -3
- chia/_tests/process_junit.py +16 -17
- chia/_tests/rpc/test_rpc_client.py +59 -2
- chia/_tests/rpc/test_rpc_server.py +183 -0
- chia/_tests/simulation/test_simulation.py +5 -5
- chia/_tests/simulation/test_simulator.py +8 -10
- chia/_tests/simulation/test_start_simulator.py +5 -4
- chia/_tests/timelord/test_new_peak.py +19 -19
- chia/_tests/tools/test_run_block.py +1 -2
- chia/_tests/tools/test_virtual_project.py +591 -0
- chia/_tests/util/benchmark_cost.py +9 -9
- chia/_tests/util/benchmarks.py +1 -2
- chia/_tests/util/blockchain.py +12 -11
- chia/_tests/util/blockchain_mock.py +15 -15
- chia/_tests/util/build_network_protocol_files.py +12 -12
- chia/_tests/util/db_connection.py +3 -2
- chia/_tests/util/full_sync.py +14 -6
- chia/_tests/util/gen_ssl_certs.py +4 -5
- chia/_tests/util/generator_tools_testing.py +5 -7
- chia/_tests/util/get_name_puzzle_conditions.py +52 -0
- chia/_tests/util/key_tool.py +2 -3
- chia/_tests/util/misc.py +59 -106
- chia/_tests/util/network_protocol_data.py +7 -9
- chia/_tests/util/protocol_messages_json.py +112 -111
- chia/_tests/util/rpc.py +3 -0
- chia/_tests/util/run_block.py +16 -16
- chia/_tests/util/setup_nodes.py +25 -23
- chia/{clvm → _tests/util}/spend_sim.py +59 -55
- chia/_tests/util/split_managers.py +12 -9
- chia/_tests/util/temp_file.py +1 -1
- chia/_tests/util/test_action_scope.py +2 -1
- chia/_tests/util/test_async_pool.py +8 -8
- chia/_tests/util/test_build_job_matrix.py +2 -3
- chia/_tests/util/test_condition_tools.py +4 -6
- chia/_tests/util/test_config.py +5 -5
- chia/_tests/util/test_dump_keyring.py +1 -1
- chia/_tests/util/test_full_block_utils.py +19 -11
- chia/_tests/util/test_limited_semaphore.py +4 -3
- chia/_tests/util/test_logging_filter.py +2 -3
- chia/_tests/util/test_misc.py +29 -28
- chia/_tests/util/test_network.py +32 -31
- chia/_tests/util/test_network_protocol_files.py +2 -3
- chia/_tests/util/test_network_protocol_json.py +1 -0
- chia/_tests/util/test_network_protocol_test.py +18 -19
- chia/_tests/util/test_paginator.py +3 -4
- chia/_tests/util/test_pprint.py +1 -1
- chia/_tests/util/test_priority_mutex.py +18 -17
- chia/_tests/util/test_recursive_replace.py +2 -2
- chia/_tests/util/test_testnet_overrides.py +3 -3
- chia/_tests/util/test_timing.py +1 -1
- chia/_tests/util/test_trusted_peer.py +2 -2
- chia/_tests/util/time_out_assert.py +43 -6
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +13 -13
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +1 -1
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +117 -29
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +15 -15
- chia/_tests/wallet/cat_wallet/test_trades.py +50 -28
- chia/_tests/wallet/clawback/test_clawback_decorator.py +3 -5
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +6 -6
- chia/_tests/wallet/clawback/test_clawback_metadata.py +1 -2
- chia/_tests/wallet/conftest.py +135 -74
- chia/_tests/wallet/dao_wallet/test_dao_clvm.py +25 -17
- chia/_tests/wallet/dao_wallet/test_dao_wallets.py +75 -75
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +10 -12
- chia/_tests/wallet/db_wallet/test_dl_offers.py +6 -6
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +18 -18
- chia/_tests/wallet/did_wallet/test_did.py +1277 -474
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +12 -11
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +115 -105
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +6 -7
- chia/_tests/wallet/nft_wallet/test_nft_offers.py +16 -16
- chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +3 -3
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +38 -12
- chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +1 -1
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +31 -33
- chia/_tests/wallet/rpc/test_wallet_rpc.py +218 -171
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +36 -37
- chia/_tests/wallet/sync/test_wallet_sync.py +241 -78
- chia/_tests/wallet/test_address_type.py +20 -20
- chia/_tests/wallet/test_clvm_streamable.py +5 -5
- chia/_tests/wallet/test_coin_management.py +354 -0
- chia/_tests/wallet/test_coin_selection.py +34 -35
- chia/_tests/wallet/test_conditions.py +28 -16
- chia/_tests/wallet/test_debug_spend_bundle.py +156 -14
- chia/_tests/wallet/test_new_wallet_protocol.py +29 -31
- chia/_tests/wallet/test_nft_store.py +1 -2
- chia/_tests/wallet/test_notifications.py +2 -2
- chia/_tests/wallet/test_offer_parsing_performance.py +1 -1
- chia/_tests/wallet/test_puzzle_store.py +2 -3
- chia/_tests/wallet/test_sign_coin_spends.py +3 -3
- chia/_tests/wallet/test_signer_protocol.py +33 -34
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +29 -29
- chia/_tests/wallet/test_taproot.py +1 -1
- chia/_tests/wallet/test_transaction_store.py +23 -19
- chia/_tests/wallet/test_util.py +36 -32
- chia/_tests/wallet/test_wallet.py +37 -37
- chia/_tests/wallet/test_wallet_action_scope.py +8 -8
- chia/_tests/wallet/test_wallet_blockchain.py +4 -6
- chia/_tests/wallet/test_wallet_coin_store.py +34 -34
- chia/_tests/wallet/test_wallet_node.py +69 -72
- chia/_tests/wallet/test_wallet_retry.py +3 -3
- chia/_tests/wallet/test_wallet_state_manager.py +12 -5
- chia/_tests/wallet/test_wallet_trade_store.py +2 -2
- chia/_tests/wallet/test_wallet_utils.py +5 -4
- chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +3 -3
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +18 -18
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +69 -40
- chia/_tests/wallet/wallet_block_tools.py +27 -27
- chia/_tests/weight_proof/test_weight_proof.py +30 -30
- chia/apis.py +19 -0
- chia/cmds/beta.py +8 -7
- chia/cmds/beta_funcs.py +15 -11
- chia/cmds/check_wallet_db.py +29 -27
- chia/cmds/chia.py +17 -9
- chia/cmds/cmd_classes.py +87 -79
- chia/cmds/cmd_helpers.py +242 -0
- chia/cmds/cmds_util.py +56 -66
- chia/cmds/coin_funcs.py +168 -153
- chia/cmds/coins.py +156 -194
- chia/cmds/configure.py +4 -3
- chia/cmds/dao.py +89 -33
- chia/cmds/dao_funcs.py +55 -33
- chia/cmds/data.py +7 -6
- chia/cmds/data_funcs.py +26 -21
- chia/cmds/db.py +4 -3
- chia/cmds/db_backup_func.py +2 -2
- chia/cmds/db_upgrade_func.py +3 -3
- chia/cmds/db_validate_func.py +2 -2
- chia/cmds/dev.py +2 -0
- chia/cmds/farm.py +18 -5
- chia/cmds/farm_funcs.py +17 -24
- chia/cmds/gh.py +275 -0
- chia/cmds/init.py +4 -11
- chia/cmds/init_funcs.py +9 -9
- chia/cmds/installers.py +5 -3
- chia/cmds/keys.py +56 -39
- chia/cmds/keys_funcs.py +30 -31
- chia/cmds/netspace.py +6 -3
- chia/cmds/netspace_funcs.py +3 -2
- chia/cmds/param_types.py +16 -6
- chia/cmds/passphrase.py +8 -7
- chia/cmds/passphrase_funcs.py +7 -61
- chia/cmds/peer.py +2 -1
- chia/cmds/peer_funcs.py +5 -5
- chia/cmds/plotnft.py +207 -153
- chia/cmds/plotnft_funcs.py +205 -174
- chia/cmds/plots.py +14 -6
- chia/cmds/plotters.py +2 -1
- chia/cmds/rpc.py +48 -28
- chia/cmds/show.py +2 -1
- chia/cmds/show_funcs.py +7 -6
- chia/cmds/signer.py +50 -58
- chia/cmds/sim.py +22 -14
- chia/cmds/sim_funcs.py +11 -11
- chia/cmds/start.py +3 -3
- chia/cmds/start_funcs.py +9 -12
- chia/cmds/stop.py +4 -3
- chia/cmds/units.py +1 -3
- chia/cmds/wallet.py +252 -96
- chia/cmds/wallet_funcs.py +217 -143
- chia/consensus/block_body_validation.py +133 -86
- chia/consensus/block_creation.py +42 -21
- chia/consensus/block_header_validation.py +32 -37
- chia/consensus/block_record.py +1 -2
- chia/consensus/blockchain.py +167 -180
- chia/consensus/blockchain_interface.py +10 -10
- chia/consensus/constants.py +2 -2
- chia/consensus/default_constants.py +3 -4
- chia/consensus/difficulty_adjustment.py +5 -5
- chia/consensus/find_fork_point.py +5 -5
- chia/consensus/full_block_to_block_record.py +4 -4
- chia/consensus/get_block_challenge.py +2 -2
- chia/consensus/get_block_generator.py +4 -3
- chia/consensus/multiprocess_validation.py +207 -304
- chia/consensus/vdf_info_computation.py +3 -3
- chia/daemon/client.py +46 -27
- chia/daemon/keychain_proxy.py +10 -9
- chia/daemon/keychain_server.py +18 -18
- chia/daemon/server.py +103 -113
- chia/daemon/windows_signal.py +2 -2
- chia/data_layer/data_layer.py +64 -76
- chia/data_layer/data_layer_api.py +8 -0
- chia/data_layer/data_layer_errors.py +3 -3
- chia/data_layer/data_layer_server.py +2 -2
- chia/data_layer/data_layer_util.py +71 -71
- chia/data_layer/data_layer_wallet.py +63 -67
- chia/data_layer/data_store.py +72 -72
- chia/data_layer/dl_wallet_store.py +10 -10
- chia/data_layer/download_data.py +5 -5
- chia/data_layer/s3_plugin_service.py +9 -9
- chia/data_layer/util/benchmark.py +0 -1
- chia/data_layer/util/plugin.py +2 -3
- chia/farmer/farmer.py +46 -43
- chia/farmer/farmer_api.py +27 -21
- chia/full_node/block_height_map.py +6 -6
- chia/full_node/block_store.py +41 -35
- chia/full_node/coin_store.py +42 -41
- chia/full_node/fee_estimate.py +2 -2
- chia/full_node/fee_estimation.py +1 -2
- chia/full_node/fee_history.py +5 -6
- chia/full_node/fee_tracker.py +24 -24
- chia/full_node/full_node.py +574 -300
- chia/full_node/full_node_api.py +181 -130
- chia/full_node/full_node_store.py +43 -43
- chia/full_node/hint_management.py +4 -4
- chia/full_node/hint_store.py +9 -10
- chia/full_node/mempool.py +25 -19
- chia/full_node/mempool_check_conditions.py +11 -42
- chia/full_node/mempool_manager.py +48 -53
- chia/full_node/pending_tx_cache.py +9 -9
- chia/full_node/subscriptions.py +23 -24
- chia/full_node/sync_store.py +8 -7
- chia/full_node/tx_processing_queue.py +3 -3
- chia/full_node/util/__init__.py +0 -0
- chia/full_node/weight_proof.py +79 -78
- chia/harvester/harvester.py +9 -8
- chia/harvester/harvester_api.py +19 -13
- chia/introducer/introducer.py +7 -5
- chia/introducer/introducer_api.py +9 -3
- chia/legacy/keyring.py +6 -5
- chia/plot_sync/delta.py +8 -8
- chia/plot_sync/receiver.py +12 -11
- chia/plot_sync/sender.py +15 -12
- chia/plotters/bladebit.py +12 -12
- chia/plotters/chiapos.py +2 -2
- chia/plotters/madmax.py +8 -8
- chia/plotters/plotters.py +6 -6
- chia/plotters/plotters_util.py +6 -4
- chia/plotting/cache.py +8 -7
- chia/plotting/check_plots.py +8 -8
- chia/plotting/create_plots.py +6 -6
- chia/plotting/manager.py +22 -22
- chia/plotting/util.py +31 -19
- chia/pools/pool_config.py +7 -7
- chia/pools/pool_puzzles.py +16 -16
- chia/pools/pool_wallet.py +64 -57
- chia/pools/pool_wallet_info.py +3 -3
- chia/protocols/full_node_protocol.py +3 -3
- chia/protocols/harvester_protocol.py +12 -12
- chia/protocols/introducer_protocol.py +1 -2
- chia/protocols/protocol_message_types.py +4 -4
- chia/protocols/protocol_state_machine.py +2 -2
- chia/protocols/protocol_timing.py +1 -0
- chia/protocols/shared_protocol.py +3 -3
- chia/protocols/timelord_protocol.py +2 -2
- chia/protocols/wallet_protocol.py +33 -33
- chia/rpc/crawler_rpc_api.py +12 -7
- chia/rpc/data_layer_rpc_api.py +49 -44
- chia/rpc/data_layer_rpc_client.py +41 -41
- chia/rpc/data_layer_rpc_util.py +7 -11
- chia/rpc/farmer_rpc_api.py +32 -27
- chia/rpc/farmer_rpc_client.py +14 -14
- chia/rpc/full_node_rpc_api.py +53 -48
- chia/rpc/full_node_rpc_client.py +30 -30
- chia/rpc/harvester_rpc_api.py +16 -11
- chia/rpc/harvester_rpc_client.py +6 -6
- chia/rpc/rpc_client.py +34 -14
- chia/rpc/rpc_server.py +117 -43
- chia/rpc/timelord_rpc_api.py +9 -4
- chia/rpc/util.py +11 -211
- chia/rpc/wallet_request_types.py +276 -60
- chia/rpc/wallet_rpc_api.py +563 -399
- chia/rpc/wallet_rpc_client.py +220 -250
- chia/seeder/crawl_store.py +6 -8
- chia/seeder/crawler.py +23 -36
- chia/seeder/crawler_api.py +28 -22
- chia/seeder/dns_server.py +99 -50
- chia/seeder/start_crawler.py +13 -9
- chia/server/address_manager.py +19 -19
- chia/server/address_manager_store.py +17 -17
- chia/server/api_protocol.py +106 -1
- chia/server/capabilities.py +3 -3
- chia/server/chia_policy.py +17 -16
- chia/server/introducer_peers.py +3 -3
- chia/server/node_discovery.py +34 -38
- chia/server/rate_limit_numbers.py +26 -16
- chia/server/rate_limits.py +67 -27
- chia/server/server.py +52 -31
- chia/server/signal_handlers.py +6 -3
- chia/server/ssl_context.py +5 -5
- chia/server/start_data_layer.py +37 -23
- chia/server/start_farmer.py +28 -16
- chia/server/start_full_node.py +29 -23
- chia/server/start_harvester.py +28 -15
- chia/server/start_introducer.py +27 -15
- chia/server/start_service.py +17 -29
- chia/server/start_timelord.py +25 -18
- chia/server/start_wallet.py +22 -18
- chia/server/upnp.py +4 -3
- chia/server/ws_connection.py +68 -54
- chia/simulator/add_blocks_in_batches.py +54 -0
- chia/simulator/block_tools.py +65 -64
- chia/simulator/full_node_simulator.py +66 -74
- chia/simulator/setup_services.py +10 -9
- chia/simulator/simulator_full_node_rpc_api.py +12 -14
- chia/simulator/simulator_full_node_rpc_client.py +3 -5
- chia/simulator/simulator_test_tools.py +8 -7
- chia/simulator/socket.py +1 -4
- chia/simulator/ssl_certs.py +5 -5
- chia/simulator/ssl_certs_1.py +2 -4
- chia/simulator/ssl_certs_10.py +2 -4
- chia/simulator/ssl_certs_2.py +2 -4
- chia/simulator/ssl_certs_3.py +2 -4
- chia/simulator/ssl_certs_4.py +2 -4
- chia/simulator/ssl_certs_5.py +2 -4
- chia/simulator/ssl_certs_6.py +2 -4
- chia/simulator/ssl_certs_7.py +2 -4
- chia/simulator/ssl_certs_8.py +2 -4
- chia/simulator/ssl_certs_9.py +2 -4
- chia/simulator/start_simulator.py +14 -6
- chia/simulator/wallet_tools.py +21 -20
- chia/ssl/create_ssl.py +11 -11
- chia/timelord/iters_from_block.py +2 -2
- chia/timelord/timelord.py +57 -33
- chia/timelord/timelord_api.py +12 -6
- chia/timelord/timelord_launcher.py +10 -8
- chia/timelord/timelord_state.py +5 -5
- chia/types/block_protocol.py +2 -2
- chia/types/blockchain_format/coin.py +3 -3
- chia/types/blockchain_format/program.py +17 -18
- chia/types/blockchain_format/tree_hash.py +9 -9
- chia/types/coin_spend.py +8 -8
- chia/types/condition_with_args.py +1 -2
- chia/types/eligible_coin_spends.py +16 -15
- chia/types/generator_types.py +1 -2
- chia/types/internal_mempool_item.py +1 -2
- chia/types/mempool_item.py +7 -7
- chia/types/mempool_submission_status.py +2 -2
- chia/types/peer_info.py +1 -1
- chia/types/spend_bundle.py +1 -2
- chia/types/transaction_queue_entry.py +2 -2
- chia/types/unfinished_header_block.py +2 -2
- chia/types/validation_state.py +14 -0
- chia/types/weight_proof.py +5 -6
- chia/util/action_scope.py +8 -8
- chia/util/async_pool.py +6 -4
- chia/util/augmented_chain.py +13 -9
- chia/util/batches.py +5 -2
- chia/util/bech32m.py +14 -11
- chia/util/beta_metrics.py +5 -4
- chia/util/block_cache.py +5 -5
- chia/util/byte_types.py +2 -0
- chia/util/check_fork_next_block.py +3 -2
- chia/util/chia_logging.py +41 -21
- chia/util/collection.py +3 -3
- chia/util/condition_tools.py +18 -18
- chia/util/config.py +26 -25
- chia/util/cpu.py +2 -0
- chia/util/db_synchronous.py +2 -0
- chia/util/db_version.py +2 -0
- chia/util/db_wrapper.py +13 -10
- chia/util/default_root.py +17 -0
- chia/util/dump_keyring.py +6 -6
- chia/util/errors.py +5 -3
- chia/util/file_keyring.py +22 -33
- chia/util/files.py +2 -0
- chia/util/full_block_utils.py +31 -7
- chia/util/generator_tools.py +18 -8
- chia/util/hash.py +3 -1
- chia/util/initial-config.yaml +19 -0
- chia/util/inline_executor.py +2 -0
- chia/util/ip_address.py +39 -0
- chia/util/json_util.py +0 -4
- chia/util/keychain.py +27 -24
- chia/util/keyring_wrapper.py +65 -4
- chia/util/limited_semaphore.py +3 -1
- chia/util/lock.py +4 -2
- chia/util/log_exceptions.py +5 -2
- chia/util/logging.py +3 -1
- chia/util/lru_cache.py +2 -0
- chia/util/math.py +4 -4
- chia/util/network.py +15 -73
- chia/util/paginator.py +3 -1
- chia/util/path.py +2 -0
- chia/util/permissions.py +3 -2
- chia/util/prev_transaction_block.py +1 -3
- chia/util/priority_mutex.py +6 -3
- chia/util/profiler.py +7 -4
- chia/util/recursive_replace.py +2 -0
- chia/util/safe_cancel_task.py +2 -0
- chia/util/service_groups.py +2 -2
- chia/util/setproctitle.py +2 -0
- chia/util/significant_bits.py +2 -0
- chia/util/ssl_check.py +11 -11
- chia/util/streamable.py +44 -56
- chia/util/task_referencer.py +59 -0
- chia/util/task_timing.py +22 -18
- chia/util/timing.py +4 -1
- chia/util/vdf_prover.py +2 -3
- chia/util/virtual_project_analysis.py +540 -0
- chia/util/ws_message.py +6 -6
- chia/wallet/cat_wallet/cat_info.py +3 -3
- chia/wallet/cat_wallet/cat_outer_puzzle.py +3 -3
- chia/wallet/cat_wallet/cat_utils.py +5 -4
- chia/wallet/cat_wallet/cat_wallet.py +56 -70
- chia/wallet/cat_wallet/dao_cat_info.py +3 -3
- chia/wallet/cat_wallet/dao_cat_wallet.py +18 -18
- chia/wallet/cat_wallet/lineage_store.py +2 -2
- chia/wallet/coin_selection.py +15 -15
- chia/wallet/conditions.py +257 -71
- chia/wallet/dao_wallet/dao_info.py +4 -4
- chia/wallet/dao_wallet/dao_utils.py +43 -42
- chia/wallet/dao_wallet/dao_wallet.py +66 -68
- chia/wallet/db_wallet/db_wallet_puzzles.py +12 -8
- chia/wallet/derive_keys.py +11 -11
- chia/wallet/did_wallet/did_info.py +3 -3
- chia/wallet/did_wallet/did_wallet.py +56 -47
- chia/wallet/did_wallet/did_wallet_puzzles.py +7 -6
- chia/wallet/lineage_proof.py +4 -4
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/nft_info.py +4 -4
- chia/wallet/nft_wallet/nft_puzzles.py +16 -16
- chia/wallet/nft_wallet/nft_wallet.py +90 -89
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +2 -2
- chia/wallet/nft_wallet/transfer_program_puzzle.py +2 -2
- chia/wallet/nft_wallet/uncurry_nft.py +2 -2
- chia/wallet/notification_manager.py +5 -5
- chia/wallet/notification_store.py +6 -6
- chia/wallet/outer_puzzles.py +2 -2
- chia/wallet/payment.py +4 -5
- chia/wallet/puzzle_drivers.py +4 -4
- chia/wallet/puzzles/clawback/drivers.py +5 -5
- chia/wallet/puzzles/clawback/puzzle_decorator.py +7 -7
- chia/wallet/puzzles/load_clvm.py +2 -3
- chia/wallet/puzzles/p2_conditions.py +1 -2
- chia/wallet/puzzles/p2_delegated_conditions.py +1 -2
- chia/wallet/puzzles/p2_delegated_puzzle.py +2 -3
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +3 -4
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +1 -2
- chia/wallet/puzzles/p2_puzzle_hash.py +1 -2
- chia/wallet/puzzles/puzzle_utils.py +7 -7
- chia/wallet/puzzles/singleton_top_layer.py +6 -5
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +6 -5
- chia/wallet/puzzles/tails.py +34 -30
- chia/wallet/signer_protocol.py +7 -8
- chia/wallet/singleton.py +4 -4
- chia/wallet/trade_manager.py +155 -141
- chia/wallet/trade_record.py +5 -5
- chia/wallet/trading/offer.py +100 -101
- chia/wallet/trading/trade_store.py +14 -14
- chia/wallet/transaction_record.py +31 -16
- chia/wallet/util/address_type.py +4 -4
- chia/wallet/util/blind_signer_tl.py +8 -12
- chia/wallet/util/clvm_streamable.py +15 -15
- chia/wallet/util/compute_hints.py +5 -5
- chia/wallet/util/compute_memos.py +4 -6
- chia/wallet/util/curry_and_treehash.py +3 -2
- chia/wallet/util/debug_spend_bundle.py +6 -8
- chia/wallet/util/merkle_tree.py +10 -10
- chia/wallet/util/merkle_utils.py +10 -10
- chia/wallet/util/new_peak_queue.py +3 -3
- chia/wallet/util/peer_request_cache.py +8 -8
- chia/{util → wallet/util}/pprint.py +2 -3
- chia/wallet/util/puzzle_compression.py +3 -4
- chia/wallet/util/puzzle_decorator.py +10 -10
- chia/wallet/util/query_filter.py +9 -10
- chia/wallet/util/tx_config.py +12 -12
- chia/wallet/util/wallet_sync_utils.py +24 -21
- chia/wallet/util/wallet_types.py +9 -2
- chia/wallet/vc_wallet/cr_cat_drivers.py +28 -27
- chia/wallet/vc_wallet/cr_cat_wallet.py +42 -40
- chia/wallet/vc_wallet/cr_outer_puzzle.py +4 -4
- chia/wallet/vc_wallet/vc_drivers.py +16 -16
- chia/wallet/vc_wallet/vc_store.py +9 -9
- chia/wallet/vc_wallet/vc_wallet.py +35 -35
- chia/wallet/wallet.py +54 -54
- chia/wallet/wallet_action_scope.py +14 -13
- chia/wallet/wallet_blockchain.py +10 -10
- chia/wallet/wallet_coin_record.py +2 -2
- chia/wallet/wallet_coin_store.py +10 -10
- chia/wallet/wallet_info.py +1 -2
- chia/wallet/wallet_interested_store.py +5 -5
- chia/wallet/wallet_nft_store.py +6 -6
- chia/wallet/wallet_node.py +72 -76
- chia/wallet/wallet_node_api.py +33 -27
- chia/wallet/wallet_pool_store.py +1 -2
- chia/wallet/wallet_protocol.py +15 -15
- chia/wallet/wallet_puzzle_store.py +35 -4
- chia/wallet/wallet_retry_store.py +2 -2
- chia/wallet/wallet_singleton_store.py +10 -9
- chia/wallet/wallet_spend_bundle.py +4 -20
- chia/wallet/wallet_state_manager.py +223 -224
- chia/wallet/wallet_transaction_store.py +44 -18
- chia/wallet/wallet_user_store.py +2 -2
- chia/wallet/wallet_weight_proof_handler.py +2 -2
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/LICENSE +1 -1
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/METADATA +67 -72
- chia_blockchain-2.5.1.dist-info/RECORD +1042 -0
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/WHEEL +1 -1
- mozilla-ca/cacert.pem +32 -87
- chia/_tests/cmds/wallet/test_coins.py +0 -195
- chia/consensus/block_root_validation.py +0 -46
- chia/util/api_decorators.py +0 -89
- chia_blockchain-2.5.0rc1.dist-info/RECORD +0 -1028
- {chia_blockchain-2.5.0rc1.dist-info → chia_blockchain-2.5.1.dist-info}/entry_points.txt +0 -0
chia/data_layer/data_store.py
CHANGED
|
@@ -3,10 +3,11 @@ from __future__ import annotations
|
|
|
3
3
|
import contextlib
|
|
4
4
|
import logging
|
|
5
5
|
from collections import defaultdict
|
|
6
|
+
from collections.abc import AsyncIterator, Awaitable
|
|
6
7
|
from contextlib import asynccontextmanager
|
|
7
8
|
from dataclasses import dataclass, replace
|
|
8
9
|
from pathlib import Path
|
|
9
|
-
from typing import Any,
|
|
10
|
+
from typing import Any, BinaryIO, Callable, Optional, Union
|
|
10
11
|
|
|
11
12
|
import aiosqlite
|
|
12
13
|
|
|
@@ -495,15 +496,14 @@ class DataStore:
|
|
|
495
496
|
|
|
496
497
|
async def check(self) -> None:
|
|
497
498
|
for check in self._checks:
|
|
498
|
-
|
|
499
|
-
await check(self) # pylint: disable=too-many-function-args
|
|
499
|
+
await check(self)
|
|
500
500
|
|
|
501
501
|
async def _check_roots_are_incrementing(self) -> None:
|
|
502
502
|
async with self.db_wrapper.reader() as reader:
|
|
503
503
|
cursor = await reader.execute("SELECT * FROM root ORDER BY tree_id, generation")
|
|
504
504
|
roots = [Root.from_row(row=row) async for row in cursor]
|
|
505
505
|
|
|
506
|
-
roots_by_tree:
|
|
506
|
+
roots_by_tree: dict[bytes32, list[Root]] = defaultdict(list)
|
|
507
507
|
for root in roots:
|
|
508
508
|
roots_by_tree[root.store_id].append(root)
|
|
509
509
|
|
|
@@ -522,7 +522,7 @@ class DataStore:
|
|
|
522
522
|
async with self.db_wrapper.reader() as reader:
|
|
523
523
|
cursor = await reader.execute("SELECT * FROM node")
|
|
524
524
|
|
|
525
|
-
bad_node_hashes:
|
|
525
|
+
bad_node_hashes: list[bytes32] = []
|
|
526
526
|
async for row in cursor:
|
|
527
527
|
node = row_to_node(row=row)
|
|
528
528
|
if isinstance(node, InternalNode):
|
|
@@ -538,7 +538,7 @@ class DataStore:
|
|
|
538
538
|
if len(bad_node_hashes) > 0:
|
|
539
539
|
raise NodeHashError(node_hashes=bad_node_hashes)
|
|
540
540
|
|
|
541
|
-
_checks:
|
|
541
|
+
_checks: tuple[Callable[[DataStore], Awaitable[None]], ...] = (
|
|
542
542
|
_check_roots_are_incrementing,
|
|
543
543
|
_check_hashes,
|
|
544
544
|
)
|
|
@@ -553,7 +553,7 @@ class DataStore:
|
|
|
553
553
|
|
|
554
554
|
return tree_root.node_hash is None
|
|
555
555
|
|
|
556
|
-
async def get_store_ids(self) ->
|
|
556
|
+
async def get_store_ids(self) -> set[bytes32]:
|
|
557
557
|
async with self.db_wrapper.reader() as reader:
|
|
558
558
|
cursor = await reader.execute("SELECT DISTINCT tree_id FROM root")
|
|
559
559
|
|
|
@@ -597,7 +597,7 @@ class DataStore:
|
|
|
597
597
|
|
|
598
598
|
return Root.from_row(row=row)
|
|
599
599
|
|
|
600
|
-
async def get_all_pending_batches_roots(self) ->
|
|
600
|
+
async def get_all_pending_batches_roots(self) -> list[Root]:
|
|
601
601
|
async with self.db_wrapper.reader() as reader:
|
|
602
602
|
cursor = await reader.execute(
|
|
603
603
|
"""
|
|
@@ -623,7 +623,7 @@ class DataStore:
|
|
|
623
623
|
return False
|
|
624
624
|
return True
|
|
625
625
|
|
|
626
|
-
async def get_roots_between(self, store_id: bytes32, generation_begin: int, generation_end: int) ->
|
|
626
|
+
async def get_roots_between(self, store_id: bytes32, generation_begin: int, generation_end: int) -> list[Root]:
|
|
627
627
|
async with self.db_wrapper.reader() as reader:
|
|
628
628
|
cursor = await reader.execute(
|
|
629
629
|
"SELECT * FROM root WHERE tree_id == :tree_id "
|
|
@@ -658,7 +658,7 @@ class DataStore:
|
|
|
658
658
|
node_hash: bytes32,
|
|
659
659
|
store_id: bytes32,
|
|
660
660
|
root_hash: Optional[bytes32] = None,
|
|
661
|
-
) ->
|
|
661
|
+
) -> list[InternalNode]:
|
|
662
662
|
async with self.db_wrapper.reader() as reader:
|
|
663
663
|
if root_hash is None:
|
|
664
664
|
root = await self.get_tree_root(store_id=store_id)
|
|
@@ -702,7 +702,7 @@ class DataStore:
|
|
|
702
702
|
store_id: bytes32,
|
|
703
703
|
generation: Optional[int] = None,
|
|
704
704
|
root_hash: Optional[bytes32] = None,
|
|
705
|
-
) ->
|
|
705
|
+
) -> list[InternalNode]:
|
|
706
706
|
async with self.db_wrapper.reader():
|
|
707
707
|
nodes = []
|
|
708
708
|
if root_hash is None:
|
|
@@ -725,7 +725,7 @@ class DataStore:
|
|
|
725
725
|
|
|
726
726
|
return nodes
|
|
727
727
|
|
|
728
|
-
async def get_internal_nodes(self, store_id: bytes32, root_hash: Optional[bytes32] = None) ->
|
|
728
|
+
async def get_internal_nodes(self, store_id: bytes32, root_hash: Optional[bytes32] = None) -> list[InternalNode]:
|
|
729
729
|
async with self.db_wrapper.reader() as reader:
|
|
730
730
|
if root_hash is None:
|
|
731
731
|
root = await self.get_tree_root(store_id=store_id)
|
|
@@ -745,7 +745,7 @@ class DataStore:
|
|
|
745
745
|
{"root_hash": root_hash, "node_type": NodeType.INTERNAL},
|
|
746
746
|
)
|
|
747
747
|
|
|
748
|
-
internal_nodes:
|
|
748
|
+
internal_nodes: list[InternalNode] = []
|
|
749
749
|
async for row in cursor:
|
|
750
750
|
node = row_to_node(row=row)
|
|
751
751
|
if not isinstance(node, InternalNode):
|
|
@@ -791,7 +791,7 @@ class DataStore:
|
|
|
791
791
|
self,
|
|
792
792
|
store_id: bytes32,
|
|
793
793
|
root_hash: Union[bytes32, Unspecified] = unspecified,
|
|
794
|
-
) ->
|
|
794
|
+
) -> list[TerminalNode]:
|
|
795
795
|
async with self.db_wrapper.reader() as reader:
|
|
796
796
|
resolved_root_hash: Optional[bytes32]
|
|
797
797
|
if root_hash is unspecified:
|
|
@@ -801,7 +801,7 @@ class DataStore:
|
|
|
801
801
|
resolved_root_hash = root_hash
|
|
802
802
|
|
|
803
803
|
cursor = await self.get_keys_values_cursor(reader, resolved_root_hash)
|
|
804
|
-
terminal_nodes:
|
|
804
|
+
terminal_nodes: list[TerminalNode] = []
|
|
805
805
|
async for row in cursor:
|
|
806
806
|
if row["depth"] > 62:
|
|
807
807
|
# TODO: Review the value and implementation of left-to-right order
|
|
@@ -836,9 +836,9 @@ class DataStore:
|
|
|
836
836
|
resolved_root_hash = root_hash
|
|
837
837
|
|
|
838
838
|
cursor = await self.get_keys_values_cursor(reader, resolved_root_hash)
|
|
839
|
-
keys_values_hashed:
|
|
840
|
-
key_hash_to_length:
|
|
841
|
-
leaf_hash_to_length:
|
|
839
|
+
keys_values_hashed: dict[bytes32, bytes32] = {}
|
|
840
|
+
key_hash_to_length: dict[bytes32, int] = {}
|
|
841
|
+
leaf_hash_to_length: dict[bytes32, int] = {}
|
|
842
842
|
async for row in cursor:
|
|
843
843
|
if row["depth"] > 62:
|
|
844
844
|
raise Exception("Tree depth exceeded 62, unable to guarantee left-to-right node order.")
|
|
@@ -853,8 +853,8 @@ class DataStore:
|
|
|
853
853
|
|
|
854
854
|
async def get_leaf_hashes_by_hashed_key(
|
|
855
855
|
self, store_id: bytes32, root_hash: Optional[bytes32] = None
|
|
856
|
-
) ->
|
|
857
|
-
result:
|
|
856
|
+
) -> dict[bytes32, bytes32]:
|
|
857
|
+
result: dict[bytes32, bytes32] = {}
|
|
858
858
|
async with self.db_wrapper.reader() as reader:
|
|
859
859
|
if root_hash is None:
|
|
860
860
|
root = await self.get_tree_root(store_id=store_id)
|
|
@@ -876,7 +876,7 @@ class DataStore:
|
|
|
876
876
|
keys_values_compressed = await self.get_keys_values_compressed(store_id, root_hash)
|
|
877
877
|
pagination_data = get_hashes_for_page(page, keys_values_compressed.key_hash_to_length, max_page_size)
|
|
878
878
|
|
|
879
|
-
keys:
|
|
879
|
+
keys: list[bytes] = []
|
|
880
880
|
for hash in pagination_data.hashes:
|
|
881
881
|
leaf_hash = keys_values_compressed.keys_values_hashed[hash]
|
|
882
882
|
node = await self.get_node(leaf_hash)
|
|
@@ -900,7 +900,7 @@ class DataStore:
|
|
|
900
900
|
keys_values_compressed = await self.get_keys_values_compressed(store_id, root_hash)
|
|
901
901
|
pagination_data = get_hashes_for_page(page, keys_values_compressed.leaf_hash_to_length, max_page_size)
|
|
902
902
|
|
|
903
|
-
keys_values:
|
|
903
|
+
keys_values: list[TerminalNode] = []
|
|
904
904
|
for hash in pagination_data.hashes:
|
|
905
905
|
node = await self.get_node(hash)
|
|
906
906
|
assert isinstance(node, TerminalNode)
|
|
@@ -923,11 +923,11 @@ class DataStore:
|
|
|
923
923
|
hash2: bytes32,
|
|
924
924
|
) -> KVDiffPaginationData:
|
|
925
925
|
old_pairs = await self.get_keys_values_compressed(store_id, hash1)
|
|
926
|
-
if len(old_pairs.keys_values_hashed) == 0 and hash1 != bytes32
|
|
926
|
+
if len(old_pairs.keys_values_hashed) == 0 and hash1 != bytes32.zeros:
|
|
927
927
|
raise Exception(f"Unable to diff: Can't find keys and values for {hash1}")
|
|
928
928
|
|
|
929
929
|
new_pairs = await self.get_keys_values_compressed(store_id, hash2)
|
|
930
|
-
if len(new_pairs.keys_values_hashed) == 0 and hash2 != bytes32
|
|
930
|
+
if len(new_pairs.keys_values_hashed) == 0 and hash2 != bytes32.zeros:
|
|
931
931
|
raise Exception(f"Unable to diff: Can't find keys and values for {hash2}")
|
|
932
932
|
|
|
933
933
|
old_pairs_leaf_hashes = {v for v in old_pairs.keys_values_hashed.values()}
|
|
@@ -941,7 +941,7 @@ class DataStore:
|
|
|
941
941
|
lengths[hash] = old_pairs.leaf_hash_to_length[hash]
|
|
942
942
|
|
|
943
943
|
pagination_data = get_hashes_for_page(page, lengths, max_page_size)
|
|
944
|
-
kv_diff:
|
|
944
|
+
kv_diff: list[DiffData] = []
|
|
945
945
|
|
|
946
946
|
for hash in pagination_data.hashes:
|
|
947
947
|
node = await self.get_node(hash)
|
|
@@ -1063,7 +1063,7 @@ class DataStore:
|
|
|
1063
1063
|
self,
|
|
1064
1064
|
store_id: bytes32,
|
|
1065
1065
|
root_hash: Union[bytes32, Unspecified] = unspecified,
|
|
1066
|
-
) ->
|
|
1066
|
+
) -> dict[bytes, bytes]:
|
|
1067
1067
|
pairs = await self.get_keys_values(store_id=store_id, root_hash=root_hash)
|
|
1068
1068
|
return {node.key: node.value for node in pairs}
|
|
1069
1069
|
|
|
@@ -1071,7 +1071,7 @@ class DataStore:
|
|
|
1071
1071
|
self,
|
|
1072
1072
|
store_id: bytes32,
|
|
1073
1073
|
root_hash: Union[bytes32, Unspecified] = unspecified,
|
|
1074
|
-
) ->
|
|
1074
|
+
) -> list[bytes]:
|
|
1075
1075
|
async with self.db_wrapper.reader() as reader:
|
|
1076
1076
|
if root_hash is unspecified:
|
|
1077
1077
|
root = await self.get_tree_root(store_id=store_id)
|
|
@@ -1094,7 +1094,7 @@ class DataStore:
|
|
|
1094
1094
|
{"root_hash": resolved_root_hash, "node_type": NodeType.TERMINAL},
|
|
1095
1095
|
)
|
|
1096
1096
|
|
|
1097
|
-
keys:
|
|
1097
|
+
keys: list[bytes] = [row["key"] async for row in cursor]
|
|
1098
1098
|
|
|
1099
1099
|
return keys
|
|
1100
1100
|
|
|
@@ -1105,9 +1105,9 @@ class DataStore:
|
|
|
1105
1105
|
root_hash: Optional[bytes32],
|
|
1106
1106
|
generation: Optional[int] = None,
|
|
1107
1107
|
use_optimized: bool = True,
|
|
1108
|
-
) ->
|
|
1108
|
+
) -> list[InternalNode]:
|
|
1109
1109
|
if use_optimized:
|
|
1110
|
-
ancestors:
|
|
1110
|
+
ancestors: list[InternalNode] = await self.get_ancestors_optimized(
|
|
1111
1111
|
node_hash=node_hash,
|
|
1112
1112
|
store_id=store_id,
|
|
1113
1113
|
generation=generation,
|
|
@@ -1120,7 +1120,7 @@ class DataStore:
|
|
|
1120
1120
|
generation=generation,
|
|
1121
1121
|
root_hash=root_hash,
|
|
1122
1122
|
)
|
|
1123
|
-
ancestors_2:
|
|
1123
|
+
ancestors_2: list[InternalNode] = await self.get_ancestors(
|
|
1124
1124
|
node_hash=node_hash, store_id=store_id, root_hash=root_hash
|
|
1125
1125
|
)
|
|
1126
1126
|
if ancestors != ancestors_2:
|
|
@@ -1136,12 +1136,12 @@ class DataStore:
|
|
|
1136
1136
|
left: bytes32,
|
|
1137
1137
|
right: bytes32,
|
|
1138
1138
|
traversal_node_hash: bytes32,
|
|
1139
|
-
ancestors:
|
|
1139
|
+
ancestors: list[InternalNode],
|
|
1140
1140
|
status: Status,
|
|
1141
1141
|
root: Root,
|
|
1142
1142
|
) -> Root:
|
|
1143
1143
|
# update ancestors after inserting root, to keep table constraints.
|
|
1144
|
-
insert_ancestors_cache:
|
|
1144
|
+
insert_ancestors_cache: list[tuple[bytes32, bytes32, bytes32]] = []
|
|
1145
1145
|
new_generation = root.generation + 1
|
|
1146
1146
|
# create first new internal node
|
|
1147
1147
|
new_hash = await self._insert_internal_node(left_hash=left, right_hash=right)
|
|
@@ -1212,7 +1212,7 @@ class DataStore:
|
|
|
1212
1212
|
|
|
1213
1213
|
if was_empty:
|
|
1214
1214
|
if side is not None:
|
|
1215
|
-
raise Exception("Tree was empty so side must be unspecified, got: {side!r}")
|
|
1215
|
+
raise Exception(f"Tree was empty so side must be unspecified, got: {side!r}")
|
|
1216
1216
|
|
|
1217
1217
|
new_root = await self._insert_root(
|
|
1218
1218
|
store_id=store_id,
|
|
@@ -1273,7 +1273,7 @@ class DataStore:
|
|
|
1273
1273
|
log.debug(f"Request to delete an unknown key ignored: {key.hex()}")
|
|
1274
1274
|
return root
|
|
1275
1275
|
|
|
1276
|
-
ancestors:
|
|
1276
|
+
ancestors: list[InternalNode] = await self.get_ancestors_common(
|
|
1277
1277
|
node_hash=node_hash,
|
|
1278
1278
|
store_id=store_id,
|
|
1279
1279
|
root_hash=root_hash,
|
|
@@ -1306,7 +1306,7 @@ class DataStore:
|
|
|
1306
1306
|
else:
|
|
1307
1307
|
new_generation = root.generation + 1
|
|
1308
1308
|
# update ancestors after inserting root, to keep table constraints.
|
|
1309
|
-
insert_ancestors_cache:
|
|
1309
|
+
insert_ancestors_cache: list[tuple[bytes32, bytes32, bytes32]] = []
|
|
1310
1310
|
# more parents to handle so let's traverse them
|
|
1311
1311
|
for ancestor in ancestors[1:]:
|
|
1312
1312
|
if ancestor.left_hash == old_child_hash:
|
|
@@ -1433,7 +1433,7 @@ class DataStore:
|
|
|
1433
1433
|
else:
|
|
1434
1434
|
await writer.execute(query, params)
|
|
1435
1435
|
|
|
1436
|
-
async def get_nodes(self, node_hashes:
|
|
1436
|
+
async def get_nodes(self, node_hashes: list[bytes32]) -> list[Node]:
|
|
1437
1437
|
query_parameter_place_holders = ",".join("?" for _ in node_hashes)
|
|
1438
1438
|
async with self.db_wrapper.reader() as reader:
|
|
1439
1439
|
# TODO: handle SQLITE_MAX_VARIABLE_NUMBER
|
|
@@ -1452,9 +1452,9 @@ class DataStore:
|
|
|
1452
1452
|
return [hash_to_node[node_hash] for node_hash in node_hashes]
|
|
1453
1453
|
|
|
1454
1454
|
async def get_leaf_at_minimum_height(
|
|
1455
|
-
self, root_hash: bytes32, hash_to_parent:
|
|
1455
|
+
self, root_hash: bytes32, hash_to_parent: dict[bytes32, InternalNode]
|
|
1456
1456
|
) -> TerminalNode:
|
|
1457
|
-
queue:
|
|
1457
|
+
queue: list[bytes32] = [root_hash]
|
|
1458
1458
|
batch_size = min(500, SQLITE_MAX_VARIABLE_NUMBER - 10)
|
|
1459
1459
|
|
|
1460
1460
|
while True:
|
|
@@ -1473,8 +1473,8 @@ class DataStore:
|
|
|
1473
1473
|
async def batch_upsert(
|
|
1474
1474
|
self,
|
|
1475
1475
|
hash: bytes32,
|
|
1476
|
-
to_update_hashes:
|
|
1477
|
-
pending_upsert_new_hashes:
|
|
1476
|
+
to_update_hashes: set[bytes32],
|
|
1477
|
+
pending_upsert_new_hashes: dict[bytes32, bytes32],
|
|
1478
1478
|
) -> bytes32:
|
|
1479
1479
|
if hash not in to_update_hashes:
|
|
1480
1480
|
return hash
|
|
@@ -1488,7 +1488,7 @@ class DataStore:
|
|
|
1488
1488
|
async def insert_batch(
|
|
1489
1489
|
self,
|
|
1490
1490
|
store_id: bytes32,
|
|
1491
|
-
changelist:
|
|
1491
|
+
changelist: list[dict[str, Any]],
|
|
1492
1492
|
status: Status = Status.PENDING,
|
|
1493
1493
|
enable_batch_autoinsert: bool = True,
|
|
1494
1494
|
) -> Optional[bytes32]:
|
|
@@ -1510,9 +1510,9 @@ class DataStore:
|
|
|
1510
1510
|
|
|
1511
1511
|
assert latest_local_root is not None
|
|
1512
1512
|
|
|
1513
|
-
key_hash_frequency:
|
|
1514
|
-
first_action:
|
|
1515
|
-
last_action:
|
|
1513
|
+
key_hash_frequency: dict[bytes32, int] = {}
|
|
1514
|
+
first_action: dict[bytes32, str] = {}
|
|
1515
|
+
last_action: dict[bytes32, str] = {}
|
|
1516
1516
|
|
|
1517
1517
|
for change in changelist:
|
|
1518
1518
|
key = change["key"]
|
|
@@ -1522,8 +1522,8 @@ class DataStore:
|
|
|
1522
1522
|
first_action[hash] = change["action"]
|
|
1523
1523
|
last_action[hash] = change["action"]
|
|
1524
1524
|
|
|
1525
|
-
pending_autoinsert_hashes:
|
|
1526
|
-
pending_upsert_new_hashes:
|
|
1525
|
+
pending_autoinsert_hashes: list[bytes32] = []
|
|
1526
|
+
pending_upsert_new_hashes: dict[bytes32, bytes32] = {}
|
|
1527
1527
|
leaf_hashes = await self.get_leaf_hashes_by_hashed_key(store_id)
|
|
1528
1528
|
|
|
1529
1529
|
for change in changelist:
|
|
@@ -1598,8 +1598,8 @@ class DataStore:
|
|
|
1598
1598
|
raise Exception(f"Operation in batch is not insert or delete: {change}")
|
|
1599
1599
|
|
|
1600
1600
|
if len(pending_upsert_new_hashes) > 0:
|
|
1601
|
-
to_update_hashes:
|
|
1602
|
-
to_update_queue:
|
|
1601
|
+
to_update_hashes: set[bytes32] = set(pending_upsert_new_hashes.keys())
|
|
1602
|
+
to_update_queue: list[bytes32] = list(pending_upsert_new_hashes.keys())
|
|
1603
1603
|
batch_size = min(500, SQLITE_MAX_VARIABLE_NUMBER - 10)
|
|
1604
1604
|
|
|
1605
1605
|
while len(to_update_queue) > 0:
|
|
@@ -1622,7 +1622,7 @@ class DataStore:
|
|
|
1622
1622
|
# Start with the leaf nodes and pair them to form new nodes at the next level up, repeating this process
|
|
1623
1623
|
# in a bottom-up fashion until a single root node remains. This constructs a balanced tree from the leaves.
|
|
1624
1624
|
while len(pending_autoinsert_hashes) > 1:
|
|
1625
|
-
new_hashes:
|
|
1625
|
+
new_hashes: list[bytes32] = []
|
|
1626
1626
|
for i in range(0, len(pending_autoinsert_hashes) - 1, 2):
|
|
1627
1627
|
internal_node_hash = await self._insert_internal_node(
|
|
1628
1628
|
pending_autoinsert_hashes[i], pending_autoinsert_hashes[i + 1]
|
|
@@ -1638,9 +1638,9 @@ class DataStore:
|
|
|
1638
1638
|
if latest_local_root is None or latest_local_root.node_hash is None:
|
|
1639
1639
|
await self._insert_root(store_id=store_id, node_hash=subtree_hash, status=Status.COMMITTED)
|
|
1640
1640
|
else:
|
|
1641
|
-
hash_to_parent:
|
|
1641
|
+
hash_to_parent: dict[bytes32, InternalNode] = {}
|
|
1642
1642
|
min_height_leaf = await self.get_leaf_at_minimum_height(latest_local_root.node_hash, hash_to_parent)
|
|
1643
|
-
ancestors:
|
|
1643
|
+
ancestors: list[InternalNode] = []
|
|
1644
1644
|
hash = min_height_leaf.hash
|
|
1645
1645
|
while hash in hash_to_parent:
|
|
1646
1646
|
node = hash_to_parent[hash]
|
|
@@ -1665,7 +1665,7 @@ class DataStore:
|
|
|
1665
1665
|
# We delete all "temporary" records stored in root and ancestor tables and store only the final result.
|
|
1666
1666
|
await self.rollback_to_generation(store_id, old_root.generation)
|
|
1667
1667
|
await self.insert_root_with_ancestor_table(store_id=store_id, node_hash=root.node_hash, status=status)
|
|
1668
|
-
if status in
|
|
1668
|
+
if status in {Status.PENDING, Status.PENDING_BATCH}:
|
|
1669
1669
|
new_root = await self.get_pending_root(store_id=store_id)
|
|
1670
1670
|
assert new_root is not None
|
|
1671
1671
|
elif status == Status.COMMITTED:
|
|
@@ -1712,10 +1712,10 @@ class DataStore:
|
|
|
1712
1712
|
|
|
1713
1713
|
async def _get_one_ancestor_multiple_hashes(
|
|
1714
1714
|
self,
|
|
1715
|
-
node_hashes:
|
|
1715
|
+
node_hashes: list[bytes32],
|
|
1716
1716
|
store_id: bytes32,
|
|
1717
1717
|
generation: Optional[int] = None,
|
|
1718
|
-
) ->
|
|
1718
|
+
) -> list[InternalNode]:
|
|
1719
1719
|
async with self.db_wrapper.reader() as reader:
|
|
1720
1720
|
node_hashes_place_holders = ",".join("?" for _ in node_hashes)
|
|
1721
1721
|
if generation is None:
|
|
@@ -1747,14 +1747,14 @@ class DataStore:
|
|
|
1747
1747
|
)
|
|
1748
1748
|
|
|
1749
1749
|
if previous_root.node_hash is not None:
|
|
1750
|
-
previous_internal_nodes:
|
|
1750
|
+
previous_internal_nodes: list[InternalNode] = await self.get_internal_nodes(
|
|
1751
1751
|
store_id=store_id,
|
|
1752
1752
|
root_hash=previous_root.node_hash,
|
|
1753
1753
|
)
|
|
1754
|
-
known_hashes:
|
|
1754
|
+
known_hashes: set[bytes32] = {node.hash for node in previous_internal_nodes}
|
|
1755
1755
|
else:
|
|
1756
1756
|
known_hashes = set()
|
|
1757
|
-
internal_nodes:
|
|
1757
|
+
internal_nodes: list[InternalNode] = await self.get_internal_nodes(
|
|
1758
1758
|
store_id=store_id,
|
|
1759
1759
|
root_hash=root.node_hash,
|
|
1760
1760
|
)
|
|
@@ -1809,7 +1809,7 @@ class DataStore:
|
|
|
1809
1809
|
return node
|
|
1810
1810
|
|
|
1811
1811
|
async def maybe_get_node_from_key_hash(
|
|
1812
|
-
self, leaf_hashes:
|
|
1812
|
+
self, leaf_hashes: dict[bytes32, bytes32], hash: bytes32
|
|
1813
1813
|
) -> Optional[TerminalNode]:
|
|
1814
1814
|
if hash in leaf_hashes:
|
|
1815
1815
|
leaf_hash = leaf_hashes[hash]
|
|
@@ -1875,7 +1875,7 @@ class DataStore:
|
|
|
1875
1875
|
{"root_hash": root_node.hash},
|
|
1876
1876
|
)
|
|
1877
1877
|
nodes = [row_to_node(row=row) async for row in cursor]
|
|
1878
|
-
hash_to_node:
|
|
1878
|
+
hash_to_node: dict[bytes32, Node] = {}
|
|
1879
1879
|
for node in reversed(nodes):
|
|
1880
1880
|
if isinstance(node, InternalNode):
|
|
1881
1881
|
node = replace(node, left=hash_to_node[node.left_hash], right=hash_to_node[node.right_hash])
|
|
@@ -1904,7 +1904,7 @@ class DataStore:
|
|
|
1904
1904
|
else:
|
|
1905
1905
|
ancestors = await self.get_ancestors(node_hash=node_hash, store_id=store_id, root_hash=root_hash)
|
|
1906
1906
|
|
|
1907
|
-
layers:
|
|
1907
|
+
layers: list[ProofOfInclusionLayer] = []
|
|
1908
1908
|
child_hash = node_hash
|
|
1909
1909
|
for parent in ancestors:
|
|
1910
1910
|
layer = ProofOfInclusionLayer.from_internal_node(internal_node=parent, traversal_child_hash=child_hash)
|
|
@@ -1959,7 +1959,7 @@ class DataStore:
|
|
|
1959
1959
|
deltas_only: bool,
|
|
1960
1960
|
writer: BinaryIO,
|
|
1961
1961
|
) -> None:
|
|
1962
|
-
if node_hash == bytes32
|
|
1962
|
+
if node_hash == bytes32.zeros:
|
|
1963
1963
|
return
|
|
1964
1964
|
|
|
1965
1965
|
if deltas_only:
|
|
@@ -1981,7 +1981,7 @@ class DataStore:
|
|
|
1981
1981
|
writer.write(len(to_write).to_bytes(4, byteorder="big"))
|
|
1982
1982
|
writer.write(to_write)
|
|
1983
1983
|
|
|
1984
|
-
async def update_subscriptions_from_wallet(self, store_id: bytes32, new_urls:
|
|
1984
|
+
async def update_subscriptions_from_wallet(self, store_id: bytes32, new_urls: list[str]) -> None:
|
|
1985
1985
|
async with self.db_wrapper.writer() as writer:
|
|
1986
1986
|
cursor = await writer.execute(
|
|
1987
1987
|
"SELECT * FROM subscriptions WHERE from_wallet == 1 AND tree_id == :tree_id",
|
|
@@ -2053,7 +2053,7 @@ class DataStore:
|
|
|
2053
2053
|
},
|
|
2054
2054
|
)
|
|
2055
2055
|
|
|
2056
|
-
async def remove_subscriptions(self, store_id: bytes32, urls:
|
|
2056
|
+
async def remove_subscriptions(self, store_id: bytes32, urls: list[str]) -> None:
|
|
2057
2057
|
async with self.db_wrapper.writer() as writer:
|
|
2058
2058
|
for url in urls:
|
|
2059
2059
|
await writer.execute(
|
|
@@ -2099,8 +2099,8 @@ class DataStore:
|
|
|
2099
2099
|
"pending_batch_status": Status.PENDING_BATCH.value,
|
|
2100
2100
|
},
|
|
2101
2101
|
)
|
|
2102
|
-
to_delete:
|
|
2103
|
-
ref_counts:
|
|
2102
|
+
to_delete: dict[bytes, tuple[bytes, bytes]] = {}
|
|
2103
|
+
ref_counts: dict[bytes, int] = {}
|
|
2104
2104
|
async for row in cursor:
|
|
2105
2105
|
hash = row["hash"]
|
|
2106
2106
|
left = row["left"]
|
|
@@ -2195,7 +2195,7 @@ class DataStore:
|
|
|
2195
2195
|
await self.update_server_info(store_id, new_server_info)
|
|
2196
2196
|
return new_server_info
|
|
2197
2197
|
|
|
2198
|
-
async def get_available_servers_for_store(self, store_id: bytes32, timestamp: int) ->
|
|
2198
|
+
async def get_available_servers_for_store(self, store_id: bytes32, timestamp: int) -> list[ServerInfo]:
|
|
2199
2199
|
subscriptions = await self.get_subscriptions()
|
|
2200
2200
|
subscription = next((subscription for subscription in subscriptions if subscription.store_id == store_id), None)
|
|
2201
2201
|
if subscription is None:
|
|
@@ -2206,8 +2206,8 @@ class DataStore:
|
|
|
2206
2206
|
servers_info.append(server_info)
|
|
2207
2207
|
return servers_info
|
|
2208
2208
|
|
|
2209
|
-
async def get_subscriptions(self) ->
|
|
2210
|
-
subscriptions:
|
|
2209
|
+
async def get_subscriptions(self) -> list[Subscription]:
|
|
2210
|
+
subscriptions: list[Subscription] = []
|
|
2211
2211
|
|
|
2212
2212
|
async with self.db_wrapper.reader() as reader:
|
|
2213
2213
|
cursor = await reader.execute(
|
|
@@ -2244,14 +2244,14 @@ class DataStore:
|
|
|
2244
2244
|
# NOTE: empty is expressed as zeros
|
|
2245
2245
|
hash_1: bytes32,
|
|
2246
2246
|
hash_2: bytes32,
|
|
2247
|
-
) ->
|
|
2247
|
+
) -> set[DiffData]:
|
|
2248
2248
|
async with self.db_wrapper.reader():
|
|
2249
2249
|
old_pairs = set(await self.get_keys_values(store_id, hash_1))
|
|
2250
|
-
if len(old_pairs) == 0 and hash_1 != bytes32
|
|
2250
|
+
if len(old_pairs) == 0 and hash_1 != bytes32.zeros:
|
|
2251
2251
|
raise Exception(f"Unable to diff: Can't find keys and values for {hash_1}")
|
|
2252
2252
|
|
|
2253
2253
|
new_pairs = set(await self.get_keys_values(store_id, hash_2))
|
|
2254
|
-
if len(new_pairs) == 0 and hash_2 != bytes32
|
|
2254
|
+
if len(new_pairs) == 0 and hash_2 != bytes32.zeros:
|
|
2255
2255
|
raise Exception(f"Unable to diff: Can't find keys and values for {hash_2}")
|
|
2256
2256
|
|
|
2257
2257
|
insertions = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import dataclasses
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Optional, TypeVar, Union
|
|
5
5
|
|
|
6
6
|
from aiosqlite import Row
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ def _row_to_singleton_record(row: Row) -> SingletonRecord:
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def _row_to_mirror(row: Row, confirmed_at_height: Optional[uint32]) -> Mirror:
|
|
33
|
-
urls:
|
|
33
|
+
urls: list[bytes] = []
|
|
34
34
|
byte_list: bytes = row[3]
|
|
35
35
|
while byte_list != b"":
|
|
36
36
|
length = uint16.from_bytes(byte_list[0:2])
|
|
@@ -48,7 +48,7 @@ class DataLayerStore:
|
|
|
48
48
|
db_wrapper: DBWrapper2
|
|
49
49
|
|
|
50
50
|
@classmethod
|
|
51
|
-
async def create(cls:
|
|
51
|
+
async def create(cls: type[_T_DataLayerStore], db_wrapper: DBWrapper2) -> _T_DataLayerStore:
|
|
52
52
|
self = cls()
|
|
53
53
|
|
|
54
54
|
self.db_wrapper = db_wrapper
|
|
@@ -131,11 +131,11 @@ class DataLayerStore:
|
|
|
131
131
|
min_generation: Optional[uint32] = None,
|
|
132
132
|
max_generation: Optional[uint32] = None,
|
|
133
133
|
num_results: Optional[uint32] = None,
|
|
134
|
-
) ->
|
|
134
|
+
) -> list[SingletonRecord]:
|
|
135
135
|
"""
|
|
136
136
|
Returns stored singletons with a specific launcher ID.
|
|
137
137
|
"""
|
|
138
|
-
query_params:
|
|
138
|
+
query_params: list[Union[bytes32, uint32]] = [launcher_id]
|
|
139
139
|
for optional_param in (min_generation, max_generation, num_results):
|
|
140
140
|
if optional_param is not None:
|
|
141
141
|
query_params.append(optional_param)
|
|
@@ -200,7 +200,7 @@ class DataLayerStore:
|
|
|
200
200
|
return _row_to_singleton_record(row)
|
|
201
201
|
return None
|
|
202
202
|
|
|
203
|
-
async def get_unconfirmed_singletons(self, launcher_id: bytes32) ->
|
|
203
|
+
async def get_unconfirmed_singletons(self, launcher_id: bytes32) -> list[SingletonRecord]:
|
|
204
204
|
"""
|
|
205
205
|
Returns all singletons with a specific launcher id that have not yet been marked confirmed
|
|
206
206
|
"""
|
|
@@ -214,7 +214,7 @@ class DataLayerStore:
|
|
|
214
214
|
|
|
215
215
|
return records
|
|
216
216
|
|
|
217
|
-
async def get_singletons_by_root(self, launcher_id: bytes32, root: bytes32) ->
|
|
217
|
+
async def get_singletons_by_root(self, launcher_id: bytes32, root: bytes32) -> list[SingletonRecord]:
|
|
218
218
|
async with self.db_wrapper.reader_no_transaction() as conn:
|
|
219
219
|
cursor = await conn.execute(
|
|
220
220
|
"SELECT * from singleton_records WHERE launcher_id=? AND root=? ORDER BY generation DESC",
|
|
@@ -276,7 +276,7 @@ class DataLayerStore:
|
|
|
276
276
|
return Coin(bytes32(row[1][0:32]), bytes32(row[1][32:64]), uint64(int.from_bytes(row[1][64:72], "big")))
|
|
277
277
|
return None
|
|
278
278
|
|
|
279
|
-
async def get_all_launchers(self) ->
|
|
279
|
+
async def get_all_launchers(self) -> list[bytes32]:
|
|
280
280
|
"""
|
|
281
281
|
Checks DB for all launchers.
|
|
282
282
|
"""
|
|
@@ -329,7 +329,7 @@ class DataLayerStore:
|
|
|
329
329
|
),
|
|
330
330
|
)
|
|
331
331
|
|
|
332
|
-
async def get_mirrors(self, launcher_id: bytes32) ->
|
|
332
|
+
async def get_mirrors(self, launcher_id: bytes32) -> list[Mirror]:
|
|
333
333
|
async with self.db_wrapper.reader_no_transaction() as conn:
|
|
334
334
|
cursor = await conn.execute(
|
|
335
335
|
"SELECT * from mirrors WHERE launcher_id=?",
|
|
@@ -337,7 +337,7 @@ class DataLayerStore:
|
|
|
337
337
|
)
|
|
338
338
|
rows = await cursor.fetchall()
|
|
339
339
|
await cursor.close()
|
|
340
|
-
mirrors:
|
|
340
|
+
mirrors: list[Mirror] = []
|
|
341
341
|
|
|
342
342
|
for row in rows:
|
|
343
343
|
confirmation_height = await execute_fetchone(
|
chia/data_layer/download_data.py
CHANGED
|
@@ -5,7 +5,7 @@ import logging
|
|
|
5
5
|
import time
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import
|
|
8
|
+
from typing import Optional
|
|
9
9
|
|
|
10
10
|
import aiohttp
|
|
11
11
|
from typing_extensions import Literal
|
|
@@ -145,7 +145,7 @@ async def write_files_for_root(
|
|
|
145
145
|
if root.node_hash is not None:
|
|
146
146
|
node_hash = root.node_hash
|
|
147
147
|
else:
|
|
148
|
-
node_hash = bytes32
|
|
148
|
+
node_hash = bytes32.zeros # todo change
|
|
149
149
|
|
|
150
150
|
filename_full_tree = get_full_tree_filename_path(foldername, store_id, node_hash, root.generation, group_by_store)
|
|
151
151
|
filename_diff_tree = get_delta_filename_path(foldername, store_id, node_hash, root.generation, group_by_store)
|
|
@@ -237,7 +237,7 @@ async def insert_from_delta_file(
|
|
|
237
237
|
store_id: bytes32,
|
|
238
238
|
existing_generation: int,
|
|
239
239
|
target_generation: int,
|
|
240
|
-
root_hashes:
|
|
240
|
+
root_hashes: list[bytes32],
|
|
241
241
|
server_info: ServerInfo,
|
|
242
242
|
client_foldername: Path,
|
|
243
243
|
timeout: aiohttp.ClientTimeout,
|
|
@@ -291,7 +291,7 @@ async def insert_from_delta_file(
|
|
|
291
291
|
num_inserted = await insert_into_data_store_from_file(
|
|
292
292
|
data_store,
|
|
293
293
|
store_id,
|
|
294
|
-
None if root_hash == bytes32
|
|
294
|
+
None if root_hash == bytes32.zeros else root_hash,
|
|
295
295
|
target_filename_path,
|
|
296
296
|
)
|
|
297
297
|
log.info(
|
|
@@ -336,7 +336,7 @@ def delete_full_file_if_exists(foldername: Path, store_id: bytes32, root: Root)
|
|
|
336
336
|
if root.node_hash is not None:
|
|
337
337
|
node_hash = root.node_hash
|
|
338
338
|
else:
|
|
339
|
-
node_hash = bytes32
|
|
339
|
+
node_hash = bytes32.zeros # todo change
|
|
340
340
|
|
|
341
341
|
not_found = 0
|
|
342
342
|
for group_by_store in (True, False):
|