chia-blockchain 2.5.7rc4__py3-none-any.whl → 2.6.0rc2__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.
Files changed (531) hide show
  1. chia/__init__.py +8 -4
  2. chia/_tests/blockchain/blockchain_test_utils.py +6 -8
  3. chia/_tests/blockchain/test_augmented_chain.py +4 -4
  4. chia/_tests/blockchain/test_blockchain.py +165 -190
  5. chia/_tests/blockchain/test_blockchain_transactions.py +5 -2
  6. chia/_tests/blockchain/test_build_chains.py +2 -4
  7. chia/_tests/blockchain/test_get_block_generator.py +2 -3
  8. chia/_tests/clvm/coin_store.py +4 -7
  9. chia/_tests/clvm/test_clvm_step.py +4 -4
  10. chia/_tests/clvm/test_puzzle_compression.py +2 -1
  11. chia/_tests/clvm/test_puzzle_drivers.py +2 -2
  12. chia/_tests/clvm/test_singletons.py +2 -4
  13. chia/_tests/clvm/test_spend_sim.py +2 -2
  14. chia/_tests/cmds/cmd_test_utils.py +27 -45
  15. chia/_tests/cmds/test_cmd_framework.py +6 -6
  16. chia/_tests/cmds/test_daemon.py +3 -3
  17. chia/_tests/cmds/test_show.py +4 -4
  18. chia/_tests/cmds/test_tx_config_args.py +1 -2
  19. chia/_tests/cmds/testing_classes.py +4 -5
  20. chia/_tests/cmds/wallet/test_did.py +24 -27
  21. chia/_tests/cmds/wallet/test_nft.py +12 -10
  22. chia/_tests/cmds/wallet/test_vcs.py +11 -12
  23. chia/_tests/cmds/wallet/test_wallet.py +134 -89
  24. chia/_tests/conftest.py +66 -31
  25. chia/_tests/connection_utils.py +2 -2
  26. chia/_tests/core/cmds/test_beta.py +4 -4
  27. chia/_tests/core/cmds/test_keys.py +2 -3
  28. chia/_tests/core/cmds/test_wallet.py +15 -15
  29. chia/_tests/core/consensus/test_pot_iterations.py +19 -73
  30. chia/_tests/core/custom_types/test_proof_of_space.py +124 -98
  31. chia/_tests/core/daemon/test_daemon.py +11 -11
  32. chia/_tests/core/data_layer/conftest.py +2 -2
  33. chia/_tests/core/data_layer/test_data_rpc.py +28 -14
  34. chia/_tests/core/data_layer/test_data_store.py +10 -10
  35. chia/_tests/core/data_layer/util.py +11 -11
  36. chia/_tests/core/farmer/test_farmer_api.py +2 -4
  37. chia/_tests/core/full_node/full_sync/test_full_sync.py +8 -7
  38. chia/_tests/core/full_node/stores/test_block_store.py +5 -4
  39. chia/_tests/core/full_node/stores/test_coin_store.py +5 -11
  40. chia/_tests/core/full_node/stores/test_full_node_store.py +8 -8
  41. chia/_tests/core/full_node/stores/test_hint_store.py +2 -2
  42. chia/_tests/core/full_node/test_block_height_map.py +3 -4
  43. chia/_tests/core/full_node/test_conditions.py +21 -23
  44. chia/_tests/core/full_node/test_full_node.py +273 -70
  45. chia/_tests/core/full_node/test_hard_fork_utils.py +92 -0
  46. chia/_tests/core/full_node/test_hint_management.py +2 -4
  47. chia/_tests/core/full_node/test_performance.py +0 -1
  48. chia/_tests/core/full_node/test_prev_tx_block.py +88 -11
  49. chia/_tests/core/full_node/test_transactions.py +1 -2
  50. chia/_tests/core/full_node/test_tx_processing_queue.py +198 -30
  51. chia/_tests/core/mempool/test_mempool.py +54 -50
  52. chia/_tests/core/mempool/test_mempool_fee_estimator.py +39 -39
  53. chia/_tests/core/mempool/test_mempool_fee_protocol.py +2 -6
  54. chia/_tests/core/mempool/test_mempool_manager.py +988 -854
  55. chia/_tests/core/mempool/test_singleton_fast_forward.py +6 -6
  56. chia/_tests/core/server/serve.py +7 -7
  57. chia/_tests/core/server/test_dos.py +1 -2
  58. chia/_tests/core/server/test_event_loop.py +12 -4
  59. chia/_tests/core/server/test_loop.py +7 -8
  60. chia/_tests/core/server/test_rate_limits.py +9 -8
  61. chia/_tests/core/server/test_server.py +61 -1
  62. chia/_tests/core/services/test_services.py +2 -2
  63. chia/_tests/core/ssl/test_ssl.py +2 -2
  64. chia/_tests/core/test_cost_calculation.py +2 -6
  65. chia/_tests/core/test_farmer_harvester_rpc.py +3 -5
  66. chia/_tests/core/test_filter.py +0 -1
  67. chia/_tests/core/test_full_node_rpc.py +2 -2
  68. chia/_tests/core/test_merkle_set.py +1 -2
  69. chia/_tests/core/test_seeder.py +4 -4
  70. chia/_tests/core/util/test_config.py +4 -4
  71. chia/_tests/core/util/test_jsonify.py +2 -2
  72. chia/_tests/core/util/test_keychain.py +3 -3
  73. chia/_tests/core/util/test_lockfile.py +2 -1
  74. chia/_tests/core/util/test_log_exceptions.py +1 -2
  75. chia/_tests/core/util/test_streamable.py +17 -17
  76. chia/_tests/db/test_db_wrapper.py +3 -2
  77. chia/_tests/environments/wallet.py +14 -14
  78. chia/_tests/ether.py +4 -3
  79. chia/_tests/farmer_harvester/test_farmer.py +41 -24
  80. chia/_tests/farmer_harvester/test_farmer_harvester.py +50 -17
  81. chia/_tests/farmer_harvester/test_filter_prefix_bits.py +27 -27
  82. chia/_tests/farmer_harvester/test_third_party_harvesters.py +21 -22
  83. chia/_tests/fee_estimation/test_fee_estimation_integration.py +18 -18
  84. chia/_tests/fee_estimation/test_fee_estimation_rpc.py +11 -9
  85. chia/_tests/harvester/test_harvester_api.py +11 -4
  86. chia/_tests/plot_sync/test_plot_sync.py +13 -11
  87. chia/_tests/plot_sync/test_receiver.py +11 -10
  88. chia/_tests/plot_sync/test_sync_simulated.py +2 -2
  89. chia/_tests/plot_sync/util.py +1 -2
  90. chia/_tests/plotting/test_plot_manager.py +7 -6
  91. chia/_tests/plotting/test_prover.py +30 -38
  92. chia/_tests/pools/test_pool_cmdline.py +4 -6
  93. chia/_tests/pools/test_pool_rpc.py +203 -61
  94. chia/_tests/pools/test_pool_wallet.py +3 -3
  95. chia/_tests/pools/test_wallet_pool_store.py +1 -4
  96. chia/_tests/process_junit.py +2 -2
  97. chia/_tests/rpc/test_rpc_client.py +4 -4
  98. chia/_tests/rpc/test_rpc_server.py +3 -3
  99. chia/_tests/simulation/test_simulation.py +12 -25
  100. chia/_tests/solver/test_solver_service.py +13 -4
  101. chia/_tests/testconfig.py +2 -2
  102. chia/_tests/timelord/test_new_peak.py +22 -11
  103. chia/_tests/tools/test_run_block.py +0 -2
  104. chia/_tests/tools/test_virtual_project.py +2 -1
  105. chia/_tests/util/benchmarks.py +1 -0
  106. chia/_tests/util/blockchain.py +38 -36
  107. chia/_tests/util/blockchain_mock.py +11 -11
  108. chia/_tests/util/build_network_protocol_files.py +2 -1
  109. chia/_tests/util/coin_store.py +2 -1
  110. chia/_tests/util/config.py +1 -1
  111. chia/_tests/util/db_connection.py +2 -3
  112. chia/_tests/util/full_sync.py +9 -11
  113. chia/_tests/util/gen_ssl_certs.py +4 -5
  114. chia/_tests/util/get_name_puzzle_conditions.py +2 -0
  115. chia/_tests/util/misc.py +24 -24
  116. chia/_tests/util/network_protocol_data.py +20 -3
  117. chia/_tests/util/protocol_messages_bytes-v1.0 +0 -0
  118. chia/_tests/util/protocol_messages_json.py +292 -3
  119. chia/_tests/util/setup_nodes.py +62 -47
  120. chia/_tests/util/spend_sim.py +57 -57
  121. chia/_tests/util/test_async_pool.py +2 -3
  122. chia/_tests/util/test_chia_version.py +1 -3
  123. chia/_tests/util/test_config.py +3 -3
  124. chia/_tests/util/test_full_block_utils.py +6 -3
  125. chia/_tests/util/test_limited_semaphore.py +1 -2
  126. chia/_tests/util/test_misc.py +2 -2
  127. chia/_tests/util/test_network.py +1 -2
  128. chia/_tests/util/test_priority_mutex.py +3 -3
  129. chia/_tests/util/test_recursive_replace.py +5 -6
  130. chia/_tests/util/test_replace_str_to_bytes.py +9 -10
  131. chia/_tests/util/test_testnet_overrides.py +3 -3
  132. chia/_tests/util/time_out_assert.py +2 -2
  133. chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +4 -6
  134. chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +2 -4
  135. chia/_tests/wallet/cat_wallet/test_cat_wallet.py +19 -13
  136. chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +13 -13
  137. chia/_tests/wallet/cat_wallet/test_trades.py +40 -38
  138. chia/_tests/wallet/clawback/test_clawback_lifecycle.py +2 -4
  139. chia/_tests/wallet/conftest.py +6 -6
  140. chia/_tests/wallet/db_wallet/test_db_graftroot.py +1 -1
  141. chia/_tests/wallet/db_wallet/test_dl_offers.py +34 -34
  142. chia/_tests/wallet/did_wallet/test_did.py +16 -6
  143. chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +21 -21
  144. chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +20 -6
  145. chia/_tests/wallet/nft_wallet/test_nft_offers.py +19 -21
  146. chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +1 -2
  147. chia/_tests/wallet/nft_wallet/test_nft_wallet.py +121 -2
  148. chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +6 -9
  149. chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +44 -1
  150. chia/_tests/wallet/rpc/test_wallet_rpc.py +1672 -896
  151. chia/_tests/wallet/sync/test_wallet_sync.py +63 -60
  152. chia/_tests/wallet/test_clvm_streamable.py +2 -3
  153. chia/_tests/wallet/test_coin_management.py +2 -2
  154. chia/_tests/wallet/test_conditions.py +45 -51
  155. chia/_tests/wallet/test_debug_spend_bundle.py +2 -2
  156. chia/_tests/wallet/test_new_wallet_protocol.py +17 -17
  157. chia/_tests/wallet/test_notifications.py +14 -14
  158. chia/_tests/wallet/test_signer_protocol.py +5 -5
  159. chia/_tests/wallet/test_singleton_lifecycle_fast.py +4 -3
  160. chia/_tests/wallet/test_transaction_store.py +20 -20
  161. chia/_tests/wallet/test_util.py +2 -2
  162. chia/_tests/wallet/test_wallet.py +380 -228
  163. chia/_tests/wallet/test_wallet_action_scope.py +4 -4
  164. chia/_tests/wallet/test_wallet_blockchain.py +12 -12
  165. chia/_tests/wallet/test_wallet_coin_store.py +3 -4
  166. chia/_tests/wallet/test_wallet_node.py +16 -15
  167. chia/_tests/wallet/test_wallet_test_framework.py +2 -1
  168. chia/_tests/wallet/test_wallet_utils.py +2 -3
  169. chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +3 -5
  170. chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +14 -15
  171. chia/_tests/wallet/vc_wallet/test_vc_wallet.py +29 -24
  172. chia/_tests/wallet/wallet_block_tools.py +12 -11
  173. chia/_tests/weight_proof/config.py +1 -0
  174. chia/_tests/weight_proof/test_weight_proof.py +5 -4
  175. chia/apis/__init__.py +21 -0
  176. chia/apis/farmer_stub.py +102 -0
  177. chia/apis/full_node_stub.py +374 -0
  178. chia/apis/harvester_stub.py +57 -0
  179. chia/apis/introducer_stub.py +35 -0
  180. chia/apis/solver_stub.py +30 -0
  181. chia/apis/stub_protocol_registry.py +21 -0
  182. chia/apis/timelord_stub.py +39 -0
  183. chia/apis/wallet_stub.py +161 -0
  184. chia/cmds/beta.py +3 -4
  185. chia/cmds/beta_funcs.py +4 -3
  186. chia/cmds/check_wallet_db.py +4 -4
  187. chia/cmds/chia.py +1 -2
  188. chia/cmds/cmd_classes.py +11 -13
  189. chia/cmds/cmd_helpers.py +11 -11
  190. chia/cmds/cmds_util.py +15 -15
  191. chia/cmds/coin_funcs.py +6 -7
  192. chia/cmds/coins.py +2 -3
  193. chia/cmds/configure.py +1 -2
  194. chia/cmds/data.py +42 -42
  195. chia/cmds/data_funcs.py +81 -81
  196. chia/cmds/db.py +4 -5
  197. chia/cmds/db_backup_func.py +2 -2
  198. chia/cmds/db_upgrade_func.py +3 -3
  199. chia/cmds/db_validate_func.py +2 -2
  200. chia/cmds/dev/data.py +4 -4
  201. chia/cmds/dev/gh.py +5 -5
  202. chia/cmds/dev/installers.py +2 -3
  203. chia/cmds/dev/mempool.py +3 -4
  204. chia/cmds/dev/mempool_funcs.py +4 -4
  205. chia/cmds/dev/sim.py +8 -8
  206. chia/cmds/dump_keyring.py +3 -3
  207. chia/cmds/farm.py +6 -8
  208. chia/cmds/farm_funcs.py +25 -24
  209. chia/cmds/init_funcs.py +4 -4
  210. chia/cmds/keys.py +16 -18
  211. chia/cmds/keys_funcs.py +36 -36
  212. chia/cmds/netspace.py +1 -3
  213. chia/cmds/netspace_funcs.py +1 -2
  214. chia/cmds/options.py +3 -2
  215. chia/cmds/param_types.py +17 -16
  216. chia/cmds/passphrase.py +6 -7
  217. chia/cmds/passphrase_funcs.py +11 -13
  218. chia/cmds/peer.py +1 -3
  219. chia/cmds/peer_funcs.py +3 -3
  220. chia/cmds/plotnft.py +6 -7
  221. chia/cmds/plotnft_funcs.py +37 -26
  222. chia/cmds/rpc.py +3 -3
  223. chia/cmds/show.py +3 -5
  224. chia/cmds/show_funcs.py +9 -9
  225. chia/cmds/sim_funcs.py +25 -26
  226. chia/cmds/solver.py +1 -3
  227. chia/cmds/solver_funcs.py +1 -2
  228. chia/cmds/start_funcs.py +2 -2
  229. chia/cmds/wallet.py +76 -81
  230. chia/cmds/wallet_funcs.py +206 -177
  231. chia/consensus/augmented_chain.py +6 -6
  232. chia/consensus/block_body_validation.py +19 -15
  233. chia/consensus/block_creation.py +25 -21
  234. chia/consensus/block_header_validation.py +27 -13
  235. chia/consensus/block_height_map.py +3 -6
  236. chia/consensus/block_height_map_protocol.py +2 -2
  237. chia/consensus/block_record.py +2 -4
  238. chia/consensus/blockchain.py +58 -40
  239. chia/consensus/blockchain_interface.py +7 -7
  240. chia/consensus/coin_store_protocol.py +5 -6
  241. chia/consensus/condition_tools.py +4 -4
  242. chia/consensus/cost_calculator.py +2 -3
  243. chia/consensus/default_constants.py +19 -13
  244. chia/consensus/deficit.py +1 -3
  245. chia/consensus/difficulty_adjustment.py +3 -5
  246. chia/consensus/find_fork_point.py +2 -4
  247. chia/consensus/full_block_to_block_record.py +11 -13
  248. chia/consensus/generator_tools.py +2 -3
  249. chia/consensus/get_block_challenge.py +50 -26
  250. chia/consensus/get_block_generator.py +2 -3
  251. chia/consensus/make_sub_epoch_summary.py +8 -7
  252. chia/consensus/multiprocess_validation.py +31 -20
  253. chia/consensus/pos_quality.py +6 -23
  254. chia/consensus/pot_iterations.py +17 -44
  255. chia/consensus/signage_point.py +4 -5
  256. chia/consensus/vdf_info_computation.py +2 -4
  257. chia/daemon/client.py +8 -8
  258. chia/daemon/keychain_proxy.py +31 -37
  259. chia/daemon/server.py +32 -33
  260. chia/daemon/windows_signal.py +4 -3
  261. chia/data_layer/data_layer.py +86 -77
  262. chia/data_layer/data_layer_rpc_api.py +9 -9
  263. chia/data_layer/data_layer_rpc_client.py +13 -15
  264. chia/data_layer/data_layer_server.py +3 -3
  265. chia/data_layer/data_layer_util.py +14 -14
  266. chia/data_layer/data_layer_wallet.py +94 -101
  267. chia/data_layer/data_store.py +50 -50
  268. chia/data_layer/dl_wallet_store.py +9 -12
  269. chia/data_layer/download_data.py +8 -9
  270. chia/data_layer/s3_plugin_service.py +5 -9
  271. chia/data_layer/start_data_layer.py +5 -5
  272. chia/farmer/farmer.py +31 -31
  273. chia/farmer/farmer_api.py +45 -33
  274. chia/farmer/farmer_rpc_api.py +5 -4
  275. chia/farmer/farmer_rpc_client.py +6 -6
  276. chia/farmer/start_farmer.py +6 -6
  277. chia/full_node/block_store.py +13 -16
  278. chia/full_node/check_fork_next_block.py +1 -2
  279. chia/full_node/coin_store.py +15 -16
  280. chia/full_node/eligible_coin_spends.py +3 -3
  281. chia/full_node/fee_estimate_store.py +2 -3
  282. chia/full_node/fee_tracker.py +1 -2
  283. chia/full_node/full_block_utils.py +4 -4
  284. chia/full_node/full_node.py +239 -223
  285. chia/full_node/full_node_api.py +197 -152
  286. chia/full_node/full_node_rpc_api.py +34 -32
  287. chia/full_node/full_node_rpc_client.py +18 -19
  288. chia/full_node/full_node_store.py +45 -43
  289. chia/full_node/hard_fork_utils.py +44 -0
  290. chia/full_node/hint_management.py +2 -2
  291. chia/full_node/mempool.py +17 -19
  292. chia/full_node/mempool_manager.py +89 -42
  293. chia/full_node/pending_tx_cache.py +2 -3
  294. chia/full_node/start_full_node.py +5 -5
  295. chia/full_node/sync_store.py +3 -4
  296. chia/full_node/tx_processing_queue.py +120 -36
  297. chia/full_node/weight_proof.py +61 -48
  298. chia/harvester/harvester.py +25 -24
  299. chia/harvester/harvester_api.py +61 -38
  300. chia/harvester/harvester_rpc_api.py +10 -10
  301. chia/harvester/start_harvester.py +4 -4
  302. chia/introducer/introducer.py +3 -3
  303. chia/introducer/introducer_api.py +6 -4
  304. chia/introducer/start_introducer.py +4 -4
  305. chia/legacy/keyring.py +3 -3
  306. chia/plot_sync/delta.py +1 -2
  307. chia/plot_sync/receiver.py +20 -17
  308. chia/plot_sync/sender.py +15 -10
  309. chia/plotters/bladebit.py +7 -7
  310. chia/plotters/chiapos.py +2 -2
  311. chia/plotters/madmax.py +4 -4
  312. chia/plotters/plotters.py +4 -4
  313. chia/plotters/plotters_util.py +3 -3
  314. chia/plotting/cache.py +20 -14
  315. chia/plotting/check_plots.py +26 -35
  316. chia/plotting/create_plots.py +22 -23
  317. chia/plotting/manager.py +21 -14
  318. chia/plotting/prover.py +59 -42
  319. chia/plotting/util.py +16 -16
  320. chia/pools/pool_config.py +2 -1
  321. chia/pools/pool_puzzles.py +11 -12
  322. chia/pools/pool_wallet.py +34 -57
  323. chia/pools/pool_wallet_info.py +39 -10
  324. chia/protocols/farmer_protocol.py +8 -9
  325. chia/protocols/fee_estimate.py +3 -4
  326. chia/protocols/full_node_protocol.py +3 -4
  327. chia/protocols/harvester_protocol.py +27 -15
  328. chia/protocols/outbound_message.py +3 -3
  329. chia/protocols/pool_protocol.py +8 -9
  330. chia/protocols/shared_protocol.py +1 -2
  331. chia/protocols/solver_protocol.py +9 -2
  332. chia/protocols/timelord_protocol.py +4 -7
  333. chia/protocols/wallet_protocol.py +11 -12
  334. chia/rpc/rpc_client.py +9 -9
  335. chia/rpc/rpc_server.py +17 -17
  336. chia/rpc/util.py +2 -2
  337. chia/seeder/crawler.py +8 -8
  338. chia/seeder/crawler_api.py +21 -27
  339. chia/seeder/crawler_rpc_api.py +2 -2
  340. chia/seeder/dns_server.py +21 -21
  341. chia/seeder/start_crawler.py +4 -4
  342. chia/server/address_manager.py +15 -16
  343. chia/server/api_protocol.py +11 -11
  344. chia/server/chia_policy.py +46 -26
  345. chia/server/introducer_peers.py +2 -3
  346. chia/server/node_discovery.py +19 -19
  347. chia/server/rate_limit_numbers.py +4 -5
  348. chia/server/rate_limits.py +4 -4
  349. chia/server/resolve_peer_info.py +4 -4
  350. chia/server/server.py +49 -52
  351. chia/server/signal_handlers.py +6 -6
  352. chia/server/start_service.py +17 -17
  353. chia/server/upnp.py +4 -6
  354. chia/server/ws_connection.py +52 -37
  355. chia/simulator/add_blocks_in_batches.py +1 -3
  356. chia/simulator/block_tools.py +312 -200
  357. chia/simulator/full_node_simulator.py +56 -35
  358. chia/simulator/keyring.py +2 -3
  359. chia/simulator/setup_services.py +15 -15
  360. chia/simulator/simulator_full_node_rpc_api.py +1 -2
  361. chia/simulator/simulator_full_node_rpc_client.py +1 -2
  362. chia/simulator/simulator_protocol.py +1 -2
  363. chia/simulator/simulator_test_tools.py +3 -3
  364. chia/simulator/start_simulator.py +7 -7
  365. chia/simulator/wallet_tools.py +10 -10
  366. chia/solver/solver.py +10 -10
  367. chia/solver/solver_api.py +10 -8
  368. chia/solver/solver_rpc_api.py +2 -2
  369. chia/solver/start_solver.py +4 -4
  370. chia/ssl/cacert.pem +148 -90
  371. chia/ssl/chia_ca.crt +14 -10
  372. chia/ssl/chia_ca_old.crt +19 -0
  373. chia/ssl/create_ssl.py +4 -4
  374. chia/ssl/renewedselfsignedca.conf +4 -0
  375. chia/ssl/ssl_check.py +1 -2
  376. chia/timelord/iters_from_block.py +1 -4
  377. chia/timelord/start_timelord.py +4 -4
  378. chia/timelord/timelord.py +44 -40
  379. chia/timelord/timelord_api.py +6 -4
  380. chia/timelord/timelord_launcher.py +2 -2
  381. chia/timelord/timelord_rpc_api.py +2 -2
  382. chia/timelord/timelord_state.py +11 -12
  383. chia/types/block_protocol.py +1 -3
  384. chia/types/blockchain_format/coin.py +1 -3
  385. chia/types/blockchain_format/program.py +11 -8
  386. chia/types/blockchain_format/proof_of_space.py +123 -76
  387. chia/types/blockchain_format/tree_hash.py +3 -3
  388. chia/types/blockchain_format/vdf.py +1 -2
  389. chia/types/coin_spend.py +3 -3
  390. chia/types/mempool_item.py +5 -5
  391. chia/types/mempool_submission_status.py +2 -3
  392. chia/types/peer_info.py +1 -2
  393. chia/types/unfinished_header_block.py +3 -4
  394. chia/types/validation_state.py +1 -2
  395. chia/util/action_scope.py +8 -8
  396. chia/util/async_pool.py +5 -5
  397. chia/util/bech32m.py +1 -2
  398. chia/util/beta_metrics.py +2 -2
  399. chia/util/block_cache.py +4 -4
  400. chia/util/chia_logging.py +2 -2
  401. chia/util/chia_version.py +1 -2
  402. chia/util/config.py +15 -16
  403. chia/util/db_wrapper.py +26 -27
  404. chia/util/default_root.py +1 -2
  405. chia/util/errors.py +3 -3
  406. chia/util/file_keyring.py +14 -14
  407. chia/util/files.py +2 -3
  408. chia/util/hash.py +4 -4
  409. chia/util/initial-config.yaml +4 -5
  410. chia/util/inline_executor.py +2 -1
  411. chia/util/ip_address.py +1 -2
  412. chia/util/keychain.py +25 -27
  413. chia/util/keyring_wrapper.py +18 -19
  414. chia/util/lock.py +3 -4
  415. chia/util/log_exceptions.py +1 -2
  416. chia/util/lru_cache.py +2 -2
  417. chia/util/network.py +6 -6
  418. chia/util/path.py +2 -3
  419. chia/util/priority_mutex.py +2 -2
  420. chia/util/profiler.py +1 -2
  421. chia/util/safe_cancel_task.py +1 -2
  422. chia/util/streamable.py +24 -10
  423. chia/util/task_referencer.py +1 -1
  424. chia/util/timing.py +3 -3
  425. chia/util/virtual_project_analysis.py +6 -5
  426. chia/util/ws_message.py +2 -2
  427. chia/wallet/cat_wallet/cat_info.py +3 -4
  428. chia/wallet/cat_wallet/cat_outer_puzzle.py +12 -11
  429. chia/wallet/cat_wallet/cat_utils.py +3 -4
  430. chia/wallet/cat_wallet/cat_wallet.py +61 -83
  431. chia/wallet/cat_wallet/lineage_store.py +3 -4
  432. chia/wallet/cat_wallet/r_cat_wallet.py +19 -22
  433. chia/wallet/coin_selection.py +9 -10
  434. chia/wallet/conditions.py +142 -106
  435. chia/wallet/db_wallet/db_wallet_puzzles.py +4 -5
  436. chia/wallet/derivation_record.py +1 -2
  437. chia/wallet/derive_keys.py +2 -4
  438. chia/wallet/did_wallet/did_info.py +10 -11
  439. chia/wallet/did_wallet/did_wallet.py +36 -82
  440. chia/wallet/did_wallet/did_wallet_puzzles.py +7 -8
  441. chia/wallet/driver_protocol.py +5 -7
  442. chia/wallet/lineage_proof.py +4 -4
  443. chia/wallet/nft_wallet/metadata_outer_puzzle.py +11 -11
  444. chia/wallet/nft_wallet/nft_info.py +8 -9
  445. chia/wallet/nft_wallet/nft_puzzle_utils.py +8 -8
  446. chia/wallet/nft_wallet/nft_wallet.py +79 -116
  447. chia/wallet/nft_wallet/ownership_outer_puzzle.py +14 -14
  448. chia/wallet/nft_wallet/singleton_outer_puzzle.py +12 -11
  449. chia/wallet/nft_wallet/transfer_program_puzzle.py +11 -11
  450. chia/wallet/nft_wallet/uncurry_nft.py +10 -11
  451. chia/wallet/notification_manager.py +3 -3
  452. chia/wallet/notification_store.py +44 -61
  453. chia/wallet/outer_puzzles.py +6 -7
  454. chia/wallet/puzzle_drivers.py +34 -6
  455. chia/wallet/puzzles/clawback/drivers.py +6 -6
  456. chia/wallet/puzzles/deployed_puzzle_hashes.json +1 -54
  457. chia/wallet/puzzles/load_clvm.py +1 -1
  458. chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +1 -2
  459. chia/wallet/puzzles/singleton_top_layer.py +2 -3
  460. chia/wallet/puzzles/singleton_top_layer_v1_1.py +3 -4
  461. chia/wallet/puzzles/tails.py +3 -3
  462. chia/wallet/singleton.py +5 -7
  463. chia/wallet/singleton_record.py +3 -3
  464. chia/wallet/start_wallet.py +5 -5
  465. chia/wallet/trade_manager.py +37 -58
  466. chia/wallet/trade_record.py +4 -4
  467. chia/wallet/trading/offer.py +59 -46
  468. chia/wallet/trading/trade_store.py +8 -9
  469. chia/wallet/transaction_record.py +8 -8
  470. chia/wallet/uncurried_puzzle.py +1 -2
  471. chia/wallet/util/clvm_streamable.py +12 -12
  472. chia/wallet/util/compute_hints.py +4 -5
  473. chia/wallet/util/curry_and_treehash.py +1 -2
  474. chia/wallet/util/merkle_tree.py +2 -3
  475. chia/wallet/util/peer_request_cache.py +8 -8
  476. chia/wallet/util/signing.py +85 -0
  477. chia/wallet/util/tx_config.py +15 -6
  478. chia/wallet/util/wallet_sync_utils.py +14 -16
  479. chia/wallet/util/wallet_types.py +2 -2
  480. chia/wallet/vc_wallet/cr_cat_drivers.py +10 -11
  481. chia/wallet/vc_wallet/cr_cat_wallet.py +50 -68
  482. chia/wallet/vc_wallet/cr_outer_puzzle.py +14 -13
  483. chia/wallet/vc_wallet/vc_drivers.py +27 -27
  484. chia/wallet/vc_wallet/vc_store.py +5 -6
  485. chia/wallet/vc_wallet/vc_wallet.py +33 -61
  486. chia/wallet/wallet.py +50 -78
  487. chia/wallet/wallet_action_scope.py +11 -11
  488. chia/wallet/wallet_blockchain.py +12 -12
  489. chia/wallet/wallet_coin_record.py +12 -6
  490. chia/wallet/wallet_coin_store.py +24 -25
  491. chia/wallet/wallet_interested_store.py +3 -5
  492. chia/wallet/wallet_nft_store.py +10 -11
  493. chia/wallet/wallet_node.py +53 -61
  494. chia/wallet/wallet_node_api.py +5 -3
  495. chia/wallet/wallet_protocol.py +23 -23
  496. chia/wallet/wallet_puzzle_store.py +15 -18
  497. chia/wallet/wallet_request_types.py +778 -114
  498. chia/wallet/wallet_retry_store.py +1 -3
  499. chia/wallet/wallet_rpc_api.py +572 -909
  500. chia/wallet/wallet_rpc_client.py +87 -279
  501. chia/wallet/wallet_singleton_store.py +3 -4
  502. chia/wallet/wallet_state_manager.py +332 -106
  503. chia/wallet/wallet_transaction_store.py +11 -14
  504. chia/wallet/wallet_user_store.py +4 -6
  505. chia/wallet/wallet_weight_proof_handler.py +4 -4
  506. {chia_blockchain-2.5.7rc4.dist-info → chia_blockchain-2.6.0rc2.dist-info}/METADATA +6 -5
  507. {chia_blockchain-2.5.7rc4.dist-info → chia_blockchain-2.6.0rc2.dist-info}/RECORD +510 -517
  508. chia/apis.py +0 -21
  509. chia/consensus/check_time_locks.py +0 -57
  510. chia/data_layer/puzzles/__init__.py +0 -0
  511. chia/data_layer/puzzles/graftroot_dl_offers.clsp +0 -100
  512. chia/data_layer/puzzles/graftroot_dl_offers.clsp.hex +0 -1
  513. chia/types/coin_record.py +0 -44
  514. chia/wallet/nft_wallet/puzzles/__init__.py +0 -0
  515. chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp +0 -6
  516. chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp.hex +0 -1
  517. chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp +0 -6
  518. chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp.hex +0 -1
  519. chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp +0 -30
  520. chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp.hex +0 -1
  521. chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp +0 -28
  522. chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp.hex +0 -1
  523. chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp +0 -100
  524. chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp.hex +0 -1
  525. chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp +0 -78
  526. chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp.hex +0 -1
  527. chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp +0 -74
  528. chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp.hex +0 -1
  529. {chia_blockchain-2.5.7rc4.dist-info → chia_blockchain-2.6.0rc2.dist-info}/WHEEL +0 -0
  530. {chia_blockchain-2.5.7rc4.dist-info → chia_blockchain-2.6.0rc2.dist-info}/entry_points.txt +0 -0
  531. {chia_blockchain-2.5.7rc4.dist-info → chia_blockchain-2.6.0rc2.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
- from typing import Optional, cast
4
+ from typing import cast
5
5
 
6
6
  from bitstring import BitArray
7
- from chia_rs import AugSchemeMPL, ConsensusConstants, G1Element, PlotSize, PrivateKey, ProofOfSpace
7
+ from chia_rs import AugSchemeMPL, ConsensusConstants, G1Element, PlotParam, PrivateKey, ProofOfSpace, validate_proof_v2
8
8
  from chia_rs.sized_bytes import bytes32
9
9
  from chia_rs.sized_ints import uint8, uint32
10
10
  from chiapos import Verifier
@@ -13,44 +13,23 @@ from chia.util.hash import std_hash
13
13
 
14
14
  log = logging.getLogger(__name__)
15
15
 
16
- # These are temporary stubs for chiapos2, that we build against until it's ready to be integrated.
17
-
18
-
19
- # returns quality string for v2 plot, or None if invalid
20
- def validate_proof_v2(
21
- plot_id: bytes32, size: uint8, required_plot_strength: uint8, challenge: bytes32, proof: bytes
22
- ) -> Optional[bytes32]:
23
- # TODO: todo_v2_plots call into new chiapos library
24
- raise NotImplementedError
25
-
26
-
27
- # this is compute intensive, solving a partial proof returning a full proof
28
- def solve_proof(partial_proof: bytes) -> bytes:
29
- # TODO: todo_v2_plots call into new chiapos library
30
- raise NotImplementedError
31
-
32
-
33
- # given a partial proof, computes the quality. This is used to compute required iters.
34
- def quality_for_partial_proof(partial_proof: bytes, challenge: bytes32) -> bytes32:
35
- # TODO: todo_v2_plots call into new chiapos library
36
- return std_hash(partial_proof + challenge)
37
-
38
16
 
39
17
  def make_pos(
40
18
  challenge: bytes32,
41
- pool_public_key: Optional[G1Element],
42
- pool_contract_puzzle_hash: Optional[bytes32],
19
+ pool_public_key: G1Element | None,
20
+ pool_contract_puzzle_hash: bytes32 | None,
43
21
  plot_public_key: G1Element,
44
- version_and_size: PlotSize,
22
+ version_and_size: PlotParam,
45
23
  proof: bytes,
46
24
  ) -> ProofOfSpace:
47
25
  k: int
48
26
  if version_and_size.size_v1 is not None:
49
27
  k = version_and_size.size_v1
50
28
  else:
51
- assert version_and_size.size_v2 is not None
52
- k = version_and_size.size_v2
29
+ assert version_and_size.strength_v2 is not None
30
+ k = version_and_size.strength_v2
53
31
  assert k is not None
32
+ assert k <= 0x3F
54
33
  k |= 0x80
55
34
 
56
35
  return ProofOfSpace(
@@ -64,6 +43,11 @@ def make_pos(
64
43
 
65
44
 
66
45
  def get_plot_id(pos: ProofOfSpace) -> bytes32:
46
+ plot_param = pos.param()
47
+ if plot_param.strength_v2 is not None:
48
+ assert pos.pool_contract_puzzle_hash is not None
49
+ return calculate_plot_id_v2(pos.pool_contract_puzzle_hash, pos.plot_public_key, uint8(plot_param.strength_v2))
50
+
67
51
  assert pos.pool_public_key is None or pos.pool_contract_puzzle_hash is None
68
52
  if pos.pool_public_key is None:
69
53
  assert pos.pool_contract_puzzle_hash is not None
@@ -71,32 +55,74 @@ def get_plot_id(pos: ProofOfSpace) -> bytes32:
71
55
  return calculate_plot_id_pk(pos.pool_public_key, pos.plot_public_key)
72
56
 
73
57
 
74
- def check_plot_size(constants: ConsensusConstants, ps: PlotSize) -> bool:
58
+ def check_plot_param(constants: ConsensusConstants, ps: PlotParam) -> bool:
75
59
  size_v1 = ps.size_v1
76
- if size_v1 is not None:
77
- assert ps.size_v2 is None
78
- if size_v1 < constants.MIN_PLOT_SIZE_V1:
79
- log.error("Plot size is lower than the minimum")
60
+ strength_v2 = ps.strength_v2
61
+ if strength_v2 is not None:
62
+ if strength_v2 < constants.MIN_PLOT_STRENGTH:
63
+ log.error(f"Plot strength ({strength_v2}) is lower than the minimum ({constants.MIN_PLOT_STRENGTH})")
80
64
  return False
81
- if size_v1 > constants.MAX_PLOT_SIZE_V1:
82
- log.error("Plot size is higher than the maximum")
65
+ if strength_v2 > constants.MAX_PLOT_STRENGTH:
66
+ log.error(f"Plot strength ({strength_v2}) is too high (max is {constants.MAX_PLOT_STRENGTH})")
83
67
  return False
84
68
  return True
85
69
 
86
- size_v2 = ps.size_v2
87
- assert size_v2 is not None
88
- if size_v2 < constants.MIN_PLOT_SIZE_V2:
89
- log.error("Plot size is lower than the minimum")
90
- return False
91
- if size_v2 > constants.MAX_PLOT_SIZE_V2:
92
- log.error("Plot size is higher than the maximum")
70
+ assert size_v1 is not None
71
+ if size_v1 < constants.MIN_PLOT_SIZE_V1:
72
+ log.error(f"Plot size ({size_v1}) is lower than the minimum ({constants.MIN_PLOT_SIZE_V1})")
93
73
  return False
94
- if (size_v2 & 1) == 1:
95
- log.error("Plot size is odd")
74
+ if size_v1 > constants.MAX_PLOT_SIZE_V1:
75
+ log.error(f"Plot size ({size_v1}) is higher than the maximum ({constants.MAX_PLOT_SIZE_V1})")
96
76
  return False
97
77
  return True
98
78
 
99
79
 
80
+ def num_phase_out_epochs(constants: ConsensusConstants) -> int:
81
+ """
82
+ The number of phase-out epochs is always a power-of-two minus 1. i.e. it
83
+ will also be a mask for the hash of the proof we're checking for phase-out.
84
+ Since the hash of the proof are random bits, the simplest check is just to
85
+ mask and compare the resulting value against the phase-out count down.
86
+ """
87
+ return (1 << constants.PLOT_V1_PHASE_OUT_EPOCH_BITS) - 1
88
+
89
+
90
+ def v1_cut_off_height(constants: ConsensusConstants) -> int:
91
+ """
92
+ returns the height where v1 proofs-of-space are no longer valid. Blocks
93
+ whose previous transaction block is equal to or higher than this may not have a
94
+ v1 proof.
95
+ """
96
+ return constants.HARD_FORK2_HEIGHT + num_phase_out_epochs(constants) * constants.EPOCH_BLOCKS
97
+
98
+
99
+ def is_v1_phased_out(
100
+ proof: bytes,
101
+ prev_transaction_block_height: uint32, # this is the height of the last tx block before the current block SP
102
+ constants: ConsensusConstants,
103
+ ) -> bool:
104
+ if prev_transaction_block_height < constants.HARD_FORK2_HEIGHT:
105
+ return False
106
+
107
+ # This is a v1 plot and the phase-out period has started
108
+ # The probability of having been phased out is proportional on the
109
+ # number of epochs since hard fork activation
110
+ phase_out_epoch_mask = num_phase_out_epochs(constants)
111
+
112
+ # we just look at one byte so the mask can't be bigger than that
113
+ assert phase_out_epoch_mask < 256
114
+
115
+ # this counter is counting down to zero
116
+ epoch_counter = (v1_cut_off_height(constants) - prev_transaction_block_height) // constants.EPOCH_BLOCKS
117
+
118
+ # if we're past the phase-out, v1 plots are unconditionally invalid
119
+ if epoch_counter < 0:
120
+ return True
121
+
122
+ proof_value = std_hash(proof + b"chia proof-of-space v1 phase-out")[0] & phase_out_epoch_mask
123
+ return proof_value >= epoch_counter
124
+
125
+
100
126
  def verify_and_get_quality_string(
101
127
  pos: ProofOfSpace,
102
128
  constants: ConsensusConstants,
@@ -104,8 +130,25 @@ def verify_and_get_quality_string(
104
130
  signage_point: bytes32,
105
131
  *,
106
132
  height: uint32,
107
- ) -> Optional[bytes32]:
133
+ prev_transaction_block_height: uint32, # this is the height of the last tx block before the current block SP
134
+ height_agnostic: bool = False,
135
+ ) -> bytes32 | None:
136
+ plot_param = pos.param()
137
+
138
+ if not height_agnostic:
139
+ if plot_param.size_v1 is not None and is_v1_phased_out(pos.proof, prev_transaction_block_height, constants):
140
+ log.info("v1 proof has been phased-out and is no longer valid")
141
+ return None
142
+
143
+ if plot_param.strength_v2 is not None and prev_transaction_block_height < constants.HARD_FORK2_HEIGHT:
144
+ log.info("v2 proof support has not yet activated")
145
+ return None
146
+
108
147
  # Exactly one of (pool_public_key, pool_contract_puzzle_hash) must not be None
148
+ # Except v2 plots, they only support pool contract puzzle hash
149
+ if plot_param.strength_v2 is not None and pos.pool_contract_puzzle_hash is None:
150
+ log.error("v2 plots require pool_contract_puzzle_hash, pool public key is not supported")
151
+ return None
109
152
  if (pos.pool_public_key is None) and (pos.pool_contract_puzzle_hash is None):
110
153
  log.error("Expected pool public key or pool contract puzzle hash but got neither")
111
154
  return None
@@ -113,37 +156,42 @@ def verify_and_get_quality_string(
113
156
  log.error("Expected pool public key or pool contract puzzle hash but got both")
114
157
  return None
115
158
 
116
- plot_size = pos.size()
117
- if not check_plot_size(constants, plot_size):
159
+ if not check_plot_param(constants, plot_param):
118
160
  return None
119
161
 
120
162
  plot_id: bytes32 = get_plot_id(pos)
121
163
  new_challenge: bytes32 = calculate_pos_challenge(plot_id, original_challenge_hash, signage_point)
122
164
 
123
165
  if new_challenge != pos.challenge:
124
- log.error("Calculated pos challenge doesn't match the provided one")
166
+ log.error(f"Calculated pos challenge doesn't match the provided one {new_challenge}")
125
167
  return None
126
168
 
127
169
  # we use different plot filter prefix sizes depending on v1 or v2 plots
128
- prefix_bits = calculate_prefix_bits(constants, height, plot_size)
170
+ prefix_bits = calculate_prefix_bits(constants, height, plot_param)
129
171
  if not passes_plot_filter(prefix_bits, plot_id, original_challenge_hash, signage_point):
130
- log.error("Did not pass the plot filter")
172
+ log.error(f"Did not pass the plot filter. prefix bits: {prefix_bits} {'V1' if plot_param.size_v1 else 'V2'}")
131
173
  return None
132
174
 
133
- if plot_size.size_v1 is not None:
175
+ if plot_param.size_v1 is not None:
134
176
  # === V1 plots ===
135
- assert plot_size.size_v2 is None
177
+ assert plot_param.strength_v2 is None
136
178
 
137
- quality_str = Verifier().validate_proof(plot_id, plot_size.size_v1, pos.challenge, bytes(pos.proof))
179
+ quality_str = Verifier().validate_proof(plot_id, plot_param.size_v1, pos.challenge, bytes(pos.proof))
138
180
  if not quality_str:
139
181
  return None
140
182
  return bytes32(quality_str)
141
183
  else:
142
184
  # === V2 plots ===
143
- assert plot_size.size_v2 is not None
185
+ assert plot_param.strength_v2 is not None
144
186
 
145
- required_plot_strength = calculate_required_plot_strength(constants, height)
146
- return validate_proof_v2(plot_id, plot_size.size_v2, required_plot_strength, pos.challenge, bytes(pos.proof))
187
+ return validate_proof_v2(
188
+ plot_id,
189
+ constants.PLOT_SIZE_V2,
190
+ pos.challenge,
191
+ plot_param.strength_v2,
192
+ constants.QUALITY_PROOF_SCAN_FILTER,
193
+ pos.proof,
194
+ )
147
195
 
148
196
 
149
197
  def passes_plot_filter(
@@ -163,10 +211,16 @@ def passes_plot_filter(
163
211
  return cast(bool, plot_filter[:prefix_bits].uint == 0)
164
212
 
165
213
 
166
- def calculate_prefix_bits(constants: ConsensusConstants, height: uint32, plot_size: PlotSize) -> int:
167
- # v2 plots have a constant plot filter size
168
- if plot_size.size_v2 is not None:
169
- return constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2
214
+ def calculate_prefix_bits(constants: ConsensusConstants, height: uint32, plot_param: PlotParam) -> int:
215
+ if plot_param.strength_v2 is not None:
216
+ prefix_bits = int(constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2)
217
+ if height >= constants.PLOT_FILTER_V2_THIRD_ADJUSTMENT_HEIGHT:
218
+ prefix_bits -= 3
219
+ elif height >= constants.PLOT_FILTER_V2_SECOND_ADJUSTMENT_HEIGHT:
220
+ prefix_bits -= 2
221
+ elif height >= constants.PLOT_FILTER_V2_FIRST_ADJUSTMENT_HEIGHT:
222
+ prefix_bits -= 1
223
+ return max(0, prefix_bits)
170
224
 
171
225
  prefix_bits = int(constants.NUMBER_ZERO_BITS_PLOT_FILTER_V1)
172
226
  if height >= constants.PLOT_FILTER_32_HEIGHT:
@@ -181,21 +235,6 @@ def calculate_prefix_bits(constants: ConsensusConstants, height: uint32, plot_si
181
235
  return max(0, prefix_bits)
182
236
 
183
237
 
184
- def calculate_required_plot_strength(constants: ConsensusConstants, height: uint32) -> uint8:
185
- if height < constants.PLOT_STRENGTH_4_HEIGHT:
186
- return constants.PLOT_STRENGTH_INITIAL
187
- if height < constants.PLOT_STRENGTH_5_HEIGHT:
188
- return uint8(4)
189
- if height < constants.PLOT_STRENGTH_6_HEIGHT:
190
- return uint8(5)
191
- if height < constants.PLOT_STRENGTH_7_HEIGHT:
192
- return uint8(6)
193
- if height < constants.PLOT_STRENGTH_8_HEIGHT:
194
- return uint8(7)
195
- else:
196
- return uint8(8)
197
-
198
-
199
238
  def calculate_plot_filter_input(plot_id: bytes32, challenge_hash: bytes32, signage_point: bytes32) -> bytes32:
200
239
  return std_hash(plot_id + challenge_hash + signage_point)
201
240
 
@@ -204,6 +243,14 @@ def calculate_pos_challenge(plot_id: bytes32, challenge_hash: bytes32, signage_p
204
243
  return std_hash(calculate_plot_filter_input(plot_id, challenge_hash, signage_point))
205
244
 
206
245
 
246
+ def calculate_plot_id_v2(
247
+ pool_contract_puzzle_hash: bytes32,
248
+ plot_public_key: G1Element,
249
+ strength: uint8,
250
+ ) -> bytes32:
251
+ return std_hash(bytes(pool_contract_puzzle_hash) + bytes(plot_public_key) + bytes(strength))
252
+
253
+
207
254
  def calculate_plot_id_pk(
208
255
  pool_public_key: G1Element,
209
256
  plot_public_key: G1Element,
@@ -8,7 +8,7 @@ have to worry about blowing out the python stack.
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
- from typing import Callable, Optional, Union
11
+ from collections.abc import Callable
12
12
 
13
13
  from chia_rs.sized_bytes import bytes32
14
14
  from clvm.CLVMObject import CLVMStorage
@@ -16,13 +16,13 @@ from clvm.SExp import SExp
16
16
 
17
17
  from chia.util.hash import std_hash
18
18
 
19
- ValueType = Union[bytes, CLVMStorage]
19
+ ValueType = bytes | CLVMStorage
20
20
  ValueStackType = list[ValueType]
21
21
  Op = Callable[[ValueStackType, "OpStackType", set[bytes32]], None]
22
22
  OpStackType = list[Op]
23
23
 
24
24
 
25
- def sha256_treehash(sexp: CLVMStorage, precalculated: Optional[set[bytes32]] = None) -> bytes32:
25
+ def sha256_treehash(sexp: CLVMStorage, precalculated: set[bytes32] | None = None) -> bytes32:
26
26
  """
27
27
  Hash values in `precalculated` are presumed to have been hashed already.
28
28
  """
@@ -4,7 +4,6 @@ import logging
4
4
  import traceback
5
5
  from enum import IntEnum
6
6
  from functools import lru_cache
7
- from typing import Optional
8
7
 
9
8
  from chia_rs import ConsensusConstants, VDFInfo, VDFProof
10
9
  from chia_rs.sized_bytes import bytes32, bytes100
@@ -51,7 +50,7 @@ def validate_vdf(
51
50
  constants: ConsensusConstants,
52
51
  input_el: ClassgroupElement,
53
52
  info: VDFInfo,
54
- target_vdf_info: Optional[VDFInfo] = None,
53
+ target_vdf_info: VDFInfo | None = None,
55
54
  ) -> bool:
56
55
  """
57
56
  If target_vdf_info is passed in, it is compared with info.
chia/types/coin_spend.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Any, Union
4
+ from typing import Any
5
5
 
6
6
  from chia_rs import CoinSpend
7
7
 
@@ -14,8 +14,8 @@ from chia.types.condition_with_args import ConditionWithArgs
14
14
 
15
15
  def make_spend(
16
16
  coin: Coin,
17
- puzzle_reveal: Union[Program, SerializedProgram],
18
- solution: Union[Program, SerializedProgram],
17
+ puzzle_reveal: Program | SerializedProgram,
18
+ solution: Program | SerializedProgram,
19
19
  ) -> CoinSpend:
20
20
  pr: SerializedProgram
21
21
  sol: SerializedProgram
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass, field
4
- from typing import Any, Optional
4
+ from typing import Any
5
5
 
6
6
  from chia_rs import CoinSpend, G2Element, SpendBundle, SpendBundleConditions
7
7
  from chia_rs.sized_bytes import bytes32
@@ -31,7 +31,7 @@ class BundleCoinSpend:
31
31
  # current unspent lineage belonging to this singleton, that we would rebase
32
32
  # this spend on top of if we were to make a block now
33
33
  # When finding MempoolItems by coin ID, we use Coin ID from it if it's set
34
- latest_singleton_lineage: Optional[UnspentLineageInfo]
34
+ latest_singleton_lineage: UnspentLineageInfo | None
35
35
 
36
36
  @property
37
37
  def supports_fast_forward(self) -> bool:
@@ -47,12 +47,12 @@ class MempoolItem:
47
47
  height_added_to_mempool: uint32
48
48
 
49
49
  # If present, this SpendBundle is not valid at or before this height
50
- assert_height: Optional[uint32] = None
50
+ assert_height: uint32 | None = None
51
51
 
52
52
  # If present, this SpendBundle is not valid once the block height reaches
53
53
  # the specified height
54
- assert_before_height: Optional[uint32] = None
55
- assert_before_seconds: Optional[uint64] = None
54
+ assert_before_height: uint32 | None = None
55
+ assert_before_seconds: uint64 | None = None
56
56
 
57
57
  # Map of coin ID to coin spend data between the bundle and its
58
58
  # SpendBundleConditions
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Optional, Union
5
4
 
6
5
  from chia_rs.sized_ints import uint8
7
6
 
@@ -20,9 +19,9 @@ class MempoolSubmissionStatus(Streamable):
20
19
 
21
20
  peer_id: str
22
21
  inclusion_status: uint8 # MempoolInclusionStatus
23
- error_msg: Optional[str]
22
+ error_msg: str | None
24
23
 
25
- def to_json_dict_convenience(self) -> dict[str, Union[str, MempoolInclusionStatus, None]]:
24
+ def to_json_dict_convenience(self) -> dict[str, str | MempoolInclusionStatus | None]:
26
25
  formatted = self.to_json_dict()
27
26
  formatted["inclusion_status"] = MempoolInclusionStatus(self.inclusion_status).name
28
27
  return formatted
chia/types/peer_info.py CHANGED
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import ipaddress
4
4
  from dataclasses import dataclass
5
- from typing import Union
6
5
 
7
6
  from chia_rs.sized_ints import uint16, uint64
8
7
 
@@ -23,7 +22,7 @@ class PeerInfo:
23
22
  _port: uint16
24
23
 
25
24
  # TODO, Drop this as soon as all call PeerInfo calls pass in an IPAddress
26
- def __init__(self, host: Union[IPAddress, str], port: int):
25
+ def __init__(self, host: IPAddress | str, port: int):
27
26
  self._ip = host if isinstance(host, IPAddress) else IPAddress.create(host)
28
27
  self._port = uint16(port)
29
28
 
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Optional
5
4
 
6
5
  from chia_rs import EndOfSubSlotBundle, Foliage, FoliageTransactionBlock, RewardChainBlockUnfinished
7
6
  from chia_rs.sized_bytes import bytes32
@@ -17,10 +16,10 @@ class UnfinishedHeaderBlock(Streamable):
17
16
  # Same as a FullBlock but without TransactionInfo and Generator, used by light clients
18
17
  finished_sub_slots: list[EndOfSubSlotBundle] # If first sb
19
18
  reward_chain_block: RewardChainBlockUnfinished # Reward chain trunk data
20
- challenge_chain_sp_proof: Optional[VDFProof] # If not first sp in sub-slot
21
- reward_chain_sp_proof: Optional[VDFProof] # If not first sp in sub-slot
19
+ challenge_chain_sp_proof: VDFProof | None # If not first sp in sub-slot
20
+ reward_chain_sp_proof: VDFProof | None # If not first sp in sub-slot
22
21
  foliage: Foliage # Reward chain foliage data
23
- foliage_transaction_block: Optional[FoliageTransactionBlock] # Reward chain foliage data (tx block)
22
+ foliage_transaction_block: FoliageTransactionBlock | None # Reward chain foliage data (tx block)
24
23
  transactions_filter: bytes # Filter for block transactions
25
24
 
26
25
  @property
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import dataclasses
4
- from typing import Optional
5
4
 
6
5
  from chia_rs import BlockRecord
7
6
  from chia_rs.sized_ints import uint64
@@ -11,4 +10,4 @@ from chia_rs.sized_ints import uint64
11
10
  class ValidationState:
12
11
  ssi: uint64
13
12
  difficulty: uint64
14
- prev_ses_block: Optional[BlockRecord] = None
13
+ prev_ses_block: BlockRecord | None = None
chia/util/action_scope.py CHANGED
@@ -1,9 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import contextlib
4
- from collections.abc import AsyncIterator, Awaitable
4
+ from collections.abc import AsyncIterator, Awaitable, Callable
5
5
  from dataclasses import dataclass, field
6
- from typing import Callable, Generic, Optional, Protocol, TypeVar
6
+ from typing import Generic, Protocol, TypeVar
7
7
 
8
8
  import aiosqlite
9
9
  from typing_extensions import Self
@@ -31,7 +31,7 @@ class ResourceManager(Protocol):
31
31
  @dataclass
32
32
  class SQLiteResourceManager:
33
33
  _db: DBWrapper2
34
- _active_writer: Optional[aiosqlite.Connection] = field(init=False, default=None)
34
+ _active_writer: aiosqlite.Connection | None = field(init=False, default=None)
35
35
 
36
36
  def get_active_writer(self) -> aiosqlite.Connection:
37
37
  if self._active_writer is None:
@@ -102,8 +102,8 @@ class ActionScope(Generic[_T_SideEffects, _T_Config]):
102
102
  _resource_manager: ResourceManager
103
103
  _side_effects_format: type[_T_SideEffects]
104
104
  _config: _T_Config # An object not intended to be mutated during the lifetime of the scope
105
- _callback: Optional[Callable[[StateInterface[_T_SideEffects]], Awaitable[None]]] = None
106
- _final_side_effects: Optional[_T_SideEffects] = field(init=False, default=None)
105
+ _callback: Callable[[StateInterface[_T_SideEffects]], Awaitable[None]] | None = None
106
+ _final_side_effects: _T_SideEffects | None = field(init=False, default=None)
107
107
 
108
108
  @property
109
109
  def side_effects(self) -> _T_SideEffects:
@@ -155,13 +155,13 @@ class ActionScope(Generic[_T_SideEffects, _T_Config]):
155
155
  class StateInterface(Generic[_T_SideEffects]):
156
156
  side_effects: _T_SideEffects
157
157
  _callbacks_allowed: bool
158
- _callback: Optional[Callable[[StateInterface[_T_SideEffects]], Awaitable[None]]] = None
158
+ _callback: Callable[[StateInterface[_T_SideEffects]], Awaitable[None]] | None = None
159
159
 
160
160
  @property
161
- def callback(self) -> Optional[Callable[[StateInterface[_T_SideEffects]], Awaitable[None]]]:
161
+ def callback(self) -> Callable[[StateInterface[_T_SideEffects]], Awaitable[None]] | None:
162
162
  return self._callback
163
163
 
164
- def set_callback(self, new_callback: Optional[Callable[[StateInterface[_T_SideEffects]], Awaitable[None]]]) -> None:
164
+ def set_callback(self, new_callback: Callable[[StateInterface[_T_SideEffects]], Awaitable[None]] | None) -> None:
165
165
  if not self._callbacks_allowed:
166
166
  raise RuntimeError("Callback cannot be edited from inside itself")
167
167
 
chia/util/async_pool.py CHANGED
@@ -7,7 +7,7 @@ import itertools
7
7
  import logging
8
8
  import traceback
9
9
  from collections.abc import AsyncIterator, Iterator
10
- from typing import Generic, Optional, Protocol, TypeVar, final
10
+ from typing import Generic, Protocol, TypeVar, final
11
11
 
12
12
  import anyio
13
13
 
@@ -49,8 +49,8 @@ class Job(Generic[T]):
49
49
  input: T
50
50
  started: asyncio.Event = dataclasses.field(default_factory=asyncio.Event)
51
51
  done: asyncio.Event = dataclasses.field(default_factory=asyncio.Event)
52
- exception: Optional[BaseException] = None
53
- task: Optional[asyncio.Task[object]] = None
52
+ exception: BaseException | None = None
53
+ task: asyncio.Task[object] | None = None
54
54
  cancelled: bool = False
55
55
 
56
56
 
@@ -59,7 +59,7 @@ class Job(Generic[T]):
59
59
  class QueuedAsyncPool(Generic[J, R]):
60
60
  name: str
61
61
  job_queue: JobQueueProtocol[Job[J]]
62
- result_queue: Optional[ResultQueueProtocol[R]]
62
+ result_queue: ResultQueueProtocol[R] | None
63
63
  worker_async_callable: QueuedWorkerCallable[J, R]
64
64
 
65
65
  @classmethod
@@ -70,7 +70,7 @@ class QueuedAsyncPool(Generic[J, R]):
70
70
  job_queue: JobQueueProtocol[Job[J]],
71
71
  worker_async_callable: QueuedWorkerCallable[J, R],
72
72
  target_worker_count: int,
73
- result_queue: Optional[ResultQueueProtocol[R]] = None,
73
+ result_queue: ResultQueueProtocol[R] | None = None,
74
74
  log: logging.Logger = logging.getLogger(__name__),
75
75
  ) -> AsyncIterator[QueuedAsyncPool[J, R]]:
76
76
  self = cls(
chia/util/bech32m.py CHANGED
@@ -23,7 +23,6 @@
23
23
  from __future__ import annotations
24
24
 
25
25
  from collections.abc import Iterable
26
- from typing import Optional
27
26
 
28
27
  from chia_rs.sized_bytes import bytes32
29
28
 
@@ -71,7 +70,7 @@ def bech32_encode(hrp: str, data: list[int]) -> str:
71
70
  return hrp + "1" + "".join([CHARSET[d] for d in combined])
72
71
 
73
72
 
74
- def bech32_decode(bech: str, max_length: int = 90) -> tuple[Optional[str], Optional[list[int]]]:
73
+ def bech32_decode(bech: str, max_length: int = 90) -> tuple[str | None, list[int] | None]:
75
74
  """Validate a Bech32 string, and determine HRP and data."""
76
75
  bech = bech.strip()
77
76
  if (any(ord(x) < 33 or ord(x) > 126 for x in bech)) or (bech.lower() != bech and bech.upper() != bech):
chia/util/beta_metrics.py CHANGED
@@ -6,7 +6,7 @@ import platform
6
6
  import socket
7
7
  from dataclasses import dataclass
8
8
  from pathlib import Path
9
- from typing import Any, Optional
9
+ from typing import Any
10
10
 
11
11
  import psutil
12
12
 
@@ -76,7 +76,7 @@ def log_network_metrics() -> None:
76
76
  @dataclass
77
77
  class BetaMetricsLogger:
78
78
  root_path: Path
79
- task: Optional[asyncio.Task[None]] = None
79
+ task: asyncio.Task[None] | None = None
80
80
  stop_task: bool = False
81
81
 
82
82
  def start_logging(self) -> None:
chia/util/block_cache.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, ClassVar, Optional, cast
3
+ from typing import TYPE_CHECKING, ClassVar, cast
4
4
 
5
5
  from chia_rs import BlockRecord
6
6
  from chia_rs.sized_bytes import bytes32
@@ -34,11 +34,11 @@ class BlockCache:
34
34
 
35
35
  def height_to_block_record(self, height: uint32) -> BlockRecord:
36
36
  # Precondition: height is < peak height
37
- header_hash: Optional[bytes32] = self.height_to_hash(height)
37
+ header_hash: bytes32 | None = self.height_to_hash(height)
38
38
  assert header_hash is not None
39
39
  return self.block_record(header_hash)
40
40
 
41
- def height_to_hash(self, height: uint32) -> Optional[bytes32]:
41
+ def height_to_hash(self, height: uint32) -> bytes32 | None:
42
42
  if height not in self._height_to_hash:
43
43
  return None
44
44
  return self._height_to_hash[height]
@@ -52,7 +52,7 @@ class BlockCache:
52
52
  def contains_height(self, height: uint32) -> bool:
53
53
  return height in self._height_to_hash
54
54
 
55
- def try_block_record(self, header_hash: bytes32) -> Optional[BlockRecord]:
55
+ def try_block_record(self, header_hash: bytes32) -> BlockRecord | None:
56
56
  return self._block_records.get(header_hash)
57
57
 
58
58
  async def prev_block_hash(self, header_hashes: list[bytes32]) -> list[bytes32]:
chia/util/chia_logging.py CHANGED
@@ -4,7 +4,7 @@ import logging
4
4
  import os
5
5
  from logging.handlers import SysLogHandler
6
6
  from pathlib import Path
7
- from typing import Any, Optional, cast
7
+ from typing import Any, cast
8
8
 
9
9
  import colorlog
10
10
  from concurrent_log_handler import ConcurrentRotatingFileHandler
@@ -46,7 +46,7 @@ def initialize_logging(
46
46
  service_name: str,
47
47
  logging_config: dict[str, Any],
48
48
  root_path: Path,
49
- beta_root_path: Optional[Path] = None,
49
+ beta_root_path: Path | None = None,
50
50
  ) -> None:
51
51
  log_backcompat = logging_config.get("log_backcompat", False)
52
52
  log_level = logging_config.get("log_level", default_log_level)
chia/util/chia_version.py CHANGED
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from re import search
4
- from typing import Union
5
4
 
6
5
  from packaging.version import InvalidVersion, Version
7
6
 
@@ -26,7 +25,7 @@ def _chia_short_version_from_str(version: str) -> str:
26
25
  return version
27
26
 
28
27
 
29
- def chia_short_version(version: Union[str, Version] = __version__) -> str:
28
+ def chia_short_version(version: str | Version = __version__) -> str:
30
29
  if isinstance(version, Version):
31
30
  return _chia_short_version_from_version(version)
32
31