From 11a1667c1a32c1d52610d5493b1815580daf57ec Mon Sep 17 00:00:00 2001 From: Matthew Howard Date: Thu, 7 Nov 2024 15:47:38 +0000 Subject: [PATCH] formatting and file hash --- chia/_tests/clvm/test_member_puzzles.py | 79 ++++++++++--------- .../puzzles/deployed_puzzle_hashes.json | 2 +- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/chia/_tests/clvm/test_member_puzzles.py b/chia/_tests/clvm/test_member_puzzles.py index b3fc84516b53..ad2c40efa0b1 100644 --- a/chia/_tests/clvm/test_member_puzzles.py +++ b/chia/_tests/clvm/test_member_puzzles.py @@ -3,17 +3,18 @@ import itertools from typing import List -from chia.util.hash import std_hash import pytest from chia_rs import AugSchemeMPL, G2Element from chia._tests.clvm.test_custody_architecture import ACSDPuzValidator from chia.clvm.spend_sim import CostLogger, sim_and_client from chia.consensus.default_constants import DEFAULT_CONSTANTS +from chia.types.blockchain_format.coin import Coin from chia.types.blockchain_format.program import Program -from chia.types.coin_spend import CoinSpend, make_spend +from chia.types.coin_spend import make_spend from chia.types.mempool_inclusion_status import MempoolInclusionStatus -from chia.types.spend_bundle import SpendBundle +from chia.util.hash import std_hash +from chia.util.ints import uint64 from chia.wallet.conditions import CreateCoinAnnouncement from chia.wallet.puzzles.custody.custody_architecture import ( DelegatedPuzzleAndSolution, @@ -26,10 +27,8 @@ ) from chia.wallet.puzzles.custody.member_puzzles.member_puzzles import BLSMember, SingletonMember from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import puzzle_for_synthetic_public_key -from chia.types.blockchain_format.coin import Coin from chia.wallet.singleton import SINGLETON_LAUNCHER_PUZZLE, SINGLETON_LAUNCHER_PUZZLE_HASH, SINGLETON_TOP_LAYER_MOD from chia.wallet.wallet_spend_bundle import WalletSpendBundle -from chia.wallet.wallet import make_spend @pytest.mark.anyio @@ -102,6 +101,7 @@ async def test_bls_member(cost_logger: CostLogger) -> None: await sim.farm_block() await sim.rewind(block_height) + @pytest.mark.anyio @pytest.mark.parametrize( "with_restrictions", @@ -167,7 +167,7 @@ async def test_2_of_4_bls_members(cost_logger: CostLogger, with_restrictions: bo sig, keys[index].sign( delegated_puzzle_hash + m_of_n_coin.name() + DEFAULT_CONSTANTS.AGG_SIG_ME_ADDITIONAL_DATA - ), # noqa) + ), ] ) assert isinstance(m_of_n.puzzle, MofN) @@ -204,11 +204,12 @@ async def test_2_of_4_bls_members(cost_logger: CostLogger, with_restrictions: bo await sim.farm_block() await sim.rewind(block_height) + @pytest.mark.anyio async def test_singleton_member(cost_logger: CostLogger) -> None: async with sim_and_client() as (sim, client): delegated_puzzle = Program.to(1) - + sk = AugSchemeMPL.key_gen(bytes.fromhex(str(0) * 64)) pk = sk.public_key() puz = puzzle_for_synthetic_public_key(pk) @@ -217,32 +218,36 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: coin = (await client.get_coin_records_by_puzzle_hashes([puz.get_tree_hash()], include_spent_coins=False))[ 0 ].coin - eve_coin = Coin(coin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, 1) + eve_coin = Coin(coin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH, uint64(1)) singleton_struct = (SINGLETON_TOP_LAYER_MOD.get_tree_hash(), (eve_coin.name(), SINGLETON_LAUNCHER_PUZZLE_HASH)) - singleton_innerpuz = Program.to(( - 1, - [ - [51, Program.to(1).get_tree_hash(), 1], - [66, 0x07, delegated_puzzle.get_tree_hash(), coin.name()] - ], # create approval message to singleton member puzzle - )) + singleton_innerpuz = Program.to( + ( + 1, + [ + [51, Program.to(1).get_tree_hash(), 1], + [66, 0x07, delegated_puzzle.get_tree_hash(), coin.name()], + ], # create approval message to singleton member puzzle + ) + ) singleton_puzzle = SINGLETON_TOP_LAYER_MOD.curry(singleton_struct, singleton_innerpuz) launcher_solution = Program.to([singleton_puzzle.get_tree_hash(), 1, 0]) conditions_list = [ - [51, SINGLETON_LAUNCHER_PUZZLE_HASH, 1], - [61, std_hash(eve_coin.name() + launcher_solution.get_tree_hash())] + [51, SINGLETON_LAUNCHER_PUZZLE_HASH, 1], + [61, std_hash(eve_coin.name() + launcher_solution.get_tree_hash())], ] solution = Program.to([0, (1, conditions_list), 0]) - - msg = bytes(solution.rest().first().get_tree_hash()) + coin.name() + DEFAULT_CONSTANTS.AGG_SIG_ME_ADDITIONAL_DATA + + msg = ( + bytes(solution.rest().first().get_tree_hash()) + coin.name() + DEFAULT_CONSTANTS.AGG_SIG_ME_ADDITIONAL_DATA + ) sig = sk.sign(msg) sb = WalletSpendBundle( [ make_spend(coin, puz, solution), make_spend(eve_coin, SINGLETON_LAUNCHER_PUZZLE, launcher_solution), ], - sig + sig, ) result = await client.push_tx( cost_logger.add_cost( @@ -254,9 +259,11 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: await sim.farm_block(singleton_puzzle.get_tree_hash()) - singleton_coin = (await client.get_coin_records_by_puzzle_hashes([singleton_puzzle.get_tree_hash()], include_spent_coins=False))[ - 0 - ].coin + singleton_coin = ( + await client.get_coin_records_by_puzzle_hashes( + [singleton_puzzle.get_tree_hash()], include_spent_coins=False + ) + )[0].coin singleton_member_puzzle = PuzzleWithRestrictions(0, [], SingletonMember(eve_coin.name())) memo = PuzzleHint( @@ -278,23 +285,19 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: # Farm and find coin await sim.farm_block(singleton_member_puzzle.puzzle_hash()) - coin = (await client.get_coin_records_by_puzzle_hashes([singleton_member_puzzle.puzzle_hash()], include_spent_coins=False))[ - 0 - ].coin + coin = ( + await client.get_coin_records_by_puzzle_hashes( + [singleton_member_puzzle.puzzle_hash()], include_spent_coins=False + ) + )[0].coin block_height = sim.block_height # Create an announcements to be asserted in the delegated puzzle announcement = CreateCoinAnnouncement(msg=b"foo", coin_id=coin.name()) # Make solution for singleton - fullsol = Program.to( - [ - [eve_coin.parent_coin_info, 1], - 1, - 0 - ] - ) - + fullsol = Program.to([[eve_coin.parent_coin_info, 1], 1, 0]) + sb = WalletSpendBundle( [ make_spend( @@ -303,7 +306,9 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: singleton_member_puzzle.solve( [], [], - Program.to([[singleton_coin.parent_coin_info, singleton_innerpuz.get_tree_hash(), 1]]), # singleton member puzzle only requires singleton's current innerpuz + Program.to( + [[singleton_coin.parent_coin_info, singleton_innerpuz.get_tree_hash(), 1]] + ), # singleton member puzzle only requires singleton's current innerpuz DelegatedPuzzleAndSolution( delegated_puzzle, Program.to( @@ -319,7 +324,7 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: singleton_coin, singleton_puzzle, fullsol, - ) + ), ], G2Element(), ) @@ -331,4 +336,4 @@ async def test_singleton_member(cost_logger: CostLogger) -> None: ) assert result == (MempoolInclusionStatus.SUCCESS, None) await sim.farm_block() - await sim.rewind(block_height) \ No newline at end of file + await sim.rewind(block_height) diff --git a/chia/wallet/puzzles/deployed_puzzle_hashes.json b/chia/wallet/puzzles/deployed_puzzle_hashes.json index 819cda56b628..8fc2007d2695 100644 --- a/chia/wallet/puzzles/deployed_puzzle_hashes.json +++ b/chia/wallet/puzzles/deployed_puzzle_hashes.json @@ -67,7 +67,7 @@ "singleton_launcher": "eff07522495060c066f66f32acc2a77e3a3e737aca8baea4d1a64ea4cdc13da9", "singleton_top_layer": "24e044101e57b3d8c908b8a38ad57848afd29d3eecc439dba45f4412df4954fd", "singleton_top_layer_v1_1": "7faa3253bfddd1e0decb0906b2dc6247bbc4cf608f58345d173adb63e8b47c9f", - "singleton_member": "414fa2172f3ed47c0504aa93b78acf4c656f69312332224cddc3fc2d7cc9a832", + "singleton_member": "b2a3576fb4737ff078caef58bcbd5464968d92ebdd493814f495c75fd6d769de", "standard_vc_backdoor_puzzle": "fbce76408ebaf9b3d0b8cd90cc68607755eeca67cd7432d5eea85f3f498cc002", "std_parent_morpher": "8c3f1dc2e46c0d7ec4c2cbd007e23c0368ff8f80c5bc0101647a5c27626ebce6", "test_generator_deserialize": "52add794fc76e89512e4a063c383418bda084c8a78c74055abe80179e4a7832c",