From bfd5cdb8327a85431a503ad534b73f724d434a64 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 23 Nov 2021 23:40:49 -0500 Subject: [PATCH 1/7] add type: ignores for all the clvm stuff --- chia/clvm/spend_sim.py | 10 +- chia/full_node/full_node_api.py | 7 +- chia/full_node/generator.py | 9 +- chia/full_node/mempool_check_conditions.py | 5 +- chia/pools/pool_puzzles.py | 53 +++++++-- chia/pools/pool_wallet.py | 9 +- chia/rpc/full_node_rpc_api.py | 10 +- chia/types/blockchain_format/program.py | 19 ++- chia/types/blockchain_format/tree_hash.py | 4 +- chia/wallet/cc_wallet/cc_utils.py | 26 ++++- chia/wallet/cc_wallet/cc_wallet.py | 34 +++++- chia/wallet/did_wallet/did_wallet.py | 71 +++++++++--- .../puzzles/genesis_by_coin_id_with_0.py | 8 +- .../puzzles/genesis_by_puzzle_hash_with_0.py | 8 +- chia/wallet/puzzles/p2_conditions.py | 4 +- .../wallet/puzzles/p2_delegated_conditions.py | 4 +- chia/wallet/puzzles/p2_delegated_puzzle.py | 9 +- .../p2_delegated_puzzle_or_hidden_puzzle.py | 13 ++- .../puzzles/p2_m_of_n_delegate_direct.py | 4 +- chia/wallet/puzzles/p2_puzzle_hash.py | 4 +- .../wallet/puzzles/prefarm/make_prefarm_ph.py | 8 +- chia/wallet/puzzles/prefarm/spend_prefarm.py | 10 +- chia/wallet/puzzles/singleton_top_layer.py | 51 ++++++--- chia/wallet/puzzles/test_cc.py | 22 +++- chia/wallet/util/debug_spend_bundle.py | 15 ++- chia/wallet/util/trade_utils.py | 7 +- chia/wallet/wallet.py | 7 +- chia/wallet/wallet_node.py | 7 +- setup.py | 3 +- tests/clvm/test_puzzles.py | 10 +- tests/core/full_node/test_conditions.py | 9 +- tests/core/make_block_generator.py | 9 +- tests/generator/test_compression.py | 5 +- tests/generator/test_rom.py | 9 +- tests/pools/test_wallet_pool_store.py | 9 +- tests/util/benchmark_cost.py | 5 +- tests/wallet/test_singleton.py | 4 +- tests/wallet/test_singleton_lifecycle.py | 22 +++- tests/wallet/test_singleton_lifecycle_fast.py | 108 ++++++++++++++---- tests/wallet_tools.py | 14 ++- 40 files changed, 508 insertions(+), 137 deletions(-) diff --git a/chia/clvm/spend_sim.py b/chia/clvm/spend_sim.py index 776bf6bb35b3..7fd6174b4028 100644 --- a/chia/clvm/spend_sim.py +++ b/chia/clvm/spend_sim.py @@ -290,8 +290,14 @@ async def get_puzzle_and_solution(self, coin_id: bytes32, height: uint32) -> Opt if error: return None else: - puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) - solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected + # "Program" [arg-type] + puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) # type: ignore[arg-type] + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected + # "Program" [arg-type] + solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) # type: ignore[arg-type] # noqa E501 return CoinSpend(coin_record.coin, puzzle_ser, solution_ser) async def get_all_mempool_tx_ids(self) -> List[bytes32]: diff --git a/chia/full_node/full_node_api.py b/chia/full_node/full_node_api.py index 5512718cfc7b..73498542100a 100644 --- a/chia/full_node/full_node_api.py +++ b/chia/full_node/full_node_api.py @@ -1289,7 +1289,12 @@ async def request_puzzle_solution(self, request: wallet_protocol.RequestPuzzleSo pz = Program.to(puzzle) sol = Program.to(solution) - wrapper = PuzzleSolutionResponse(coin_name, height, pz, sol) + # TODO: address hint error and remove ignore + # error: Argument 3 to "PuzzleSolutionResponse" has incompatible type "SExp"; expected "Program" + # [arg-type] + # error: Argument 4 to "PuzzleSolutionResponse" has incompatible type "SExp"; expected "Program" + # [arg-type] + wrapper = PuzzleSolutionResponse(coin_name, height, pz, sol) # type: ignore[arg-type] response = wallet_protocol.RespondPuzzleSolution(wrapper) response_msg = make_msg(ProtocolMessageTypes.respond_puzzle_solution, response) return response_msg diff --git a/chia/full_node/generator.py b/chia/full_node/generator.py index 912f64e908eb..e66a131c977b 100644 --- a/chia/full_node/generator.py +++ b/chia/full_node/generator.py @@ -37,7 +37,9 @@ def create_generator_args(generator_ref_list: List[SerializedProgram]) -> Progra `create_generator_args`: The format and contents of these arguments affect consensus. """ gen_ref_list = [bytes(g) for g in generator_ref_list] - return Program.to([gen_ref_list]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([gen_ref_list]) # type: ignore[return-value] def create_compressed_generator( @@ -54,7 +56,10 @@ def create_compressed_generator( DECOMPRESS_PUZZLE, DECOMPRESS_CSE_WITH_PREFIX, Program.to(start), Program.to(end), compressed_cse_list ) generator_arg = GeneratorArg(original_generator.block_height, original_generator.generator) - return BlockGenerator(program, [generator_arg]) + # TODO: address hint error and remove ignore + # error: Argument 1 to "BlockGenerator" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return BlockGenerator(program, [generator_arg]) # type: ignore[arg-type] def setup_generator_args(self: BlockGenerator) -> Tuple[SerializedProgram, Program]: diff --git a/chia/full_node/mempool_check_conditions.py b/chia/full_node/mempool_check_conditions.py index a7c071e44ad7..e63960075294 100644 --- a/chia/full_node/mempool_check_conditions.py +++ b/chia/full_node/mempool_check_conditions.py @@ -123,7 +123,10 @@ def get_puzzle_and_solution_for_coin(generator: BlockGenerator, coin_name: bytes if not generator.generator_args: block_program_args = [NIL] else: - block_program_args = create_generator_args(generator.generator_refs()) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "Program", variable has type + # "List[Program]") [assignment] + block_program_args = create_generator_args(generator.generator_refs()) # type: ignore[assignment] cost, result = GENERATOR_FOR_SINGLE_COIN_MOD.run_with_cost( max_cost, block_program, block_program_args, coin_name diff --git a/chia/pools/pool_puzzles.py b/chia/pools/pool_puzzles.py index 0568e868d6f5..0113e5c74897 100644 --- a/chia/pools/pool_puzzles.py +++ b/chia/pools/pool_puzzles.py @@ -33,7 +33,9 @@ SINGLETON_LAUNCHER_HASH = SINGLETON_LAUNCHER.get_tree_hash() SINGLETON_MOD_HASH = POOL_OUTER_MOD_HASH -SINGLETON_MOD_HASH_HASH = Program.to(SINGLETON_MOD_HASH).get_tree_hash() +# TODO: address hint error and remove ignore +# error: "SExp" has no attribute "get_tree_hash" [attr-defined] +SINGLETON_MOD_HASH_HASH = Program.to(SINGLETON_MOD_HASH).get_tree_hash() # type: ignore[attr-defined] def create_waiting_room_inner_puzzle( @@ -170,20 +172,28 @@ def create_travel_spend( # inner sol is key_value_list () # key_value_list is: # "ps" -> poolstate as bytes - inner_sol: Program = Program.to([[("p", bytes(target))], 0]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + inner_sol: Program = Program.to([[("p", bytes(target))], 0]) # type: ignore[assignment] elif is_pool_waitingroom_inner_puzzle(inner_puzzle): # inner sol is (spend_type, key_value_list, pool_reward_height) destination_inner: Program = pool_state_to_inner_puzzle( target, launcher_coin.name(), genesis_challenge, delay_time, delay_ph ) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] log.debug( f"create_travel_spend: waitingroom: target PoolState bytes:\n{bytes(target).hex()}\n" f"{target}" - f"hash:{Program.to(bytes(target)).get_tree_hash()}" + f"hash:{Program.to(bytes(target)).get_tree_hash()}" # type: ignore[attr-defined] ) # key_value_list is: # "ps" -> poolstate as bytes - inner_sol = Program.to([1, [("p", bytes(target))], destination_inner.get_tree_hash()]) # current or target + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + inner_sol = Program.to([1, [("p", bytes(target))], destination_inner.get_tree_hash()]) # type: ignore[assignment] # noqa E501 # current or target else: raise ValueError @@ -203,7 +213,10 @@ def create_travel_spend( last_coin_spend.coin.amount, ] ) - full_solution: Program = Program.to([parent_info_list, current_singleton.amount, inner_sol]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + full_solution: Program = Program.to([parent_info_list, current_singleton.amount, inner_sol]) # type: ignore[assignment] # noqa E501 full_puzzle: Program = create_full_puzzle(inner_puzzle, launcher_coin.name()) return ( @@ -231,10 +244,16 @@ def create_absorb_spend( reward_amount: uint64 = calculate_pool_reward(height) if is_pool_member_inner_puzzle(inner_puzzle): # inner sol is (spend_type, pool_reward_amount, pool_reward_height, extra_data) - inner_sol: Program = Program.to([reward_amount, height]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + inner_sol: Program = Program.to([reward_amount, height]) # type: ignore[assignment] elif is_pool_waitingroom_inner_puzzle(inner_puzzle): # inner sol is (spend_type, destination_puzhash, pool_reward_amount, pool_reward_height, extra_data) - inner_sol = Program.to([0, reward_amount, height]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + inner_sol = Program.to([0, reward_amount, height]) # type: ignore[assignment] else: raise ValueError # full sol = (parent_info, my_amount, inner_solution) @@ -242,20 +261,29 @@ def create_absorb_spend( assert coin is not None if coin.parent_coin_info == launcher_coin.name(): - parent_info: Program = Program.to([launcher_coin.parent_coin_info, launcher_coin.amount]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + parent_info: Program = Program.to([launcher_coin.parent_coin_info, launcher_coin.amount]) # type: ignore[assignment] # noqa E501 else: p = Program.from_bytes(bytes(last_coin_spend.puzzle_reveal)) last_coin_spend_inner_puzzle: Optional[Program] = get_inner_puzzle_from_puzzle(p) assert last_coin_spend_inner_puzzle is not None - parent_info = Program.to( + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + parent_info = Program.to( # type: ignore[assignment] [ last_coin_spend.coin.parent_coin_info, last_coin_spend_inner_puzzle.get_tree_hash(), last_coin_spend.coin.amount, ] ) + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" + # [arg-type] full_solution: SerializedProgram = SerializedProgram.from_program( - Program.to([parent_info, last_coin_spend.coin.amount, inner_sol]) + Program.to([parent_info, last_coin_spend.coin.amount, inner_sol]) # type: ignore[arg-type] ) full_puzzle: SerializedProgram = SerializedProgram.from_program( create_full_puzzle(inner_puzzle, launcher_coin.name()) @@ -267,8 +295,11 @@ def create_absorb_spend( create_p2_singleton_puzzle(SINGLETON_MOD_HASH, launcher_coin.name(), delay_time, delay_ph) ) reward_coin: Coin = Coin(reward_parent, p2_singleton_puzzle.get_tree_hash(), reward_amount) + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" + # [arg-type] p2_singleton_solution: SerializedProgram = SerializedProgram.from_program( - Program.to([inner_puzzle.get_tree_hash(), reward_coin.name()]) + Program.to([inner_puzzle.get_tree_hash(), reward_coin.name()]) # type: ignore[arg-type] ) assert p2_singleton_puzzle.get_tree_hash() == reward_coin.puzzle_hash assert full_puzzle.get_tree_hash() == coin.puzzle_hash diff --git a/chia/pools/pool_wallet.py b/chia/pools/pool_wallet.py index 918b2db888df..5724642ec190 100644 --- a/chia/pools/pool_wallet.py +++ b/chia/pools/pool_wallet.py @@ -628,7 +628,9 @@ async def generate_launcher_spend( puzzle_hash: bytes32 = full_pooling_puzzle.get_tree_hash() pool_state_bytes = Program.to([("p", bytes(initial_target_state)), ("t", delay_time), ("h", delay_ph)]) announcement_set: Set[bytes32] = set() - announcement_message = Program.to([puzzle_hash, amount, pool_state_bytes]).get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + announcement_message = Program.to([puzzle_hash, amount, pool_state_bytes]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 announcement_set.add(Announcement(launcher_coin.name(), announcement_message).name()) create_launcher_tx_record: Optional[TransactionRecord] = await standard_wallet.generate_signed_transaction( @@ -643,7 +645,10 @@ async def generate_launcher_spend( ) assert create_launcher_tx_record is not None and create_launcher_tx_record.spend_bundle is not None - genesis_launcher_solution: Program = Program.to([puzzle_hash, amount, pool_state_bytes]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + genesis_launcher_solution: Program = Program.to([puzzle_hash, amount, pool_state_bytes]) # type: ignore[assignment] # noqa E501 launcher_cs: CoinSpend = CoinSpend( launcher_coin, diff --git a/chia/rpc/full_node_rpc_api.py b/chia/rpc/full_node_rpc_api.py index 4c71cfb41141..d2e44cfbd474 100644 --- a/chia/rpc/full_node_rpc_api.py +++ b/chia/rpc/full_node_rpc_api.py @@ -559,8 +559,14 @@ async def get_puzzle_and_solution(self, request: Dict) -> Optional[Dict]: if error is not None: raise ValueError(f"Error: {error}") - puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) - solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected + # "Program" [arg-type] + puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) # type: ignore[arg-type] + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected + # "Program" [arg-type] + solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) # type: ignore[arg-type] return {"coin_solution": CoinSpend(coin_record.coin, puzzle_ser, solution_ser)} async def get_additions_and_removals(self, request: Dict) -> Optional[Dict]: diff --git a/chia/types/blockchain_format/program.py b/chia/types/blockchain_format/program.py index f81c03445fe3..cc3546e5515e 100644 --- a/chia/types/blockchain_format/program.py +++ b/chia/types/blockchain_format/program.py @@ -103,7 +103,10 @@ def get_tree_hash(self, *args: bytes32) -> bytes32: def run_with_cost(self, max_cost: int, args) -> Tuple[int, "Program"]: prog_args = Program.to(args) cost, r = run_program(self, prog_args, max_cost) - return cost, Program.to(r) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[Any, SExp]", expected "Tuple[int, Program]") + # [return-value] + return cost, Program.to(r) # type: ignore[return-value] def run(self, args) -> "Program": cost, r = self.run_with_cost(INFINITE_COST, args) @@ -111,12 +114,17 @@ def run(self, args) -> "Program": def curry(self, *args) -> "Program": cost, r = curry(self, list(args)) - return Program.to(r) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(r) # type: ignore[return-value] def uncurry(self) -> Tuple["Program", "Program"]: r = uncurry(self) if r is None: - return self, self.to(0) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[Program, SExp]", expected + # "Tuple[Program, Program]") [return-value] + return self, self.to(0) # type: ignore[return-value] return r def as_int(self) -> int: @@ -296,7 +304,10 @@ def _run(self, max_cost: int, flags, *args) -> Tuple[int, Program]: max_cost, flags, ) - return cost, Program.to(ret) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[Any, SExp]", expected "Tuple[int, Program]") + # [return-value] + return cost, Program.to(ret) # type: ignore[return-value] NIL = Program.from_bytes(b"\x80") diff --git a/chia/types/blockchain_format/tree_hash.py b/chia/types/blockchain_format/tree_hash.py index 5bd03db8b511..933ccd8a08cd 100644 --- a/chia/types/blockchain_format/tree_hash.py +++ b/chia/types/blockchain_format/tree_hash.py @@ -14,7 +14,9 @@ from chia.util.hash import std_hash -def sha256_treehash(sexp: CLVMObject, precalculated: Optional[Set[bytes32]] = None) -> bytes32: +# TODO: address hint error and remove ignore +# error: Module "clvm.CLVMObject" is not valid as a type [valid-type] +def sha256_treehash(sexp: CLVMObject, precalculated: Optional[Set[bytes32]] = None) -> bytes32: # type: ignore[valid-type] # noqa E501 """ Hash values in `precalculated` are presumed to have been hashed already. """ diff --git a/chia/wallet/cc_wallet/cc_utils.py b/chia/wallet/cc_wallet/cc_utils.py index b403ea55059e..b2b0c9fe5bde 100644 --- a/chia/wallet/cc_wallet/cc_utils.py +++ b/chia/wallet/cc_wallet/cc_utils.py @@ -54,7 +54,9 @@ def cc_puzzle_hash_for_inner_puzzle_hash(mod_code, genesis_coin_checker, inner_p def lineage_proof_for_cc_parent(parent_coin: Coin, parent_inner_puzzle_hash: bytes32) -> Program: - return Program.to( + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to( # type: ignore[return-value] ( 1, [parent_coin.parent_coin_info, parent_inner_puzzle_hash, parent_coin.amount], @@ -88,13 +90,18 @@ def coin_spend_for_lock_coin( ) -> CoinSpend: puzzle_reveal = LOCK_INNER_PUZZLE.curry(prev_coin.as_list(), subtotal) coin = Coin(coin.name(), puzzle_reveal.get_tree_hash(), uint64(0)) - coin_spend = CoinSpend(coin, puzzle_reveal, Program.to(0)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, Program.to(0)) # type: ignore[arg-type] return coin_spend def bundle_for_spendable_cc_list(spendable_cc: SpendableCC) -> Program: pair = (spendable_cc.coin.as_list(), spendable_cc.lineage_proof) - return Program.to(pair) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(pair) # type: ignore[return-value] def spend_bundle_for_spendable_ccs( @@ -120,8 +127,13 @@ def spend_bundle_for_spendable_ccs( # figure out what the output amounts are by running the inner puzzles & solutions output_amounts = [] for cc_spend_info, inner_solution in zip(spendable_cc_list, inner_solutions): + # TODO: address hint error and remove ignore + # error: Argument 1 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + # error: Argument 2 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] error, conditions, cost = conditions_dict_for_solution( - cc_spend_info.inner_puzzle, inner_solution, INFINITE_COST + cc_spend_info.inner_puzzle, inner_solution, INFINITE_COST # type: ignore[arg-type] ) total = 0 if conditions: @@ -157,7 +169,11 @@ def spend_bundle_for_spendable_ccs( next_bundle, subtotals[index], ] - coin_spend = CoinSpend(input_coins[index], puzzle_reveal, Program.to(solution)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(input_coins[index], puzzle_reveal, Program.to(solution)) # type: ignore[arg-type] coin_spends.append(coin_spend) if sigs is None or sigs == []: diff --git a/chia/wallet/cc_wallet/cc_wallet.py b/chia/wallet/cc_wallet/cc_wallet.py index 3487f232a184..e08877edb44a 100644 --- a/chia/wallet/cc_wallet/cc_wallet.py +++ b/chia/wallet/cc_wallet/cc_wallet.py @@ -297,7 +297,10 @@ async def coin_added(self, coin: Coin, height: uint32): inner_puzzle = await self.inner_puzzle_for_cc_puzhash(coin.puzzle_hash) lineage_proof = Program.to((1, [coin.parent_coin_info, inner_puzzle.get_tree_hash(), coin.amount])) - await self.add_lineage(coin.name(), lineage_proof, True) + # TODO: address hint error and remove ignore + # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected + # "Optional[Program]" [arg-type] + await self.add_lineage(coin.name(), lineage_proof, True) # type: ignore[arg-type] for name, lineage_proofs in self.cc_info.lineage_proofs: if coin.parent_coin_info == name: @@ -406,14 +409,20 @@ async def generate_zero_val_coin(self, send=True, exclude: List[Coin] = None) -> await self.add_lineage( eve_coin.name(), - Program.to( + # TODO: address hint error and remove ignore + # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected + # "Optional[Program]" [arg-type] + Program.to( # type: ignore[arg-type] ( 1, [eve_coin.parent_coin_info, cc_inner, eve_coin.amount], ) ), ) - await self.add_lineage(eve_coin.parent_coin_info, Program.to((0, [origin.as_list(), 1]))) + # TODO: address hint error and remove ignore + # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected + # "Optional[Program]" [arg-type] + await self.add_lineage(eve_coin.parent_coin_info, Program.to((0, [origin.as_list(), 1]))) # type: ignore[arg-type] # noqa E501 if send: regular_record = TransactionRecord( @@ -552,8 +561,13 @@ async def get_sigs(self, innerpuz: Program, innersol: Program, coin_name: bytes3 pubkey, private = await self.wallet_state_manager.get_keys(puzzle_hash) synthetic_secret_key = calculate_synthetic_secret_key(private, DEFAULT_HIDDEN_PUZZLE_HASH) sigs: List[G2Element] = [] + # TODO: address hint error and remove ignore + # error: Argument 1 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + # error: Argument 2 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] error, conditions, cost = conditions_dict_for_solution( - innerpuz, innersol, self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM + innerpuz, innersol, self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM # type: ignore[arg-type] ) if conditions is not None: for _, msg in pkm_pairs_for_conditions_dict( @@ -685,7 +699,10 @@ async def generate_new_coloured_coin(self, amount: uint64) -> SpendBundle: origin_id = origin.name() cc_inner_hash = await self.get_new_inner_hash() - await self.add_lineage(origin_id, Program.to((0, [origin.as_list(), 0]))) + # TODO: address hint error and remove ignore + # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected + # "Optional[Program]" [arg-type] + await self.add_lineage(origin_id, Program.to((0, [origin.as_list(), 0]))) # type: ignore[arg-type] genesis_coin_checker = create_genesis_or_zero_coin_checker(origin_id) minted_cc_puzzle_hash = cc_puzzle_hash_for_inner_puzzle_hash(CC_MOD, genesis_coin_checker, cc_inner_hash) @@ -747,7 +764,12 @@ async def create_spend_bundle_relative_amount(self, cc_amount, zero_coin: Coin = None, None, ] - list_of_solutions.append(CoinSpend(coin, puzzle_reveal, Program.to(solution))) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" + # [arg-type] + list_of_solutions.append(CoinSpend(coin, puzzle_reveal, Program.to(solution))) # type: ignore[arg-type] aggsig = AugSchemeMPL.aggregate(sigs) return SpendBundle(list_of_solutions, aggsig) diff --git a/chia/wallet/did_wallet/did_wallet.py b/chia/wallet/did_wallet/did_wallet.py index f6f207a4fc2a..fb6d687474e7 100644 --- a/chia/wallet/did_wallet/did_wallet.py +++ b/chia/wallet/did_wallet/did_wallet.py @@ -522,7 +522,10 @@ async def create_message_spend(self, messages: List[Tuple[int, bytes]], new_inne if new_innerpuzhash is None: new_innerpuzhash = innerpuz.get_tree_hash() # innerpuz solution is (mode amount messages new_puz) - innersol: Program = Program.to([1, coin.amount, messages, new_innerpuzhash]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + innersol: Program = Program.to([1, coin.amount, messages, new_innerpuzhash]) # type: ignore[assignment] # full solution is (corehash parent_info my_amount innerpuz_reveal solution) full_puzzle: Program = did_wallet_puzzles.create_fullpuz( @@ -542,11 +545,17 @@ async def create_message_spend(self, messages: List[Tuple[int, bytes]], new_inne innersol, ] ) - list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME # new_inner_puzhash amount message + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([new_innerpuzhash, coin.amount, messages]).get_tree_hash() + Program.to([new_innerpuzhash, coin.amount, messages]).get_tree_hash() # type: ignore[attr-defined] + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) @@ -588,7 +597,10 @@ async def create_exit_spend(self, puzhash: bytes32): coin = coins.pop() amount = coin.amount - 1 # innerpuz solution is (mode amount new_puzhash) - innersol: Program = Program.to([0, amount, puzhash]) + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + innersol: Program = Program.to([0, amount, puzhash]) # type: ignore[assignment] # full solution is (corehash parent_info my_amount innerpuz_reveal solution) innerpuz: Program = self.did_info.current_inner @@ -609,10 +621,16 @@ async def create_exit_spend(self, puzhash: bytes32): innersol, ] ) - list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([amount, puzhash]).get_tree_hash() + Program.to([amount, puzhash]).get_tree_hash() # type: ignore[attr-defined] + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) @@ -681,11 +699,17 @@ async def create_attestment( innersol, ] ) - list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] message_spend = did_wallet_puzzles.create_spend_for_message(coin.name(), recovering_coin_name, newpuz, pubkey) message_spend_bundle = SpendBundle([message_spend], AugSchemeMPL.aggregate([])) # sign for AGG_SIG_ME - to_sign = Program.to([innerpuz.get_tree_hash(), coin.amount, messages]).get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + to_sign = Program.to([innerpuz.get_tree_hash(), coin.amount, messages]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 message = to_sign + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA pubkey = did_wallet_puzzles.get_pubkey_from_innerpuz(innerpuz) index = await self.wallet_state_manager.puzzle_store.index_for_pubkey(pubkey) @@ -785,7 +809,10 @@ async def recovery_spend( assert self.did_info.origin_coin is not None # innersol is mode new_amount message new_inner_puzhash parent_innerpuzhash_amounts_for_recovery_ids pubkey recovery_list_reveal) # noqa - innersol: Program = Program.to( + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") + # [assignment] + innersol: Program = Program.to( # type: ignore[assignment] [ 2, coin.amount, @@ -816,7 +843,11 @@ async def recovery_spend( innersol, ] ) - list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] index = await self.wallet_state_manager.puzzle_store.index_for_pubkey(pubkey) if index is None: @@ -926,7 +957,9 @@ async def generate_new_decentralised_id(self, amount: uint64) -> Optional[SpendB did_puzzle_hash = did_full_puz.get_tree_hash() announcement_set: Set[bytes32] = set() - announcement_message = Program.to([did_puzzle_hash, amount, bytes(0x80)]).get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + announcement_message = Program.to([did_puzzle_hash, amount, bytes(0x80)]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 announcement_set.add(Announcement(launcher_coin.name(), announcement_message).name()) tx_record: Optional[TransactionRecord] = await self.standard_wallet.generate_signed_transaction( @@ -935,7 +968,11 @@ async def generate_new_decentralised_id(self, amount: uint64) -> Optional[SpendB genesis_launcher_solution = Program.to([did_puzzle_hash, amount, bytes(0x80)]) - launcher_cs = CoinSpend(launcher_coin, genesis_launcher_puz, genesis_launcher_solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + launcher_cs = CoinSpend(launcher_coin, genesis_launcher_puz, genesis_launcher_solution) # type: ignore[arg-type] # noqa E501 launcher_sb = SpendBundle([launcher_cs], AugSchemeMPL.aggregate([])) eve_coin = Coin(launcher_coin.name(), did_puzzle_hash, amount) future_parent = LineageProof( @@ -983,10 +1020,16 @@ async def generate_eve_spend(self, coin: Coin, full_puzzle: Program, innerpuz: P innersol, ] ) - list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([innerpuz.get_tree_hash(), coin.amount, []]).get_tree_hash() + Program.to([innerpuz.get_tree_hash(), coin.amount, []]).get_tree_hash() # type: ignore[attr-defined] + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) diff --git a/chia/wallet/puzzles/genesis_by_coin_id_with_0.py b/chia/wallet/puzzles/genesis_by_coin_id_with_0.py index 3b473d64cca6..e375c9e547ee 100644 --- a/chia/wallet/puzzles/genesis_by_coin_id_with_0.py +++ b/chia/wallet/puzzles/genesis_by_coin_id_with_0.py @@ -33,11 +33,15 @@ def genesis_coin_id_for_genesis_coin_checker( def lineage_proof_for_genesis(parent_coin: Coin) -> Program: - return Program.to((0, [parent_coin.as_list(), 0])) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to((0, [parent_coin.as_list(), 0])) # type: ignore[return-value] def lineage_proof_for_zero(parent_coin: Coin) -> Program: - return Program.to((0, [parent_coin.as_list(), 1])) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to((0, [parent_coin.as_list(), 1])) # type: ignore[return-value] def lineage_proof_for_coin(parent_coin: Coin) -> Program: diff --git a/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py b/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py index 53829902421b..f58620833e78 100644 --- a/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py +++ b/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py @@ -33,11 +33,15 @@ def genesis_puzzle_hash_for_genesis_coin_checker( def lineage_proof_for_genesis_puzzle(parent_coin: Coin) -> Program: - return Program.to((0, [parent_coin.as_list(), 0])) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to((0, [parent_coin.as_list(), 0])) # type: ignore[return-value] def lineage_proof_for_zero(parent_coin: Coin) -> Program: - return Program.to((0, [parent_coin.as_list(), 1])) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to((0, [parent_coin.as_list(), 1])) # type: ignore[return-value] def lineage_proof_for_coin(parent_coin: Coin) -> Program: diff --git a/chia/wallet/puzzles/p2_conditions.py b/chia/wallet/puzzles/p2_conditions.py index f43bdecd9dea..5bf6fefb4d7b 100644 --- a/chia/wallet/puzzles/p2_conditions.py +++ b/chia/wallet/puzzles/p2_conditions.py @@ -22,4 +22,6 @@ def puzzle_for_conditions(conditions) -> Program: def solution_for_conditions(conditions) -> Program: - return Program.to([puzzle_for_conditions(conditions), 0]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([puzzle_for_conditions(conditions), 0]) # type: ignore[return-value] diff --git a/chia/wallet/puzzles/p2_delegated_conditions.py b/chia/wallet/puzzles/p2_delegated_conditions.py index f17522b1709f..5d45fda67f26 100644 --- a/chia/wallet/puzzles/p2_delegated_conditions.py +++ b/chia/wallet/puzzles/p2_delegated_conditions.py @@ -18,4 +18,6 @@ def puzzle_for_pk(public_key: Program) -> Program: def solution_for_conditions(conditions: Program) -> Program: - return conditions.to([conditions]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return conditions.to([conditions]) # type: ignore[return-value] diff --git a/chia/wallet/puzzles/p2_delegated_puzzle.py b/chia/wallet/puzzles/p2_delegated_puzzle.py index a1bb20a50cb9..abebd8df58b1 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle.py @@ -26,8 +26,13 @@ def puzzle_for_pk(public_key: bytes) -> Program: def solution_for_conditions(conditions) -> Program: delegated_puzzle = p2_conditions.puzzle_for_conditions(conditions) - return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "solution_for_delegated_puzzle" has incompatible type "SExp"; expected "Program" + # [arg-type] + return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) # type: ignore[arg-type] def solution_for_delegated_puzzle(delegated_puzzle: Program, delegated_solution: Program) -> Program: - return delegated_puzzle.to([delegated_puzzle, delegated_solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return delegated_puzzle.to([delegated_puzzle, delegated_solution]) # type: ignore[return-value] diff --git a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py index 1308234c24e0..077375705cbc 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py @@ -79,7 +79,9 @@ def puzzle_for_pk(public_key: G1Element) -> Program: def solution_for_delegated_puzzle(delegated_puzzle: Program, solution: Program) -> Program: - return Program.to([[], delegated_puzzle, solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([[], delegated_puzzle, solution]) # type: ignore[return-value] def solution_for_hidden_puzzle( @@ -87,9 +89,14 @@ def solution_for_hidden_puzzle( hidden_puzzle: Program, solution_to_hidden_puzzle: Program, ) -> Program: - return Program.to([hidden_public_key, hidden_puzzle, solution_to_hidden_puzzle]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([hidden_public_key, hidden_puzzle, solution_to_hidden_puzzle]) # type: ignore[return-value] def solution_for_conditions(conditions) -> Program: delegated_puzzle = puzzle_for_conditions(conditions) - return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "solution_for_delegated_puzzle" has incompatible type "SExp"; expected "Program" + # [arg-type] + return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) # type: ignore[arg-type] diff --git a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py index 6d8f18aec750..3df94bc3b0a9 100644 --- a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +++ b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py @@ -17,4 +17,6 @@ def puzzle_for_m_of_public_key_list(m, public_key_list) -> Program: def solution_for_delegated_puzzle(m, selectors, puzzle, solution) -> Program: - return Program.to([selectors, puzzle, solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([selectors, puzzle, solution]) # type: ignore[return-value] diff --git a/chia/wallet/puzzles/p2_puzzle_hash.py b/chia/wallet/puzzles/p2_puzzle_hash.py index fcb0de2c1654..2f529fd3b8d1 100644 --- a/chia/wallet/puzzles/p2_puzzle_hash.py +++ b/chia/wallet/puzzles/p2_puzzle_hash.py @@ -23,4 +23,6 @@ def puzzle_for_inner_puzzle(inner_puzzle: Program) -> Program: def solution_for_inner_puzzle_and_inner_solution(inner_puzzle: Program, inner_puzzle_solution: Program) -> Program: - return Program.to([inner_puzzle, inner_puzzle_solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([inner_puzzle, inner_puzzle_solution]) # type: ignore[return-value] diff --git a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py index a611c37623e0..38ac74a49177 100644 --- a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py +++ b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py @@ -27,14 +27,18 @@ def make_puzzle(amount: int) -> int: puzzle_prog = Program.to(binutils.assemble(puzzle)) print("Program: ", puzzle_prog) - puzzle_hash = puzzle_prog.get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + puzzle_hash = puzzle_prog.get_tree_hash() # type: ignore[attr-defined] solution = "()" prefix = "xch" print("PH", puzzle_hash) print(f"Address: {encode_puzzle_hash(puzzle_hash, prefix)}") - result = puzzle_prog.run(solution) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "run" [attr-defined] + result = puzzle_prog.run(solution) # type: ignore[attr-defined] error, result_human = parse_sexp_to_conditions(result) total_chia = 0 diff --git a/chia/wallet/puzzles/prefarm/spend_prefarm.py b/chia/wallet/puzzles/prefarm/spend_prefarm.py index 06037659201b..0c03163b02d8 100644 --- a/chia/wallet/puzzles/prefarm/spend_prefarm.py +++ b/chia/wallet/puzzles/prefarm/spend_prefarm.py @@ -63,8 +63,14 @@ async def main() -> None: p_solution = Program.to(binutils.assemble("()")) - sb_farmer = SpendBundle([CoinSpend(farmer_prefarm, p_farmer_2, p_solution)], G2Element()) - sb_pool = SpendBundle([CoinSpend(pool_prefarm, p_pool_2, p_solution)], G2Element()) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + sb_farmer = SpendBundle([CoinSpend(farmer_prefarm, p_farmer_2, p_solution)], G2Element()) # type: ignore[arg-type] # noqa E501 + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + sb_pool = SpendBundle([CoinSpend(pool_prefarm, p_pool_2, p_solution)], G2Element()) # type: ignore[arg-type] print("\n\n\nConditions") print_conditions(sb_pool) diff --git a/chia/wallet/puzzles/singleton_top_layer.py b/chia/wallet/puzzles/singleton_top_layer.py index 3cb0effe55e0..203c179d8635 100644 --- a/chia/wallet/puzzles/singleton_top_layer.py +++ b/chia/wallet/puzzles/singleton_top_layer.py @@ -28,7 +28,9 @@ def generate_launcher_coin(coin: Coin, amount: uint64) -> Coin: # Wrap inner puzzles that are not singleton specific to strip away "truths" def adapt_inner_to_singleton(inner_puzzle: Program) -> Program: # (a (q . inner_puzzle) (r 1)) - return Program.to([2, (1, inner_puzzle), [6, 1]]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([2, (1, inner_puzzle), [6, 1]]) # type: ignore[return-value] # Take standard coin and amount -> launch conditions & launcher coin solution @@ -61,22 +63,30 @@ def launch_conditions_and_coinsol( amount, ], ) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] assert_launcher_announcement = Program.to( [ ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, - std_hash(launcher_coin.name() + launcher_solution.get_tree_hash()), + std_hash(launcher_coin.name() + launcher_solution.get_tree_hash()), # type: ignore[attr-defined] ], ) conditions = [create_launcher, assert_launcher_announcement] + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] launcher_coin_spend = CoinSpend( launcher_coin, - SINGLETON_LAUNCHER, - launcher_solution, + SINGLETON_LAUNCHER, # type: ignore[arg-type] + launcher_solution, # type: ignore[arg-type] ) - return conditions, launcher_coin_spend + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[List[SExp], CoinSpend]", expected + # "Tuple[List[Program], CoinSpend]") [return-value] + return conditions, launcher_coin_spend # type: ignore[return-value] # Take a coin solution, return a lineage proof for their child to use in spends @@ -127,7 +137,9 @@ def solution_for_singleton( lineage_proof.amount, ] - return Program.to([parent_info, amount, inner_solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([parent_info, amount, inner_solution]) # type: ignore[return-value] # Create a coin that a singleton can claim @@ -148,12 +160,16 @@ def pay_to_singleton_or_delay_puzzle(launcher_id: bytes32, delay_time: uint64, d # Solution for EITHER p2_singleton or the claiming spend case for p2_singleton_or_delayed_puzhash def solution_for_p2_singleton(p2_singleton_coin: Coin, singleton_inner_puzhash: bytes32) -> Program: - return Program.to([singleton_inner_puzhash, p2_singleton_coin.name()]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([singleton_inner_puzhash, p2_singleton_coin.name()]) # type: ignore[return-value] # Solution for the delayed spend case for p2_singleton_or_delayed_puzhash def solution_for_p2_delayed_puzzle(output_amount: uint64) -> Program: - return Program.to([output_amount, []]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([output_amount, []]) # type: ignore[return-value] # Get announcement conditions for singleton solution and full CoinSpend for the claimed coin @@ -174,12 +190,18 @@ def claim_p2_singleton( delay_time, delay_ph, ) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] claim_coinsol = CoinSpend( p2_singleton_coin, - puzzle, - solution_for_p2_singleton(p2_singleton_coin, singleton_inner_puzhash), + puzzle, # type: ignore[arg-type] + solution_for_p2_singleton(p2_singleton_coin, singleton_inner_puzhash), # type: ignore[arg-type] ) - return assertion, announcement, claim_coinsol + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[SExp, SExp, CoinSpend]", expected + # "Tuple[Program, Program, CoinSpend]") [return-value] + return assertion, announcement, claim_coinsol # type: ignore[return-value] # Get the CoinSpend for spending to a delayed puzzle @@ -190,9 +212,12 @@ def spend_to_delayed_puzzle( delay_time: uint64, delay_ph: bytes32, ) -> CoinSpend: + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] claim_coinsol = CoinSpend( p2_singleton_coin, - pay_to_singleton_or_delay_puzzle(launcher_id, delay_time, delay_ph), - solution_for_p2_delayed_puzzle(output_amount), + pay_to_singleton_or_delay_puzzle(launcher_id, delay_time, delay_ph), # type: ignore[arg-type] + solution_for_p2_delayed_puzzle(output_amount), # type: ignore[arg-type] ) return claim_coinsol diff --git a/chia/wallet/puzzles/test_cc.py b/chia/wallet/puzzles/test_cc.py index 2ac473e6bf47..41f57c262188 100644 --- a/chia/wallet/puzzles/test_cc.py +++ b/chia/wallet/puzzles/test_cc.py @@ -68,7 +68,9 @@ def issue_cc_from_farmed_coin( # get a farmed coin farmed_puzzle = ANYONE_CAN_SPEND_PUZZLE - farmed_puzzle_hash = farmed_puzzle.get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + farmed_puzzle_hash = farmed_puzzle.get_tree_hash() # type: ignore[attr-defined] # mint a cc @@ -83,7 +85,10 @@ def issue_cc_from_farmed_coin( # this is just a coincidence... for more complicated puzzles, you'll likely have to do some real work solution = Program.to(output_conditions) - coin_spend = CoinSpend(farmed_coin, farmed_puzzle, solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(farmed_coin, farmed_puzzle, solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], NULL_SIGNATURE) return genesis_coin_checker, spend_bundle @@ -92,7 +97,9 @@ def solution_for_pay_to_any(puzzle_hash_amount_pairs: List[Tuple[bytes32, int]]) output_conditions = [ [ConditionOpcode.CREATE_COIN, puzzle_hash, amount] for puzzle_hash, amount in puzzle_hash_amount_pairs ] - return Program.to(output_conditions) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(output_conditions) # type: ignore[return-value] def test_spend_through_n(mod_code, coin_checker_for_farmed_coin, n): @@ -180,7 +187,9 @@ def test_spend_zero_coin(mod_code: Program, coin_checker_for_farmed_coin): """ eve_inner_puzzle = ANYONE_CAN_SPEND_PUZZLE - eve_inner_puzzle_hash = eve_inner_puzzle.get_tree_hash() + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + eve_inner_puzzle_hash = eve_inner_puzzle.get_tree_hash() # type: ignore[attr-defined] total_minted = 0x111 @@ -206,7 +215,10 @@ def test_spend_zero_coin(mod_code: Program, coin_checker_for_farmed_coin): wrapped_cc_puzzle_hash = cc_puzzle_hash_for_inner_puzzle_hash(mod_code, genesis_coin_checker, eve_inner_puzzle_hash) solution = solution_for_pay_to_any([(wrapped_cc_puzzle_hash, 0)]) - coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, solution) # type: ignore[arg-type] spendable_cc_list = spendable_cc_list_from_coin_spend(coin_spend, hash_to_puzzle_f) assert len(spendable_cc_list) == 1 zero_cc_spendable = spendable_cc_list[0] diff --git a/chia/wallet/util/debug_spend_bundle.py b/chia/wallet/util/debug_spend_bundle.py index c22f5cd04882..fc6d14361f79 100644 --- a/chia/wallet/util/debug_spend_bundle.py +++ b/chia/wallet/util/debug_spend_bundle.py @@ -34,7 +34,9 @@ def coin_as_program(coin: Coin) -> Program: """ Convenience function for when putting `coin_info` into a solution. """ - return Program.to([coin.parent_coin_info, coin.puzzle_hash, coin.amount]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([coin.parent_coin_info, coin.puzzle_hash, coin.amount]) # type: ignore[return-value] def dump_coin(coin: Coin) -> str: @@ -72,7 +74,12 @@ def debug_spend_bundle(spend_bundle, agg_sig_additional_data=DEFAULT_CONSTANTS.A print(f" with id {coin_name}") print() print(f"\nbrun -y main.sym '{bu_disassemble(puzzle_reveal)}' '{bu_disassemble(solution)}'") - error, conditions, cost = conditions_dict_for_solution(puzzle_reveal, solution, INFINITE_COST) + # TODO: address hint error and remove ignore + # error: Argument 1 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + # error: Argument 2 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + error, conditions, cost = conditions_dict_for_solution(puzzle_reveal, solution, INFINITE_COST) # type: ignore[arg-type] # noqa E501 if error: print(f"*** error {error}") elif conditions is not None: @@ -195,4 +202,6 @@ def solution_for_pay_to_any(puzzle_hash_amount_pairs: Iterable[Tuple[bytes32, in output_conditions = [ [ConditionOpcode.CREATE_COIN, puzzle_hash, amount] for puzzle_hash, amount in puzzle_hash_amount_pairs ] - return Program.to(output_conditions) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(output_conditions) # type: ignore[return-value] diff --git a/chia/wallet/util/trade_utils.py b/chia/wallet/util/trade_utils.py index 3fd50726fe60..2f9faf2c8aae 100644 --- a/chia/wallet/util/trade_utils.py +++ b/chia/wallet/util/trade_utils.py @@ -50,7 +50,12 @@ def get_output_discrepancy_for_puzzle_and_solution(coin, puzzle, solution): def get_output_amount_for_puzzle_and_solution(puzzle: Program, solution: Program) -> int: - error, conditions, cost = conditions_dict_for_solution(puzzle, solution, INFINITE_COST) + # TODO: address hint error and remove ignore + # error: Argument 1 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + # error: Argument 2 to "conditions_dict_for_solution" has incompatible type "Program"; expected + # "SerializedProgram" [arg-type] + error, conditions, cost = conditions_dict_for_solution(puzzle, solution, INFINITE_COST) # type: ignore[arg-type] total = 0 if conditions: for _ in conditions.get(ConditionOpcode.CREATE_COIN, []): diff --git a/chia/wallet/wallet.py b/chia/wallet/wallet.py index 3458182825d3..8a517311a10d 100644 --- a/chia/wallet/wallet.py +++ b/chia/wallet/wallet.py @@ -463,7 +463,12 @@ async def create_spend_bundle_relative_chia(self, chia_amount: int, exclude: Lis primaries = [{"puzzlehash": newpuzhash, "amount": chia_amount}] solution = self.make_solution(primaries=primaries) output_created = coin - list_of_solutions.append(CoinSpend(coin, puzzle, solution)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + list_of_solutions.append(CoinSpend(coin, puzzle, solution)) # type: ignore[arg-type] await self.hack_populate_secret_keys_for_coin_spends(list_of_solutions) spend_bundle = await sign_coin_spends( diff --git a/chia/wallet/wallet_node.py b/chia/wallet/wallet_node.py index 086633f8d1be..45117731b06f 100644 --- a/chia/wallet/wallet_node.py +++ b/chia/wallet/wallet_node.py @@ -894,7 +894,12 @@ async def fetch_puzzle_solution(self, peer, height: uint32, coin: Coin) -> CoinS ) if solution_response is None or not isinstance(solution_response, wallet_protocol.RespondPuzzleSolution): raise ValueError(f"Was not able to obtain solution {solution_response}") - return CoinSpend(coin, solution_response.response.puzzle, solution_response.response.solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return CoinSpend(coin, solution_response.response.puzzle, solution_response.response.solution) # type: ignore[arg-type] # noqa E501 async def get_additional_coin_spends( self, peer, block, added_coins: List[Coin], removed_coins: List[Coin] diff --git a/setup.py b/setup.py index d4c1723ef8f5..6b31e910b045 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,8 @@ "chiavdf==1.0.3", # timelord and vdf verification "chiabip158==1.0", # bip158-style wallet filters "chiapos==1.0.6", # proof of space - "clvm==0.9.7", + # TODO: set to the new release version + "clvm @ git+https://github.com/Chia-Network/clvm@pep-561", "clvm_rs==0.1.15", "clvm_tools==0.4.3", "aiohttp==3.7.4", # HTTP server for full node rpc diff --git a/tests/clvm/test_puzzles.py b/tests/clvm/test_puzzles.py index 8f508448c96c..ed8bede75f58 100644 --- a/tests/clvm/test_puzzles.py +++ b/tests/clvm/test_puzzles.py @@ -70,7 +70,10 @@ def do_test_spend( coin = coin_db.farm_coin(puzzle_hash, farm_time) # spend it - coin_spend = CoinSpend(coin, puzzle_reveal, solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) coin_db.update_coin_store_for_spend_bundle(spend_bundle, spend_time, MAX_BLOCK_COST_CLVM, COST_PER_BYTE) @@ -100,7 +103,10 @@ def default_payments_and_conditions( (throwaway_puzzle_hash(initial_index + 2, key_lookup), (initial_index + 1) * 1000), ] conditions = Program.to([make_create_coin_condition(ph, amount) for ph, amount in payments]) - return payments, conditions + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[List[Tuple[Any, int]], SExp]", expected + # "Tuple[List[Tuple[Any, int]], Program]") [return-value] + return payments, conditions # type: ignore[return-value] def make_create_coin_condition(puzzle_hash, amount): diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index 3f7ca9a4876c..0ef4eed1a472 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -49,7 +49,9 @@ def cleanup_keyring(keyring: TempKeyring): # We call it the `EASY_PUZZLE` because it's pretty easy to solve. EASY_PUZZLE = Program.to(assemble("1")) -EASY_PUZZLE_HASH = EASY_PUZZLE.get_tree_hash() +# TODO: address hint error and remove ignore +# error: "SExp" has no attribute "get_tree_hash" [attr-defined] +EASY_PUZZLE_HASH = EASY_PUZZLE.get_tree_hash() # type: ignore[attr-defined] def initial_blocks(block_count: int = 4) -> List[FullBlock]: @@ -121,7 +123,10 @@ async def check_conditions( blocks = initial_blocks() coin = list(blocks[spend_reward_index].get_included_reward_coins())[0] - coin_spend = CoinSpend(coin, EASY_PUZZLE, condition_solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(coin, EASY_PUZZLE, condition_solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) # now let's try to create a block with the spend bundle and ensure that it doesn't validate diff --git a/tests/core/make_block_generator.py b/tests/core/make_block_generator.py index 37f4711183a9..eead88d86a81 100644 --- a/tests/core/make_block_generator.py +++ b/tests/core/make_block_generator.py @@ -43,7 +43,9 @@ def make_fake_coin(index: int, puzzle_hash_db: dict) -> Coin: def conditions_for_payment(coin) -> Program: d: Dict = {} # a throwaway db since we don't care new_puzzle_hash = puzzle_hash_for_index(int.from_bytes(coin.puzzle_hash, "big"), d) - return Program.to([[ConditionOpcode.CREATE_COIN, new_puzzle_hash, coin.amount]]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([[ConditionOpcode.CREATE_COIN, new_puzzle_hash, coin.amount]]) # type: ignore[return-value] def make_spend_bundle(count: int) -> SpendBundle: @@ -55,7 +57,10 @@ def make_spend_bundle(count: int) -> SpendBundle: puzzle_reveal = puzzle_hash_db[coin.puzzle_hash] conditions = conditions_for_payment(coin) solution = solution_for_conditions(conditions) - coin_spend = CoinSpend(coin, puzzle_reveal, solution) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] coin_spends.append(coin_spend) spend_bundle = SpendBundle(coin_spends, blspy.G2Element()) diff --git a/tests/generator/test_compression.py b/tests/generator/test_compression.py index 1313cc6a2b5c..ad709d2888ea 100644 --- a/tests/generator/test_compression.py +++ b/tests/generator/test_compression.py @@ -78,7 +78,10 @@ def create_multiple_ref_generator(args: MultipleCompressorArg, spend_bundle: Spe GeneratorArg(FAKE_BLOCK_HEIGHT1, args.arg[0].generator), GeneratorArg(FAKE_BLOCK_HEIGHT2, args.arg[1].generator), ] - return BlockGenerator(program, generator_args) + # TODO: address hint error and remove ignore + # error: Argument 1 to "BlockGenerator" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return BlockGenerator(program, generator_args) # type: ignore[arg-type] def spend_bundle_to_coin_spend_entry_list(bundle: SpendBundle) -> List[Any]: diff --git a/tests/generator/test_rom.py b/tests/generator/test_rom.py index efcbaa1ed2b7..0e9eb2824669 100644 --- a/tests/generator/test_rom.py +++ b/tests/generator/test_rom.py @@ -43,7 +43,14 @@ "1380ff02ff05ff2b80ff018080" ) -COMPILED_GENERATOR_CODE = bytes(Program.to(compile_clvm_text(GENERATOR_CODE, []))) +# TODO: address hint error and remove ignore +# error: No overload variant of "bytes" matches argument type "SExp" [call-overload] +# note: Possible overload variants: +# note: def bytes(cls, ints: Iterable[int]) -> bytes +# note: def bytes(cls, length: int) -> bytes +# note: def bytes(cls, o: SupportsBytes) -> bytes +# note: <2 more non-matching overloads not shown> +COMPILED_GENERATOR_CODE = bytes(Program.to(compile_clvm_text(GENERATOR_CODE, []))) # type: ignore[call-overload] FIRST_GENERATOR = Program.to( binutils.assemble('((parent_id (c 1 (q "puzzle blob")) 50000 "solution is here" extra data for coin))') diff --git a/tests/pools/test_wallet_pool_store.py b/tests/pools/test_wallet_pool_store.py index 066fa39dcbeb..774f7518f4bc 100644 --- a/tests/pools/test_wallet_pool_store.py +++ b/tests/pools/test_wallet_pool_store.py @@ -31,10 +31,15 @@ def make_child_solution(coin_spend: CoinSpend, new_coin: Optional[Coin] = None) solution_prog = Program.to(binutils.assemble(solution)) if new_coin is None: new_coin = coin_spend.additions()[0] + # TODO: address hint error and remove ignore + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" + # [arg-type] + # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" + # [arg-type] sol: CoinSpend = CoinSpend( new_coin, - SerializedProgram.from_program(puzzle_prog), - SerializedProgram.from_program(solution_prog), + SerializedProgram.from_program(puzzle_prog), # type: ignore[arg-type] + SerializedProgram.from_program(solution_prog), # type: ignore[arg-type] ) return sol diff --git a/tests/util/benchmark_cost.py b/tests/util/benchmark_cost.py index 417467917a5f..ce5897a7e142 100644 --- a/tests/util/benchmark_cost.py +++ b/tests/util/benchmark_cost.py @@ -126,7 +126,10 @@ def benchmark_all_operators(): puzzle_start = time.time() clvm_cost = 0 for i in range(0, 1000): - cost_run, sexp = puzzles[i].run_with_cost(solutions[i], INFINITE_COST) + # TODO: address hint error and remove ignore + # error: Argument 1 to "run_with_cost" of "Program" has incompatible type "Program"; expected "int" + # [arg-type] + cost_run, sexp = puzzles[i].run_with_cost(solutions[i], INFINITE_COST) # type: ignore[arg-type] clvm_cost += cost_run puzzle_end = time.time() diff --git a/tests/wallet/test_singleton.py b/tests/wallet/test_singleton.py index bf3eba6f71a1..f97b7c058664 100644 --- a/tests/wallet/test_singleton.py +++ b/tests/wallet/test_singleton.py @@ -15,7 +15,9 @@ LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() +# TODO: address hint error and remove ignore +# error: "SExp" has no attribute "get_tree_hash" [attr-defined] +LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() # type: ignore[attr-defined] POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000") diff --git a/tests/wallet/test_singleton_lifecycle.py b/tests/wallet/test_singleton_lifecycle.py index f98c57d164ed..69914de7b4eb 100644 --- a/tests/wallet/test_singleton_lifecycle.py +++ b/tests/wallet/test_singleton_lifecycle.py @@ -40,7 +40,9 @@ def check_coin_spend(coin_spend: CoinSpend): def adaptor_for_singleton_inner_puzzle(puzzle: Program) -> Program: # this is prety slow - return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) # type: ignore[return-value] def launcher_conditions_and_spend_bundle( @@ -57,7 +59,9 @@ def launcher_conditions_and_spend_bundle( ) singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash() message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) # type: ignore[attr-defined] # noqa E501 expected_conditions = [] expected_conditions.append( Program.to( @@ -70,10 +74,16 @@ def launcher_conditions_and_spend_bundle( ) ) launcher_solution = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - coin_spend = CoinSpend(launcher_coin, launcher_puzzle, launcher_solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(launcher_coin, launcher_puzzle, launcher_solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) lineage_proof = Program.to([parent_coin_id, launcher_amount]) - return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[SExp, Any, List[SExp], SpendBundle]", expected + # "Tuple[Program, Any, List[Program], SpendBundle]") [return-value] + return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle # type: ignore[return-value] def singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32, inner_puzzle: Program) -> Program: @@ -85,7 +95,9 @@ def singleton_puzzle_hash(launcher_id: Program, launcher_puzzle_hash: bytes32, i def solution_for_singleton_puzzle(lineage_proof: Program, my_amount: int, inner_solution: Program) -> Program: - return Program.to([lineage_proof, my_amount, inner_solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([lineage_proof, my_amount, inner_solution]) # type: ignore[return-value] def p2_singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32) -> Program: diff --git a/tests/wallet/test_singleton_lifecycle_fast.py b/tests/wallet/test_singleton_lifecycle_fast.py index 89af12c7b515..e711f0c167b7 100644 --- a/tests/wallet/test_singleton_lifecycle_fast.py +++ b/tests/wallet/test_singleton_lifecycle_fast.py @@ -28,7 +28,9 @@ P2_SINGLETON_MOD_HASH = P2_SINGLETON_MOD.get_tree_hash() ANYONE_CAN_SPEND_PUZZLE = Program.to(1) -ANYONE_CAN_SPEND_WITH_PADDING_PUZZLE_HASH = Program.to(binutils.assemble("(a (q . 1) 3)")).get_tree_hash() +# TODO: address hint error and remove ignore +# error: "SExp" has no attribute "get_tree_hash" [attr-defined] +ANYONE_CAN_SPEND_WITH_PADDING_PUZZLE_HASH = Program.to(binutils.assemble("(a (q . 1) 3)")).get_tree_hash() # type: ignore[attr-defined] # noqa E501 POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000") @@ -95,7 +97,9 @@ def solve_launcher(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwa destination_puzzle_hash = from_kwargs(kwargs, "destination_puzzle_hash", bytes32) metadata = from_kwargs(kwargs, "metadata", List[Tuple[str, Program]]) solution = Program.to([destination_puzzle_hash, launcher_amount, metadata]) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_anyone_can_spend(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -105,7 +109,9 @@ def solve_anyone_can_spend(solver: Solver, puzzle_db: PuzzleDB, args: List[Progr """ conditions = from_kwargs(kwargs, "conditions", List[Program]) solution = Program.to(conditions) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_anyone_can_spend_with_padding( @@ -114,7 +120,9 @@ def solve_anyone_can_spend_with_padding( """This is the puzzle `(a (q . 1) 3)`. It's only for testing.""" conditions = from_kwargs(kwargs, "conditions", List[Program]) solution = Program.to((0, conditions)) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -127,7 +135,9 @@ def solve_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kw lineage_proof = from_kwargs(kwargs, "lineage_proof", Program) coin_amount = from_kwargs(kwargs, "coin_amount", int) solution = inner_solution.to([lineage_proof, coin_amount, inner_solution.rest()]) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_pool_member(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -138,12 +148,16 @@ def solve_pool_member(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], to_waiting_room = pool_member_spend_type == "to-waiting-room" if to_waiting_room: key_value_list = from_kwargs(kwargs, "key_value_list", List[Tuple[str, Program]]) - return Program.to([0, 1, 0, 0, key_value_list]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([0, 1, 0, 0, key_value_list]) # type: ignore[return-value] # it's an "absorb_pool_reward" type pool_reward_amount = from_kwargs(kwargs, "pool_reward_amount", int) pool_reward_height = from_kwargs(kwargs, "pool_reward_height", int) solution = Program.to([0, pool_reward_amount, pool_reward_height]) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_pool_waiting_room(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -155,12 +169,16 @@ def solve_pool_waiting_room(solver: Solver, puzzle_db: PuzzleDB, args: List[Prog if exit_waiting_room: key_value_list = from_kwargs(kwargs, "key_value_list", List[Tuple[str, Program]]) destination_puzzle_hash = from_kwargs(kwargs, "destination_puzzle_hash", int) - return Program.to([0, 1, key_value_list, destination_puzzle_hash]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([0, 1, key_value_list, destination_puzzle_hash]) # type: ignore[return-value] # it's an "absorb_pool_reward" type pool_reward_amount = from_kwargs(kwargs, "pool_reward_amount", int) pool_reward_height = from_kwargs(kwargs, "pool_reward_height", int) solution = Program.to([0, 0, pool_reward_amount, pool_reward_height]) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -173,7 +191,9 @@ def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], singleton_inner_puzzle_hash = from_kwargs(kwargs, "singleton_inner_puzzle_hash") p2_singleton_coin_name = from_kwargs(kwargs, "p2_singleton_coin_name") solution = Program.to([singleton_inner_puzzle_hash, p2_singleton_coin_name]) - return solution + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return solution # type: ignore[return-value] raise ValueError("can't solve `delayed-spend` yet") @@ -183,7 +203,9 @@ def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], SOLVER.register_solver(SINGLETON_MOD_HASH, solve_singleton) SOLVER.register_solver(POOL_MEMBER_MOD.get_tree_hash(), solve_pool_member) SOLVER.register_solver(POOL_WAITINGROOM_MOD.get_tree_hash(), solve_pool_waiting_room) -SOLVER.register_solver(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), solve_anyone_can_spend) +# TODO: address hint error and remove ignore +# error: "SExp" has no attribute "get_tree_hash" [attr-defined] +SOLVER.register_solver(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), solve_anyone_can_spend) # type: ignore[attr-defined] SOLVER.register_solver(P2_SINGLETON_MOD_HASH, solve_p2_singleton) @@ -221,7 +243,12 @@ def coin_spend_for_conditions(self, puzzle_db: PuzzleDB, **kwargs) -> CoinSpend: solution = solve_puzzle( puzzle_db, puzzle_reveal, lineage_proof=self.lineage_proof, coin_amount=coin.amount, **kwargs ) - return CoinSpend(coin, puzzle_reveal, solution) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] def update_state(self, puzzle_db: PuzzleDB, removals: List[CoinSpend]) -> int: state_change_count = 0 @@ -239,7 +266,10 @@ def update_state(self, puzzle_db: PuzzleDB, removals: List[CoinSpend]) -> int: lineage_proof = Program.to( [self.current_state.parent_coin_info, parent_inner_puzzle_hash, coin.amount] ) - self.lineage_proof = lineage_proof + # TODO: address hint error and remove ignore + # error: Incompatible types in assignment (expression has type "SExp", variable has type + # "Program") [assignment] + self.lineage_proof = lineage_proof # type: ignore[assignment] self.current_state = coin state_change_count += 1 return state_change_count @@ -256,7 +286,9 @@ def adaptor_for_singleton_inner_puzzle(puzzle: Program) -> Program: puzzle to work as a singleton inner puzzle. """ # this is pretty slow and lame - return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) # type: ignore[return-value] def launcher_conditions_and_spend_bundle( @@ -274,7 +306,9 @@ def launcher_conditions_and_spend_bundle( puzzle_db.add_puzzle(singleton_full_puzzle) singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash() message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) # type: ignore[attr-defined] # noqa E501 expected_conditions = [] expected_conditions.append( Program.to( @@ -293,9 +327,14 @@ def launcher_conditions_and_spend_bundle( launcher_amount=launcher_amount, metadata=metadata, ) - coin_spend = CoinSpend(launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution) # type: ignore[arg-type] # noqa E501 spend_bundle = SpendBundle([coin_spend], G2Element()) - return launcher_coin.name(), expected_conditions, spend_bundle + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[Any, List[SExp], SpendBundle]", expected + # "Tuple[Any, List[Program], SpendBundle]") [return-value] + return launcher_coin.name(), expected_conditions, spend_bundle # type: ignore[return-value] def singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32, inner_puzzle: Program) -> Program: @@ -307,7 +346,9 @@ def singleton_puzzle_hash(launcher_id: Program, launcher_puzzle_hash: bytes32, i def solution_for_singleton_puzzle(lineage_proof: Program, my_amount: int, inner_solution: Program) -> Program: - return Program.to([lineage_proof, my_amount, inner_solution]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([lineage_proof, my_amount, inner_solution]) # type: ignore[return-value] def p2_singleton_puzzle_for_launcher( @@ -352,10 +393,12 @@ def claim_p2_singleton( singleton_inner_puzzle_hash=inner_puzzle_hash, p2_singleton_coin_name=p2_singleton_coin_name, ) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] p2_singleton_coin_spend = CoinSpend( p2_singleton_coin, p2_singleton_puzzle.to_serialized_program(), - p2_singleton_solution, + p2_singleton_solution, # type: ignore[arg-type] ) expected_p2_singleton_announcement = Announcement(p2_singleton_coin_name, bytes(b"$")).name() singleton_conditions = [ @@ -363,7 +406,10 @@ def claim_p2_singleton( Program.to([ConditionOpcode.CREATE_COIN, inner_puzzle_hash, 1]), Program.to([ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, expected_p2_singleton_announcement]), ] - return p2_singleton_coin_spend, singleton_conditions + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "Tuple[CoinSpend, List[SExp]]", expected + # "Tuple[CoinSpend, List[Program]]") [return-value] + return p2_singleton_coin_spend, singleton_conditions # type: ignore[return-value] def lineage_proof_for_coin_spend(coin_spend: CoinSpend) -> Program: @@ -374,14 +420,18 @@ def lineage_proof_for_coin_spend(coin_spend: CoinSpend) -> Program: inner_puzzle_hash = None if coin.puzzle_hash == LAUNCHER_PUZZLE_HASH: - return Program.to([parent_name, amount]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([parent_name, amount]) # type: ignore[return-value] full_puzzle = Program.from_bytes(bytes(coin_spend.puzzle_reveal)) _, args = full_puzzle.uncurry() _, __, ___, inner_puzzle = list(args.as_iter()) inner_puzzle_hash = inner_puzzle.get_tree_hash() - return Program.to([parent_name, inner_puzzle_hash, amount]) + # TODO: address hint error and remove ignore + # error: Incompatible return value type (got "SExp", expected "Program") [return-value] + return Program.to([parent_name, inner_puzzle_hash, amount]) # type: ignore[return-value] def create_throwaway_pubkey(seed: bytes) -> G1Element: @@ -402,20 +452,28 @@ def spend_coin_to_singleton( metadata = [("foo", "bar")] now = CoinTimestamp(10012300, 1) - farmed_coin = coin_store.farm_coin(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), now, amount=farmed_coin_amount) + # TODO: address hint error and remove ignore + # error: "SExp" has no attribute "get_tree_hash" [attr-defined] + farmed_coin = coin_store.farm_coin(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), now, amount=farmed_coin_amount) # type: ignore[attr-defined] # noqa E501 now.seconds += 500 now.height += 1 launcher_amount: uint64 = uint64(1) launcher_puzzle = LAUNCHER_PUZZLE launcher_puzzle_hash = launcher_puzzle.get_tree_hash() - initial_singleton_puzzle = adaptor_for_singleton_inner_puzzle(ANYONE_CAN_SPEND_PUZZLE) + # TODO: address hint error and remove ignore + # error: Argument 1 to "adaptor_for_singleton_inner_puzzle" has incompatible type "SExp"; expected "Program" + # [arg-type] + initial_singleton_puzzle = adaptor_for_singleton_inner_puzzle(ANYONE_CAN_SPEND_PUZZLE) # type: ignore[arg-type] launcher_id, condition_list, launcher_spend_bundle = launcher_conditions_and_spend_bundle( puzzle_db, farmed_coin.name(), launcher_amount, initial_singleton_puzzle, metadata, launcher_puzzle ) conditions = Program.to(condition_list) - coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, conditions) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, conditions) # type: ignore[arg-type] spend_bundle = SpendBundle.aggregate([launcher_spend_bundle, SpendBundle([coin_spend], G2Element())]) additions, removals = coin_store.update_coin_store_for_spend_bundle( diff --git a/tests/wallet_tools.py b/tests/wallet_tools.py index d22e67262cae..1339b2625b31 100644 --- a/tests/wallet_tools.py +++ b/tests/wallet_tools.py @@ -149,9 +149,19 @@ def generate_unsigned_transaction( ConditionWithArgs(ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, [primary_announcement_hash]) ) main_solution = self.make_solution(condition_dic) - spends.append(CoinSpend(coin, puzzle, main_solution)) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + spends.append(CoinSpend(coin, puzzle, main_solution)) # type: ignore[arg-type] else: - spends.append(CoinSpend(coin, puzzle, self.make_solution(secondary_coins_cond_dic))) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + spends.append(CoinSpend(coin, puzzle, self.make_solution(secondary_coins_cond_dic))) # type: ignore[arg-type] # noqa E501 return spends def sign_transaction(self, coin_spends: List[CoinSpend]) -> SpendBundle: From e758934962d38d6c906010be28b6e4e68b9e8802 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 24 Nov 2021 10:54:27 -0500 Subject: [PATCH 2/7] remove some ignores no longer needed after clvm fix --- chia/clvm/spend_sim.py | 10 +-- chia/full_node/full_node_api.py | 7 +- chia/full_node/generator.py | 4 +- chia/pools/pool_puzzles.py | 53 +++-------- chia/pools/pool_wallet.py | 9 +- chia/rpc/full_node_rpc_api.py | 10 +-- chia/types/blockchain_format/program.py | 19 +--- chia/wallet/cc_wallet/cc_utils.py | 8 +- chia/wallet/cc_wallet/cc_wallet.py | 20 +---- chia/wallet/did_wallet/did_wallet.py | 35 ++------ .../puzzles/genesis_by_coin_id_with_0.py | 8 +- .../puzzles/genesis_by_puzzle_hash_with_0.py | 8 +- chia/wallet/puzzles/p2_conditions.py | 4 +- .../wallet/puzzles/p2_delegated_conditions.py | 4 +- chia/wallet/puzzles/p2_delegated_puzzle.py | 9 +- .../p2_delegated_puzzle_or_hidden_puzzle.py | 13 +-- .../puzzles/p2_m_of_n_delegate_direct.py | 4 +- chia/wallet/puzzles/p2_puzzle_hash.py | 4 +- .../wallet/puzzles/prefarm/make_prefarm_ph.py | 8 +- chia/wallet/puzzles/singleton_top_layer.py | 30 ++----- chia/wallet/puzzles/test_cc.py | 12 +-- chia/wallet/util/debug_spend_bundle.py | 8 +- tests/clvm/test_puzzles.py | 5 +- tests/core/full_node/test_conditions.py | 4 +- tests/core/make_block_generator.py | 4 +- tests/generator/test_rom.py | 9 +- tests/pools/test_wallet_pool_store.py | 9 +- tests/wallet/test_singleton.py | 4 +- tests/wallet/test_singleton_lifecycle.py | 17 +--- tests/wallet/test_singleton_lifecycle_fast.py | 88 +++++-------------- 30 files changed, 96 insertions(+), 331 deletions(-) diff --git a/chia/clvm/spend_sim.py b/chia/clvm/spend_sim.py index 7fd6174b4028..776bf6bb35b3 100644 --- a/chia/clvm/spend_sim.py +++ b/chia/clvm/spend_sim.py @@ -290,14 +290,8 @@ async def get_puzzle_and_solution(self, coin_id: bytes32, height: uint32) -> Opt if error: return None else: - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected - # "Program" [arg-type] - puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) # type: ignore[arg-type] - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected - # "Program" [arg-type] - solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) # type: ignore[arg-type] # noqa E501 + puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) + solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) return CoinSpend(coin_record.coin, puzzle_ser, solution_ser) async def get_all_mempool_tx_ids(self) -> List[bytes32]: diff --git a/chia/full_node/full_node_api.py b/chia/full_node/full_node_api.py index 73498542100a..5512718cfc7b 100644 --- a/chia/full_node/full_node_api.py +++ b/chia/full_node/full_node_api.py @@ -1289,12 +1289,7 @@ async def request_puzzle_solution(self, request: wallet_protocol.RequestPuzzleSo pz = Program.to(puzzle) sol = Program.to(solution) - # TODO: address hint error and remove ignore - # error: Argument 3 to "PuzzleSolutionResponse" has incompatible type "SExp"; expected "Program" - # [arg-type] - # error: Argument 4 to "PuzzleSolutionResponse" has incompatible type "SExp"; expected "Program" - # [arg-type] - wrapper = PuzzleSolutionResponse(coin_name, height, pz, sol) # type: ignore[arg-type] + wrapper = PuzzleSolutionResponse(coin_name, height, pz, sol) response = wallet_protocol.RespondPuzzleSolution(wrapper) response_msg = make_msg(ProtocolMessageTypes.respond_puzzle_solution, response) return response_msg diff --git a/chia/full_node/generator.py b/chia/full_node/generator.py index e66a131c977b..7c3a2dd15eab 100644 --- a/chia/full_node/generator.py +++ b/chia/full_node/generator.py @@ -37,9 +37,7 @@ def create_generator_args(generator_ref_list: List[SerializedProgram]) -> Progra `create_generator_args`: The format and contents of these arguments affect consensus. """ gen_ref_list = [bytes(g) for g in generator_ref_list] - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([gen_ref_list]) # type: ignore[return-value] + return Program.to([gen_ref_list]) def create_compressed_generator( diff --git a/chia/pools/pool_puzzles.py b/chia/pools/pool_puzzles.py index 0113e5c74897..0568e868d6f5 100644 --- a/chia/pools/pool_puzzles.py +++ b/chia/pools/pool_puzzles.py @@ -33,9 +33,7 @@ SINGLETON_LAUNCHER_HASH = SINGLETON_LAUNCHER.get_tree_hash() SINGLETON_MOD_HASH = POOL_OUTER_MOD_HASH -# TODO: address hint error and remove ignore -# error: "SExp" has no attribute "get_tree_hash" [attr-defined] -SINGLETON_MOD_HASH_HASH = Program.to(SINGLETON_MOD_HASH).get_tree_hash() # type: ignore[attr-defined] +SINGLETON_MOD_HASH_HASH = Program.to(SINGLETON_MOD_HASH).get_tree_hash() def create_waiting_room_inner_puzzle( @@ -172,28 +170,20 @@ def create_travel_spend( # inner sol is key_value_list () # key_value_list is: # "ps" -> poolstate as bytes - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - inner_sol: Program = Program.to([[("p", bytes(target))], 0]) # type: ignore[assignment] + inner_sol: Program = Program.to([[("p", bytes(target))], 0]) elif is_pool_waitingroom_inner_puzzle(inner_puzzle): # inner sol is (spend_type, key_value_list, pool_reward_height) destination_inner: Program = pool_state_to_inner_puzzle( target, launcher_coin.name(), genesis_challenge, delay_time, delay_ph ) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] log.debug( f"create_travel_spend: waitingroom: target PoolState bytes:\n{bytes(target).hex()}\n" f"{target}" - f"hash:{Program.to(bytes(target)).get_tree_hash()}" # type: ignore[attr-defined] + f"hash:{Program.to(bytes(target)).get_tree_hash()}" ) # key_value_list is: # "ps" -> poolstate as bytes - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - inner_sol = Program.to([1, [("p", bytes(target))], destination_inner.get_tree_hash()]) # type: ignore[assignment] # noqa E501 # current or target + inner_sol = Program.to([1, [("p", bytes(target))], destination_inner.get_tree_hash()]) # current or target else: raise ValueError @@ -213,10 +203,7 @@ def create_travel_spend( last_coin_spend.coin.amount, ] ) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - full_solution: Program = Program.to([parent_info_list, current_singleton.amount, inner_sol]) # type: ignore[assignment] # noqa E501 + full_solution: Program = Program.to([parent_info_list, current_singleton.amount, inner_sol]) full_puzzle: Program = create_full_puzzle(inner_puzzle, launcher_coin.name()) return ( @@ -244,16 +231,10 @@ def create_absorb_spend( reward_amount: uint64 = calculate_pool_reward(height) if is_pool_member_inner_puzzle(inner_puzzle): # inner sol is (spend_type, pool_reward_amount, pool_reward_height, extra_data) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - inner_sol: Program = Program.to([reward_amount, height]) # type: ignore[assignment] + inner_sol: Program = Program.to([reward_amount, height]) elif is_pool_waitingroom_inner_puzzle(inner_puzzle): # inner sol is (spend_type, destination_puzhash, pool_reward_amount, pool_reward_height, extra_data) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - inner_sol = Program.to([0, reward_amount, height]) # type: ignore[assignment] + inner_sol = Program.to([0, reward_amount, height]) else: raise ValueError # full sol = (parent_info, my_amount, inner_solution) @@ -261,29 +242,20 @@ def create_absorb_spend( assert coin is not None if coin.parent_coin_info == launcher_coin.name(): - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - parent_info: Program = Program.to([launcher_coin.parent_coin_info, launcher_coin.amount]) # type: ignore[assignment] # noqa E501 + parent_info: Program = Program.to([launcher_coin.parent_coin_info, launcher_coin.amount]) else: p = Program.from_bytes(bytes(last_coin_spend.puzzle_reveal)) last_coin_spend_inner_puzzle: Optional[Program] = get_inner_puzzle_from_puzzle(p) assert last_coin_spend_inner_puzzle is not None - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - parent_info = Program.to( # type: ignore[assignment] + parent_info = Program.to( [ last_coin_spend.coin.parent_coin_info, last_coin_spend_inner_puzzle.get_tree_hash(), last_coin_spend.coin.amount, ] ) - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" - # [arg-type] full_solution: SerializedProgram = SerializedProgram.from_program( - Program.to([parent_info, last_coin_spend.coin.amount, inner_sol]) # type: ignore[arg-type] + Program.to([parent_info, last_coin_spend.coin.amount, inner_sol]) ) full_puzzle: SerializedProgram = SerializedProgram.from_program( create_full_puzzle(inner_puzzle, launcher_coin.name()) @@ -295,11 +267,8 @@ def create_absorb_spend( create_p2_singleton_puzzle(SINGLETON_MOD_HASH, launcher_coin.name(), delay_time, delay_ph) ) reward_coin: Coin = Coin(reward_parent, p2_singleton_puzzle.get_tree_hash(), reward_amount) - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" - # [arg-type] p2_singleton_solution: SerializedProgram = SerializedProgram.from_program( - Program.to([inner_puzzle.get_tree_hash(), reward_coin.name()]) # type: ignore[arg-type] + Program.to([inner_puzzle.get_tree_hash(), reward_coin.name()]) ) assert p2_singleton_puzzle.get_tree_hash() == reward_coin.puzzle_hash assert full_puzzle.get_tree_hash() == coin.puzzle_hash diff --git a/chia/pools/pool_wallet.py b/chia/pools/pool_wallet.py index 5724642ec190..918b2db888df 100644 --- a/chia/pools/pool_wallet.py +++ b/chia/pools/pool_wallet.py @@ -628,9 +628,7 @@ async def generate_launcher_spend( puzzle_hash: bytes32 = full_pooling_puzzle.get_tree_hash() pool_state_bytes = Program.to([("p", bytes(initial_target_state)), ("t", delay_time), ("h", delay_ph)]) announcement_set: Set[bytes32] = set() - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - announcement_message = Program.to([puzzle_hash, amount, pool_state_bytes]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 + announcement_message = Program.to([puzzle_hash, amount, pool_state_bytes]).get_tree_hash() announcement_set.add(Announcement(launcher_coin.name(), announcement_message).name()) create_launcher_tx_record: Optional[TransactionRecord] = await standard_wallet.generate_signed_transaction( @@ -645,10 +643,7 @@ async def generate_launcher_spend( ) assert create_launcher_tx_record is not None and create_launcher_tx_record.spend_bundle is not None - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - genesis_launcher_solution: Program = Program.to([puzzle_hash, amount, pool_state_bytes]) # type: ignore[assignment] # noqa E501 + genesis_launcher_solution: Program = Program.to([puzzle_hash, amount, pool_state_bytes]) launcher_cs: CoinSpend = CoinSpend( launcher_coin, diff --git a/chia/rpc/full_node_rpc_api.py b/chia/rpc/full_node_rpc_api.py index d2e44cfbd474..4c71cfb41141 100644 --- a/chia/rpc/full_node_rpc_api.py +++ b/chia/rpc/full_node_rpc_api.py @@ -559,14 +559,8 @@ async def get_puzzle_and_solution(self, request: Dict) -> Optional[Dict]: if error is not None: raise ValueError(f"Error: {error}") - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected - # "Program" [arg-type] - puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) # type: ignore[arg-type] - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected - # "Program" [arg-type] - solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) # type: ignore[arg-type] + puzzle_ser: SerializedProgram = SerializedProgram.from_program(Program.to(puzzle)) + solution_ser: SerializedProgram = SerializedProgram.from_program(Program.to(solution)) return {"coin_solution": CoinSpend(coin_record.coin, puzzle_ser, solution_ser)} async def get_additions_and_removals(self, request: Dict) -> Optional[Dict]: diff --git a/chia/types/blockchain_format/program.py b/chia/types/blockchain_format/program.py index cc3546e5515e..f81c03445fe3 100644 --- a/chia/types/blockchain_format/program.py +++ b/chia/types/blockchain_format/program.py @@ -103,10 +103,7 @@ def get_tree_hash(self, *args: bytes32) -> bytes32: def run_with_cost(self, max_cost: int, args) -> Tuple[int, "Program"]: prog_args = Program.to(args) cost, r = run_program(self, prog_args, max_cost) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[Any, SExp]", expected "Tuple[int, Program]") - # [return-value] - return cost, Program.to(r) # type: ignore[return-value] + return cost, Program.to(r) def run(self, args) -> "Program": cost, r = self.run_with_cost(INFINITE_COST, args) @@ -114,17 +111,12 @@ def run(self, args) -> "Program": def curry(self, *args) -> "Program": cost, r = curry(self, list(args)) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(r) # type: ignore[return-value] + return Program.to(r) def uncurry(self) -> Tuple["Program", "Program"]: r = uncurry(self) if r is None: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[Program, SExp]", expected - # "Tuple[Program, Program]") [return-value] - return self, self.to(0) # type: ignore[return-value] + return self, self.to(0) return r def as_int(self) -> int: @@ -304,10 +296,7 @@ def _run(self, max_cost: int, flags, *args) -> Tuple[int, Program]: max_cost, flags, ) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[Any, SExp]", expected "Tuple[int, Program]") - # [return-value] - return cost, Program.to(ret) # type: ignore[return-value] + return cost, Program.to(ret) NIL = Program.from_bytes(b"\x80") diff --git a/chia/wallet/cc_wallet/cc_utils.py b/chia/wallet/cc_wallet/cc_utils.py index b2b0c9fe5bde..129be86be2ec 100644 --- a/chia/wallet/cc_wallet/cc_utils.py +++ b/chia/wallet/cc_wallet/cc_utils.py @@ -54,9 +54,7 @@ def cc_puzzle_hash_for_inner_puzzle_hash(mod_code, genesis_coin_checker, inner_p def lineage_proof_for_cc_parent(parent_coin: Coin, parent_inner_puzzle_hash: bytes32) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to( # type: ignore[return-value] + return Program.to( ( 1, [parent_coin.parent_coin_info, parent_inner_puzzle_hash, parent_coin.amount], @@ -99,9 +97,7 @@ def coin_spend_for_lock_coin( def bundle_for_spendable_cc_list(spendable_cc: SpendableCC) -> Program: pair = (spendable_cc.coin.as_list(), spendable_cc.lineage_proof) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(pair) # type: ignore[return-value] + return Program.to(pair) def spend_bundle_for_spendable_ccs( diff --git a/chia/wallet/cc_wallet/cc_wallet.py b/chia/wallet/cc_wallet/cc_wallet.py index e08877edb44a..20ce7e6d8b07 100644 --- a/chia/wallet/cc_wallet/cc_wallet.py +++ b/chia/wallet/cc_wallet/cc_wallet.py @@ -297,10 +297,7 @@ async def coin_added(self, coin: Coin, height: uint32): inner_puzzle = await self.inner_puzzle_for_cc_puzhash(coin.puzzle_hash) lineage_proof = Program.to((1, [coin.parent_coin_info, inner_puzzle.get_tree_hash(), coin.amount])) - # TODO: address hint error and remove ignore - # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected - # "Optional[Program]" [arg-type] - await self.add_lineage(coin.name(), lineage_proof, True) # type: ignore[arg-type] + await self.add_lineage(coin.name(), lineage_proof, True) for name, lineage_proofs in self.cc_info.lineage_proofs: if coin.parent_coin_info == name: @@ -409,20 +406,14 @@ async def generate_zero_val_coin(self, send=True, exclude: List[Coin] = None) -> await self.add_lineage( eve_coin.name(), - # TODO: address hint error and remove ignore - # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected - # "Optional[Program]" [arg-type] - Program.to( # type: ignore[arg-type] + Program.to( ( 1, [eve_coin.parent_coin_info, cc_inner, eve_coin.amount], ) ), ) - # TODO: address hint error and remove ignore - # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected - # "Optional[Program]" [arg-type] - await self.add_lineage(eve_coin.parent_coin_info, Program.to((0, [origin.as_list(), 1]))) # type: ignore[arg-type] # noqa E501 + await self.add_lineage(eve_coin.parent_coin_info, Program.to((0, [origin.as_list(), 1]))) if send: regular_record = TransactionRecord( @@ -699,10 +690,7 @@ async def generate_new_coloured_coin(self, amount: uint64) -> SpendBundle: origin_id = origin.name() cc_inner_hash = await self.get_new_inner_hash() - # TODO: address hint error and remove ignore - # error: Argument 2 to "add_lineage" of "CCWallet" has incompatible type "SExp"; expected - # "Optional[Program]" [arg-type] - await self.add_lineage(origin_id, Program.to((0, [origin.as_list(), 0]))) # type: ignore[arg-type] + await self.add_lineage(origin_id, Program.to((0, [origin.as_list(), 0]))) genesis_coin_checker = create_genesis_or_zero_coin_checker(origin_id) minted_cc_puzzle_hash = cc_puzzle_hash_for_inner_puzzle_hash(CC_MOD, genesis_coin_checker, cc_inner_hash) diff --git a/chia/wallet/did_wallet/did_wallet.py b/chia/wallet/did_wallet/did_wallet.py index fb6d687474e7..60417b7a99b9 100644 --- a/chia/wallet/did_wallet/did_wallet.py +++ b/chia/wallet/did_wallet/did_wallet.py @@ -522,10 +522,7 @@ async def create_message_spend(self, messages: List[Tuple[int, bytes]], new_inne if new_innerpuzhash is None: new_innerpuzhash = innerpuz.get_tree_hash() # innerpuz solution is (mode amount messages new_puz) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - innersol: Program = Program.to([1, coin.amount, messages, new_innerpuzhash]) # type: ignore[assignment] + innersol: Program = Program.to([1, coin.amount, messages, new_innerpuzhash]) # full solution is (corehash parent_info my_amount innerpuz_reveal solution) full_puzzle: Program = did_wallet_puzzles.create_fullpuz( @@ -552,10 +549,8 @@ async def create_message_spend(self, messages: List[Tuple[int, bytes]], new_inne list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME # new_inner_puzhash amount message - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([new_innerpuzhash, coin.amount, messages]).get_tree_hash() # type: ignore[attr-defined] + Program.to([new_innerpuzhash, coin.amount, messages]).get_tree_hash() + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) @@ -597,10 +592,7 @@ async def create_exit_spend(self, puzhash: bytes32): coin = coins.pop() amount = coin.amount - 1 # innerpuz solution is (mode amount new_puzhash) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - innersol: Program = Program.to([0, amount, puzhash]) # type: ignore[assignment] + innersol: Program = Program.to([0, amount, puzhash]) # full solution is (corehash parent_info my_amount innerpuz_reveal solution) innerpuz: Program = self.did_info.current_inner @@ -627,10 +619,8 @@ async def create_exit_spend(self, puzhash: bytes32): # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([amount, puzhash]).get_tree_hash() # type: ignore[attr-defined] + Program.to([amount, puzhash]).get_tree_hash() + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) @@ -707,9 +697,7 @@ async def create_attestment( message_spend = did_wallet_puzzles.create_spend_for_message(coin.name(), recovering_coin_name, newpuz, pubkey) message_spend_bundle = SpendBundle([message_spend], AugSchemeMPL.aggregate([])) # sign for AGG_SIG_ME - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - to_sign = Program.to([innerpuz.get_tree_hash(), coin.amount, messages]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 + to_sign = Program.to([innerpuz.get_tree_hash(), coin.amount, messages]).get_tree_hash() message = to_sign + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA pubkey = did_wallet_puzzles.get_pubkey_from_innerpuz(innerpuz) index = await self.wallet_state_manager.puzzle_store.index_for_pubkey(pubkey) @@ -809,10 +797,7 @@ async def recovery_spend( assert self.did_info.origin_coin is not None # innersol is mode new_amount message new_inner_puzhash parent_innerpuzhash_amounts_for_recovery_ids pubkey recovery_list_reveal) # noqa - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type "Program") - # [assignment] - innersol: Program = Program.to( # type: ignore[assignment] + innersol: Program = Program.to( [ 2, coin.amount, @@ -957,9 +942,7 @@ async def generate_new_decentralised_id(self, amount: uint64) -> Optional[SpendB did_puzzle_hash = did_full_puz.get_tree_hash() announcement_set: Set[bytes32] = set() - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - announcement_message = Program.to([did_puzzle_hash, amount, bytes(0x80)]).get_tree_hash() # type: ignore[attr-defined] # noqa E501 + announcement_message = Program.to([did_puzzle_hash, amount, bytes(0x80)]).get_tree_hash() announcement_set.add(Announcement(launcher_coin.name(), announcement_message).name()) tx_record: Optional[TransactionRecord] = await self.standard_wallet.generate_signed_transaction( @@ -1026,10 +1009,8 @@ async def generate_eve_spend(self, coin: Coin, full_puzzle: Program, innerpuz: P # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] message = ( - Program.to([innerpuz.get_tree_hash(), coin.amount, []]).get_tree_hash() # type: ignore[attr-defined] + Program.to([innerpuz.get_tree_hash(), coin.amount, []]).get_tree_hash() + coin.name() + self.wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA ) diff --git a/chia/wallet/puzzles/genesis_by_coin_id_with_0.py b/chia/wallet/puzzles/genesis_by_coin_id_with_0.py index e375c9e547ee..3b473d64cca6 100644 --- a/chia/wallet/puzzles/genesis_by_coin_id_with_0.py +++ b/chia/wallet/puzzles/genesis_by_coin_id_with_0.py @@ -33,15 +33,11 @@ def genesis_coin_id_for_genesis_coin_checker( def lineage_proof_for_genesis(parent_coin: Coin) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to((0, [parent_coin.as_list(), 0])) # type: ignore[return-value] + return Program.to((0, [parent_coin.as_list(), 0])) def lineage_proof_for_zero(parent_coin: Coin) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to((0, [parent_coin.as_list(), 1])) # type: ignore[return-value] + return Program.to((0, [parent_coin.as_list(), 1])) def lineage_proof_for_coin(parent_coin: Coin) -> Program: diff --git a/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py b/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py index f58620833e78..53829902421b 100644 --- a/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py +++ b/chia/wallet/puzzles/genesis_by_puzzle_hash_with_0.py @@ -33,15 +33,11 @@ def genesis_puzzle_hash_for_genesis_coin_checker( def lineage_proof_for_genesis_puzzle(parent_coin: Coin) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to((0, [parent_coin.as_list(), 0])) # type: ignore[return-value] + return Program.to((0, [parent_coin.as_list(), 0])) def lineage_proof_for_zero(parent_coin: Coin) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to((0, [parent_coin.as_list(), 1])) # type: ignore[return-value] + return Program.to((0, [parent_coin.as_list(), 1])) def lineage_proof_for_coin(parent_coin: Coin) -> Program: diff --git a/chia/wallet/puzzles/p2_conditions.py b/chia/wallet/puzzles/p2_conditions.py index 5bf6fefb4d7b..f43bdecd9dea 100644 --- a/chia/wallet/puzzles/p2_conditions.py +++ b/chia/wallet/puzzles/p2_conditions.py @@ -22,6 +22,4 @@ def puzzle_for_conditions(conditions) -> Program: def solution_for_conditions(conditions) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([puzzle_for_conditions(conditions), 0]) # type: ignore[return-value] + return Program.to([puzzle_for_conditions(conditions), 0]) diff --git a/chia/wallet/puzzles/p2_delegated_conditions.py b/chia/wallet/puzzles/p2_delegated_conditions.py index 5d45fda67f26..f17522b1709f 100644 --- a/chia/wallet/puzzles/p2_delegated_conditions.py +++ b/chia/wallet/puzzles/p2_delegated_conditions.py @@ -18,6 +18,4 @@ def puzzle_for_pk(public_key: Program) -> Program: def solution_for_conditions(conditions: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return conditions.to([conditions]) # type: ignore[return-value] + return conditions.to([conditions]) diff --git a/chia/wallet/puzzles/p2_delegated_puzzle.py b/chia/wallet/puzzles/p2_delegated_puzzle.py index abebd8df58b1..a1bb20a50cb9 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle.py @@ -26,13 +26,8 @@ def puzzle_for_pk(public_key: bytes) -> Program: def solution_for_conditions(conditions) -> Program: delegated_puzzle = p2_conditions.puzzle_for_conditions(conditions) - # TODO: address hint error and remove ignore - # error: Argument 2 to "solution_for_delegated_puzzle" has incompatible type "SExp"; expected "Program" - # [arg-type] - return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) # type: ignore[arg-type] + return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) def solution_for_delegated_puzzle(delegated_puzzle: Program, delegated_solution: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return delegated_puzzle.to([delegated_puzzle, delegated_solution]) # type: ignore[return-value] + return delegated_puzzle.to([delegated_puzzle, delegated_solution]) diff --git a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py index 077375705cbc..1308234c24e0 100644 --- a/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py +++ b/chia/wallet/puzzles/p2_delegated_puzzle_or_hidden_puzzle.py @@ -79,9 +79,7 @@ def puzzle_for_pk(public_key: G1Element) -> Program: def solution_for_delegated_puzzle(delegated_puzzle: Program, solution: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([[], delegated_puzzle, solution]) # type: ignore[return-value] + return Program.to([[], delegated_puzzle, solution]) def solution_for_hidden_puzzle( @@ -89,14 +87,9 @@ def solution_for_hidden_puzzle( hidden_puzzle: Program, solution_to_hidden_puzzle: Program, ) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([hidden_public_key, hidden_puzzle, solution_to_hidden_puzzle]) # type: ignore[return-value] + return Program.to([hidden_public_key, hidden_puzzle, solution_to_hidden_puzzle]) def solution_for_conditions(conditions) -> Program: delegated_puzzle = puzzle_for_conditions(conditions) - # TODO: address hint error and remove ignore - # error: Argument 2 to "solution_for_delegated_puzzle" has incompatible type "SExp"; expected "Program" - # [arg-type] - return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) # type: ignore[arg-type] + return solution_for_delegated_puzzle(delegated_puzzle, Program.to(0)) diff --git a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py index 3df94bc3b0a9..6d8f18aec750 100644 --- a/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py +++ b/chia/wallet/puzzles/p2_m_of_n_delegate_direct.py @@ -17,6 +17,4 @@ def puzzle_for_m_of_public_key_list(m, public_key_list) -> Program: def solution_for_delegated_puzzle(m, selectors, puzzle, solution) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([selectors, puzzle, solution]) # type: ignore[return-value] + return Program.to([selectors, puzzle, solution]) diff --git a/chia/wallet/puzzles/p2_puzzle_hash.py b/chia/wallet/puzzles/p2_puzzle_hash.py index 2f529fd3b8d1..fcb0de2c1654 100644 --- a/chia/wallet/puzzles/p2_puzzle_hash.py +++ b/chia/wallet/puzzles/p2_puzzle_hash.py @@ -23,6 +23,4 @@ def puzzle_for_inner_puzzle(inner_puzzle: Program) -> Program: def solution_for_inner_puzzle_and_inner_solution(inner_puzzle: Program, inner_puzzle_solution: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([inner_puzzle, inner_puzzle_solution]) # type: ignore[return-value] + return Program.to([inner_puzzle, inner_puzzle_solution]) diff --git a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py index 38ac74a49177..a611c37623e0 100644 --- a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py +++ b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py @@ -27,18 +27,14 @@ def make_puzzle(amount: int) -> int: puzzle_prog = Program.to(binutils.assemble(puzzle)) print("Program: ", puzzle_prog) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - puzzle_hash = puzzle_prog.get_tree_hash() # type: ignore[attr-defined] + puzzle_hash = puzzle_prog.get_tree_hash() solution = "()" prefix = "xch" print("PH", puzzle_hash) print(f"Address: {encode_puzzle_hash(puzzle_hash, prefix)}") - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "run" [attr-defined] - result = puzzle_prog.run(solution) # type: ignore[attr-defined] + result = puzzle_prog.run(solution) error, result_human = parse_sexp_to_conditions(result) total_chia = 0 diff --git a/chia/wallet/puzzles/singleton_top_layer.py b/chia/wallet/puzzles/singleton_top_layer.py index 203c179d8635..a329dec61462 100644 --- a/chia/wallet/puzzles/singleton_top_layer.py +++ b/chia/wallet/puzzles/singleton_top_layer.py @@ -28,9 +28,7 @@ def generate_launcher_coin(coin: Coin, amount: uint64) -> Coin: # Wrap inner puzzles that are not singleton specific to strip away "truths" def adapt_inner_to_singleton(inner_puzzle: Program) -> Program: # (a (q . inner_puzzle) (r 1)) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([2, (1, inner_puzzle), [6, 1]]) # type: ignore[return-value] + return Program.to([2, (1, inner_puzzle), [6, 1]]) # Take standard coin and amount -> launch conditions & launcher coin solution @@ -63,12 +61,10 @@ def launch_conditions_and_coinsol( amount, ], ) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] assert_launcher_announcement = Program.to( [ ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, - std_hash(launcher_coin.name() + launcher_solution.get_tree_hash()), # type: ignore[attr-defined] + std_hash(launcher_coin.name() + launcher_solution.get_tree_hash()), ], ) @@ -83,10 +79,7 @@ def launch_conditions_and_coinsol( launcher_solution, # type: ignore[arg-type] ) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[List[SExp], CoinSpend]", expected - # "Tuple[List[Program], CoinSpend]") [return-value] - return conditions, launcher_coin_spend # type: ignore[return-value] + return conditions, launcher_coin_spend # Take a coin solution, return a lineage proof for their child to use in spends @@ -137,9 +130,7 @@ def solution_for_singleton( lineage_proof.amount, ] - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([parent_info, amount, inner_solution]) # type: ignore[return-value] + return Program.to([parent_info, amount, inner_solution]) # Create a coin that a singleton can claim @@ -160,16 +151,12 @@ def pay_to_singleton_or_delay_puzzle(launcher_id: bytes32, delay_time: uint64, d # Solution for EITHER p2_singleton or the claiming spend case for p2_singleton_or_delayed_puzhash def solution_for_p2_singleton(p2_singleton_coin: Coin, singleton_inner_puzhash: bytes32) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([singleton_inner_puzhash, p2_singleton_coin.name()]) # type: ignore[return-value] + return Program.to([singleton_inner_puzhash, p2_singleton_coin.name()]) # Solution for the delayed spend case for p2_singleton_or_delayed_puzhash def solution_for_p2_delayed_puzzle(output_amount: uint64) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([output_amount, []]) # type: ignore[return-value] + return Program.to([output_amount, []]) # Get announcement conditions for singleton solution and full CoinSpend for the claimed coin @@ -198,10 +185,7 @@ def claim_p2_singleton( puzzle, # type: ignore[arg-type] solution_for_p2_singleton(p2_singleton_coin, singleton_inner_puzhash), # type: ignore[arg-type] ) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[SExp, SExp, CoinSpend]", expected - # "Tuple[Program, Program, CoinSpend]") [return-value] - return assertion, announcement, claim_coinsol # type: ignore[return-value] + return assertion, announcement, claim_coinsol # Get the CoinSpend for spending to a delayed puzzle diff --git a/chia/wallet/puzzles/test_cc.py b/chia/wallet/puzzles/test_cc.py index 41f57c262188..289ee1dffaa1 100644 --- a/chia/wallet/puzzles/test_cc.py +++ b/chia/wallet/puzzles/test_cc.py @@ -68,9 +68,7 @@ def issue_cc_from_farmed_coin( # get a farmed coin farmed_puzzle = ANYONE_CAN_SPEND_PUZZLE - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - farmed_puzzle_hash = farmed_puzzle.get_tree_hash() # type: ignore[attr-defined] + farmed_puzzle_hash = farmed_puzzle.get_tree_hash() # mint a cc @@ -97,9 +95,7 @@ def solution_for_pay_to_any(puzzle_hash_amount_pairs: List[Tuple[bytes32, int]]) output_conditions = [ [ConditionOpcode.CREATE_COIN, puzzle_hash, amount] for puzzle_hash, amount in puzzle_hash_amount_pairs ] - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(output_conditions) # type: ignore[return-value] + return Program.to(output_conditions) def test_spend_through_n(mod_code, coin_checker_for_farmed_coin, n): @@ -187,9 +183,7 @@ def test_spend_zero_coin(mod_code: Program, coin_checker_for_farmed_coin): """ eve_inner_puzzle = ANYONE_CAN_SPEND_PUZZLE - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - eve_inner_puzzle_hash = eve_inner_puzzle.get_tree_hash() # type: ignore[attr-defined] + eve_inner_puzzle_hash = eve_inner_puzzle.get_tree_hash() total_minted = 0x111 diff --git a/chia/wallet/util/debug_spend_bundle.py b/chia/wallet/util/debug_spend_bundle.py index fc6d14361f79..d111456be15f 100644 --- a/chia/wallet/util/debug_spend_bundle.py +++ b/chia/wallet/util/debug_spend_bundle.py @@ -34,9 +34,7 @@ def coin_as_program(coin: Coin) -> Program: """ Convenience function for when putting `coin_info` into a solution. """ - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([coin.parent_coin_info, coin.puzzle_hash, coin.amount]) # type: ignore[return-value] + return Program.to([coin.parent_coin_info, coin.puzzle_hash, coin.amount]) def dump_coin(coin: Coin) -> str: @@ -202,6 +200,4 @@ def solution_for_pay_to_any(puzzle_hash_amount_pairs: Iterable[Tuple[bytes32, in output_conditions = [ [ConditionOpcode.CREATE_COIN, puzzle_hash, amount] for puzzle_hash, amount in puzzle_hash_amount_pairs ] - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(output_conditions) # type: ignore[return-value] + return Program.to(output_conditions) diff --git a/tests/clvm/test_puzzles.py b/tests/clvm/test_puzzles.py index ed8bede75f58..ba9ef308e808 100644 --- a/tests/clvm/test_puzzles.py +++ b/tests/clvm/test_puzzles.py @@ -103,10 +103,7 @@ def default_payments_and_conditions( (throwaway_puzzle_hash(initial_index + 2, key_lookup), (initial_index + 1) * 1000), ] conditions = Program.to([make_create_coin_condition(ph, amount) for ph, amount in payments]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[List[Tuple[Any, int]], SExp]", expected - # "Tuple[List[Tuple[Any, int]], Program]") [return-value] - return payments, conditions # type: ignore[return-value] + return payments, conditions def make_create_coin_condition(puzzle_hash, amount): diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index 0ef4eed1a472..560faa432d1e 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -49,9 +49,7 @@ def cleanup_keyring(keyring: TempKeyring): # We call it the `EASY_PUZZLE` because it's pretty easy to solve. EASY_PUZZLE = Program.to(assemble("1")) -# TODO: address hint error and remove ignore -# error: "SExp" has no attribute "get_tree_hash" [attr-defined] -EASY_PUZZLE_HASH = EASY_PUZZLE.get_tree_hash() # type: ignore[attr-defined] +EASY_PUZZLE_HASH = EASY_PUZZLE.get_tree_hash() def initial_blocks(block_count: int = 4) -> List[FullBlock]: diff --git a/tests/core/make_block_generator.py b/tests/core/make_block_generator.py index eead88d86a81..eb2fe82ed1ee 100644 --- a/tests/core/make_block_generator.py +++ b/tests/core/make_block_generator.py @@ -43,9 +43,7 @@ def make_fake_coin(index: int, puzzle_hash_db: dict) -> Coin: def conditions_for_payment(coin) -> Program: d: Dict = {} # a throwaway db since we don't care new_puzzle_hash = puzzle_hash_for_index(int.from_bytes(coin.puzzle_hash, "big"), d) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([[ConditionOpcode.CREATE_COIN, new_puzzle_hash, coin.amount]]) # type: ignore[return-value] + return Program.to([[ConditionOpcode.CREATE_COIN, new_puzzle_hash, coin.amount]]) def make_spend_bundle(count: int) -> SpendBundle: diff --git a/tests/generator/test_rom.py b/tests/generator/test_rom.py index 0e9eb2824669..efcbaa1ed2b7 100644 --- a/tests/generator/test_rom.py +++ b/tests/generator/test_rom.py @@ -43,14 +43,7 @@ "1380ff02ff05ff2b80ff018080" ) -# TODO: address hint error and remove ignore -# error: No overload variant of "bytes" matches argument type "SExp" [call-overload] -# note: Possible overload variants: -# note: def bytes(cls, ints: Iterable[int]) -> bytes -# note: def bytes(cls, length: int) -> bytes -# note: def bytes(cls, o: SupportsBytes) -> bytes -# note: <2 more non-matching overloads not shown> -COMPILED_GENERATOR_CODE = bytes(Program.to(compile_clvm_text(GENERATOR_CODE, []))) # type: ignore[call-overload] +COMPILED_GENERATOR_CODE = bytes(Program.to(compile_clvm_text(GENERATOR_CODE, []))) FIRST_GENERATOR = Program.to( binutils.assemble('((parent_id (c 1 (q "puzzle blob")) 50000 "solution is here" extra data for coin))') diff --git a/tests/pools/test_wallet_pool_store.py b/tests/pools/test_wallet_pool_store.py index 774f7518f4bc..066fa39dcbeb 100644 --- a/tests/pools/test_wallet_pool_store.py +++ b/tests/pools/test_wallet_pool_store.py @@ -31,15 +31,10 @@ def make_child_solution(coin_spend: CoinSpend, new_coin: Optional[Coin] = None) solution_prog = Program.to(binutils.assemble(solution)) if new_coin is None: new_coin = coin_spend.additions()[0] - # TODO: address hint error and remove ignore - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" - # [arg-type] - # error: Argument 1 to "from_program" of "SerializedProgram" has incompatible type "SExp"; expected "Program" - # [arg-type] sol: CoinSpend = CoinSpend( new_coin, - SerializedProgram.from_program(puzzle_prog), # type: ignore[arg-type] - SerializedProgram.from_program(solution_prog), # type: ignore[arg-type] + SerializedProgram.from_program(puzzle_prog), + SerializedProgram.from_program(solution_prog), ) return sol diff --git a/tests/wallet/test_singleton.py b/tests/wallet/test_singleton.py index f97b7c058664..bf3eba6f71a1 100644 --- a/tests/wallet/test_singleton.py +++ b/tests/wallet/test_singleton.py @@ -15,9 +15,7 @@ LAUNCHER_PUZZLE_HASH = LAUNCHER_PUZZLE.get_tree_hash() SINGLETON_MOD_HASH = SINGLETON_MOD.get_tree_hash() -# TODO: address hint error and remove ignore -# error: "SExp" has no attribute "get_tree_hash" [attr-defined] -LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() # type: ignore[attr-defined] +LAUNCHER_ID = Program.to(b"launcher-id").get_tree_hash() POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000") diff --git a/tests/wallet/test_singleton_lifecycle.py b/tests/wallet/test_singleton_lifecycle.py index 69914de7b4eb..77b269f17889 100644 --- a/tests/wallet/test_singleton_lifecycle.py +++ b/tests/wallet/test_singleton_lifecycle.py @@ -40,9 +40,7 @@ def check_coin_spend(coin_spend: CoinSpend): def adaptor_for_singleton_inner_puzzle(puzzle: Program) -> Program: # this is prety slow - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) # type: ignore[return-value] + return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) def launcher_conditions_and_spend_bundle( @@ -59,9 +57,7 @@ def launcher_conditions_and_spend_bundle( ) singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash() message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) # type: ignore[attr-defined] # noqa E501 + expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) expected_conditions = [] expected_conditions.append( Program.to( @@ -80,10 +76,7 @@ def launcher_conditions_and_spend_bundle( coin_spend = CoinSpend(launcher_coin, launcher_puzzle, launcher_solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) lineage_proof = Program.to([parent_coin_id, launcher_amount]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[SExp, Any, List[SExp], SpendBundle]", expected - # "Tuple[Program, Any, List[Program], SpendBundle]") [return-value] - return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle # type: ignore[return-value] + return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle def singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32, inner_puzzle: Program) -> Program: @@ -95,9 +88,7 @@ def singleton_puzzle_hash(launcher_id: Program, launcher_puzzle_hash: bytes32, i def solution_for_singleton_puzzle(lineage_proof: Program, my_amount: int, inner_solution: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([lineage_proof, my_amount, inner_solution]) # type: ignore[return-value] + return Program.to([lineage_proof, my_amount, inner_solution]) def p2_singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32) -> Program: diff --git a/tests/wallet/test_singleton_lifecycle_fast.py b/tests/wallet/test_singleton_lifecycle_fast.py index e711f0c167b7..505fc7380a8b 100644 --- a/tests/wallet/test_singleton_lifecycle_fast.py +++ b/tests/wallet/test_singleton_lifecycle_fast.py @@ -28,9 +28,7 @@ P2_SINGLETON_MOD_HASH = P2_SINGLETON_MOD.get_tree_hash() ANYONE_CAN_SPEND_PUZZLE = Program.to(1) -# TODO: address hint error and remove ignore -# error: "SExp" has no attribute "get_tree_hash" [attr-defined] -ANYONE_CAN_SPEND_WITH_PADDING_PUZZLE_HASH = Program.to(binutils.assemble("(a (q . 1) 3)")).get_tree_hash() # type: ignore[attr-defined] # noqa E501 +ANYONE_CAN_SPEND_WITH_PADDING_PUZZLE_HASH = Program.to(binutils.assemble("(a (q . 1) 3)")).get_tree_hash() POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000") @@ -97,9 +95,7 @@ def solve_launcher(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwa destination_puzzle_hash = from_kwargs(kwargs, "destination_puzzle_hash", bytes32) metadata = from_kwargs(kwargs, "metadata", List[Tuple[str, Program]]) solution = Program.to([destination_puzzle_hash, launcher_amount, metadata]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_anyone_can_spend(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -109,9 +105,7 @@ def solve_anyone_can_spend(solver: Solver, puzzle_db: PuzzleDB, args: List[Progr """ conditions = from_kwargs(kwargs, "conditions", List[Program]) solution = Program.to(conditions) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_anyone_can_spend_with_padding( @@ -120,9 +114,7 @@ def solve_anyone_can_spend_with_padding( """This is the puzzle `(a (q . 1) 3)`. It's only for testing.""" conditions = from_kwargs(kwargs, "conditions", List[Program]) solution = Program.to((0, conditions)) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -135,9 +127,7 @@ def solve_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kw lineage_proof = from_kwargs(kwargs, "lineage_proof", Program) coin_amount = from_kwargs(kwargs, "coin_amount", int) solution = inner_solution.to([lineage_proof, coin_amount, inner_solution.rest()]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_pool_member(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -148,16 +138,12 @@ def solve_pool_member(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], to_waiting_room = pool_member_spend_type == "to-waiting-room" if to_waiting_room: key_value_list = from_kwargs(kwargs, "key_value_list", List[Tuple[str, Program]]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([0, 1, 0, 0, key_value_list]) # type: ignore[return-value] + return Program.to([0, 1, 0, 0, key_value_list]) # it's an "absorb_pool_reward" type pool_reward_amount = from_kwargs(kwargs, "pool_reward_amount", int) pool_reward_height = from_kwargs(kwargs, "pool_reward_height", int) solution = Program.to([0, pool_reward_amount, pool_reward_height]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_pool_waiting_room(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -169,16 +155,12 @@ def solve_pool_waiting_room(solver: Solver, puzzle_db: PuzzleDB, args: List[Prog if exit_waiting_room: key_value_list = from_kwargs(kwargs, "key_value_list", List[Tuple[str, Program]]) destination_puzzle_hash = from_kwargs(kwargs, "destination_puzzle_hash", int) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([0, 1, key_value_list, destination_puzzle_hash]) # type: ignore[return-value] + return Program.to([0, 1, key_value_list, destination_puzzle_hash]) # it's an "absorb_pool_reward" type pool_reward_amount = from_kwargs(kwargs, "pool_reward_amount", int) pool_reward_height = from_kwargs(kwargs, "pool_reward_height", int) solution = Program.to([0, 0, pool_reward_amount, pool_reward_height]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], kwargs: Dict) -> Program: @@ -191,9 +173,7 @@ def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], singleton_inner_puzzle_hash = from_kwargs(kwargs, "singleton_inner_puzzle_hash") p2_singleton_coin_name = from_kwargs(kwargs, "p2_singleton_coin_name") solution = Program.to([singleton_inner_puzzle_hash, p2_singleton_coin_name]) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return solution # type: ignore[return-value] + return solution raise ValueError("can't solve `delayed-spend` yet") @@ -203,9 +183,7 @@ def solve_p2_singleton(solver: Solver, puzzle_db: PuzzleDB, args: List[Program], SOLVER.register_solver(SINGLETON_MOD_HASH, solve_singleton) SOLVER.register_solver(POOL_MEMBER_MOD.get_tree_hash(), solve_pool_member) SOLVER.register_solver(POOL_WAITINGROOM_MOD.get_tree_hash(), solve_pool_waiting_room) -# TODO: address hint error and remove ignore -# error: "SExp" has no attribute "get_tree_hash" [attr-defined] -SOLVER.register_solver(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), solve_anyone_can_spend) # type: ignore[attr-defined] +SOLVER.register_solver(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), solve_anyone_can_spend) SOLVER.register_solver(P2_SINGLETON_MOD_HASH, solve_p2_singleton) @@ -266,10 +244,7 @@ def update_state(self, puzzle_db: PuzzleDB, removals: List[CoinSpend]) -> int: lineage_proof = Program.to( [self.current_state.parent_coin_info, parent_inner_puzzle_hash, coin.amount] ) - # TODO: address hint error and remove ignore - # error: Incompatible types in assignment (expression has type "SExp", variable has type - # "Program") [assignment] - self.lineage_proof = lineage_proof # type: ignore[assignment] + self.lineage_proof = lineage_proof self.current_state = coin state_change_count += 1 return state_change_count @@ -286,9 +261,7 @@ def adaptor_for_singleton_inner_puzzle(puzzle: Program) -> Program: puzzle to work as a singleton inner puzzle. """ # this is pretty slow and lame - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) # type: ignore[return-value] + return Program.to(binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle))) def launcher_conditions_and_spend_bundle( @@ -306,9 +279,7 @@ def launcher_conditions_and_spend_bundle( puzzle_db.add_puzzle(singleton_full_puzzle) singleton_full_puzzle_hash = singleton_full_puzzle.get_tree_hash() message_program = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) # type: ignore[attr-defined] # noqa E501 + expected_announcement = Announcement(launcher_coin.name(), message_program.get_tree_hash()) expected_conditions = [] expected_conditions.append( Program.to( @@ -331,10 +302,7 @@ def launcher_conditions_and_spend_bundle( # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] coin_spend = CoinSpend(launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution) # type: ignore[arg-type] # noqa E501 spend_bundle = SpendBundle([coin_spend], G2Element()) - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[Any, List[SExp], SpendBundle]", expected - # "Tuple[Any, List[Program], SpendBundle]") [return-value] - return launcher_coin.name(), expected_conditions, spend_bundle # type: ignore[return-value] + return launcher_coin.name(), expected_conditions, spend_bundle def singleton_puzzle(launcher_id: Program, launcher_puzzle_hash: bytes32, inner_puzzle: Program) -> Program: @@ -346,9 +314,7 @@ def singleton_puzzle_hash(launcher_id: Program, launcher_puzzle_hash: bytes32, i def solution_for_singleton_puzzle(lineage_proof: Program, my_amount: int, inner_solution: Program) -> Program: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([lineage_proof, my_amount, inner_solution]) # type: ignore[return-value] + return Program.to([lineage_proof, my_amount, inner_solution]) def p2_singleton_puzzle_for_launcher( @@ -406,10 +372,7 @@ def claim_p2_singleton( Program.to([ConditionOpcode.CREATE_COIN, inner_puzzle_hash, 1]), Program.to([ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, expected_p2_singleton_announcement]), ] - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "Tuple[CoinSpend, List[SExp]]", expected - # "Tuple[CoinSpend, List[Program]]") [return-value] - return p2_singleton_coin_spend, singleton_conditions # type: ignore[return-value] + return p2_singleton_coin_spend, singleton_conditions def lineage_proof_for_coin_spend(coin_spend: CoinSpend) -> Program: @@ -420,18 +383,14 @@ def lineage_proof_for_coin_spend(coin_spend: CoinSpend) -> Program: inner_puzzle_hash = None if coin.puzzle_hash == LAUNCHER_PUZZLE_HASH: - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([parent_name, amount]) # type: ignore[return-value] + return Program.to([parent_name, amount]) full_puzzle = Program.from_bytes(bytes(coin_spend.puzzle_reveal)) _, args = full_puzzle.uncurry() _, __, ___, inner_puzzle = list(args.as_iter()) inner_puzzle_hash = inner_puzzle.get_tree_hash() - # TODO: address hint error and remove ignore - # error: Incompatible return value type (got "SExp", expected "Program") [return-value] - return Program.to([parent_name, inner_puzzle_hash, amount]) # type: ignore[return-value] + return Program.to([parent_name, inner_puzzle_hash, amount]) def create_throwaway_pubkey(seed: bytes) -> G1Element: @@ -452,19 +411,14 @@ def spend_coin_to_singleton( metadata = [("foo", "bar")] now = CoinTimestamp(10012300, 1) - # TODO: address hint error and remove ignore - # error: "SExp" has no attribute "get_tree_hash" [attr-defined] - farmed_coin = coin_store.farm_coin(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), now, amount=farmed_coin_amount) # type: ignore[attr-defined] # noqa E501 + farmed_coin = coin_store.farm_coin(ANYONE_CAN_SPEND_PUZZLE.get_tree_hash(), now, amount=farmed_coin_amount) now.seconds += 500 now.height += 1 launcher_amount: uint64 = uint64(1) launcher_puzzle = LAUNCHER_PUZZLE launcher_puzzle_hash = launcher_puzzle.get_tree_hash() - # TODO: address hint error and remove ignore - # error: Argument 1 to "adaptor_for_singleton_inner_puzzle" has incompatible type "SExp"; expected "Program" - # [arg-type] - initial_singleton_puzzle = adaptor_for_singleton_inner_puzzle(ANYONE_CAN_SPEND_PUZZLE) # type: ignore[arg-type] + initial_singleton_puzzle = adaptor_for_singleton_inner_puzzle(ANYONE_CAN_SPEND_PUZZLE) launcher_id, condition_list, launcher_spend_bundle = launcher_conditions_and_spend_bundle( puzzle_db, farmed_coin.name(), launcher_amount, initial_singleton_puzzle, metadata, launcher_puzzle ) From 2cd28707c2c410e870123687709f62a5f1e6a1da Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 24 Nov 2021 22:54:32 -0500 Subject: [PATCH 3/7] add .to_serialized_program() as needed in tests --- tests/clvm/test_puzzles.py | 5 +--- tests/core/full_node/test_conditions.py | 5 +--- tests/core/make_block_generator.py | 5 +--- tests/generator/test_compression.py | 5 +--- tests/wallet/test_singleton_lifecycle.py | 7 +++--- tests/wallet/test_singleton_lifecycle_fast.py | 24 +++++++------------ tests/wallet_tools.py | 20 +++++++--------- 7 files changed, 23 insertions(+), 48 deletions(-) diff --git a/tests/clvm/test_puzzles.py b/tests/clvm/test_puzzles.py index ba9ef308e808..d59e9afc5219 100644 --- a/tests/clvm/test_puzzles.py +++ b/tests/clvm/test_puzzles.py @@ -70,10 +70,7 @@ def do_test_spend( coin = coin_db.farm_coin(puzzle_hash, farm_time) # spend it - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal.to_serialized_program(), solution.to_serialized_program()) spend_bundle = SpendBundle([coin_spend], G2Element()) coin_db.update_coin_store_for_spend_bundle(spend_bundle, spend_time, MAX_BLOCK_COST_CLVM, COST_PER_BYTE) diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index 560faa432d1e..a976fc0945c4 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -121,10 +121,7 @@ async def check_conditions( blocks = initial_blocks() coin = list(blocks[spend_reward_index].get_included_reward_coins())[0] - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - coin_spend = CoinSpend(coin, EASY_PUZZLE, condition_solution) # type: ignore[arg-type] + coin_spend = CoinSpend(coin, EASY_PUZZLE.to_serialized_program(), condition_solution.to_serialized_program()) spend_bundle = SpendBundle([coin_spend], G2Element()) # now let's try to create a block with the spend bundle and ensure that it doesn't validate diff --git a/tests/core/make_block_generator.py b/tests/core/make_block_generator.py index eb2fe82ed1ee..089461d69ad4 100644 --- a/tests/core/make_block_generator.py +++ b/tests/core/make_block_generator.py @@ -55,10 +55,7 @@ def make_spend_bundle(count: int) -> SpendBundle: puzzle_reveal = puzzle_hash_db[coin.puzzle_hash] conditions = conditions_for_payment(coin) solution = solution_for_conditions(conditions) - # TODO: address hint error and remove ignore - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, solution.to_serialized_program()) coin_spends.append(coin_spend) spend_bundle = SpendBundle(coin_spends, blspy.G2Element()) diff --git a/tests/generator/test_compression.py b/tests/generator/test_compression.py index ad709d2888ea..97474d5e854c 100644 --- a/tests/generator/test_compression.py +++ b/tests/generator/test_compression.py @@ -78,10 +78,7 @@ def create_multiple_ref_generator(args: MultipleCompressorArg, spend_bundle: Spe GeneratorArg(FAKE_BLOCK_HEIGHT1, args.arg[0].generator), GeneratorArg(FAKE_BLOCK_HEIGHT2, args.arg[1].generator), ] - # TODO: address hint error and remove ignore - # error: Argument 1 to "BlockGenerator" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - return BlockGenerator(program, generator_args) # type: ignore[arg-type] + return BlockGenerator(program.to_serialized_program(), generator_args) def spend_bundle_to_coin_spend_entry_list(bundle: SpendBundle) -> List[Any]: diff --git a/tests/wallet/test_singleton_lifecycle.py b/tests/wallet/test_singleton_lifecycle.py index 77b269f17889..c7214f3972ae 100644 --- a/tests/wallet/test_singleton_lifecycle.py +++ b/tests/wallet/test_singleton_lifecycle.py @@ -70,10 +70,9 @@ def launcher_conditions_and_spend_bundle( ) ) launcher_solution = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - coin_spend = CoinSpend(launcher_coin, launcher_puzzle, launcher_solution) # type: ignore[arg-type] + coin_spend = CoinSpend( + launcher_coin, launcher_puzzle.to_serialized_program(), launcher_solution.to_serialized_program() + ) spend_bundle = SpendBundle([coin_spend], G2Element()) lineage_proof = Program.to([parent_coin_id, launcher_amount]) return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle diff --git a/tests/wallet/test_singleton_lifecycle_fast.py b/tests/wallet/test_singleton_lifecycle_fast.py index 505fc7380a8b..f5ed9da28830 100644 --- a/tests/wallet/test_singleton_lifecycle_fast.py +++ b/tests/wallet/test_singleton_lifecycle_fast.py @@ -221,12 +221,7 @@ def coin_spend_for_conditions(self, puzzle_db: PuzzleDB, **kwargs) -> CoinSpend: solution = solve_puzzle( puzzle_db, puzzle_reveal, lineage_proof=self.lineage_proof, coin_amount=coin.amount, **kwargs ) - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - return CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] + return CoinSpend(coin, puzzle_reveal.to_serialized_program(), solution.to_serialized_program()) def update_state(self, puzzle_db: PuzzleDB, removals: List[CoinSpend]) -> int: state_change_count = 0 @@ -298,9 +293,9 @@ def launcher_conditions_and_spend_bundle( launcher_amount=launcher_amount, metadata=metadata, ) - # TODO: address hint error and remove ignore - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - coin_spend = CoinSpend(launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution) # type: ignore[arg-type] # noqa E501 + coin_spend = CoinSpend( + launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution.to_serialized_program() + ) spend_bundle = SpendBundle([coin_spend], G2Element()) return launcher_coin.name(), expected_conditions, spend_bundle @@ -359,12 +354,10 @@ def claim_p2_singleton( singleton_inner_puzzle_hash=inner_puzzle_hash, p2_singleton_coin_name=p2_singleton_coin_name, ) - # TODO: address hint error and remove ignore - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] p2_singleton_coin_spend = CoinSpend( p2_singleton_coin, p2_singleton_puzzle.to_serialized_program(), - p2_singleton_solution, # type: ignore[arg-type] + p2_singleton_solution.to_serialized_program(), ) expected_p2_singleton_announcement = Announcement(p2_singleton_coin_name, bytes(b"$")).name() singleton_conditions = [ @@ -424,10 +417,9 @@ def spend_coin_to_singleton( ) conditions = Program.to(condition_list) - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, conditions) # type: ignore[arg-type] + coin_spend = CoinSpend( + farmed_coin, ANYONE_CAN_SPEND_PUZZLE.to_serialized_program(), conditions.to_serialized_program() + ) spend_bundle = SpendBundle.aggregate([launcher_spend_bundle, SpendBundle([coin_spend], G2Element())]) additions, removals = coin_store.update_coin_store_for_spend_bundle( diff --git a/tests/wallet_tools.py b/tests/wallet_tools.py index 1339b2625b31..efe1a5598f12 100644 --- a/tests/wallet_tools.py +++ b/tests/wallet_tools.py @@ -149,19 +149,15 @@ def generate_unsigned_transaction( ConditionWithArgs(ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, [primary_announcement_hash]) ) main_solution = self.make_solution(condition_dic) - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - spends.append(CoinSpend(coin, puzzle, main_solution)) # type: ignore[arg-type] + spends.append(CoinSpend(coin, puzzle.to_serialized_program(), main_solution.to_serialized_program())) else: - # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" - # [arg-type] - spends.append(CoinSpend(coin, puzzle, self.make_solution(secondary_coins_cond_dic))) # type: ignore[arg-type] # noqa E501 + spends.append( + CoinSpend( + coin, + puzzle.to_serialized_program(), + self.make_solution(secondary_coins_cond_dic).to_serialized_program(), + ) + ) return spends def sign_transaction(self, coin_spends: List[CoinSpend]) -> SpendBundle: From 5faa2bc4815420a4e31e4dffecf674feb1d7d440 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 24 Nov 2021 22:55:07 -0500 Subject: [PATCH 4/7] correct parameter ordering for benchmarking cost --- tests/util/benchmark_cost.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/util/benchmark_cost.py b/tests/util/benchmark_cost.py index ce5897a7e142..95fb0f015c68 100644 --- a/tests/util/benchmark_cost.py +++ b/tests/util/benchmark_cost.py @@ -126,10 +126,7 @@ def benchmark_all_operators(): puzzle_start = time.time() clvm_cost = 0 for i in range(0, 1000): - # TODO: address hint error and remove ignore - # error: Argument 1 to "run_with_cost" of "Program" has incompatible type "Program"; expected "int" - # [arg-type] - cost_run, sexp = puzzles[i].run_with_cost(solutions[i], INFINITE_COST) # type: ignore[arg-type] + cost_run, sexp = puzzles[i].run_with_cost(max_cost=INFINITE_COST, args=solutions[i]) clvm_cost += cost_run puzzle_end = time.time() From 89c873e1dff4d18378060fcdb990fdc296e03bae Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 24 Nov 2021 22:58:15 -0500 Subject: [PATCH 5/7] Revert "correct parameter ordering for benchmarking cost" This reverts commit 5faa2bc4815420a4e31e4dffecf674feb1d7d440. --- tests/util/benchmark_cost.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/util/benchmark_cost.py b/tests/util/benchmark_cost.py index 95fb0f015c68..ce5897a7e142 100644 --- a/tests/util/benchmark_cost.py +++ b/tests/util/benchmark_cost.py @@ -126,7 +126,10 @@ def benchmark_all_operators(): puzzle_start = time.time() clvm_cost = 0 for i in range(0, 1000): - cost_run, sexp = puzzles[i].run_with_cost(max_cost=INFINITE_COST, args=solutions[i]) + # TODO: address hint error and remove ignore + # error: Argument 1 to "run_with_cost" of "Program" has incompatible type "Program"; expected "int" + # [arg-type] + cost_run, sexp = puzzles[i].run_with_cost(solutions[i], INFINITE_COST) # type: ignore[arg-type] clvm_cost += cost_run puzzle_end = time.time() From f14b0a1a791ccba0ff0c063523f864c3d836586e Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 24 Nov 2021 22:58:24 -0500 Subject: [PATCH 6/7] Revert "add .to_serialized_program() as needed in tests" This reverts commit 2cd28707c2c410e870123687709f62a5f1e6a1da. --- tests/clvm/test_puzzles.py | 5 +++- tests/core/full_node/test_conditions.py | 5 +++- tests/core/make_block_generator.py | 5 +++- tests/generator/test_compression.py | 5 +++- tests/wallet/test_singleton_lifecycle.py | 7 +++--- tests/wallet/test_singleton_lifecycle_fast.py | 24 ++++++++++++------- tests/wallet_tools.py | 20 +++++++++------- 7 files changed, 48 insertions(+), 23 deletions(-) diff --git a/tests/clvm/test_puzzles.py b/tests/clvm/test_puzzles.py index d59e9afc5219..ba9ef308e808 100644 --- a/tests/clvm/test_puzzles.py +++ b/tests/clvm/test_puzzles.py @@ -70,7 +70,10 @@ def do_test_spend( coin = coin_db.farm_coin(puzzle_hash, farm_time) # spend it - coin_spend = CoinSpend(coin, puzzle_reveal.to_serialized_program(), solution.to_serialized_program()) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) coin_db.update_coin_store_for_spend_bundle(spend_bundle, spend_time, MAX_BLOCK_COST_CLVM, COST_PER_BYTE) diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index a976fc0945c4..560faa432d1e 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -121,7 +121,10 @@ async def check_conditions( blocks = initial_blocks() coin = list(blocks[spend_reward_index].get_included_reward_coins())[0] - coin_spend = CoinSpend(coin, EASY_PUZZLE.to_serialized_program(), condition_solution.to_serialized_program()) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(coin, EASY_PUZZLE, condition_solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) # now let's try to create a block with the spend bundle and ensure that it doesn't validate diff --git a/tests/core/make_block_generator.py b/tests/core/make_block_generator.py index 089461d69ad4..eb2fe82ed1ee 100644 --- a/tests/core/make_block_generator.py +++ b/tests/core/make_block_generator.py @@ -55,7 +55,10 @@ def make_spend_bundle(count: int) -> SpendBundle: puzzle_reveal = puzzle_hash_db[coin.puzzle_hash] conditions = conditions_for_payment(coin) solution = solution_for_conditions(conditions) - coin_spend = CoinSpend(coin, puzzle_reveal, solution.to_serialized_program()) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + coin_spend = CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] coin_spends.append(coin_spend) spend_bundle = SpendBundle(coin_spends, blspy.G2Element()) diff --git a/tests/generator/test_compression.py b/tests/generator/test_compression.py index 97474d5e854c..ad709d2888ea 100644 --- a/tests/generator/test_compression.py +++ b/tests/generator/test_compression.py @@ -78,7 +78,10 @@ def create_multiple_ref_generator(args: MultipleCompressorArg, spend_bundle: Spe GeneratorArg(FAKE_BLOCK_HEIGHT1, args.arg[0].generator), GeneratorArg(FAKE_BLOCK_HEIGHT2, args.arg[1].generator), ] - return BlockGenerator(program.to_serialized_program(), generator_args) + # TODO: address hint error and remove ignore + # error: Argument 1 to "BlockGenerator" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return BlockGenerator(program, generator_args) # type: ignore[arg-type] def spend_bundle_to_coin_spend_entry_list(bundle: SpendBundle) -> List[Any]: diff --git a/tests/wallet/test_singleton_lifecycle.py b/tests/wallet/test_singleton_lifecycle.py index c7214f3972ae..77b269f17889 100644 --- a/tests/wallet/test_singleton_lifecycle.py +++ b/tests/wallet/test_singleton_lifecycle.py @@ -70,9 +70,10 @@ def launcher_conditions_and_spend_bundle( ) ) launcher_solution = Program.to([singleton_full_puzzle_hash, launcher_amount, metadata]) - coin_spend = CoinSpend( - launcher_coin, launcher_puzzle.to_serialized_program(), launcher_solution.to_serialized_program() - ) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(launcher_coin, launcher_puzzle, launcher_solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], G2Element()) lineage_proof = Program.to([parent_coin_id, launcher_amount]) return lineage_proof, launcher_coin.name(), expected_conditions, spend_bundle diff --git a/tests/wallet/test_singleton_lifecycle_fast.py b/tests/wallet/test_singleton_lifecycle_fast.py index f5ed9da28830..505fc7380a8b 100644 --- a/tests/wallet/test_singleton_lifecycle_fast.py +++ b/tests/wallet/test_singleton_lifecycle_fast.py @@ -221,7 +221,12 @@ def coin_spend_for_conditions(self, puzzle_db: PuzzleDB, **kwargs) -> CoinSpend: solution = solve_puzzle( puzzle_db, puzzle_reveal, lineage_proof=self.lineage_proof, coin_amount=coin.amount, **kwargs ) - return CoinSpend(coin, puzzle_reveal.to_serialized_program(), solution.to_serialized_program()) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + return CoinSpend(coin, puzzle_reveal, solution) # type: ignore[arg-type] def update_state(self, puzzle_db: PuzzleDB, removals: List[CoinSpend]) -> int: state_change_count = 0 @@ -293,9 +298,9 @@ def launcher_conditions_and_spend_bundle( launcher_amount=launcher_amount, metadata=metadata, ) - coin_spend = CoinSpend( - launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution.to_serialized_program() - ) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(launcher_coin, SerializedProgram.from_program(launcher_puzzle), solution) # type: ignore[arg-type] # noqa E501 spend_bundle = SpendBundle([coin_spend], G2Element()) return launcher_coin.name(), expected_conditions, spend_bundle @@ -354,10 +359,12 @@ def claim_p2_singleton( singleton_inner_puzzle_hash=inner_puzzle_hash, p2_singleton_coin_name=p2_singleton_coin_name, ) + # TODO: address hint error and remove ignore + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] p2_singleton_coin_spend = CoinSpend( p2_singleton_coin, p2_singleton_puzzle.to_serialized_program(), - p2_singleton_solution.to_serialized_program(), + p2_singleton_solution, # type: ignore[arg-type] ) expected_p2_singleton_announcement = Announcement(p2_singleton_coin_name, bytes(b"$")).name() singleton_conditions = [ @@ -417,9 +424,10 @@ def spend_coin_to_singleton( ) conditions = Program.to(condition_list) - coin_spend = CoinSpend( - farmed_coin, ANYONE_CAN_SPEND_PUZZLE.to_serialized_program(), conditions.to_serialized_program() - ) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, conditions) # type: ignore[arg-type] spend_bundle = SpendBundle.aggregate([launcher_spend_bundle, SpendBundle([coin_spend], G2Element())]) additions, removals = coin_store.update_coin_store_for_spend_bundle( diff --git a/tests/wallet_tools.py b/tests/wallet_tools.py index efe1a5598f12..1339b2625b31 100644 --- a/tests/wallet_tools.py +++ b/tests/wallet_tools.py @@ -149,15 +149,19 @@ def generate_unsigned_transaction( ConditionWithArgs(ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT, [primary_announcement_hash]) ) main_solution = self.make_solution(condition_dic) - spends.append(CoinSpend(coin, puzzle.to_serialized_program(), main_solution.to_serialized_program())) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + spends.append(CoinSpend(coin, puzzle, main_solution)) # type: ignore[arg-type] else: - spends.append( - CoinSpend( - coin, - puzzle.to_serialized_program(), - self.make_solution(secondary_coins_cond_dic).to_serialized_program(), - ) - ) + # TODO: address hint error and remove ignore + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + spends.append(CoinSpend(coin, puzzle, self.make_solution(secondary_coins_cond_dic))) # type: ignore[arg-type] # noqa E501 return spends def sign_transaction(self, coin_spends: List[CoinSpend]) -> SpendBundle: From f4cd4264a58efa22b2067b0df52e9794b6733316 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Thu, 25 Nov 2021 00:05:14 -0500 Subject: [PATCH 7/7] update the type hint error comments --- chia/wallet/cc_wallet/cc_utils.py | 5 +++-- chia/wallet/cc_wallet/cc_wallet.py | 2 +- chia/wallet/did_wallet/did_wallet.py | 14 ++++++++------ chia/wallet/puzzles/prefarm/spend_prefarm.py | 12 ++++++++---- chia/wallet/puzzles/singleton_top_layer.py | 2 +- chia/wallet/puzzles/test_cc.py | 6 +++--- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/chia/wallet/cc_wallet/cc_utils.py b/chia/wallet/cc_wallet/cc_utils.py index 129be86be2ec..db074f7aca35 100644 --- a/chia/wallet/cc_wallet/cc_utils.py +++ b/chia/wallet/cc_wallet/cc_utils.py @@ -90,7 +90,7 @@ def coin_spend_for_lock_coin( coin = Coin(coin.name(), puzzle_reveal.get_tree_hash(), uint64(0)) # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] coin_spend = CoinSpend(coin, puzzle_reveal, Program.to(0)) # type: ignore[arg-type] return coin_spend @@ -168,7 +168,8 @@ def spend_bundle_for_spendable_ccs( # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] coin_spend = CoinSpend(input_coins[index], puzzle_reveal, Program.to(solution)) # type: ignore[arg-type] coin_spends.append(coin_spend) diff --git a/chia/wallet/cc_wallet/cc_wallet.py b/chia/wallet/cc_wallet/cc_wallet.py index 20ce7e6d8b07..53c09ce7a385 100644 --- a/chia/wallet/cc_wallet/cc_wallet.py +++ b/chia/wallet/cc_wallet/cc_wallet.py @@ -755,7 +755,7 @@ async def create_spend_bundle_relative_amount(self, cc_amount, zero_coin: Coin = # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] list_of_solutions.append(CoinSpend(coin, puzzle_reveal, Program.to(solution))) # type: ignore[arg-type] diff --git a/chia/wallet/did_wallet/did_wallet.py b/chia/wallet/did_wallet/did_wallet.py index 60417b7a99b9..856afb9beb52 100644 --- a/chia/wallet/did_wallet/did_wallet.py +++ b/chia/wallet/did_wallet/did_wallet.py @@ -545,7 +545,7 @@ async def create_message_spend(self, messages: List[Tuple[int, bytes]], new_inne # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME # new_inner_puzhash amount message @@ -616,7 +616,7 @@ async def create_exit_spend(self, puzhash: bytes32): # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME message = ( @@ -692,7 +692,7 @@ async def create_attestment( # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] message_spend = did_wallet_puzzles.create_spend_for_message(coin.name(), recovering_coin_name, newpuz, pubkey) message_spend_bundle = SpendBundle([message_spend], AugSchemeMPL.aggregate([])) @@ -831,7 +831,7 @@ async def recovery_spend( # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] index = await self.wallet_state_manager.puzzle_store.index_for_pubkey(pubkey) @@ -954,7 +954,8 @@ async def generate_new_decentralised_id(self, amount: uint64) -> Optional[SpendB # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] launcher_cs = CoinSpend(launcher_coin, genesis_launcher_puz, genesis_launcher_solution) # type: ignore[arg-type] # noqa E501 launcher_sb = SpendBundle([launcher_cs], AugSchemeMPL.aggregate([])) eve_coin = Coin(launcher_coin.name(), did_puzzle_hash, amount) @@ -1006,7 +1007,8 @@ async def generate_eve_spend(self, coin: Coin, full_puzzle: Program, innerpuz: P # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" # [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] list_of_solutions = [CoinSpend(coin, full_puzzle, fullsol)] # type: ignore[arg-type] # sign for AGG_SIG_ME message = ( diff --git a/chia/wallet/puzzles/prefarm/spend_prefarm.py b/chia/wallet/puzzles/prefarm/spend_prefarm.py index 0c03163b02d8..382c7eb7a1d0 100644 --- a/chia/wallet/puzzles/prefarm/spend_prefarm.py +++ b/chia/wallet/puzzles/prefarm/spend_prefarm.py @@ -64,12 +64,16 @@ async def main() -> None: p_solution = Program.to(binutils.assemble("()")) # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] sb_farmer = SpendBundle([CoinSpend(farmer_prefarm, p_farmer_2, p_solution)], G2Element()) # type: ignore[arg-type] # noqa E501 # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" + # [arg-type] sb_pool = SpendBundle([CoinSpend(pool_prefarm, p_pool_2, p_solution)], G2Element()) # type: ignore[arg-type] print("\n\n\nConditions") diff --git a/chia/wallet/puzzles/singleton_top_layer.py b/chia/wallet/puzzles/singleton_top_layer.py index a329dec61462..d1ba75d690f9 100644 --- a/chia/wallet/puzzles/singleton_top_layer.py +++ b/chia/wallet/puzzles/singleton_top_layer.py @@ -72,7 +72,7 @@ def launch_conditions_and_coinsol( # TODO: address hint error and remove ignore # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] launcher_coin_spend = CoinSpend( launcher_coin, SINGLETON_LAUNCHER, # type: ignore[arg-type] diff --git a/chia/wallet/puzzles/test_cc.py b/chia/wallet/puzzles/test_cc.py index 289ee1dffaa1..218128103fcc 100644 --- a/chia/wallet/puzzles/test_cc.py +++ b/chia/wallet/puzzles/test_cc.py @@ -84,8 +84,8 @@ def issue_cc_from_farmed_coin( solution = Program.to(output_conditions) # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] - # error: Argument 3 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] + # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] coin_spend = CoinSpend(farmed_coin, farmed_puzzle, solution) # type: ignore[arg-type] spend_bundle = SpendBundle([coin_spend], NULL_SIGNATURE) return genesis_coin_checker, spend_bundle @@ -210,7 +210,7 @@ def test_spend_zero_coin(mod_code: Program, coin_checker_for_farmed_coin): solution = solution_for_pay_to_any([(wrapped_cc_puzzle_hash, 0)]) # TODO: address hint error and remove ignore - # error: Argument 2 to "CoinSpend" has incompatible type "SExp"; expected "SerializedProgram" [arg-type] + # error: Argument 2 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] # error: Argument 3 to "CoinSpend" has incompatible type "Program"; expected "SerializedProgram" [arg-type] coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, solution) # type: ignore[arg-type] spendable_cc_list = spendable_cc_list_from_coin_spend(coin_spend, hash_to_puzzle_f)