diff --git a/chia/rpc/wallet_rpc_api.py b/chia/rpc/wallet_rpc_api.py index 213cf202fcd3..cf374703cb6e 100644 --- a/chia/rpc/wallet_rpc_api.py +++ b/chia/rpc/wallet_rpc_api.py @@ -1943,9 +1943,7 @@ async def get_offer_summary(self, request: Dict[str, Any]) -> EndpointResult: "also": { **info["also"], "flags": ProofsChecker.from_program( - uncurry_puzzle( - Program(assemble(info["also"]["proofs_checker"])) # type: ignore[no-untyped-call] - ) + uncurry_puzzle(Program(assemble(info["also"]["proofs_checker"]))) ).flags, }, } diff --git a/chia/wallet/puzzle_drivers.py b/chia/wallet/puzzle_drivers.py index 754d0f68ba5c..5aa6817f5ebc 100644 --- a/chia/wallet/puzzle_drivers.py +++ b/chia/wallet/puzzle_drivers.py @@ -104,7 +104,7 @@ def decode_info_value(cls: Any, value: Any) -> Any: else: if value == "()": # special case return Program.to([]) - expression: SExp = assemble(value) # type: ignore + expression: SExp = assemble(value) if expression.atom is None: return Program(expression) else: diff --git a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py index 78f4d01bee2e..7a95250a896d 100644 --- a/chia/wallet/puzzles/prefarm/make_prefarm_ph.py +++ b/chia/wallet/puzzles/prefarm/make_prefarm_ph.py @@ -29,7 +29,7 @@ def make_puzzle(amount: int) -> int: # print(puzzle) # TODO: properly type hint clvm_tools - assembled_puzzle = binutils.assemble(puzzle) # type: ignore[no-untyped-call] + assembled_puzzle = binutils.assemble(puzzle) puzzle_prog = Program.to(assembled_puzzle) print("Program: ", puzzle_prog) puzzle_hash = puzzle_prog.get_tree_hash() diff --git a/chia/wallet/puzzles/prefarm/spend_prefarm.py b/chia/wallet/puzzles/prefarm/spend_prefarm.py index 758d27aac1c4..12aa5fbc997a 100644 --- a/chia/wallet/puzzles/prefarm/spend_prefarm.py +++ b/chia/wallet/puzzles/prefarm/spend_prefarm.py @@ -53,14 +53,10 @@ async def main() -> None: ph2 = decode_puzzle_hash(address2) p_farmer_2 = SerializedProgram.to( - binutils.assemble( - f"(q . ((51 0x{ph1.hex()} {farmer_amounts}) " f"(51 0x{ph2.hex()} {farmer_amounts})))" - ) # type: ignore[no-untyped-call] + binutils.assemble(f"(q . ((51 0x{ph1.hex()} {farmer_amounts}) " f"(51 0x{ph2.hex()} {farmer_amounts})))") ) p_pool_2 = SerializedProgram.to( - binutils.assemble( - f"(q . ((51 0x{ph1.hex()} {pool_amounts}) " f"(51 0x{ph2.hex()} {pool_amounts})))" - ) # type: ignore[no-untyped-call] + binutils.assemble(f"(q . ((51 0x{ph1.hex()} {pool_amounts}) " f"(51 0x{ph2.hex()} {pool_amounts})))") ) print(f"Ph1: {ph1.hex()}") @@ -68,7 +64,7 @@ async def main() -> None: assert ph1.hex() == "1b7ab2079fa635554ad9bd4812c622e46ee3b1875a7813afba127bb0cc9794f9" assert ph2.hex() == "6f184a7074c925ef8688ce56941eb8929be320265f824ec7e351356cc745d38a" - p_solution = SerializedProgram.to(binutils.assemble("()")) # type: ignore[no-untyped-call] + p_solution = SerializedProgram.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()) diff --git a/setup.py b/setup.py index 3611d6fb6817..bd56783e1e10 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ "chiabip158==1.3", # bip158-style wallet filters "chiapos==2.0.3", # proof of space "clvm==0.9.8", - "clvm_tools==0.4.7", # Currying, Program.to, other conveniences + "clvm_tools==0.4.8", # Currying, Program.to, other conveniences "chia_rs==0.5.2", "clvm-tools-rs==0.1.40", # Rust implementation of clvm_tools' compiler "aiohttp==3.9.1", # HTTP server for full node rpc diff --git a/tests/core/full_node/test_conditions.py b/tests/core/full_node/test_conditions.py index 8eed161b1a70..0cfb097db575 100644 --- a/tests/core/full_node/test_conditions.py +++ b/tests/core/full_node/test_conditions.py @@ -137,7 +137,7 @@ class TestConditions: async def test_unknown_conditions_with_cost( self, opcode: int, expected_cost: int, bt: BlockTools, consensus_mode: ConsensusMode ) -> None: - conditions = Program.to(assemble(f"(({opcode} 1337))")) # type: ignore[no-untyped-call] + conditions = Program.to(assemble(f"(({opcode} 1337))")) additions, removals, new_block = await check_conditions(bt, conditions) if consensus_mode != ConsensusMode.HARD_FORK_2_0: @@ -164,7 +164,7 @@ async def test_unknown_conditions_with_cost( async def test_softfork_condition( self, condition: str, expected_cost: int, bt: BlockTools, consensus_mode: ConsensusMode ) -> None: - conditions = Program.to(assemble(condition)) # type: ignore[no-untyped-call] + conditions = Program.to(assemble(condition)) additions, removals, new_block = await check_conditions(bt, conditions) if consensus_mode != ConsensusMode.HARD_FORK_2_0: @@ -267,7 +267,7 @@ async def test_softfork_condition( ], ) async def test_condition(self, opcode: ConditionOpcode, value: int, expected: Err, bt: BlockTools) -> None: - conditions = Program.to(assemble(f"(({opcode[0]} {value}))")) # type: ignore[no-untyped-call] + conditions = Program.to(assemble(f"(({opcode[0]} {value}))")) await check_conditions(bt, conditions, expected_err=expected) @pytest.mark.anyio @@ -276,22 +276,14 @@ async def test_invalid_my_id(self, bt: BlockTools) -> None: coin = blocks[-2].get_included_reward_coins()[0] wrong_name = bytearray(coin.name()) wrong_name[-1] ^= 1 - conditions = Program.to( - assemble( - f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{wrong_name.hex()}))" - ) # type: ignore[no-untyped-call] - ) + conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{wrong_name.hex()}))")) await check_conditions(bt, conditions, expected_err=Err.ASSERT_MY_COIN_ID_FAILED) @pytest.mark.anyio async def test_valid_my_id(self, bt: BlockTools) -> None: blocks = await initial_blocks(bt) coin = blocks[-2].get_included_reward_coins()[0] - conditions = Program.to( - assemble( - f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{coin.name().hex()}))" - ) # type: ignore[no-untyped-call] - ) + conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{coin.name().hex()}))")) await check_conditions(bt, conditions) @pytest.mark.anyio @@ -300,7 +292,7 @@ async def test_invalid_coin_announcement(self, bt: BlockTools) -> None: coin = blocks[-2].get_included_reward_coins()[0] announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test_bad") conditions = Program.to( - assemble( # type: ignore[no-untyped-call] + assemble( f"(({ConditionOpcode.CREATE_COIN_ANNOUNCEMENT[0]} 'test')" f"({ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT[0]} 0x{announce.msg_calc.hex()}))" ) @@ -313,7 +305,7 @@ async def test_valid_coin_announcement(self, bt: BlockTools) -> None: coin = blocks[-2].get_included_reward_coins()[0] announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test") conditions = Program.to( - assemble( # type: ignore[no-untyped-call] + assemble( f"(({ConditionOpcode.CREATE_COIN_ANNOUNCEMENT[0]} 'test')" f"({ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT[0]} 0x{announce.msg_calc.hex()}))" ) @@ -324,7 +316,7 @@ async def test_valid_coin_announcement(self, bt: BlockTools) -> None: async def test_invalid_puzzle_announcement(self, bt: BlockTools) -> None: announce = AssertPuzzleAnnouncement(asserted_ph=EASY_PUZZLE_HASH, asserted_msg=b"test_bad") conditions = Program.to( - assemble( # type: ignore[no-untyped-call] + assemble( f"(({ConditionOpcode.CREATE_PUZZLE_ANNOUNCEMENT[0]} 'test')" f"({ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT[0]} 0x{announce.msg_calc.hex()}))" ) @@ -335,7 +327,7 @@ async def test_invalid_puzzle_announcement(self, bt: BlockTools) -> None: async def test_valid_puzzle_announcement(self, bt: BlockTools) -> None: announce = AssertPuzzleAnnouncement(asserted_ph=EASY_PUZZLE_HASH, asserted_msg=b"test") conditions = Program.to( - assemble( # type: ignore[no-untyped-call] + assemble( f"(({ConditionOpcode.CREATE_PUZZLE_ANNOUNCEMENT[0]} 'test')" f"({ConditionOpcode.ASSERT_PUZZLE_ANNOUNCEMENT[0]} 0x{announce.msg_calc.hex()}))" ) @@ -387,7 +379,7 @@ async def test_announce_conditions_limit( conditions = b"" if prefix != "": - conditions += b"\xff" + assemble(prefix).as_bin() # type: ignore[no-untyped-call] + conditions += b"\xff" + assemble(prefix).as_bin() cond = condition.format( coin="0x" + coin.name().hex(), @@ -396,7 +388,7 @@ async def test_announce_conditions_limit( pann="0x" + puzzle_announcement.msg_calc.hex(), ) - conditions += (b"\xff" + assemble(cond).as_bin()) * num # type: ignore[no-untyped-call] + conditions += (b"\xff" + assemble(cond).as_bin()) * num conditions += b"\x80" conditions_program = Program.from_bytes(conditions) diff --git a/tests/core/test_cost_calculation.py b/tests/core/test_cost_calculation.py index 772925e3a451..c7c180c3f964 100644 --- a/tests/core/test_cost_calculation.py +++ b/tests/core/test_cost_calculation.py @@ -146,7 +146,7 @@ async def test_mempool_mode(softfork_height: int, bt: BlockTools) -> None: binutils.assemble( f"(q ((0x3d2331635a58c0d49912bc1427d7db51afe3f20a7b4bcaffa17ee250dcbcbfaa {disassembly} 300" f" (() (q . (({unknown_opcode} '00000000000000000000000000000000' 0x0cbba106e000))) ()))))" - ).as_bin() # type: ignore[no-untyped-call] + ).as_bin() ) generator = BlockGenerator(program, [], []) npc_result: NPCResult = get_name_puzzle_conditions( @@ -183,9 +183,7 @@ async def test_clvm_mempool_mode(softfork_height: int) -> None: # if-condition, that depends on executing an unknown operator # ("0xfe"). In mempool mode, this should fail, but in non-mempool # mode, the unknown operator should be treated as if it returns (). - program = SerializedProgram.from_bytes( - binutils.assemble(f"(i (0xfe (q . 0)) (q . ()) {disassembly})").as_bin() # type: ignore[no-untyped-call] - ) + program = SerializedProgram.from_bytes(binutils.assemble(f"(i (0xfe (q . 0)) (q . ()) {disassembly})").as_bin()) generator = BlockGenerator(program, [], []) npc_result: NPCResult = get_name_puzzle_conditions( generator, @@ -236,9 +234,7 @@ async def test_clvm_max_cost(softfork_height: int) -> None: # mode, the unknown operator should be treated as if it returns (). # the CLVM program has a cost of 391969 program = SerializedProgram.from_bytes( - binutils.assemble( - f"(i (softfork (q . 10000000)) (q . ()) {disassembly})" - ).as_bin() # type: ignore[no-untyped-call] + binutils.assemble(f"(i (softfork (q . 10000000)) (q . ()) {disassembly})").as_bin() ) # ensure we fail if the program exceeds the cost @@ -273,7 +269,7 @@ async def test_standard_tx(benchmark_runner: BenchmarkRunner) -> None: conditions = binutils.assemble( "((51 0x699eca24f2b6f4b25b16f7a418d0dc4fc5fce3b9145aecdda184158927738e3e 10)" " (51 0x847bb2385534070c39a39cc5dfdc7b35e2db472dc0ab10ab4dec157a2178adbf 0x00cbba106df6))" - ) # type: ignore[no-untyped-call] + ) solution_program = SerializedProgram.from_bytes( bytes(p2_delegated_puzzle_or_hidden_puzzle.solution_for_conditions(conditions)) ) diff --git a/tests/core/test_program.py b/tests/core/test_program.py index 39fb2a6d38ca..cea5e494ec10 100644 --- a/tests/core/test_program.py +++ b/tests/core/test_program.py @@ -34,7 +34,7 @@ def test_serialized_program_to() -> None: Program.to([1, 2, 3]), SerializedProgram.to([1, 2, 3]), b"123", - binutils.assemble(prg), # type: ignore[no-untyped-call] + binutils.assemble(prg), [b"1", b"2", b"3"], (b"1", (b"2", b"3")), None, diff --git a/tests/core/util/test_streamable.py b/tests/core/util/test_streamable.py index ec12d851ee74..e16cd33372d4 100644 --- a/tests/core/util/test_streamable.py +++ b/tests/core/util/test_streamable.py @@ -652,7 +652,7 @@ def test_ambiguous_deserialization_program() -> None: class TestClassProgram(Streamable): a: Program - program = Program.to(binutils.assemble("()")) # type: ignore[no-untyped-call] # TODO, add typing in clvm_tools + program = Program.to(binutils.assemble("()")) TestClassProgram.from_bytes(bytes(program)) diff --git a/tests/generator/test_compression.py b/tests/generator/test_compression.py index f69115c92cee..07b0aacd30fa 100644 --- a/tests/generator/test_compression.py +++ b/tests/generator/test_compression.py @@ -217,7 +217,7 @@ def test_decompress_puzzle(self) -> None: def test_decompress_cse(self) -> None: """Decompress a single CSE / CoinSpendEntry""" - cse0 = binutils.assemble( # type: ignore[no-untyped-call] + cse0 = binutils.assemble( "((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (() (q (51 0x6b7a83babea1eec790c947db4464ab657dbe9b887fe9acc247062847b8c2a8a9 0x0186a0)) ())))" ) cost, out = DECOMPRESS_CSE.run_with_cost( @@ -228,7 +228,7 @@ def test_decompress_cse(self) -> None: print(out) def test_decompress_cse_with_prefix(self) -> None: - cse0 = binutils.assemble( # type: ignore[no-untyped-call] + cse0 = binutils.assemble( "((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (() (q (51 0x6b7a83babea1eec790c947db4464ab657dbe9b887fe9acc247062847b8c2a8a9 0x0186a0)) ())))" ) @@ -245,10 +245,10 @@ def test_decompress_cse_with_prefix(self) -> None: def test_block_program_zero(self) -> None: "Decompress a list of CSEs" - cse1 = binutils.assemble( # type: ignore[no-untyped-call] + cse1 = binutils.assemble( "(((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (() (q (51 0x6b7a83babea1eec790c947db4464ab657dbe9b887fe9acc247062847b8c2a8a9 0x0186a0)) ()))))" ) - cse2 = binutils.assemble( # type: ignore[no-untyped-call] + cse2 = binutils.assemble( """ ( ((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) @@ -286,10 +286,10 @@ def test_block_program_zero(self) -> None: print(out) def test_block_program_zero_with_curry(self) -> None: - cse1 = binutils.assemble( # type: ignore[no-untyped-call] + cse1 = binutils.assemble( "(((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) (0xb081963921826355dcb6c355ccf9c2637c18adf7d38ee44d803ea9ca41587e48c913d8d46896eb830aeadfc13144a8eac3 (() (q (51 0x6b7a83babea1eec790c947db4464ab657dbe9b887fe9acc247062847b8c2a8a9 0x0186a0)) ()))))" ) - cse2 = binutils.assemble( # type: ignore[no-untyped-call] + cse2 = binutils.assemble( """ ( ((0x0000000000000000000000000000000000000000000000000000000000000000 0x0186a0) diff --git a/tests/generator/test_rom.py b/tests/generator/test_rom.py index f98a38c73338..a4ab6333d514 100644 --- a/tests/generator/test_rom.py +++ b/tests/generator/test_rom.py @@ -46,7 +46,7 @@ COMPILED_GENERATOR_CODE = bytes(Program.to(compile_clvm_text(GENERATOR_CODE, []))) # type: ignore[no-untyped-call] FIRST_GENERATOR = Program.to( - binutils.assemble( # type: ignore[no-untyped-call] + binutils.assemble( """ ((0x0000000000000000000000000000000000000000000000000000000000000000 1 50000 ((51 0x0000000000000000000000000000000000000000000000000000000000000001 500)) @@ -54,7 +54,7 @@ ) ).as_bin() -SECOND_GENERATOR = Program.to(binutils.assemble("(extra data for block)")).as_bin() # type: ignore[no-untyped-call] +SECOND_GENERATOR = Program.to(binutils.assemble("(extra data for block)")).as_bin() def to_sp(sexp: bytes) -> SerializedProgram: diff --git a/tests/wallet/nft_wallet/test_ownership_outer_puzzle.py b/tests/wallet/nft_wallet/test_ownership_outer_puzzle.py index 0a5a3ff4bb88..a4091853aa25 100644 --- a/tests/wallet/nft_wallet/test_ownership_outer_puzzle.py +++ b/tests/wallet/nft_wallet/test_ownership_outer_puzzle.py @@ -21,7 +21,7 @@ def test_ownership_outer_puzzle() -> None: # (mod (current_owner conditions solution) # (list current_owner () conditions) # ) - transfer_program = assemble( # type: ignore + transfer_program = assemble( """ (c 2 (c () (c 5 ()))) """ diff --git a/tests/wallet/test_singleton.py b/tests/wallet/test_singleton.py index 134e14599a46..74f17df68ff8 100644 --- a/tests/wallet/test_singleton.py +++ b/tests/wallet/test_singleton.py @@ -45,7 +45,7 @@ def test_only_odd_coins() -> None: solution = Program.to( [ (singleton_mod_hash, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)), - Program.to(binutils.assemble("(q (51 0xcafef00d 200))")), # type: ignore[no-untyped-call] + Program.to(binutils.assemble("(q (51 0xcafef00d 200))")), [0xDEADBEEF, 0xCAFEF00D, 200], 200, [], @@ -59,7 +59,7 @@ def test_only_odd_coins() -> None: solution = Program.to( [ (singleton_mod_hash, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)), - Program.to(binutils.assemble("(q (51 0xcafef00d 201))")), # type: ignore[no-untyped-call] + Program.to(binutils.assemble("(q (51 0xcafef00d 201))")), [0xDEADBEEF, 0xCAFED00D, 210], 205, 0, @@ -74,7 +74,7 @@ def test_only_one_odd_coin_created() -> None: solution = Program.to( [ (singleton_mod_hash, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)), - Program.to(binutils.assemble(clsp)), # type: ignore[no-untyped-call] + Program.to(binutils.assemble(clsp)), [0xDEADBEEF, 0xCAFEF00D, 411], 411, [], @@ -88,7 +88,7 @@ def test_only_one_odd_coin_created() -> None: solution = Program.to( [ (singleton_mod_hash, (LAUNCHER_ID, LAUNCHER_PUZZLE_HASH)), - Program.to(binutils.assemble(clsp)), # type: ignore[no-untyped-call] + Program.to(binutils.assemble(clsp)), [0xDEADBEEF, 0xCAFEF00D, 411], 411, [], diff --git a/tests/wallet/test_singleton_lifecycle_fast.py b/tests/wallet/test_singleton_lifecycle_fast.py index 1a96bfceb8bd..14df1cbf2786 100644 --- a/tests/wallet/test_singleton_lifecycle_fast.py +++ b/tests/wallet/test_singleton_lifecycle_fast.py @@ -32,7 +32,7 @@ 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() # type: ignore[no-untyped-call] # 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") @@ -273,7 +273,7 @@ def adaptor_for_singleton_inner_puzzle(puzzle: Program) -> Program: puzzle to work as a singleton inner puzzle. """ # this is pretty slow and lame - program = binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle)) # type: ignore[no-untyped-call] + program = binutils.assemble("(a (q . %s) 3)" % binutils.disassemble(puzzle)) # TODO: Remove cast when we improve typing return cast(Program, Program.to(program)) @@ -299,9 +299,9 @@ def launcher_conditions_and_spend_bundle( ) expected_conditions = [] clsp = f"(0x{ConditionOpcode.ASSERT_COIN_ANNOUNCEMENT.hex()} 0x{expected_announcement.msg_calc})" - expected_conditions.append(Program.to(binutils.assemble(clsp))) # type: ignore[no-untyped-call] + expected_conditions.append(Program.to(binutils.assemble(clsp))) clsp = f"(0x{ConditionOpcode.CREATE_COIN.hex()} 0x{launcher_puzzle_hash} {launcher_amount})" - expected_conditions.append(Program.to(binutils.assemble(clsp))) # type: ignore[no-untyped-call] + expected_conditions.append(Program.to(binutils.assemble(clsp))) solution = solve_puzzle( puzzle_db, launcher_puzzle,