chia-blockchain 2.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chia/__init__.py +10 -0
- chia/__main__.py +5 -0
- chia/_tests/README.md +53 -0
- chia/_tests/__init__.py +0 -0
- chia/_tests/blockchain/__init__.py +0 -0
- chia/_tests/blockchain/blockchain_test_utils.py +197 -0
- chia/_tests/blockchain/config.py +4 -0
- chia/_tests/blockchain/test_augmented_chain.py +147 -0
- chia/_tests/blockchain/test_blockchain.py +4100 -0
- chia/_tests/blockchain/test_blockchain_transactions.py +1050 -0
- chia/_tests/blockchain/test_build_chains.py +61 -0
- chia/_tests/blockchain/test_get_block_generator.py +72 -0
- chia/_tests/blockchain/test_lookup_fork_chain.py +195 -0
- chia/_tests/build-init-files.py +93 -0
- chia/_tests/build-job-matrix.py +204 -0
- chia/_tests/check_pytest_monitor_output.py +34 -0
- chia/_tests/check_sql_statements.py +73 -0
- chia/_tests/chia-start-sim +42 -0
- chia/_tests/clvm/__init__.py +0 -0
- chia/_tests/clvm/benchmark_costs.py +23 -0
- chia/_tests/clvm/coin_store.py +147 -0
- chia/_tests/clvm/test_chialisp_deserialization.py +101 -0
- chia/_tests/clvm/test_clvm_step.py +37 -0
- chia/_tests/clvm/test_condition_codes.py +13 -0
- chia/_tests/clvm/test_curry_and_treehash.py +57 -0
- chia/_tests/clvm/test_program.py +150 -0
- chia/_tests/clvm/test_puzzle_compression.py +144 -0
- chia/_tests/clvm/test_puzzle_drivers.py +45 -0
- chia/_tests/clvm/test_puzzles.py +247 -0
- chia/_tests/clvm/test_singletons.py +540 -0
- chia/_tests/clvm/test_spend_sim.py +181 -0
- chia/_tests/cmds/__init__.py +0 -0
- chia/_tests/cmds/cmd_test_utils.py +472 -0
- chia/_tests/cmds/config.py +3 -0
- chia/_tests/cmds/conftest.py +23 -0
- chia/_tests/cmds/test_click_types.py +195 -0
- chia/_tests/cmds/test_cmd_framework.py +400 -0
- chia/_tests/cmds/test_cmds_util.py +97 -0
- chia/_tests/cmds/test_daemon.py +92 -0
- chia/_tests/cmds/test_farm_cmd.py +67 -0
- chia/_tests/cmds/test_show.py +116 -0
- chia/_tests/cmds/test_sim.py +207 -0
- chia/_tests/cmds/test_timelock_args.py +75 -0
- chia/_tests/cmds/test_tx_config_args.py +153 -0
- chia/_tests/cmds/testing_classes.py +59 -0
- chia/_tests/cmds/wallet/__init__.py +0 -0
- chia/_tests/cmds/wallet/test_coins.py +195 -0
- chia/_tests/cmds/wallet/test_consts.py +47 -0
- chia/_tests/cmds/wallet/test_dao.py +565 -0
- chia/_tests/cmds/wallet/test_did.py +403 -0
- chia/_tests/cmds/wallet/test_nft.py +470 -0
- chia/_tests/cmds/wallet/test_notifications.py +124 -0
- chia/_tests/cmds/wallet/test_offer.toffer +1 -0
- chia/_tests/cmds/wallet/test_tx_decorators.py +27 -0
- chia/_tests/cmds/wallet/test_vcs.py +376 -0
- chia/_tests/cmds/wallet/test_wallet.py +1126 -0
- chia/_tests/cmds/wallet/test_wallet_check.py +111 -0
- chia/_tests/conftest.py +1304 -0
- chia/_tests/connection_utils.py +124 -0
- chia/_tests/core/__init__.py +0 -0
- chia/_tests/core/cmds/__init__.py +0 -0
- chia/_tests/core/cmds/test_beta.py +382 -0
- chia/_tests/core/cmds/test_keys.py +1734 -0
- chia/_tests/core/cmds/test_wallet.py +126 -0
- chia/_tests/core/config.py +3 -0
- chia/_tests/core/consensus/__init__.py +0 -0
- chia/_tests/core/consensus/test_block_creation.py +56 -0
- chia/_tests/core/consensus/test_pot_iterations.py +117 -0
- chia/_tests/core/custom_types/__init__.py +0 -0
- chia/_tests/core/custom_types/test_coin.py +109 -0
- chia/_tests/core/custom_types/test_proof_of_space.py +144 -0
- chia/_tests/core/custom_types/test_spend_bundle.py +71 -0
- chia/_tests/core/daemon/__init__.py +0 -0
- chia/_tests/core/daemon/config.py +4 -0
- chia/_tests/core/daemon/test_daemon.py +2128 -0
- chia/_tests/core/daemon/test_daemon_register.py +109 -0
- chia/_tests/core/daemon/test_keychain_proxy.py +100 -0
- chia/_tests/core/data_layer/__init__.py +0 -0
- chia/_tests/core/data_layer/config.py +5 -0
- chia/_tests/core/data_layer/conftest.py +105 -0
- chia/_tests/core/data_layer/test_data_cli.py +57 -0
- chia/_tests/core/data_layer/test_data_layer.py +83 -0
- chia/_tests/core/data_layer/test_data_layer_util.py +219 -0
- chia/_tests/core/data_layer/test_data_rpc.py +3865 -0
- chia/_tests/core/data_layer/test_data_store.py +2423 -0
- chia/_tests/core/data_layer/test_data_store_schema.py +381 -0
- chia/_tests/core/data_layer/test_plugin.py +91 -0
- chia/_tests/core/data_layer/util.py +232 -0
- chia/_tests/core/farmer/__init__.py +0 -0
- chia/_tests/core/farmer/config.py +3 -0
- chia/_tests/core/farmer/test_farmer_api.py +101 -0
- chia/_tests/core/full_node/__init__.py +0 -0
- chia/_tests/core/full_node/config.py +4 -0
- chia/_tests/core/full_node/dos/__init__.py +0 -0
- chia/_tests/core/full_node/dos/config.py +3 -0
- chia/_tests/core/full_node/full_sync/__init__.py +0 -0
- chia/_tests/core/full_node/full_sync/config.py +4 -0
- chia/_tests/core/full_node/full_sync/test_full_sync.py +448 -0
- chia/_tests/core/full_node/ram_db.py +27 -0
- chia/_tests/core/full_node/stores/__init__.py +0 -0
- chia/_tests/core/full_node/stores/config.py +4 -0
- chia/_tests/core/full_node/stores/test_block_store.py +488 -0
- chia/_tests/core/full_node/stores/test_coin_store.py +888 -0
- chia/_tests/core/full_node/stores/test_full_node_store.py +1215 -0
- chia/_tests/core/full_node/stores/test_hint_store.py +230 -0
- chia/_tests/core/full_node/stores/test_sync_store.py +135 -0
- chia/_tests/core/full_node/test_address_manager.py +588 -0
- chia/_tests/core/full_node/test_block_height_map.py +556 -0
- chia/_tests/core/full_node/test_conditions.py +558 -0
- chia/_tests/core/full_node/test_full_node.py +2445 -0
- chia/_tests/core/full_node/test_generator_tools.py +82 -0
- chia/_tests/core/full_node/test_hint_management.py +104 -0
- chia/_tests/core/full_node/test_node_load.py +34 -0
- chia/_tests/core/full_node/test_performance.py +182 -0
- chia/_tests/core/full_node/test_subscriptions.py +492 -0
- chia/_tests/core/full_node/test_transactions.py +203 -0
- chia/_tests/core/full_node/test_tx_processing_queue.py +154 -0
- chia/_tests/core/large_block.py +2388 -0
- chia/_tests/core/make_block_generator.py +72 -0
- chia/_tests/core/mempool/__init__.py +0 -0
- chia/_tests/core/mempool/config.py +4 -0
- chia/_tests/core/mempool/test_mempool.py +3180 -0
- chia/_tests/core/mempool/test_mempool_fee_estimator.py +104 -0
- chia/_tests/core/mempool/test_mempool_fee_protocol.py +55 -0
- chia/_tests/core/mempool/test_mempool_item_queries.py +192 -0
- chia/_tests/core/mempool/test_mempool_manager.py +2054 -0
- chia/_tests/core/mempool/test_mempool_performance.py +65 -0
- chia/_tests/core/mempool/test_singleton_fast_forward.py +567 -0
- chia/_tests/core/node_height.py +28 -0
- chia/_tests/core/server/__init__.py +0 -0
- chia/_tests/core/server/config.py +3 -0
- chia/_tests/core/server/flood.py +82 -0
- chia/_tests/core/server/serve.py +132 -0
- chia/_tests/core/server/test_capabilities.py +68 -0
- chia/_tests/core/server/test_dos.py +320 -0
- chia/_tests/core/server/test_event_loop.py +109 -0
- chia/_tests/core/server/test_loop.py +290 -0
- chia/_tests/core/server/test_node_discovery.py +74 -0
- chia/_tests/core/server/test_rate_limits.py +370 -0
- chia/_tests/core/server/test_server.py +225 -0
- chia/_tests/core/server/test_upnp.py +8 -0
- chia/_tests/core/services/__init__.py +0 -0
- chia/_tests/core/services/config.py +3 -0
- chia/_tests/core/services/test_services.py +166 -0
- chia/_tests/core/ssl/__init__.py +0 -0
- chia/_tests/core/ssl/config.py +3 -0
- chia/_tests/core/ssl/test_ssl.py +198 -0
- chia/_tests/core/test_coins.py +33 -0
- chia/_tests/core/test_cost_calculation.py +314 -0
- chia/_tests/core/test_crawler.py +175 -0
- chia/_tests/core/test_crawler_rpc.py +53 -0
- chia/_tests/core/test_daemon_rpc.py +24 -0
- chia/_tests/core/test_db_conversion.py +129 -0
- chia/_tests/core/test_db_validation.py +161 -0
- chia/_tests/core/test_farmer_harvester_rpc.py +504 -0
- chia/_tests/core/test_filter.py +37 -0
- chia/_tests/core/test_full_node_rpc.py +794 -0
- chia/_tests/core/test_merkle_set.py +343 -0
- chia/_tests/core/test_program.py +49 -0
- chia/_tests/core/test_rpc_util.py +87 -0
- chia/_tests/core/test_seeder.py +308 -0
- chia/_tests/core/test_setproctitle.py +13 -0
- chia/_tests/core/util/__init__.py +0 -0
- chia/_tests/core/util/config.py +4 -0
- chia/_tests/core/util/test_block_cache.py +44 -0
- chia/_tests/core/util/test_cached_bls.py +57 -0
- chia/_tests/core/util/test_config.py +337 -0
- chia/_tests/core/util/test_file_keyring_synchronization.py +105 -0
- chia/_tests/core/util/test_files.py +391 -0
- chia/_tests/core/util/test_jsonify.py +146 -0
- chia/_tests/core/util/test_keychain.py +514 -0
- chia/_tests/core/util/test_keyring_wrapper.py +490 -0
- chia/_tests/core/util/test_lockfile.py +380 -0
- chia/_tests/core/util/test_log_exceptions.py +187 -0
- chia/_tests/core/util/test_lru_cache.py +56 -0
- chia/_tests/core/util/test_significant_bits.py +40 -0
- chia/_tests/core/util/test_streamable.py +883 -0
- chia/_tests/db/__init__.py +0 -0
- chia/_tests/db/test_db_wrapper.py +565 -0
- chia/_tests/environments/__init__.py +0 -0
- chia/_tests/environments/common.py +35 -0
- chia/_tests/environments/full_node.py +47 -0
- chia/_tests/environments/wallet.py +368 -0
- chia/_tests/ether.py +19 -0
- chia/_tests/farmer_harvester/__init__.py +0 -0
- chia/_tests/farmer_harvester/config.py +3 -0
- chia/_tests/farmer_harvester/test_farmer.py +1264 -0
- chia/_tests/farmer_harvester/test_farmer_harvester.py +292 -0
- chia/_tests/farmer_harvester/test_filter_prefix_bits.py +130 -0
- chia/_tests/farmer_harvester/test_third_party_harvesters.py +501 -0
- chia/_tests/farmer_harvester/test_third_party_harvesters_data.json +29 -0
- chia/_tests/fee_estimation/__init__.py +0 -0
- chia/_tests/fee_estimation/config.py +3 -0
- chia/_tests/fee_estimation/test_fee_estimation_integration.py +262 -0
- chia/_tests/fee_estimation/test_fee_estimation_rpc.py +287 -0
- chia/_tests/fee_estimation/test_fee_estimation_unit_tests.py +145 -0
- chia/_tests/fee_estimation/test_mempoolitem_height_added.py +146 -0
- chia/_tests/generator/__init__.py +0 -0
- chia/_tests/generator/puzzles/__init__.py +0 -0
- chia/_tests/generator/puzzles/test_generator_deserialize.clsp +3 -0
- chia/_tests/generator/puzzles/test_generator_deserialize.clsp.hex +1 -0
- chia/_tests/generator/puzzles/test_multiple_generator_input_arguments.clsp +19 -0
- chia/_tests/generator/puzzles/test_multiple_generator_input_arguments.clsp.hex +1 -0
- chia/_tests/generator/test_compression.py +218 -0
- chia/_tests/generator/test_generator_types.py +44 -0
- chia/_tests/generator/test_rom.py +182 -0
- chia/_tests/plot_sync/__init__.py +0 -0
- chia/_tests/plot_sync/config.py +3 -0
- chia/_tests/plot_sync/test_delta.py +102 -0
- chia/_tests/plot_sync/test_plot_sync.py +617 -0
- chia/_tests/plot_sync/test_receiver.py +451 -0
- chia/_tests/plot_sync/test_sender.py +116 -0
- chia/_tests/plot_sync/test_sync_simulated.py +450 -0
- chia/_tests/plot_sync/util.py +67 -0
- chia/_tests/plotting/__init__.py +0 -0
- chia/_tests/plotting/config.py +3 -0
- chia/_tests/plotting/test_plot_manager.py +738 -0
- chia/_tests/plotting/util.py +13 -0
- chia/_tests/pools/__init__.py +0 -0
- chia/_tests/pools/config.py +5 -0
- chia/_tests/pools/test_pool_cmdline.py +23 -0
- chia/_tests/pools/test_pool_config.py +44 -0
- chia/_tests/pools/test_pool_puzzles_lifecycle.py +398 -0
- chia/_tests/pools/test_pool_rpc.py +1010 -0
- chia/_tests/pools/test_pool_wallet.py +201 -0
- chia/_tests/pools/test_wallet_pool_store.py +161 -0
- chia/_tests/process_junit.py +349 -0
- chia/_tests/rpc/__init__.py +0 -0
- chia/_tests/rpc/test_rpc_client.py +81 -0
- chia/_tests/simulation/__init__.py +0 -0
- chia/_tests/simulation/config.py +6 -0
- chia/_tests/simulation/test_simulation.py +501 -0
- chia/_tests/simulation/test_simulator.py +234 -0
- chia/_tests/simulation/test_start_simulator.py +106 -0
- chia/_tests/testconfig.py +13 -0
- chia/_tests/timelord/__init__.py +0 -0
- chia/_tests/timelord/config.py +3 -0
- chia/_tests/timelord/test_new_peak.py +437 -0
- chia/_tests/timelord/test_timelord.py +11 -0
- chia/_tests/tools/1315537.json +170 -0
- chia/_tests/tools/1315544.json +160 -0
- chia/_tests/tools/1315630.json +150 -0
- chia/_tests/tools/300000.json +105 -0
- chia/_tests/tools/442734.json +140 -0
- chia/_tests/tools/466212.json +130 -0
- chia/_tests/tools/__init__.py +0 -0
- chia/_tests/tools/config.py +5 -0
- chia/_tests/tools/test-blockchain-db.sqlite +0 -0
- chia/_tests/tools/test_full_sync.py +30 -0
- chia/_tests/tools/test_legacy_keyring.py +82 -0
- chia/_tests/tools/test_run_block.py +129 -0
- chia/_tests/util/__init__.py +0 -0
- chia/_tests/util/benchmark_cost.py +170 -0
- chia/_tests/util/benchmarks.py +154 -0
- chia/_tests/util/bip39_test_vectors.json +148 -0
- chia/_tests/util/blockchain.py +133 -0
- chia/_tests/util/blockchain_mock.py +132 -0
- chia/_tests/util/build_network_protocol_files.py +302 -0
- chia/_tests/util/clvm_generator.bin +0 -0
- chia/_tests/util/config.py +3 -0
- chia/_tests/util/constants.py +20 -0
- chia/_tests/util/db_connection.py +36 -0
- chia/_tests/util/full_sync.py +245 -0
- chia/_tests/util/gen_ssl_certs.py +115 -0
- chia/_tests/util/generator_tools_testing.py +47 -0
- chia/_tests/util/key_tool.py +37 -0
- chia/_tests/util/misc.py +722 -0
- chia/_tests/util/network_protocol_data.py +1074 -0
- chia/_tests/util/protocol_messages_bytes-v1.0 +0 -0
- chia/_tests/util/protocol_messages_json.py +2700 -0
- chia/_tests/util/rpc.py +23 -0
- chia/_tests/util/run_block.py +163 -0
- chia/_tests/util/setup_nodes.py +479 -0
- chia/_tests/util/split_managers.py +99 -0
- chia/_tests/util/temp_file.py +14 -0
- chia/_tests/util/test_action_scope.py +143 -0
- chia/_tests/util/test_async_pool.py +366 -0
- chia/_tests/util/test_build_job_matrix.py +43 -0
- chia/_tests/util/test_build_network_protocol_files.py +7 -0
- chia/_tests/util/test_chia_version.py +50 -0
- chia/_tests/util/test_collection.py +11 -0
- chia/_tests/util/test_condition_tools.py +231 -0
- chia/_tests/util/test_config.py +426 -0
- chia/_tests/util/test_dump_keyring.py +60 -0
- chia/_tests/util/test_errors.py +10 -0
- chia/_tests/util/test_full_block_utils.py +271 -0
- chia/_tests/util/test_installed.py +20 -0
- chia/_tests/util/test_limited_semaphore.py +52 -0
- chia/_tests/util/test_logging_filter.py +43 -0
- chia/_tests/util/test_misc.py +444 -0
- chia/_tests/util/test_network.py +74 -0
- chia/_tests/util/test_network_protocol_files.py +579 -0
- chia/_tests/util/test_network_protocol_json.py +266 -0
- chia/_tests/util/test_network_protocol_test.py +257 -0
- chia/_tests/util/test_paginator.py +72 -0
- chia/_tests/util/test_pprint.py +17 -0
- chia/_tests/util/test_priority_mutex.py +487 -0
- chia/_tests/util/test_recursive_replace.py +116 -0
- chia/_tests/util/test_replace_str_to_bytes.py +137 -0
- chia/_tests/util/test_service_groups.py +15 -0
- chia/_tests/util/test_ssl_check.py +31 -0
- chia/_tests/util/test_testnet_overrides.py +19 -0
- chia/_tests/util/test_tests_misc.py +38 -0
- chia/_tests/util/test_timing.py +37 -0
- chia/_tests/util/test_trusted_peer.py +51 -0
- chia/_tests/util/time_out_assert.py +154 -0
- chia/_tests/wallet/__init__.py +0 -0
- chia/_tests/wallet/cat_wallet/__init__.py +0 -0
- chia/_tests/wallet/cat_wallet/config.py +4 -0
- chia/_tests/wallet/cat_wallet/test_cat_lifecycle.py +468 -0
- chia/_tests/wallet/cat_wallet/test_cat_outer_puzzle.py +69 -0
- chia/_tests/wallet/cat_wallet/test_cat_wallet.py +1738 -0
- chia/_tests/wallet/cat_wallet/test_offer_lifecycle.py +291 -0
- chia/_tests/wallet/cat_wallet/test_trades.py +2578 -0
- chia/_tests/wallet/clawback/__init__.py +0 -0
- chia/_tests/wallet/clawback/config.py +3 -0
- chia/_tests/wallet/clawback/test_clawback_decorator.py +80 -0
- chia/_tests/wallet/clawback/test_clawback_lifecycle.py +292 -0
- chia/_tests/wallet/clawback/test_clawback_metadata.py +51 -0
- chia/_tests/wallet/config.py +4 -0
- chia/_tests/wallet/conftest.py +217 -0
- chia/_tests/wallet/dao_wallet/__init__.py +0 -0
- chia/_tests/wallet/dao_wallet/config.py +3 -0
- chia/_tests/wallet/dao_wallet/test_dao_clvm.py +1322 -0
- chia/_tests/wallet/dao_wallet/test_dao_wallets.py +3488 -0
- chia/_tests/wallet/db_wallet/__init__.py +0 -0
- chia/_tests/wallet/db_wallet/config.py +3 -0
- chia/_tests/wallet/db_wallet/test_db_graftroot.py +143 -0
- chia/_tests/wallet/db_wallet/test_dl_offers.py +491 -0
- chia/_tests/wallet/db_wallet/test_dl_wallet.py +823 -0
- chia/_tests/wallet/did_wallet/__init__.py +0 -0
- chia/_tests/wallet/did_wallet/config.py +4 -0
- chia/_tests/wallet/did_wallet/test_did.py +1481 -0
- chia/_tests/wallet/nft_wallet/__init__.py +0 -0
- chia/_tests/wallet/nft_wallet/config.py +4 -0
- chia/_tests/wallet/nft_wallet/test_nft_1_offers.py +1492 -0
- chia/_tests/wallet/nft_wallet/test_nft_bulk_mint.py +1014 -0
- chia/_tests/wallet/nft_wallet/test_nft_lifecycle.py +376 -0
- chia/_tests/wallet/nft_wallet/test_nft_offers.py +1209 -0
- chia/_tests/wallet/nft_wallet/test_nft_puzzles.py +172 -0
- chia/_tests/wallet/nft_wallet/test_nft_wallet.py +2558 -0
- chia/_tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +70 -0
- chia/_tests/wallet/rpc/__init__.py +0 -0
- chia/_tests/wallet/rpc/config.py +4 -0
- chia/_tests/wallet/rpc/test_dl_wallet_rpc.py +287 -0
- chia/_tests/wallet/rpc/test_wallet_rpc.py +3106 -0
- chia/_tests/wallet/simple_sync/__init__.py +0 -0
- chia/_tests/wallet/simple_sync/config.py +3 -0
- chia/_tests/wallet/simple_sync/test_simple_sync_protocol.py +719 -0
- chia/_tests/wallet/sync/__init__.py +0 -0
- chia/_tests/wallet/sync/config.py +4 -0
- chia/_tests/wallet/sync/test_wallet_sync.py +1529 -0
- chia/_tests/wallet/test_address_type.py +189 -0
- chia/_tests/wallet/test_bech32m.py +45 -0
- chia/_tests/wallet/test_clvm_streamable.py +244 -0
- chia/_tests/wallet/test_coin_selection.py +589 -0
- chia/_tests/wallet/test_conditions.py +388 -0
- chia/_tests/wallet/test_debug_spend_bundle.py +76 -0
- chia/_tests/wallet/test_new_wallet_protocol.py +1176 -0
- chia/_tests/wallet/test_nft_store.py +193 -0
- chia/_tests/wallet/test_notifications.py +196 -0
- chia/_tests/wallet/test_offer_parsing_performance.py +48 -0
- chia/_tests/wallet/test_puzzle_store.py +133 -0
- chia/_tests/wallet/test_sign_coin_spends.py +159 -0
- chia/_tests/wallet/test_signer_protocol.py +948 -0
- chia/_tests/wallet/test_singleton.py +122 -0
- chia/_tests/wallet/test_singleton_lifecycle_fast.py +772 -0
- chia/_tests/wallet/test_singleton_store.py +152 -0
- chia/_tests/wallet/test_taproot.py +19 -0
- chia/_tests/wallet/test_transaction_store.py +941 -0
- chia/_tests/wallet/test_util.py +181 -0
- chia/_tests/wallet/test_wallet.py +2139 -0
- chia/_tests/wallet/test_wallet_action_scope.py +85 -0
- chia/_tests/wallet/test_wallet_blockchain.py +113 -0
- chia/_tests/wallet/test_wallet_coin_store.py +1002 -0
- chia/_tests/wallet/test_wallet_interested_store.py +43 -0
- chia/_tests/wallet/test_wallet_key_val_store.py +40 -0
- chia/_tests/wallet/test_wallet_node.py +783 -0
- chia/_tests/wallet/test_wallet_retry.py +95 -0
- chia/_tests/wallet/test_wallet_state_manager.py +252 -0
- chia/_tests/wallet/test_wallet_test_framework.py +275 -0
- chia/_tests/wallet/test_wallet_trade_store.py +218 -0
- chia/_tests/wallet/test_wallet_user_store.py +34 -0
- chia/_tests/wallet/test_wallet_utils.py +155 -0
- chia/_tests/wallet/vc_wallet/__init__.py +0 -0
- chia/_tests/wallet/vc_wallet/config.py +3 -0
- chia/_tests/wallet/vc_wallet/test_cr_outer_puzzle.py +70 -0
- chia/_tests/wallet/vc_wallet/test_vc_lifecycle.py +883 -0
- chia/_tests/wallet/vc_wallet/test_vc_wallet.py +801 -0
- chia/_tests/wallet/wallet_block_tools.py +327 -0
- chia/_tests/weight_proof/__init__.py +0 -0
- chia/_tests/weight_proof/config.py +3 -0
- chia/_tests/weight_proof/test_weight_proof.py +528 -0
- chia/clvm/__init__.py +0 -0
- chia/clvm/spend_sim.py +488 -0
- chia/cmds/__init__.py +0 -0
- chia/cmds/beta.py +183 -0
- chia/cmds/beta_funcs.py +133 -0
- chia/cmds/check_wallet_db.py +418 -0
- chia/cmds/chia.py +143 -0
- chia/cmds/cmd_classes.py +315 -0
- chia/cmds/cmds_util.py +498 -0
- chia/cmds/coin_funcs.py +260 -0
- chia/cmds/coins.py +220 -0
- chia/cmds/completion.py +49 -0
- chia/cmds/configure.py +331 -0
- chia/cmds/dao.py +1008 -0
- chia/cmds/dao_funcs.py +576 -0
- chia/cmds/data.py +707 -0
- chia/cmds/data_funcs.py +380 -0
- chia/cmds/db.py +86 -0
- chia/cmds/db_backup_func.py +77 -0
- chia/cmds/db_upgrade_func.py +452 -0
- chia/cmds/db_validate_func.py +184 -0
- chia/cmds/dev.py +16 -0
- chia/cmds/farm.py +87 -0
- chia/cmds/farm_funcs.py +207 -0
- chia/cmds/init.py +70 -0
- chia/cmds/init_funcs.py +367 -0
- chia/cmds/installers.py +129 -0
- chia/cmds/keys.py +510 -0
- chia/cmds/keys_funcs.py +864 -0
- chia/cmds/netspace.py +47 -0
- chia/cmds/netspace_funcs.py +53 -0
- chia/cmds/options.py +32 -0
- chia/cmds/param_types.py +228 -0
- chia/cmds/passphrase.py +130 -0
- chia/cmds/passphrase_funcs.py +346 -0
- chia/cmds/peer.py +50 -0
- chia/cmds/peer_funcs.py +129 -0
- chia/cmds/plotnft.py +206 -0
- chia/cmds/plotnft_funcs.py +374 -0
- chia/cmds/plots.py +222 -0
- chia/cmds/plotters.py +17 -0
- chia/cmds/rpc.py +188 -0
- chia/cmds/show.py +71 -0
- chia/cmds/show_funcs.py +214 -0
- chia/cmds/signer.py +304 -0
- chia/cmds/sim.py +217 -0
- chia/cmds/sim_funcs.py +509 -0
- chia/cmds/start.py +24 -0
- chia/cmds/start_funcs.py +112 -0
- chia/cmds/stop.py +61 -0
- chia/cmds/units.py +11 -0
- chia/cmds/wallet.py +1745 -0
- chia/cmds/wallet_funcs.py +1800 -0
- chia/consensus/__init__.py +0 -0
- chia/consensus/block_body_validation.py +515 -0
- chia/consensus/block_creation.py +525 -0
- chia/consensus/block_header_validation.py +1064 -0
- chia/consensus/block_record.py +32 -0
- chia/consensus/block_rewards.py +53 -0
- chia/consensus/block_root_validation.py +46 -0
- chia/consensus/blockchain.py +1100 -0
- chia/consensus/blockchain_interface.py +56 -0
- chia/consensus/coinbase.py +30 -0
- chia/consensus/condition_costs.py +9 -0
- chia/consensus/constants.py +49 -0
- chia/consensus/cost_calculator.py +15 -0
- chia/consensus/default_constants.py +90 -0
- chia/consensus/deficit.py +55 -0
- chia/consensus/difficulty_adjustment.py +412 -0
- chia/consensus/find_fork_point.py +111 -0
- chia/consensus/full_block_to_block_record.py +167 -0
- chia/consensus/get_block_challenge.py +106 -0
- chia/consensus/get_block_generator.py +26 -0
- chia/consensus/make_sub_epoch_summary.py +210 -0
- chia/consensus/multiprocess_validation.py +365 -0
- chia/consensus/pos_quality.py +19 -0
- chia/consensus/pot_iterations.py +67 -0
- chia/consensus/puzzles/__init__.py +0 -0
- chia/consensus/puzzles/chialisp_deserialisation.clsp +69 -0
- chia/consensus/puzzles/chialisp_deserialisation.clsp.hex +1 -0
- chia/consensus/puzzles/rom_bootstrap_generator.clsp +37 -0
- chia/consensus/puzzles/rom_bootstrap_generator.clsp.hex +1 -0
- chia/consensus/vdf_info_computation.py +156 -0
- chia/daemon/__init__.py +0 -0
- chia/daemon/client.py +233 -0
- chia/daemon/keychain_proxy.py +501 -0
- chia/daemon/keychain_server.py +365 -0
- chia/daemon/server.py +1616 -0
- chia/daemon/windows_signal.py +56 -0
- chia/data_layer/__init__.py +0 -0
- chia/data_layer/data_layer.py +1303 -0
- chia/data_layer/data_layer_api.py +25 -0
- chia/data_layer/data_layer_errors.py +50 -0
- chia/data_layer/data_layer_server.py +170 -0
- chia/data_layer/data_layer_util.py +985 -0
- chia/data_layer/data_layer_wallet.py +1315 -0
- chia/data_layer/data_store.py +2267 -0
- chia/data_layer/dl_wallet_store.py +407 -0
- chia/data_layer/download_data.py +389 -0
- chia/data_layer/puzzles/__init__.py +0 -0
- chia/data_layer/puzzles/graftroot_dl_offers.clsp +100 -0
- chia/data_layer/puzzles/graftroot_dl_offers.clsp.hex +1 -0
- chia/data_layer/s3_plugin_config.yml +33 -0
- chia/data_layer/s3_plugin_service.py +468 -0
- chia/data_layer/util/__init__.py +0 -0
- chia/data_layer/util/benchmark.py +108 -0
- chia/data_layer/util/plugin.py +41 -0
- chia/farmer/__init__.py +0 -0
- chia/farmer/farmer.py +920 -0
- chia/farmer/farmer_api.py +814 -0
- chia/full_node/__init__.py +0 -0
- chia/full_node/bitcoin_fee_estimator.py +85 -0
- chia/full_node/block_height_map.py +271 -0
- chia/full_node/block_store.py +570 -0
- chia/full_node/bundle_tools.py +19 -0
- chia/full_node/coin_store.py +646 -0
- chia/full_node/fee_estimate.py +54 -0
- chia/full_node/fee_estimate_store.py +24 -0
- chia/full_node/fee_estimation.py +93 -0
- chia/full_node/fee_estimator.py +90 -0
- chia/full_node/fee_estimator_constants.py +38 -0
- chia/full_node/fee_estimator_interface.py +42 -0
- chia/full_node/fee_history.py +26 -0
- chia/full_node/fee_tracker.py +564 -0
- chia/full_node/full_node.py +3052 -0
- chia/full_node/full_node_api.py +1974 -0
- chia/full_node/full_node_store.py +1033 -0
- chia/full_node/hint_management.py +56 -0
- chia/full_node/hint_store.py +94 -0
- chia/full_node/mempool.py +583 -0
- chia/full_node/mempool_check_conditions.py +177 -0
- chia/full_node/mempool_manager.py +858 -0
- chia/full_node/pending_tx_cache.py +112 -0
- chia/full_node/puzzles/__init__.py +0 -0
- chia/full_node/puzzles/block_program_zero.clsp +14 -0
- chia/full_node/puzzles/block_program_zero.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp +5 -0
- chia/full_node/puzzles/decompress_coin_spend_entry.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp +7 -0
- chia/full_node/puzzles/decompress_coin_spend_entry_with_prefix.clsp.hex +1 -0
- chia/full_node/puzzles/decompress_puzzle.clsp +6 -0
- chia/full_node/puzzles/decompress_puzzle.clsp.hex +1 -0
- chia/full_node/signage_point.py +16 -0
- chia/full_node/subscriptions.py +248 -0
- chia/full_node/sync_store.py +145 -0
- chia/full_node/tx_processing_queue.py +78 -0
- chia/full_node/weight_proof.py +1719 -0
- chia/harvester/__init__.py +0 -0
- chia/harvester/harvester.py +271 -0
- chia/harvester/harvester_api.py +374 -0
- chia/introducer/__init__.py +0 -0
- chia/introducer/introducer.py +120 -0
- chia/introducer/introducer_api.py +64 -0
- chia/legacy/__init__.py +0 -0
- chia/legacy/keyring.py +154 -0
- chia/plot_sync/__init__.py +0 -0
- chia/plot_sync/delta.py +61 -0
- chia/plot_sync/exceptions.py +56 -0
- chia/plot_sync/receiver.py +385 -0
- chia/plot_sync/sender.py +337 -0
- chia/plot_sync/util.py +43 -0
- chia/plotters/__init__.py +0 -0
- chia/plotters/bladebit.py +388 -0
- chia/plotters/chiapos.py +63 -0
- chia/plotters/madmax.py +224 -0
- chia/plotters/plotters.py +577 -0
- chia/plotters/plotters_util.py +131 -0
- chia/plotting/__init__.py +0 -0
- chia/plotting/cache.py +212 -0
- chia/plotting/check_plots.py +283 -0
- chia/plotting/create_plots.py +278 -0
- chia/plotting/manager.py +436 -0
- chia/plotting/util.py +324 -0
- chia/pools/__init__.py +0 -0
- chia/pools/pool_config.py +110 -0
- chia/pools/pool_puzzles.py +459 -0
- chia/pools/pool_wallet.py +926 -0
- chia/pools/pool_wallet_info.py +118 -0
- chia/pools/puzzles/__init__.py +0 -0
- chia/pools/puzzles/pool_member_innerpuz.clsp +70 -0
- chia/pools/puzzles/pool_member_innerpuz.clsp.hex +1 -0
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp +69 -0
- chia/pools/puzzles/pool_waitingroom_innerpuz.clsp.hex +1 -0
- chia/protocols/__init__.py +0 -0
- chia/protocols/farmer_protocol.py +102 -0
- chia/protocols/full_node_protocol.py +219 -0
- chia/protocols/harvester_protocol.py +216 -0
- chia/protocols/introducer_protocol.py +26 -0
- chia/protocols/pool_protocol.py +177 -0
- chia/protocols/protocol_message_types.py +139 -0
- chia/protocols/protocol_state_machine.py +87 -0
- chia/protocols/protocol_timing.py +7 -0
- chia/protocols/shared_protocol.py +86 -0
- chia/protocols/timelord_protocol.py +93 -0
- chia/protocols/wallet_protocol.py +401 -0
- chia/py.typed +0 -0
- chia/rpc/__init__.py +0 -0
- chia/rpc/crawler_rpc_api.py +75 -0
- chia/rpc/data_layer_rpc_api.py +639 -0
- chia/rpc/data_layer_rpc_client.py +188 -0
- chia/rpc/data_layer_rpc_util.py +62 -0
- chia/rpc/farmer_rpc_api.py +360 -0
- chia/rpc/farmer_rpc_client.py +86 -0
- chia/rpc/full_node_rpc_api.py +954 -0
- chia/rpc/full_node_rpc_client.py +292 -0
- chia/rpc/harvester_rpc_api.py +136 -0
- chia/rpc/harvester_rpc_client.py +54 -0
- chia/rpc/rpc_client.py +144 -0
- chia/rpc/rpc_server.py +447 -0
- chia/rpc/timelord_rpc_api.py +27 -0
- chia/rpc/util.py +293 -0
- chia/rpc/wallet_request_types.py +688 -0
- chia/rpc/wallet_rpc_api.py +4779 -0
- chia/rpc/wallet_rpc_client.py +1844 -0
- chia/seeder/__init__.py +0 -0
- chia/seeder/crawl_store.py +427 -0
- chia/seeder/crawler.py +423 -0
- chia/seeder/crawler_api.py +129 -0
- chia/seeder/dns_server.py +544 -0
- chia/seeder/peer_record.py +146 -0
- chia/seeder/start_crawler.py +88 -0
- chia/server/__init__.py +0 -0
- chia/server/address_manager.py +658 -0
- chia/server/address_manager_store.py +237 -0
- chia/server/api_protocol.py +11 -0
- chia/server/capabilities.py +24 -0
- chia/server/chia_policy.py +345 -0
- chia/server/introducer_peers.py +76 -0
- chia/server/node_discovery.py +718 -0
- chia/server/outbound_message.py +33 -0
- chia/server/rate_limit_numbers.py +204 -0
- chia/server/rate_limits.py +113 -0
- chia/server/server.py +720 -0
- chia/server/signal_handlers.py +117 -0
- chia/server/ssl_context.py +32 -0
- chia/server/start_data_layer.py +137 -0
- chia/server/start_farmer.py +86 -0
- chia/server/start_full_node.py +106 -0
- chia/server/start_harvester.py +80 -0
- chia/server/start_introducer.py +69 -0
- chia/server/start_service.py +328 -0
- chia/server/start_timelord.py +82 -0
- chia/server/start_wallet.py +109 -0
- chia/server/upnp.py +117 -0
- chia/server/ws_connection.py +752 -0
- chia/simulator/__init__.py +0 -0
- chia/simulator/block_tools.py +2053 -0
- chia/simulator/full_node_simulator.py +802 -0
- chia/simulator/keyring.py +128 -0
- chia/simulator/setup_services.py +505 -0
- chia/simulator/simulator_constants.py +13 -0
- chia/simulator/simulator_full_node_rpc_api.py +101 -0
- chia/simulator/simulator_full_node_rpc_client.py +62 -0
- chia/simulator/simulator_protocol.py +29 -0
- chia/simulator/simulator_test_tools.py +163 -0
- chia/simulator/socket.py +27 -0
- chia/simulator/ssl_certs.py +114 -0
- chia/simulator/ssl_certs_1.py +699 -0
- chia/simulator/ssl_certs_10.py +699 -0
- chia/simulator/ssl_certs_2.py +699 -0
- chia/simulator/ssl_certs_3.py +699 -0
- chia/simulator/ssl_certs_4.py +699 -0
- chia/simulator/ssl_certs_5.py +699 -0
- chia/simulator/ssl_certs_6.py +699 -0
- chia/simulator/ssl_certs_7.py +699 -0
- chia/simulator/ssl_certs_8.py +699 -0
- chia/simulator/ssl_certs_9.py +699 -0
- chia/simulator/start_simulator.py +135 -0
- chia/simulator/wallet_tools.py +245 -0
- chia/ssl/__init__.py +0 -0
- chia/ssl/chia_ca.crt +19 -0
- chia/ssl/chia_ca.key +28 -0
- chia/ssl/create_ssl.py +249 -0
- chia/ssl/dst_root_ca.pem +20 -0
- chia/timelord/__init__.py +0 -0
- chia/timelord/iters_from_block.py +50 -0
- chia/timelord/timelord.py +1202 -0
- chia/timelord/timelord_api.py +132 -0
- chia/timelord/timelord_launcher.py +188 -0
- chia/timelord/timelord_state.py +244 -0
- chia/timelord/types.py +22 -0
- chia/types/__init__.py +0 -0
- chia/types/aliases.py +35 -0
- chia/types/block_protocol.py +20 -0
- chia/types/blockchain_format/__init__.py +0 -0
- chia/types/blockchain_format/classgroup.py +5 -0
- chia/types/blockchain_format/coin.py +28 -0
- chia/types/blockchain_format/foliage.py +8 -0
- chia/types/blockchain_format/pool_target.py +5 -0
- chia/types/blockchain_format/program.py +270 -0
- chia/types/blockchain_format/proof_of_space.py +135 -0
- chia/types/blockchain_format/reward_chain_block.py +6 -0
- chia/types/blockchain_format/serialized_program.py +5 -0
- chia/types/blockchain_format/sized_bytes.py +11 -0
- chia/types/blockchain_format/slots.py +9 -0
- chia/types/blockchain_format/sub_epoch_summary.py +5 -0
- chia/types/blockchain_format/tree_hash.py +72 -0
- chia/types/blockchain_format/vdf.py +86 -0
- chia/types/clvm_cost.py +13 -0
- chia/types/coin_record.py +43 -0
- chia/types/coin_spend.py +115 -0
- chia/types/condition_opcodes.py +73 -0
- chia/types/condition_with_args.py +17 -0
- chia/types/eligible_coin_spends.py +364 -0
- chia/types/end_of_slot_bundle.py +5 -0
- chia/types/fee_rate.py +38 -0
- chia/types/full_block.py +5 -0
- chia/types/generator_types.py +14 -0
- chia/types/header_block.py +5 -0
- chia/types/internal_mempool_item.py +19 -0
- chia/types/mempool_inclusion_status.py +9 -0
- chia/types/mempool_item.py +85 -0
- chia/types/mempool_submission_status.py +30 -0
- chia/types/mojos.py +7 -0
- chia/types/peer_info.py +64 -0
- chia/types/signing_mode.py +29 -0
- chia/types/spend_bundle.py +31 -0
- chia/types/spend_bundle_conditions.py +7 -0
- chia/types/transaction_queue_entry.py +55 -0
- chia/types/unfinished_block.py +5 -0
- chia/types/unfinished_header_block.py +37 -0
- chia/types/weight_proof.py +50 -0
- chia/util/__init__.py +0 -0
- chia/util/action_scope.py +168 -0
- chia/util/api_decorators.py +89 -0
- chia/util/async_pool.py +224 -0
- chia/util/augmented_chain.py +130 -0
- chia/util/batches.py +39 -0
- chia/util/bech32m.py +123 -0
- chia/util/beta_metrics.py +118 -0
- chia/util/block_cache.py +56 -0
- chia/util/byte_types.py +10 -0
- chia/util/check_fork_next_block.py +32 -0
- chia/util/chia_logging.py +124 -0
- chia/util/chia_version.py +33 -0
- chia/util/collection.py +17 -0
- chia/util/condition_tools.py +201 -0
- chia/util/config.py +366 -0
- chia/util/cpu.py +20 -0
- chia/util/db_synchronous.py +21 -0
- chia/util/db_version.py +30 -0
- chia/util/db_wrapper.py +427 -0
- chia/util/default_root.py +10 -0
- chia/util/dump_keyring.py +93 -0
- chia/util/english.txt +2048 -0
- chia/util/errors.py +351 -0
- chia/util/file_keyring.py +480 -0
- chia/util/files.py +95 -0
- chia/util/full_block_utils.py +321 -0
- chia/util/generator_tools.py +62 -0
- chia/util/hash.py +29 -0
- chia/util/initial-config.yaml +675 -0
- chia/util/inline_executor.py +24 -0
- chia/util/ints.py +19 -0
- chia/util/json_util.py +41 -0
- chia/util/keychain.py +673 -0
- chia/util/keyring_wrapper.py +266 -0
- chia/util/limited_semaphore.py +39 -0
- chia/util/lock.py +47 -0
- chia/util/log_exceptions.py +29 -0
- chia/util/logging.py +34 -0
- chia/util/lru_cache.py +29 -0
- chia/util/math.py +20 -0
- chia/util/network.py +240 -0
- chia/util/paginator.py +46 -0
- chia/util/path.py +29 -0
- chia/util/permissions.py +19 -0
- chia/util/pprint.py +40 -0
- chia/util/prev_transaction_block.py +23 -0
- chia/util/priority_mutex.py +92 -0
- chia/util/profiler.py +194 -0
- chia/util/recursive_replace.py +22 -0
- chia/util/safe_cancel_task.py +14 -0
- chia/util/service_groups.py +47 -0
- chia/util/setproctitle.py +20 -0
- chia/util/significant_bits.py +30 -0
- chia/util/ssl_check.py +213 -0
- chia/util/streamable.py +654 -0
- chia/util/task_timing.py +378 -0
- chia/util/timing.py +64 -0
- chia/util/vdf_prover.py +31 -0
- chia/util/ws_message.py +66 -0
- chia/wallet/__init__.py +0 -0
- chia/wallet/cat_wallet/__init__.py +0 -0
- chia/wallet/cat_wallet/cat_constants.py +75 -0
- chia/wallet/cat_wallet/cat_info.py +47 -0
- chia/wallet/cat_wallet/cat_outer_puzzle.py +120 -0
- chia/wallet/cat_wallet/cat_utils.py +163 -0
- chia/wallet/cat_wallet/cat_wallet.py +869 -0
- chia/wallet/cat_wallet/dao_cat_info.py +28 -0
- chia/wallet/cat_wallet/dao_cat_wallet.py +669 -0
- chia/wallet/cat_wallet/lineage_store.py +74 -0
- chia/wallet/cat_wallet/puzzles/__init__.py +0 -0
- chia/wallet/cat_wallet/puzzles/cat_truths.clib +31 -0
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp +397 -0
- chia/wallet/cat_wallet/puzzles/cat_v2.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp +25 -0
- chia/wallet/cat_wallet/puzzles/delegated_tail.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp +15 -0
- chia/wallet/cat_wallet/puzzles/everything_with_signature.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp +26 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp +42 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_coin_id_or_singleton.clsp.hex +1 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp +24 -0
- chia/wallet/cat_wallet/puzzles/genesis_by_puzzle_hash.clsp.hex +1 -0
- chia/wallet/coin_selection.py +188 -0
- chia/wallet/conditions.py +1326 -0
- chia/wallet/dao_wallet/__init__.py +0 -0
- chia/wallet/dao_wallet/dao_info.py +61 -0
- chia/wallet/dao_wallet/dao_utils.py +810 -0
- chia/wallet/dao_wallet/dao_wallet.py +2121 -0
- chia/wallet/db_wallet/__init__.py +0 -0
- chia/wallet/db_wallet/db_wallet_puzzles.py +107 -0
- chia/wallet/derivation_record.py +30 -0
- chia/wallet/derive_keys.py +146 -0
- chia/wallet/did_wallet/__init__.py +0 -0
- chia/wallet/did_wallet/did_info.py +39 -0
- chia/wallet/did_wallet/did_wallet.py +1485 -0
- chia/wallet/did_wallet/did_wallet_puzzles.py +220 -0
- chia/wallet/did_wallet/puzzles/__init__.py +0 -0
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp +135 -0
- chia/wallet/did_wallet/puzzles/did_innerpuz.clsp.hex +1 -0
- chia/wallet/driver_protocol.py +26 -0
- chia/wallet/key_val_store.py +55 -0
- chia/wallet/lineage_proof.py +58 -0
- chia/wallet/nft_wallet/__init__.py +0 -0
- chia/wallet/nft_wallet/metadata_outer_puzzle.py +92 -0
- chia/wallet/nft_wallet/nft_info.py +120 -0
- chia/wallet/nft_wallet/nft_puzzles.py +305 -0
- chia/wallet/nft_wallet/nft_wallet.py +1686 -0
- chia/wallet/nft_wallet/ownership_outer_puzzle.py +101 -0
- chia/wallet/nft_wallet/puzzles/__init__.py +0 -0
- chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp +6 -0
- chia/wallet/nft_wallet/puzzles/create_nft_launcher_from_did.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp +6 -0
- chia/wallet/nft_wallet/puzzles/nft_intermediate_launcher.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp +30 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_default.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp +28 -0
- chia/wallet/nft_wallet/puzzles/nft_metadata_updater_updateable.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp +100 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_layer.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp +78 -0
- chia/wallet/nft_wallet/puzzles/nft_ownership_transfer_program_one_way_claim_with_royalties.clsp.hex +1 -0
- chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp +74 -0
- chia/wallet/nft_wallet/puzzles/nft_state_layer.clsp.hex +1 -0
- chia/wallet/nft_wallet/singleton_outer_puzzle.py +101 -0
- chia/wallet/nft_wallet/transfer_program_puzzle.py +82 -0
- chia/wallet/nft_wallet/uncurry_nft.py +217 -0
- chia/wallet/notification_manager.py +117 -0
- chia/wallet/notification_store.py +178 -0
- chia/wallet/outer_puzzles.py +84 -0
- chia/wallet/payment.py +34 -0
- chia/wallet/puzzle_drivers.py +118 -0
- chia/wallet/puzzles/__init__.py +0 -0
- chia/wallet/puzzles/augmented_condition.clsp +13 -0
- chia/wallet/puzzles/augmented_condition.clsp.hex +1 -0
- chia/wallet/puzzles/clawback/__init__.py +0 -0
- chia/wallet/puzzles/clawback/drivers.py +188 -0
- chia/wallet/puzzles/clawback/metadata.py +38 -0
- chia/wallet/puzzles/clawback/puzzle_decorator.py +67 -0
- chia/wallet/puzzles/condition_codes.clib +77 -0
- chia/wallet/puzzles/curry-and-treehash.clib +102 -0
- chia/wallet/puzzles/curry.clib +135 -0
- chia/wallet/puzzles/curry_by_index.clib +16 -0
- chia/wallet/puzzles/dao_cat_eve.clsp +17 -0
- chia/wallet/puzzles/dao_cat_eve.clsp.hex +1 -0
- chia/wallet/puzzles/dao_cat_launcher.clsp +36 -0
- chia/wallet/puzzles/dao_cat_launcher.clsp.hex +1 -0
- chia/wallet/puzzles/dao_finished_state.clsp +35 -0
- chia/wallet/puzzles/dao_finished_state.clsp.hex +1 -0
- chia/wallet/puzzles/dao_finished_state.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_lockup.clsp +288 -0
- chia/wallet/puzzles/dao_lockup.clsp.hex +1 -0
- chia/wallet/puzzles/dao_lockup.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal.clsp +377 -0
- chia/wallet/puzzles/dao_proposal.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp +78 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal_timer.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp +87 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex +1 -0
- chia/wallet/puzzles/dao_proposal_validator.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp +240 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex +1 -0
- chia/wallet/puzzles/dao_spend_p2_singleton_v2.clsp.hex.sha256tree +1 -0
- chia/wallet/puzzles/dao_treasury.clsp +115 -0
- chia/wallet/puzzles/dao_treasury.clsp.hex +1 -0
- chia/wallet/puzzles/dao_update_proposal.clsp +44 -0
- chia/wallet/puzzles/dao_update_proposal.clsp.hex +1 -0
- chia/wallet/puzzles/deployed_puzzle_hashes.json +67 -0
- chia/wallet/puzzles/json.clib +25 -0
- chia/wallet/puzzles/load_clvm.py +162 -0
- chia/wallet/puzzles/merkle_utils.clib +18 -0
- chia/wallet/puzzles/notification.clsp +7 -0
- chia/wallet/puzzles/notification.clsp.hex +1 -0
- chia/wallet/puzzles/p2_1_of_n.clsp +22 -0
- chia/wallet/puzzles/p2_1_of_n.clsp.hex +1 -0
- chia/wallet/puzzles/p2_conditions.clsp +3 -0
- chia/wallet/puzzles/p2_conditions.clsp.hex +1 -0
- chia/wallet/puzzles/p2_conditions.py +27 -0
- chia/wallet/puzzles/p2_delegated_conditions.clsp +18 -0
- chia/wallet/puzzles/p2_delegated_conditions.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_conditions.py +22 -0
- chia/wallet/puzzles/p2_delegated_puzzle.clsp +19 -0
- chia/wallet/puzzles/p2_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_puzzle.py +35 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp +91 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +161 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp +108 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.clsp.hex +1 -0
- chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +22 -0
- chia/wallet/puzzles/p2_parent.clsp +19 -0
- chia/wallet/puzzles/p2_parent.clsp.hex +1 -0
- chia/wallet/puzzles/p2_puzzle_hash.clsp +18 -0
- chia/wallet/puzzles/p2_puzzle_hash.clsp.hex +1 -0
- chia/wallet/puzzles/p2_puzzle_hash.py +28 -0
- chia/wallet/puzzles/p2_singleton.clsp +30 -0
- chia/wallet/puzzles/p2_singleton.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_aggregator.clsp +81 -0
- chia/wallet/puzzles/p2_singleton_aggregator.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp +50 -0
- chia/wallet/puzzles/p2_singleton_or_delayed_puzhash.clsp.hex +1 -0
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp +47 -0
- chia/wallet/puzzles/p2_singleton_via_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/puzzles/puzzle_utils.py +34 -0
- chia/wallet/puzzles/settlement_payments.clsp +49 -0
- chia/wallet/puzzles/settlement_payments.clsp.hex +1 -0
- chia/wallet/puzzles/sha256tree.clib +11 -0
- chia/wallet/puzzles/singleton_launcher.clsp +16 -0
- chia/wallet/puzzles/singleton_launcher.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer.clsp +177 -0
- chia/wallet/puzzles/singleton_top_layer.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer.py +295 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp +107 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.clsp.hex +1 -0
- chia/wallet/puzzles/singleton_top_layer_v1_1.py +344 -0
- chia/wallet/puzzles/singleton_truths.clib +21 -0
- chia/wallet/puzzles/tails.py +344 -0
- chia/wallet/puzzles/utility_macros.clib +48 -0
- chia/wallet/signer_protocol.py +126 -0
- chia/wallet/singleton.py +106 -0
- chia/wallet/singleton_record.py +30 -0
- chia/wallet/trade_manager.py +1088 -0
- chia/wallet/trade_record.py +67 -0
- chia/wallet/trading/__init__.py +0 -0
- chia/wallet/trading/offer.py +703 -0
- chia/wallet/trading/trade_status.py +13 -0
- chia/wallet/trading/trade_store.py +526 -0
- chia/wallet/transaction_record.py +143 -0
- chia/wallet/transaction_sorting.py +14 -0
- chia/wallet/uncurried_puzzle.py +17 -0
- chia/wallet/util/__init__.py +0 -0
- chia/wallet/util/address_type.py +55 -0
- chia/wallet/util/blind_signer_tl.py +168 -0
- chia/wallet/util/clvm_streamable.py +203 -0
- chia/wallet/util/compute_hints.py +66 -0
- chia/wallet/util/compute_memos.py +45 -0
- chia/wallet/util/curry_and_treehash.py +90 -0
- chia/wallet/util/debug_spend_bundle.py +234 -0
- chia/wallet/util/merkle_tree.py +100 -0
- chia/wallet/util/merkle_utils.py +102 -0
- chia/wallet/util/new_peak_queue.py +82 -0
- chia/wallet/util/notifications.py +12 -0
- chia/wallet/util/peer_request_cache.py +174 -0
- chia/wallet/util/puzzle_compression.py +96 -0
- chia/wallet/util/puzzle_decorator.py +100 -0
- chia/wallet/util/puzzle_decorator_type.py +7 -0
- chia/wallet/util/query_filter.py +60 -0
- chia/wallet/util/transaction_type.py +23 -0
- chia/wallet/util/tx_config.py +158 -0
- chia/wallet/util/wallet_sync_utils.py +348 -0
- chia/wallet/util/wallet_types.py +65 -0
- chia/wallet/vc_wallet/__init__.py +0 -0
- chia/wallet/vc_wallet/cr_cat_drivers.py +663 -0
- chia/wallet/vc_wallet/cr_cat_wallet.py +875 -0
- chia/wallet/vc_wallet/cr_outer_puzzle.py +102 -0
- chia/wallet/vc_wallet/cr_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp +3 -0
- chia/wallet/vc_wallet/cr_puzzles/conditions_w_fee_announce.clsp.hex +1 -0
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp +304 -0
- chia/wallet/vc_wallet/cr_puzzles/credential_restriction.clsp.hex +1 -0
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp +45 -0
- chia/wallet/vc_wallet/cr_puzzles/flag_proofs_checker.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_drivers.py +838 -0
- chia/wallet/vc_wallet/vc_puzzles/__init__.py +0 -0
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp +30 -0
- chia/wallet/vc_wallet/vc_puzzles/covenant_layer.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp +75 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_covenant_morpher.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp +32 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_transfer_program_covenant_adapter.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp +80 -0
- chia/wallet/vc_wallet/vc_puzzles/eml_update_metadata_with_DID.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp +163 -0
- chia/wallet/vc_wallet/vc_puzzles/exigent_metadata_layer.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp +16 -0
- chia/wallet/vc_wallet/vc_puzzles/p2_announced_delegated_puzzle.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp +74 -0
- chia/wallet/vc_wallet/vc_puzzles/standard_vc_backdoor_puzzle.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp +23 -0
- chia/wallet/vc_wallet/vc_puzzles/std_parent_morpher.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp +64 -0
- chia/wallet/vc_wallet/vc_puzzles/viral_backdoor.clsp.hex +1 -0
- chia/wallet/vc_wallet/vc_store.py +263 -0
- chia/wallet/vc_wallet/vc_wallet.py +638 -0
- chia/wallet/wallet.py +698 -0
- chia/wallet/wallet_action_scope.py +95 -0
- chia/wallet/wallet_blockchain.py +244 -0
- chia/wallet/wallet_coin_record.py +72 -0
- chia/wallet/wallet_coin_store.py +351 -0
- chia/wallet/wallet_info.py +36 -0
- chia/wallet/wallet_interested_store.py +188 -0
- chia/wallet/wallet_nft_store.py +279 -0
- chia/wallet/wallet_node.py +1769 -0
- chia/wallet/wallet_node_api.py +201 -0
- chia/wallet/wallet_pool_store.py +120 -0
- chia/wallet/wallet_protocol.py +90 -0
- chia/wallet/wallet_puzzle_store.py +365 -0
- chia/wallet/wallet_retry_store.py +70 -0
- chia/wallet/wallet_singleton_store.py +258 -0
- chia/wallet/wallet_spend_bundle.py +41 -0
- chia/wallet/wallet_state_manager.py +2820 -0
- chia/wallet/wallet_transaction_store.py +470 -0
- chia/wallet/wallet_user_store.py +110 -0
- chia/wallet/wallet_weight_proof_handler.py +126 -0
- chia_blockchain-2.4.4.dist-info/LICENSE +201 -0
- chia_blockchain-2.4.4.dist-info/METADATA +161 -0
- chia_blockchain-2.4.4.dist-info/RECORD +1028 -0
- chia_blockchain-2.4.4.dist-info/WHEEL +4 -0
- chia_blockchain-2.4.4.dist-info/entry_points.txt +17 -0
- mozilla-ca/cacert.pem +3666 -0
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Tuple
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
from clvm.casts import int_to_bytes
|
|
8
|
+
|
|
9
|
+
from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
|
|
10
|
+
from chia._tests.util.generator_tools_testing import run_and_get_removals_and_additions
|
|
11
|
+
from chia.full_node.full_node_api import FullNodeAPI
|
|
12
|
+
from chia.protocols import wallet_protocol
|
|
13
|
+
from chia.server.server import ChiaServer
|
|
14
|
+
from chia.simulator.block_tools import BlockTools, test_constants
|
|
15
|
+
from chia.simulator.wallet_tools import WalletTool
|
|
16
|
+
from chia.types.blockchain_format.sized_bytes import bytes32
|
|
17
|
+
from chia.types.condition_opcodes import ConditionOpcode
|
|
18
|
+
from chia.types.condition_with_args import ConditionWithArgs
|
|
19
|
+
from chia.types.spend_bundle import SpendBundle, estimate_fees
|
|
20
|
+
from chia.util.errors import ConsensusError, Err
|
|
21
|
+
from chia.util.ints import uint32, uint64
|
|
22
|
+
from chia.wallet.conditions import AssertCoinAnnouncement, AssertPuzzleAnnouncement
|
|
23
|
+
|
|
24
|
+
BURN_PUZZLE_HASH = bytes32(b"0" * 32)
|
|
25
|
+
|
|
26
|
+
WALLET_A = WalletTool(test_constants)
|
|
27
|
+
WALLET_A_PUZZLE_HASHES = [WALLET_A.get_new_puzzlehash() for _ in range(5)]
|
|
28
|
+
|
|
29
|
+
log = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class TestBlockchainTransactions:
|
|
33
|
+
@pytest.mark.anyio
|
|
34
|
+
async def test_basic_blockchain_tx(
|
|
35
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
36
|
+
) -> None:
|
|
37
|
+
num_blocks = 10
|
|
38
|
+
wallet_a = WALLET_A
|
|
39
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
40
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
41
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
42
|
+
full_node_1 = full_node_api_1.full_node
|
|
43
|
+
blocks = bt.get_consecutive_blocks(
|
|
44
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
for block in blocks:
|
|
48
|
+
await full_node_api_1.full_node.add_block(block, None)
|
|
49
|
+
|
|
50
|
+
spend_block = blocks[2]
|
|
51
|
+
spend_coin = None
|
|
52
|
+
for coin in spend_block.get_included_reward_coins():
|
|
53
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
54
|
+
spend_coin = coin
|
|
55
|
+
|
|
56
|
+
assert spend_coin is not None
|
|
57
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_puzzlehash, spend_coin)
|
|
58
|
+
|
|
59
|
+
assert spend_bundle is not None
|
|
60
|
+
tx: wallet_protocol.SendTransaction = wallet_protocol.SendTransaction(spend_bundle)
|
|
61
|
+
|
|
62
|
+
await full_node_api_1.send_transaction(tx)
|
|
63
|
+
|
|
64
|
+
sb = full_node_1.mempool_manager.get_spendbundle(spend_bundle.name())
|
|
65
|
+
assert sb == spend_bundle
|
|
66
|
+
|
|
67
|
+
last_block = blocks[-1]
|
|
68
|
+
result = await full_node_1.mempool_manager.create_bundle_from_mempool(
|
|
69
|
+
last_block.header_hash, full_node_1.coin_store.get_unspent_lineage_info_for_puzzle_hash
|
|
70
|
+
)
|
|
71
|
+
assert result is not None
|
|
72
|
+
next_spendbundle, _ = result
|
|
73
|
+
|
|
74
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
75
|
+
1,
|
|
76
|
+
block_list_input=blocks,
|
|
77
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
78
|
+
transaction_data=next_spendbundle,
|
|
79
|
+
guarantee_transaction_block=True,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
next_block = new_blocks[-1]
|
|
83
|
+
await full_node_1.add_block(next_block)
|
|
84
|
+
|
|
85
|
+
blockchain_peak = full_node_1.blockchain.get_peak()
|
|
86
|
+
assert blockchain_peak is not None
|
|
87
|
+
assert next_block.header_hash == blockchain_peak.header_hash
|
|
88
|
+
|
|
89
|
+
added_coins = next_spendbundle.additions()
|
|
90
|
+
|
|
91
|
+
# Two coins are added, main spend and change
|
|
92
|
+
assert len(added_coins) == 2
|
|
93
|
+
for coin in added_coins:
|
|
94
|
+
unspent = await full_node_1.coin_store.get_coin_record(coin.name())
|
|
95
|
+
assert unspent is not None
|
|
96
|
+
assert not unspent.spent
|
|
97
|
+
assert not unspent.coinbase
|
|
98
|
+
|
|
99
|
+
@pytest.mark.anyio
|
|
100
|
+
async def test_validate_blockchain_with_double_spend(
|
|
101
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
102
|
+
) -> None:
|
|
103
|
+
num_blocks = 5
|
|
104
|
+
wallet_a = WALLET_A
|
|
105
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
106
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
107
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
108
|
+
full_node_1 = full_node_api_1.full_node
|
|
109
|
+
blocks = bt.get_consecutive_blocks(
|
|
110
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
for block in blocks:
|
|
114
|
+
await full_node_api_1.full_node.add_block(block)
|
|
115
|
+
|
|
116
|
+
spend_block = blocks[2]
|
|
117
|
+
spend_coin = None
|
|
118
|
+
for coin in spend_block.get_included_reward_coins():
|
|
119
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
120
|
+
spend_coin = coin
|
|
121
|
+
assert spend_coin is not None
|
|
122
|
+
|
|
123
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_puzzlehash, spend_coin)
|
|
124
|
+
spend_bundle_double = wallet_a.generate_signed_transaction(uint64(1001), receiver_puzzlehash, spend_coin)
|
|
125
|
+
|
|
126
|
+
block_spendbundle = SpendBundle.aggregate([spend_bundle, spend_bundle_double])
|
|
127
|
+
|
|
128
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
129
|
+
1,
|
|
130
|
+
block_list_input=blocks,
|
|
131
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
132
|
+
transaction_data=block_spendbundle,
|
|
133
|
+
guarantee_transaction_block=True,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
next_block = new_blocks[-1]
|
|
137
|
+
await _validate_and_add_block(full_node_1.blockchain, next_block, expected_error=Err.DOUBLE_SPEND)
|
|
138
|
+
|
|
139
|
+
@pytest.mark.anyio
|
|
140
|
+
async def test_validate_blockchain_duplicate_output(
|
|
141
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
142
|
+
) -> None:
|
|
143
|
+
num_blocks = 3
|
|
144
|
+
wallet_a = WALLET_A
|
|
145
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
146
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
147
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
148
|
+
full_node_1 = full_node_api_1.full_node
|
|
149
|
+
blocks = bt.get_consecutive_blocks(
|
|
150
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
for block in blocks:
|
|
154
|
+
await full_node_api_1.full_node.add_block(block)
|
|
155
|
+
|
|
156
|
+
spend_block = blocks[2]
|
|
157
|
+
|
|
158
|
+
spend_coin = None
|
|
159
|
+
for coin in spend_block.get_included_reward_coins():
|
|
160
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
161
|
+
spend_coin = coin
|
|
162
|
+
assert spend_coin is not None
|
|
163
|
+
|
|
164
|
+
spend_bundle = wallet_a.generate_signed_transaction(
|
|
165
|
+
uint64(1000), receiver_puzzlehash, spend_coin, additional_outputs=[(receiver_puzzlehash, 1000)]
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
169
|
+
1,
|
|
170
|
+
block_list_input=blocks,
|
|
171
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
172
|
+
transaction_data=spend_bundle,
|
|
173
|
+
guarantee_transaction_block=True,
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
next_block = new_blocks[-1]
|
|
177
|
+
await _validate_and_add_block(full_node_1.blockchain, next_block, expected_error=Err.DUPLICATE_OUTPUT)
|
|
178
|
+
|
|
179
|
+
@pytest.mark.anyio
|
|
180
|
+
async def test_validate_blockchain_with_reorg_double_spend(
|
|
181
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
182
|
+
) -> None:
|
|
183
|
+
num_blocks = 10
|
|
184
|
+
wallet_a = WALLET_A
|
|
185
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
186
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
187
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
188
|
+
blocks = bt.get_consecutive_blocks(
|
|
189
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
for block in blocks:
|
|
193
|
+
await full_node_api_1.full_node.add_block(block)
|
|
194
|
+
|
|
195
|
+
spend_block = blocks[2]
|
|
196
|
+
|
|
197
|
+
spend_coin = None
|
|
198
|
+
for coin in spend_block.get_included_reward_coins():
|
|
199
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
200
|
+
spend_coin = coin
|
|
201
|
+
assert spend_coin is not None
|
|
202
|
+
|
|
203
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_puzzlehash, spend_coin)
|
|
204
|
+
|
|
205
|
+
blocks_spend = bt.get_consecutive_blocks(
|
|
206
|
+
1,
|
|
207
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
208
|
+
guarantee_transaction_block=True,
|
|
209
|
+
transaction_data=spend_bundle,
|
|
210
|
+
)
|
|
211
|
+
# Move chain to height 10, with a spend at height 10
|
|
212
|
+
for block in blocks_spend:
|
|
213
|
+
await full_node_api_1.full_node.add_block(block)
|
|
214
|
+
|
|
215
|
+
# Reorg at height 5, add up to and including height 12
|
|
216
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
217
|
+
7,
|
|
218
|
+
blocks[:6],
|
|
219
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
220
|
+
guarantee_transaction_block=True,
|
|
221
|
+
seed=b"another seed",
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
for block in new_blocks:
|
|
225
|
+
await full_node_api_1.full_node.add_block(block)
|
|
226
|
+
|
|
227
|
+
# Spend the same coin in the new reorg chain at height 13
|
|
228
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
229
|
+
1,
|
|
230
|
+
new_blocks,
|
|
231
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
232
|
+
guarantee_transaction_block=True,
|
|
233
|
+
transaction_data=spend_bundle,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
await _validate_and_add_block(full_node_api_1.full_node.blockchain, new_blocks[-1])
|
|
237
|
+
|
|
238
|
+
# But can't spend it twice
|
|
239
|
+
new_blocks_double = bt.get_consecutive_blocks(
|
|
240
|
+
1,
|
|
241
|
+
new_blocks,
|
|
242
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
243
|
+
guarantee_transaction_block=True,
|
|
244
|
+
transaction_data=spend_bundle,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
await _validate_and_add_block(
|
|
248
|
+
full_node_api_1.full_node.blockchain, new_blocks_double[-1], expected_error=Err.DOUBLE_SPEND
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
# Now test Reorg at block 5, same spend at block height 12
|
|
252
|
+
new_blocks_reorg = bt.get_consecutive_blocks(
|
|
253
|
+
1,
|
|
254
|
+
new_blocks[:12],
|
|
255
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
256
|
+
guarantee_transaction_block=True,
|
|
257
|
+
transaction_data=spend_bundle,
|
|
258
|
+
seed=b"spend at 12 is ok",
|
|
259
|
+
)
|
|
260
|
+
for block in new_blocks_reorg:
|
|
261
|
+
await full_node_api_1.full_node.add_block(block)
|
|
262
|
+
|
|
263
|
+
# Spend at height 13 is also OK (same height)
|
|
264
|
+
new_blocks_reorg = bt.get_consecutive_blocks(
|
|
265
|
+
1,
|
|
266
|
+
new_blocks[:13],
|
|
267
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
268
|
+
guarantee_transaction_block=True,
|
|
269
|
+
transaction_data=spend_bundle,
|
|
270
|
+
seed=b"spend at 13 is ok",
|
|
271
|
+
)
|
|
272
|
+
for block in new_blocks_reorg:
|
|
273
|
+
await full_node_api_1.full_node.add_block(block)
|
|
274
|
+
|
|
275
|
+
# Spend at height 14 is not OK (already spend)
|
|
276
|
+
new_blocks_reorg = bt.get_consecutive_blocks(
|
|
277
|
+
1,
|
|
278
|
+
new_blocks[:14],
|
|
279
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
280
|
+
guarantee_transaction_block=True,
|
|
281
|
+
transaction_data=spend_bundle,
|
|
282
|
+
seed=b"spend at 14 is double spend",
|
|
283
|
+
)
|
|
284
|
+
with pytest.raises(ConsensusError):
|
|
285
|
+
for block in new_blocks_reorg:
|
|
286
|
+
await full_node_api_1.full_node.add_block(block)
|
|
287
|
+
|
|
288
|
+
@pytest.mark.anyio
|
|
289
|
+
async def test_validate_blockchain_spend_reorg_coin(
|
|
290
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools], softfork_height: uint32
|
|
291
|
+
) -> None:
|
|
292
|
+
num_blocks = 10
|
|
293
|
+
wallet_a = WALLET_A
|
|
294
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
295
|
+
receiver_1_puzzlehash = WALLET_A_PUZZLE_HASHES[1]
|
|
296
|
+
receiver_2_puzzlehash = WALLET_A_PUZZLE_HASHES[2]
|
|
297
|
+
receiver_3_puzzlehash = WALLET_A_PUZZLE_HASHES[3]
|
|
298
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
299
|
+
blocks = bt.get_consecutive_blocks(
|
|
300
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
for block in blocks:
|
|
304
|
+
await full_node_api_1.full_node.add_block(block)
|
|
305
|
+
|
|
306
|
+
spend_block = blocks[2]
|
|
307
|
+
|
|
308
|
+
spend_coin = None
|
|
309
|
+
for coin in spend_block.get_included_reward_coins():
|
|
310
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
311
|
+
spend_coin = coin
|
|
312
|
+
|
|
313
|
+
assert spend_coin
|
|
314
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_1_puzzlehash, spend_coin)
|
|
315
|
+
|
|
316
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
317
|
+
1,
|
|
318
|
+
blocks[:5],
|
|
319
|
+
seed=b"spend_reorg_coin",
|
|
320
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
321
|
+
transaction_data=spend_bundle,
|
|
322
|
+
guarantee_transaction_block=True,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
326
|
+
|
|
327
|
+
coin_2 = None
|
|
328
|
+
for coin in run_and_get_removals_and_additions(
|
|
329
|
+
new_blocks[-1],
|
|
330
|
+
test_constants.MAX_BLOCK_COST_CLVM,
|
|
331
|
+
height=softfork_height,
|
|
332
|
+
constants=bt.constants,
|
|
333
|
+
)[1]:
|
|
334
|
+
if coin.puzzle_hash == receiver_1_puzzlehash:
|
|
335
|
+
coin_2 = coin
|
|
336
|
+
break
|
|
337
|
+
assert coin_2 is not None
|
|
338
|
+
|
|
339
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_2_puzzlehash, coin_2)
|
|
340
|
+
|
|
341
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
342
|
+
1,
|
|
343
|
+
new_blocks[:6],
|
|
344
|
+
seed=b"spend_reorg_coin",
|
|
345
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
346
|
+
transaction_data=spend_bundle,
|
|
347
|
+
guarantee_transaction_block=True,
|
|
348
|
+
)
|
|
349
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
350
|
+
|
|
351
|
+
coin_3 = None
|
|
352
|
+
for coin in run_and_get_removals_and_additions(
|
|
353
|
+
new_blocks[-1],
|
|
354
|
+
test_constants.MAX_BLOCK_COST_CLVM,
|
|
355
|
+
height=softfork_height,
|
|
356
|
+
constants=bt.constants,
|
|
357
|
+
)[1]:
|
|
358
|
+
if coin.puzzle_hash == receiver_2_puzzlehash:
|
|
359
|
+
coin_3 = coin
|
|
360
|
+
break
|
|
361
|
+
assert coin_3 is not None
|
|
362
|
+
|
|
363
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_3_puzzlehash, coin_3)
|
|
364
|
+
|
|
365
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
366
|
+
1,
|
|
367
|
+
new_blocks[:7],
|
|
368
|
+
seed=b"spend_reorg_coin",
|
|
369
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
370
|
+
transaction_data=spend_bundle,
|
|
371
|
+
guarantee_transaction_block=True,
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
375
|
+
|
|
376
|
+
@pytest.mark.anyio
|
|
377
|
+
async def test_validate_blockchain_spend_reorg_cb_coin(
|
|
378
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
379
|
+
) -> None:
|
|
380
|
+
num_blocks = 15
|
|
381
|
+
wallet_a = WALLET_A
|
|
382
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
383
|
+
receiver_1_puzzlehash = WALLET_A_PUZZLE_HASHES[1]
|
|
384
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
385
|
+
blocks = bt.get_consecutive_blocks(num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash)
|
|
386
|
+
|
|
387
|
+
for block in blocks:
|
|
388
|
+
await full_node_api_1.full_node.add_block(block)
|
|
389
|
+
|
|
390
|
+
# Spends a coinbase created in reorg
|
|
391
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
392
|
+
5,
|
|
393
|
+
blocks[:6],
|
|
394
|
+
seed=b"reorg cb coin",
|
|
395
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
396
|
+
guarantee_transaction_block=True,
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
for block in new_blocks:
|
|
400
|
+
await full_node_api_1.full_node.add_block(block)
|
|
401
|
+
|
|
402
|
+
spend_block = new_blocks[-1]
|
|
403
|
+
spend_coin = None
|
|
404
|
+
for coin in spend_block.get_included_reward_coins():
|
|
405
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
406
|
+
spend_coin = coin
|
|
407
|
+
assert spend_coin is not None
|
|
408
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_1_puzzlehash, spend_coin)
|
|
409
|
+
|
|
410
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
411
|
+
1,
|
|
412
|
+
new_blocks,
|
|
413
|
+
seed=b"reorg cb coin",
|
|
414
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
415
|
+
transaction_data=spend_bundle,
|
|
416
|
+
guarantee_transaction_block=True,
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
420
|
+
|
|
421
|
+
@pytest.mark.anyio
|
|
422
|
+
async def test_validate_blockchain_spend_reorg_since_genesis(
|
|
423
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
424
|
+
) -> None:
|
|
425
|
+
num_blocks = 10
|
|
426
|
+
wallet_a = WALLET_A
|
|
427
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
428
|
+
receiver_1_puzzlehash = WALLET_A_PUZZLE_HASHES[1]
|
|
429
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
430
|
+
blocks = bt.get_consecutive_blocks(
|
|
431
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
for block in blocks:
|
|
435
|
+
await full_node_api_1.full_node.add_block(block)
|
|
436
|
+
|
|
437
|
+
spend_block = blocks[-1]
|
|
438
|
+
spend_coin = None
|
|
439
|
+
for coin in spend_block.get_included_reward_coins():
|
|
440
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
441
|
+
spend_coin = coin
|
|
442
|
+
assert spend_coin is not None
|
|
443
|
+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_1_puzzlehash, spend_coin)
|
|
444
|
+
|
|
445
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
446
|
+
1, blocks, seed=b"", farmer_reward_puzzle_hash=coinbase_puzzlehash, transaction_data=spend_bundle
|
|
447
|
+
)
|
|
448
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
449
|
+
|
|
450
|
+
# Spends a coin in a genesis reorg, that was already spent
|
|
451
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
452
|
+
12,
|
|
453
|
+
[],
|
|
454
|
+
seed=b"reorg since genesis",
|
|
455
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
456
|
+
guarantee_transaction_block=True,
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
for block in new_blocks:
|
|
460
|
+
await full_node_api_1.full_node.add_block(block)
|
|
461
|
+
|
|
462
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
463
|
+
1,
|
|
464
|
+
new_blocks,
|
|
465
|
+
seed=b"reorg since genesis",
|
|
466
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
467
|
+
transaction_data=spend_bundle,
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
await full_node_api_1.full_node.add_block(new_blocks[-1])
|
|
471
|
+
|
|
472
|
+
@pytest.mark.anyio
|
|
473
|
+
async def test_assert_my_coin_id(
|
|
474
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
475
|
+
) -> None:
|
|
476
|
+
num_blocks = 10
|
|
477
|
+
wallet_a = WALLET_A
|
|
478
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
479
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
480
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
481
|
+
full_node_1 = full_node_api_1.full_node
|
|
482
|
+
# Farm blocks
|
|
483
|
+
blocks = bt.get_consecutive_blocks(
|
|
484
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
485
|
+
)
|
|
486
|
+
|
|
487
|
+
for block in blocks:
|
|
488
|
+
await full_node_api_1.full_node.add_block(block)
|
|
489
|
+
|
|
490
|
+
# Coinbase that gets spent
|
|
491
|
+
|
|
492
|
+
spend_block = blocks[2]
|
|
493
|
+
bad_block = blocks[3]
|
|
494
|
+
spend_coin = None
|
|
495
|
+
bad_spend_coin = None
|
|
496
|
+
for coin in spend_block.get_included_reward_coins():
|
|
497
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
498
|
+
spend_coin = coin
|
|
499
|
+
assert spend_coin is not None
|
|
500
|
+
for coin in bad_block.get_included_reward_coins():
|
|
501
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
502
|
+
bad_spend_coin = coin
|
|
503
|
+
assert bad_spend_coin is not None
|
|
504
|
+
valid_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_COIN_ID, [spend_coin.name()])
|
|
505
|
+
valid_dic = {valid_cvp.opcode: [valid_cvp]}
|
|
506
|
+
bad_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_MY_COIN_ID, [bad_spend_coin.name()])
|
|
507
|
+
|
|
508
|
+
bad_dic = {bad_cvp.opcode: [bad_cvp]}
|
|
509
|
+
bad_spend_bundle = wallet_a.generate_signed_transaction(uint64(1000), receiver_puzzlehash, spend_coin, bad_dic)
|
|
510
|
+
|
|
511
|
+
valid_spend_bundle = wallet_a.generate_signed_transaction(
|
|
512
|
+
uint64(1000), receiver_puzzlehash, spend_coin, valid_dic
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
assert bad_spend_bundle is not None
|
|
516
|
+
assert valid_spend_bundle is not None
|
|
517
|
+
|
|
518
|
+
# Invalid block bundle
|
|
519
|
+
# Create another block that includes our transaction
|
|
520
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
521
|
+
1,
|
|
522
|
+
blocks,
|
|
523
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
524
|
+
transaction_data=bad_spend_bundle,
|
|
525
|
+
guarantee_transaction_block=True,
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
# Try to validate that block
|
|
529
|
+
await _validate_and_add_block(
|
|
530
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_MY_COIN_ID_FAILED
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
# Valid block bundle
|
|
534
|
+
# Create another block that includes our transaction
|
|
535
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
536
|
+
1,
|
|
537
|
+
blocks,
|
|
538
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
539
|
+
transaction_data=valid_spend_bundle,
|
|
540
|
+
guarantee_transaction_block=True,
|
|
541
|
+
)
|
|
542
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
543
|
+
|
|
544
|
+
@pytest.mark.anyio
|
|
545
|
+
async def test_assert_coin_announcement_consumed(
|
|
546
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
547
|
+
) -> None:
|
|
548
|
+
num_blocks = 10
|
|
549
|
+
wallet_a = WALLET_A
|
|
550
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
551
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
552
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
553
|
+
full_node_1 = full_node_api_1.full_node
|
|
554
|
+
# Farm blocks
|
|
555
|
+
blocks = bt.get_consecutive_blocks(
|
|
556
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
for block in blocks:
|
|
560
|
+
await full_node_api_1.full_node.add_block(block)
|
|
561
|
+
|
|
562
|
+
# Coinbase that gets spent
|
|
563
|
+
block1 = blocks[2]
|
|
564
|
+
block2 = blocks[3]
|
|
565
|
+
|
|
566
|
+
spend_coin_block_1 = None
|
|
567
|
+
spend_coin_block_2 = None
|
|
568
|
+
for coin in block1.get_included_reward_coins():
|
|
569
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
570
|
+
spend_coin_block_1 = coin
|
|
571
|
+
assert spend_coin_block_1 is not None
|
|
572
|
+
for coin in block2.get_included_reward_coins():
|
|
573
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
574
|
+
spend_coin_block_2 = coin
|
|
575
|
+
assert spend_coin_block_2 is not None
|
|
576
|
+
|
|
577
|
+
# This condition requires block2 coinbase to be spent
|
|
578
|
+
block1_cvp = ConditionWithArgs(
|
|
579
|
+
ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT,
|
|
580
|
+
[AssertCoinAnnouncement(asserted_id=spend_coin_block_2.name(), asserted_msg=b"test").msg_calc],
|
|
581
|
+
)
|
|
582
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
583
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
584
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
# This condition requires block1 coinbase to be spent
|
|
588
|
+
block2_cvp = ConditionWithArgs(
|
|
589
|
+
ConditionOpcode.CREATE_COIN_ANNOUNCEMENT,
|
|
590
|
+
[b"test"],
|
|
591
|
+
)
|
|
592
|
+
block2_dic = {block2_cvp.opcode: [block2_cvp]}
|
|
593
|
+
block2_spend_bundle = wallet_a.generate_signed_transaction(
|
|
594
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_2, block2_dic
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
# Invalid block bundle
|
|
598
|
+
assert block1_spend_bundle is not None
|
|
599
|
+
# Create another block that includes our transaction
|
|
600
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
601
|
+
1,
|
|
602
|
+
blocks,
|
|
603
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
604
|
+
transaction_data=block1_spend_bundle,
|
|
605
|
+
guarantee_transaction_block=True,
|
|
606
|
+
)
|
|
607
|
+
|
|
608
|
+
# Try to validate that block
|
|
609
|
+
await _validate_and_add_block(
|
|
610
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_ANNOUNCE_CONSUMED_FAILED
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
# bundle_together contains both transactions
|
|
614
|
+
bundle_together = SpendBundle.aggregate([block1_spend_bundle, block2_spend_bundle])
|
|
615
|
+
|
|
616
|
+
# Create another block that includes our transaction
|
|
617
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
618
|
+
1,
|
|
619
|
+
blocks,
|
|
620
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
621
|
+
transaction_data=bundle_together,
|
|
622
|
+
guarantee_transaction_block=True,
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
# Try to validate newly created block
|
|
626
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
627
|
+
|
|
628
|
+
@pytest.mark.anyio
|
|
629
|
+
async def test_assert_puzzle_announcement_consumed(
|
|
630
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
631
|
+
) -> None:
|
|
632
|
+
num_blocks = 10
|
|
633
|
+
wallet_a = WALLET_A
|
|
634
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
635
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
636
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
637
|
+
full_node_1 = full_node_api_1.full_node
|
|
638
|
+
# Farm blocks
|
|
639
|
+
blocks = bt.get_consecutive_blocks(
|
|
640
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
for block in blocks:
|
|
644
|
+
await full_node_api_1.full_node.add_block(block)
|
|
645
|
+
|
|
646
|
+
# Coinbase that gets spent
|
|
647
|
+
block1 = blocks[2]
|
|
648
|
+
block2 = blocks[3]
|
|
649
|
+
|
|
650
|
+
spend_coin_block_1 = None
|
|
651
|
+
spend_coin_block_2 = None
|
|
652
|
+
for coin in block1.get_included_reward_coins():
|
|
653
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
654
|
+
spend_coin_block_1 = coin
|
|
655
|
+
assert spend_coin_block_1 is not None
|
|
656
|
+
for coin in block2.get_included_reward_coins():
|
|
657
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
658
|
+
spend_coin_block_2 = coin
|
|
659
|
+
assert spend_coin_block_2 is not None
|
|
660
|
+
|
|
661
|
+
# This condition requires block2 coinbase to be spent
|
|
662
|
+
block1_cvp = ConditionWithArgs(
|
|
663
|
+
ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT,
|
|
664
|
+
[AssertPuzzleAnnouncement(asserted_ph=spend_coin_block_2.puzzle_hash, asserted_msg=b"test").msg_calc],
|
|
665
|
+
)
|
|
666
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
667
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
668
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
669
|
+
)
|
|
670
|
+
|
|
671
|
+
# This condition requires block1 coinbase to be spent
|
|
672
|
+
block2_cvp = ConditionWithArgs(
|
|
673
|
+
ConditionOpcode.CREATE_PUZZLE_ANNOUNCEMENT,
|
|
674
|
+
[b"test"],
|
|
675
|
+
)
|
|
676
|
+
block2_dic = {block2_cvp.opcode: [block2_cvp]}
|
|
677
|
+
block2_spend_bundle = wallet_a.generate_signed_transaction(
|
|
678
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_2, block2_dic
|
|
679
|
+
)
|
|
680
|
+
|
|
681
|
+
# Invalid block bundle
|
|
682
|
+
assert block1_spend_bundle is not None
|
|
683
|
+
# Create another block that includes our transaction
|
|
684
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
685
|
+
1,
|
|
686
|
+
blocks,
|
|
687
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
688
|
+
transaction_data=block1_spend_bundle,
|
|
689
|
+
guarantee_transaction_block=True,
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
# Try to validate that block
|
|
693
|
+
await _validate_and_add_block(
|
|
694
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_ANNOUNCE_CONSUMED_FAILED
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
# bundle_together contains both transactions
|
|
698
|
+
bundle_together = SpendBundle.aggregate([block1_spend_bundle, block2_spend_bundle])
|
|
699
|
+
|
|
700
|
+
# Create another block that includes our transaction
|
|
701
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
702
|
+
1,
|
|
703
|
+
blocks,
|
|
704
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
705
|
+
transaction_data=bundle_together,
|
|
706
|
+
guarantee_transaction_block=True,
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
# Try to validate newly created block
|
|
710
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
711
|
+
|
|
712
|
+
@pytest.mark.anyio
|
|
713
|
+
async def test_assert_height_absolute(
|
|
714
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
715
|
+
) -> None:
|
|
716
|
+
num_blocks = 10
|
|
717
|
+
wallet_a = WALLET_A
|
|
718
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
719
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
720
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
721
|
+
full_node_1 = full_node_api_1.full_node
|
|
722
|
+
# Farm blocks
|
|
723
|
+
blocks = bt.get_consecutive_blocks(
|
|
724
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
for block in blocks:
|
|
728
|
+
await full_node_api_1.full_node.add_block(block)
|
|
729
|
+
|
|
730
|
+
# Coinbase that gets spent
|
|
731
|
+
block1 = blocks[2]
|
|
732
|
+
spend_coin_block_1 = None
|
|
733
|
+
for coin in block1.get_included_reward_coins():
|
|
734
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
735
|
+
spend_coin_block_1 = coin
|
|
736
|
+
assert spend_coin_block_1 is not None
|
|
737
|
+
|
|
738
|
+
# This condition requires block1 coinbase to be spent after index 10
|
|
739
|
+
block1_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, [int_to_bytes(10)])
|
|
740
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
741
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
742
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
743
|
+
)
|
|
744
|
+
|
|
745
|
+
# program that will be sent too early
|
|
746
|
+
assert block1_spend_bundle is not None
|
|
747
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
748
|
+
1,
|
|
749
|
+
blocks,
|
|
750
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
751
|
+
transaction_data=block1_spend_bundle,
|
|
752
|
+
guarantee_transaction_block=True,
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
# Try to validate that block at index 10
|
|
756
|
+
await _validate_and_add_block(
|
|
757
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_HEIGHT_ABSOLUTE_FAILED
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
761
|
+
1,
|
|
762
|
+
blocks,
|
|
763
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
764
|
+
guarantee_transaction_block=True,
|
|
765
|
+
)
|
|
766
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
767
|
+
|
|
768
|
+
# At index 11, it can be spent
|
|
769
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
770
|
+
1,
|
|
771
|
+
new_blocks,
|
|
772
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
773
|
+
transaction_data=block1_spend_bundle,
|
|
774
|
+
guarantee_transaction_block=True,
|
|
775
|
+
)
|
|
776
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
777
|
+
|
|
778
|
+
@pytest.mark.anyio
|
|
779
|
+
async def test_assert_height_relative(
|
|
780
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
781
|
+
) -> None:
|
|
782
|
+
num_blocks = 11
|
|
783
|
+
wallet_a = WALLET_A
|
|
784
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
785
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
786
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
787
|
+
full_node_1 = full_node_api_1.full_node
|
|
788
|
+
# Farm blocks
|
|
789
|
+
blocks = bt.get_consecutive_blocks(
|
|
790
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
for block in blocks:
|
|
794
|
+
await full_node_api_1.full_node.add_block(block)
|
|
795
|
+
|
|
796
|
+
# Coinbase that gets spent
|
|
797
|
+
block1 = blocks[2]
|
|
798
|
+
spend_coin_block_1 = None
|
|
799
|
+
for coin in block1.get_included_reward_coins():
|
|
800
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
801
|
+
spend_coin_block_1 = coin
|
|
802
|
+
assert spend_coin_block_1 is not None
|
|
803
|
+
|
|
804
|
+
# This condition requires block1 coinbase to be spent after index 11
|
|
805
|
+
# This condition requires block1 coinbase to be spent more than 10 block after it was farmed
|
|
806
|
+
# block index has to be greater than (2 + 9 = 11)
|
|
807
|
+
block1_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, [int_to_bytes(9)])
|
|
808
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
809
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
810
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
# program that will be sent too early
|
|
814
|
+
assert block1_spend_bundle is not None
|
|
815
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
816
|
+
1,
|
|
817
|
+
blocks,
|
|
818
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
819
|
+
transaction_data=block1_spend_bundle,
|
|
820
|
+
guarantee_transaction_block=True,
|
|
821
|
+
)
|
|
822
|
+
|
|
823
|
+
# Try to validate that block at index 11
|
|
824
|
+
await _validate_and_add_block(
|
|
825
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_HEIGHT_RELATIVE_FAILED
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
829
|
+
1,
|
|
830
|
+
blocks,
|
|
831
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
832
|
+
guarantee_transaction_block=True,
|
|
833
|
+
)
|
|
834
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
835
|
+
|
|
836
|
+
# At index 12, it can be spent
|
|
837
|
+
new_blocks = bt.get_consecutive_blocks(
|
|
838
|
+
1,
|
|
839
|
+
new_blocks,
|
|
840
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
841
|
+
transaction_data=block1_spend_bundle,
|
|
842
|
+
guarantee_transaction_block=True,
|
|
843
|
+
)
|
|
844
|
+
await _validate_and_add_block(full_node_1.blockchain, new_blocks[-1])
|
|
845
|
+
|
|
846
|
+
@pytest.mark.anyio
|
|
847
|
+
async def test_assert_seconds_relative(
|
|
848
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
849
|
+
) -> None:
|
|
850
|
+
num_blocks = 10
|
|
851
|
+
wallet_a = WALLET_A
|
|
852
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
853
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
854
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
855
|
+
full_node_1 = full_node_api_1.full_node
|
|
856
|
+
# Farm blocks
|
|
857
|
+
blocks = bt.get_consecutive_blocks(
|
|
858
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
for block in blocks:
|
|
862
|
+
await full_node_api_1.full_node.add_block(block)
|
|
863
|
+
|
|
864
|
+
# Coinbase that gets spent
|
|
865
|
+
block1 = blocks[2]
|
|
866
|
+
spend_coin_block_1 = None
|
|
867
|
+
for coin in block1.get_included_reward_coins():
|
|
868
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
869
|
+
spend_coin_block_1 = coin
|
|
870
|
+
assert spend_coin_block_1 is not None
|
|
871
|
+
|
|
872
|
+
# This condition requires block1 coinbase to be spent 300 seconds after coin creation
|
|
873
|
+
block1_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_SECONDS_RELATIVE, [int_to_bytes(300)])
|
|
874
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
875
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
876
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
877
|
+
)
|
|
878
|
+
|
|
879
|
+
# program that will be sent to early
|
|
880
|
+
assert block1_spend_bundle is not None
|
|
881
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
882
|
+
1,
|
|
883
|
+
blocks,
|
|
884
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
885
|
+
transaction_data=block1_spend_bundle,
|
|
886
|
+
time_per_block=20,
|
|
887
|
+
guarantee_transaction_block=True,
|
|
888
|
+
)
|
|
889
|
+
|
|
890
|
+
# Try to validate that block before 300 sec
|
|
891
|
+
await _validate_and_add_block(
|
|
892
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_SECONDS_RELATIVE_FAILED
|
|
893
|
+
)
|
|
894
|
+
|
|
895
|
+
# we compare the timestamp against the previous transaction block, so in
|
|
896
|
+
# order to progress the timestamp, we need to farm one more block
|
|
897
|
+
blocks.extend(
|
|
898
|
+
bt.get_consecutive_blocks(
|
|
899
|
+
1,
|
|
900
|
+
blocks,
|
|
901
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
902
|
+
guarantee_transaction_block=True,
|
|
903
|
+
time_per_block=301,
|
|
904
|
+
)
|
|
905
|
+
)
|
|
906
|
+
await full_node_api_1.full_node.add_block(blocks[-1])
|
|
907
|
+
|
|
908
|
+
valid_new_blocks = bt.get_consecutive_blocks(
|
|
909
|
+
1,
|
|
910
|
+
blocks,
|
|
911
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
912
|
+
transaction_data=block1_spend_bundle,
|
|
913
|
+
guarantee_transaction_block=True,
|
|
914
|
+
time_per_block=301,
|
|
915
|
+
)
|
|
916
|
+
await _validate_and_add_block(full_node_1.blockchain, valid_new_blocks[-1])
|
|
917
|
+
|
|
918
|
+
@pytest.mark.anyio
|
|
919
|
+
async def test_assert_seconds_absolute(
|
|
920
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
921
|
+
) -> None:
|
|
922
|
+
num_blocks = 10
|
|
923
|
+
wallet_a = WALLET_A
|
|
924
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
925
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
926
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
927
|
+
full_node_1 = full_node_api_1.full_node
|
|
928
|
+
# Farm blocks
|
|
929
|
+
blocks = bt.get_consecutive_blocks(
|
|
930
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
931
|
+
)
|
|
932
|
+
|
|
933
|
+
for block in blocks:
|
|
934
|
+
await full_node_api_1.full_node.add_block(block)
|
|
935
|
+
|
|
936
|
+
# Coinbase that gets spent
|
|
937
|
+
block1 = blocks[2]
|
|
938
|
+
spend_coin_block_1 = None
|
|
939
|
+
for coin in block1.get_included_reward_coins():
|
|
940
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
941
|
+
spend_coin_block_1 = coin
|
|
942
|
+
assert spend_coin_block_1 is not None
|
|
943
|
+
|
|
944
|
+
# This condition requires block1 coinbase to be spent after 30 seconds from now
|
|
945
|
+
assert blocks[-1].foliage_transaction_block is not None
|
|
946
|
+
current_time_plus3 = uint64(blocks[-1].foliage_transaction_block.timestamp + 30)
|
|
947
|
+
block1_cvp = ConditionWithArgs(ConditionOpcode.ASSERT_SECONDS_ABSOLUTE, [int_to_bytes(current_time_plus3)])
|
|
948
|
+
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
|
949
|
+
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
|
950
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
# program that will be sent to early
|
|
954
|
+
assert block1_spend_bundle is not None
|
|
955
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
956
|
+
1,
|
|
957
|
+
blocks,
|
|
958
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
959
|
+
transaction_data=block1_spend_bundle,
|
|
960
|
+
time_per_block=20,
|
|
961
|
+
guarantee_transaction_block=True,
|
|
962
|
+
)
|
|
963
|
+
|
|
964
|
+
# Try to validate that block before 30 sec
|
|
965
|
+
await _validate_and_add_block(
|
|
966
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.ASSERT_SECONDS_ABSOLUTE_FAILED
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
# we compare the timestamp against the previous transaction block, so in
|
|
970
|
+
# order to progress the timestamp, we need to farm one more block
|
|
971
|
+
blocks.extend(
|
|
972
|
+
bt.get_consecutive_blocks(
|
|
973
|
+
1,
|
|
974
|
+
blocks,
|
|
975
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
976
|
+
guarantee_transaction_block=True,
|
|
977
|
+
time_per_block=30,
|
|
978
|
+
)
|
|
979
|
+
)
|
|
980
|
+
await full_node_api_1.full_node.add_block(blocks[-1])
|
|
981
|
+
|
|
982
|
+
valid_new_blocks = bt.get_consecutive_blocks(
|
|
983
|
+
1,
|
|
984
|
+
blocks,
|
|
985
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
986
|
+
transaction_data=block1_spend_bundle,
|
|
987
|
+
guarantee_transaction_block=True,
|
|
988
|
+
time_per_block=31,
|
|
989
|
+
)
|
|
990
|
+
await _validate_and_add_block(full_node_1.blockchain, valid_new_blocks[-1])
|
|
991
|
+
|
|
992
|
+
@pytest.mark.anyio
|
|
993
|
+
async def test_assert_fee_condition(
|
|
994
|
+
self, two_nodes: Tuple[FullNodeAPI, FullNodeAPI, ChiaServer, ChiaServer, BlockTools]
|
|
995
|
+
) -> None:
|
|
996
|
+
num_blocks = 10
|
|
997
|
+
wallet_a = WALLET_A
|
|
998
|
+
coinbase_puzzlehash = WALLET_A_PUZZLE_HASHES[0]
|
|
999
|
+
receiver_puzzlehash = BURN_PUZZLE_HASH
|
|
1000
|
+
full_node_api_1, _, _, _, bt = two_nodes
|
|
1001
|
+
full_node_1 = full_node_api_1.full_node
|
|
1002
|
+
# Farm blocks
|
|
1003
|
+
blocks = bt.get_consecutive_blocks(
|
|
1004
|
+
num_blocks, farmer_reward_puzzle_hash=coinbase_puzzlehash, guarantee_transaction_block=True
|
|
1005
|
+
)
|
|
1006
|
+
|
|
1007
|
+
for block in blocks:
|
|
1008
|
+
await full_node_api_1.full_node.add_block(block)
|
|
1009
|
+
|
|
1010
|
+
# Coinbase that gets spent
|
|
1011
|
+
block1 = blocks[2]
|
|
1012
|
+
spend_coin_block_1 = None
|
|
1013
|
+
for coin in block1.get_included_reward_coins():
|
|
1014
|
+
if coin.puzzle_hash == coinbase_puzzlehash:
|
|
1015
|
+
spend_coin_block_1 = coin
|
|
1016
|
+
assert spend_coin_block_1 is not None
|
|
1017
|
+
|
|
1018
|
+
# This condition requires fee to be 10 mojo
|
|
1019
|
+
cvp_fee = ConditionWithArgs(ConditionOpcode.RESERVE_FEE, [int_to_bytes(10)])
|
|
1020
|
+
# This spend bundle has 9 mojo as fee
|
|
1021
|
+
block1_dic_bad = {cvp_fee.opcode: [cvp_fee]}
|
|
1022
|
+
block1_dic_good = {cvp_fee.opcode: [cvp_fee]}
|
|
1023
|
+
block1_spend_bundle_bad = wallet_a.generate_signed_transaction(
|
|
1024
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic_bad, fee=9
|
|
1025
|
+
)
|
|
1026
|
+
block1_spend_bundle_good = wallet_a.generate_signed_transaction(
|
|
1027
|
+
uint64(1000), receiver_puzzlehash, spend_coin_block_1, block1_dic_good, fee=10
|
|
1028
|
+
)
|
|
1029
|
+
log.warning(block1_spend_bundle_good.additions())
|
|
1030
|
+
log.warning(f"Spend bundle fees: {estimate_fees(block1_spend_bundle_good)}")
|
|
1031
|
+
invalid_new_blocks = bt.get_consecutive_blocks(
|
|
1032
|
+
1,
|
|
1033
|
+
blocks,
|
|
1034
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
1035
|
+
transaction_data=block1_spend_bundle_bad,
|
|
1036
|
+
guarantee_transaction_block=True,
|
|
1037
|
+
)
|
|
1038
|
+
|
|
1039
|
+
await _validate_and_add_block(
|
|
1040
|
+
full_node_1.blockchain, invalid_new_blocks[-1], expected_error=Err.RESERVE_FEE_CONDITION_FAILED
|
|
1041
|
+
)
|
|
1042
|
+
|
|
1043
|
+
valid_new_blocks = bt.get_consecutive_blocks(
|
|
1044
|
+
1,
|
|
1045
|
+
blocks,
|
|
1046
|
+
farmer_reward_puzzle_hash=coinbase_puzzlehash,
|
|
1047
|
+
transaction_data=block1_spend_bundle_good,
|
|
1048
|
+
guarantee_transaction_block=True,
|
|
1049
|
+
)
|
|
1050
|
+
await _validate_and_add_block(full_node_1.blockchain, valid_new_blocks[-1])
|